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 |
|---|---|---|---|---|---|---|---|---|---|
#ifndef HASH_FN_H
#define HASH_FN_H
#define STRING_ALPHABET_SIZE 26
#define SEED 3234213
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>
typedef unsigned long int ulint;
typedef struct hash_fn_t {
mpz_t p;
mpz_t a;
mpz_t b;
mpz_t m;
gmp_randstate_t state;
} hash_fn;
/**
* Initialize the parameters for the function.
*
*/
void hash_fn_init(hash_fn *f, ulint table_size);
/**
* Generate values for p, a, and b.
*
*/
void hash_fn_generate(hash_fn *f, mpz_t u);
/**
* Apply hash function to a string.
*
*/
void hash_string(const hash_fn *f, mpz_t out, const char *string);
/**
* Apply hash function to an integer.
*
*/
void hash_integer(const hash_fn *f, mpz_t out, mpz_t integer);
/**
* Deallocate the function's parameters.
*
*/
void hash_fn_destroy(hash_fn *f);
#endif
| pjantrania/perfect-hashing | types/hash_fn.h | C | mit | 834 | [
30522,
1001,
2065,
13629,
2546,
23325,
1035,
1042,
2078,
1035,
1044,
1001,
9375,
23325,
1035,
1042,
2078,
1035,
1044,
1001,
9375,
5164,
1035,
12440,
1035,
2946,
2656,
1001,
9375,
6534,
25392,
20958,
17134,
1001,
2421,
1026,
2358,
20617,
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... |
from victor.exceptions import (
FieldValidationException,
FieldTypeConversionError,
FieldRequiredError,
VectorInputTypeError
)
class Field(object):
required = True
"""Field is required and an exception will be raised if missing"""
missing_value = None
"""Value to use when field is missing and not required"""
strict = False
"""Field value must pass validation or an exception will be raised"""
cast_cls = None
data = None
def __init__(self, required=True, missing_value=None, strict=False):
self.required = required
self.missing_value = missing_value
self.strict = strict
def _validate(self, value):
return True
def _cast_type(self, value):
return self.cast_cls(value)
def set_data(self, value):
if self.strict:
if not self._validate(value):
raise FieldValidationException('%s does not '
'except this value'
% self.__class__.__name__)
elif self.cast_cls is not None:
value = self._cast_type(value)
self.data = value
class CharField(Field):
pass
class StringField(Field):
cast_cls = str
def _validate(self, value):
if not isinstance(value, (str, unicode)):
return False
return True
class IntField(Field):
cast_cls = int
_cast_fallback_value = 0
def __init__(self, *args, **kwargs):
super(IntField, self).__init__(*args, **kwargs)
if self.missing_value is None:
self.missing_value = self._cast_fallback_value
def _cast_type(self, value):
try:
return self.cast_cls(value)
except ValueError, exc:
if self.missing_value is False:
raise FieldTypeConversionError('Could not convert '
'data or use missing_value: %s'
% exc)
return self.missing_value
class FloatField(IntField):
cast_class = float
_cast_fallback_value = 0.0
class ListField(Field):
cls = None
"""Field class to represent list items"""
def __init__(self, cls, *args, **kwargs):
assert isinstance(cls, Field), 'cls is not a valid Field instance'
self.cls = cls
super(ListField, self).__init__(*args, **kwargs)
def _validate(self, value):
if not isinstance(value, (list, tuple)):
raise FieldValidationException('ListField requires data '
'to be a sequence type')
for x in value:
self.cls.set_data(value)
self.data = value
return True
class Vector(object):
def __init__(self):
self.input_data = {}
self._fields = {}
self._map = {}
self._required = []
self._setup_fields()
def get_name(self):
return self.__class__.__name__
def __call__(self, data):
return self.input(data)
def input(self, data):
self._map = {}
if not isinstance(data, dict):
raise VectorInputTypeError('Vector input not a dictionary')
self._validate(data)
self._map_attrs(data)
def _setup_fields(self):
self._fields = {}
for a in dir(self):
v = getattr(self, a)
if isinstance(v, Field):
self._fields[a] = v
if v.required:
self._required.append(a)
self._reset_fields()
def _reset_fields(self):
for f in self.get_fields():
setattr(self, f, None)
def _validate(self, input_data):
for f in self._required:
if f not in input_data:
raise FieldRequiredError('Missing field %s is a required field'
% f)
for k, v in input_data.iteritems():
if k in self.get_fields():
f = self.get_field(k)
f.set_data(v)
def _map_attrs(self, input_data):
self.input_data = input_data
for k, v in self.input_data.iteritems():
if k in self.get_fields():
# setattr(self, k, self.get_field(k).data)
self._map[k] = self.get_field(k).data
else:
# setattr(self, k, v)
self._map[k] = v
for k, v in self._map.iteritems():
setattr(self, k, v)
def get_fields(self):
return self._fields
def get_field(self, name):
return self._fields[name]
@property
def data(self):
return self._map
| alexph/victor | victor/vector.py | Python | mit | 4,717 | [
30522,
2013,
5125,
1012,
11790,
12324,
1006,
2492,
10175,
8524,
3508,
10288,
24422,
1010,
2492,
13874,
8663,
27774,
2121,
29165,
1010,
2492,
2890,
15549,
5596,
2121,
29165,
1010,
9207,
2378,
18780,
13874,
2121,
29165,
1007,
2465,
2492,
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... |
<html>
<head>
<meta charset='utf-8'>
<style>
.pass {
font-weight: bold;
color: green;
}
.fail {
font-weight: bold;
color: red;
}
</style>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function SputnikError(message)
{
this.message = message;
}
SputnikError.prototype.toString = function ()
{
return 'SputnikError: ' + this.message;
};
var sputnikException;
function testPrint(msg)
{
var span = document.createElement("span");
document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
span.innerHTML = msg + '<br />';
}
function escapeHTML(text)
{
return text.toString().replace(/&/g, "&").replace(/</g, "<");
}
function printTestPassed(msg)
{
testPrint('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
}
function printTestFailed(msg)
{
testPrint('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
}
function testFailed(msg)
{
throw new SputnikError(msg);
}
var successfullyParsed = false;
</script>
</head>
<body>
<p>S7.8.3_A3.4_T4</p>
<div id='console'></div>
<script>
try {
/**
* @name: S7.8.3_A3.4_T4;
* @section: 7.8.3;
* @assertion: DecimalLiteral :: DecimalIntegerLiteral. DecimalDigigts ExponentPart;
* @description: ExponentPart :: E -DecimalDigits;
*/
//CHECK#0
if (0.0E-1 !== 0) {
testFailed('#0: 0.0E-1 === 0');
}
//CHECK#1
if (1.1E-1 !== 0.11) {
testFailed('#1: 1.1E-1 === 0.11');
}
//CHECK#2
if (2.2E-1 !== 0.22) {
testFailed('#2: 2.2E-1 === 0.22');
}
//CHECK#3
if (3.3E-1 !== 0.33) {
testFailed('#3: 3.3E-1 === 0.33');
}
//CHECK#4
if (4.4E-1 !== 0.44) {
testFailed('#4: 4.4E-1 === 0.44');
}
//CHECK#5
if (5.5E-1 !== 0.55) {
testFailed('#5: 5.5E-1 === 0.55');
}
//CHECK#6
if (6.6E-1 !== 0.66) {
testFailed('#6: 6.E-1 === 0.66');
}
//CHECK#7
if (7.7E-1 !== 0.77) {
testFailed('#7: 7.7E-1 === 0.77');
}
//CHECK#8
if (8.8E-1 !== 0.88) {
testFailed('#8: 8.8E-1 === 0.88');
}
//CHECK#9
if (9.9E-1 !== 0.99) {
testFailed('#9: 9.9E-1 === 0.99');
}
} catch (ex) {
sputnikException = ex;
}
var successfullyParsed = true;
</script>
<script>
if (!successfullyParsed)
printTestFailed('successfullyParsed is not set');
else if (sputnikException)
printTestFailed(sputnikException);
else
printTestPassed("");
testPrint('<br /><span class="pass">TEST COMPLETE</span>');
</script>
</body>
</html>
| youfoh/webkit-efl | LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A3.4_T4.html | HTML | lgpl-2.1 | 2,420 | [
30522,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1005,
21183,
2546,
1011,
1022,
1005,
1028,
1026,
2806,
1028,
1012,
3413,
1063,
15489,
1011,
3635,
1024,
7782,
1025,
3609,
1024,
2665,
1025,
1065,
1012,
8246,
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... |
\documentclass[10pt]{article}
% Эта строка — комментарий, она не будет показана в выходном файле
\usepackage{ucs}
\usepackage[a4paper, total={6in, 10in}]{geometry}
\usepackage{listings}
\usepackage[utf8x]{inputenc } % Включаем поддержку UTF8
\title{CIA MTA 2. Lab 7}
\date{28 September 2016}
\author{Ali Abdulmadzhidov}
\begin{document}
\renewcommand*\rmdefault{cmss}
\maketitle
\section{MTA loop\newline}
\subsection{Step by step \newline}
\begin{enumerate}
\item Add alias to /etc/mail/aliases, where st15.os3.su is neighboor whom i send mail in triangle loop
\begin{verbatim}
loop: loop@st15.os3.su
\end{verbatim}
\item Generate aliases.db
\begin{verbatim}
cd /etc/mail
newaliases
\end{verbatim}
\item Restart sendmail
\begin{verbatim}
service sendmail restart
\end{verbatim}
\end{enumerate}
\subsection{Answers \newline}
\begin{enumerate}
\item It'll go through all computers and it'll be reciverd to sender with error that maximum hops was made. For my sendmail is max is 25 hops, on 26'th it'll stop.
\item On my sendmail i can change max hops count by adding line to config file and recompile it
\begin{verbatim}
define(`confMAX_HOP',hops)
\end{verbatim}
\end{enumerate}
\begin{verbatim}
From MAILER-DAEMON Tue Sep 27 15:06:03 2016
Return-Path: <MAILER-DAEMON>
Received: from st15.os3.su (mail.st15.os3.su [188.130.155.48])
by mail.st9.os3.su (8.15.2/8.15.2) with ESMTP id u8RC63il026117
for <root@mail.st9.os3.su>; Tue, 27 Sep 2016 15:06:03 +0300
Received: by st15.os3.su (Postfix)
id E4FEE202113D; Tue, 27 Sep 2016 15:06:02 +0300 (MSK)
Date: Tue, 27 Sep 2016 15:06:02 +0300 (MSK)
From: MAILER-DAEMON@st15.os3.su (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: root@mail.st9.os3.su
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="D054620210E4.1474977962/st15.os3.su"
Message-Id: <20160927120602.E4FEE202113D@st15.os3.su>
Status: RO
Content-Length: 3277
Lines: 80
This is a MIME-encapsulated message.
--D054620210E4.1474977962/st15.os3.su
Content-Description: Notification
Content-Type: text/plain; charset=us-ascii
This is the mail system at host st15.os3.su.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
<loop@st15.os3.su>: mail forwarding loop for loop@st15.os3.su
--D054620210E4.1474977962/st15.os3.su
Content-Description: Delivery report
Content-Type: message/delivery-status
Reporting-MTA: dns; st15.os3.su
X-Postfix-Queue-ID: D054620210E4
X-Postfix-Sender: rfc822; root@mail.st9.os3.su
Arrival-Date: Tue, 27 Sep 2016 15:06:02 +0300 (MSK)
Final-Recipient: rfc822; loop@st15.os3.su
Original-Recipient: rfc822;loop@st15.os3.su
Action: failed
Status: 5.4.6
Diagnostic-Code: X-Postfix; mail forwarding loop for loop@st15.os3.su
--D054620210E4.1474977962/st15.os3.su
Content-Description: Undelivered Message
Content-Type: message/rfc822
Return-Path: <root@mail.st9.os3.su>
Received: from mail.st9.os3.su (mail.st9.os3.su [188.130.155.42])
by st15.os3.su (Postfix) with ESMTP id D054620210E4
for <loop@st15.os3.su>; Tue, 27 Sep 2016 15:06:02 +0300 (MSK)
Received: from st12.os3.su (mail.st12.os3.su [188.130.155.45])
by mail.st9.os3.su (8.15.2/8.15.2) with ESMTP id u8RC6220026090
for <loop@mail.st9.os3.su>; Tue, 27 Sep 2016 15:06:02 +0300
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=mail.st12.os3.su; s=default; h=Message-Id:From:Date:Sender:Reply-To:Subject
:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
List-Subscribe:List-Post:List-Owner:List-Archive;
bh=P8YA7gvhetesGWSlzyOnF+1ig1eETsGbkPXTUcY5VQM=; b=b/aeKQA4Xu5n4I0AlY5uP2nlvf
eh6n3SngHUbtU6TO+CVFB1v6rtqiFDIUk9/cKty12YGdhkJUU46cOi1TZXmgRcRnHtjgwrVSi2VGp
sTaBBxr9JMR0oOmgl2Debp0sc4jVgCnKXYPQDBeg0JuSXt13E/ok8rXlKSnoH4G66Toc=;
Received: from mail.st15.os3.su ([188.130.155.48] helo=st15.os3.su)
by st12.os3.su with esmtp (Exim 4.87_167-ff5929e)
(envelope-from <root@mail.st9.os3.su>)
id 1bor97-0000OG-P6
for loop@mail.st12.os3.su; Tue, 27 Sep 2016 15:06:01 +0300
Received: by st15.os3.su (Postfix)
id CEB63202113D; Tue, 27 Sep 2016 15:06:00 +0300 (MSK)
Delivered-To: loop@st15.os3.su
Received: from mail.st9.os3.su (mail.st9.os3.su [188.130.155.42])
by st15.os3.su (Postfix) with ESMTP id BE0A420210E4
for <loop@st15.os3.su>; Tue, 27 Sep 2016 15:06:00 +0300 (MSK)
Received: from mail.st9.os3.su (localhost [127.0.0.1])
by mail.st9.os3.su (8.15.2/8.15.2) with ESMTP id u8RC60U6026085
for <loop@st15.os3.su>; Tue, 27 Sep 2016 15:06:00 +0300
Received: (from root@localhost)
by mail.st9.os3.su (8.15.2/8.15.2/Submit) id u8RC5VNm026071
for loop@st15.os3.su; Tue, 27 Sep 2016 15:05:31 +0300
Date: Tue, 27 Sep 2016 15:05:31 +0300
From: root <root@mail.st9.os3.su>
Message-Id: <201609271205.u8RC5VNm026071@mail.st9.os3.su>
aaa
/
--D054620210E4.1474977962/st15.os3.su--
0
\end{verbatim}
\section{Virtual domains\newline}
\subsection{Step by step \newline}
\begin{enumerate}
\item (b) Add feature to /etc/mail/sendmail.mc
\begin{verbatim}
FEATURE(virtusertable, `hash -o /etc/mail/virtusertable')
\end{verbatim}
\item (a) Add MX RR to our zone file
\begin{verbatim}
altmail IN MX 0 mail.st9.os3.su.
\end{verbatim}
\item Restart nsd
\begin{verbatim}
nsd-contron restart
\end{verbatim}
\item Add virtuser's to new domain in virtusertable
\begin{verbatim}
ali@altmail.st9.os3.su a.abdulmadzhidov
\end{verbatim}
\item Compile all configs and make virtusertable.db
\begin{verbatim}
cd /etc/mail
make all
\end{verbatim}
\item Restart sendmail
\begin{verbatim}
service sendmail restart
\end{verbatim}
\end{enumerate}
Tested by sending mail with sendmail ali@altmail.st9.os3.su < mess.txt
\begin{verbatim}
From mrzizik@mail.st9.os3.su Wed Sep 28 14:14:59 2016
Return-Path: <mrzizik@mail.st9.os3.su>
Received: from mail.st9.os3.su (localhost [127.0.0.1])
by mail.st9.os3.su (8.15.2/8.15.2) with ESMTP id u8SBEwei011414
for <ali@altmail.st9.os3.su>; Wed, 28 Sep 2016 14:14:59 +0300
Received: (from mrzizik@localhost)
by mail.st9.os3.su (8.15.2/8.15.2/Submit) id u8SBEp9r011411
for ali@altmail.st9.os3.su; Wed, 28 Sep 2016 14:14:51 +0300
Date: Wed, 28 Sep 2016 14:14:51 +0300
From: mrzizik <mrzizik@mail.st9.os3.su>
Message-Id: <201609281114.u8SBEp9r011411@mail.st9.os3.su>
testing
\end{verbatim}
Output of mails form altmail was tested by telnet.
\begin{verbatim}
root@SNE09:~# telnet 188.130.155.42 25
Trying 188.130.155.42...
Connected to 188.130.155.42.
Escape character is '^]'.
220 mail.st9.os3.su ESMTP Sendmail 8.15.2/8.15.2; Wed, 28 Sep 2016 14:23:46 +0300
ehlo altmail.st9.os3.su
250-mail.st9.os3.su Hello mail.st9.os3.su [188.130.155.42] (may be forged), pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
mail from: ali@altmail.st9.os3.su
250 2.1.0 ali@altmail.st9.os3.su... Sender ok
rcpt to: root@mail.st9.os3.su
250 2.1.5 root@mail.st9.os3.su... Recipient ok
data
354 Enter mail, end with "." on a line by itself
this is mail for ali at altmail
.
250 2.0.0 u8SBNkPh011824 Message accepted for delivery
\end{verbatim}
The mail
\begin{verbatim}
From ali@altmail.st9.os3.su Wed Sep 28 14:24:35 2016
Return-Path: <ali@altmail.st9.os3.su>
Received: from altmail.st9.os3.su (mail.st9.os3.su [188.130.155.42] (may be forged))
by mail.st9.os3.su (8.15.2/8.15.2) with ESMTP id u8SBNkPh011824
for root@mail.st9.os3.su; Wed, 28 Sep 2016 14:24:22 +0300
Date: Wed, 28 Sep 2016 14:23:46 +0300
From: ali@altmail.st9.os3.su
Message-Id: <201609281124.u8SBNkPh011824@mail.st9.os3.su>
this is mail for ali at altmail
\end{verbatim}
\section{Spam and Security\newline}
\subsection{SPF and DKIM}
\subsubsection{SPF}
SPF verifies sender by SPF or TXT record in DNS and filters it by that compare. It's weakness is dns spoofing, cause in that situation it would be useless.
\subsubsection{DKIM}
DKIM uses cryptography for verifiyng sender of mail. In headers of email it sends signature of mail. When message comes to recepient, it gets public key from dns and checks dkim-signature. After that it decides what to do with email. Problem of this way is resources that we spend to sign and verify every message and also not strong to dns spoof.
(b) I chose SPF, cause i also implemented DNSSEC and dnsspoof isn't scaring me anymore. Also SPF a bit easier to implement.
\subsubsection{Installation}
\begin{enumerate}
\item Installing spf-milter-python and libspf2 from repo's
\begin{verbatim}
apt install spf-milter python libspf2-2
\end{verbatim}
\item Looking to spf's configs to find where it stores socket
\begin{verbatim}
> cat /etc/spf-milter-python/spfmilter.cfg
...
socketname = /var/run/spf-milter-python/spfmiltersock
...
\end{verbatim}
Also there we can change the networks mail from whom wouln't be checked
\item Setting up sendmail config for using spf-milter. We need to add one line to sendmail.mc
\begin{verbatim}
> nano /etc/mail/sendmail.mc
...
INPUT_MAIL_FILTER(`spfmilter',`S=unix:/var/run/spf-milter-python/spfmiltersock')dnl
...
\end{verbatim}
\item Recompiling config files and restarting sendmail
\begin{verbatim}
service sendmail restart
\end{verbatim}
\item Adding TXT RR to our zone on NSD domnain server.
\begin{verbatim}
mail IN TXT "v=spf1 ip4:188.130.155.42 +mx ~all
\end{verbatim}
\item Resigning our zone and restarting dns
\end{enumerate}
\subsubsection*{SPF inbox pass}
\begin{verbatim}
From mboldyrev@mail.st12.os3.su Thu Sep 29 13:27:59 2016
Return-Path: <mboldyrev@mail.st12.os3.su>
Received-SPF: Pass (mail.st9.os3.su: domain of mail.st12.os3.su designates 188.130.155.45 as permitted sender) client-ip=188.130.155.45; envelope-from="mboldyrev@mail.st12.os3.su"; helo=st12.os3.su; receiver=mail.st9.os3.su; mechanism=all; identity=mailfrom
Received: from st12.os3.su (mail.st12.os3.su [188.130.155.45])
by mail.st9.os3.su (8.15.2/8.15.2) with ESMTP id u8TARxV7005879
for <root@mail.st9.os3.su>; Thu, 29 Sep 2016 13:27:59 +0300
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=mail.st12.os3.su; s=default; h=Date:From:Message-Id:Sender:Reply-To:Subject
:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
List-Subscribe:List-Post:List-Owner:List-Archive;
bh=a+WK1yvGvIXnnB6UKyVEidaky0FPifEFBKk53/i4JBU=; b=hYKT80UtVIRX0YF+SS2PYXsCTL
UddZRwMvdLLPhbIOZ1R1mYhPP9ZR86dw57boR5mGUZXPvNxhr55lHGwM1UWqinI/N9K5viaRIYT6u
Ul9Gs0kdcZhuAvG8OBuEqcubSk4EBIZhIhLPYyiqVyr1DkxILooYd3Nai3RIP/3r5MK8=;
Received: from mail.st9.os3.su ([188.130.155.42] helo=mail.st12.os3.su)
by st12.os3.su with esmtp (Exim 4.87_167-ff5929e)
(envelope-from <mboldyrev@mail.st12.os3.su>)
id 1bpYZD-0002Ky-GK
for root@mail.st9.os3.su; Thu, 29 Sep 2016 13:27:55 +0300
Message-Id: <E1bpYZD-0002Ky-GK@st12.os3.su>
From: mboldyrev@mail.st12.os3.su
Date: Thu, 29 Sep 2016 13:27:55 +0300
testSPFtest
\end{verbatim}
\subsubsection*{SPF inbox filtered}
\begin{verbatim}
From sne8@st8.os3.su Thu Sep 29 13:34:35 2016
Return-Path: <sne8@st8.os3.su>
X-Hello-SPF: pass
Received-SPF: None (mail.st9.os3.su: 188.130.155.41 is neither permitted nor denied by domain of st8.os3.su) client-ip=188.130.155.41; envelope-from="sne8@st8.os3.su"; helo=mail.st8.os3.su; receiver=mail.st9.os3.su; identity=mailfrom
Received: from mail.st8.os3.su (mail.st8.os3.su [188.130.155.41])
by mail.st9.os3.su (8.15.2/8.15.2) with ESMTP id u8TAYUF1006112
for <root@mail.st9.os3.su>; Thu, 29 Sep 2016 13:34:35 +0300
Received: by mail.st8.os3.su (Postfix, from userid 1000)
id 9B8A5BE06BA; Thu, 29 Sep 2016 13:34:24 +0300 (MSK)
DKIM-Filter: OpenDKIM Filter v2.10.3 mail.st8.os3.su 9B8A5BE06BA
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st8.os3.su; s=mail;
t=1475145264; bh=vRaZkUWuKXoyya0tqJOUtXWOf8urpnxdoAk0zwJRYcw=;
h=Date:From:From;
b=gAojl0WuxWnwNPxjiHOok7V2gOOqzPY7vElcOIo6D5/sp2+jhv4pv8YCWM2CF250p
O0fdrBAzV1PTKyQh1tAMR2TfwRz8AZ69K5W9odqrpXlqYCFRtjSHKU0KdsJt0yD+Oq
U4wEsd6uulIoFsYjplc6XLQsMHHIBoSQiP0F2yfg=
Message-Id: <20160929103424.9B8A5BE06BA@mail.st8.os3.su>
Date: Thu, 29 Sep 2016 13:34:19 +0300 (MSK)
From: sne8@st8.os3.su (sne8)
0134
\end{verbatim}
Output SPF is checked by online service. Debug screenshots are attached.
\subsection{Generic anti-spam solutions}
From the various spam solutions i chose spamassassin
\subsubsection{Installation}
\begin{enumerate}
\item Installing spamassassin and spamass-milter from repo
\begin{verbatim}
apt install spamassassin spamass-milter
\end{verbatim}
\item Lookin to spamassassing configs to change configurations if needed
\begin{verbatim}
> nano /etc/spamassassin/local.cf
...
trusted_networks 188.130.155/24
...
\end{verbatim}
\item Setting sendmail to work with spamass-milter
\begin{verbatim}
> nano /etc/mail/sendmail.mc
...
INPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass/spamass.sock, F=T, T=C:15m;S:4m;R:4m;E:10m')
...
\end{verbatim}
\item Recompiling config files and restarting sendmail
\begin{verbatim}
service sendmail restart
\end{verbatim}
\end{enumerate}
\subsection{Authentication}
\subsubsection{Installation}
\begin{enumerate}
\item Install openssl and sasl
\begin{verbatim}
apt install openssl sasl
\end{verbatim}
\item Create certificates for openssl
\begin{verbatim}
mkdir -p /etc/mail/certs
cd /etc/mail/certs
openssl req -new -x509 -keyout cakey.pem -out cacert.pem -days 365
openssl req -nodes -new -x509 -keyout sendmail.pem -out sendmail.pem -days 365
openssl x509 -noout -text -in sendmail.pem
chmod 600 ./sendmail.pem
\end{verbatim}
\item Change sendmail config and recompile
\begin{verbatim}
define(`confAUTH_MECHANISMS', `LOGIN PLAIN DIGEST-MD5 CRAM-MD5')dnl
TRUST_AUTH_MECH(`LOGIN PLAIN DIGEST-MD5 CRAM-MD5')dnl
dnl ### do STARTTLS
define(`confCACERT_PATH', `/etc/mail/certs')dnl
define(`confCACERT', `/etc/mail/certs/cacert.pem')dnl
define(`confSERVER_CERT', `/etc/mail/certs/sendmail.pem')dnl
define(`confSERVER_KEY', `/etc/mail/certs/sendmail.pem')dnl
define(`confCLIENT_CERT', `/etc/mail/certs/sendmail.pem')dnl
define(`confCLIENT_KEY', `/etc/mail/certs/sendmail.pem')dnl
DAEMON_OPTIONS(`Family=inet, Port=585, Name=MTA-SSL, M=s')dnl
\end{verbatim}
\end{enumerate}
\end{document}
| mrZizik/lab_reports | mta2/mta.tex | TeX | apache-2.0 | 16,992 | [
30522,
1032,
6254,
26266,
1031,
2184,
13876,
1033,
1063,
3720,
1065,
1003,
1208,
22919,
10260,
1196,
22919,
16856,
14150,
28598,
1517,
1189,
14150,
29745,
29745,
15290,
18947,
22919,
10260,
16856,
15414,
1010,
1193,
19865,
1192,
15290,
1181,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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
/* @var $this CouponController */
/* @var $model Coupon */
$this->breadcrumbs=array(
'Coupons'=>array('index'),
$model->coupon_id=>array('view','id'=>$model->coupon_id),
'Update',
);
$this->menu=array(
array('label'=>'List Coupon', 'url'=>array('index')),
array('label'=>'Create Coupon', 'url'=>array('create')),
array('label'=>'View Coupon', 'url'=>array('view', 'id'=>$model->coupon_id)),
array('label'=>'Manage Coupon', 'url'=>array('admin')),
);
?>
<h1>Update Coupon <?php echo $model->coupon_id; ?></h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?> | tierous/yiirisma | protected/views/coupon/update.php | PHP | unlicense | 589 | [
30522,
1026,
1029,
25718,
1013,
1008,
1030,
13075,
1002,
2023,
8648,
2239,
8663,
13181,
10820,
1008,
1013,
1013,
1008,
1030,
13075,
1002,
2944,
8648,
2239,
1008,
1013,
1002,
2023,
1011,
1028,
7852,
26775,
25438,
2015,
1027,
9140,
1006,
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... |
//
// "$Id$"
//
// MD5 support code for HTMLDOC.
//
// Copyright 2011 by Michael R Sweet.
// Copyright 2001-2008 by Easy Software Products.
// Copyright 1999 Aladdin Enterprises. All rights reserved.
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
// L. Peter Deutsch
// ghost@aladdin.com
//
//
// Independent implementation of MD5 (RFC 1321).
//
// This code implements the MD5 Algorithm defined in RFC 1321.
// It is derived directly from the text of the RFC and not from the
// reference implementation.
//
// The original and principal author of md5.h is L. Peter Deutsch
// <ghost@aladdin.com>. Other authors are noted in the change history
// that follows (in reverse chronological order):
//
// 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
// 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
// added conditionalization for C++ compilation from Martin
// Purschke <purschke@bnl.gov>.
// 1999-05-03 lpd Original version.
//
#ifndef _HTMLDOC_MD5_H_
# define _HTMLDOC_MD5_H_
# include "types.h"
//
// This code has some adaptations for the Ghostscript environment, but it
// will compile and run correctly in any environment with 8-bit chars and
// 32-bit ints. Specifically, it assumes that if the following are
// defined, they have the same meaning as in Ghostscript: P1, P2, P3,
// ARCH_IS_BIG_ENDIAN.
//
// Define the state of the MD5 Algorithm.
struct hdMD5
{
hdWord count[2]; // message length in bits, lsw first
hdWord abcd[4]; // digest buffer
hdByte buf[64]; // accumulate block
void append(const hdByte *data, int nbytes);
void finish(hdByte *digest);
void init();
void process(const hdByte *data);
};
#endif // !_HTMLDOC_MD5_H_
//
// End of "$Id$".
//
| TimofonicJunkRoom/HTMLDOC | htmldoc/md5.h | C | gpl-2.0 | 2,570 | [
30522,
1013,
1013,
1013,
1013,
1000,
1002,
8909,
1002,
1000,
1013,
1013,
1013,
1013,
9108,
2629,
2490,
3642,
2005,
16129,
3527,
2278,
1012,
1013,
1013,
1013,
1013,
9385,
2249,
2011,
2745,
1054,
4086,
1012,
1013,
1013,
9385,
2541,
1011,
22... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package alice.tuprolog.json;
import alice.tuprolog.Term;
//Alberto
public class ReducedEngineState extends AbstractEngineState {
@SuppressWarnings("unused")
private String type = "ReducedEngineState";
@Override
public void setQuery(Term query) {
this.query = query;
}
@Override
public Term getQuery(){
return this.query;
}
@Override
public void setNumberAskedResults(int nResultAsked) {
this.nAskedResults = nResultAsked;
}
@Override
public int getNumberAskedResults(){
return this.nAskedResults;
}
@Override
public void setHasOpenAlternatives(boolean hasOpenAlternatives) {
this.hasOpenAlternatives = hasOpenAlternatives;
}
@Override
public boolean hasOpenAlternatives(){
return this.hasOpenAlternatives;
}
@Override
public long getSerializationTimestamp() {
return serializationTimestamp;
}
@Override
public void setSerializationTimestamp(long serializationTimestamp) {
this.serializationTimestamp = serializationTimestamp;
}
}
| zakski/project-soisceal | 2p-mvn/tuProlog-3.5-mvn/src/alice/tuprolog/json/ReducedEngineState.java | Java | lgpl-3.0 | 990 | [
30522,
7427,
5650,
1012,
10722,
21572,
21197,
1012,
1046,
3385,
30524,
21572,
21197,
1012,
2744,
1025,
1013,
1013,
12007,
2270,
2465,
4359,
13159,
10586,
12259,
8908,
10061,
13159,
10586,
12259,
1063,
1030,
16081,
9028,
5582,
2015,
1006,
1000... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<meta charset="utf-8"/>
<!-- @TEMPLATE -->
<textarea name="css">
.m-b0{background:#fd0;}
</textarea>
<textarea name="ntp" id="b0-ntp-0">
<div class="m-b0">
<p>0000000000000000000000</p>
<p>0000000000000000000000</p>
<p>0000000000000000000000</p>
<p>0000000000000000000000</p>
<p>0000000000000000000000</p>
<p>0000000000000000000000</p>
<p>0000000000000000000000</p>
</div>
</textarea>
<textarea name="js" data-src="../../javascript/module/index/b.b0.js"></textarea>
<!-- /@TEMPLATE --> | NetEaseWD/NEJPublisher | demo/web-app/src/html/index/b.b0.html | HTML | mit | 570 | [
30522,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1013,
1028,
1026,
999,
1011,
1011,
1030,
23561,
1011,
1011,
1028,
1026,
3793,
12069,
2050,
2171,
1027,
1000,
20116,
2015,
1000,
1028,
1012,
1049,
1011,
1038,
2692,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.deploy.rest
import java.lang.Boolean
import org.json4s.jackson.JsonMethods._
import org.apache.spark.{SparkConf, SparkFunSuite}
import org.apache.spark.util.Utils
/**
* Tests for the REST application submission protocol.
*/
class SubmitRestProtocolSuite extends SparkFunSuite {
test("validate") {
val request = new DummyRequest
intercept[SubmitRestProtocolException] { request.validate() } // missing everything
request.clientSparkVersion = "1.2.3"
intercept[SubmitRestProtocolException] { request.validate() } // missing name and age
request.name = "something"
intercept[SubmitRestProtocolException] { request.validate() } // missing only age
request.age = 2
intercept[SubmitRestProtocolException] { request.validate() } // age too low
request.age = 10
request.validate() // everything is set properly
request.clientSparkVersion = null
intercept[SubmitRestProtocolException] { request.validate() } // missing only Spark version
request.clientSparkVersion = "1.2.3"
request.name = null
intercept[SubmitRestProtocolException] { request.validate() } // missing only name
request.message = "not-setting-name"
intercept[SubmitRestProtocolException] { request.validate() } // still missing name
}
test("request to and from JSON") {
val request = new DummyRequest
intercept[SubmitRestProtocolException] { request.toJson } // implicit validation
request.clientSparkVersion = "1.2.3"
request.active = true
request.age = 25
request.name = "jung"
val json = request.toJson
assertJsonEquals(json, dummyRequestJson)
val newRequest = SubmitRestProtocolMessage.fromJson(json, classOf[DummyRequest])
assert(newRequest.clientSparkVersion === "1.2.3")
assert(newRequest.clientSparkVersion === "1.2.3")
assert(newRequest.active)
assert(newRequest.age === 25)
assert(newRequest.name === "jung")
assert(newRequest.message === null)
}
test("response to and from JSON") {
val response = new DummyResponse
response.serverSparkVersion = "3.3.4"
response.success = true
val json = response.toJson
assertJsonEquals(json, dummyResponseJson)
val newResponse = SubmitRestProtocolMessage.fromJson(json, classOf[DummyResponse])
assert(newResponse.serverSparkVersion === "3.3.4")
assert(newResponse.serverSparkVersion === "3.3.4")
assert(newResponse.success)
assert(newResponse.message === null)
}
test("CreateSubmissionRequest") {
val message = new CreateSubmissionRequest
intercept[SubmitRestProtocolException] { message.validate() }
message.clientSparkVersion = "1.2.3"
message.appResource = "honey-walnut-cherry.jar"
message.mainClass = "org.apache.spark.examples.SparkPie"
message.appArgs = Array("two slices")
message.environmentVariables = Map("PATH" -> "/dev/null")
val conf = new SparkConf(false)
conf.set("spark.app.name", "SparkPie")
message.sparkProperties = conf.getAll.toMap
message.validate()
// optional fields
conf.set("spark.jars", "mayonnaise.jar,ketchup.jar")
conf.set("spark.files", "fireball.png")
conf.set("spark.driver.memory", s"${Utils.DEFAULT_DRIVER_MEM_MB}m")
conf.set("spark.driver.cores", "180")
conf.set("spark.driver.extraJavaOptions", " -Dslices=5 -Dcolor=mostly_red")
conf.set("spark.driver.extraClassPath", "food-coloring.jar")
conf.set("spark.driver.extraLibraryPath", "pickle.jar")
conf.set("spark.driver.supervise", "false")
conf.set("spark.executor.memory", "256m")
conf.set("spark.cores.max", "10000")
message.sparkProperties = conf.getAll.toMap
message.appArgs = Array("two slices", "a hint of cinnamon")
message.environmentVariables = Map("PATH" -> "/dev/null")
message.validate()
// bad fields
var badConf = conf.clone().set("spark.driver.cores", "one hundred feet")
message.sparkProperties = badConf.getAll.toMap
intercept[SubmitRestProtocolException] { message.validate() }
badConf = conf.clone().set("spark.driver.supervise", "nope, never")
message.sparkProperties = badConf.getAll.toMap
intercept[SubmitRestProtocolException] { message.validate() }
badConf = conf.clone().set("spark.cores.max", "two men")
message.sparkProperties = badConf.getAll.toMap
intercept[SubmitRestProtocolException] { message.validate() }
message.sparkProperties = conf.getAll.toMap
// test JSON
val json = message.toJson
assertJsonEquals(json, submitDriverRequestJson)
val newMessage = SubmitRestProtocolMessage.fromJson(json, classOf[CreateSubmissionRequest])
assert(newMessage.clientSparkVersion === "1.2.3")
assert(newMessage.appResource === "honey-walnut-cherry.jar")
assert(newMessage.mainClass === "org.apache.spark.examples.SparkPie")
assert(newMessage.sparkProperties("spark.app.name") === "SparkPie")
assert(newMessage.sparkProperties("spark.jars") === "mayonnaise.jar,ketchup.jar")
assert(newMessage.sparkProperties("spark.files") === "fireball.png")
assert(newMessage.sparkProperties("spark.driver.memory") === s"${Utils.DEFAULT_DRIVER_MEM_MB}m")
assert(newMessage.sparkProperties("spark.driver.cores") === "180")
assert(newMessage.sparkProperties("spark.driver.extraJavaOptions") ===
" -Dslices=5 -Dcolor=mostly_red")
assert(newMessage.sparkProperties("spark.driver.extraClassPath") === "food-coloring.jar")
assert(newMessage.sparkProperties("spark.driver.extraLibraryPath") === "pickle.jar")
assert(newMessage.sparkProperties("spark.driver.supervise") === "false")
assert(newMessage.sparkProperties("spark.executor.memory") === "256m")
assert(newMessage.sparkProperties("spark.cores.max") === "10000")
assert(newMessage.appArgs === message.appArgs)
assert(newMessage.sparkProperties === message.sparkProperties)
assert(newMessage.environmentVariables === message.environmentVariables)
}
test("CreateSubmissionResponse") {
val message = new CreateSubmissionResponse
intercept[SubmitRestProtocolException] { message.validate() }
message.serverSparkVersion = "1.2.3"
message.submissionId = "driver_123"
message.success = true
message.validate()
// test JSON
val json = message.toJson
assertJsonEquals(json, submitDriverResponseJson)
val newMessage = SubmitRestProtocolMessage.fromJson(json, classOf[CreateSubmissionResponse])
assert(newMessage.serverSparkVersion === "1.2.3")
assert(newMessage.submissionId === "driver_123")
assert(newMessage.success)
}
test("KillSubmissionResponse") {
val message = new KillSubmissionResponse
intercept[SubmitRestProtocolException] { message.validate() }
message.serverSparkVersion = "1.2.3"
message.submissionId = "driver_123"
message.success = true
message.validate()
// test JSON
val json = message.toJson
assertJsonEquals(json, killDriverResponseJson)
val newMessage = SubmitRestProtocolMessage.fromJson(json, classOf[KillSubmissionResponse])
assert(newMessage.serverSparkVersion === "1.2.3")
assert(newMessage.submissionId === "driver_123")
assert(newMessage.success)
}
test("SubmissionStatusResponse") {
val message = new SubmissionStatusResponse
intercept[SubmitRestProtocolException] { message.validate() }
message.serverSparkVersion = "1.2.3"
message.submissionId = "driver_123"
message.success = true
message.validate()
// optional fields
message.driverState = "RUNNING"
message.workerId = "worker_123"
message.workerHostPort = "1.2.3.4:7780"
// test JSON
val json = message.toJson
assertJsonEquals(json, driverStatusResponseJson)
val newMessage = SubmitRestProtocolMessage.fromJson(json, classOf[SubmissionStatusResponse])
assert(newMessage.serverSparkVersion === "1.2.3")
assert(newMessage.submissionId === "driver_123")
assert(newMessage.driverState === "RUNNING")
assert(newMessage.success)
assert(newMessage.workerId === "worker_123")
assert(newMessage.workerHostPort === "1.2.3.4:7780")
}
test("ErrorResponse") {
val message = new ErrorResponse
intercept[SubmitRestProtocolException] { message.validate() }
message.serverSparkVersion = "1.2.3"
message.message = "Field not found in submit request: X"
message.validate()
// test JSON
val json = message.toJson
assertJsonEquals(json, errorJson)
val newMessage = SubmitRestProtocolMessage.fromJson(json, classOf[ErrorResponse])
assert(newMessage.serverSparkVersion === "1.2.3")
assert(newMessage.message === "Field not found in submit request: X")
}
private val dummyRequestJson =
"""
|{
| "action" : "DummyRequest",
| "active" : true,
| "age" : 25,
| "clientSparkVersion" : "1.2.3",
| "name" : "jung"
|}
""".stripMargin
private val dummyResponseJson =
"""
|{
| "action" : "DummyResponse",
| "serverSparkVersion" : "3.3.4",
| "success": true
|}
""".stripMargin
private val submitDriverRequestJson =
s"""
|{
| "action" : "CreateSubmissionRequest",
| "appArgs" : [ "two slices", "a hint of cinnamon" ],
| "appResource" : "honey-walnut-cherry.jar",
| "clientSparkVersion" : "1.2.3",
| "environmentVariables" : {
| "PATH" : "/dev/null"
| },
| "mainClass" : "org.apache.spark.examples.SparkPie",
| "sparkProperties" : {
| "spark.driver.extraLibraryPath" : "pickle.jar",
| "spark.jars" : "mayonnaise.jar,ketchup.jar",
| "spark.driver.supervise" : "false",
| "spark.app.name" : "SparkPie",
| "spark.cores.max" : "10000",
| "spark.driver.memory" : "${Utils.DEFAULT_DRIVER_MEM_MB}m",
| "spark.files" : "fireball.png",
| "spark.driver.cores" : "180",
| "spark.driver.extraJavaOptions" : " -Dslices=5 -Dcolor=mostly_red",
| "spark.executor.memory" : "256m",
| "spark.driver.extraClassPath" : "food-coloring.jar"
| }
|}
""".stripMargin
private val submitDriverResponseJson =
"""
|{
| "action" : "CreateSubmissionResponse",
| "serverSparkVersion" : "1.2.3",
| "submissionId" : "driver_123",
| "success" : true
|}
""".stripMargin
private val killDriverResponseJson =
"""
|{
| "action" : "KillSubmissionResponse",
| "serverSparkVersion" : "1.2.3",
| "submissionId" : "driver_123",
| "success" : true
|}
""".stripMargin
private val driverStatusResponseJson =
"""
|{
| "action" : "SubmissionStatusResponse",
| "driverState" : "RUNNING",
| "serverSparkVersion" : "1.2.3",
| "submissionId" : "driver_123",
| "success" : true,
| "workerHostPort" : "1.2.3.4:7780",
| "workerId" : "worker_123"
|}
""".stripMargin
private val errorJson =
"""
|{
| "action" : "ErrorResponse",
| "message" : "Field not found in submit request: X",
| "serverSparkVersion" : "1.2.3"
|}
""".stripMargin
/** Assert that the contents in the two JSON strings are equal after ignoring whitespace. */
private def assertJsonEquals(jsonString1: String, jsonString2: String): Unit = {
val trimmedJson1 = jsonString1.trim
val trimmedJson2 = jsonString2.trim
val json1 = compact(render(parse(trimmedJson1)))
val json2 = compact(render(parse(trimmedJson2)))
// Put this on a separate line to avoid printing comparison twice when test fails
val equals = json1 == json2
assert(equals, "\"[%s]\" did not equal \"[%s]\"".format(trimmedJson1, trimmedJson2))
}
}
private class DummyResponse extends SubmitRestProtocolResponse
private class DummyRequest extends SubmitRestProtocolRequest {
var active: Boolean = null
var age: Integer = null
var name: String = null
protected override def doValidate(): Unit = {
super.doValidate()
assertFieldIsSet(name, "name")
assertFieldIsSet(age, "age")
assert(age > 5, "Not old enough!")
}
}
| esi-mineset/spark | core/src/test/scala/org/apache/spark/deploy/rest/SubmitRestProtocolSuite.scala | Scala | apache-2.0 | 12,949 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
1008,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
1008,
2023,
2147,
2005,
3176,
2592,
4953,
9385,
6095,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#pragma once
#include "Application.h"
namespace Lab5Master
{
Application::Application(HINSTANCE hInst, int nCmdShow)
{
AppInstance = hInst;
CmdShow = nCmdShow;
GlobalWindow = nullptr;
LoadString(AppInstance, IDS_TITLE, AppTitle, MAX_STR);
LoadString(AppInstance, IDC_MAINWINDOWCLASS, MainWindowClass, MAX_STR);
ReadSystemMetrics();
}
Application::~Application()
{
GlobalWindow->~MainWindow();
}
int Application::CreateWindows()
{
int x = (ScreenWidth - WIDTH) / 2;
int y = (ScreenHeight - HEIGHT) / 2;
GlobalWindow = new MainWindow(AppInstance, CmdShow, AppTitle, MainWindowClass, x, y, WIDTH, HEIGHT);
return GlobalWindow->Start();
}
int Application::Run()
{
MSG msg;
HACCEL hAccelTable;
hAccelTable = LoadAccelerators(AppInstance, MAKEINTRESOURCE(IDR_HOTKEYS));
Window::GlobalMessageMap.clear();
Window::ProcessMessages = false;
Window::QueuedMessages.clear();
int res = CreateWindows();
if (res != 0)
return res;
Window::ProcessMessages = true;
Window::ResentQueuedMessages();
GlobalWindow->Show(CmdShow);
while (GetMessage(&msg, nullptr, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Window::GlobalMessageMap.clear();
return msg.wParam;
}
void Application::ReadSystemMetrics()
{
ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
}
}
| kinpa200296/SP_labs | Lab5Master/Application.cpp | C++ | mit | 1,462 | [
30522,
1001,
10975,
8490,
2863,
2320,
1001,
2421,
1000,
4646,
1012,
1044,
1000,
3415,
15327,
6845,
2629,
8706,
1063,
4646,
1024,
1024,
4646,
1006,
7632,
23808,
6651,
7632,
23808,
1010,
20014,
13316,
26876,
22231,
2860,
1007,
1063,
10439,
70... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
* The President and Fellows of Harvard College.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY 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 UNIVERSITY OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _LIB_H_
#define _LIB_H_
/*
* Miscellaneous standard C functions for the kernel, and other widely used
* kernel functions.
*
* Note: setjmp and longjmp are in <setjmp.h>.
*/
#include <cdefs.h>
/*
* Assert macros.
*
* KASSERT and DEBUGASSERT are the same, except that they can be
* toggled independently. DEBUGASSERT is used in places where making
* checks is likely to be expensive and relatively unlikely to be
* helpful.
*
* Note that there's also a COMPILE_ASSERT for compile-time checks;
* it's in <cdefs.h>.
*
* Regular assertions (KASSERT) are disabled by the kernel config
* option "noasserts". DEBUGASSERT could be controlled by kernel
* config also, but since it's likely to be wanted only rarely during
* testing there doesn't seem much point; one can just edit this file
* temporarily instead.
*/
#include "opt-noasserts.h"
#if OPT_NOASSERTS
#define KASSERT(expr) ((void)(expr))
#else
#define KASSERT(expr) \
((expr) ? (void)0 : badassert(#expr, __FILE__, __LINE__, __func__))
#endif
#if 1 /* no debug asserts */
#define DEBUGASSERT(expr) ((void)(expr))
#else
#define DEBUGASSERT(expr) \
((expr) ? (void)0 : badassert(#expr, __FILE__, __LINE__, __func__))
#endif
/*
* Bit flags for DEBUG()
*/
#define DB_LOCORE 0x001
#define DB_SYSCALL 0x002
#define DB_INTERRUPT 0x004
#define DB_DEVICE 0x008
#define DB_THREADS 0x010
#define DB_VM 0x020
#define DB_EXEC 0x040
#define DB_VFS 0x080
#define DB_SFS 0x100
#define DB_NET 0x200
#define DB_NETFS 0x400
#define DB_KMALLOC 0x800
extern uint32_t dbflags;
/*
* DEBUG() is for conditionally printing debug messages to the console.
*
* The idea is that you put lots of lines of the form
*
* DEBUG(DB_VM, "VM free pages: %u\n", free_pages);
*
* throughout the kernel; then you can toggle whether these messages
* are printed or not at runtime by setting the value of dbflags with
* the debugger.
*
* Unfortunately, as of this writing, there are only a very few such
* messages actually present in the system yet. Feel free to add more.
*
* DEBUG is a varargs macro. These were added to the language in C99.
*/
#define DEBUG(d, ...) ((dbflags & (d)) ? kprintf(__VA_ARGS__) : 0)
/*
* Random number generator, using the random device.
*
* random() returns a number between 0 and randmax() inclusive.
*/
#define RANDOM_MAX (randmax())
uint32_t randmax(void);
uint32_t random(void);
/*
* Kernel heap memory allocation. Like malloc/free.
* If out of memory, kmalloc returns NULL.
*
* kheap_nextgeneration, dump, and dumpall do nothing unless heap
* labeling (for leak detection) in kmalloc.c (q.v.) is enabled.
*/
void *kmalloc(size_t size);
void kfree(void *ptr);
void kheap_printstats(void);
void kheap_nextgeneration(void);
void kheap_dump(void);
void kheap_dumpall(void);
/*
* C string functions.
*
* kstrdup is like strdup, but calls kmalloc instead of malloc.
* If out of memory, it returns NULL.
*/
size_t strlen(const char *str);
int strcmp(const char *str1, const char *str2);
char *strcpy(char *dest, const char *src);
char *strcat(char *dest, const char *src);
char *kstrdup(const char *str);
char *strchr(const char *searched, int searchfor);
char *strrchr(const char *searched, int searchfor);
char *strtok_r(char *buf, const char *seps, char **context);
void *memcpy(void *dest, const void *src, size_t len);
void *memmove(void *dest, const void *src, size_t len);
void *memset(void *block, int ch, size_t len);
void bzero(void *ptr, size_t len);
int atoi(const char *str);
int snprintf(char *buf, size_t maxlen, const char *fmt, ...) __PF(3,4);
const char *strerror(int errcode);
/*
* Low-level console access.
*/
void putch(int ch);
int getch(void);
void beep(void);
/*
* Higher-level console output.
*
* kprintf is like printf, only in the kernel.
* panic prepends the string "panic: " to the message printed, and then
* resets the system.
* badassert calls panic in a way suitable for an assertion failure.
* kgets is like gets, only with a buffer size argument.
*
* kprintf_bootstrap sets up a lock for kprintf and should be called
* during boot once malloc is available and before any additional
* threads are created.
*/
int kprintf(const char *format, ...) __PF(1,2);
__DEAD void panic(const char *format, ...) __PF(1,2);
__DEAD void badassert(const char *expr, const char *file,
int line, const char *func);
void kgets(char *buf, size_t maxbuflen);
void kprintf_bootstrap(void);
/*
* Other miscellaneous stuff
*/
#define DIVROUNDUP(a,b) (((a)+(b)-1)/(b))
#define ROUNDUP(a,b) (DIVROUNDUP(a,b)*b)
#define max(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
#endif /* _LIB_H_ */
| computist/os161 | kern/include/lib.h | C | mit | 6,383 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2456,
1010,
2541,
1010,
2526,
1010,
2494,
1010,
2432,
1010,
2384,
1010,
2263,
1010,
2268,
1008,
1996,
2343,
1998,
13572,
1997,
5765,
2267,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
{% include header.html %}
{% include about.html %}
{% include work.html %}
{% include contact.html %}
{% include footer.html %} | Galiant/Portfolio | _layouts/default.html | HTML | mit | 131 | [
30522,
1063,
1003,
2421,
20346,
1012,
16129,
1003,
1065,
1063,
1003,
2421,
2055,
1012,
16129,
1003,
1065,
1063,
1003,
2421,
2147,
1012,
16129,
1003,
1065,
1063,
1003,
2421,
3967,
1012,
16129,
1003,
1065,
1063,
1003,
2421,
3329,
2121,
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... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>presburger: 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.10.0 / presburger - 8.8.0</a></li>
</ul>
</div>
</div>
</div>
<div class="article">
<div class="row">
<div class="col-md-12">
<a href="../..">« Up</a>
<h1>
presburger
<small>
8.8.0
<span class="label label-info">Not compatible</span>
</small>
</h1>
<p><em><script>document.write(moment("2020-02-26 23:22:14 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2020-02-26 23:22:14 UTC)</em><p>
<h2>Context</h2>
<pre># Packages matching: installed
# Name # Installed # Synopsis
base-bigarray base
base-threads base
base-unix base
conf-findutils 1 Virtual package relying on findutils
conf-m4 1 Virtual package relying on m4
coq 8.10.0 Formal proof management system
num 1.3 The legacy Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.09.0 The OCaml compiler (virtual package)
ocaml-base-compiler 4.09.0 Official release 4.09.0
ocaml-config 1 OCaml Switch Configuration
ocamlfind 1.8.1 A library manager for OCaml
# opam file:
opam-version: "2.0"
maintainer: "Hugo.Herbelin@inria.fr"
homepage: "https://github.com/coq-contribs/presburger"
license: "LGPL 2.1"
build: [make "-j%{jobs}%"]
install: [make "install"]
remove: ["rm" "-R" "%{lib}%/coq/user-contrib/Presburger"]
depends: [
"ocaml"
"coq" {>= "8.8" & < "8.9~"}
]
tags: [ "keyword: Integers" "keyword: Arithmetic" "keyword: Decision Procedure" "keyword: Presburger" "category: Mathematics/Logic/Foundations" "category: Mathematics/Arithmetic and Number Theory/Miscellaneous" "category: Computer Science/Decision Procedures and Certified Algorithms/Decision procedures" "date: March 2002" ]
authors: [ "Laurent Théry" ]
bug-reports: "https://github.com/coq-contribs/presburger/issues"
dev-repo: "git+https://github.com/coq-contribs/presburger.git"
synopsis: "Presburger's algorithm"
description: """
A formalization of Presburger's algorithm as stated in
the initial paper by Presburger."""
flags: light-uninstall
url {
src: "https://github.com/coq-contribs/presburger/archive/v8.8.0.tar.gz"
checksum: "md5=a1b064cf124b40bae0df70e22630d2d6"
}
</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-presburger.8.8.0 coq.8.10.0</code></dd>
<dt>Return code</dt>
<dd>5120</dd>
<dt>Output</dt>
<dd><pre>[NOTE] Package coq is already installed (current version is 8.10.0).
The following dependencies couldn't be met:
- coq-presburger -> coq < 8.9~ -> ocaml < 4.06.0
base of this switch (use `--unlock-base' to force)
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-presburger.8.8.0</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Install dependencies</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Install</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Installation size</h2>
<p>No files were installed.</p>
<h2>Uninstall</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Missing removes</dt>
<dd>
none
</dd>
<dt>Wrong removes</dt>
<dd>
none
</dd>
</dl>
</div>
</div>
</div>
<hr/>
<div class="footer">
<p class="text-center">
<small>Sources are on <a href="https://github.com/coq-bench">GitHub</a>. © Guillaume Claret.</small>
</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../../../../bootstrap.min.js"></script>
</body>
</html>
| coq-bench/coq-bench.github.io | clean/Linux-x86_64-4.09.0-2.0.5/released/8.10.0/presburger/8.8.0.html | HTML | mit | 7,100 | [
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... |
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
/**
* IdentityTranslator does not translate anything.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class IdentityTranslator implements TranslatorInterface
{
private $selector;
private $locale;
/**
* Constructor.
*
* @param MessageSelector $selector The message selector for pluralization
*/
public function __construct(MessageSelector $selector)
{
$this->selector = $selector;
}
/**
* {@inheritdoc}
*/
public function setLocale($locale)
{
$this->locale = $locale;
}
/**
* {@inheritdoc}
*/
public function getLocale()
{
return $this->locale ?: \Locale::getDefault();
}
/**
* {@inheritdoc}
*/
public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
{
return strtr((string) $id, $parameters);
}
/**
* {@inheritdoc}
*/
public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
{
return strtr($this->selector->choose((string) $id, (int) $number, $locale ?: $this->getLocale()), $parameters);
}
}
| bijen/nform | vendor/symfony/symfony/src/Symfony/Component/Translation/IdentityTranslator.php | PHP | mit | 1,465 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
25353,
2213,
14876,
4890,
7427,
1012,
1008,
1008,
1006,
1039,
1007,
6904,
11283,
2078,
8962,
2368,
19562,
1026,
6904,
11283,
2078,
1030,
25353,
2213,
14876,
489... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
class TmsFakeIn < ActiveRecord::Base
set_table_name "tms_fake_in"
end
# == Schema Information
#
# Table name: tms_fake_in
#
# id :integer(10) not null, primary key
# message :text not null
# created_at :datetime
# priority :integer(10) default(0), not null
#
| jfoxGRT/jboss_upgrade | standalone/deployments/custserv-web/src/main/webapp/WEB-INF/app/models/tms_fake_in.rb | Ruby | lgpl-2.1 | 299 | [
30522,
2465,
1056,
5244,
7011,
29501,
2078,
1026,
3161,
2890,
27108,
2094,
1024,
1024,
2918,
2275,
1035,
2795,
1035,
2171,
1000,
1056,
5244,
1035,
8275,
1035,
1999,
1000,
2203,
1001,
1027,
1027,
8040,
28433,
2592,
1001,
1001,
2795,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 Google Inc
*
* Licensed under the Apache License, Version 2.0(the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Linq;
using Google.Apis.Dfareporting.v3_4;
using Google.Apis.Dfareporting.v3_4.Data;
namespace DfaReporting.Samples {
/// <summary>
/// This example illustrates how to get a list of all the files for a report.
/// </summary>
class GetReportFiles : SampleBase {
/// <summary>
/// Returns a description about the code example.
/// </summary>
public override string Description {
get {
return "This example illustrates how to get a list of all the files" +
" for a report.\n";
}
}
/// <summary>
/// Main method, to run this code example as a standalone application.
/// </summary>
/// <param name="args">The command line arguments.</param>
public static void Main(string[] args) {
SampleBase codeExample = new GetReportFiles();
Console.WriteLine(codeExample.Description);
codeExample.Run(DfaReportingFactory.getInstance());
}
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="service">An initialized Dfa Reporting service object
/// </param>
public override void Run(DfareportingService service) {
long reportId = long.Parse(_T("INSERT_REPORT_ID_HERE"));
long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));
// Limit the fields returned.
String fields = "nextPageToken,items(fileName,id,status)";
FileList files;
String nextPageToken = null;
do {
// Create and execute the report files list request.
ReportsResource.FilesResource.ListRequest request =
service.Reports.Files.List(profileId, reportId);
request.Fields = fields;
request.PageToken = nextPageToken;
files = request.Execute();
foreach (File file in files.Items) {
Console.WriteLine("Report file with ID {0} and file name \"{1}\" has status \"{2}\".",
file.Id, file.FileName, file.Status);
}
// Update the next page token.
nextPageToken = files.NextPageToken;
} while (files.Items.Any() && !String.IsNullOrEmpty(nextPageToken));
}
}
}
| googleads/googleads-dfa-reporting-samples | dotnet/v3.4/Reports/GetReportFiles.cs | C# | apache-2.0 | 2,743 | [
30522,
1013,
1008,
1008,
9385,
2325,
8224,
4297,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
module Mutant
class Mutator
class Node
# Mutator for nth-ref nodes
class NthRef < self
handle :nth_ref
children :number
private
# Perform dispatch
#
# @return [undefined]
#
# @api private
def dispatch
unless number.equal?(1)
emit_number(number - 1)
end
emit_number(number + 1)
end
end # NthRef
end # Node
end # Mutator
end # Mutant
| nepalez/mutant | lib/mutant/mutator/node/nthref.rb | Ruby | mit | 487 | [
30522,
11336,
15527,
2465,
14163,
29336,
2953,
2465,
13045,
1001,
14163,
29336,
2953,
2005,
23961,
2232,
1011,
25416,
14164,
2465,
23961,
28362,
2546,
1026,
2969,
5047,
1024,
23961,
2232,
1035,
25416,
2336,
1024,
2193,
2797,
1001,
4685,
18365... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* License Agreement for OpenSearchServer
*
* Copyright (C) 2013-2015 Emmanuel Keller / Jaeksoft
*
* http://www.open-search-server.com
*
* This file is part of OpenSearchServer.
*
* OpenSearchServer 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.
*
* OpenSearchServer 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 OpenSearchServer.
* If not, see <http://www.gnu.org/licenses/>.
**/
package com.jaeksoft.searchlib.script.commands;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import com.jaeksoft.searchlib.Client;
import com.jaeksoft.searchlib.SearchLibException;
import com.jaeksoft.searchlib.analysis.LanguageEnum;
import com.jaeksoft.searchlib.index.IndexDocument;
import com.jaeksoft.searchlib.script.CommandAbstract;
import com.jaeksoft.searchlib.script.CommandEnum;
import com.jaeksoft.searchlib.script.ScriptCommandContext;
import com.jaeksoft.searchlib.script.ScriptException;
public class IndexDocumentCommands {
public static class New extends CommandAbstract {
public New() {
super(CommandEnum.INDEX_DOCUMENT_NEW);
}
@Override
public void run(ScriptCommandContext context, String id,
String... parameters) throws ScriptException {
IndexDocument indexDocument = new IndexDocument(
LanguageEnum.findByNameOrCode(getParameterString(1)));
context.addIndexDocument(indexDocument);
}
}
public static class AddValue extends CommandAbstract {
public AddValue() {
super(CommandEnum.INDEX_DOCUMENT_ADD_VALUE);
}
@Override
public void run(ScriptCommandContext context, String id,
String... parameters) throws ScriptException {
checkParameters(2, parameters);
IndexDocument indexDocument = context.getIndexDocument();
if (indexDocument == null)
throwError("No index document has been created. Call INDEX_DOCUMENT_NEW.");
String field = getParameterString(0);
String value = getParameterString(1);
value = context.replaceVariables(value);
Float boost = getParameterFloat(2);
indexDocument.add(field, value, boost == null ? 1.0F : boost);
}
}
public static class AddNow extends CommandAbstract {
public AddNow() {
super(CommandEnum.INDEX_DOCUMENT_ADD_NOW);
}
@Override
public void run(ScriptCommandContext context, String id,
String... parameters) throws ScriptException {
checkParameters(2, parameters);
IndexDocument indexDocument = context.getIndexDocument();
if (indexDocument == null)
throwError("No index document has been created. Call INDEX_DOCUMENT_NEW.");
String field = getParameterString(0);
String format = getParameterString(1);
format = context.replaceVariables(format);
SimpleDateFormat df = new SimpleDateFormat(format);
String value = df.format(new Date());
Float boost = getParameterFloat(2);
indexDocument.add(field, value, boost == null ? 1.0F : boost);
}
}
public static class Update extends CommandAbstract {
public Update() {
super(CommandEnum.INDEX_DOCUMENT_UPDATE);
}
@Override
public void run(ScriptCommandContext context, String id,
String... parameters) throws ScriptException {
List<IndexDocument> indexDocuments = context.getIndexDocuments();
if (CollectionUtils.isEmpty(indexDocuments))
return;
Client client = (Client) context.getConfig();
try {
context.clearIndexDocuments(client
.updateDocuments(indexDocuments));
} catch (IOException e) {
throw new ScriptException(e);
} catch (SearchLibException e) {
throw new ScriptException(e);
}
}
}
}
| nvoron23/opensearchserver | src/main/java/com/jaeksoft/searchlib/script/commands/IndexDocumentCommands.java | Java | gpl-3.0 | 4,085 | [
30522,
1013,
1008,
1008,
1008,
6105,
3820,
2005,
7480,
14644,
18069,
2121,
6299,
1008,
1008,
9385,
1006,
1039,
1007,
2286,
1011,
2325,
14459,
16155,
1013,
22770,
5705,
15794,
1008,
1008,
8299,
1024,
1013,
1013,
7479,
1012,
2330,
1011,
3945,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var _ = require('lodash');
var doFacesIntersect = require('./face-intersection').doFacesIntersect;
function flatMeshIntersects(mesh){
var numFaces = mesh.faces.length;
for (var i = 0; i < numFaces; ++i) {
var firstFace = _.map(mesh.faces[i].vertices, function(vertexIndex){
return mesh.vertices[vertexIndex];
});
for (var j = i + 1; j < numFaces; ++j) {
var secondFace = _.map(mesh.faces[j].vertices, function(vertexIndex){
return mesh.vertices[vertexIndex];
});
if (doFacesIntersect(firstFace, secondFace)) {
return true;
}
}
}
return false;
}
exports.flatMeshIntersects = flatMeshIntersects;
| mjleehh/paper-model | lib/algorithms/flat-mesh-intersection.js | JavaScript | gpl-3.0 | 737 | [
30522,
13075,
1035,
1027,
5478,
1006,
1005,
8840,
8883,
2232,
1005,
1007,
1025,
13075,
2079,
12172,
11493,
7747,
22471,
1027,
5478,
1006,
1005,
1012,
1013,
2227,
1011,
6840,
1005,
1007,
1012,
2079,
12172,
11493,
7747,
22471,
1025,
3853,
425... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Copyright (c) 2011-2012 Litecoin Developers
// Copyright (c) 2013-2013 Bluecoin Developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "netbase.h"
#include "util.h"
#ifndef WIN32
#include <sys/fcntl.h>
#endif
#include "strlcpy.h"
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
using namespace std;
// Settings
typedef std::pair<CService, int> proxyType;
static proxyType proxyInfo[NET_MAX];
static proxyType nameproxyInfo;
int nConnectTimeout = 5000;
bool fNameLookup = false;
static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
enum Network ParseNetwork(std::string net) {
boost::to_lower(net);
if (net == "ipv4") return NET_IPV4;
if (net == "ipv6") return NET_IPV6;
if (net == "tor") return NET_TOR;
if (net == "i2p") return NET_I2P;
return NET_UNROUTABLE;
}
void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {
size_t colon = in.find_last_of(':');
// if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator
bool fHaveColon = colon != in.npos;
bool fBracketed = fHaveColon && (in[0]=='[' && in[colon-1]==']'); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe
bool fMultiColon = fHaveColon && (in.find_last_of(':',colon-1) != in.npos);
if (fHaveColon && (colon==0 || fBracketed || !fMultiColon)) {
char *endp = NULL;
int n = strtol(in.c_str() + colon + 1, &endp, 10);
if (endp && *endp == 0 && n >= 0) {
in = in.substr(0, colon);
if (n > 0 && n < 0x10000)
portOut = n;
}
}
if (in.size()>0 && in[0] == '[' && in[in.size()-1] == ']')
hostOut = in.substr(1, in.size()-2);
else
hostOut = in;
}
bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
{
vIP.clear();
{
CNetAddr addr;
if (addr.SetSpecial(std::string(pszName))) {
vIP.push_back(addr);
return true;
}
}
struct addrinfo aiHint;
memset(&aiHint, 0, sizeof(struct addrinfo));
aiHint.ai_socktype = SOCK_STREAM;
aiHint.ai_protocol = IPPROTO_TCP;
#ifdef WIN32
# ifdef USE_IPV6
aiHint.ai_family = AF_UNSPEC;
# else
aiHint.ai_family = AF_INET;
# endif
aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST;
#else
# ifdef USE_IPV6
aiHint.ai_family = AF_UNSPEC;
# else
aiHint.ai_family = AF_INET;
# endif
aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST;
#endif
struct addrinfo *aiRes = NULL;
int nErr = getaddrinfo(pszName, NULL, &aiHint, &aiRes);
if (nErr)
return false;
struct addrinfo *aiTrav = aiRes;
while (aiTrav != NULL && (nMaxSolutions == 0 || vIP.size() < nMaxSolutions))
{
if (aiTrav->ai_family == AF_INET)
{
assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in));
vIP.push_back(CNetAddr(((struct sockaddr_in*)(aiTrav->ai_addr))->sin_addr));
}
#ifdef USE_IPV6
if (aiTrav->ai_family == AF_INET6)
{
assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in6));
vIP.push_back(CNetAddr(((struct sockaddr_in6*)(aiTrav->ai_addr))->sin6_addr));
}
#endif
aiTrav = aiTrav->ai_next;
}
freeaddrinfo(aiRes);
return (vIP.size() > 0);
}
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
{
if (pszName[0] == 0)
return false;
char psz[256];
char *pszHost = psz;
strlcpy(psz, pszName, sizeof(psz));
if (psz[0] == '[' && psz[strlen(psz)-1] == ']')
{
pszHost = psz+1;
psz[strlen(psz)-1] = 0;
}
return LookupIntern(pszHost, vIP, nMaxSolutions, fAllowLookup);
}
bool LookupHostNumeric(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions)
{
return LookupHost(pszName, vIP, nMaxSolutions, false);
}
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
{
if (pszName[0] == 0)
return false;
int port = portDefault;
std::string hostname = "";
SplitHostPort(std::string(pszName), port, hostname);
std::vector<CNetAddr> vIP;
bool fRet = LookupIntern(hostname.c_str(), vIP, nMaxSolutions, fAllowLookup);
if (!fRet)
return false;
vAddr.resize(vIP.size());
for (unsigned int i = 0; i < vIP.size(); i++)
vAddr[i] = CService(vIP[i], port);
return true;
}
bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLookup)
{
std::vector<CService> vService;
bool fRet = Lookup(pszName, vService, portDefault, fAllowLookup, 1);
if (!fRet)
return false;
addr = vService[0];
return true;
}
bool LookupNumeric(const char *pszName, CService& addr, int portDefault)
{
return Lookup(pszName, addr, portDefault, false);
}
bool static Socks4(const CService &addrDest, SOCKET& hSocket)
{
printf("SOCKS4 connecting %s\n", addrDest.ToString().c_str());
if (!addrDest.IsIPv4())
{
closesocket(hSocket);
return error("Proxy destination is not IPv4");
}
char pszSocks4IP[] = "\4\1\0\0\0\0\0\0user";
struct sockaddr_in addr;
socklen_t len = sizeof(addr);
if (!addrDest.GetSockAddr((struct sockaddr*)&addr, &len) || addr.sin_family != AF_INET)
{
closesocket(hSocket);
return error("Cannot get proxy destination address");
}
memcpy(pszSocks4IP + 2, &addr.sin_port, 2);
memcpy(pszSocks4IP + 4, &addr.sin_addr, 4);
char* pszSocks4 = pszSocks4IP;
int nSize = sizeof(pszSocks4IP);
int ret = send(hSocket, pszSocks4, nSize, MSG_NOSIGNAL);
if (ret != nSize)
{
closesocket(hSocket);
return error("Error sending to proxy");
}
char pchRet[8];
if (recv(hSocket, pchRet, 8, 0) != 8)
{
closesocket(hSocket);
return error("Error reading proxy response");
}
if (pchRet[1] != 0x5a)
{
closesocket(hSocket);
if (pchRet[1] != 0x5b)
printf("ERROR: Proxy returned error %d\n", pchRet[1]);
return false;
}
printf("SOCKS4 connected %s\n", addrDest.ToString().c_str());
return true;
}
bool static Socks5(string strDest, int port, SOCKET& hSocket)
{
printf("SOCKS5 connecting %s\n", strDest.c_str());
if (strDest.size() > 255)
{
closesocket(hSocket);
return error("Hostname too long");
}
char pszSocks5Init[] = "\5\1\0";
char *pszSocks5 = pszSocks5Init;
ssize_t nSize = sizeof(pszSocks5Init) - 1;
ssize_t ret = send(hSocket, pszSocks5, nSize, MSG_NOSIGNAL);
if (ret != nSize)
{
closesocket(hSocket);
return error("Error sending to proxy");
}
char pchRet1[2];
if (recv(hSocket, pchRet1, 2, 0) != 2)
{
closesocket(hSocket);
return error("Error reading proxy response");
}
if (pchRet1[0] != 0x05 || pchRet1[1] != 0x00)
{
closesocket(hSocket);
return error("Proxy failed to initialize");
}
string strSocks5("\5\1");
strSocks5 += '\000'; strSocks5 += '\003';
strSocks5 += static_cast<char>(std::min((int)strDest.size(), 255));
strSocks5 += strDest;
strSocks5 += static_cast<char>((port >> 8) & 0xFF);
strSocks5 += static_cast<char>((port >> 0) & 0xFF);
ret = send(hSocket, strSocks5.c_str(), strSocks5.size(), MSG_NOSIGNAL);
if (ret != (ssize_t)strSocks5.size())
{
closesocket(hSocket);
return error("Error sending to proxy");
}
char pchRet2[4];
if (recv(hSocket, pchRet2, 4, 0) != 4)
{
closesocket(hSocket);
return error("Error reading proxy response");
}
if (pchRet2[0] != 0x05)
{
closesocket(hSocket);
return error("Proxy failed to accept request");
}
if (pchRet2[1] != 0x00)
{
closesocket(hSocket);
switch (pchRet2[1])
{
case 0x01: return error("Proxy error: general failure");
case 0x02: return error("Proxy error: connection not allowed");
case 0x03: return error("Proxy error: network unreachable");
case 0x04: return error("Proxy error: host unreachable");
case 0x05: return error("Proxy error: connection refused");
case 0x06: return error("Proxy error: TTL expired");
case 0x07: return error("Proxy error: protocol error");
case 0x08: return error("Proxy error: address type not supported");
default: return error("Proxy error: unknown");
}
}
if (pchRet2[2] != 0x00)
{
closesocket(hSocket);
return error("Error: malformed proxy response");
}
char pchRet3[256];
switch (pchRet2[3])
{
case 0x01: ret = recv(hSocket, pchRet3, 4, 0) != 4; break;
case 0x04: ret = recv(hSocket, pchRet3, 16, 0) != 16; break;
case 0x03:
{
ret = recv(hSocket, pchRet3, 1, 0) != 1;
if (ret)
return error("Error reading from proxy");
int nRecv = pchRet3[0];
ret = recv(hSocket, pchRet3, nRecv, 0) != nRecv;
break;
}
default: closesocket(hSocket); return error("Error: malformed proxy response");
}
if (ret)
{
closesocket(hSocket);
return error("Error reading from proxy");
}
if (recv(hSocket, pchRet3, 2, 0) != 2)
{
closesocket(hSocket);
return error("Error reading from proxy");
}
printf("SOCKS5 connected %s\n", strDest.c_str());
return true;
}
bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRet, int nTimeout)
{
hSocketRet = INVALID_SOCKET;
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
#else
struct sockaddr sockaddr;
#endif
socklen_t len = sizeof(sockaddr);
if (!addrConnect.GetSockAddr((struct sockaddr*)&sockaddr, &len)) {
printf("Cannot connect to %s: unsupported network\n", addrConnect.ToString().c_str());
return false;
}
SOCKET hSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP);
if (hSocket == INVALID_SOCKET)
return false;
#ifdef SO_NOSIGPIPE
int set = 1;
setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int));
#endif
#ifdef WIN32
u_long fNonblock = 1;
if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
#else
int fFlags = fcntl(hSocket, F_GETFL, 0);
if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == -1)
#endif
{
closesocket(hSocket);
return false;
}
if (connect(hSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR)
{
// WSAEINVAL is here because some legacy version of winsock uses it
if (WSAGetLastError() == WSAEINPROGRESS || WSAGetLastError() == WSAEWOULDBLOCK || WSAGetLastError() == WSAEINVAL)
{
struct timeval timeout;
timeout.tv_sec = nTimeout / 1000;
timeout.tv_usec = (nTimeout % 1000) * 1000;
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(hSocket, &fdset);
int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout);
if (nRet == 0)
{
printf("connection timeout\n");
closesocket(hSocket);
return false;
}
if (nRet == SOCKET_ERROR)
{
printf("select() for connection failed: %i\n",WSAGetLastError());
closesocket(hSocket);
return false;
}
socklen_t nRetSize = sizeof(nRet);
#ifdef WIN32
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR)
#else
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
#endif
{
printf("getsockopt() for connection failed: %i\n",WSAGetLastError());
closesocket(hSocket);
return false;
}
if (nRet != 0)
{
printf("connect() failed after select(): %s\n",strerror(nRet));
closesocket(hSocket);
return false;
}
}
#ifdef WIN32
else if (WSAGetLastError() != WSAEISCONN)
#else
else
#endif
{
printf("connect() failed: %i\n",WSAGetLastError());
closesocket(hSocket);
return false;
}
}
// this isn't even strictly necessary
// CNode::ConnectNode immediately turns the socket back to non-blocking
// but we'll turn it back to blocking just in case
#ifdef WIN32
fNonblock = 0;
if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
#else
fFlags = fcntl(hSocket, F_GETFL, 0);
if (fcntl(hSocket, F_SETFL, fFlags & !O_NONBLOCK) == SOCKET_ERROR)
#endif
{
closesocket(hSocket);
return false;
}
hSocketRet = hSocket;
return true;
}
bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion) {
assert(net >= 0 && net < NET_MAX);
if (nSocksVersion != 0 && nSocksVersion != 4 && nSocksVersion != 5)
return false;
if (nSocksVersion != 0 && !addrProxy.IsValid())
return false;
proxyInfo[net] = std::make_pair(addrProxy, nSocksVersion);
return true;
}
bool GetProxy(enum Network net, CService &addrProxy) {
assert(net >= 0 && net < NET_MAX);
if (!proxyInfo[net].second)
return false;
addrProxy = proxyInfo[net].first;
return true;
}
bool SetNameProxy(CService addrProxy, int nSocksVersion) {
if (nSocksVersion != 0 && nSocksVersion != 5)
return false;
if (nSocksVersion != 0 && !addrProxy.IsValid())
return false;
nameproxyInfo = std::make_pair(addrProxy, nSocksVersion);
return true;
}
bool GetNameProxy() {
return nameproxyInfo.second != 0;
}
bool IsProxy(const CNetAddr &addr) {
for (int i=0; i<NET_MAX; i++) {
if (proxyInfo[i].second && (addr == (CNetAddr)proxyInfo[i].first))
return true;
}
return false;
}
bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
{
const proxyType &proxy = proxyInfo[addrDest.GetNetwork()];
// no proxy needed
if (!proxy.second)
return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout);
SOCKET hSocket = INVALID_SOCKET;
// first connect to proxy server
if (!ConnectSocketDirectly(proxy.first, hSocket, nTimeout))
return false;
// do socks negotiation
switch (proxy.second) {
case 4:
if (!Socks4(addrDest, hSocket))
return false;
break;
case 5:
if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket))
return false;
break;
default:
return false;
}
hSocketRet = hSocket;
return true;
}
bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout)
{
string strDest;
int port = portDefault;
SplitHostPort(string(pszDest), port, strDest);
SOCKET hSocket = INVALID_SOCKET;
CService addrResolved(CNetAddr(strDest, fNameLookup && !nameproxyInfo.second), port);
if (addrResolved.IsValid()) {
addr = addrResolved;
return ConnectSocket(addr, hSocketRet, nTimeout);
}
addr = CService("0.0.0.0:0");
if (!nameproxyInfo.second)
return false;
if (!ConnectSocketDirectly(nameproxyInfo.first, hSocket, nTimeout))
return false;
switch(nameproxyInfo.second)
{
default:
case 4: return false;
case 5:
if (!Socks5(strDest, port, hSocket))
return false;
break;
}
hSocketRet = hSocket;
return true;
}
void CNetAddr::Init()
{
memset(ip, 0, 16);
}
void CNetAddr::SetIP(const CNetAddr& ipIn)
{
memcpy(ip, ipIn.ip, sizeof(ip));
}
static const unsigned char pchOnionCat[] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43};
static const unsigned char pchGarliCat[] = {0xFD,0x60,0xDB,0x4D,0xDD,0xB5};
bool CNetAddr::SetSpecial(const std::string &strName)
{
if (strName.size()>6 && strName.substr(strName.size() - 6, 6) == ".onion") {
std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 6).c_str());
if (vchAddr.size() != 16-sizeof(pchOnionCat))
return false;
memcpy(ip, pchOnionCat, sizeof(pchOnionCat));
for (unsigned int i=0; i<16-sizeof(pchOnionCat); i++)
ip[i + sizeof(pchOnionCat)] = vchAddr[i];
return true;
}
if (strName.size()>11 && strName.substr(strName.size() - 11, 11) == ".oc.b32.i2p") {
std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 11).c_str());
if (vchAddr.size() != 16-sizeof(pchGarliCat))
return false;
memcpy(ip, pchOnionCat, sizeof(pchGarliCat));
for (unsigned int i=0; i<16-sizeof(pchGarliCat); i++)
ip[i + sizeof(pchGarliCat)] = vchAddr[i];
return true;
}
return false;
}
CNetAddr::CNetAddr()
{
Init();
}
CNetAddr::CNetAddr(const struct in_addr& ipv4Addr)
{
memcpy(ip, pchIPv4, 12);
memcpy(ip+12, &ipv4Addr, 4);
}
#ifdef USE_IPV6
CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr)
{
memcpy(ip, &ipv6Addr, 16);
}
#endif
CNetAddr::CNetAddr(const char *pszIp, bool fAllowLookup)
{
Init();
std::vector<CNetAddr> vIP;
if (LookupHost(pszIp, vIP, 1, fAllowLookup))
*this = vIP[0];
}
CNetAddr::CNetAddr(const std::string &strIp, bool fAllowLookup)
{
Init();
std::vector<CNetAddr> vIP;
if (LookupHost(strIp.c_str(), vIP, 1, fAllowLookup))
*this = vIP[0];
}
int CNetAddr::GetByte(int n) const
{
return ip[15-n];
}
bool CNetAddr::IsIPv4() const
{
return (memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0);
}
bool CNetAddr::IsIPv6() const
{
return (!IsIPv4() && !IsTor() && !IsI2P());
}
bool CNetAddr::IsRFC1918() const
{
return IsIPv4() && (
GetByte(3) == 10 ||
(GetByte(3) == 192 && GetByte(2) == 168) ||
(GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31)));
}
bool CNetAddr::IsRFC3927() const
{
return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254);
}
bool CNetAddr::IsRFC3849() const
{
return GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x0D && GetByte(12) == 0xB8;
}
bool CNetAddr::IsRFC3964() const
{
return (GetByte(15) == 0x20 && GetByte(14) == 0x02);
}
bool CNetAddr::IsRFC6052() const
{
static const unsigned char pchRFC6052[] = {0,0x64,0xFF,0x9B,0,0,0,0,0,0,0,0};
return (memcmp(ip, pchRFC6052, sizeof(pchRFC6052)) == 0);
}
bool CNetAddr::IsRFC4380() const
{
return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0 && GetByte(12) == 0);
}
bool CNetAddr::IsRFC4862() const
{
static const unsigned char pchRFC4862[] = {0xFE,0x80,0,0,0,0,0,0};
return (memcmp(ip, pchRFC4862, sizeof(pchRFC4862)) == 0);
}
bool CNetAddr::IsRFC4193() const
{
return ((GetByte(15) & 0xFE) == 0xFC);
}
bool CNetAddr::IsRFC6145() const
{
static const unsigned char pchRFC6145[] = {0,0,0,0,0,0,0,0,0xFF,0xFF,0,0};
return (memcmp(ip, pchRFC6145, sizeof(pchRFC6145)) == 0);
}
bool CNetAddr::IsRFC4843() const
{
return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && (GetByte(12) & 0xF0) == 0x10);
}
bool CNetAddr::IsTor() const
{
return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0);
}
bool CNetAddr::IsI2P() const
{
return (memcmp(ip, pchGarliCat, sizeof(pchGarliCat)) == 0);
}
bool CNetAddr::IsLocal() const
{
// IPv4 loopback
if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0))
return true;
// IPv6 loopback (::1/128)
static const unsigned char pchLocal[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
if (memcmp(ip, pchLocal, 16) == 0)
return true;
return false;
}
bool CNetAddr::IsMulticast() const
{
return (IsIPv4() && (GetByte(3) & 0xF0) == 0xE0)
|| (GetByte(15) == 0xFF);
}
bool CNetAddr::IsValid() const
{
// Clean up 3-byte shifted addresses caused by garbage in size field
// of addr messages from versions before 0.2.9 checksum.
// Two consecutive addr messages look like this:
// header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26...
// so if the first length field is garbled, it reads the second batch
// of addr misaligned by 3 bytes.
if (memcmp(ip, pchIPv4+3, sizeof(pchIPv4)-3) == 0)
return false;
// unspecified IPv6 address (::/128)
unsigned char ipNone[16] = {};
if (memcmp(ip, ipNone, 16) == 0)
return false;
// documentation IPv6 address
if (IsRFC3849())
return false;
if (IsIPv4())
{
// INADDR_NONE
uint32_t ipNone = INADDR_NONE;
if (memcmp(ip+12, &ipNone, 4) == 0)
return false;
// 0
ipNone = 0;
if (memcmp(ip+12, &ipNone, 4) == 0)
return false;
}
return true;
}
bool CNetAddr::IsRoutable() const
{
return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor() && !IsI2P()) || IsRFC4843() || IsLocal());
}
enum Network CNetAddr::GetNetwork() const
{
if (!IsRoutable())
return NET_UNROUTABLE;
if (IsIPv4())
return NET_IPV4;
if (IsTor())
return NET_TOR;
if (IsI2P())
return NET_I2P;
return NET_IPV6;
}
std::string CNetAddr::ToStringIP() const
{
if (IsTor())
return EncodeBase32(&ip[6], 10) + ".onion";
if (IsI2P())
return EncodeBase32(&ip[6], 10) + ".oc.b32.i2p";
CService serv(*this, 0);
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
#else
struct sockaddr sockaddr;
#endif
socklen_t socklen = sizeof(sockaddr);
if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) {
char name[1025] = "";
if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), NULL, 0, NI_NUMERICHOST))
return std::string(name);
}
if (IsIPv4())
return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));
else
return strprintf("%x:%x:%x:%x:%x:%x:%x:%x",
GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12),
GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8),
GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4),
GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0));
}
std::string CNetAddr::ToString() const
{
return ToStringIP();
}
bool operator==(const CNetAddr& a, const CNetAddr& b)
{
return (memcmp(a.ip, b.ip, 16) == 0);
}
bool operator!=(const CNetAddr& a, const CNetAddr& b)
{
return (memcmp(a.ip, b.ip, 16) != 0);
}
bool operator<(const CNetAddr& a, const CNetAddr& b)
{
return (memcmp(a.ip, b.ip, 16) < 0);
}
bool CNetAddr::GetInAddr(struct in_addr* pipv4Addr) const
{
if (!IsIPv4())
return false;
memcpy(pipv4Addr, ip+12, 4);
return true;
}
#ifdef USE_IPV6
bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const
{
memcpy(pipv6Addr, ip, 16);
return true;
}
#endif
// get canonical identifier of an address' group
// no two connections will be attempted to addresses with the same group
std::vector<unsigned char> CNetAddr::GetGroup() const
{
std::vector<unsigned char> vchRet;
int nClass = NET_IPV6;
int nStartByte = 0;
int nBits = 16;
// all local addresses belong to the same group
if (IsLocal())
{
nClass = 255;
nBits = 0;
}
// all unroutable addresses belong to the same group
if (!IsRoutable())
{
nClass = NET_UNROUTABLE;
nBits = 0;
}
// for IPv4 addresses, '1' + the 16 higher-order bits of the IP
// includes mapped IPv4, SIIT translated IPv4, and the well-known prefix
else if (IsIPv4() || IsRFC6145() || IsRFC6052())
{
nClass = NET_IPV4;
nStartByte = 12;
}
// for 6to4 tunneled addresses, use the encapsulated IPv4 address
else if (IsRFC3964())
{
nClass = NET_IPV4;
nStartByte = 2;
}
// for Teredo-tunneled IPv6 addresses, use the encapsulated IPv4 address
else if (IsRFC4380())
{
vchRet.push_back(NET_IPV4);
vchRet.push_back(GetByte(3) ^ 0xFF);
vchRet.push_back(GetByte(2) ^ 0xFF);
return vchRet;
}
else if (IsTor())
{
nClass = NET_TOR;
nStartByte = 6;
nBits = 4;
}
else if (IsI2P())
{
nClass = NET_I2P;
nStartByte = 6;
nBits = 4;
}
// for he.net, use /36 groups
else if (GetByte(15) == 0x20 && GetByte(14) == 0x11 && GetByte(13) == 0x04 && GetByte(12) == 0x70)
nBits = 36;
// for the rest of the IPv6 network, use /32 groups
else
nBits = 32;
vchRet.push_back(nClass);
while (nBits >= 8)
{
vchRet.push_back(GetByte(15 - nStartByte));
nStartByte++;
nBits -= 8;
}
if (nBits > 0)
vchRet.push_back(GetByte(15 - nStartByte) | ((1 << nBits) - 1));
return vchRet;
}
uint64 CNetAddr::GetHash() const
{
uint256 hash = Hash(&ip[0], &ip[16]);
uint64 nRet;
memcpy(&nRet, &hash, sizeof(nRet));
return nRet;
}
void CNetAddr::print() const
{
printf("CNetAddr(%s)\n", ToString().c_str());
}
// private extensions to enum Network, only returned by GetExtNetwork,
// and only used in GetReachabilityFrom
static const int NET_UNKNOWN = NET_MAX + 0;
static const int NET_TEREDO = NET_MAX + 1;
int static GetExtNetwork(const CNetAddr *addr)
{
if (addr == NULL)
return NET_UNKNOWN;
if (addr->IsRFC4380())
return NET_TEREDO;
return addr->GetNetwork();
}
/** Calculates a metric for how reachable (*this) is from a given partner */
int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
{
enum Reachability {
REACH_UNREACHABLE,
REACH_DEFAULT,
REACH_TEREDO,
REACH_IPV6_WEAK,
REACH_IPV4,
REACH_IPV6_STRONG,
REACH_PRIVATE
};
if (!IsRoutable())
return REACH_UNREACHABLE;
int ourNet = GetExtNetwork(this);
int theirNet = GetExtNetwork(paddrPartner);
bool fTunnel = IsRFC3964() || IsRFC6052() || IsRFC6145();
switch(theirNet) {
case NET_IPV4:
switch(ourNet) {
default: return REACH_DEFAULT;
case NET_IPV4: return REACH_IPV4;
}
case NET_IPV6:
switch(ourNet) {
default: return REACH_DEFAULT;
case NET_TEREDO: return REACH_TEREDO;
case NET_IPV4: return REACH_IPV4;
case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunneled
}
case NET_TOR:
switch(ourNet) {
default: return REACH_DEFAULT;
case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well
case NET_TOR: return REACH_PRIVATE;
}
case NET_I2P:
switch(ourNet) {
default: return REACH_DEFAULT;
case NET_I2P: return REACH_PRIVATE;
}
case NET_TEREDO:
switch(ourNet) {
default: return REACH_DEFAULT;
case NET_TEREDO: return REACH_TEREDO;
case NET_IPV6: return REACH_IPV6_WEAK;
case NET_IPV4: return REACH_IPV4;
}
case NET_UNKNOWN:
case NET_UNROUTABLE:
default:
switch(ourNet) {
default: return REACH_DEFAULT;
case NET_TEREDO: return REACH_TEREDO;
case NET_IPV6: return REACH_IPV6_WEAK;
case NET_IPV4: return REACH_IPV4;
case NET_I2P: return REACH_PRIVATE; // assume connections from unroutable addresses are
case NET_TOR: return REACH_PRIVATE; // either from Tor/I2P, or don't care about our address
}
}
}
void CService::Init()
{
port = 0;
}
CService::CService()
{
Init();
}
CService::CService(const CNetAddr& cip, unsigned short portIn) : CNetAddr(cip), port(portIn)
{
}
CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNetAddr(ipv4Addr), port(portIn)
{
}
#ifdef USE_IPV6
CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn)
{
}
#endif
CService::CService(const struct sockaddr_in& addr) : CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port))
{
assert(addr.sin_family == AF_INET);
}
#ifdef USE_IPV6
CService::CService(const struct sockaddr_in6 &addr) : CNetAddr(addr.sin6_addr), port(ntohs(addr.sin6_port))
{
assert(addr.sin6_family == AF_INET6);
}
#endif
bool CService::SetSockAddr(const struct sockaddr *paddr)
{
switch (paddr->sa_family) {
case AF_INET:
*this = CService(*(const struct sockaddr_in*)paddr);
return true;
#ifdef USE_IPV6
case AF_INET6:
*this = CService(*(const struct sockaddr_in6*)paddr);
return true;
#endif
default:
return false;
}
}
CService::CService(const char *pszIpPort, bool fAllowLookup)
{
Init();
CService ip;
if (Lookup(pszIpPort, ip, 0, fAllowLookup))
*this = ip;
}
CService::CService(const char *pszIpPort, int portDefault, bool fAllowLookup)
{
Init();
CService ip;
if (Lookup(pszIpPort, ip, portDefault, fAllowLookup))
*this = ip;
}
CService::CService(const std::string &strIpPort, bool fAllowLookup)
{
Init();
CService ip;
if (Lookup(strIpPort.c_str(), ip, 0, fAllowLookup))
*this = ip;
}
CService::CService(const std::string &strIpPort, int portDefault, bool fAllowLookup)
{
Init();
CService ip;
if (Lookup(strIpPort.c_str(), ip, portDefault, fAllowLookup))
*this = ip;
}
unsigned short CService::GetPort() const
{
return port;
}
bool operator==(const CService& a, const CService& b)
{
return (CNetAddr)a == (CNetAddr)b && a.port == b.port;
}
bool operator!=(const CService& a, const CService& b)
{
return (CNetAddr)a != (CNetAddr)b || a.port != b.port;
}
bool operator<(const CService& a, const CService& b)
{
return (CNetAddr)a < (CNetAddr)b || ((CNetAddr)a == (CNetAddr)b && a.port < b.port);
}
bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const
{
if (IsIPv4()) {
if (*addrlen < (socklen_t)sizeof(struct sockaddr_in))
return false;
*addrlen = sizeof(struct sockaddr_in);
struct sockaddr_in *paddrin = (struct sockaddr_in*)paddr;
memset(paddrin, 0, *addrlen);
if (!GetInAddr(&paddrin->sin_addr))
return false;
paddrin->sin_family = AF_INET;
paddrin->sin_port = htons(port);
return true;
}
#ifdef USE_IPV6
if (IsIPv6()) {
if (*addrlen < (socklen_t)sizeof(struct sockaddr_in6))
return false;
*addrlen = sizeof(struct sockaddr_in6);
struct sockaddr_in6 *paddrin6 = (struct sockaddr_in6*)paddr;
memset(paddrin6, 0, *addrlen);
if (!GetIn6Addr(&paddrin6->sin6_addr))
return false;
paddrin6->sin6_family = AF_INET6;
paddrin6->sin6_port = htons(port);
return true;
}
#endif
return false;
}
std::vector<unsigned char> CService::GetKey() const
{
std::vector<unsigned char> vKey;
vKey.resize(18);
memcpy(&vKey[0], ip, 16);
vKey[16] = port / 0x100;
vKey[17] = port & 0x0FF;
return vKey;
}
std::string CService::ToStringPort() const
{
return strprintf("%i", port);
}
std::string CService::ToStringIPPort() const
{
if (IsIPv4() || IsTor() || IsI2P()) {
return ToStringIP() + ":" + ToStringPort();
} else {
return "[" + ToStringIP() + "]:" + ToStringPort();
}
}
std::string CService::ToString() const
{
return ToStringIPPort();
}
void CService::print() const
{
printf("CService(%s)\n", ToString().c_str());
}
void CService::SetPort(unsigned short portIn)
{
port = portIn;
}
| dallen6/bluecoin | src/netbase.cpp | C++ | mit | 32,522 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2268,
1011,
2230,
20251,
6182,
17823,
22591,
3406,
1013,
1013,
9385,
1006,
1039,
1007,
2268,
1011,
2262,
1996,
2978,
3597,
2378,
9797,
1013,
1013,
9385,
1006,
1039,
1007,
2249,
1011,
2262,
5507,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.describe({
name: 'craigslist-utils',
summary: 'Npm Craigslist-utils packaged for Meteor.'
});
Npm.depends ({
'craigslist-utils': '0.0.7'
});
Package.on_use(function (api) {
api.add_files('craigslist-utils.js', ['server']);
api.export('CL');
});
Package.on_test(function (api) {
api.use('craigslist-utils');
api.use('tinytest');
api.add_files('craigslist-utils_tests.js');
});
| premosystems/meteor-craigslist-utils | package.js | JavaScript | mit | 409 | [
30522,
7427,
1012,
6235,
1006,
1063,
2171,
1024,
1005,
7010,
14540,
2923,
1011,
21183,
12146,
1005,
1010,
12654,
1024,
1005,
27937,
2213,
7010,
14540,
2923,
1011,
21183,
12146,
21972,
2005,
23879,
1012,
1005,
1065,
1007,
1025,
27937,
2213,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 edu.virginia.psyc.kaiser.persistence;
import edu.virginia.psyc.kaiser.domain.KaiserStudy;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.mindtrails.domain.Participant;
import org.mindtrails.domain.data.DoNotDelete;
import org.mindtrails.domain.questionnaire.LinkedQuestionnaireData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* This Oasis questionnaire is used over time in the study to determine
* participant progress. So while it can be exported through the admin
* panel, the data should not be deleted. To help make things a little
* safer, we obscure the names of the fields while the data is stored in
* the database.
*/
@Entity
@Table(name="OA")
@Data
@EqualsAndHashCode(callSuper = true)
@DoNotDelete
public class OA extends LinkedQuestionnaireData implements Comparable<OA> {
private static final Logger LOG = LoggerFactory.getLogger(OA.class);
public static int NO_ANSWER = 555;
public static final int MAX_SCORE = 4;
protected String sessionId;
@Column(name="AXF")
@NotNull
private Integer anxious_freq;
@Column(name="AXS")
@NotNull
private Integer anxious_sev;
@Column(name="AVO")
@NotNull
private Integer avoid;
@Column(name="WRK")
@NotNull
private Integer interfere;
@Column(name="SOC")
@NotNull
private Integer interfere_social;
public OA(int anxious_freq, int anxious_sev, int avoid, int interfere, int interfere_social) {
this.anxious_freq=anxious_freq;
this.anxious_sev = anxious_sev;
this.avoid = avoid;
this.interfere = interfere;
this.interfere_social = interfere_social;
this.date = new Date();
}
public OA(){}
public double score() {
int sum = 0;
double total = 0.0;
if(anxious_freq != NO_ANSWER) { sum += anxious_freq; total++;}
if(anxious_sev != NO_ANSWER) { sum += anxious_sev; total++;}
if(avoid != NO_ANSWER) { sum += avoid; total++;}
if(interfere != NO_ANSWER) { sum += interfere; total++;}
if(interfere_social != NO_ANSWER) { sum += interfere_social; total++;}
if (total == 0) return 0;
return(sum / total) * 5;
}
public boolean eligible() {
return(this.score() >= 6 );
}
private boolean noAnswers() {
return(
anxious_freq == NO_ANSWER &&
anxious_sev == NO_ANSWER &&
avoid == NO_ANSWER &&
interfere == NO_ANSWER &&
interfere_social == NO_ANSWER
);
}
public boolean atRisk(OA original) {
if(original.noAnswers()) return false;
return (score() / original.score()) > 1.5;
}
public double getIncrease(OA original) {
return (score() / original.score());
}
@Override
public int compareTo(OA o) {
return date.compareTo(o.date);
}
@Override
public Map<String,Object> modelAttributes(Participant p) {
Map<String, Object> attributes = new HashMap<>();
if (p.getStudy() instanceof KaiserStudy) {
KaiserStudy study = (KaiserStudy) p.getStudy();
attributes.put("inSessions", study.inSession());
} else {
attributes.put("inSessions", false);
}
return attributes;
}
}
| danfunk/MindTrails | kaiser/src/main/java/edu/virginia/psyc/kaiser/persistence/OA.java | Java | mit | 3,551 | [
30522,
7427,
3968,
2226,
1012,
3448,
1012,
8827,
2100,
2278,
1012,
15676,
1012,
28297,
1025,
12324,
3968,
2226,
1012,
3448,
1012,
8827,
2100,
2278,
1012,
15676,
1012,
5884,
1012,
15676,
3367,
20217,
1025,
12324,
8840,
13344,
2243,
1012,
295... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 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.
fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> {
a.iter().map(|a| a*a)
//~^ ERROR binary operation `*` cannot be applied to type `&T`
}
fn main() {
let a = (0..30).collect::<Vec<_>>();
for k in func(&a) {
println!("{}", k);
}
}
| GBGamer/rust | src/test/ui/issues/issue-35668.rs | Rust | apache-2.0 | 734 | [
30522,
1013,
1013,
9385,
2355,
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... |
var path = require("path");
var webpack = require("webpack");
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var pkg = require(path.join(process.cwd(), 'package.json'));
var assetsPath = path.join(__dirname, "public","js");
var publicPath = "/public/";
var commonLoaders = [
{
test: /\.js$|\.jsx$/,
loaders: ["babel"],
include: path.join(__dirname, "app")
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
'css?sourceMap&-restructuring!' +
'autoprefixer-loader'
)
},
{
test: /\.less$/,
loader: ExtractTextPlugin.extract(
'css?sourceMap!' +
'autoprefixer-loader!' +
'less?{"sourceMap":true,"modifyVars":' + JSON.stringify(pkg.theme || {})+'}'
)
}
];
module.exports = {
// The configuration for the client
name: "browser",
/* The entry point of the bundle
* Entry points for multi page app could be more complex
* A good example of entry points would be:
* entry: {
* pageA: "./pageA",
* pageB: "./pageB",
* pageC: "./pageC",
* adminPageA: "./adminPageA",
* adminPageB: "./adminPageB",
* adminPageC: "./adminPageC"
* }
*
* We can then proceed to optimize what are the common chunks
* plugins: [
* new CommonsChunkPlugin("admin-commons.js", ["adminPageA", "adminPageB"]),
* new CommonsChunkPlugin("common.js", ["pageA", "pageB", "admin-commons.js"], 2),
* new CommonsChunkPlugin("c-commons.js", ["pageC", "adminPageC"]);
* ]
*/
context: path.join(__dirname, "app"),
entry: {
app: "./app.js"
},
output: {
// The output directory as absolute path
path: assetsPath,
// The filename of the entry chunk as relative path inside the output.path directory
filename: "bundle.js",
// The output path from the view of the Javascript
publicPath: publicPath
},
module: {
loaders: commonLoaders
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('ant.css', {
disable: false,
allChunks: true
}),
]
};
| gitoneman/react-webpack-redux-starter | webpack.config.js | JavaScript | mit | 2,348 | [
30522,
13075,
4130,
1027,
5478,
1006,
1000,
4130,
1000,
1007,
1025,
13075,
4773,
23947,
1027,
5478,
1006,
1000,
4773,
23947,
1000,
1007,
1025,
13075,
14817,
18209,
24759,
15916,
2378,
1027,
5478,
1006,
1005,
14817,
1011,
3793,
1011,
4773,
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... |
var testLogin = function(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
alert("username="+username+" , password="+password);
}
window.onload = function (){
}
| Xcoder1011/OC_StudyDemo | OC与JS互调/WebView-JS/WebView-JS/加载本地的js,html,css/js/test.js | JavaScript | mit | 248 | [
30522,
13075,
3231,
21197,
2378,
1027,
3853,
1006,
1007,
1063,
13075,
5310,
18442,
1027,
6254,
1012,
2131,
12260,
3672,
3762,
3593,
1006,
1000,
5310,
18442,
1000,
1007,
1012,
3643,
1025,
13075,
20786,
1027,
6254,
1012,
2131,
12260,
3672,
37... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 ssh_test
import (
fakesys "github.com/cloudfoundry/bosh-utils/system/fakes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
boshdir "github.com/cloudfoundry/bosh-cli/director"
. "github.com/cloudfoundry/bosh-cli/ssh"
)
var _ = Describe("SSHArgs", func() {
var (
connOpts ConnectionOpts
result boshdir.SSHResult
forceTTY bool
privKeyFile *fakesys.FakeFile
knownHostsFile *fakesys.FakeFile
fs *fakesys.FakeFileSystem
host boshdir.Host
)
BeforeEach(func() {
connOpts = ConnectionOpts{}
result = boshdir.SSHResult{}
forceTTY = false
fs = fakesys.NewFakeFileSystem()
privKeyFile = fakesys.NewFakeFile("/tmp/priv-key", fs)
knownHostsFile = fakesys.NewFakeFile("/tmp/known-hosts", fs)
host = boshdir.Host{Host: "127.0.0.1", Username: "user"}
})
Describe("LoginForHost", func() {
act := func() []string {
return SSHArgs{}.LoginForHost(host)
}
It("returns login details with IPv4", func() {
Expect(act()).To(Equal([]string{"127.0.0.1", "-l", "user"}))
})
It("returns login details with IPv6 non-bracketed", func() {
host.Host = "::1"
Expect(act()).To(Equal([]string{"::1", "-l", "user"}))
})
})
Describe("OptsForHost", func() {
act := func() []string {
args := SSHArgs{
ConnOpts: connOpts,
Result: result,
ForceTTY: forceTTY,
PrivKeyFile: privKeyFile,
KnownHostsFile: knownHostsFile,
}
return args.OptsForHost(host)
}
It("returns ssh options with correct paths to private key and known hosts", func() {
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
}))
})
It("returns ssh options with forced tty option if requested", func() {
forceTTY = true
Expect(act()).To(Equal([]string{
"-tt",
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
}))
})
It("returns ssh options with custom raw options specified", func() {
connOpts.RawOpts = []string{"raw1", "raw2"}
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"raw1", "raw2",
}))
})
It("returns ssh options with gateway settings returned from the Director", func() {
result.GatewayUsername = "gw-user"
result.GatewayHost = "gw-host"
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", "ProxyCommand=ssh -tt -W %h:%p -l gw-user gw-host -o ServerAliveInterval=30 -o ForwardAgent=no -o ClearAllForwardings=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null",
}))
})
It("returns ssh options with gateway settings returned from the Director and private key set by user", func() {
connOpts.GatewayPrivateKeyPath = "/tmp/gw-priv-key"
result.GatewayUsername = "gw-user"
result.GatewayHost = "gw-host"
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", "ProxyCommand=ssh -tt -W %h:%p -l gw-user gw-host -o ServerAliveInterval=30 -o ForwardAgent=no -o ClearAllForwardings=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PasswordAuthentication=no -o IdentitiesOnly=yes -o IdentityFile=/tmp/gw-priv-key",
}))
})
It("returns ssh options with gateway settings overridden by user even if the Director specifies some", func() {
connOpts.GatewayUsername = "user-gw-user"
connOpts.GatewayHost = "user-gw-host"
result.GatewayUsername = "gw-user"
result.GatewayHost = "gw-host"
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", "ProxyCommand=ssh -tt -W %h:%p -l user-gw-user user-gw-host -o ServerAliveInterval=30 -o ForwardAgent=no -o ClearAllForwardings=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null",
}))
})
It("returns ssh options without gateway settings if disabled even if user or the Director specifies some", func() {
connOpts.GatewayDisable = true
connOpts.GatewayUsername = "user-gw-user"
connOpts.GatewayHost = "user-gw-host"
result.GatewayUsername = "gw-user"
result.GatewayHost = "gw-host"
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
}))
})
It("returns ssh options without socks5 settings if SOCKS5Proxy is set", func() {
connOpts.GatewayDisable = true
connOpts.GatewayUsername = "user-gw-user"
connOpts.GatewayHost = "user-gw-host"
connOpts.SOCKS5Proxy = "socks5://some-proxy"
result.GatewayUsername = "gw-user"
result.GatewayHost = "gw-host"
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", "ProxyCommand=nc -x some-proxy %h %p",
}))
})
It("starts a socks5 proxy and uses the address if SOCKS5Proxy has ssh+socks5:// schema", func() {
connOpts.GatewayDisable = true
connOpts.GatewayUsername = "user-gw-user"
connOpts.GatewayHost = "user-gw-host"
connOpts.SOCKS5Proxy = "ssh+socks5://some-jumpbox-address?private-key=some-private-key-path"
result.GatewayUsername = "gw-user"
result.GatewayHost = "gw-host"
args := NewSSHArgs(
connOpts,
result,
forceTTY,
privKeyFile,
knownHostsFile,
)
Expect(args.OptsForHost(host)).To(ConsistOf(
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", MatchRegexp("ProxyCommand=nc -x 127.0.0.1:\\d+ %h %p"),
))
})
It("returns ssh options with bracketed gateway proxy command if host IP is IPv6", func() {
result.GatewayUsername = "gw-user"
result.GatewayHost = "gw-host"
host = boshdir.Host{Host: "::1", Username: "user"}
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", "ProxyCommand=ssh -tt -W [%h]:%p -l gw-user gw-host -o ServerAliveInterval=30 -o ForwardAgent=no -o ClearAllForwardings=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null",
}))
})
It("returns ssh options with non-bracketed IPs if gateway IP is IPv6", func() {
result.GatewayUsername = "gw-user"
result.GatewayHost = "::1"
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", "ProxyCommand=ssh -tt -W %h:%p -l gw-user ::1 -o ServerAliveInterval=30 -o ForwardAgent=no -o ClearAllForwardings=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null",
}))
})
It("returns ssh options with bracketed and non-bracketed IPs if host and gateway IP is IPv6", func() {
result.GatewayUsername = "gw-user"
result.GatewayHost = "::1"
host = boshdir.Host{Host: "::2", Username: "user"}
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", "ProxyCommand=ssh -tt -W [%h]:%p -l gw-user ::1 -o ServerAliveInterval=30 -o ForwardAgent=no -o ClearAllForwardings=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null",
}))
})
It("returns ssh options non-bracketed if host is IPv6 and SOCKS5Proxy is set", func() {
host = boshdir.Host{Host: "::1", Username: "user"}
connOpts.SOCKS5Proxy = "socks5://some-proxy"
Expect(act()).To(Equal([]string{
"-o", "ServerAliveInterval=30",
"-o", "ForwardAgent=no",
"-o", "PasswordAuthentication=no",
"-o", "IdentitiesOnly=yes",
"-o", "IdentityFile=/tmp/priv-key",
"-o", "StrictHostKeyChecking=yes",
"-o", "UserKnownHostsFile=/tmp/known-hosts",
"-o", "ProxyCommand=nc -x some-proxy %h %p",
}))
})
})
})
| cppforlife/bosh-lint | src/github.com/cloudfoundry/bosh-cli/ssh/ssh_args_test.go | GO | apache-2.0 | 9,932 | [
30522,
7427,
7020,
2232,
1035,
3231,
12324,
1006,
8275,
6508,
2015,
1000,
21025,
2705,
12083,
1012,
4012,
1013,
6112,
14876,
8630,
2854,
1013,
8945,
4095,
1011,
21183,
12146,
1013,
2291,
1013,
8275,
2015,
1000,
1012,
1000,
21025,
2705,
1208... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.craft.client.render;
public class OffsettedOpenGLBuffer extends OpenGLBuffer
{
/**
* Offset in indices list
*/
private int offset;
/**
* Max index registred
*/
private int max = 0;
public void addIndex(int index)
{
super.addIndex(this.offset + index);
if(index > max)
max = index;
}
/**
* Sets offset of this buffer
*/
public void setOffset(int index)
{
this.offset = index;
}
/**
* Gets current offset in indices list
*/
public int getOffset()
{
return offset;
}
/**
* Sets current offset at the end of the indices list
*/
public void setOffsetToEnd()
{
setOffset(offset + max + 1);
max = 0;
}
/**
* Increments the offset by given amount
*/
public void incrementOffset(int amount)
{
offset += amount;
}
}
| jglrxavpok/OurCraft | src/main/java/org/craft/client/render/OffsettedOpenGLBuffer.java | Java | mit | 947 | [
30522,
7427,
8917,
1012,
7477,
1012,
7396,
1012,
17552,
1025,
2270,
2465,
16396,
3064,
26915,
23296,
8569,
12494,
8908,
2330,
23296,
8569,
12494,
1063,
1013,
1008,
1008,
1008,
16396,
1999,
29299,
2862,
1008,
1013,
2797,
20014,
16396,
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... |
/*
* ColorRGB property file
*
* This file is part of the "ForkENGINE" (Copyright (c) 2014 by Lukas Hermanns)
* See "LICENSE.txt" for license information.
*/
#include "Engine/Component/Component.h"
#include "IO/FileSystem/File.h"
namespace Fork
{
namespace Engine
{
Component::Property::Types Component::ColorRGBProperty::Type() const
{
return Types::ColorRGB;
}
void Component::ColorRGBProperty::WriteToFile(IO::File& file) const
{
file.Write<unsigned char>(value.r);
file.Write<unsigned char>(value.g);
file.Write<unsigned char>(value.b);
}
void Component::ColorRGBProperty::ReadFromFile(IO::File& file)
{
value.r = file.Read<unsigned char>();
value.g = file.Read<unsigned char>();
value.b = file.Read<unsigned char>();
}
void Component::ColorRGBProperty::WriteToVariant(IO::Variant& variant) const
{
variant = value;
}
void Component::ColorRGBProperty::ReadFromVariant(const IO::Variant& variant)
{
value = variant.GetColorRGB();
}
} // /namespace Engine
} // /namespace Fork
// ======================== | LukasBanana/ForkENGINE | sources/Engine/Component/Property/ColorRGBProperty.cpp | C++ | bsd-3-clause | 1,063 | [
30522,
1013,
1008,
1008,
3609,
10623,
2497,
3200,
5371,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
1000,
9292,
13159,
3170,
1000,
1006,
9385,
1006,
1039,
1007,
2297,
2011,
23739,
12224,
2015,
1007,
1008,
2156,
1000,
6105,
1012,
19067,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 rugal;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* This is a base test class for non-controller class in testing stage<BR/>
* with the assistance of this test base class, there is no need to redeploy web
* server over and over again, which is
* too time wastage.<BR/>
* any class that extends this class could have the capability to test without
* web server deployment
* <p>
* @author Rugal Bernstein
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = config.ApplicationContext.class)
@Ignore
public abstract class JUnitSpringTestBase
{
public JUnitSpringTestBase()
{
}
}
| sunmaolin/test | test-hibernate/src/test/java/rugal/JUnitSpringTestBase.java | Java | epl-1.0 | 784 | [
30522,
7427,
20452,
2389,
1025,
12324,
8917,
1012,
12022,
4183,
1012,
8568,
1025,
12324,
8917,
1012,
12022,
4183,
1012,
5479,
1012,
2448,
24415,
1025,
12324,
8917,
1012,
3500,
15643,
6198,
1012,
3231,
1012,
6123,
1012,
6123,
8663,
8873,
273... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.rotoplastyc.util;
public class NavDef {
private final String i[];
public final static NavDef ERRO = new NavDef("err","mood_bad","ERRO");
public final static NavDef ERRO2 = new NavDef("err","mood","ERRO");
public NavDef(String contentPointer, String icon, String displayName) {
i = new String[3];
i[0] = contentPointer;
i[1] = icon;
i[2] = displayName;
}
public String getContentPointer() {
return i[0];
}
public String getIcon() {
return i[1];
}
public String getDisplayName() {
return i[2];
}
}
| lucasnoetzold/Viagens | src/java/com/rotoplastyc/util/NavDef.java | Java | apache-2.0 | 641 | [
30522,
7427,
4012,
1012,
18672,
7361,
8523,
3723,
2278,
1012,
21183,
4014,
1025,
2270,
2465,
6583,
16872,
12879,
1063,
2797,
2345,
5164,
1045,
1031,
1033,
1025,
2270,
2345,
10763,
6583,
16872,
12879,
9413,
3217,
1027,
2047,
6583,
16872,
128... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<header>Nombre de dominio local en Internet</header>
<center><tt>mydomain</tt></center>
<hr>
El parámetro "mydomain" especifica el nombre de dominio local en Internet.
Por defecto se usa <tt>$myhostname</tt> menos el primer componente.
<tt>$mydomain</tt> se usa como valor por defecto en otros muchos parámetros
de configuración.
<hr>
| xtso520ok/webmin | postfix/help/opt_mydomain.es.UTF-8.html | HTML | bsd-3-clause | 341 | [
30522,
1026,
20346,
1028,
2053,
19908,
2139,
14383,
5498,
2080,
2334,
4372,
4274,
1026,
1013,
20346,
1028,
1026,
2415,
1028,
1026,
23746,
1028,
2026,
9527,
8113,
1026,
1013,
23746,
1028,
1026,
1013,
2415,
1028,
1026,
17850,
1028,
3449,
1149... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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/>.
*
*/
/*
based on u8g_com_LPC1768_st7920_hw_spi.c
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
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.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef TARGET_LPC1768
// #include <inttypes.h>
// #include "src/core/macros.h"
// #include "Configuration.h"
#include <U8glib.h>
#define SPI_FULL_SPEED 0
#define SPI_HALF_SPEED 1
#define SPI_QUARTER_SPEED 2
#define SPI_EIGHTH_SPEED 3
#define SPI_SIXTEENTH_SPEED 4
#define SPI_SPEED_5 5
#define SPI_SPEED_6 6
void spiBegin();
void spiInit(uint8_t spiRate);
void spiSend(uint8_t b);
void spiSend(const uint8_t* buf, size_t n);
static uint8_t rs_last_state = 255;
static void u8g_com_LPC1768_st7920_write_byte_hw_spi(uint8_t rs, uint8_t val)
{
uint8_t i;
if ( rs != rs_last_state) { // time to send a command/data byte
rs_last_state = rs;
if ( rs == 0 )
/* command */
spiSend(0x0f8);
else
/* data */
spiSend(0x0fa);
for( i = 0; i < 4; i++ ) // give the controller some time to process the data
u8g_10MicroDelay(); // 2 is bad, 3 is OK, 4 is safe
}
spiSend(val & 0x0f0);
spiSend(val << 4);
}
uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
{
switch(msg)
{
case U8G_COM_MSG_INIT:
u8g_SetPILevel(u8g, U8G_PI_CS, 0);
u8g_SetPIOutput(u8g, U8G_PI_CS);
u8g_Delay(5);
spiBegin();
spiInit(SPI_EIGHTH_SPEED); // ST7920 max speed is about 1.1 MHz
u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */
break;
case U8G_COM_MSG_STOP:
break;
case U8G_COM_MSG_RESET:
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
break;
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
break;
case U8G_COM_MSG_CHIP_SELECT:
u8g_SetPILevel(u8g, U8G_PI_CS, arg_val); //note: the st7920 has an active high chip select
break;
case U8G_COM_MSG_WRITE_BYTE:
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val);
break;
case U8G_COM_MSG_WRITE_SEQ:
{
uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 )
{
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--;
}
}
break;
case U8G_COM_MSG_WRITE_SEQ_P:
{
uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 )
{
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--;
}
}
break;
}
return 1;
}
#endif // TARGET_LPC1768
| MoonshineSG/Marlin | Marlin/src/HAL/HAL_LPC1768/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp | C++ | gpl-3.0 | 5,033 | [
30522,
1013,
1008,
1008,
1008,
9388,
30524,
8059,
1013,
9388,
4115,
1033,
1008,
1008,
2241,
2006,
19938,
1998,
24665,
16558,
1012,
1008,
9385,
1006,
1039,
1007,
2249,
11503,
9257,
19739,
19473,
4877,
1013,
10240,
3158,
4315,
23564,
13728,
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... |
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
*
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
*
* 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.
*
* For more information, contact:
*
* Generalitat Valenciana
* Conselleria d'Infraestructures i Transport
* Av. Blasco Ibáñez, 50
* 46010 VALENCIA
* SPAIN
*
* +34 963862235
* gvsig@gva.es
* www.gvsig.gva.es
*
* or
*
* IVER T.I. S.A
* Salamanca 50
* 46005 Valencia
* Spain
*
* +34 963163400
* dac@iver.es
*/
package com.iver.core;
/**
*/
import com.iver.andami.PluginServices;
import com.iver.andami.plugins.Extension;
import com.iver.core.configExtensions.ConfigPlugins;
/**
* Extensión para abrir el diálogo de configuración de ANDAMI.
*
* @author Vicente Caballero Navarro
* @deprecated
*
*/
public class ConfigExtension extends Extension {
/* (non-Javadoc)
* @see com.iver.andami.plugins.Extension#execute(java.lang.String)
*/
public void execute(String actionCommand) {
ConfigPlugins cp=new ConfigPlugins();
PluginServices.getMDIManager().addWindow(cp);
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isVisible() {
return true;
}
/**
* @see com.iver.mdiApp.plugins.IExtension#isEnabled()
*/
public boolean isEnabled() {
return true;
}
/**
* @see com.iver.andami.plugins.IExtension#initialize()
*/
public void initialize() {
}
}
| iCarto/siga | libCorePlugin/src/com/iver/core/ConfigExtension.java | Java | gpl-3.0 | 2,163 | [
30522,
1013,
1008,
1043,
15088,
8004,
1012,
24761,
18532,
2050,
2139,
12367,
21736,
20248,
17643,
8873,
3540,
2139,
2474,
2236,
6590,
2102,
13083,
2532,
1008,
1008,
9385,
1006,
1039,
1007,
2432,
4921,
2121,
1056,
1012,
1045,
1012,
1998,
223... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 the J2ObjC translator. DO NOT EDIT!
// source: ./sandbox/src/java/org/apache/lucene/bkdtree/OfflineLatLonReader.java
//
#include "J2ObjC_header.h"
#pragma push_macro("INCLUDE_ALL_OrgApacheLuceneBkdtreeOfflineLatLonReader")
#ifdef RESTRICT_OrgApacheLuceneBkdtreeOfflineLatLonReader
#define INCLUDE_ALL_OrgApacheLuceneBkdtreeOfflineLatLonReader 0
#else
#define INCLUDE_ALL_OrgApacheLuceneBkdtreeOfflineLatLonReader 1
#endif
#undef RESTRICT_OrgApacheLuceneBkdtreeOfflineLatLonReader
#if __has_feature(nullability)
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wnullability"
#pragma GCC diagnostic ignored "-Wnullability-completeness"
#endif
#if !defined (OrgApacheLuceneBkdtreeOfflineLatLonReader_) && (INCLUDE_ALL_OrgApacheLuceneBkdtreeOfflineLatLonReader || defined(INCLUDE_OrgApacheLuceneBkdtreeOfflineLatLonReader))
#define OrgApacheLuceneBkdtreeOfflineLatLonReader_
#define RESTRICT_OrgApacheLuceneBkdtreeLatLonReader 1
#define INCLUDE_OrgApacheLuceneBkdtreeLatLonReader 1
#include "org/apache/lucene/bkdtree/LatLonReader.h"
@class OrgApacheLuceneStoreInputStreamDataInput;
@class OrgLukhnosPortmobileFilePath;
@interface OrgApacheLuceneBkdtreeOfflineLatLonReader : NSObject < OrgApacheLuceneBkdtreeLatLonReader > {
@public
OrgApacheLuceneStoreInputStreamDataInput *in_;
jlong countLeft_;
}
#pragma mark Public
- (void)close;
- (jint)docID;
- (jint)latEnc;
- (jint)lonEnc;
- (jboolean)next;
- (jlong)ord;
#pragma mark Package-Private
- (instancetype __nonnull)initPackagePrivateWithOrgLukhnosPortmobileFilePath:(OrgLukhnosPortmobileFilePath *)tempFile
withLong:(jlong)start
withLong:(jlong)count;
// Disallowed inherited constructors, do not use.
- (instancetype __nonnull)init NS_UNAVAILABLE;
@end
J2OBJC_EMPTY_STATIC_INIT(OrgApacheLuceneBkdtreeOfflineLatLonReader)
J2OBJC_FIELD_SETTER(OrgApacheLuceneBkdtreeOfflineLatLonReader, in_, OrgApacheLuceneStoreInputStreamDataInput *)
FOUNDATION_EXPORT void OrgApacheLuceneBkdtreeOfflineLatLonReader_initPackagePrivateWithOrgLukhnosPortmobileFilePath_withLong_withLong_(OrgApacheLuceneBkdtreeOfflineLatLonReader *self, OrgLukhnosPortmobileFilePath *tempFile, jlong start, jlong count);
FOUNDATION_EXPORT OrgApacheLuceneBkdtreeOfflineLatLonReader *new_OrgApacheLuceneBkdtreeOfflineLatLonReader_initPackagePrivateWithOrgLukhnosPortmobileFilePath_withLong_withLong_(OrgLukhnosPortmobileFilePath *tempFile, jlong start, jlong count) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT OrgApacheLuceneBkdtreeOfflineLatLonReader *create_OrgApacheLuceneBkdtreeOfflineLatLonReader_initPackagePrivateWithOrgLukhnosPortmobileFilePath_withLong_withLong_(OrgLukhnosPortmobileFilePath *tempFile, jlong start, jlong count);
J2OBJC_TYPE_LITERAL_HEADER(OrgApacheLuceneBkdtreeOfflineLatLonReader)
#endif
#if __has_feature(nullability)
#pragma clang diagnostic pop
#endif
#pragma pop_macro("INCLUDE_ALL_OrgApacheLuceneBkdtreeOfflineLatLonReader")
| lukhnos/objclucene | include/org/apache/lucene/bkdtree/OfflineLatLonReader.h | C | mit | 3,070 | [
30522,
1013,
1013,
1013,
1013,
7013,
2011,
1996,
1046,
30524,
1012,
2079,
2025,
10086,
999,
1013,
1013,
3120,
1024,
1012,
1013,
5472,
8758,
1013,
5034,
2278,
1013,
9262,
1013,
8917,
1013,
15895,
1013,
19913,
2638,
1013,
23923,
11927,
9910,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
timeclock
=========
Description
-----------
Very simple tool to observe how time is spent. Using the punch command, times and work categories can be recorded. Then these times can be analyzed, including the use of category groups.
Install
-------
In the source directory, run python setup.py install.
License
-------
Licensed for use under the terms of the GNU Public License, or GPL. See the file 'LICENSE' for details.
Build Status
------------
[](https://travis-ci.org/kd0kfo/timeclock)
| kd0kfo/timeclock | README.md | Markdown | gpl-2.0 | 573 | [
30522,
2051,
20464,
7432,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
6412,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
2200,
3722,
6994,
2000,
11949,
2129,
2051,
2003,
2985,
1012,
2478,
1996,
8595,
3094,
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 uint8_t _pattern16x16[512] = {
0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0x92,0x48,
0x89,0xE6,0xF8,0x00,0xF8,0x00,0x83,0x49,0x5B,0x29,0xF8,0x00,0xF8,0x00,0xF8,0x00,
0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0x89,0xE6,0xFD,0xD6,
0xFE,0x37,0x92,0x47,0xF8,0x00,0x72,0xC7,0xEF,0xDC,0x63,0x6B,0xF8,0x00,0xF8,0x00,
0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0x89,0x48,0xFD,0x93,0xFA,0xA8,
0xD9,0x83,0xFD,0xB3,0x91,0x68,0xAA,0x2B,0xF7,0x1F,0x72,0xF0,0xF8,0x00,0xF8,0x00,
0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xAA,0x2B,0xFD,0xFA,0xE1,0xC4,0xD1,0x21,
0xD9,0x83,0xE1,0xC4,0xFE,0x3B,0x99,0xCA,0xD5,0xFC,0x83,0x93,0xF8,0x00,0xF8,0x00,
0xF8,0x00,0xF8,0x00,0xF8,0x00,0xC1,0xE7,0xFD,0x56,0xEA,0x29,0xAA,0x88,0x68,0x80,
0x79,0x02,0xA2,0x47,0xC9,0x25,0xFD,0xF8,0xC2,0x07,0xB9,0xC7,0xF8,0x00,0xF8,0x00,
0xF8,0x00,0xF8,0x00,0xA1,0x04,0xFD,0xD6,0xE2,0x08,0xD9,0xC7,0x58,0x00,0xFD,0x33,
0xF4,0xB1,0x70,0xA0,0xD9,0xC7,0xC9,0x66,0xFE,0x17,0x98,0xE3,0xF8,0x00,0xF8,0x00,
0xF8,0x00,0x82,0x03,0xFD,0x31,0xE2,0x05,0xC2,0x07,0x78,0x00,0xB6,0x37,0xF7,0xFF,
0xF7,0xFF,0xB6,0x37,0x80,0x00,0xB1,0xA5,0xD9,0xC4,0xFE,0x15,0x69,0x60,0xF8,0x00,
0x92,0x64,0xFD,0xB1,0xEA,0x66,0xD9,0xA4,0x78,0x00,0xFC,0xD1,0xEF,0xDE,0xF7,0xFF,
0xF7,0xFF,0xE7,0xBD,0xFC,0xF2,0x88,0x80,0xD9,0xC4,0xD9,0xC4,0xFE,0xB5,0x8A,0x23,
0x48,0xE4,0x51,0x05,0x40,0x66,0x40,0x66,0xCD,0x58,0xFF,0x5F,0xFF,0xFE,0xFF,0x9C,
0xFF,0xFE,0xFF,0x7C,0xFF,0x7F,0xDD,0xDA,0x38,0x25,0x48,0x87,0x51,0x25,0x48,0xE4,
0xA3,0xAF,0xE5,0xB7,0xED,0xBB,0xFE,0x5E,0xFF,0x3F,0x6A,0x4D,0x62,0xC9,0x62,0xCA,
0x62,0xEA,0x62,0xEA,0x72,0x8D,0xFE,0xFF,0xFE,0x3D,0xED,0xBB,0xE5,0x97,0xAB,0xF0,
0x73,0xCC,0xFF,0xFD,0xEF,0xDE,0xE7,0x9D,0xFF,0xFF,0x94,0xD4,0xFF,0xFF,0xEF,0x9F,
0xB5,0x97,0xFF,0xFF,0x94,0xD4,0xFF,0xFF,0xF7,0xFF,0xF7,0xFE,0xFF,0xFD,0x6B,0xAC,
0x6B,0x8B,0xFF,0xFD,0xF7,0xFE,0xFF,0xFF,0xFF,0xFF,0x4A,0x6A,0xB5,0xB8,0xC6,0x5A,
0xC6,0x3A,0xEF,0x9F,0x5B,0x0D,0xF7,0xBF,0xFF,0xFF,0xF7,0xDE,0xFF,0xFD,0x73,0xCC,
0x6B,0xE7,0xFF,0xF9,0xFF,0xF7,0xFF,0x95,0xFF,0xFB,0xAD,0x50,0xDF,0xFF,0xDF,0xFF,
0xA6,0x9B,0xCF,0xBF,0x9C,0xAE,0xFF,0xFB,0xFF,0xF6,0xFF,0xF7,0xFF,0xF9,0x6B,0xE7,
0x63,0xA6,0xA5,0xAE,0xCD,0xEE,0xCD,0xEE,0xCE,0x34,0x63,0x07,0x33,0x0D,0x32,0xCC,
0x4B,0x8F,0x43,0x4E,0x63,0x07,0xCE,0x54,0xC5,0xAD,0xBD,0x8D,0xAD,0xEF,0x6B,0xE7,
0x73,0x28,0xD6,0x14,0xFF,0x5C,0xEE,0xB9,0xEE,0xD9,0xF7,0x1A,0xFF,0xDA,0xEF,0x58,
0xE6,0xF7,0xEF,0x58,0xF7,0x3B,0xEF,0x1A,0xEE,0xD9,0xFF,0x7C,0xCD,0xF3,0x73,0x08,
0x5A,0x65,0x49,0xC3,0x31,0x03,0x49,0xC6,0x49,0xC6,0x39,0x64,0x39,0x81,0x42,0x03,
0x41,0xE2,0x39,0xA2,0x49,0xC6,0x41,0xA5,0x49,0xC6,0x41,0x64,0x41,0x81,0x6A,0xC7
};
| jakeware/svis | svis_teensy/dependencies/libraries/RA8875/Examples/_Teensy3/patternExample/pattern16x16.h | C | mit | 2,632 | [
30522,
9530,
3367,
21318,
3372,
2620,
1035,
1056,
1035,
5418,
16048,
2595,
16048,
1031,
24406,
1033,
1027,
1063,
1014,
2595,
2546,
2620,
1010,
1014,
2595,
8889,
1010,
1014,
2595,
2546,
2620,
1010,
1014,
2595,
8889,
1010,
1014,
2595,
2546,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
title: "Como incluir os anúncios do Google AdSense em seu site"
description: "Siga as etapas para saber como incluir anúncios em seu site. Crie uma conta do Google AdSense, crie blocos de anúncios, veicule os blocos em seu site, configure as definições de pagamento e receba seus pagamentos."
updated_on: 2014-07-31
key-takeaways:
tldr:
- "Para criar uma conta do Google AdSense, é preciso ter 18 anos, ter uma Conta do Google e fornecer seu endereço."
- "Seu site deve estar ativo antes do envio da inscrição e o conteúdo do site deve estar em conformidade com as políticas do Google AdSense."
- "Crie blocos de anúncios responsivos para garantir que o anúncio esteja adequado para qualquer dispositivo utilizado pelo usuário."
- "Verifique as configurações de pagamento e espere o dinheiro começar a entrar."
notes:
crawler:
- "Certifique-se de que o rastreador do Google AdSense consegue acessar seu site (consulte <a href='https://support.google.com/adsense/answer/10532'>este tópico de ajuda</a>)."
body:
- "Cole todo o código do anúncio na tag de corpo, caso contrário, os anúncios não serão exibidos."
smarttag:
- "<code>data-ad-client</code> e <code>data-ad-slot</code> serão exclusivas para cada anúncio gerado."
- "A tag <code>data-ad-format=auto</code> no código de anúncio gerado ativa o comportamento de dimensão inteligente para o bloco de anúncios responsivo."
---
<p class="intro">
Siga as etapas para saber como incluir anúncios em seu site. Crie uma conta do Google AdSense, crie blocos de anúncios, veicule os blocos em seu site, configure as definições de pagamento e receba seus pagamentos.
</p>
{% include shared/toc.liquid %}
{% include shared/takeaway.liquid list=page.key-takeaways.tldr %}
## Como criar página de exemplo com os anúncios
Neste passo a passo, você criará uma página simples com anúncios responsivos por meio do Google AdSense e do Web Starter Kit:
<img src="images/ad-ss-600.png" sizes="100vw"
srcset="images/ad-ss-1200.png 1200w,
images/ad-ss-900.png 900w,
images/ad-ss-600.png 600w,
images/ad-ss-300.png 300w"
alt="Site de exemplo com anúncios para computador e celular">
Se você ainda não conhece o Web Start Kit, consulte a documentação [Configurar o Web Starter Kit]({{site.fundamentals}}/tools/setup/setup_kit.html), em inglês.
Para incluir anúncios em seu site e receber pagamentos, você precisa seguir estas etapas simples:
1. Criar uma conta do Google AdSense.
2. Criar blocos de anúncios.
3. Veicular blocos de anúncios em uma página.
4. Configurar definições de pagamento.
## Criar uma conta do Google AdSense
Para veicular anúncios em seu site, você precisará de uma conta ativa do Google AdSense. Se você ainda não tem uma conta do Google AdSense, será preciso [criá-la](https://www.google.com/adsense/) e concordar com os termos de serviço do Google AdSense. Ao criar a conta, você precisa verificar:
* Que tem pelo menos 18 anos e possui uma Conta do Google verificada.
* Que possui um site ativo ou outro conteúdo on-line em conformidade com
[políticas do programa Google AdSense](https://support.google.com/adsense/answer/48182). Há anúncios hospedados neste site.
* Você tem um endereço postal e um endereço de e-mail associado à sua conta bancária, para poder receber os pagamentos.
## Criar blocos de anúncios
Um bloco de anúncios é um conjunto de anúncios exibidos em sua página em razão do JavaScript que você adiciona à sua página. Você tem três opções de dimensionamento para os blocos de anúncios:
* **[Responsivo (Recomendado)](https://support.google.com/adsense/answer/3213689)**.
* [Predefinido](https://support.google.com/adsense/answer/6002621).
* [Dimensão personalizada](https://support.google.com/adsense/answer/3289364).
Você está criando um site responsivo, use blocos de anúncios responsivos.
Os anúncios responsivos se redimensionam automaticamente com base no tamanho do dispositivo e na largura do contêiner pai.
Os anúncios responsivos atuam in-line com seu layout responsivo, garantindo que o site ficará bonito em qualquer dispositivo.
Se você não usar blocos de anúncios responsivos, será preciso escrever muito mais códigos para controlar como os anúncios são exibidos com base no dispositivo de um usuário. Mesmo se você especificar o tamanho exato de seus blocos de anúncios, utilize os blocos responsivos no [modo avançado]({{site.fundamentals}}/monetization/ads/customize-ads.html#what-if-responsive-sizing-isnt-enough).
Para simplificar o código e poupar tempo e esforço, o código do anúncio responsivo adapta automaticamente o tamanho do bloco de anúncios ao layout de sua página.
O código calcula o tamanho necessário dinamicamente, com base na largura do contêiner pai do bloco de anúncios, e depois escolhe o tamanho de anúncio com o melhor desempenho que se encaixa no contêiner.
Por exemplo, um site otimizado para dispositivos móveis com largura de 360 px pode exibir um bloco de 320 x 50.
Rastreie os [tamanhos de anúncios com o melhor desempenho](https://support.google.com/adsense/answer/6002621#top) no [Guia de tamanhos de anúncios] do Google AdSense (https://support.google.com/adsense/answer/6002621#top).
### Para criar um bloco de anúncios responsivo
1. Acesse a [guia `Meus anúncios`](https://www.google.com/adsense/app#myads-springboard).
2. Clique em <strong>+Novo bloco de anúncios</strong>.
3. Forneça a seu bloco de anúncios um nome exclusivo. Esse nome é exibido no código de anúncio que é colado em seu site, então faça uma descrição.
4. Selecione <strong>Responsivo</strong> no menu suspenso `Tamanho do anúncio`.
5. Selecione <strong>Inserir anúncios gráficos e de texto</strong> no menu suspenso `Tipo de anúncio`.
6. Clique em <strong>Salvar e gerar código</strong>.
7. Na caixa <strong>Código de anúncio</strong> exibida, selecione a opção <strong>Dimensionamento inteligente (recomendado)</strong> no menu suspenso `Modo`.
Esse é o modo recomendado e que não exige alterações em seu código de anúncio.
Depois de criar o bloco de anúncios, o Google AdSense fornece um snippet de código a ser incluído em seu site, semelhante ao código abaixo:
{% highlight html %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Top ad in web starter kit sample -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="XX-XXX-XXXXXXXXXXXXXXXX"
data-ad-slot="XXXXXXXXXX"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endhighlight %}
{% include shared/remember.liquid title="Note" list=page.notes.smarttag %}
## Incluir blocos de anúncios em seu site
Para incluir o anúncio na página, precisamos colar o snippet fornecido pelo Google AdSense em sua marcação. Se você deseja incluir vários anúncios, pode reutilizar o mesmo bloco de anúncios ou criar vários blocos de anúncios.
1. Abra o `index.html` na pasta `app`.
2. Cole o snippet fornecido na tag `main`.
3. Salve o arquivo e tente visualizá-lo no navegador, depois tente abri-lo em um dispositivo móvel ou pelo emulador do Google Chrome.
{% include shared/remember.liquid title="Remember" list=page.notes.body %}
<div>
<a href="/web/fundamentals/resources/samples/monetization/ads/">
<img src="images/ad-ss-600.png" sizes="100vw"
srcset="images/ad-ss-1200.png 1200w,
images/ad-ss-900.png 900w,
images/ad-ss-600.png 600w,
images/ad-ss-300.png 300w"
alt="Site de exemplo com anúncios para computador e celular">
<br>
Tente
</a>
</div>
## Configurar definições de pagamento
Está imaginando quando seu pagamento do Google AdSense será feito? Tentando descobrir se você será pago neste mês ou no próximo? Não deixe de concluir as etapas abaixo:
1. Verifique se você forneceu quaisquer informações fiscais necessárias no [perfil de recebedor](https://www.google.com/adsense/app#payments3/h=BILLING_PROFILE).
2. Confirme se o nome e o endereço do recebedor estão corretos.
3. Selecione a forma de pagamento na [página `Configurações de pagamento`](https://www.google.com/adsense/app#payments3/h=ACCOUNT_SETTINGS).
4. Insira seu [número pessoal de identificação (PIN, na sigla em inglês)](https://support.google.com/adsense/answer/157667). Esse PIN confirma a exatidão de suas informações de conta.
5. Verifique se seu saldo atinge o [limite de pagamento](https://support.google.com/adsense/answer/1709871).
Consulte a [Introdução aos pagamentos do Google AdSense](https://support.google.com/adsense/answer/1709858) caso tenha dúvidas adicionais.
| beaufortfrancois/WebFundamentals | src/content/pt-br/fundamentals/discovery-and-distribution/monetization/ads/include-ads.markdown | Markdown | apache-2.0 | 8,808 | [
30522,
1011,
1011,
1011,
2516,
1024,
1000,
18609,
4297,
7630,
4313,
9808,
30524,
4313,
2019,
4609,
9793,
2015,
7861,
7367,
2226,
2609,
1012,
13675,
2666,
8529,
2050,
9530,
2696,
2079,
8224,
14997,
16700,
1010,
13675,
2666,
15984,
2891,
2139... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*******************************************************************************
* Agere Systems Inc.
* Wireless device driver for Linux (wlags49).
*
* Copyright (c) 1998-2003 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
* Initially developed by TriplePoint, Inc.
* http://www.triplepoint.com
*
*------------------------------------------------------------------------------
*
* Header for definitions and macros internal to the drvier.
*
*------------------------------------------------------------------------------
*
* SOFTWARE LICENSE
*
* This software is provided subject to the following terms and conditions,
* which you should read carefully before using the software. Using this
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
* Copyright © 2003 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
* modifications, 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 as comments in the code as
* well as in the documentation and/or other materials provided with the
* distribution.
*
* . 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 Agere Systems Inc. nor the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* Disclaimer
*
* THIS SOFTWARE IS PROVIDED AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
* RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. 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, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
******************************************************************************/
#ifndef __WAVELAN2_H__
#define __WAVELAN2_H__
/*******************************************************************************
* include files
******************************************************************************/
#ifdef BUS_PCMCIA
#include <pcmcia/cistpl.h>
#include <pcmcia/cisreg.h>
#include <pcmcia/ciscode.h>
#include <pcmcia/ds.h>
#endif // BUS_PCMCIA
#include <linux/wireless.h>
#include <net/iw_handler.h>
#include <linux/list.h>
#include <linux/interrupt.h>
/*******************************************************************************
* constant definitions
******************************************************************************/
#define p_u8 __u8
#define p_s8 __s8
#define p_u16 __u16
#define p_s16 __s16
#define p_u32 __u32
#define p_s32 __s32
#define p_char char
#define MAX_KEY_LEN (2 + (13 * 2)) // 0x plus 13 hex digit pairs
#define MB_SIZE 1024
#define MAX_ENC_LEN 104
#define MAX_SCAN_TIME_SEC 8
#define MAX_NAPS 32
#define CFG_MB_INFO 0x0820 //Mail Box Info Block
#define NUM_WDS_PORTS 6
#define WVLAN_MAX_LOOKAHEAD (HCF_MAX_MSG+46) /* as per s0005MIC_4.doc */
/* Min/Max/Default Parameter Values */
#if 0 //;? (HCF_TYPE) & HCF_TYPE_AP
//;? why this difference depending on compile option, seems to me it should depend on runtime if anything
#define PARM_DEFAULT_SSID "LinuxAP"
#else
#define PARM_DEFAULT_SSID "ANY"
#endif // HCF_TYPE_AP
#define PARM_MIN_NAME_LEN 1
#define PARM_MAX_NAME_LEN 32
/* The following definitions pertain to module and profile parameters */
// #define PARM_AP_MODE APMode
// #define PARM_NAME_AP_MODE TEXT("APMode")
// #define PARM_DEFAULT_AP_MODE FALSE
#define PARM_AUTHENTICATION Authentication
#define PARM_NAME_AUTHENTICATION TEXT("Authentication")
#define PARM_MIN_AUTHENTICATION 1
#define PARM_MAX_AUTHENTICATION 2
#define PARM_DEFAULT_AUTHENTICATION 1
#define PARM_AUTH_KEY_MGMT_SUITE AuthKeyMgmtSuite
#define PARM_NAME_AUTH_KEY_MGMT_SUITE TEXT("AuthKeyMgmtSuite")
#define PARM_MIN_AUTH_KEY_MGMT_SUITE 0
#define PARM_MAX_AUTH_KEY_MGMT_SUITE 4
#define PARM_DEFAULT_AUTH_KEY_MGMT_SUITE 0
#define PARM_BRSC_2GHZ BRSC2GHz
#define PARM_NAME_BRSC_2GHZ TEXT("BRSC2GHz")
#define PARM_MIN_BRSC 0x0000
#define PARM_MAX_BRSC 0x0FFF
#define PARM_DEFAULT_BRSC_2GHZ 0x000F
#define PARM_BRSC_5GHZ BRSC5GHz
#define PARM_NAME_BRSC_5GHZ TEXT("BRSC5GHz")
#define PARM_DEFAULT_BRSC_5GHZ 0x0150
#define PARM_COEXISTENCE Coexistence
#define PARM_NAME_COEXISTENCE TEXT("Coexistence")
#define PARM_MIN_COEXISTENCE 0x0000
#define PARM_MAX_COEXISTENCE 0x0007
#define PARM_DEFAULT_COEXISTENCE 0x0000
#define PARM_CONFIGURED Configured
#define PARM_NAME_CONFIGURED TEXT("Configured")
#define PARM_CONNECTION_CONTROL ConnectionControl
#define PARM_NAME_CONNECTION_CONTROL TEXT("ConnectionControl")
#define PARM_MIN_CONNECTION_CONTROL 0
#define PARM_MAX_CONNECTION_CONTROL 3
#define PARM_DEFAULT_CONNECTION_CONTROL 2
#define PARM_CREATE_IBSS CreateIBSS
#define PARM_NAME_CREATE_IBSS TEXT("CreateIBSS")
#define PARM_DEFAULT_CREATE_IBSS FALSE
#define PARM_DEFAULT_CREATE_IBSS_STR "N"
#define PARM_DEBUG_FLAG DebugFlag
#define PARM_NAME_DEBUG_FLAG TEXT("DebugFlag")
#define PARM_MIN_DEBUG_FLAG 0
#define PARM_MAX_DEBUG_FLAG 0xFFFF
#define PARM_DEFAULT_DEBUG_FLAG 0xFFFF
#define PARM_DESIRED_SSID DesiredSSID
#define PARM_NAME_DESIRED_SSID TEXT("DesiredSSID")
#define PARM_DOWNLOAD_FIRMWARE DownloadFirmware
#define PARM_NAME_DOWNLOAD_FIRMWARE TEXT("DownloadFirmware")
#define PARM_DRIVER_ENABLE DriverEnable
#define PARM_NAME_DRIVER_ENABLE TEXT("DriverEnable")
#define PARM_DEFAULT_DRIVER_ENABLE TRUE
#define PARM_ENABLE_ENCRYPTION EnableEncryption
#define PARM_NAME_ENABLE_ENCRYPTION TEXT("EnableEncryption")
#define PARM_MIN_ENABLE_ENCRYPTION 0
#define PARM_MAX_ENABLE_ENCRYPTION 7
#define PARM_DEFAULT_ENABLE_ENCRYPTION 0
#define PARM_ENCRYPTION Encryption
#define PARM_NAME_ENCRYPTION TEXT("Encryption")
#define PARM_EXCLUDE_UNENCRYPTED ExcludeUnencrypted
#define PARM_NAME_EXCLUDE_UNENCRYPTED TEXT("ExcludeUnencrypted")
#define PARM_DEFAULT_EXCLUDE_UNENCRYPTED TRUE
#define PARM_DEFAULT_EXCLUDE_UNENCRYPTED_STR "N"
#define PARM_INTRA_BSS_RELAY IntraBSSRelay
#define PARM_NAME_INTRA_BSS_RELAY TEXT("IntraBSSRelay")
#define PARM_DEFAULT_INTRA_BSS_RELAY TRUE
#define PARM_DEFAULT_INTRA_BSS_RELAY_STR "Y"
#define PARM_KEY1 Key1
#define PARM_NAME_KEY1 TEXT("Key1")
#define PARM_KEY2 Key2
#define PARM_NAME_KEY2 TEXT("Key2")
#define PARM_KEY3 Key3
#define PARM_NAME_KEY3 TEXT("Key3")
#define PARM_KEY4 Key4
#define PARM_NAME_KEY4 TEXT("Key4")
//;? #define PARM_KEY_FORMAT AsciiHex
//;? #define PARM_NAME_KEY_FORMAT TEXT("AsciiHex")
#define PARM_LOAD_BALANCING LoadBalancing
#define PARM_NAME_LOAD_BALANCING TEXT("LoadBalancing")
#define PARM_DEFAULT_LOAD_BALANCING TRUE
#define PARM_DEFAULT_LOAD_BALANCING_STR "Y"
#define PARM_MAX_DATA_LENGTH MaxDataLength
#define PARM_NAME_MAX_DATA_LENGTH TEXT("MaxDataLength")
#define PARM_MAX_SLEEP MaxSleepDuration
#define PARM_NAME_MAX_SLEEP TEXT("MaxSleepDuration")
#define PARM_MIN_MAX_PM_SLEEP 1 //;?names nearly right?
#define PARM_MAX_MAX_PM_SLEEP 65535
#define PARM_DEFAULT_MAX_PM_SLEEP 100
#define PARM_MEDIUM_DISTRIBUTION MediumDistribution
#define PARM_NAME_MEDIUM_DISTRIBUTION TEXT("MediumDistribution")
#define PARM_DEFAULT_MEDIUM_DISTRIBUTION TRUE
#define PARM_DEFAULT_MEDIUM_DISTRIBUTION_STR "Y"
#define PARM_MICROWAVE_ROBUSTNESS MicroWaveRobustness
#define PARM_NAME_MICROWAVE_ROBUSTNESS TEXT("MicroWaveRobustness")
#define PARM_DEFAULT_MICROWAVE_ROBUSTNESS FALSE
#define PARM_DEFAULT_MICROWAVE_ROBUSTNESS_STR "N"
#define PARM_MULTICAST_PM_BUFFERING MulticastPMBuffering
#define PARM_NAME_MULTICAST_PM_BUFFERING TEXT("MulticastPMBuffering")
#define PARM_DEFAULT_MULTICAST_PM_BUFFERING TRUE
#define PARM_DEFAULT_MULTICAST_PM_BUFFERING_STR "Y"
#define PARM_MULTICAST_RATE MulticastRate
#define PARM_NAME_MULTICAST_RATE TEXT("MulticastRate")
#ifdef WARP
#define PARM_MIN_MULTICAST_RATE 0x0001
#define PARM_MAX_MULTICAST_RATE 0x0fff
#define PARM_DEFAULT_MULTICAST_RATE_2GHZ 0x0004
#define PARM_DEFAULT_MULTICAST_RATE_5GHZ 0x0010
#else
#define PARM_MIN_MULTICAST_RATE 0x0001
#define PARM_MAX_MULTICAST_RATE 0x0004
#define PARM_DEFAULT_MULTICAST_RATE_2GHZ 0x0002
#define PARM_DEFAULT_MULTICAST_RATE_5GHZ 0x0000
#endif // WARP
#define PARM_MULTICAST_RX MulticastReceive
#define PARM_NAME_MULTICAST_RX TEXT("MulticastReceive")
#define PARM_DEFAULT_MULTICAST_RX TRUE
#define PARM_DEFAULT_MULTICAST_RX_STR "Y"
#define PARM_NETWORK_ADDR NetworkAddress
#define PARM_NAME_NETWORK_ADDR TEXT("NetworkAddress")
#define PARM_DEFAULT_NETWORK_ADDR { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
#define PARM_NETWORK_TYPE NetworkType
#define PARM_NAME_NETWORK_TYPE TEXT("NetworkType")
#define PARM_DEFAULT_NETWORK_TYPE 0
#define PARM_OWN_ATIM_WINDOW OwnATIMWindow
#define PARM_NAME_OWN_ATIM_WINDOW TEXT("OwnATIMWindow")
#define PARM_MIN_OWN_ATIM_WINDOW 0
#define PARM_MAX_OWN_ATIM_WINDOW 100
#define PARM_DEFAULT_OWN_ATIM_WINDOW 0
#define PARM_OWN_BEACON_INTERVAL OwnBeaconInterval
#define PARM_NAME_OWN_BEACON_INTERVAL TEXT("OwnBeaconInterval")
#define PARM_MIN_OWN_BEACON_INTERVAL 20
#define PARM_MAX_OWN_BEACON_INTERVAL 200
#define PARM_DEFAULT_OWN_BEACON_INTERVAL 100
#define PARM_OWN_CHANNEL OwnChannel
#define PARM_NAME_OWN_CHANNEL TEXT("OwnChannel")
#define PARM_MIN_OWN_CHANNEL 1
#define PARM_MAX_OWN_CHANNEL 161
#define PARM_DEFAULT_OWN_CHANNEL 10
#define PARM_OWN_DTIM_PERIOD OwnDTIMPeriod
#define PARM_NAME_OWN_DTIM_PERIOD TEXT("OwnDTIMPeriod")
#define PARM_MIN_OWN_DTIM_PERIOD 1
#define PARM_MAX_OWN_DTIM_PERIOD 65535
#define PARM_DEFAULT_OWN_DTIM_PERIOD 1
#define PARM_OWN_NAME OwnName
#define PARM_NAME_OWN_NAME TEXT("OwnName")
#define PARM_DEFAULT_OWN_NAME "Linux"
#define PARM_OWN_SSID OwnSSID
#define PARM_NAME_OWN_SSID TEXT("OwnSSID")
#define PARM_PM_ENABLED PMEnabled
#define PARM_NAME_PM_ENABLED TEXT("PMEnabled")
#define PARM_MAX_PM_ENABLED 3
#define PARM_PMEPS PMEPS
#define PARM_NAME_PMEPS TEXT("PMEPS")
#define PARM_PM_HOLDOVER_DURATION PMHoldoverDuration
#define PARM_NAME_PM_HOLDOVER_DURATION TEXT("PMHoldoverDuration")
#define PARM_MIN_PM_HOLDOVER_DURATION 1
#define PARM_MAX_PM_HOLDOVER_DURATION 1000
#define PARM_DEFAULT_PM_HOLDOVER_DURATION 100
#define PARM_PM_MODE PowerMode
#define PARM_NAME_PM_MODE TEXT("PowerMode")
#define PARM_PORT_TYPE PortType
#define PARM_NAME_PORT_TYPE TEXT("PortType")
#define PARM_MIN_PORT_TYPE 1
#define PARM_MAX_PORT_TYPE 3
#define PARM_DEFAULT_PORT_TYPE 1
#define PARM_PROMISCUOUS_MODE PromiscuousMode
#define PARM_NAME_PROMISCUOUS_MODE TEXT("PromiscuousMode")
#define PARM_DEFAULT_PROMISCUOUS_MODE FALSE
#define PARM_DEFAULT_PROMISCUOUS_MODE_STR "N"
#define PARM_REJECT_ANY RejectANY
#define PARM_NAME_REJECT_ANY TEXT("RejectANY")
#define PARM_DEFAULT_REJECT_ANY FALSE
#define PARM_DEFAULT_REJECT_ANY_STR "N"
#define PARM_RTS_THRESHOLD RTSThreshold
#define PARM_NAME_RTS_THRESHOLD TEXT("RTSThreshold")
#define PARM_MIN_RTS_THRESHOLD 0
#define PARM_MAX_RTS_THRESHOLD 2347
#define PARM_DEFAULT_RTS_THRESHOLD 2347
#define PARM_RTS_THRESHOLD1 RTSThreshold1
#define PARM_NAME_RTS_THRESHOLD1 TEXT("RTSThreshold1")
#define PARM_RTS_THRESHOLD2 RTSThreshold2
#define PARM_NAME_RTS_THRESHOLD2 TEXT("RTSThreshold2")
#define PARM_RTS_THRESHOLD3 RTSThreshold3
#define PARM_NAME_RTS_THRESHOLD3 TEXT("RTSThreshold3")
#define PARM_RTS_THRESHOLD4 RTSThreshold4
#define PARM_NAME_RTS_THRESHOLD4 TEXT("RTSThreshold4")
#define PARM_RTS_THRESHOLD5 RTSThreshold5
#define PARM_NAME_RTS_THRESHOLD5 TEXT("RTSThreshold5")
#define PARM_RTS_THRESHOLD6 RTSThreshold6
#define PARM_NAME_RTS_THRESHOLD6 TEXT("RTSThreshold6")
#define PARM_SRSC_2GHZ SRSC2GHz
#define PARM_NAME_SRSC_2GHZ TEXT("SRSC2GHz")
#define PARM_MIN_SRSC 0x0000
#define PARM_MAX_SRSC 0x0FFF
#define PARM_DEFAULT_SRSC_2GHZ 0x0FFF
#define PARM_SRSC_5GHZ SRSC5GHz
#define PARM_NAME_SRSC_5GHZ TEXT("SRSC5GHz")
#define PARM_DEFAULT_SRSC_5GHZ 0x0FF0
#define PARM_SYSTEM_SCALE SystemScale
#define PARM_NAME_SYSTEM_SCALE TEXT("SystemScale")
#define PARM_MIN_SYSTEM_SCALE 1
#define PARM_MAX_SYSTEM_SCALE 5
#define PARM_DEFAULT_SYSTEM_SCALE 1
#define PARM_TX_KEY TxKey
#define PARM_NAME_TX_KEY TEXT("TxKey")
#define PARM_MIN_TX_KEY 1
#define PARM_MAX_TX_KEY 4
#define PARM_DEFAULT_TX_KEY 1
#define PARM_TX_POW_LEVEL TxPowLevel
#define PARM_NAME_TX_POW_LEVEL TEXT("TxPowLevel")
#define PARM_MIN_TX_POW_LEVEL 1 // 20 dBm
#define PARM_MAX_TX_POW_LEVEL 6 // 8 dBm
#define PARM_DEFAULT_TX_POW_LEVEL 3 // 15 dBm
#define PARM_TX_RATE TxRateControl
#define PARM_NAME_TX_RATE TEXT("TxRateControl")
#define PARM_MIN_TX_RATE 0x0001
#ifdef WARP
#define PARM_MAX_TX_RATE 0x0FFF
#define PARM_DEFAULT_TX_RATE_2GHZ 0x0FFF
#define PARM_DEFAULT_TX_RATE_5GHZ 0x0FF0
#else
#define PARM_MAX_TX_RATE 0x0007
#define PARM_DEFAULT_TX_RATE_2GHZ 0x0003
#define PARM_DEFAULT_TX_RATE_5GHZ 0x0000
#endif // WARP
#define PARM_TX_RATE1 TxRateControl1
#define PARM_NAME_TX_RATE1 TEXT("TxRateControl1")
#define PARM_TX_RATE2 TxRateControl2
#define PARM_NAME_TX_RATE2 TEXT("TxRateControl2")
#define PARM_TX_RATE3 TxRateControl3
#define PARM_NAME_TX_RATE3 TEXT("TxRateControl3")
#define PARM_TX_RATE4 TxRateControl4
#define PARM_NAME_TX_RATE4 TEXT("TxRateControl4")
#define PARM_TX_RATE5 TxRateControl5
#define PARM_NAME_TX_RATE5 TEXT("TxRateControl5")
#define PARM_TX_RATE6 TxRateControl6
#define PARM_NAME_TX_RATE6 TEXT("TxRateControl6")
#define PARM_VENDORDESCRIPTION VendorDescription
#define PARM_NAME_VENDORDESCRIPTION TEXT("VendorDescription")
#define PARM_WDS_ADDRESS WDSAddress
#define PARM_NAME_WDS_ADDRESS TEXT("WDSAddress")
#define PARM_WDS_ADDRESS1 WDSAddress1
#define PARM_NAME_WDS_ADDRESS1 TEXT("WDSAddress1")
#define PARM_WDS_ADDRESS2 WDSAddress2
#define PARM_NAME_WDS_ADDRESS2 TEXT("WDSAddress2")
#define PARM_WDS_ADDRESS3 WDSAddress3
#define PARM_NAME_WDS_ADDRESS3 TEXT("WDSAddress3")
#define PARM_WDS_ADDRESS4 WDSAddress4
#define PARM_NAME_WDS_ADDRESS4 TEXT("WDSAddress4")
#define PARM_WDS_ADDRESS5 WDSAddress5
#define PARM_NAME_WDS_ADDRESS5 TEXT("WDSAddress5")
#define PARM_WDS_ADDRESS6 WDSAddress6
#define PARM_NAME_WDS_ADDRESS6 TEXT("WDSAddress6")
/*
#define PARM_LONG_RETRY_LIMIT LongRetryLimit
#define PARM_NAME_LONG_RETRY_LIMIT TEXT("LongRetryLimit")
#define PARM_MIN_LONG_RETRY_LIMIT 1
#define PARM_MAX_LONG_RETRY_LIMIT 15
#define PARM_DEFAULT_LONG_RETRY_LIMIT 3
#define PARM_PROBE_DATA_RATES ProbeDataRates
#define PARM_NAME_PROBE_DATA_RATES TEXT("ProbeDataRates")
#define PARM_MIN_PROBE_DATA_RATES 0x0000
#define PARM_MAX_PROBE_DATA_RATES 0x0FFF
#define PARM_DEFAULT_PROBE_DATA_RATES_2GHZ 0x0002
#define PARM_DEFAULT_PROBE_DATA_RATES_5GHZ 0x0010
#define PARM_SHORT_RETRY_LIMIT ShortRetryLimit
#define PARM_NAME_SHORT_RETRY_LIMIT TEXT("ShortRetryLimit")
#define PARM_MIN_SHORT_RETRY_LIMIT 1
#define PARM_MAX_SHORT_RETRY_LIMIT 15
#define PARM_DEFAULT_SHORT_RETRY_LIMIT 7
*/
/*******************************************************************************
* state definitions
******************************************************************************/
/* The following constants are used to track state the device */
#define WL_FRIMWARE_PRESENT 1 // Download if needed
#define WL_FRIMWARE_NOT_PRESENT 0 // Skip over download, assume its already there
#define WL_HANDLING_INT 1 // Actually call the HCF to switch interrupts on/off
#define WL_NOT_HANDLING_INT 0 // Not yet handling interrupts, do not switch on/off
/*******************************************************************************
* macro definitions
******************************************************************************/
/* The following macro ensures that no symbols are exported, minimizing the
chance of a symbol collision in the kernel */
// EXPORT_NO_SYMBOLS;
#define NELEM(arr) (sizeof(arr) / sizeof(arr[0]))
#define WVLAN_VALID_MAC_ADDRESS( x ) \
((x[0]!=0xFF) && (x[1]!=0xFF) && (x[2]!=0xFF) && (x[3]!=0xFF) && (x[4]!=0xFF) && (x[5]!=0xFF))
/*******************************************************************************
* type definitions
******************************************************************************/
#undef FALSE
#undef TRUE
typedef enum
{
FALSE = 0,
TRUE = 1
}
bool_t;
typedef struct _ScanResult
{
//hcf_16 len;
//hcf_16 typ;
int scan_complete;
int num_aps;
SCAN_RS_STRCT APTable [MAX_NAPS];
}
ScanResult;
typedef struct _LINK_STATUS_STRCT
{
hcf_16 len;
hcf_16 typ;
hcf_16 linkStatus; /* 1..5 */
}
LINK_STATUS_STRCT;
typedef struct _ASSOC_STATUS_STRCT
{
hcf_16 len;
hcf_16 typ;
hcf_16 assocStatus; /* 1..3 */
hcf_8 staAddr[ETH_ALEN];
hcf_8 oldApAddr[ETH_ALEN];
}
ASSOC_STATUS_STRCT;
typedef struct _SECURITY_STATUS_STRCT
{
hcf_16 len;
hcf_16 typ;
hcf_16 securityStatus; /* 1..3 */
hcf_8 staAddr[ETH_ALEN];
hcf_16 reason;
}
SECURITY_STATUS_STRCT;
#define WVLAN_WMP_PDU_TYPE_LT_REQ 0x00
#define WVLAN_WMP_PDU_TYPE_LT_RSP 0x01
#define WVLAN_WMP_PDU_TYPE_APL_REQ 0x02
#define WVLAN_WMP_PDU_TYPE_APL_RSP 0x03
typedef struct wvlan_eth_hdr
{
unsigned char dst[ETH_ALEN]; /* Destination address. */
unsigned char src[ETH_ALEN]; /* Source address. */
unsigned short len; /* Length of the PDU. */
}
WVLAN_ETH_HDR, *PWVLAN_ETH_HDR;
typedef struct wvlan_llc_snap
{
unsigned char dsap; /* DSAP (0xAA) */
unsigned char ssap; /* SSAP (0xAA) */
unsigned char ctrl; /* Control (0x03) */
unsigned char oui[3]; /* Organization Unique ID (00-60-1d). */
unsigned char specid[2]; /* Specific ID code (00-01). */
}
WVLAN_LLC_SNAP, *PWVLAN_LLC_SNAP;
typedef struct wvlan_lt_hdr
{
unsigned char version; /* Version (0x00) */
unsigned char type; /* PDU type: 0-req/1-resp. */
unsigned short id; /* Identifier to associate resp to req. */
}
WVLAN_LT_HDR, *PWVLAN_LT_HDR;
typedef struct wvlan_wmp_hdr
{
unsigned char version; /* Version */
unsigned char type; /* PDU type */
}
WVLAN_WMP_HDR, *PWVLAN_WMP_HDR;
#define FILLER_SIZE 1554
#define TEST_PATTERN_SIZE 54
typedef struct wvlan_lt_req
{
unsigned char Filler[TEST_PATTERN_SIZE]; /* minimal length of 54 bytes */
}
WVLAN_LT_REQ, *PWVLAN_LT_REQ;
typedef struct wvlan_lt_rsp
{
char name[32];
/* Measured Data */
unsigned char signal;
unsigned char noise;
unsigned char rxFlow;
unsigned char dataRate;
unsigned short protocol;
/* Capabilities */
unsigned char station;
unsigned char dataRateCap;
unsigned char powerMgmt[4];
unsigned char robustness[4];
unsigned char scaling;
unsigned char reserved[5];
}
WVLAN_LT_RSP, *PWVLAN_LT_RSP;
typedef struct wvlan_rx_wmp_hdr
{
unsigned short status;
unsigned short reserved1[2];
unsigned char silence;
unsigned char signal;
unsigned char rate;
unsigned char rxFlow;
unsigned short reserved2[2];
unsigned short frameControl;
unsigned short duration;
unsigned short address1[3];
unsigned short address2[3];
unsigned short address3[3];
unsigned short sequenceControl;
unsigned short address4[3];
#ifndef HERMES25 //;?just to be on the safe side of inherited but not comprehended code #ifdef HERMES2
unsigned short seems_to_be_unused_reserved3[5]; //;?
unsigned short seems_to_be_unused_reserved4; //;?
#endif // HERMES25
unsigned short HeaderDataLen;
}
WVLAN_RX_WMP_HDR, *PWVLAN_RX_WMP_HDR;
typedef struct wvlan_linktest_req_pdu
{
WVLAN_ETH_HDR ethHdr;
WVLAN_LLC_SNAP llcSnap;
WVLAN_LT_HDR ltHdr;
WVLAN_LT_REQ ltReq;
}
WVLAN_LINKTEST_REQ_PDU, *PWVLAN_LINKTEST_REQ_PDU;
typedef struct wvlan_linktest_rsp_pdu
{
WVLAN_RX_WMP_HDR wmpRxHdr;
WVLAN_ETH_HDR ethHdr;
WVLAN_LLC_SNAP llcSnap;
WVLAN_LT_HDR ltHdr;
WVLAN_LT_RSP ltRsp;
}
WVLAN_LINKTEST_RSP_PDU, *PWVLAN_LINKTEST_RSP_PDU;
typedef struct _LINKTEST_RSP_STRCT
{
hcf_16 len;
hcf_16 typ;
WVLAN_LINKTEST_RSP_PDU ltRsp;
}
LINKTEST_RSP_STRCT;
typedef struct wvlan_wmp_rsp_pdu
{
WVLAN_RX_WMP_HDR wmpRxHdr;
WVLAN_ETH_HDR ethHdr;
WVLAN_LLC_SNAP llcSnap;
WVLAN_WMP_HDR wmpHdr;
}
WVLAN_WMP_RSP_PDU, *PWVLAN_WMP_RSP_PDU;
typedef struct _WMP_RSP_STRCT
{
hcf_16 len;
hcf_16 typ;
WVLAN_WMP_RSP_PDU wmpRsp;
}
WMP_RSP_STRCT;
typedef struct _PROBE_RESP
{
// first part: 802.11
hcf_16 length;
hcf_16 infoType;
hcf_16 reserved0;
//hcf_8 signal;
hcf_8 silence;
hcf_8 signal; // Moved signal here as signal/noise values were flipped
hcf_8 rxFlow;
hcf_8 rate;
hcf_16 reserved1[2];
// second part:
hcf_16 frameControl;
hcf_16 durID;
hcf_8 address1[6];
hcf_8 address2[6];
hcf_8 BSSID[6]; //! this is correct, right ?
hcf_16 sequence;
hcf_8 address4[6];
#ifndef WARP
hcf_8 reserved2[12];
#endif // WARP
hcf_16 dataLength;
// the information in the next 3 fields (DA/SA/LenType) is actually not filled in.
hcf_8 DA[6];
hcf_8 SA[6];
#ifdef WARP
hcf_8 channel;
hcf_8 band;
#else
hcf_16 lenType;
#endif // WARP
hcf_8 timeStamp[8];
hcf_16 beaconInterval;
hcf_16 capability;
hcf_8 rawData[200]; //! <<< think about this number !
hcf_16 flags;
}
PROBE_RESP, *PPROBE_RESP;
typedef struct _ProbeResult
{
int scan_complete;
int num_aps;
PROBE_RESP ProbeTable[MAX_NAPS];
}
ProbeResult;
/* Definitions used to parse capabilities out of the probe responses */
#define CAPABILITY_ESS 0x0001
#define CAPABILITY_IBSS 0x0002
#define CAPABILITY_PRIVACY 0x0010
/* Definitions used to parse the Information Elements out of probe responses */
#define DS_INFO_ELEM 0x03
#define GENERIC_INFO_ELEM 0xdd
#define WPA_MAX_IE_LEN 40
#define WPA_SELECTOR_LEN 4
#define WPA_OUI_TYPE { 0x00, 0x50, 0xf2, 1 }
#define WPA_VERSION 1
#define WPA_AUTH_KEY_MGMT_UNSPEC_802_1X { 0x00, 0x50, 0xf2, 1 }
#define WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X { 0x00, 0x50, 0xf2, 2 }
#define WPA_CIPHER_SUITE_NONE { 0x00, 0x50, 0xf2, 0 }
#define WPA_CIPHER_SUITE_WEP40 { 0x00, 0x50, 0xf2, 1 }
#define WPA_CIPHER_SUITE_TKIP { 0x00, 0x50, 0xf2, 2 }
#define WPA_CIPHER_SUITE_WRAP { 0x00, 0x50, 0xf2, 3 }
#define WPA_CIPHER_SUITE_CCMP { 0x00, 0x50, 0xf2, 4 }
#define WPA_CIPHER_SUITE_WEP104 { 0x00, 0x50, 0xf2, 5 }
typedef enum wvlan_drv_mode
{
WVLAN_DRV_MODE_NO_DOWNLOAD, /* this is the same as STA for Hermes 1 */
/* it is also only applicable for Hermes 1 */
WVLAN_DRV_MODE_STA,
WVLAN_DRV_MODE_AP,
WVLAN_DRV_MODE_MAX
}
WVLAN_DRV_MODE, *PWVLAN_DRV_MODE;
typedef enum wvlan_port_state
{
WVLAN_PORT_STATE_ENABLED,
WVLAN_PORT_STATE_DISABLED,
WVLAN_PORT_STATE_CONNECTED
}
WVLAN_PORT_STATE, *PWVLAN_PORT_STATE;
/*
typedef enum wvlan_connect_state
{
WVLAN_CONNECT_STATE_CONNECTED,
WVLAN_CONNECT_STATE_DISCONNECTED
}
WVLAN_CONNECT_STATE, *PWVLAN_CONNECT_STATE;
*/
typedef enum wvlan_pm_state
{
WVLAN_PM_STATE_DISABLED,
WVLAN_PM_STATE_ENHANCED,
WVLAN_PM_STATE_STANDARD
}
WVLAN_PM_STATE, *PWVLAN_PM_STATE;
typedef struct wvlan_frame
{
struct sk_buff *skb; /* sk_buff for frame. */
hcf_16 port; /* MAC port for the frame. */
hcf_16 len; /* Length of the frame. */
}
WVLAN_FRAME, *PWVLAN_FRAME;
typedef struct wvlan_lframe
{
struct list_head node; /* Node in the list */
WVLAN_FRAME frame; /* Frame. */
}
WVLAN_LFRAME, *PWVLAN_LFRAME;
#define DEFAULT_NUM_TX_FRAMES 48
#define TX_Q_LOW_WATER_MARK (DEFAULT_NUM_TX_FRAMES/3)
#define WVLAN_MAX_TX_QUEUES 1
#ifdef USE_WDS
typedef struct wvlan_wds_if
{
struct net_device *dev;
int is_registered;
int netif_queue_on;
struct net_device_stats stats;
hcf_16 rtsThreshold;
hcf_16 txRateCntl;
hcf_8 wdsAddress[ETH_ALEN];
} WVLAN_WDS_IF, *PWVLAN_WDS_IF;
#endif // USE_WDS
#define NUM_RX_DESC 5
#define NUM_TX_DESC 5
typedef struct dma_strct
{
DESC_STRCT *tx_packet[NUM_TX_DESC];
DESC_STRCT *rx_packet[NUM_RX_DESC];
DESC_STRCT *rx_reclaim_desc, *tx_reclaim_desc; // Descriptors for host-reclaim purposes (see HCF)
int tx_rsc_ind; // DMA Tx resource indicator is maintained in the MSF, not in the HCF
int rx_rsc_ind; // Also added rx resource indicator so that cleanup can be performed if alloc fails
int status;
} DMA_STRCT;
/* Macros used in DMA support */
/* get bus address of {rx,tx}dma structure member, in little-endian byte order */
#define WL_DMA_BUS_ADDR_LE(str, i, mem) \
cpu_to_le32(str##_dma_addr[(i)] + ((hcf_8 *)&str[(i)]->mem - (hcf_8 *)str[(i)]))
struct wl_private
{
#ifdef BUS_PCMCIA
struct pcmcia_device *link;
#endif // BUS_PCMCIA
struct net_device *dev;
// struct net_device *dev_next;
spinlock_t slock;
struct tasklet_struct task;
struct net_device_stats stats;
#ifdef WIRELESS_EXT
struct iw_statistics wstats;
// int spy_number;
// u_char spy_address[IW_MAX_SPY][ETH_ALEN];
// struct iw_quality spy_stat[IW_MAX_SPY];
struct iw_spy_data spy_data;
struct iw_public_data wireless_data;
#endif // WIRELESS_EXT
IFB_STRCT hcfCtx;
//;? struct timer_list timer_oor;
//;? hcf_16 timer_oor_cnt;
u_long wlags49_type; //controls output in /proc/wlags49
u_long flags;
hcf_16 DebugFlag;
int is_registered;
int is_handling_int;
int firmware_present;
CFG_DRV_INFO_STRCT driverInfo;
CFG_IDENTITY_STRCT driverIdentity;
CFG_FW_IDENTITY_STRCT StationIdentity;
CFG_PRI_IDENTITY_STRCT PrimaryIdentity;
CFG_PRI_IDENTITY_STRCT NICIdentity;
ltv_t ltvRecord;
u_long txBytes;
hcf_16 maxPort; /* 0 for STA, 6 for AP */
/* Elements used for async notification from hardware */
RID_LOG_STRCT RidList[10];
ltv_t updatedRecord;
PROBE_RESP ProbeResp;
ASSOC_STATUS_STRCT assoc_stat;
SECURITY_STATUS_STRCT sec_stat;
u_char lookAheadBuf[WVLAN_MAX_LOOKAHEAD];
hcf_8 PortType; // 1 - 3 (1 [Normal] | 3 [AdHoc])
hcf_16 Channel; // 0 - 14 (0)
hcf_16 TxRateControl[2];
hcf_8 DistanceBetweenAPs; // 1 - 3 (1)
hcf_16 RTSThreshold; // 0 - 2347 (2347)
hcf_16 PMEnabled; // 0 - 2, 8001 - 8002 (0)
hcf_8 MicrowaveRobustness;// 0 - 1 (0)
hcf_8 CreateIBSS; // 0 - 1 (0)
hcf_8 MulticastReceive; // 0 - 1 (1)
hcf_16 MaxSleepDuration; // 0 - 65535 (100)
hcf_8 MACAddress[ETH_ALEN];
char NetworkName[HCF_MAX_NAME_LEN+1];
char StationName[HCF_MAX_NAME_LEN+1];
hcf_8 EnableEncryption; // 0 - 1 (0)
char Key1[MAX_KEY_LEN+1];
char Key2[MAX_KEY_LEN+1];
char Key3[MAX_KEY_LEN+1];
char Key4[MAX_KEY_LEN+1];
hcf_8 TransmitKeyID; // 1 - 4 (1)
CFG_DEFAULT_KEYS_STRCT DefaultKeys;
u_char mailbox[MB_SIZE];
char szEncryption[MAX_ENC_LEN];
hcf_16 driverEnable;
hcf_16 wolasEnable;
hcf_16 atimWindow;
hcf_16 holdoverDuration;
hcf_16 MulticastRate[2];
hcf_16 authentication; // is this AP specific?
hcf_16 promiscuousMode;
WVLAN_DRV_MODE DownloadFirmware; // 0 - 2 (0 [None] | 1 [STA] | 2 [AP])
char fw_image_filename[MAX_LINE_SIZE+1];
hcf_16 AuthKeyMgmtSuite;
hcf_16 loadBalancing;
hcf_16 mediumDistribution;
hcf_16 txPowLevel;
//hcf_16 shortRetryLimit;
//hcf_16 longRetryLimit;
hcf_16 srsc[2];
hcf_16 brsc[2];
hcf_16 connectionControl;
//hcf_16 probeDataRates[2];
hcf_16 ownBeaconInterval;
hcf_16 coexistence;
WVLAN_FRAME txF;
WVLAN_LFRAME txList[DEFAULT_NUM_TX_FRAMES];
struct list_head txFree;
struct list_head txQ[WVLAN_MAX_TX_QUEUES];
int netif_queue_on;
int txQ_count;
DESC_STRCT desc_rx;
DESC_STRCT desc_tx;
WVLAN_PORT_STATE portState;
ScanResult scan_results;
ProbeResult probe_results;
int probe_num_aps;
int use_dma;
DMA_STRCT dma;
#ifdef USE_RTS
int useRTS;
#endif // USE_RTS
hcf_8 DTIMPeriod; // 1 - 255 (1)
hcf_16 multicastPMBuffering;
hcf_8 RejectAny; // 0 - 1 (0)
hcf_8 ExcludeUnencrypted; // 0 - 1 (1)
hcf_16 intraBSSRelay;
#ifdef USE_WDS
WVLAN_WDS_IF wds_port[NUM_WDS_PORTS];
#endif // USE_WDS
/* Track whether the card is using WEP encryption or WPA
* so we know what to disable next time through.
* IW_ENCODE_ALG_NONE, IW_ENCODE_ALG_WEP, IW_ENCODE_ALG_TKIP
*/
int wext_enc;
}; // wl_private
#define wl_priv(dev) ((struct wl_private *) netdev_priv(dev))
/********************************************************************/
/* Locking and synchronization functions */
/********************************************************************/
/* These functions *must* be inline or they will break horribly on
* SPARC, due to its weird semantics for save/restore flags. extern
* inline should prevent the kernel from linking or module from
* loading if they are not inlined. */
static inline void wl_lock(struct wl_private *lp,
unsigned long *flags)
{
spin_lock_irqsave(&lp->slock, *flags);
}
static inline void wl_unlock(struct wl_private *lp,
unsigned long *flags)
{
spin_unlock_irqrestore(&lp->slock, *flags);
}
/********************************************************************/
/* Interrupt enable disable functions */
/********************************************************************/
extern inline void wl_act_int_on(struct wl_private *lp)
{
/*
* Only do something when the driver is handling
* interrupts. Handling starts at wl_open and
* ends at wl_close when not in RTS mode
*/
if(lp->is_handling_int == WL_HANDLING_INT) {
hcf_action( &lp->hcfCtx, HCF_ACT_INT_ON );
}
}
extern inline void wl_act_int_off(struct wl_private *lp)
{
/*
* Only do something when the driver is handling
* interrupts. Handling starts at wl_open and
* ends at wl_close when not in RTS mode
*/
if(lp->is_handling_int == WL_HANDLING_INT) {
hcf_action( &lp->hcfCtx, HCF_ACT_INT_OFF );
}
}
#endif // __WAVELAN2_H__
| ziqiaozhou/cachebar | source/drivers/staging/wlags49_h2/wl_internal.h | C | gpl-2.0 | 36,915 | [
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... |
using System;
using Microsoft.VisualStudio.TestTools.UITesting.WpfControls;
namespace CaptainPav.Testing.UI.CodedUI.PageModeling.Wpf
{
/// <summary>
/// Default implementation of a Wpf page model
/// </summary>
public abstract class WpfPageModelBase<T> : PageModelBase<T> where T : WpfControl
{
protected readonly WpfWindow parent;
protected WpfPageModelBase(WpfWindow bw)
{
if (null == bw)
{
throw new ArgumentNullException(nameof(bw));
}
this.parent = bw;
}
protected WpfWindow DocumentWindow => this.parent;
}
} | lazyRiffs/CodedUIFluentExtensions | CodedUIExtensions/CaptainPav.Testing.UI.CodedUI.PageModeling/Wpf/WpfBaseModels.cs | C# | gpl-2.0 | 624 | [
30522,
2478,
2291,
1025,
2478,
7513,
1012,
26749,
8525,
20617,
1012,
3231,
3406,
27896,
1012,
21318,
22199,
2075,
1012,
1059,
14376,
8663,
13181,
4877,
1025,
3415,
15327,
2952,
4502,
2615,
1012,
5604,
30524,
5302,
9247,
15058,
1026,
1056,
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 edu.hm.cs.smc.channels.linkedin.models;
import javax.persistence.Entity;
import edu.hm.cs.smc.database.models.BaseEntity;
@Entity
public class LinkedInEmployeeCountRange extends BaseEntity {
private String code;
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| CCWI/SocialMediaCrawler | src/edu/hm/cs/smc/channels/linkedin/models/LinkedInEmployeeCountRange.java | Java | gpl-3.0 | 482 | [
30522,
7427,
3968,
2226,
1012,
20287,
1012,
20116,
1012,
15488,
2278,
1012,
6833,
1012,
5799,
2378,
1012,
4275,
1025,
12324,
9262,
2595,
1012,
28297,
1012,
9178,
1025,
12324,
3968,
2226,
1012,
20287,
1012,
20116,
1012,
15488,
2278,
1012,
78... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author syaoranhinata <syaoranhinata@gmail.com>
*/
$lang['server'] = '您的 LDAP 伺服器。填寫主機名稱 (<code>localhost</code>) 或完整的 URL (<code>ldap://server.tld:389</code>)';
$lang['port'] = 'LDAP 伺服器端口 (若上方沒填寫完整的 URL)';
$lang['usertree'] = '到哪裏尋找使用者帳號?如: <code>ou=People, dc=server, dc=tld</code>';
$lang['grouptree'] = '到哪裏尋找使用者群組?如: <code>ou=Group, dc=server, dc=tld</code>';
$lang['userfilter'] = '用於搜索使用者賬號的 LDAP 篩選器。如: <code>(&(uid=%{user})(objectClass=posixAccount))</code>';
$lang['groupfilter'] = '用於搜索群組的 LDAP 篩選器。例如 <code>(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))</code>';
$lang['version'] = '使用的通訊協定版本。您可能要設置為 <code>3</code>';
$lang['starttls'] = '使用 TLS 連接嗎?';
$lang['referrals'] = '是否允許引用 (referrals)?';
$lang['binddn'] = '非必要綁定使用者 (optional bind user) 的 DN (匿名綁定不能滿足要求時使用)。如: <code>cn=admin, dc=my, dc=home</code>';
$lang['bindpw'] = '上述使用者的密碼';
$lang['userscope'] = '限制使用者搜索的範圍';
$lang['groupscope'] = '限制群組搜索的範圍';
$lang['groupkey'] = '以其他使用者屬性 (而非標準 AD 群組) 來把使用者分組,例如以部門或電話號碼分類';
$lang['debug'] = '有錯誤時,顯示額外除錯資訊';
$lang['deref_o_0'] = 'LDAP_DEREF_NEVER';
$lang['deref_o_1'] = 'LDAP_DEREF_SEARCHING';
$lang['deref_o_2'] = 'LDAP_DEREF_FINDING';
$lang['deref_o_3'] = 'LDAP_DEREF_ALWAYS';
| mprins/dokuwiki | lib/plugins/authldap/lang/zh-tw/settings.php | PHP | gpl-2.0 | 1,976 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1030,
6105,
14246,
2140,
1016,
1006,
8299,
1024,
1013,
1013,
7479,
1012,
27004,
1012,
8917,
1013,
15943,
1013,
14246,
2140,
1012,
16129,
1007,
1008,
1008,
1030,
3166,
25353,
7113,
5521,
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... |
namespace FinBot.Models
{
public class BotResponse
{
public string ResponseText { get; set; }
}
} | idoban/FinBotApp | FinBot/Models/BotResponse.cs | C# | mit | 117 | [
30522,
3415,
15327,
10346,
18384,
1012,
4275,
1063,
2270,
2465,
28516,
6072,
26029,
3366,
1063,
2270,
5164,
3433,
18209,
1063,
2131,
1025,
2275,
1025,
1065,
1065,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//******************************************************************************************
// Anubis Editor 1.0 - A 3D Adventure Game Engine.
// Copyright (C) 2006-2007 Gorka Suárez García
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//******************************************************************************************
#ifndef _ANUBIS_COLOR_H_
#define _ANUBIS_COLOR_H_
//******************************************************************************************
// Includes.
//******************************************************************************************
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <gl/gl.h>
//******************************************************************************************
// Funciones auxiliares para la conversión de los colores.
//******************************************************************************************
inline GLfloat ColorIntToFloat (int value)
{
return ((float) value) / 255.0f;
}
//------------------------------------------------------------------------------------------
inline int ColorFloatToInt (GLfloat value)
{
return (int) (value * 255.0f);
}
//******************************************************************************************
#endif
//******************************************************************************************
// color.h
//****************************************************************************************** | gorkinovich/IGr | Proyecto/Shared/color.h | C | mit | 2,121 | [
30522,
1013,
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,
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... |
# frozen_string_literal: true
# Grammar for a simple subset of English language
# It is called nano-English because it has a more elaborate
# grammar than pico-English but remains still tiny compared to "real" English
require 'rley' # Load the gem
########################################
# Define a grammar for a nano English-like language
# based on chapter 12 from Jurafski & Martin book.
# Daniel Jurafsky, James H. Martin: "Speech and Language Processing";
# 2009, Pearson Education, Inc., ISBN 978-0135041963
# It defines the syntax of a sentence in a mini English-like language
builder = Rley::grammar_builder do
add_terminals('Pronoun', 'Proper-Noun')
add_terminals('Determiner', 'Noun')
add_terminals('Cardinal_number', 'Ordinal_number', 'Quant')
add_terminals('Verb', 'GerundV', 'Aux')
add_terminals('Predeterminer', 'Preposition')
rule 'language' => 'sentence'
rule 'sentence' => 'declarative'
rule 'sentence' => 'imperative'
rule 'sentence' => 'yes_no_question'
rule 'sentence' => 'wh_subject_question'
rule 'sentence' => 'wh_non_subject_question'
rule 'declarative' => 'NP VP'
rule 'imperative' => 'VP'
rule 'yes_no_question' => 'Aux NP VP'
rule 'wh_subject_question' => 'Wh_NP NP VP'
rule 'wh_non_subject_question' => 'Wh_NP Aux NP VP'
rule 'NP' => 'Predeterminer NP'
rule 'NP' => 'Pronoun'
rule 'NP' => 'Proper-Noun'
rule 'NP' => 'Det Card Ord Quant Nominal'
rule 'VP' => 'Verb'
rule 'VP' => 'Verb NP'
rule 'VP' => 'Verb NP PP'
rule 'VP' => 'Verb PP'
rule 'Det' => 'Determiner'
rule 'Det' => []
rule 'Card' => 'Cardinal_number'
rule 'Card' => []
rule 'Ord' => 'Ordinal_number'
rule 'Ord' => []
rule 'Nominal' => 'Noun'
rule 'Nominal' => 'Nominal Noun'
rule 'Nominal' => 'Nominal GerundVP'
rule 'Nominal' => 'Nominal RelClause'
rule 'PP' => 'Preposition NP'
rule 'GerundVP' => 'GerundV'
rule 'GerundVP' => 'GerundV NP'
rule 'GerundVP' => 'GerundV NP PP'
rule 'GerundVP' => 'GerundV PP'
rule 'RelClause' => 'Relative_pronoun VP'
end
# And now build the grammar...
NanoGrammar = builder.grammar
| famished-tiger/Rley | examples/NLP/nano_eng/nano_grammar.rb | Ruby | mit | 2,096 | [
30522,
1001,
7708,
1035,
5164,
1035,
18204,
1024,
2995,
1001,
8035,
2005,
1037,
3722,
16745,
1997,
2394,
2653,
1001,
2009,
2003,
2170,
28991,
1011,
2394,
2138,
2009,
2038,
1037,
2062,
9603,
1001,
8035,
2084,
27263,
2080,
1011,
2394,
2021,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 "background_extractor.h"
namespace TooManyPeeps {
BackgroundExtractor::BackgroundExtractor(const cv::Mat& original, cv::Mat& result,
int historySize, double threshold)
: ProcessFilter(original, result) {
backgroundExtractor = cv::createBackgroundSubtractorMOG2(historySize, threshold, TRACK_SHADOWS);
// If TRACK_SHADOWS = true, shadows are also marked in result with value = 127
}
BackgroundExtractor::BackgroundExtractor(cv::Mat& image, int historySize, double threshold)
: BackgroundExtractor(image, image, historySize, threshold) {
}
BackgroundExtractor::~BackgroundExtractor(void) {
delete backgroundExtractor;
}
void BackgroundExtractor::execute(void) {
backgroundExtractor->apply(get_original(), get_result());
}
};
| 99-bugs/toomanypeeps | opencv_detector/src/lib/filter/background_extractor.cpp | C++ | mit | 783 | [
30522,
1001,
2421,
1000,
4281,
1035,
14817,
2953,
1012,
1044,
1000,
3415,
15327,
2205,
2386,
18863,
13699,
2015,
1063,
4281,
10288,
6494,
16761,
1024,
1024,
4281,
10288,
6494,
16761,
1006,
9530,
3367,
26226,
1024,
1024,
13523,
1004,
2434,
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... |
void MVM_mast_to_cu(MVMThreadContext *tc, MVMObject *mast, MVMObject *types, MVMRegister *res);
void MVM_mast_to_file(MVMThreadContext *tc, MVMObject *mast, MVMObject *types, MVMString *filename);
| tony-o/deb-rakudodaily | install/include/moar/mast/driver.h | C | artistic-2.0 | 197 | [
30522,
11675,
19842,
2213,
1035,
15429,
1035,
2000,
1035,
12731,
1006,
19842,
20492,
28362,
4215,
8663,
18209,
1008,
22975,
1010,
19842,
5302,
2497,
20614,
1008,
15429,
1010,
19842,
5302,
2497,
20614,
1008,
4127,
1010,
19842,
2213,
2890,
2406... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 Maciej Chałapuk
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 restful
import (
"net/http"
"net/http/httptest"
"testing"
"strings"
"fmt"
)
type testIndexer struct {
TimesCalled int
ReturnedMap map[string]interface{}
}
func NewTestIndexer() *testIndexer {
return &testIndexer{ 0, make(map[string]interface{}) }
}
func (indexer *testIndexer) Index() map[string]interface{} {
indexer.TimesCalled += 1
return indexer.ReturnedMap
}
func TestAllMethodCalled(t *testing.T) {
fakeController := NewTestIndexer()
router, w := NewRouter(), httptest.NewRecorder()
createResourceAndServeARequest(router, "/test", "/", fakeController, w)
if fakeController.TimesCalled != 1 {
t.Errorf("Expected 1 call, got %v.", fakeController.TimesCalled)
}
}
func TestJsonResponseAfterReturningEmptyMapFromAll(t *testing.T) {
fakeController := NewTestIndexer()
router, w := NewRouter(), httptest.NewRecorder()
createResourceAndServeARequest(router, "/test", "/", fakeController, w)
expectedJson := "{}"
actualJson := strings.TrimSpace(string(w.Body.Bytes()))
if expectedJson != actualJson {
t.Errorf("Expected response '%v', got '%v'.", expectedJson, actualJson)
}
}
func TestJsonResponseAfterReturningEmptyMapWithOneString(t *testing.T) {
fakeController := NewTestIndexer()
id0 := "test"
fakeController.ReturnedMap[id0] = id0
router, w := NewRouter(), httptest.NewRecorder()
createResourceAndServeARequest(router, "/test", "/", fakeController, w)
expectedJson := fmt.Sprintf("{\"%v\":\"%v\"}", id0, id0)
actualJson := strings.TrimSpace(string(w.Body.Bytes()))
if expectedJson != actualJson {
t.Errorf("Expected response '%v', got '%v'.", expectedJson, actualJson)
}
}
type testStruct struct {
Test string `json:"test"`
}
func TestJsonResponseAfterReturningEmptyMapWithTwoStructs(t *testing.T) {
fakeController := NewTestIndexer()
id0, id1 := "0", "1"
fakeController.ReturnedMap[id0] = testStruct{id0}
fakeController.ReturnedMap[id1] = testStruct{id1}
router, w := NewRouter(), httptest.NewRecorder()
createResourceAndServeARequest(router, "/test", "/", fakeController, w)
expectedJson := fmt.Sprintf("{\"%v\":{\"test\":\"%v\"},\"%v\":{\"test\":\"%v\"}}", id0, id0, id1, id1)
actualJson := strings.TrimSpace(string(w.Body.Bytes()))
if expectedJson != actualJson {
t.Errorf("Expected response '%v', got '%v'.", expectedJson, actualJson)
}
}
func TestPanicWhenReturningNilMapFromIndexer(t *testing.T) {
fakeController := new(testIndexer) // ReturnedMap is nil
router, w := NewRouter(), httptest.NewRecorder()
defer func() {
if err := recover(); err == nil {
t.Error("Should panic when returned map is nil, but didnt.")
}
}()
createResourceAndServeARequest(router, "/test", "/", fakeController, w)
}
func createResourceAndServeARequest(router *Router,
resource string, request string, controller interface{},
out http.ResponseWriter) {
router.HandleResource(resource, controller)
url := "http://www.domain.com"+ resource + request
req, _ := http.NewRequest("GET", url, nil)
router.ServeHTTP(out, req)
}
| gosmos/restful | restful_test.go | GO | apache-2.0 | 3,673 | [
30522,
1013,
1008,
9385,
2297,
6097,
2666,
3501,
15775,
22972,
14289,
2243,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { createStore } from 'redux'
import { combineReducers } from 'redux';
import { todoReducer } from '../todo-reducer';
import { appReducer } from '../app-reducer';
const todoApp = combineReducers({
todos: todoReducer,
app: appReducer
})
export const store = createStore(todoApp);
store.getState()
// outputs ->
// {
// todos: {
// todos: []
// },
// app: {
// settingsVisible: false,
// ...
// }
// }
| lemieux/smooch-react-talk | presentation/examples/store/composed.js | JavaScript | mit | 434 | [
30522,
12324,
1063,
9005,
19277,
1065,
2013,
1005,
2417,
5602,
1005,
12324,
1063,
11506,
5596,
18796,
2869,
1065,
2013,
1005,
2417,
5602,
1005,
1025,
12324,
1063,
28681,
19574,
18796,
2099,
1065,
2013,
1005,
1012,
1012,
1013,
28681,
2080,
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... |
/* 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/>.
*
* Copyright (C) 2009 - 2012 Jun Liu and Jieping Ye
*/
#include <shogun/lib/slep/overlapping/overlapping.h>
void identifySomeZeroEntries(double * u, int * zeroGroupFlag, int *entrySignFlag,
int *pp, int *gg,
double *v, double lambda1, double lambda2,
int p, int g, double * w, double *G){
int i, j, newZeroNum, iterStep=0;
double twoNorm, temp;
/*
* process the L1 norm
*
* generate the u>=0, and assign values to entrySignFlag
*
*/
for(i=0;i<p;i++){
if (v[i]> lambda1){
u[i]=v[i]-lambda1;
entrySignFlag[i]=1;
}
else{
if (v[i] < -lambda1){
u[i]= -v[i] -lambda1;
entrySignFlag[i]=-1;
}
else{
u[i]=0;
entrySignFlag[i]=0;
}
}
}
/*
* Applying Algorithm 1 for identifying some sparse groups
*
*/
/* zeroGroupFlag denotes whether the corresponding group is zero */
for(i=0;i<g;i++)
zeroGroupFlag[i]=1;
while(1){
iterStep++;
if (iterStep>g+1){
printf("\n Identify Zero Group: iterStep= %d. The code might have a bug! Check it!", iterStep);
return;
}
/*record the number of newly detected sparse groups*/
newZeroNum=0;
for (i=0;i<g;i++){
if(zeroGroupFlag[i]){
/*compute the two norm of the */
twoNorm=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
temp=u[ (int) G[j]];
twoNorm+=temp*temp;
}
twoNorm=sqrt(twoNorm);
/*
printf("\n twoNorm=%2.5f, %2.5f",twoNorm,lambda2 * w[3*i+2]);
*/
/*
* Test whether this group should be sparse
*/
if (twoNorm<= lambda2 * w[3*i+2] ){
zeroGroupFlag[i]=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
u[ (int) G[j]]=0;
newZeroNum++;
/*
printf("\n zero group=%d", i);
*/
}
} /*end of if(!zeroGroupFlag[i]) */
} /*end of for*/
if (newZeroNum==0)
break;
}
*pp=0;
/* zeroGroupFlag denotes whether the corresponding entry is zero */
for(i=0;i<p;i++){
if (u[i]==0){
entrySignFlag[i]=0;
*pp=*pp+1;
}
}
*gg=0;
for(i=0;i<g;i++){
if (zeroGroupFlag[i]==0)
*gg=*gg+1;
}
}
void xFromY(double *x, double *y,
double *u, double *Y,
int p, int g, int *zeroGroupFlag,
double *G, double *w){
int i,j;
for(i=0;i<p;i++)
x[i]=u[i];
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
x[ (int) G[j] ] -= Y[j];
}
}
}/*end of for(i=0;i<g;i++) */
for(i=0;i<p;i++){
if (x[i]>=0){
y[i]=0;
}
else{
y[i]=x[i];
x[i]=0;
}
}
}
void YFromx(double *Y,
double *xnew, double *Ynew,
double lambda2, int g, int *zeroGroupFlag,
double *G, double *w){
int i, j;
double twoNorm, temp;
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
twoNorm=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
temp=xnew[ (int) G[j] ];
Y[j]=temp;
twoNorm+=temp*temp;
}
twoNorm=sqrt(twoNorm); /* two norm for x_{G_i}*/
if (twoNorm > 0 ){ /*if x_{G_i} is non-zero*/
temp=lambda2 * w[3*i+2] / twoNorm;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Y[j] *= temp;
}
else /*if x_{G_j} =0, we let Y^i=Ynew^i*/
{
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Y[j]=Ynew[j];
}
}
}/*end of for(i=0;i<g;i++) */
}
void dualityGap(double *gap, double *penalty2,
double *x, double *Y, int g, int *zeroGroupFlag,
double *G, double *w, double lambda2){
int i,j;
double temp, twoNorm, innerProduct;
*gap=0; *penalty2=0;
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
twoNorm=0;innerProduct=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
temp=x[ (int) G[j] ];
twoNorm+=temp*temp;
innerProduct+=temp * Y[j];
}
twoNorm=sqrt(twoNorm)* w[3*i +2];
*penalty2+=twoNorm;
twoNorm=lambda2 * twoNorm;
if (twoNorm > innerProduct)
*gap+=twoNorm-innerProduct;
}
}/*end of for(i=0;i<g;i++) */
}
void overlapping_gd(double *x, double *gap, double *penalty2,
double *v, int p, int g, double lambda1, double lambda2,
double *w, double *G, double *Y, int maxIter, int flag, double tol){
int YSize=(int) w[3*(g-1) +1]+1;
double *u=(double *)malloc(sizeof(double)*p);
double *y=(double *)malloc(sizeof(double)*p);
double *xnew=(double *)malloc(sizeof(double)*p);
double *Ynew=(double *)malloc(sizeof(double)* YSize );
int *zeroGroupFlag=(int *)malloc(sizeof(int)*g);
int *entrySignFlag=(int *)malloc(sizeof(int)*p);
int pp, gg;
int i, j, iterStep;
double twoNorm,temp, L=1, leftValue, rightValue, gapR, penalty2R;
int nextRestartStep=0;
/*
* call the function to identify some zero entries
*
* entrySignFlag[i]=0 denotes that the corresponding entry is definitely zero
*
* zeroGroupFlag[i]=0 denotes that the corresponding group is definitely zero
*
*/
identifySomeZeroEntries(u, zeroGroupFlag, entrySignFlag,
&pp, &gg,
v, lambda1, lambda2,
p, g, w, G);
penalty2[1]=pp;
penalty2[2]=gg;
/*store pp and gg to penalty2[1] and penalty2[2]*/
/*
*-------------------
* Process Y
*-------------------
* We make sure that Y is feasible
* and if x_i=0, then set Y_{ij}=0
*/
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
/*compute the two norm of the group*/
twoNorm=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
if (! u[ (int) G[j] ] )
Y[j]=0;
twoNorm+=Y[j]*Y[j];
}
twoNorm=sqrt(twoNorm);
if (twoNorm > lambda2 * w[3*i+2] ){
temp=lambda2 * w[3*i+2] / twoNorm;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Y[j]*=temp;
}
}
else{ /*this group is zero*/
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Y[j]=0;
}
}
/*
* set Ynew to zero
*
* in the following processing, we only operator Y and Ynew in the
* possibly non-zero groups by "if(zeroGroupFlag[i])"
*
*/
for(i=0;i<YSize;i++)
Ynew[i]=0;
/*
* ------------------------------------
* Gradient Descent begins here
* ------------------------------------
*/
/*
* compute x=max(u-Y * e, 0);
*
*/
xFromY(x, y, u, Y, p, g, zeroGroupFlag, G, w);
/*the main loop */
for(iterStep=0;iterStep<maxIter;iterStep++){
/*
* the gradient at Y is
*
* omega'(Y)=-x e^T
*
* where x=max(u-Y * e, 0);
*
*/
/*
* line search to find Ynew with appropriate L
*/
while (1){
/*
* compute
* Ynew = proj ( Y + x e^T / L )
*/
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
twoNorm=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
Ynew[j]= Y[j] + x[ (int) G[j] ] / L;
twoNorm+=Ynew[j]*Ynew[j];
}
twoNorm=sqrt(twoNorm);
if (twoNorm > lambda2 * w[3*i+2] ){
temp=lambda2 * w[3*i+2] / twoNorm;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Ynew[j]*=temp;
}
}
}/*end of for(i=0;i<g;i++) */
/*
* compute xnew=max(u-Ynew * e, 0);
*
*void xFromY(double *x, double *y,
* double *u, double *Y,
* int p, int g, int *zeroGroupFlag,
* double *G, double *w)
*/
xFromY(xnew, y, u, Ynew, p, g, zeroGroupFlag, G, w);
/* test whether L is appropriate*/
leftValue=0;
for(i=0;i<p;i++){
if (entrySignFlag[i]){
temp=xnew[i]-x[i];
leftValue+= temp * ( 0.5 * temp + y[i]);
}
}
rightValue=0;
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
temp=Ynew[j]-Y[j];
rightValue+=temp * temp;
}
}
}/*end of for(i=0;i<g;i++) */
rightValue=rightValue/2;
if ( leftValue <= L * rightValue){
temp= L * rightValue / leftValue;
if (temp >5)
L=L*0.8;
break;
}
else{
temp=leftValue / rightValue;
if (L*2 <= temp)
L=temp;
else
L=2*L;
if ( L / g - 2* g ){
if (rightValue < 1e-16){
break;
}
else{
printf("\n GD: leftValue=%e, rightValue=%e, ratio=%e", leftValue, rightValue, temp);
printf("\n L=%e > 2 * %d * %d. There might be a bug here. Otherwise, it is due to numerical issue.", L, g, g);
break;
}
}
}
}
/* compute the duality gap at (xnew, Ynew)
*
* void dualityGap(double *gap, double *penalty2,
* double *x, double *Y, int g, int *zeroGroupFlag,
* double *G, double *w, double lambda2)
*
*/
dualityGap(gap, penalty2, xnew, Ynew, g, zeroGroupFlag, G, w, lambda2);
/*
* flag =1 means restart
*
* flag =0 means with restart
*
* nextRestartStep denotes the next "step number" for
* initializing the restart process.
*
* This is based on the fact that, the result is only beneficial when
* xnew is good. In other words,
* if xnew is not good, then the
* restart might not be helpful.
*/
if ( (flag==0) || (flag==1 && iterStep < nextRestartStep )){
/* copy Ynew to Y, and xnew to x */
memcpy(x, xnew, sizeof(double) * p);
memcpy(Y, Ynew, sizeof(double) * YSize);
/*
printf("\n iterStep=%d, L=%2.5f, gap=%e", iterStep, L, *gap);
*/
}
else{
/*
* flag=1
*
* We allow the restart of the program.
*
* Here, Y is constructed as a subgradient of xnew, based on the
* assumption that Y might be a better choice than Ynew, provided
* that xnew is good enough.
*
*/
/*
* compute the restarting point Y with xnew and Ynew
*
*void YFromx(double *Y,
* double *xnew, double *Ynew,
* double lambda2, int g, int *zeroGroupFlag,
* double *G, double *w)
*/
YFromx(Y, xnew, Ynew, lambda2, g, zeroGroupFlag, G, w);
/*compute the solution with the starting point Y
*
*void xFromY(double *x, double *y,
* double *u, double *Y,
* int p, int g, int *zeroGroupFlag,
* double *G, double *w)
*
*/
xFromY(x, y, u, Y, p, g, zeroGroupFlag, G, w);
/*compute the duality at (x, Y)
*
* void dualityGap(double *gap, double *penalty2,
* double *x, double *Y, int g, int *zeroGroupFlag,
* double *G, double *w, double lambda2)
*
*/
dualityGap(&gapR, &penalty2R, x, Y, g, zeroGroupFlag, G, w, lambda2);
if (*gap< gapR){
/*(xnew, Ynew) is better in terms of duality gap*/
/* copy Ynew to Y, and xnew to x */
memcpy(x, xnew, sizeof(double) * p);
memcpy(Y, Ynew, sizeof(double) * YSize);
/*In this case, we do not apply restart, as (x,Y) is not better
*
* We postpone the "restart" by giving a
* "nextRestartStep"
*/
/*
* we test *gap here, in case *gap=0
*/
if (*gap <=tol)
break;
else{
nextRestartStep=iterStep+ (int) sqrt(gapR / *gap);
}
}
else{ /*we use (x, Y), as it is better in terms of duality gap*/
*gap=gapR;
*penalty2=penalty2R;
}
/*
printf("\n iterStep=%d, L=%2.5f, gap=%e, gapR=%e", iterStep, L, *gap, gapR);
*/
}
/*
* if the duality gap is within pre-specified parameter tol
*
* we terminate the algorithm
*/
if (*gap <=tol)
break;
}
penalty2[3]=iterStep;
penalty2[4]=0;
for(i=0;i<g;i++){
if (zeroGroupFlag[i]==0)
penalty2[4]=penalty2[4]+1;
else{
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
if (x[ (int) G[j] ] !=0)
break;
}
if (j>(int) w[3*i +1])
penalty2[4]=penalty2[4]+1;
}
}
/*
* assign sign to the solution x
*/
for(i=0;i<p;i++){
if (entrySignFlag[i]==-1){
x[i]=-x[i];
}
}
free (u);
free (y);
free (xnew);
free (Ynew);
free (zeroGroupFlag);
free (entrySignFlag);
}
void gradientDescentStep(double *xnew, double *Ynew,
double *LL, double *u, double *y, int *entrySignFlag, double lambda2,
double *x, double *Y, int p, int g, int * zeroGroupFlag,
double *G, double *w){
double twoNorm, temp, L=*LL, leftValue, rightValue;
int i,j;
while (1){
/*
* compute
* Ynew = proj ( Y + x e^T / L )
*/
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
twoNorm=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
Ynew[j]= Y[j] + x[ (int) G[j] ] / L;
twoNorm+=Ynew[j]*Ynew[j];
}
twoNorm=sqrt(twoNorm);
if (twoNorm > lambda2 * w[3*i+2] ){
temp=lambda2 * w[3*i+2] / twoNorm;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Ynew[j]*=temp;
}
}
}/*end of for(i=0;i<g;i++) */
/*
* compute xnew=max(u-Ynew * e, 0);
*
*void xFromY(double *x, double *y,
* double *u, double *Y,
* int p, int g, int *zeroGroupFlag,
* double *G, double *w)
*/
xFromY(xnew, y, u, Ynew, p, g, zeroGroupFlag, G, w);
/* test whether L is appropriate*/
leftValue=0;
for(i=0;i<p;i++){
if (entrySignFlag[i]){
temp=xnew[i]-x[i];
leftValue+= temp * ( 0.5 * temp + y[i]);
}
}
rightValue=0;
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
temp=Ynew[j]-Y[j];
rightValue+=temp * temp;
}
}
}/*end of for(i=0;i<g;i++) */
rightValue=rightValue/2;
/*
printf("\n leftValue =%e, rightValue=%e, L=%e", leftValue, rightValue, L);
*/
if ( leftValue <= L * rightValue){
temp= L * rightValue / leftValue;
if (temp >5)
L=L*0.8;
break;
}
else{
temp=leftValue / rightValue;
if (L*2 <= temp)
L=temp;
else
L=2*L;
if ( L / g - 2* g >0 ){
if (rightValue < 1e-16){
break;
}
else{
printf("\n One Gradient Step: leftValue=%e, rightValue=%e, ratio=%e", leftValue, rightValue, temp);
printf("\n L=%e > 2 * %d * %d. There might be a bug here. Otherwise, it is due to numerical issue.", L, g, g);
break;
}
}
}
}
*LL=L;
}
void overlapping_agd(double *x, double *gap, double *penalty2,
double *v, int p, int g, double lambda1, double lambda2,
double *w, double *G, double *Y, int maxIter, int flag, double tol){
int YSize=(int) w[3*(g-1) +1]+1;
double *u=(double *)malloc(sizeof(double)*p);
double *y=(double *)malloc(sizeof(double)*p);
double *xnew=(double *)malloc(sizeof(double)*p);
double *Ynew=(double *)malloc(sizeof(double)* YSize );
double *xS=(double *)malloc(sizeof(double)*p);
double *YS=(double *)malloc(sizeof(double)* YSize );
/*double *xp=(double *)malloc(sizeof(double)*p);*/
double *Yp=(double *)malloc(sizeof(double)* YSize );
int *zeroGroupFlag=(int *)malloc(sizeof(int)*g);
int *entrySignFlag=(int *)malloc(sizeof(int)*p);
int pp, gg;
int i, j, iterStep;
double twoNorm,temp, L=1, leftValue, rightValue, gapR, penalty2R;
int nextRestartStep=0;
double alpha, alphap=0.5, beta, gamma;
/*
* call the function to identify some zero entries
*
* entrySignFlag[i]=0 denotes that the corresponding entry is definitely zero
*
* zeroGroupFlag[i]=0 denotes that the corresponding group is definitely zero
*
*/
identifySomeZeroEntries(u, zeroGroupFlag, entrySignFlag,
&pp, &gg,
v, lambda1, lambda2,
p, g, w, G);
penalty2[1]=pp;
penalty2[2]=gg;
/*store pp and gg to penalty2[1] and penalty2[2]*/
/*
*-------------------
* Process Y
*-------------------
* We make sure that Y is feasible
* and if x_i=0, then set Y_{ij}=0
*/
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
/*compute the two norm of the group*/
twoNorm=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
if (! u[ (int) G[j] ] )
Y[j]=0;
twoNorm+=Y[j]*Y[j];
}
twoNorm=sqrt(twoNorm);
if (twoNorm > lambda2 * w[3*i+2] ){
temp=lambda2 * w[3*i+2] / twoNorm;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Y[j]*=temp;
}
}
else{ /*this group is zero*/
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Y[j]=0;
}
}
/*
* set Ynew and Yp to zero
*
* in the following processing, we only operate, Yp, Y and Ynew in the
* possibly non-zero groups by "if(zeroGroupFlag[i])"
*
*/
for(i=0;i<YSize;i++)
YS[i]=Yp[i]=Ynew[i]=0;
/*
* ---------------
*
* we first do a gradient descent step for determing the value of an approporate L
*
* Also, we initialize gamma
*
* with Y, we compute a new Ynew
*
*/
/*
* compute x=max(u-Y * e, 0);
*/
xFromY(x, y, u, Y, p, g, zeroGroupFlag, G, w);
/*
* compute (xnew, Ynew) from (x, Y)
*
*
* gradientDescentStep(double *xnew, double *Ynew,
double *LL, double *u, double *y, int *entrySignFlag, double lambda2,
double *x, double *Y, int p, int g, int * zeroGroupFlag,
double *G, double *w)
*/
gradientDescentStep(xnew, Ynew,
&L, u, y,entrySignFlag,lambda2,
x, Y, p, g, zeroGroupFlag,
G, w);
/*
* we have finished one gradient descent to get
*
* (x, Y) and (xnew, Ynew), where (xnew, Ynew) is
*
* a gradient descent step based on (x, Y)
*
* we set (xp, Yp)=(x, Y)
*
* (x, Y)= (xnew, Ynew)
*/
/*memcpy(xp, x, sizeof(double) * p);*/
memcpy(Yp, Y, sizeof(double) * YSize);
/*memcpy(x, xnew, sizeof(double) * p);*/
memcpy(Y, Ynew, sizeof(double) * YSize);
gamma=L;
/*
* ------------------------------------
* Accelerated Gradient Descent begins here
* ------------------------------------
*/
for(iterStep=0;iterStep<maxIter;iterStep++){
while (1){
/*
* compute alpha as the positive root of
*
* L * alpha^2 = (1-alpha) * gamma
*
*/
alpha= ( - gamma + sqrt( gamma * gamma + 4 * L * gamma ) ) / 2 / L;
beta= gamma * (1-alphap)/ alphap / (gamma + L * alpha);
/*
* compute YS= Y + beta * (Y - Yp)
*
*/
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
YS[j]=Y[j] + beta * (Y[j]-Yp[j]);
}
}
}/*end of for(i=0;i<g;i++) */
/*
* compute xS
*/
xFromY(xS, y, u, YS, p, g, zeroGroupFlag, G, w);
/*
*
* Ynew = proj ( YS + xS e^T / L )
*
*/
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
twoNorm=0;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
Ynew[j]= YS[j] + xS[ (int) G[j] ] / L;
twoNorm+=Ynew[j]*Ynew[j];
}
twoNorm=sqrt(twoNorm);
if (twoNorm > lambda2 * w[3*i+2] ){
temp=lambda2 * w[3*i+2] / twoNorm;
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++)
Ynew[j]*=temp;
}
}
}/*end of for(i=0;i<g;i++) */
/*
* compute xnew=max(u-Ynew * e, 0);
*
*void xFromY(double *x, double *y,
* double *u, double *Y,
* int p, int g, int *zeroGroupFlag,
* double *G, double *w)
*/
xFromY(xnew, y, u, Ynew, p, g, zeroGroupFlag, G, w);
/* test whether L is appropriate*/
leftValue=0;
for(i=0;i<p;i++){
if (entrySignFlag[i]){
temp=xnew[i]-xS[i];
leftValue+= temp * ( 0.5 * temp + y[i]);
}
}
rightValue=0;
for(i=0;i<g;i++){
if(zeroGroupFlag[i]){ /*this group is non-zero*/
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
temp=Ynew[j]-YS[j];
rightValue+=temp * temp;
}
}
}/*end of for(i=0;i<g;i++) */
rightValue=rightValue/2;
if ( leftValue <= L * rightValue){
temp= L * rightValue / leftValue;
if (temp >5)
L=L*0.8;
break;
}
else{
temp=leftValue / rightValue;
if (L*2 <= temp)
L=temp;
else
L=2*L;
if ( L / g - 2* g >0 ){
if (rightValue < 1e-16){
break;
}
else{
printf("\n AGD: leftValue=%e, rightValue=%e, ratio=%e", leftValue, rightValue, temp);
printf("\n L=%e > 2 * %d * %d. There might be a bug here. Otherwise, it is due to numerical issue.", L, g, g);
break;
}
}
}
}
/* compute the duality gap at (xnew, Ynew)
*
* void dualityGap(double *gap, double *penalty2,
* double *x, double *Y, int g, int *zeroGroupFlag,
* double *G, double *w, double lambda2)
*
*/
dualityGap(gap, penalty2,
xnew, Ynew, g, zeroGroupFlag,
G, w, lambda2);
/*
* if the duality gap is within pre-specified parameter tol
*
* we terminate the algorithm
*/
if (*gap <=tol){
memcpy(x, xnew, sizeof(double) * p);
memcpy(Y, Ynew, sizeof(double) * YSize);
break;
}
/*
* flag =1 means restart
*
* flag =0 means with restart
*
* nextRestartStep denotes the next "step number" for
* initializing the restart process.
*
* This is based on the fact that, the result is only beneficial when
* xnew is good. In other words,
* if xnew is not good, then the
* restart might not be helpful.
*/
if ( (flag==0) || (flag==1 && iterStep < nextRestartStep )){
/*memcpy(xp, x, sizeof(double) * p);*/
memcpy(Yp, Y, sizeof(double) * YSize);
/*memcpy(x, xnew, sizeof(double) * p);*/
memcpy(Y, Ynew, sizeof(double) * YSize);
gamma=gamma * (1-alpha);
alphap=alpha;
/*
printf("\n iterStep=%d, L=%2.5f, gap=%e", iterStep, L, *gap);
*/
}
else{
/*
* flag=1
*
* We allow the restart of the program.
*
* Here, Y is constructed as a subgradient of xnew, based on the
* assumption that Y might be a better choice than Ynew, provided
* that xnew is good enough.
*
*/
/*
* compute the restarting point YS with xnew and Ynew
*
*void YFromx(double *Y,
* double *xnew, double *Ynew,
* double lambda2, int g, int *zeroGroupFlag,
* double *G, double *w)
*/
YFromx(YS, xnew, Ynew, lambda2, g, zeroGroupFlag, G, w);
/*compute the solution with the starting point YS
*
*void xFromY(double *x, double *y,
* double *u, double *Y,
* int p, int g, int *zeroGroupFlag,
* double *G, double *w)
*
*/
xFromY(xS, y, u, YS, p, g, zeroGroupFlag, G, w);
/*compute the duality at (xS, YS)
*
* void dualityGap(double *gap, double *penalty2,
* double *x, double *Y, int g, int *zeroGroupFlag,
* double *G, double *w, double lambda2)
*
*/
dualityGap(&gapR, &penalty2R, xS, YS, g, zeroGroupFlag, G, w, lambda2);
if (*gap< gapR){
/*(xnew, Ynew) is better in terms of duality gap*/
/*In this case, we do not apply restart, as (xS,YS) is not better
*
* We postpone the "restart" by giving a
* "nextRestartStep"
*/
/*memcpy(xp, x, sizeof(double) * p);*/
memcpy(Yp, Y, sizeof(double) * YSize);
/*memcpy(x, xnew, sizeof(double) * p);*/
memcpy(Y, Ynew, sizeof(double) * YSize);
gamma=gamma * (1-alpha);
alphap=alpha;
nextRestartStep=iterStep+ (int) sqrt(gapR / *gap);
}
else{
/*we use (xS, YS), as it is better in terms of duality gap*/
*gap=gapR;
*penalty2=penalty2R;
if (*gap <=tol){
memcpy(x, xS, sizeof(double) * p);
memcpy(Y, YS, sizeof(double) * YSize);
break;
}else{
/*
* we do a gradient descent based on (xS, YS)
*
*/
/*
* compute (x, Y) from (xS, YS)
*
*
* gradientDescentStep(double *xnew, double *Ynew,
* double *LL, double *u, double *y, int *entrySignFlag, double lambda2,
* double *x, double *Y, int p, int g, int * zeroGroupFlag,
* double *G, double *w)
*/
gradientDescentStep(x, Y,
&L, u, y, entrySignFlag,lambda2,
xS, YS, p, g, zeroGroupFlag,
G, w);
/*memcpy(xp, xS, sizeof(double) * p);*/
memcpy(Yp, YS, sizeof(double) * YSize);
gamma=L;
alphap=0.5;
}
}
/*
* printf("\n iterStep=%d, L=%2.5f, gap=%e, gapR=%e", iterStep, L, *gap, gapR);
*/
}/* flag =1*/
} /* main loop */
penalty2[3]=iterStep+1;
/*
* get the number of nonzero groups
*/
penalty2[4]=0;
for(i=0;i<g;i++){
if (zeroGroupFlag[i]==0)
penalty2[4]=penalty2[4]+1;
else{
for(j=(int) w[3*i] ; j<= (int) w[3*i +1]; j++){
if (x[ (int) G[j] ] !=0)
break;
}
if (j>(int) w[3*i +1])
penalty2[4]=penalty2[4]+1;
}
}
/*
* assign sign to the solution x
*/
for(i=0;i<p;i++){
if (entrySignFlag[i]==-1){
x[i]=-x[i];
}
}
free (u);
free (y);
free (xnew);
free (Ynew);
free (xS);
free (YS);
/*free (xp);*/
free (Yp);
free (zeroGroupFlag);
free (entrySignFlag);
}
void overlapping(double *x, double *gap, double *penalty2,
double *v, int p, int g, double lambda1, double lambda2,
double *w, double *G, double *Y, int maxIter, int flag, double tol){
switch(flag){
case 0:
case 1:
overlapping_gd(x, gap, penalty2,
v, p, g, lambda1, lambda2,
w, G, Y, maxIter, flag,tol);
break;
case 2:
case 3:
overlapping_agd(x, gap, penalty2,
v, p, g, lambda1, lambda2,
w, G, Y, maxIter, flag-2,tol);
break;
default:
/* printf("\n Wrong flag! The value of flag should be 0,1,2,3. The program uses flag=2.");*/
overlapping_agd(x, gap, penalty2,
v, p, g, lambda1, lambda2,
w, G, Y, maxIter, 0,tol);
break;
}
}
| ratschlab/ASP | src/shogun/lib/slep/overlapping/overlapping.cpp | C++ | gpl-2.0 | 26,209 | [
30522,
1013,
1008,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
1008,
2009,
2104,
1996,
3408,
1997,
1996,
27004,
2236,
2270,
6105,
2004,
2405,
2011,
1008,
1996,
2489,
4007,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="GENERATOR" content="VSdocman - documentation generator; https://www.helixoft.com" />
<link rel="icon" href="favicon.ico">
<title>tlece_ProductPurchased Attached Properties</title>
<link rel="stylesheet" type="text/css" href="msdn2019/toc.css" />
<script src="msdn2019/toc.js"></script>
<link rel="stylesheet" type="text/css" href="msdn2019/msdn2019.css"></link>
<script src="msdn2019/msdn2019.js" type="text/javascript"></script>
<script src="SyntaxHighlighter/scripts/shCore_helixoft.js" type="text/javascript"></script>
<script src="SyntaxHighlighter/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="SyntaxHighlighter/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="SyntaxHighlighter/scripts/shBrushFSharp.js" type="text/javascript"></script>
<script src="SyntaxHighlighter/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="SyntaxHighlighter/scripts/shBrushJScript.js" type="text/javascript"></script>
<link href="SyntaxHighlighter/styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="SyntaxHighlighter/styles/shThemeMsdnLW.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
SyntaxHighlighter.all();
</script>
<link rel="stylesheet" type="text/css" href="vsdocman_overrides.css"></link>
</head>
<body style="direction: ltr;">
<div id="topic">
<!--HEADER START-->
<div id="header">
<div id="header-top-container">
<div id="header-top-parent-container1">
<div id="header-top-container1">
<div id="runningHeaderText1"><a id="headerLogo" href="#" onclick="window.location.href = getCssCustomProperty('--headerLogoLink'); return false;">logo</a></div>
<div id="runningHeaderText1b"><script>
document.write(getCssCustomProperty('--headerTopCustomLineHtml'));
</script></div>
</div>
</div>
<div id="header-top-container2">
<div id="runningHeaderText">SOLUTION-WIDE PROPERTIES Reference</div>
<div id="search-bar-container">
<form id="search-bar" action="search--.html">
<input id="HeaderSearchInput" type="search" name="search" placeholder="Search" >
<button id="btn-search" class="c-glyph" title="Search">
<span>Search</span>
</button>
</form>
<button id="cancel-search" class="cancel-search" title="Cancel">
<span>Cancel</span>
</button>
</div>
</div>
</div>
<hr />
<div id="header-breadcrumbs"></div>
<div id="headerLinks">
</div>
<hr />
</div>
<!--HEADER END-->
<div id="mainSection">
<div id="toc-area">
<div id="toc-container" class="stickthis full-height">
<div id="-1"></div>
<div id="c-1">
<div id="ci-1" class="inner-for-height"></div>
</div>
</div>
</div>
<div id="mainBody">
<h1 class="title">tlece_ProductPurchased Attached Properties</h1>
<p />
<p>
The following tables list the members exposed by the
<a href="topic_00000000000003F3.html">tlece_ProductPurchased</a>
type.
</p>
<div class="section_container">
<div class="section_heading">
<span><a href="javascript:void(0)" title="Collapse" onclick="toggleSection(this);">See Also</a></span>
<div> </div>
</div>
<div id="seeAlsoSection" class="section">
<div>
<a href="topic_00000000000003F3.html">tlece_ProductPurchased Class</a><br />
<a href="topic_0000000000000265.html">Tlece.Recruitment.Entities Namespace</a><br />
</div>
</div>
</div>
</div>
<div id="internal-toc-area">
<div id="internal-toc-container" class="stickthis">
<h3 id="internal-toc-heading">In this article</h3>
<span id="internal-toc-definition-localized-text">Definition</span>
</div>
</div>
</div>
<div id="footer">
<div id="footer-container">
<p><span style="color: #FF0000;">Generated with unregistered version of <a target="_top" href="http://www.helixoft.com/vsdocman/overview.html">VSdocman</a></span> <br />Your own footer text will only be shown in registered version.</p>
</div>
</div>
</div>
</body>
</html>
| asiboro/asiboro.github.io | vsdoc/topic_00000000000003F3_attached_props--.html | HTML | mit | 4,462 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
declare(strict_types=1);
namespace PoPCMSSchema\Users\ConditionalOnComponent\CustomPosts\ConditionalOnComponent\API\ModuleProcessors;
use PoP\Root\App;
use PoPAPI\API\ModuleProcessors\AbstractRelationalFieldDataloadModuleProcessor;
use PoP\ComponentModel\QueryInputOutputHandlers\ListQueryInputOutputHandler;
use PoP\ComponentModel\QueryInputOutputHandlers\QueryInputOutputHandlerInterface;
use PoP\ComponentModel\TypeResolvers\RelationalTypeResolverInterface;
use PoPCMSSchema\CustomPosts\TypeResolvers\ObjectType\CustomPostObjectTypeResolver;
use PoPCMSSchema\Posts\ModuleProcessors\PostFilterInputContainerModuleProcessor;
class FieldDataloadModuleProcessor extends AbstractRelationalFieldDataloadModuleProcessor
{
public const MODULE_DATALOAD_RELATIONALFIELDS_AUTHORCUSTOMPOSTLIST = 'dataload-relationalfields-authorcustompostlist';
private ?CustomPostObjectTypeResolver $customPostObjectTypeResolver = null;
private ?ListQueryInputOutputHandler $listQueryInputOutputHandler = null;
final public function setCustomPostObjectTypeResolver(CustomPostObjectTypeResolver $customPostObjectTypeResolver): void
{
$this->customPostObjectTypeResolver = $customPostObjectTypeResolver;
}
final protected function getCustomPostObjectTypeResolver(): CustomPostObjectTypeResolver
{
return $this->customPostObjectTypeResolver ??= $this->instanceManager->getInstance(CustomPostObjectTypeResolver::class);
}
final public function setListQueryInputOutputHandler(ListQueryInputOutputHandler $listQueryInputOutputHandler): void
{
$this->listQueryInputOutputHandler = $listQueryInputOutputHandler;
}
final protected function getListQueryInputOutputHandler(): ListQueryInputOutputHandler
{
return $this->listQueryInputOutputHandler ??= $this->instanceManager->getInstance(ListQueryInputOutputHandler::class);
}
public function getModulesToProcess(): array
{
return array(
[self::class, self::MODULE_DATALOAD_RELATIONALFIELDS_AUTHORCUSTOMPOSTLIST],
);
}
public function getRelationalTypeResolver(array $module): ?RelationalTypeResolverInterface
{
switch ($module[1]) {
case self::MODULE_DATALOAD_RELATIONALFIELDS_AUTHORCUSTOMPOSTLIST:
return $this->getCustomPostObjectTypeResolver();
}
return parent::getRelationalTypeResolver($module);
}
public function getQueryInputOutputHandler(array $module): ?QueryInputOutputHandlerInterface
{
switch ($module[1]) {
case self::MODULE_DATALOAD_RELATIONALFIELDS_AUTHORCUSTOMPOSTLIST:
return $this->getListQueryInputOutputHandler();
}
return parent::getQueryInputOutputHandler($module);
}
protected function getMutableonrequestDataloadQueryArgs(array $module, array &$props): array
{
$ret = parent::getMutableonrequestDataloadQueryArgs($module, $props);
switch ($module[1]) {
case self::MODULE_DATALOAD_RELATIONALFIELDS_AUTHORCUSTOMPOSTLIST:
$ret['authors'] = [
App::getState(['routing', 'queried-object-id']),
];
break;
}
return $ret;
}
public function getFilterSubmodule(array $module): ?array
{
switch ($module[1]) {
case self::MODULE_DATALOAD_RELATIONALFIELDS_AUTHORCUSTOMPOSTLIST:
return [PostFilterInputContainerModuleProcessor::class, PostFilterInputContainerModuleProcessor::MODULE_FILTERINPUTCONTAINER_POSTS];
}
return parent::getFilterSubmodule($module);
}
}
| leoloso/PoP | layers/CMSSchema/packages/users/src/ConditionalOnComponent/CustomPosts/ConditionalOnComponent/API/ModuleProcessors/FieldDataloadModuleProcessor.php | PHP | gpl-2.0 | 3,656 | [
30522,
1026,
1029,
25718,
13520,
1006,
9384,
1035,
4127,
1027,
1015,
1007,
1025,
3415,
15327,
3769,
27487,
4757,
5403,
2863,
1032,
5198,
1032,
18462,
2239,
9006,
29513,
3372,
1032,
7661,
19894,
2015,
1032,
18462,
2239,
9006,
29513,
3372,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2015 Marten Gajda <marten@dmfs.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
*/
package org.dmfs.davclient.rfc7231;
import org.dmfs.httpclientinterfaces.IHttpResponse;
public class HttpOptions
{
public HttpOptions(IHttpResponse response)
{
}
}
| dmfs/jdav-client | src/org/dmfs/davclient/rfc7231/HttpOptions.java | Java | gpl-3.0 | 947 | [
30522,
30524,
2368,
11721,
3501,
2850,
1026,
20481,
2368,
1030,
1040,
2213,
10343,
1012,
8917,
1028,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
1008,
2009,
2104,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |

Long Haul is a minimal jekyll theme built with COMPASS / SASS / SUSY and focuses on long form blog plosts. It is meant to used as a starting point for a jekyll blog/website.
If you really enjoy Long Haul and want to give me credit somewhere on the send or tweet out your experience with Long Haul and tag me [@brianmaierjr](https://twitter.com/brianmaier).
####[View Demo](http://brianmaierjr.com/long-haul)
## Features
- Minimal, Type Focused Design
- Built with SASS + COMPASS
- Layout with SUSY Grid
- SVG Social Icons
- Responsive Nav Menu
- XML Feed for RSS Readers
- Contact Form via Formspree
- 5 Post Loop with excerpt on Home Page
- Previous / Next Post Navigation
- Estimated Reading Time for posts
- Stylish Drop Cap on posts
- A Better Type Scale for all devices
## Setup
1. [Install Jekyll](http://jekyllrb.com)
2. Fork the [Long Haul repo](http://github.com/brianmaierjr/long-haul)
3. Clone it
4. Install susy `gem install susy`
5. Install normalize `gem install normalize-scss`
6. Run Jekyll `jekyll serve -w`
7. Run `compass watch`
8. Customize!
## Site Settings
The main settings can be found inside the `_config.yml` file:
- **title:** title of your site
- **description:** description of your site
- **url:** your url
- **paginate:** the amount of posts displayed on homepage
- **navigation:** these are the links in the main site navigation
- **social** diverse social media usernames (optional)
- **google_analytics** Google Analytics key (optional)
## License
This is [MIT](LICENSE) with no added caveats, so feel free to use this Jekyll theme on your site without linking back to me or using a disclaimer.
| mhaslam/long-haul | README.md | Markdown | mit | 1,677 | [
30522,
999,
1031,
19236,
2146,
14655,
1033,
1006,
1013,
19236,
1012,
16545,
2290,
1007,
2146,
14655,
2003,
1037,
10124,
15333,
4801,
3363,
4323,
2328,
2007,
16681,
1013,
21871,
2015,
1013,
10514,
6508,
1998,
7679,
2006,
2146,
2433,
9927,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.m4thg33k.lit.lib;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
public enum EnumBetterFurnaceType implements IStringSerializable {
IRON("Iron",0.5,1,1.25,30000, new ItemStack(Items.iron_ingot,1)),
GOLD("Gold",0.25,1,1.25,40000,new ItemStack(Items.gold_ingot,1)),
DIAMOND("Diamond",0.25,2,1.5,80000, new ItemStack(Items.diamond,1)),
REDSTONE("Redstone",0.125,0,1.25,30000,new ItemStack(Blocks.redstone_block,1)),
LAPIS("Lapis",0.25,3,1.0,20000,new ItemStack(Blocks.lapis_block,1));
protected final String name;
protected final double speedMult;
protected final int numUpgrades;
protected final double fuelEfficiencyMult;
protected final int fuelCap;
protected final ItemStack ingredient;
EnumBetterFurnaceType(String name,double speedMult,int numUpgrades,double fuelEfficiencyMult,int fuelCap,ItemStack ingredient)
{
this.name = name;
this.speedMult = speedMult;
this.numUpgrades = numUpgrades;
this.fuelEfficiencyMult = fuelEfficiencyMult;
this.fuelCap = fuelCap;
this.ingredient = ingredient.copy();
}
@Override
public String getName() {
return this.name.toLowerCase();
}
public String getTypeName()
{
return this.name;
}
public double getSpeedMult() {
return speedMult;
}
public int getNumUpgrades() {
return numUpgrades;
}
public double getFuelEfficiencyMult() {
return fuelEfficiencyMult;
}
public int getFuelCap() {
return fuelCap;
}
public ItemStack getIngredient() {
return ingredient.copy();
}
public String[] getDisplayInfo()
{
return new String[]{""+getSpeedMult(),""+getFuelEfficiencyMult(),""+getNumUpgrades(),""+(Math.floor(100*((0.0+getFuelCap())/(1600*64*getFuelEfficiencyMult())))/100)};
}
}
| M4thG33k/LittleInsignificantThings_1.9 | src/main/java/com/m4thg33k/lit/lib/EnumBetterFurnaceType.java | Java | gpl-3.0 | 1,983 | [
30522,
7427,
4012,
1012,
1049,
26724,
2290,
22394,
2243,
1012,
5507,
1012,
5622,
2497,
1025,
12324,
5658,
1012,
3067,
10419,
1012,
1999,
4183,
1012,
5991,
1025,
12324,
5658,
1012,
3067,
10419,
1012,
1999,
4183,
1012,
5167,
1025,
12324,
5658... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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":"36070570","logradouro":"Rua Jo\u00e3o Surerus J\u00fanior","bairro":"Lourdes","cidade":"Juiz de Fora","uf":"MG","estado":"Minas Gerais"});
| lfreneda/cepdb | api/v1/36070570.jsonp.js | JavaScript | cc0-1.0 | 153 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
9475,
19841,
28311,
2692,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
8183,
1032,
1057,
8889,
2063,
2509,
2080,
2469,
7946,
1046,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright (C) 2007-2011, Jens Lehmann
*
* This file is part of DL-Learner.
*
* DL-Learner 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.
*
* DL-Learner 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.dllearner.kb.extraction;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.log4j.Logger;
import org.dllearner.kb.aquisitors.RDFBlankNode;
import org.dllearner.kb.aquisitors.TupleAquisitor;
import org.dllearner.kb.manipulator.Manipulator;
import org.dllearner.utilities.datastructures.RDFNodeTuple;
import org.dllearner.utilities.owl.OWLVocabulary;
import org.semanticweb.owlapi.model.OWLAnnotation;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLDataFactory;
/**
* Is a node in the graph, that is a class.
*
* @author Sebastian Hellmann
*/
public class ClassNode extends Node {
private static Logger logger = Logger
.getLogger(ClassNode.class);
List<ObjectPropertyNode> classProperties = new ArrayList<ObjectPropertyNode>();
List<DatatypePropertyNode> datatypeProperties = new ArrayList<DatatypePropertyNode>();
List<BlankNode> blankNodes = new ArrayList<BlankNode>();
public ClassNode(String uri) {
super(uri);
}
// expands all directly connected nodes
@Override
public List<Node> expand(TupleAquisitor tupelAquisitor, Manipulator manipulator) {
SortedSet<RDFNodeTuple> newTuples = tupelAquisitor.getTupelForResource(this.uri);
// see manipulator
newTuples = manipulator.manipulate(this, newTuples);
List<Node> newNodes = new ArrayList<Node>();
Node tmp;
for (RDFNodeTuple tuple : newTuples) {
if((tmp = processTuple(tuple,tupelAquisitor.isDissolveBlankNodes()))!= null) {
newNodes.add(tmp);
}
}
return newNodes;
}
private Node processTuple( RDFNodeTuple tuple, boolean dissolveBlankNodes) {
try {
String property = tuple.a.toString();
if(tuple.b.isLiteral()) {
datatypeProperties.add(new DatatypePropertyNode(tuple.a.toString(), this, new LiteralNode(tuple.b) ));
return null;
}else if(tuple.b.isAnon()){
if(dissolveBlankNodes){
RDFBlankNode n = (RDFBlankNode) tuple.b;
BlankNode tmp = new BlankNode( n, tuple.a.toString());
//add it to the graph
blankNodes.add(tmp);
//return tmp;
return tmp;
}else{
//do nothing
return null;
}
// substitute rdf:type with owl:subclassof
}else if (property.equals(OWLVocabulary.RDF_TYPE) ||
OWLVocabulary.isStringSubClassVocab(property)) {
ClassNode tmp = new ClassNode(tuple.b.toString());
classProperties.add(new ObjectPropertyNode( OWLVocabulary.RDFS_SUBCLASS_OF, this, tmp));
return tmp;
} else {
// further expansion stops here
ClassNode tmp = new ClassNode(tuple.b.toString());
classProperties.add(new ObjectPropertyNode(tuple.a.toString(), this, tmp));
return tmp; //is missing on purpose
}
} catch (Exception e) {
logger.warn("Problem with: " + this + " in tuple " + tuple);
e.printStackTrace();
}
return null;
}
// gets the types for properties recursively
@Override
public List<BlankNode> expandProperties(TupleAquisitor tupelAquisitor, Manipulator manipulator, boolean dissolveBlankNodes) {
return new ArrayList<BlankNode>();
}
/*
* (non-Javadoc)
*
* @see org.dllearner.kb.sparql.datastructure.Node#toNTriple()
*/
@Override
public SortedSet<String> toNTriple() {
SortedSet<String> returnSet = new TreeSet<String>();
String subject = getNTripleForm();
returnSet.add(subject+"<" + OWLVocabulary.RDF_TYPE + "><" + OWLVocabulary.OWL_CLASS + ">.");
for (ObjectPropertyNode one : classProperties) {
returnSet.add(subject + one.getNTripleForm() +
one.getBPart().getNTripleForm()+" .");
returnSet.addAll(one.getBPart().toNTriple());
}
for (DatatypePropertyNode one : datatypeProperties) {
returnSet.add(subject+ one.getNTripleForm() + one.getNTripleFormOfB()
+ " .");
}
return returnSet;
}
@Override
public void toOWLOntology( OWLAPIOntologyCollector owlAPIOntologyCollector){
try{
OWLDataFactory factory = owlAPIOntologyCollector.getFactory();
OWLClass me =factory.getOWLClass(getIRI());
for (ObjectPropertyNode one : classProperties) {
OWLClass c = factory.getOWLClass(one.getBPart().getIRI());
if(OWLVocabulary.isStringSubClassVocab(one.getURIString())){
owlAPIOntologyCollector.addAxiom(factory.getOWLSubClassOfAxiom(me, c));
}else if(one.getURIString().equals(OWLVocabulary.OWL_DISJOINT_WITH)){
owlAPIOntologyCollector.addAxiom(factory.getOWLDisjointClassesAxiom(me, c));
}else if(one.getURIString().equals(OWLVocabulary.OWL_EQUIVALENT_CLASS)){
owlAPIOntologyCollector.addAxiom(factory.getOWLEquivalentClassesAxiom(me, c));
}else if(one.getURIString().equals(OWLVocabulary.RDFS_IS_DEFINED_BY)){
logger.warn("IGNORING: "+OWLVocabulary.RDFS_IS_DEFINED_BY);
continue;
}else {
tail(true, "in ontology conversion"+" object property is: "+one.getURIString()+" connected with: "+one.getBPart().getURIString());
continue;
}
one.getBPart().toOWLOntology(owlAPIOntologyCollector);
}
for (DatatypePropertyNode one : datatypeProperties) {
//FIXME add languages
// watch for tail
if(one.getURIString().equals(OWLVocabulary.RDFS_COMMENT)){
OWLAnnotation annoComment = factory.getOWLAnnotation(factory.getRDFSComment(), factory.getOWLStringLiteral(one.getBPart().getLiteral().getString()));
OWLAxiom ax = factory.getOWLAnnotationAssertionAxiom(me.getIRI(), annoComment);
owlAPIOntologyCollector.addAxiom(ax);
}else if(one.getURIString().equals(OWLVocabulary.RDFS_LABEL)) {
OWLAnnotation annoLabel = factory.getOWLAnnotation(factory.getRDFSLabel(), factory.getOWLStringLiteral(one.getBPart().getLiteral().getString()));
OWLAxiom ax = factory.getOWLAnnotationAssertionAxiom(me.getIRI(), annoLabel);
owlAPIOntologyCollector.addAxiom(ax);
}else {
tail(true, "in ontology conversion: no other datatypes, but annotation is allowed for classes."+" data property is: "+one.getURIString()+" connected with: "+one.getBPart().getNTripleForm());
}
}
for (BlankNode bn : blankNodes) {
OWLClassExpression target = bn.getAnonymousClass(owlAPIOntologyCollector);
if(OWLVocabulary.isStringSubClassVocab(bn.getInBoundEdge())){
owlAPIOntologyCollector.addAxiom(factory.getOWLSubClassOfAxiom(me, target));
}else if(bn.getInBoundEdge().equals(OWLVocabulary.OWL_DISJOINT_WITH)){
owlAPIOntologyCollector.addAxiom(factory.getOWLDisjointClassesAxiom(me, target));
}else if(bn.getInBoundEdge().equals(OWLVocabulary.OWL_EQUIVALENT_CLASS)){
owlAPIOntologyCollector.addAxiom(factory.getOWLEquivalentClassesAxiom(me, target));
}else {
tail( "in ontology conversion"+" bnode is: "+bn.getInBoundEdge()+"||"+ bn );
}
}
}catch (Exception e) {
System.out.println("aaa"+getURIString());
e.printStackTrace();
}
}
}
| daftano/dl-learner | components-core/src/main/java/org/dllearner/kb/extraction/ClassNode.java | Java | gpl-3.0 | 7,843 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2289,
1011,
2249,
1010,
25093,
28444,
2078,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
21469,
1011,
4553,
2121,
1012,
1008,
1008,
21469,
1011,
4553,
2121,
2003,
2489,
4007,
1025,
2017,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**************************************************************************************************
Filename: ipd.h
Revised: $Date: 2012-04-02 17:02:19 -0700 (Mon, 02 Apr 2012) $
Revision: $Revision: 29996 $
Description: Header file for the IPD functionality
Copyright 2009-2011 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#ifndef IPD_H
#define IPD_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "zcl.h"
/*********************************************************************
* CONSTANTS
*/
#define IPD_ENDPOINT 0x09
#define IPD_MAX_ATTRIBUTES 13
#define IPD_MAX_OPTIONS 5
#define IPD_UPDATE_TIME_PERIOD 1000 // Update time event in msec
#define IPD_GET_PRICING_INFO_PERIOD 5000 // Interval for get pricing info command
#define SE_DEVICE_POLL_RATE 8000 // Poll rate for SE end device
// Application Events
#define IPD_IDENTIFY_TIMEOUT_EVT 0x0001
#define IPD_UPDATE_TIME_EVT 0x0002
#define IPD_KEY_ESTABLISHMENT_REQUEST_EVT 0x0004
#define IPD_GET_PRICING_INFO_EVT 0x0008
/*********************************************************************
* MACROS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* VARIABLES
*/
extern SimpleDescriptionFormat_t ipdSimpleDesc;
extern CONST zclAttrRec_t ipdAttrs[];
extern zclOptionRec_t ipdOptions[];
extern uint8 ipdDeviceEnabled;
extern uint16 ipdTransitionTime;
extern uint16 ipdIdentifyTime;
extern uint32 ipdTime;
/*********************************************************************
* FUNCTIONS
*/
/*
* Initialization for the task
*/
extern void ipd_Init( uint8 task_id );
/*
* Event Process for the task
*/
extern uint16 ipd_event_loop( uint8 task_id, uint16 events );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* IPD_H */
| smileboywtu/zigbee-lcd-stack | Projects/zstack/SE/SampleApp/Source/IPD/ipd.h | C | gpl-2.0 | 4,128 | [
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... |
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function (req, res, next) {
res.render('index', { title: 'Express' });
});
//test canvas
router.get('/canvas', function (req, res, next) {
res.render('canvas');
});
module.exports = router;
| davidbull931997/NL_ChatWebApp | routes/index.js | JavaScript | mit | 299 | [
30522,
13075,
4671,
1027,
5478,
1006,
1005,
4671,
1005,
1007,
1025,
13075,
2799,
2099,
1027,
4671,
1012,
2799,
2099,
1006,
1007,
1025,
1013,
1008,
2131,
2188,
3931,
1012,
1008,
1013,
2799,
2099,
1012,
2131,
1006,
1005,
1013,
1005,
1010,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* duena functions and definitions
*
* @package duena
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) )
$content_width = 900; /* pixels */
// The excerpt based on words
if ( !function_exists('duena_string_limit_words') ) {
function duena_string_limit_words($string, $word_limit) {
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit) array_pop($words);
$res = implode(' ', $words);
$res = trim ($res);
$res = preg_replace("/[.]+$/", "", $res);
if ( '' != $res) {
return $res . '... ';
} else {
return $res;
}
}
}
/*
* Load Files.
*/
//Loading options.php for theme customizer
include_once( get_template_directory() . '/options.php');
//Loads the Options Panel
if ( !function_exists( 'optionsframework_init' ) ) {
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/options/' );
include_once( get_template_directory() . '/options/options-framework.php' );
}
/*
* Load Jetpack compatibility file.
*/
require( get_template_directory() . '/inc/jetpack.php' );
if ( ! function_exists( 'duena_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*/
function duena_setup() {
$defaults = array(
'default-color' => '',
'default-image' => '',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => ''
);
add_theme_support( 'custom-background', $defaults );
/**
* Custom functions that act independently of the theme templates
*/
require( get_template_directory() . '/inc/extras.php' );
/**
* Customizer additions
*/
require( get_template_directory() . '/inc/customizer.php' );
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on duena, use a find and replace
* to change 'duena' to the name of your theme in all the template files
*/
load_theme_textdomain( 'duena', get_template_directory() . '/languages' );
/**
* Add editor styles
*/
add_editor_style( 'css/editor-style.css' );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/**
* This theme uses wp_nav_menu() in two locations.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'duena' ),
'footer' => __( 'Footer Menu', 'duena' )
) );
/*
* This theme supports all available post formats.
* See http://codex.wordpress.org/Post_Formats
*
* Structured post formats are formats where Twenty Thirteen handles the
* output instead of the default core HTML output.
*/
add_theme_support( 'structured-post-formats', array(
'link', 'video'
) );
add_theme_support( 'post-formats', array(
'aside', 'audio', 'chat', 'gallery', 'image', 'quote', 'status'
) );
// This theme uses its own gallery styles.
add_filter( 'use_default_gallery_style', '__return_false' );
/**
* Add image sizes
*/
if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 750, 290, true ); // Normal post thumbnails
add_image_size( 'slider-post-thumbnail', 1140, 440, true ); // Slider Thumbnail
add_image_size( 'image_post_format', 750, 440, true ); // Image Post Format output
add_image_size( 'related-thumb', 160, 160, true ); // Realted Post Image output
add_image_size( 'portfolio-large-th', 550, 210, true ); // 2 cols portfolio image
add_image_size( 'portfolio-small-th', 265, 100, true ); // 4 cols portfolio image
}
}
endif; // duena_setup
add_action( 'after_setup_theme', 'duena_setup' );
/**
* Register widgetized area and update sidebar with default widgets
*/
function duena_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'duena' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
//add_action( 'widgets_init', 'duena_widgets_init' );
/**
* Enqueue scripts and styles
*/
function duena_styles() {
global $wp_styles;
// Bootstrap styles
wp_register_style( 'duena-bootstrap', get_template_directory_uri() . '/bootstrap/css/bootstrap.css');
wp_enqueue_style( 'duena-bootstrap' );
// Slider styles
wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css');
wp_enqueue_style( 'flexslider' );
// Popup styles
wp_register_style( 'magnific', get_template_directory_uri() . '/css/magnific-popup.css');
wp_enqueue_style( 'magnific' );
// FontAwesome stylesheet
wp_register_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.css', '', '4.0.3');
wp_enqueue_style( 'font-awesome' );
// Main stylesheet
wp_enqueue_style( 'duena-style', get_stylesheet_uri() );
// Add inline styles from theme options
$duena_user_css = duena_get_user_colors();
wp_add_inline_style( 'duena-style', $duena_user_css );
// Loads the Internet Explorer specific stylesheet.
wp_enqueue_style( 'duena_ie', get_template_directory_uri() . '/css/ie.css' );
$wp_styles->add_data( 'duena_ie', 'conditional', 'lt IE 9' );
}
function duena_scripts() {
wp_enqueue_script( 'duena-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
wp_enqueue_script( 'duena-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'duena-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
// Menu scripts
wp_enqueue_script('superfish', get_template_directory_uri() . '/js/superfish.js', array('jquery'), '1.4.8', true);
wp_enqueue_script('mobilemenu', get_template_directory_uri() . '/js/jquery.mobilemenu.js', array('jquery'), '1.0', true);
wp_enqueue_script('sf_Touchscreen', get_template_directory_uri() . '/js/sfmenu-touch.js', array('jquery'), '1.0', true);
// Slider
wp_enqueue_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array('jquery'), '2.1', true);
// PopUp
wp_enqueue_script('magnific', get_template_directory_uri() . '/js/jquery.magnific-popup.js', array('jquery'), '0.8.9', true);
// Bootstrap JS
wp_enqueue_script('bootstrap-custom', get_template_directory_uri() . '/js/bootstrap.js', array('jquery'), '1.0', true);
// Custom Script File
wp_enqueue_script('custom', get_template_directory_uri() . '/js/custom.js', array('jquery'), '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'duena_scripts', 10 );
add_action( 'wp_enqueue_scripts', 'duena_styles', 10 );
/**
* Include additional assests for admin area
*/
function duena_admin_assets() {
$screen = get_current_screen();
if ( isset( $screen ) && 'page' == $screen->post_type ) {
// scripts
wp_enqueue_script( 'duena-admin-script', get_template_directory_uri() . '/js/admin-scripts.js', array('jquery'), '1.0', true );
// styles
wp_enqueue_style( 'duena-admin-style', get_template_directory_uri() . '/css/admin-style.css', '', '1.0' );
}
}
add_action( 'admin_enqueue_scripts', 'duena_admin_assets' );
/**
* Adding class 'active' to current menu item
*/
add_filter( 'nav_menu_css_class', 'duena_active_item_classes', 10, 2 );
function duena_active_item_classes($classes = array(), $menu_item = false){
if(in_array('current-menu-item', $menu_item->classes)){
$classes[] = 'active';
}
return $classes;
}
/**
* Load localization
*/
load_theme_textdomain( 'duena', get_template_directory() . '/languages' );
/*-----------------------------------------------------------------------------------*/
/* Custom Gallery
/*-----------------------------------------------------------------------------------*/
if ( ! function_exists( 'duena_featured_gallery' ) ) :
function duena_featured_gallery() {
$pattern = get_shortcode_regex();
if ( preg_match( "/$pattern/s", get_the_content(), $match ) && 'gallery' == $match[2] ) {
add_filter( 'shortcode_atts_gallery', 'duena_gallery_atts' );
echo do_shortcode_tag( $match );
}
}
endif;
function duena_gallery_atts( $atts ) {
$atts['size'] = 'large';
return $atts;
}
/*-----------------------------------------------------------------------------------*/
/* Get link URL for link post type
/*-----------------------------------------------------------------------------------*/
function duena_get_link_url() {
$has_url = get_the_post_format_url();
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
/*-----------------------------------------------------------------------------------*/
/* Breabcrumbs
/*-----------------------------------------------------------------------------------*/
if (! function_exists( 'duena_breadcrumb' )) {
function duena_breadcrumb() {
$showOnHome = 0; // 1 - show "breadcrumbs" on home page, 0 - hide
$delimiter = '<li class="divider">/</li>'; // divider
$home = 'Home'; // text for link "Home"
$showCurrent = 1; // 1 - show title current post/page, 0 - hide
$before = '<li class="active">'; // open tag for active breadcrumb
$after = '</li>'; // close tag for active breadcrumb
global $post;
$homeLink = home_url();
if (is_front_page()) {
if ($showOnHome == 1) echo '<ul class="breadcrumb breadcrumb__t"><li><a href="' . $homeLink . '">' . $home . '</a><li></ul>';
} else {
echo '<ul class="breadcrumb breadcrumb__t"><li><a href="' . $homeLink . '">' . $home . '</a></li> ' . $delimiter . ' ';
if ( is_home() ) {
echo $before . 'Blog' . $after;
} elseif ( is_category() ) {
$thisCat = get_category(get_query_var('cat'), false);
if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
echo $before . 'Category Archives: "' . single_cat_title('', false) . '"' . $after;
} elseif ( is_search() ) {
echo $before . 'Search for: "' . get_search_query() . '"' . $after;
} elseif ( is_day() ) {
echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
echo '<li><a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a></li> ' . $delimiter . ' ';
echo $before . get_the_time('d') . $after;
} elseif ( is_month() ) {
echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
echo $before . get_the_time('F') . $after;
} elseif ( is_year() ) {
echo $before . get_the_time('Y') . $after;
} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != 'post' ) {
$post_name = get_post_type();
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '<li><a href="' . $homeLink . '/' . $post_name . '/">' . $post_type->labels->singular_name . '</a></li>';
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} else {
$cat = get_the_category(); $cat = $cat[0];
$cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
echo $cats;
if ($showCurrent == 1) echo $before . get_the_title() . $after;
}
} elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
$post_type = get_post_type_object(get_post_type());
echo $before . $post_type->labels->singular_name . $after;
} elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo '<li><a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a></li>';
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} elseif ( is_page() && !$post->post_parent ) {
if ($showCurrent == 1) echo $before . get_the_title() . $after;
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '<li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
for ($i = 0; $i < count($breadcrumbs); $i++) {
echo $breadcrumbs[$i];
if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
}
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} elseif ( is_tag() ) {
echo $before . 'Tag Archives: "' . single_tag_title('', false) . '"' . $after;
} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
echo $before . 'by ' . $userdata->display_name . $after;
} elseif ( is_404() ) {
echo $before . '404' . $after;
}
/*
if ( get_query_var('paged') ) {
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
echo __(' Page') . ' ' . get_query_var('paged');
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
}
*/
echo '</ul>';
}
} // end breadcrumbs()
}
/*-----------------------------------------------------------------------------------*/
/* Author Bio
/*-----------------------------------------------------------------------------------*/
add_action( 'before_sidebar', 'duena_show_author_bio', 10 );
function duena_show_author_bio() {
if ( 'no' != of_get_option('g_author_bio') ) {
?>
<div class="author_bio_sidebar">
<div class="social_box">
<?php
if ( '' != of_get_option('g_author_bio_social_twitter') ) {
echo "<a href='".esc_url( of_get_option('g_author_bio_social_twitter') )."' target='_blank'><i class='fa fa-twitter'></i></a>\n";
}
if ( '' != of_get_option('g_author_bio_social_facebook') ) {
echo "<a href='".esc_url( of_get_option('g_author_bio_social_facebook') )."' target='_blank'><i class='fa fa-facebook'></i></a>\n";
}
if ( '' != of_get_option('g_author_bio_social_google') ) {
echo "<a href='".esc_url( of_get_option('g_author_bio_social_google') )."' target='_blank'><i class='fa fa-google-plus'></i></a>\n";
}
if ( '' != of_get_option('g_author_bio_social_linked') ) {
echo "<a href='".esc_url( of_get_option('g_author_bio_social_linked') )."' target='_blank'><i class='fa fa-linkedin'></i></a>\n";
}
if ( '' != of_get_option('g_author_bio_social_rss') ) {
echo "<a href='".esc_url( of_get_option('g_author_bio_social_rss') )."' target='_blank'><i class='fa fa-rss'></i></a>\n";
}
?>
</div>
<?php if (( '' != of_get_option('g_author_bio_title') ) || ('' != of_get_option('g_author_bio_img')) || ('' != of_get_option('g_author_bio_message')) ) { ?>
<div class="content_box">
<?php
if ( '' != of_get_option('g_author_bio_title') ) {
echo "<h2>".of_get_option('g_author_bio_title')."</h2>\n";
}
if ( '' != of_get_option('g_author_bio_img') ) {
if ( '' != of_get_option('g_author_bio_title') ) {
$img_alt = of_get_option('g_author_bio_title');
} else {
$img_alt = get_bloginfo( 'name' );
}
echo "<figure class='author_bio_img'><img src='".esc_url( of_get_option('g_author_bio_img') )."' alt='".esc_attr( $img_alt )."'></figure>\n";
}
if ( '' != of_get_option('g_author_bio_message') ) {
echo "<div class='author_bio_message'>".of_get_option('g_author_bio_message')."</div>\n";
}
?>
</div>
<?php } ?>
</div>
<?php
}
}
/*-----------------------------------------------------------------------------------*/
/* Pagination (based on Twenty Fourteen pagination function)
/*-----------------------------------------------------------------------------------*/
function duena_pagination() {
global $wp_query, $wp_rewrite;
if ( $wp_query->max_num_pages < 2 ) {
return;
}
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array();
$url_parts = explode( '?', $pagenum_link );
if ( isset( $url_parts[1] ) ) {
wp_parse_str( $url_parts[1], $query_args );
}
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
$format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
// Set up paginated links.
$links = paginate_links( array(
'base' => $pagenum_link,
'format' => $format,
'total' => $wp_query->max_num_pages,
'current' => $paged,
'mid_size' => 1,
'add_args' => array_map( 'urlencode', $query_args ),
'prev_text' => __( '← Previous', 'duena' ),
'next_text' => __( 'Next →', 'duena' ),
'type' => 'list'
) );
if ( $links ) {
?>
<div class="page_nav_wrap">
<div class="post_nav">
<?php echo $links; ?>
</div><!-- .pagination -->
</div><!-- .navigation -->
<?php
}
}
/*-----------------------------------------------------------------------------------*/
/* Custom Comments Structure
/*-----------------------------------------------------------------------------------*/
function duena_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>" class="clearfix">
<div id="comment-<?php comment_ID(); ?>" class="comment-body clearfix">
<div class="clearfix">
<div class="comment-author vcard">
<?php echo get_avatar( $comment->comment_author_email, 65 ); ?>
<?php printf(__('<span class="author fn">%1$s</span>' ), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.', 'cherry') ?></em>
<?php endif; ?>
<div class="extra-wrap">
<?php comment_text() ?>
</div>
</div>
<div class="clearfix comment-footer">
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<div class="comment-meta commentmetadata"><?php printf(__('%1$s', 'cherry' ), get_comment_date('F j, Y')) ?></div>
</div>
</div>
<?php }
if (!function_exists('img_html_to_post_id')) {
function img_html_to_post_id( $html, &$matched_html = null ) {
$attachment_id = 0;
// Look for an <img /> tag
if ( ! preg_match( '#' . get_tag_regex( 'img' ) . '#i', $html, $matches ) || empty( $matches ) )
return $attachment_id;
$matched_html = $matches[0];
// Look for attributes.
if ( ! preg_match_all( '#(src|class)=([\'"])(.+?)\2#is', $matched_html, $matches ) || empty( $matches ) )
return $attachment_id;
$attr = array();
foreach ( $matches[1] as $key => $attribute_name )
$attr[ $attribute_name ] = $matches[3][ $key ];
if ( ! empty( $attr['class'] ) && false !== strpos( $attr['class'], 'wp-image-' ) )
if ( preg_match( '#wp-image-([0-9]+)#i', $attr['class'], $matches ) )
$attachment_id = absint( $matches[1] );
if ( ! $attachment_id && ! empty( $attr['src'] ) )
$attachment_id = attachment_url_to_postid( $attr['src'] );
return $attachment_id;
}
}
if (!function_exists('duena_footer_js')) {
function duena_footer_js() {
$sf_delay = esc_attr( of_get_option('sf_delay') );
$sf_f_animation = esc_attr( of_get_option('sf_f_animation') );
$sf_sl_animation = esc_attr( of_get_option('sf_sl_animation') );
$sf_speed = esc_attr( of_get_option('sf_speed') );
$sf_arrows = esc_attr( of_get_option('sf_arrows') );
if ('' == $sf_delay) {$sf_delay = 1000;}
if ('' == $sf_f_animation) {$sf_f_animation = 'show';}
if ('' == $sf_sl_animation) {$sf_sl_animation = 'show';}
if ('' == $sf_speed) {$sf_speed = 'normal';}
if ('' == $sf_arrows) {$sf_arrows = 'false';}
?>
<script type="text/javascript">
// initialise plugins
jQuery(function(){
// main navigation init
jQuery('.navbar_inner > ul').superfish({
delay: <?php echo $sf_delay; ?>, // one second delay on mouseout
animation: {opacity:"<?php echo $sf_f_animation; ?>", height:"<?php echo $sf_sl_animation; ?>"}, // fade-in and slide-down animation
speed: '<?php echo $sf_speed; ?>', // faster animation speed
autoArrows: <?php echo $sf_arrows; ?>, // generation of arrow mark-up (for submenu)
dropShadows: false
});
jQuery('.navbar_inner > div > ul').superfish({
delay: <?php echo $sf_delay; ?>, // one second delay on mouseout
animation: {opacity:"<?php echo $sf_f_animation; ?>", height:"<?php echo $sf_sl_animation; ?>"}, // fade-in and slide-down animation
speed: '<?php echo $sf_speed; ?>', // faster animation speed
autoArrows: <?php echo $sf_arrows; ?>, // generation of arrow mark-up (for submenu)
dropShadows: false
});
});
jQuery(function(){
var ismobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i)
if(ismobile){
jQuery('.navbar_inner > ul').sftouchscreen();
jQuery('.navbar_inner > div > ul').sftouchscreen();
}
});
</script>
<!--[if (gt IE 9)|!(IE)]><!-->
<script type="text/javascript">
jQuery(function(){
jQuery('.navbar_inner > ul').mobileMenu();
jQuery('.navbar_inner > div > ul').mobileMenu();
})
</script>
<!--<![endif]-->
<?php
}
add_action( 'wp_footer', 'duena_footer_js', 20, 1 );
}
| werner/78publicity | wp-content/themes/duena/functions.php | PHP | gpl-2.0 | 23,364 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
2349,
2532,
4972,
1998,
15182,
1008,
1008,
1030,
7427,
2349,
2532,
1008,
1013,
1013,
1008,
1008,
1008,
2275,
1996,
4180,
9381,
2241,
2006,
1996,
4323,
1005,
1055,
2640,
1998,
6782,
21030,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# ephemeral vpns (android)
vpns created on demand that last a short time
See main project: [ephemvpn](https://ramblurr.github.com/ephemvpn)
## License
* Android bits licensed under the Apache License 2.0
* Python bits licensed under BSD 3-clause
| Ramblurr/ephemvpn-android | README.md | Markdown | apache-2.0 | 251 | [
30522,
1001,
4958,
29122,
21673,
21210,
3619,
1006,
11924,
1007,
21210,
3619,
2580,
2006,
5157,
2008,
2197,
1037,
2460,
2051,
2156,
2364,
2622,
1024,
1031,
4958,
29122,
2615,
2361,
2078,
1033,
1006,
16770,
1024,
1013,
1013,
8223,
16558,
312... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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":"18202120","logradouro":"Rua Costabile Matarazzo","bairro":"Vila Asem","cidade":"Itapetininga","uf":"SP","estado":"S\u00e3o Paulo"});
| lfreneda/cepdb | api/v1/18202120.jsonp.js | JavaScript | cc0-1.0 | 147 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
11102,
17465,
11387,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
6849,
14454,
2063,
22640,
20409,
6844,
1000,
1010,
1000,
21790,
18933,
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... |
var ManageIssueTypePage = new Ext.Panel({
id : 'ezTrack_Manage_IssueType_Page',
layout : 'fit',
autoScroll : true,
items: [
ManageIssueTypePanelEvent
]
});
| chusiang/ezScrum_Ubuntu | WebContent/javascript/ezTrackPage/ManageIssueType.js | JavaScript | gpl-2.0 | 177 | [
30522,
13075,
6133,
14643,
23361,
18863,
13704,
1027,
2047,
4654,
2102,
1012,
5997,
1006,
1063,
8909,
1024,
1005,
1041,
2480,
6494,
3600,
1035,
6133,
1035,
3277,
13874,
1035,
3931,
1005,
1010,
9621,
1024,
1005,
4906,
1005,
1010,
8285,
11020... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.activemq.artemis.jms.example;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
/**
* A simple JMS Queue example that uses dual broker authentication mechanisms for SSL and non-SSL connections.
*/
public class SSLDualAuthenticationExample {
public static void main(final String[] args) throws Exception {
Connection producerConnection = null;
Connection consumerConnection = null;
InitialContext initialContext = null;
try {
// Step 1. Create an initial context to perform the JNDI lookup.
initialContext = new InitialContext();
// Step 2. Perfom a lookup on the queue
Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
// Step 3. Perform a lookup on the producer's SSL Connection Factory
ConnectionFactory producerConnectionFactory = (ConnectionFactory) initialContext.lookup("SslConnectionFactory");
// Step 4. Perform a lookup on the consumer's Connection Factory
ConnectionFactory consumerConnectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
// Step 5.Create a JMS Connection for the producer
producerConnection = producerConnectionFactory.createConnection();
// Step 6.Create a JMS Connection for the consumer
consumerConnection = consumerConnectionFactory.createConnection("consumer", "activemq");
// Step 7. Create a JMS Session for the producer
Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Step 8. Create a JMS Session for the consumer
Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Step 9. Create a JMS Message Producer
MessageProducer producer = producerSession.createProducer(queue);
// Step 10. Create a Text Message
TextMessage message = producerSession.createTextMessage("This is a text message");
System.out.println("Sent message: " + message.getText());
// Step 11. Send the Message
producer.send(message);
// Step 12. Create a JMS Message Consumer
MessageConsumer messageConsumer = consumerSession.createConsumer(queue);
// Step 13. Start the Connection
consumerConnection.start();
// Step 14. Receive the message
TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
System.out.println("Received message: " + messageReceived.getText());
initialContext.close();
}
finally {
// Step 15. Be sure to close our JMS resources!
if (initialContext != null) {
initialContext.close();
}
if (producerConnection != null) {
producerConnection.close();
}
if (consumerConnection != null) {
consumerConnection.close();
}
}
}
}
| lburgazzoli/apache-activemq-artemis | examples/features/standard/ssl-enabled-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/SSLDualAuthenticationExample.java | Java | apache-2.0 | 3,962 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
1008,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
1008,
2023,
2147,
2005,
3176,
2592,
4953,
9385,
6095,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
public class TimeStringQueue {
public Queue<Timenode> getTimeStringQueue(Queue<Timenode> sortedTimeNodes) {
if (sortedTimeNodes == null || sortedTimeNodes.size() == 0) {
return new LinkedList<>();
}
Map<String, Double> strToTime = new HashMap<>();
Queue<Timenode> timeStrQueue = new LinkedList<>();
while (!sortedTimeNodes.isEmpty()) {
Timenode curNode = sortedTimeNodes.remove();
if (!strToTime.containsKey(curNode.label)) {
strToTime.put(curNode.label, curNode.time);
} else {
if (curNode.time - strToTime.get(curNode.label) > 10) {
timeStrQueue.offer(curNode);
strToTime.put(curNode.label, curNode.time);
}
}
}
return timeStrQueue;
}
}
| ZzJing/ugrad-algorithm-practice | hashing/TimeStringQueue.java | Java | mit | 979 | [
30522,
12324,
9262,
1012,
21183,
4014,
1012,
23325,
2863,
2361,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
5799,
9863,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
4949,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
24240,
1025,
2270,
2465,
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... |
# XImageLoader
[中文版](https://github.com/XuDeveloper/XImageLoader/blob/master/docs/README-ZH.md)
It's a custom image-loading repository for Android.
You can use XImageLoader to load images from Internet or local files.By default it uses a HTTPUrlConnection to download images but you can also use OkhttpImageLoader instead or customize your own imageloader because it provides a interface.
Notice:This is a repository for people who want to learn more knowledge about the image loading and caching.It is not recommended for use in actual projects!
If you want to improve it, please fork it and pull requests to me!
If you like it, please star it or follow me!Thank you!
### Integration
#### Android Studio
```xml
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.github.XuDeveloper:XImageLoader:v1.0'
}
```
#### Eclipse
> Maybe you can copy my code to your project!
### Usage
Default usage:
``` java
// Asynchronous call
XImageLoader.build(context).imageview(ImageView).load(imageUrl);
// load local file,you need to use the format like "file:///address"
XImageLoader.build(context).imageview(ImageView).load("file:///address");
```
or
```java
// Synchronous call(should use it in a new thread)
Bitmap bitmap = XImageLoader.build(context).imageview(ImageView).getBitmap(imageUrl);
```
You can choose whether to use cache or not, or customize your own config(using XImageLoaderConfig):
```java
XImageLoader.build(context).imageview(isMemoryCache, isDiskCache, ImageView).load(imageUrl);
XImageLoader.build(context).imageview(isDoubleCache, ImageView).load(imageUrl);
// config settings
XImageLoaderConfig config = new XImageLoaderConfig();
config.setCache(new DoubleCache(context));
config.setLoader(new OkhttpImageLoader());
config.setLoadingResId(R.drawable.image_loading);
config.setFailResId(R.drawable.image_fail);
XImageLoader.build(context).imageview(config, ImageView).load(imageUrl);
```
You need to set the permissions in AndroidManifest.xml:
```xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
```
If you use a Android 6.0 device or more, you need to set permissions dynamically:
```java
XImageLoader.verifyStoragePermissions(activity);
```
##**License**
```license
Copyright [2016] XuDeveloper
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.
``` | XuDeveloper/XImageLoader | README.md | Markdown | apache-2.0 | 3,147 | [
30522,
1001,
8418,
26860,
11066,
2121,
1031,
1746,
1861,
1907,
1033,
1006,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
15990,
24844,
18349,
4842,
1013,
8418,
26860,
11066,
2121,
1013,
1038,
4135,
2497,
1013,
3040,
1013,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 tb.common.block;
import tb.common.item.ItemNodeFoci;
import tb.common.tile.TileNodeManipulator;
import tb.init.TBItems;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockNodeManipulator extends BlockContainer{
public BlockNodeManipulator()
{
super(Material.rock);
}
@Override
public TileEntity createNewTileEntity(World w, int meta) {
return new TileNodeManipulator();
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 0x421922;
}
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ)
{
if(p.getCurrentEquippedItem() != null)
{
ItemStack current = p.getCurrentEquippedItem();
if(current.getItem() instanceof ItemNodeFoci)
{
if(w.getBlockMetadata(x, y, z) != 0)
{
int meta = w.getBlockMetadata(x, y, z);
ItemStack stk = new ItemStack(TBItems.nodeFoci,1,meta-1);
EntityItem itm = new EntityItem(w,x+0.5D,y,z+0.5D,stk);
if(!w.isRemote)
w.spawnEntityInWorld(itm);
}
w.setBlockMetadataWithNotify(x, y, z, current.getItemDamage()+1, 3);
p.destroyCurrentEquippedItem();
return true;
}
}else
{
if(w.getBlockMetadata(x, y, z) != 0)
{
int meta = w.getBlockMetadata(x, y, z);
ItemStack stk = new ItemStack(TBItems.nodeFoci,1,meta-1);
EntityItem itm = new EntityItem(w,x+0.5D,y,z+0.5D,stk);
if(!w.isRemote)
w.spawnEntityInWorld(itm);
}
w.setBlockMetadataWithNotify(x, y, z, 0, 3);
}
return true;
}
@Override
public void breakBlock(World w, int x, int y, int z, Block b, int meta)
{
if(meta > 0) //Fix for the manipulator not dropping the foci.
{
ItemStack foci = new ItemStack(TBItems.nodeFoci,1,meta-1);
EntityItem itm = new EntityItem(w,x+0.5D,y+0.5D,z+0.5D,foci);
if(!w.isRemote)
w.spawnEntityInWorld(itm);
}
super.breakBlock(w, x, y, z, b, meta);
}
}
| KryptonCaptain/ThaumicBases | src/main/java/tb/common/block/BlockNodeManipulator.java | Java | cc0-1.0 | 2,456 | [
30522,
7427,
26419,
1012,
2691,
1012,
3796,
1025,
12324,
26419,
1012,
2691,
1012,
8875,
1012,
8875,
3630,
3207,
14876,
6895,
1025,
12324,
26419,
1012,
2691,
1012,
14090,
1012,
14090,
3630,
3207,
20799,
14289,
20051,
2953,
1025,
12324,
26419,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.Linq;
using System.Web.Mvc;
using CmsData;
using CmsWeb.Models;
using UtilityExtensions;
namespace CmsWeb.Areas.Main.Controllers
{
[Authorize(Roles = "Coupon")]
[RouteArea("Main", AreaPrefix = "Coupon"), Route("{action}/{id?}")]
public class CouponController : CmsStaffController
{
[Route("~/Coupons")]
public ActionResult Index()
{
var m = new CouponModel();
return View(m);
}
[HttpPost]
public ActionResult Create(CouponModel m)
{
if (m.couponcode.HasValue())
if (CouponModel.IsExisting(m.couponcode))
return Content("code already exists");
m.CreateCoupon();
return View(m);
}
public ActionResult Cancel(string id)
{
var c = DbUtil.Db.Coupons.SingleOrDefault(cp => cp.Id == id);
if (!c.Canceled.HasValue)
{
c.Canceled = DateTime.Now;
DbUtil.Db.SubmitChanges();
}
var m = new CouponModel();
return View("List", m);
}
public ActionResult List()
{
var m = new CouponModel();
return View(m);
}
[HttpPost]
public ActionResult List(string submit, CouponModel m)
{
if (submit == "Excel")
return m.CouponsAsDataTable().ToExcel("Coupons.xlsx");
return View(m);
}
}
}
| RGray1959/MyParish | CmsWeb/Areas/Main/Controllers/CouponController.cs | C# | gpl-2.0 | 1,520 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
4773,
1012,
19842,
2278,
1025,
2478,
4642,
16150,
6790,
1025,
2478,
4642,
26760,
15878,
1012,
4275,
1025,
2478,
9710,
10288,
29048,
2015,
1025,
3415,
15327,
464... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
define([
"dojo/_base/declare",
"dojo/_base/fx",
"dojo/_base/lang",
"dojo/dom-style",
"dojo/mouse",
"dojo/on",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dojo/text!./templates/TGPrdItem.html",
"dijit/_OnDijitClickMixin",
"dijit/_WidgetsInTemplateMixin",
"dijit/form/Button"
], function(declare, baseFx, lang, domStyle, mouse, on, _WidgetBase,
_TemplatedMixin, template,_OnDijitClickMixin,_WidgetsInTemplateMixin,Button){
return declare([_WidgetBase, _OnDijitClickMixin,_TemplatedMixin,_WidgetsInTemplateMixin], {
// Some default values for our author
// These typically map to whatever you're passing to the constructor
// 产品名称
rtzzhmc: "No Name",
// Using require.toUrl, we can get a path to our AuthorWidget's space
// and we want to have a default avatar, just in case
// 产品默认图片
rimg: require.toUrl("./images/defaultAvatar.png"),
// //起点金额
// code5:"",
// //投资风格
// code7: "",
// //收益率
// code8:"",
// //产品经理
// code3:"",
// //产品ID
// rprid:"",
// Our template - important!
templateString: template,
// A class to be applied to the root node in our template
baseClass: "TGPrdWidget",
// A reference to our background animation
mouseAnim: null,
// Colors for our background animation
baseBackgroundColor: "#fff",
// mouseBackgroundColor: "#def",
postCreate: function(){
// Get a DOM node reference for the root of our widget
var domNode = this.domNode;
// Run any parent postCreate processes - can be done at any point
this.inherited(arguments);
// Set our DOM node's background color to white -
// smoothes out the mouseenter/leave event animations
domStyle.set(domNode, "backgroundColor", this.baseBackgroundColor);
},
//设置属性
_setRimgAttr: function(imagePath) {
// We only want to set it if it's a non-empty string
if (imagePath != "") {
// Save it on our widget instance - note that
// we're using _set, to support anyone using
// our widget's Watch functionality, to watch values change
// this._set("avatar", imagePath);
// Using our avatarNode attach point, set its src value
this.imgNode.src = HTTP+imagePath;
}
}
});
}); | MingXingTeam/dojo-mobile-test | contactsList/widgets/TGPrdWidget/TGPrdWidget.js | JavaScript | mit | 2,307 | [
30522,
9375,
1006,
1031,
1000,
2079,
5558,
1013,
1035,
2918,
1013,
13520,
1000,
1010,
1000,
2079,
5558,
1013,
1035,
2918,
1013,
23292,
1000,
1010,
1000,
2079,
5558,
1013,
1035,
2918,
1013,
11374,
1000,
1010,
1000,
2079,
5558,
1013,
14383,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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">
<title>Test</title>
<link rel="stylesheet" type="text/css" href="../base.css">
<style>
#wrap{ position:absolute; display:none; width:450px; height:300px; padding:30px; background:white; text-align:center;}
</style>
</head>
<body>
<span id="open">点击我试试</span>
<div id="wrap">
<span>hahahahaahaha</span><br/><br/>
<label>关闭窗口</label>
</div>
<script src="../jquery-1.11.1.js"></script>
<script src="../vajoy.js"></script>
<script>
jQuery(document).ready(function(){
var openFun = function(){
alert("it's open");
};
//$.VJ_Dialog("#open","#wrap","#wrap label");
//$.VJ_Dialog("#open","#wrap","#wrap label",openFun);
$.VJ_Dialog("#open","#wrap","#wrap label",30,30, openFun); //窗口分别向左和向上挪动30像素,并触发openFun事件
console.log($("body").height());
})
</script>
</body>
</html>
| flyromance/jQuery | demo/VaJoy/Demo/Dialog.html | HTML | mit | 887 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
2516,
1028,
3231,
1026,
1013,
2516,
1028,
1026,
4957,
2128,
2140,
1027,
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... |
<?php
// ShabloThaurusBeatsBundle:Account:user.html.twig
return array (
'547e906' =>
array (
0 =>
array (
0 => 'bundles/thaurus/css/*',
),
1 =>
array (
),
2 =>
array (
'output' => '_controller/css/547e906.css',
'name' => '547e906',
'debug' => NULL,
'combine' => NULL,
'vars' =>
array (
),
),
),
);
| pancfab/thaurusbeats | app/cache/dev/assetic/config/5/56074505b72c59d499ce537f0bd15eef.php | PHP | mit | 394 | [
30522,
1026,
1029,
25718,
1013,
1013,
21146,
16558,
14573,
17342,
19442,
19022,
8630,
2571,
1024,
4070,
1024,
5310,
1012,
16129,
1012,
1056,
16279,
2709,
9140,
1006,
1005,
5139,
2581,
2063,
21057,
2575,
1005,
1027,
1028,
9140,
1006,
1014,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and related documentation outside the terms of the EULA
* is strictly prohibited.
*
*/
//
// Template math library for common 3D functionality
//
// nvMatrix.h - template matrix code
//
// This code is in part deriver from glh, a cross platform glut helper library.
// The copyright for glh follows this notice.
//
// Copyright (c) NVIDIA Corporation. All rights reserved.
////////////////////////////////////////////////////////////////////////////////
/*
Copyright (c) 2000 Cass Everitt
Copyright (c) 2000 NVIDIA Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
* The names of contributors to this software may not be used
to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
REGENTS 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.
Cass Everitt - cass@r3.nu
*/
#ifndef NV_MATRIX_H
#define NV_MATRIX_H
namespace nv
{
template <class T> class vec2;
template <class T> class vec3;
template <class T> class vec4;
////////////////////////////////////////////////////////////////////////////////
//
// Matrix
//
////////////////////////////////////////////////////////////////////////////////
template<class T>
class matrix4
{
public:
matrix4()
{
make_identity();
}
matrix4(T t)
{
set_value(t);
}
matrix4(const T *m)
{
set_value(m);
}
matrix4(T a00, T a01, T a02, T a03,
T a10, T a11, T a12, T a13,
T a20, T a21, T a22, T a23,
T a30, T a31, T a32, T a33) :
_11(a00), _12(a01), _13(a02), _14(a03),
_21(a10), _22(a11), _23(a12), _24(a13),
_31(a20), _32(a21), _33(a22), _34(a23),
_41(a30), _42(a31), _43(a32), _44(a33)
{}
void get_value(T *mp) const
{
int c = 0;
for (int j=0; j < 4; j++)
for (int i=0; i < 4; i++)
{
mp[c++] = element(i,j);
}
}
const T *get_value() const
{
return _array;
}
void set_value(T *mp)
{
int c = 0;
for (int j=0; j < 4; j++)
for (int i=0; i < 4; i++)
{
element(i,j) = mp[c++];
}
}
void set_value(T r)
{
for (int i=0; i < 4; i++)
for (int j=0; j < 4; j++)
{
element(i,j) = r;
}
}
void make_identity()
{
element(0,0) = 1.0;
element(0,1) = 0.0;
element(0,2) = 0.0;
element(0,3) = 0.0;
element(1,0) = 0.0;
element(1,1) = 1.0;
element(1,2) = 0.0;
element(1,3) = 0.0;
element(2,0) = 0.0;
element(2,1) = 0.0;
element(2,2) = 1.0;
element(2,3) = 0.0;
element(3,0) = 0.0;
element(3,1) = 0.0;
element(3,2) = 0.0;
element(3,3) = 1.0;
}
// set a uniform scale
void set_scale(T s)
{
element(0,0) = s;
element(1,1) = s;
element(2,2) = s;
}
void set_scale(const vec3<T> &s)
{
for (int i = 0; i < 3; i++)
{
element(i,i) = s[i];
}
}
void set_translate(const vec3<T> &t)
{
for (int i = 0; i < 3; i++)
{
element(i,3) = t[i];
}
}
void set_row(int r, const vec4<T> &t)
{
for (int i = 0; i < 4; i++)
{
element(r,i) = t[i];
}
}
void set_column(int c, const vec4<T> &t)
{
for (int i = 0; i < 4; i++)
{
element(i,c) = t[i];
}
}
vec4<T> get_row(int r) const
{
vec4<T> v;
for (int i = 0; i < 4; i++)
{
v[i] = element(r,i);
}
return v;
}
vec4<T> get_column(int c) const
{
vec4<T> v;
for (int i = 0; i < 4; i++)
{
v[i] = element(i,c);
}
return v;
}
friend matrix4 inverse(const matrix4 &m)
{
matrix4 minv;
T r1[8], r2[8], r3[8], r4[8];
T *s[4], *tmprow;
s[0] = &r1[0];
s[1] = &r2[0];
s[2] = &r3[0];
s[3] = &r4[0];
register int i,j,p,jj;
for (i=0; i<4; i++)
{
for (j=0; j<4; j++)
{
s[i][j] = m.element(i,j);
if (i==j)
{
s[i][j+4] = 1.0;
}
else
{
s[i][j+4] = 0.0;
}
}
}
T scp[4];
for (i=0; i<4; i++)
{
scp[i] = T(fabs(s[i][0]));
for (j=1; j<4; j++)
if (T(fabs(s[i][j])) > scp[i])
{
scp[i] = T(fabs(s[i][j]));
}
if (scp[i] == 0.0)
{
return minv; // singular matrix!
}
}
int pivot_to;
T scp_max;
for (i=0; i<4; i++)
{
// select pivot row
pivot_to = i;
scp_max = T(fabs(s[i][i]/scp[i]));
// find out which row should be on top
for (p=i+1; p<4; p++)
if (T(fabs(s[p][i]/scp[p])) > scp_max)
{
scp_max = T(fabs(s[p][i]/scp[p]));
pivot_to = p;
}
// Pivot if necessary
if (pivot_to != i)
{
tmprow = s[i];
s[i] = s[pivot_to];
s[pivot_to] = tmprow;
T tmpscp;
tmpscp = scp[i];
scp[i] = scp[pivot_to];
scp[pivot_to] = tmpscp;
}
T mji;
// perform gaussian elimination
for (j=i+1; j<4; j++)
{
mji = s[j][i]/s[i][i];
s[j][i] = 0.0;
for (jj=i+1; jj<8; jj++)
{
s[j][jj] -= mji*s[i][jj];
}
}
}
if (s[3][3] == 0.0)
{
return minv; // singular matrix!
}
//
// Now we have an upper triangular matrix.
//
// x x x x | y y y y
// 0 x x x | y y y y
// 0 0 x x | y y y y
// 0 0 0 x | y y y y
//
// we'll back substitute to get the inverse
//
// 1 0 0 0 | z z z z
// 0 1 0 0 | z z z z
// 0 0 1 0 | z z z z
// 0 0 0 1 | z z z z
//
T mij;
for (i=3; i>0; i--)
{
for (j=i-1; j > -1; j--)
{
mij = s[j][i]/s[i][i];
for (jj=j+1; jj<8; jj++)
{
s[j][jj] -= mij*s[i][jj];
}
}
}
for (i=0; i<4; i++)
for (j=0; j<4; j++)
{
minv(i,j) = s[i][j+4] / s[i][i];
}
return minv;
}
friend matrix4 transpose(const matrix4 &m)
{
matrix4 mtrans;
for (int i=0; i<4; i++)
for (int j=0; j<4; j++)
{
mtrans(i,j) = m.element(j,i);
}
return mtrans;
}
matrix4 &operator *= (const matrix4 &rhs)
{
matrix4 mt(*this);
set_value(T(0));
for (int i=0; i < 4; i++)
for (int j=0; j < 4; j++)
for (int c=0; c < 4; c++)
{
element(i,j) += mt(i,c) * rhs(c,j);
}
return *this;
}
friend matrix4 operator * (const matrix4 &lhs, const matrix4 &rhs)
{
matrix4 r(T(0));
for (int i=0; i < 4; i++)
for (int j=0; j < 4; j++)
for (int c=0; c < 4; c++)
{
r.element(i,j) += lhs(i,c) * rhs(c,j);
}
return r;
}
// dst = M * src
vec4<T> operator *(const vec4<T> &src) const
{
vec4<T> r;
for (int i = 0; i < 4; i++)
r[i] = (src[0] * element(i,0) + src[1] * element(i,1) +
src[2] * element(i,2) + src[3] * element(i,3));
return r;
}
// dst = src * M
friend vec4<T> operator *(const vec4<T> &lhs, const matrix4 &rhs)
{
vec4<T> r;
for (int i = 0; i < 4; i++)
r[i] = (lhs[0] * rhs.element(0,i) + lhs[1] * rhs.element(1,i) +
lhs[2] * rhs.element(2,i) + lhs[3] * rhs.element(3,i));
return r;
}
T &operator()(int row, int col)
{
return element(row,col);
}
const T &operator()(int row, int col) const
{
return element(row,col);
}
T &element(int row, int col)
{
return _array[row | (col<<2)];
}
const T &element(int row, int col) const
{
return _array[row | (col<<2)];
}
matrix4 &operator *= (const T &r)
{
for (int i = 0; i < 4; ++i)
{
element(0,i) *= r;
element(1,i) *= r;
element(2,i) *= r;
element(3,i) *= r;
}
return *this;
}
matrix4 &operator += (const matrix4 &mat)
{
for (int i = 0; i < 4; ++i)
{
element(0,i) += mat.element(0,i);
element(1,i) += mat.element(1,i);
element(2,i) += mat.element(2,i);
element(3,i) += mat.element(3,i);
}
return *this;
}
friend bool operator == (const matrix4 &lhs, const matrix4 &rhs)
{
bool r = true;
for (int i = 0; i < 16; i++)
{
r &= lhs._array[i] == rhs._array[i];
}
return r;
}
friend bool operator != (const matrix4 &lhs, const matrix4 &rhs)
{
bool r = true;
for (int i = 0; i < 16; i++)
{
r &= lhs._array[i] != rhs._array[i];
}
return r;
}
union
{
struct
{
T _11, _12, _13, _14; // standard names for components
T _21, _22, _23, _24; // standard names for components
T _31, _32, _33, _34; // standard names for components
T _41, _42, _43, _44; // standard names for components
};
T _array[16]; // array access
};
};
};
#endif
| nicolasrosa/StereoVision | CUDA/NVIDIA_CUDA-7.5_Samples/5_Simulations/smokeParticles/nvMatrix.h | C | mit | 14,871 | [
30522,
1013,
1008,
1008,
9385,
2857,
1011,
2325,
1050,
17258,
2401,
3840,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
3531,
6523,
2000,
1996,
1050,
17258,
2401,
2203,
5310,
6105,
3820,
1006,
7327,
2721,
1007,
3378,
1008,
2007,
2023,
3120,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
module Language.Aspell (
-- * Constructors
SpellChecker,
spellChecker,
spellCheckerWithOptions,
spellCheckerWithDictionary,
-- * Using the spell checker
check,
suggest
) where
import Data.ByteString.Char8
import Foreign
#if !MIN_VERSION_base(4,7,0)
hiding (unsafePerformIO)
#endif
import Foreign.C.String
import Foreign.C.Types
import Language.Aspell.Options
import System.IO.Unsafe
type AspellConfig = ForeignPtr ()
type SpellChecker = ForeignPtr ()
type CAspellConfig = Ptr ()
type CSpellChecker = Ptr ()
type CAspellCanHaveError = Ptr ()
type CWordList = Ptr ()
type CStringEnumeration = Ptr ()
newConfig :: IO AspellConfig
newConfig = do
cf <- new_aspell_config
newForeignPtr delete_aspell_config cf
setOpts :: [ACOption] -> AspellConfig -> IO AspellConfig
setOpts (Dictionary dict:opts) pt = setOpt "master" dict pt >>= setOpts opts
setOpts (WordListDir dir:opts) pt = setOpt "dict-dir" dir pt >>= setOpts opts
setOpts (Lang lang:opts) pt = setOpt "lang" lang pt >>= setOpts opts
setOpts (Size size:opts) pt = setOpt "size" newSize pt >>= setOpts opts
where
newSize = case size of
Tiny -> "+10"
ReallySmall -> "+20"
Small -> "+30"
MediumSmall -> "+40"
Medium -> "+50"
MediumLarge -> "+60"
Large -> "+70"
Huge -> "+80"
Insane -> "+90"
setOpts (PersonalWordList wl:opts) pt = setOpt "personal" wl pt >>= setOpts opts
setOpts (ReplacementsList rl:opts) pt = setOpt "repl" rl pt >>= setOpts opts
setOpts (Encoding encoding:opts) pt = setOpt "encoding" enc pt >>= setOpts opts
where
enc = case encoding of
UTF8 -> "utf-8"
Latin1 -> "iso-8859-1"
setOpts (Normalize n:opts) pt = setOptBool "normalize" n pt >>= setOpts opts
setOpts (NormalizeStrict n:opts) pt = setOptBool "norm-strict" n pt >>= setOpts opts
setOpts (NormalizeForm form:opts) pt = setOpt "norm-form" nform pt >>= setOpts opts
where
nform = case form of
None -> "none"
NFD -> "nfd"
NFC -> "nfc"
Composed -> "comp"
setOpts (NormalizeRequired b:opts) pt = setOptBool "norm-required" b pt >>= setOpts opts
setOpts (Ignore i:opts) pt = setOptInteger "ignore" i pt >>= setOpts opts
setOpts (IgnoreReplace b:opts) pt = setOptBool "ignore-repl" b pt >>= setOpts opts
setOpts (SaveReplace b:opts) pt = setOptBool "save-repl" b pt >>= setOpts opts
setOpts (KeyboardDef s:opts) pt = setOpt "keyboard" s pt >>= setOpts opts
setOpts (SuggestMode sm:opts) pt = setOpt "sug-mode" mode pt >>= setOpts opts
where
mode = case sm of
Ultra -> "ultra"
Fast -> "fast"
Normal -> "normal"
Slow -> "slow"
BadSpellers -> "bad-spellers"
setOpts (IgnoreCase b:opts) pt = setOptBool "ignore-case" b pt >>= setOpts opts
setOpts (IgnoreAccents b:opts) pt = setOptBool "ignore-accents" b pt >>= setOpts opts
setOpts (FilterMode s:opts) pt = setOpt "mode" s pt >>= setOpts opts
setOpts (EmailMargin n:opts) pt = setOptInteger "email-margin" n pt >>= setOpts opts
setOpts (TeXCheckComments b:opts) pt = setOptBool "tex-check-comments" b pt >>= setOpts opts
setOpts (ContextVisibleFirst b:opts) pt = setOptBool "context-visible-first" b pt >>= setOpts opts
setOpts (RunTogether b:opts) pt = setOptBool "run-together" b pt >>= setOpts opts
setOpts (RunTogetherLimit n:opts) pt = setOptInteger "run-together-limit" n pt >>= setOpts opts
setOpts (RunTogetherMin n:opts) pt = setOptInteger "run-together-min" n pt >>= setOpts opts
setOpts (MainConfig s:opts) pt = setOpt "conf" s pt >>= setOpts opts
setOpts (MainConfigDir s:opts) pt = setOpt "conf-dir" s pt >>= setOpts opts
setOpts (DataDir s:opts) pt = setOpt "data-dir" s pt >>= setOpts opts
setOpts (LocalDataDir s:opts) pt = setOpt "local-data-dir" s pt >>= setOpts opts
setOpts (HomeDir s:opts) pt = setOpt "home-dir" s pt >>= setOpts opts
setOpts (PersonalConfig s:opts) pt = setOpt "per-conf" s pt >>= setOpts opts
setOpts (Layout s:opts) pt = setOpt "keyboard" s pt >>= setOpts opts
setOpts (Prefix s:opts) pt = setOpt "prefix" s pt >>= setOpts opts
setOpts (SetPrefix b:opts) pt = setOptBool "set-prefix" b pt >>= setOpts opts
setOpts [] pt = return pt
setOpt :: ByteString
-> ByteString
-> AspellConfig
-> IO AspellConfig
setOpt key value pt = do
withForeignPtr pt $ \ac ->
useAsCString key $ \k ->
useAsCString value $ aspell_config_replace ac k
return pt
setOptBool :: ByteString -> Bool -> AspellConfig -> IO AspellConfig
setOptBool k v = setOpt k (if v then "true" else "false")
setOptInteger :: ByteString -> Integer -> AspellConfig -> IO AspellConfig
setOptInteger k v = setOpt k (pack $ show v)
-- | Creates a spell checker with default options.
--
-- @
-- 'spellChecker' = 'spellCheckerWithOptions' []
-- @
--
spellChecker :: IO (Either ByteString SpellChecker)
spellChecker = spellCheckerWithOptions []
-- | Creates a spell checker with a custom set of options.
spellCheckerWithOptions :: [ACOption] -> IO (Either ByteString SpellChecker)
spellCheckerWithOptions opts = do
cf <- newConfig
setOpts opts cf
canError <- withForeignPtr cf new_aspell_speller
(errNum :: Int) <- fromIntegral `fmap` aspell_error_number canError
if errNum > 0
then do
errMsg <- aspell_error_message canError >>= packCString
return $ Left errMsg
else do
speller <- to_aspell_speller canError
for <- newForeignPtr delete_aspell_speller speller
return $ Right for
-- | Convenience function for specifying a dictionary.
--
-- You can determine which dictionaries are available to you with @aspell dump dicts@.
--
-- @
-- 'spellCheckerWithDictionary' dict = 'spellCheckerWithOptions' ['Dictionary' dict]
-- @
spellCheckerWithDictionary :: ByteString -> IO (Either ByteString SpellChecker)
spellCheckerWithDictionary b = spellCheckerWithOptions [Dictionary b]
-- | Checks if a word has been spelled correctly.
check :: SpellChecker -> ByteString -> Bool
check checker word = unsafePerformIO $
withForeignPtr checker $ \ck ->
useAsCString word $ \w -> do
res <- aspell_speller_check ck w $ negate 1
return $ res == 1
-- | Lists suggestions for misspelled words.
--
-- If the input is not misspelled according to the dictionary, returns @[]@.
suggest :: SpellChecker -> ByteString -> IO [ByteString]
suggest checker word = withForeignPtr checker $ \ck ->
useAsCString word $ \w -> do
wlist <- aspell_speller_suggest ck w (negate 1)
elems <- aspell_word_list_elements wlist
suggestions <- strEnumToList elems
delete_aspell_string_enumeration elems
return suggestions
strEnumToList :: CStringEnumeration -> IO [ByteString]
strEnumToList enum = go enum
where go e = do
nw <- aspell_string_enumeration_next enum
if nw == nullPtr
then return []
else do
curWord <- packCString nw
next <- go e
return $ curWord:next
foreign import ccall unsafe "aspell.h &delete_aspell_config"
delete_aspell_config :: FunPtr (CAspellConfig -> IO ())
foreign import ccall unsafe "aspell.h &delete_aspell_speller"
delete_aspell_speller :: FunPtr (CSpellChecker -> IO ())
foreign import ccall unsafe "aspell.h delete_aspell_string_enumeration"
delete_aspell_string_enumeration :: CStringEnumeration -> IO ()
foreign import ccall unsafe "aspell.h new_aspell_config"
new_aspell_config :: IO CAspellConfig
foreign import ccall unsafe "aspell.h aspell_config_replace"
aspell_config_replace :: CAspellConfig
-> CString
-> CString
-> IO CAspellConfig
foreign import ccall unsafe "aspell.h new_aspell_speller"
new_aspell_speller :: CAspellConfig
-> IO CAspellCanHaveError
foreign import ccall unsafe "aspell.h aspell_error_number"
aspell_error_number :: CAspellCanHaveError
-> IO CUInt
foreign import ccall unsafe "aspell.h aspell_error_message"
aspell_error_message :: CAspellCanHaveError
-> IO CString
foreign import ccall unsafe "aspell.h to_aspell_speller"
to_aspell_speller :: CAspellCanHaveError
-> IO CSpellChecker
foreign import ccall unsafe "aspell.h aspell_speller_check"
aspell_speller_check :: CSpellChecker
-> CString
-> CInt
-> IO CInt
foreign import ccall unsafe "aspell.h aspell_speller_suggest"
aspell_speller_suggest :: CSpellChecker
-> CString
-> CInt
-> IO CWordList
foreign import ccall unsafe "aspell.h aspell_word_list_elements"
aspell_word_list_elements :: CWordList
-> IO CStringEnumeration
foreign import ccall unsafe "aspell.h aspell_string_enumeration_next"
aspell_string_enumeration_next :: CStringEnumeration
-> IO CString
| pikajude/haspell | Language/Aspell.hs | Haskell | mit | 9,412 | [
30522,
11336,
2653,
1012,
2004,
11880,
2140,
1006,
1011,
1011,
1008,
9570,
5668,
6297,
5403,
9102,
1010,
6297,
5403,
9102,
1010,
6297,
5403,
9102,
24415,
7361,
9285,
1010,
6297,
5403,
9102,
24415,
29201,
3258,
5649,
1010,
1011,
1011,
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... |
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
config.logger = Logger.new(STDOUT)
end
| mdibaiee/pack | config/environments/development.rb | Ruby | mit | 1,718 | [
30522,
15168,
1012,
4646,
1012,
9530,
8873,
27390,
2063,
2079,
1001,
10906,
9675,
2182,
2097,
2202,
23359,
2058,
2216,
1999,
9530,
8873,
2290,
1013,
4646,
1012,
21144,
1012,
1001,
1999,
1996,
2458,
4044,
2115,
4646,
1005,
1055,
3642,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* $Id$ */
/***************************************************************************
* (C) Copyright 2003-2010 - Stendhal *
***************************************************************************
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
package games.stendhal.server.core.reflectiondebugger;
import java.io.Serializable;
/**
* This class is used to test the reflection code.
*
* @author hendrik
*/
public class MockChildClass extends MockParentClass implements Serializable {
// note this serialVersionUID is automatically created by emma
// so we create it here anyway to simplify testing with and without
// emma
private static final long serialVersionUID = 550331563324952898L;
public boolean childPublicBoolean = true;
// this class is used by reflection
@SuppressWarnings("unused")
private float childPrivateFloat = 2.0f;
}
| AntumDeluge/arianne-stendhal | tests/games/stendhal/server/core/reflectiondebugger/MockChildClass.java | Java | gpl-2.0 | 1,470 | [
30522,
1013,
1008,
1002,
8909,
1002,
1008,
1013,
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,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using Newtonsoft.Json;
using Stripe.Infrastructure;
using System;
using System.Collections.Generic;
namespace Stripe
{
public class StripeApplicationFeeRefund
{
[JsonProperty("amount")]
public int Amount { get; set; }
[JsonProperty("created")]
[JsonConverter(typeof(StripeDateTimeConverter))]
public DateTime Created { get; set; }
[JsonProperty("currency")]
public string Currency { get; set; }
public string BalanceTransactionId { get; set; }
[JsonIgnore]
public StripeBalanceTransaction BalanceTransaction { get; set; }
[JsonProperty( "balance_transaction" )]
internal object InternalBalanceTransaction
{
set
{
ExpandableProperty<StripeBalanceTransaction>.Map( value, s => BalanceTransactionId = s, o => BalanceTransaction = o );
}
}
[JsonProperty( "fee" )]
public string ApplicationFeeId { get; set; }
[JsonProperty( "metadata" )]
public Dictionary<string, string> Metadata { get; set; }
}
}
| weizensnake/stripe.net | src/Stripe/Entities/StripeApplicationFeeRefund.cs | C# | apache-2.0 | 1,114 | [
30522,
2478,
8446,
6499,
6199,
1012,
1046,
3385,
1025,
2478,
18247,
1012,
6502,
1025,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
3415,
15327,
18247,
1063,
2270,
2465,
18247,
29098,
19341,
3508,
7959,
7869,
11263,
4859,
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... |
/*
* Copyright (c) 2004-2005 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* 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.
*
* Authors: Gabe Black
*/
#ifndef __ARCH_SPARC_KERNEL_STATS_HH__
#define __ARCH_SPARC_KERNEL_STATS_HH__
#include <map>
#include <stack>
#include <string>
#include <vector>
#include "kern/kernel_stats.hh"
namespace SparcISA {
namespace Kernel {
class Statistics : public ::Kernel::Statistics
{
public:
Statistics() : ::Kernel::Statistics()
{}
};
} // namespace AlphaISA::Kernel
} // namespace AlphaISA
#endif // __ARCH_SPARC_KERNEL_STATS_HH__
| vineodd/PIMSim | GEM5Simulation/gem5/src/arch/sparc/kernel_stats.hh | C++ | gpl-3.0 | 2,043 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2432,
1011,
2384,
1996,
22832,
1997,
1996,
2118,
1997,
4174,
1008,
2035,
2916,
9235,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
2007,
2030,
2302,
1008,
14080,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2014 The Cacti Group |
| |
| 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. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
function graph_export($force = false) {
global $debug;
/* take time to log performance data */
list($micro,$seconds) = explode(" ", microtime());
$start = $seconds + $micro;
if ($debug) {
export_debug("This is a forced run");
}
if (read_config_option("export_timing") != "disabled" || $force) {
switch (read_config_option("export_timing")) {
case "classic":
export_debug("Export Type is Classical");
if ($force) {
db_execute("UPDATE settings SET value='1' WHERE name='path_html_export_ctr'");
$total_graphs_created = config_graph_export();
config_export_stats($start, $total_graphs_created);
}elseif (read_config_option("path_html_export_ctr") >= read_config_option("path_html_export_skip")) {
db_execute("UPDATE settings SET value='1' WHERE name='path_html_export_ctr'");
$total_graphs_created = config_graph_export();
config_export_stats($start, $total_graphs_created);
} elseif (read_config_option("path_html_export_ctr") == "") {
db_execute("DELETE FROM settings WHERE name='path_html_export_ctr' OR name='path_html_export_skip'");
db_execute("REPLACE INTO settings (name,value) VALUES ('path_html_export_ctr','1')");
db_execute("REPLACE INTO settings (name,value) VALUES ('path_html_export_skip','1')");
} else {
db_execute("update settings set value='" . (read_config_option("path_html_export_ctr") + 1) . "' where name='path_html_export_ctr'");
}
break;
case "export_hourly":
export_debug("Export Type is Export Hourly");
$export_minute = read_config_option('export_hourly');
$poller_minute = read_config_option('poller_interval') / 60;
if ($force) {
$total_graphs_created = config_graph_export();
config_export_stats($start, $total_graphs_created);
}elseif (empty($export_minute)) {
db_execute("REPLACE INTO settings (name,value) VALUES ('export_hourly','0')");
} elseif (floor((date('i') / $poller_minute)) == floor((read_config_option('export_hourly') / $poller_minute))) {
$total_graphs_created = config_graph_export();
config_export_stats($start, $total_graphs_created);
}
break;
case "export_daily":
export_debug("Export Type is Export Daily");
if ($force) {
$total_graphs_created = config_graph_export();
config_export_stats($start, $total_graphs_created);
}elseif (strstr(read_config_option('export_daily'), ':')) {
$export_daily_time = explode(':', read_config_option('export_daily'));
$poller_minute = read_config_option('poller_interval') / 60;
if (date('G') == $export_daily_time[0]) {
if (floor((date('i') / $poller_minute)) == floor(($export_daily_time[1] / $poller_minute))) {
$total_graphs_created = config_graph_export();
config_export_stats($start, $total_graphs_created);
}
}
} else {
db_execute("REPLACE INTO settings (name,value) VALUES ('export_daily','00:00')");
}
break;
default:
if ($force) {
$total_graphs_created = config_graph_export();
config_export_stats($start, $total_graphs_created);
}else{
export_log("Export timing not specified. Updated config to disable exporting.");
db_execute("REPLACE INTO settings (name,value) VALUES ('export_timing','disabled')");
}
}
}
}
function config_graph_export() {
$total_graphs_created = 0;
switch (read_config_option("export_type")) {
case "local":
export_debug("Export Type is 'local'");
$total_graphs_created = export();
break;
case "sftp_php":
export_debug("Export Type is 'sftp_php'");
if (!function_exists("ftp_ssl_connect")) {
export_fatal("Secure FTP Function does not exist. Export can not continue.");
}
case "ftp_php":
export_debug("Export Type is 'ftp_php'");
/* set the temp directory */
if (strlen(read_config_option("export_temporary_directory")) == 0) {
$stExportDir = $_ENV["TMP"] . '/cacti-ftp-temp';
}else{
$stExportDir = read_config_option("export_temporary_directory") . '/cacti-ftp-temp';
}
$total_graphs_created = export_pre_ftp_upload($stExportDir);
export_log("Using PHP built-in FTP functions.");
export_ftp_php_execute($stExportDir, read_config_option("export_type"));
export_post_ftp_upload($stExportDir);
break;
case "ftp_ncftpput":
export_debug("Export Type is 'ftp_ncftpput'");
if (strstr(PHP_OS, "WIN")) export_fatal("ncftpput only available in unix environment! Export can not continue.");
/* set the temp directory */
if (strlen(read_config_option("export_temporary_directory")) == 0) {
$stExportDir = $_ENV["TMP"] . '/cacti-ftp-temp';
}else{
$stExportDir = read_config_option("export_temporary_directory") . '/cacti-ftp-temp';
}
$total_graphs_created = export_pre_ftp_upload($stExportDir);
export_log("Using ncftpput.");
export_ftp_ncftpput_execute($stExportDir);
export_post_ftp_upload($stExportDir);
break;
case "disabled":
export_debug("Export Type is 'disabled'");
break;
default:
export_fatal("Export method not specified. Exporting can not continue. Please set method properly in Cacti configuration.");
}
return $total_graphs_created;
}
function config_export_stats($start, $total_graphs_created) {
/* take time to log performance data */
list($micro,$seconds) = explode(" ", microtime());
$end = $seconds + $micro;
$export_stats = sprintf(
"ExportDate:%s ExportDuration:%01.4f TotalGraphsExported:%s",
date("Y-m-d_G:i:s"), round($end - $start,4), $total_graphs_created);
cacti_log("STATS: " . $export_stats, true, "EXPORT");
/* insert poller stats into the settings table */
db_execute("replace into settings (name,value) values ('stats_export','$export_stats')");
}
function export_fatal($stMessage) {
cacti_log("FATAL ERROR: " . $stMessage, true, "EXPORT");
export_debug($stMessage);
exit;
}
function export_log($stMessage) {
if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_HIGH) {
cacti_log($stMessage, true, "EXPORT");
}
export_debug($stMessage);
}
function export_debug($message) {
global $debug;
if ($debug) {
print rtrim($message) . "\n";
}
}
function export_pre_ftp_upload($stExportDir) {
global $config, $aFtpExport;
/* export variable as global */
$config["config_options_array"]["path_html_export"] = $stExportDir;
/* clean-up after last cacti instance */
if (is_dir($stExportDir)) {
del_directory($stExportDir, FALSE);
}else {
@mkdir($stExportDir);
}
/* go export */
$total_graphs_created = export();
/* force reaing of the variable from the database */
unset($config["config_options_array"]["path_html_export"]);
$aFtpExport['server'] = read_config_option('export_ftp_host');
if (empty($aFtpExport['server'])) {
export_fatal("FTP Hostname is not expected to be blank!");
}
$aFtpExport['remotedir'] = read_config_option('path_html_export');
if (empty($aFtpExport['remotedir'])) {
export_fatal("FTP Remote export path is not expected to be blank!");
}
$aFtpExport['port'] = read_config_option('export_ftp_port');
$aFtpExport['port'] = empty($aFtpExport['port']) ? '21' : $aFtpExport['port'];
$aFtpExport['username'] = read_config_option('export_ftp_user');
$aFtpExport['password'] = read_config_option('export_ftp_password');
if (empty($aFtpExport['username'])) {
$aFtpExport['username'] = 'Anonymous';
$aFtpExport['password'] = '';
export_log("Using Anonymous transfer method.");
}
if (read_config_option('export_ftp_passive') == 'on') {
$aFtpExport['passive'] = TRUE;
export_log("Using passive transfer method.");
}else {
$aFtpExport['passive'] = FALSE;
export_log("Using active transfer method.");
}
return $total_graphs_created;
}
function export_ftp_php_execute($stExportDir, $stFtpType = "ftp_php") {
global $aFtpExport;
/* connect to foreign system */
switch($stFtpType) {
case "ftp_php":
$oFtpConnection = ftp_connect($aFtpExport['server'], $aFtpExport['port']);
if (!$oFtpConnection) {
export_fatal("FTP Connection failed! Check hostname and port. Export can not continue.");
}else {
export_log("Conection to remote server was successful.");
}
break;
case "sftp_php":
$oFtpConnection = ftp_ssl_connect($aFtpExport['server'], $aFtpExport['port']);
if (!$oFtpConnection) {
export_fatal("SFTP Connection failed! Check hostname and port. Export can not continue.");
}else {
export_log("Conection to remote server was successful.");
}
break;
}
/* login to foreign system */
if (!ftp_login($oFtpConnection, $aFtpExport['username'], $aFtpExport['password'])) {
ftp_close($oFtpConnection);
export_fatal("FTP Login failed! Check username and password. Export can not continue.");
}else {
export_log("Remote login was successful.");
}
/* set connection type */
if ($aFtpExport['passive']) {
ftp_pasv($oFtpConnection, TRUE);
}else {
ftp_pasv($oFtpConnection, FALSE);
}
/* change directories into the remote upload directory */
if (!@ftp_chdir($oFtpConnection, $aFtpExport['remotedir'])) {
ftp_close($oFtpConnection);
export_fatal("FTP Remote directory '" . $aFtpExport['remotedir'] . "' does not exist!. Export can not continue.");
}
/* sanitize the remote location if the user has asked so */
if (read_config_option('export_ftp_sanitize') == 'on') {
export_log("Deleting remote files.");
/* get rid of the files first */
$aFtpRemoteFiles = ftp_nlist($oFtpConnection, $aFtpExport['remotedir']);
if (is_array($aFtpRemoteFiles)) {
foreach ($aFtpRemoteFiles as $stFile) {
export_log("Deleting remote file '" . $stFile . "'");
@ftp_delete($oFtpConnection, $stFile);
}
}
/* if the presentation is tree, you will have some directories too */
if (read_config_option("export_presentation") == "tree") {
$aFtpRemoteDirs = ftp_nlist($oFtpConnection, $aFtpExport['remotedir']);
foreach ($aFtpRemoteDirs as $remote_dir) {
if (ftp_chdir($oFtpConnection, addslashes($remote_dir))) {
$aFtpRemoteFiles = ftp_nlist($oFtpConnection, ".");
if (is_array($aFtpRemoteFiles)) {
foreach ($aFtpRemoteFiles as $stFile) {
export_log("Deleting Remote File '" . $stFile . "'");
ftp_delete($oFtpConnection, $stFile);
}
}
ftp_chdir($oFtpConnection, "..");
export_log("Removing Remote Directory '" . $remote_dir . "'");
ftp_rmdir($oFtpConnection, $remote_dir);
}else{
ftp_close($oFtpConnection);
export_fatal("Unable to cd on remote system");
}
}
}
$aFtpRemoteFiles = ftp_nlist($oFtpConnection, $aFtpExport['remotedir']);
if (sizeof($aFtpRemoteFiles) > 0) {
ftp_close($oFtpConnection);
export_fatal("Problem sanitizing remote ftp location, must exit.");
}
}
/* upload files to remote system */
export_log("Uploading files to remote location.");
ftp_chdir($oFtpConnection, $aFtpExport['remotedir']);
export_ftp_php_uploaddir($stExportDir,$oFtpConnection);
/* end connection */
export_log("Closing ftp connection.");
ftp_close($oFtpConnection);
}
function export_ftp_php_uploaddir($dir,$oFtpConnection) {
global $aFtpExport;
export_log("Uploading directory: '$dir' to remote location.");
if($dh = opendir($dir)) {
export_log("Uploading files to remote location.");
while(($file = readdir($dh)) !== false) {
$filePath = $dir . "/" . $file;
if($file != "." && $file != ".." && !is_dir($filePath)) {
if(!ftp_put($oFtpConnection, $file, $filePath, FTP_BINARY)) {
export_log("Failed to upload '$file'.");
}
}
if (($file != ".") &&
($file != "..") &&
(is_dir($filePath))) {
export_log("Create remote directory: '$file'.");
ftp_mkdir($oFtpConnection,$file);
export_log("Change remote directory to: '$file'.");
ftp_chdir($oFtpConnection,$file);
export_ftp_php_uploaddir($filePath,$oFtpConnection);
export_log("Change remote directory: one up.");
ftp_cdup($oFtpConnection);
}
}
closedir($dh);
}
}
function export_ftp_ncftpput_execute($stExportDir) {
global $aFtpExport;
chdir($stExportDir);
/* set the initial command structure */
$stExecute = 'ncftpput -R -V -r 1 -u ' . cacti_escapeshellarg($aFtpExport['username']) . ' -p ' . cacti_escapeshellarg($aFtpExport['password']);
/* if the user requested passive mode, use it */
if ($aFtpExport['passive']) {
$stExecute .= ' -F ';
}
/* setup the port, server, remote directory and all files */
$stExecute .= ' -P ' . cacti_escapeshellarg($aFtpExport['port']) . ' ' . cacti_escapeshellarg($aFtpExport['server']) . ' ' . cacti_escapeshellarg($aFtpExport['remotedir']) . ".";
/* run the command */
$iExecuteReturns = 0;
system($stExecute, $iExecuteReturns);
$aNcftpputStatusCodes = array (
'Success.',
'Could not connect to remote host.',
'Could not connect to remote host - timed out.',
'Transfer failed.',
'Transfer failed - timed out.',
'Directory change failed.',
'Directory change failed - timed out.',
'Malformed URL.',
'Usage error.',
'Error in login configuration file.',
'Library initialization failed.',
'Session initialization failed.');
export_log('Ncftpput returned: ' . $aNcftpputStatusCodes[$iExecuteReturns]);
}
function export_post_ftp_upload($stExportDir) {
/* clean-up after ftp-put */
if ($dh = opendir($stExportDir)) {
while (($file = readdir($dh)) !== false) {
$filePath = $stExportDir . "/" . $file;
if ($file != "." && $file != ".." && !is_dir($filePath)) {
export_log("Removing Local File '" . $file . "'");
unlink($filePath);
}
/* if the directory turns out to be a sub-directory, delete it too */
if ($file != "." && $file != ".." && is_dir($filePath)) {
export_log("Removing Local Directory '" . $filePath . "'");
export_post_ftp_upload($filePath);
}
}
closedir($dh);
/* don't delete the root of the temporary export directory */
if (read_config_option("export_temporary_directory") != $stExportDir) {
rmdir($stExportDir);
}
}
}
function export() {
global $config;
/* count how many graphs are created */
$total_graphs_created = 0;
$cacti_root_path = $config["base_path"];
$cacti_export_path = read_config_option("path_html_export");
/* if the path is not a directory, don't continue */
if (!is_dir($cacti_export_path)) {
export_fatal("Export path '" . $cacti_export_path . "' does not exist! Export can not continue.");
}
/* blank paths are not good */
if (strlen($cacti_export_path) == 0) {
export_fatal("Export path is null! Export can not continue.");
}
/* can not be the web root */
if ((strcasecmp($cacti_root_path, $cacti_export_path) == 0) &&
(read_config_option("export_type") == "local")) {
export_fatal("Export path '" . $cacti_export_path . "' is the Cacti web root. Can not continue.");
}
/* can not be a parent of the Cacti web root */
if (strncasecmp($cacti_root_path, $cacti_export_path, strlen($cacti_export_path))== 0) {
export_fatal("Export path '" . $cacti_export_path . "' is a parent folder from the Cacti web root. Can not continue.");
}
/* check for bad directories within the cacti path */
if (strcasecmp($cacti_root_path, $cacti_export_path) < 0) {
$cacti_system_paths = array(
"include",
"lib",
"install",
"rra",
"log",
"scripts",
"plugins",
"images",
"resource");
foreach($cacti_system_paths as $cacti_system_path) {
if (substr_count(strtolower($cacti_export_path), strtolower($cacti_system_path)) > 0) {
export_fatal("Export path '" . $cacti_export_path . "' is potentially within a Cacti system path '" . $cacti_system_path . "'. Can not continue.");
}
}
}
/* don't allow to export to system paths */
$system_paths = array(
"/boot",
"/lib",
"/usr",
"/usr/bin",
"/bin",
"/sbin",
"/usr/sbin",
"/usr/lib",
"/var/lib",
"/root",
"/etc",
"windows",
"winnt",
"program files");
foreach($system_paths as $system_path) {
if (substr($system_path, 0, 1) == "/") {
if ($system_path == substr($cacti_export_path, 0, strlen($system_path))) {
export_fatal("Export path '" . $cacti_export_path . "' is within a system path '" . $system_path . "'. Can not continue.");
}
}elseif (substr_count(strtolower($cacti_export_path), strtolower($system_path)) > 0) {
export_fatal("Export path '" . $cacti_export_path . "' is within a system path '" . $system_path . "'. Can not continue.");
}
}
export_log("Running graph export");
/* delete all files and directories in the cacti_export_path */
del_directory($cacti_export_path, false);
/* test how will the export will be made */
if (read_config_option('export_presentation') == 'tree') {
export_log("Running graph export with tree organization");
$total_graphs_created = tree_export();
}else {
export_log("Running graph export with legacy organization");
$total_graphs_created = classical_export($cacti_root_path, $cacti_export_path);
}
return $total_graphs_created;
}
function classical_export($cacti_root_path, $cacti_export_path) {
global $config;
include_once($config["base_path"] . "/lib/time.php");
$total_graphs_created = 0;
/* copy the css/images on the first time */
if (file_exists("$cacti_export_path/main.css") == false) {
copy("$cacti_root_path/include/main.css", "$cacti_export_path/main.css");
copy("$cacti_root_path/images/tab_cacti.gif", "$cacti_export_path/tab_cacti.gif");
copy("$cacti_root_path/images/cacti_backdrop.gif", "$cacti_export_path/cacti_backdrop.gif");
copy("$cacti_root_path/images/transparent_line.gif", "$cacti_export_path/transparent_line.gif");
copy("$cacti_root_path/images/shadow.gif", "$cacti_export_path/shadow.gif");
}
/* create the base directory */
if (!is_dir("$cacti_export_path/graphs")) {
if (!mkdir("$cacti_export_path/graphs", 0755, true)) {
export_fatal("Create directory '$cacti_export_path/graphs' failed. Can not continue");
}
}
/* determine the number of columns to write */
$classic_columns = read_config_option("export_num_columns");
/* if the index file already exists, delete it */
check_remove($cacti_export_path . "/index.html");
export_log("Creating File '" . $cacti_export_path . "/index.html'");
/* open pointer to the new index file */
$fp_index = fopen($cacti_export_path . "/index.html", "w");
/* get a list of all graphs that need exported */
$exportuser = read_config_option("export_user_id");
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
$sql_where = "WHERE " . get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
$sql_join = "LEFT JOIN host ON (host.id=graph_local.host_id)
LEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)
LEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id AND user_auth_perms.type=1 AND user_auth_perms.user_id=$exportuser)
OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=$exportuser)
OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=$exportuser))";
$sql_base = "FROM (graph_templates_graph,graph_local)
$sql_join
$sql_where
" . (empty($sql_where) ? "WHERE" : "AND") . " graph_templates_graph.local_graph_id > 0
AND graph_templates_graph.export='on'
AND graph_templates_graph.local_graph_id=graph_local.id";
$graphs = db_fetch_assoc("SELECT
graph_templates_graph.local_graph_id,
graph_templates_graph.title_cache,
graph_templates_graph.height,
graph_templates_graph.width
$sql_base
GROUP BY graph_templates_graph.local_graph_id");
$rras = db_fetch_assoc("SELECT
rra.id,
rra.name
FROM rra
ORDER BY timespan");
/* write the html header data to the index file */
$stats = "Export Date: " . date(date_time_format()) . "<br>";
$stats.= "Total Graphs: " . sizeof($graphs);
fwrite($fp_index, HTML_HEADER_CLASSIC);
fwrite($fp_index, HTML_GRAPH_HEADER_ONE_CLASSIC);
fwrite($fp_index, $stats);
fwrite($fp_index, HTML_GRAPH_HEADER_TWO_CLASSIC);
/* open a pipe to rrdtool for writing */
$rrdtool_pipe = rrd_init();
/* for each graph... */
$i = 0; $k = 0;
if ((sizeof($graphs) > 0) && (sizeof($rras) > 0)) {
foreach ($graphs as $graph) {
check_remove($cacti_export_path . "graphs/thumb_" . $graph["local_graph_id"] . ".png");
check_remove($cacti_export_path . "graph_" . $graph["local_graph_id"] . ".html");
/* settings for preview graphs */
$graph_data_array["graph_height"] = read_config_option("export_default_height");
$graph_data_array["graph_width"] = read_config_option("export_default_width");
$graph_data_array["graph_nolegend"] = true;
$graph_data_array["export"] = true;
$graph_data_array["export_filename"] = "graphs/thumb_" . $graph["local_graph_id"] . ".png";
export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
@rrdtool_function_graph($graph["local_graph_id"], 0, $graph_data_array, $rrdtool_pipe);
$total_graphs_created++;
/* generate html files for each graph */
if (!file_exists($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html")) {
export_log("Creating File '" . $cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html");
$fp_graph_index = fopen($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
fwrite($fp_graph_index, HTML_HEADER_CLASSIC);
fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE_CLASSIC);
fwrite($fp_graph_index, "<strong>Graph - " . $graph["title_cache"] . "</strong>");
fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO_CLASSIC);
fwrite($fp_graph_index, "<td>");
}else{
$fp_graph_index = NULL;
}
/* reset vars for actual graph image creation */
reset($rras);
unset($graph_data_array);
/* generate graphs for each rra */
foreach ($rras as $rra) {
$graph_data_array["export"] = true;
$graph_data_array["export_filename"] = "graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png";
export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
@rrdtool_function_graph($graph["local_graph_id"], $rra["id"], $graph_data_array, $rrdtool_pipe);
$total_graphs_created++;
/* write image related html */
fwrite($fp_graph_index, "<div align=center><img src='graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png' border=0></div>\n
<div align=center><strong>" . $rra["name"] . "</strong></div><br>");
}
fwrite($fp_graph_index, "</td></table>");
fwrite($fp_graph_index, HTML_GRAPH_FOOTER_CLASSIC);
fwrite($fp_graph_index, HTML_FOOTER_CLASSIC);
fclose($fp_graph_index);
/* main graph page html */
fwrite($fp_index, "<td align='center' width='" . round(100 / $classic_columns,0) . "%'><a href='graph_" . $graph["local_graph_id"] . ".html'><img src='graphs/thumb_" . $graph["local_graph_id"] . ".png' border='0' alt='" . $graph["title_cache"] . "'></a></td>\n");
$i++;
$k++;
if ((($i % $classic_columns) == 0) && ($k < count($graphs))) {
fwrite($fp_index, "</tr><tr>");
}
}
}else{
fwrite($fp_index, "<td><em>No Graphs Found.</em></td>");
}
/* close the rrdtool pipe */
rrd_close($rrdtool_pipe);
fwrite($fp_index, HTML_GRAPH_FOOTER_CLASSIC);
fwrite($fp_index, HTML_FOOTER_CLASSIC);
fclose($fp_index);
return $total_graphs_created;
}
function tree_export() {
global $config;
include_once($config["base_path"] . "/lib/time.php");
$total_graphs_created = 0;
/* set the user to utilize for establishing export permissions */
$export_user = read_config_option("export_user_id");
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id='" . $export_user . "'");
$cacti_root_path = $config["base_path"];
$cacti_export_path = read_config_option("path_html_export");
/* if the selected user has default rights, show all the graphs */
if ($current_user["policy_trees"] == 1) {
$trees = db_fetch_assoc("SELECT
id,
name
FROM graph_tree");
}else{
/* otherwise, show only those tree's that the user has access to */
$trees = db_fetch_assoc("SELECT
graph_tree.id AS id,
graph_tree.name AS name
FROM user_auth_perms
INNER JOIN graph_tree
ON (user_auth_perms.item_id = graph_tree.id)
WHERE user_auth_perms.user_id ='" . $current_user["id"] . "'");
}
/* if tree isolation is off, create the treeview and graphs directories for the initial hierarchy */
if (read_config_option("export_tree_isolation") == "off") {
/* create directory structure */
create_export_directory_structure($cacti_root_path, $cacti_export_path);
/* export graphs */
foreach($trees as $tree) {
$total_graphs_created += export_tree_graphs_and_graph_html("", $tree["id"]);
}
/* build base index files first */
$stats["timestamp"] = date(date_time_format());
$stats["total_graphs_created"] = $total_graphs_created;
build_html_file(0, "index", $stats);
foreach($trees as $tree) {
$leaf["tree_id"] = $tree["id"];
$leaf["title"] = "";
$leaf["name"] = $tree["name"];
build_html_file($leaf, "tree");
/* build remainder of html files */
export_tree_html("", clean_up_export_name($tree["name"]) . "_index.html", $tree["id"], 0);
}
}else{
/* now let's populate all the sub trees */
foreach ($trees as $tree) {
/* create the base directory */
if (!is_dir("$cacti_export_path/" . clean_up_export_name($tree["name"]))) {
if (!mkdir("$cacti_export_path/" . clean_up_export_name($tree["name"]), 0755, true)) {
export_fatal("Create directory '" . clean_up_export_name($tree["name"]) . "' failed. Can not continue");
}
}
create_export_directory_structure($cacti_root_path, $cacti_export_path . "/" . clean_up_export_name($tree["name"]));
/* build base index files first */
$stats["timestamp"] = date(date_time_format());
$stats["total_graphs_created"] = $total_graphs_created;
build_html_file($tree["id"], "index", $stats);
$leaf["tree_id"] = $tree["id"];
$leaf["title"] = "";
$leaf["name"] = $tree["name"];
build_html_file($leaf, "tree");
$total_graphs_created += export_tree_graphs_and_graph_html(clean_up_export_name($tree["name"]), $tree["id"]);
export_tree_html("graphs", "index.html", $tree["id"], 0);
}
}
return $total_graphs_created;
}
function export_tree_html($path, $filename, $tree_id, $parent_tree_item_id) {
/* auth check for hosts on the trees */
if (read_config_option("auth_method") != 0) {
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
$sql_join = "LEFT JOIN user_auth_perms ON (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . read_config_option("export_user_id") . ")";
if ($current_user["policy_hosts"] == "1") {
$sql_where = "AND !(user_auth_perms.user_id IS NOT NULL AND graph_tree_items.host_id>0)";
}elseif ($current_user["policy_hosts"] == "2") {
$sql_where = "AND !(user_auth_perms.user_id IS NULL AND graph_tree_items.host_id>0)";
}
}else{
$sql_join = "";
$sql_where = "";
}
if ($tree_id == 0) {
$sql_where = "WHERE graph_tree_items.local_graph_id=0
$sql_where";
}else{
$sql_where = "WHERE graph_tree_items.graph_tree_id=" . $tree_id . "
$sql_where
AND graph_tree_items.local_graph_id=0";
}
$hier_sql = "SELECT DISTINCT
graph_tree.name,
graph_tree.id AS tree_id,
graph_tree_items.id,
graph_tree_items.title,
graph_tree_items.order_key,
graph_tree_items.host_id,
graph_tree_items.host_grouping_type,
host.description AS hostname
FROM graph_tree
LEFT JOIN (graph_tree_items
LEFT JOIN host ON (graph_tree_items.host_id=host.id)
$sql_join)
ON graph_tree.id = graph_tree_items.graph_tree_id
$sql_where
ORDER BY graph_tree.name, graph_tree_items.order_key";
$hierarchy = db_fetch_assoc($hier_sql);
$node = '';
/* build all the html files */
if (sizeof($hierarchy) > 0) {
foreach ($hierarchy as $leaf) {
if ($leaf["host_id"] > 0) {
$node = build_html_file($leaf, "host", "", "", $node);
if (read_config_option("export_tree_expand_hosts") == "on") {
if ($leaf["host_grouping_type"] == HOST_GROUPING_GRAPH_TEMPLATE) {
$graph_templates = db_fetch_assoc("SELECT
graph_templates.id,
graph_templates.name,
graph_templates_graph.local_graph_id,
graph_templates_graph.title_cache
FROM (graph_local,graph_templates,graph_templates_graph)
WHERE graph_local.id=graph_templates_graph.local_graph_id
AND graph_templates_graph.graph_template_id=graph_templates.id
AND graph_local.host_id=" . $leaf["host_id"] . "
AND graph_templates_graph.export='on'
GROUP BY graph_templates.id
ORDER BY graph_templates.name");
if (sizeof($graph_templates)) {
foreach($graph_templates as $graph_template) {
$node = build_html_file($leaf, "gt", $graph_template, "", "", $node);
}
}
}else if ($leaf["host_grouping_type"] == HOST_GROUPING_DATA_QUERY_INDEX) {
$data_queries = db_fetch_assoc("SELECT
snmp_query.id,
snmp_query.name
FROM (graph_local,snmp_query)
WHERE graph_local.snmp_query_id=snmp_query.id
AND graph_local.host_id=" . $leaf["host_id"] . "
GROUP BY snmp_query.id
ORDER BY snmp_query.name");
array_push($data_queries, array(
"id" => "0",
"name" => "Graph Template Based"
));
foreach ($data_queries as $data_query) {
$node = build_html_file($leaf, "dq", $data_query, "", "", $node);
/* fetch a list of field names that are sorted by the preferred sort field */
$sort_field_data = get_formatted_data_query_indexes($leaf["host_id"], $data_query["id"]);
if ($data_query["id"] > 0) {
while (list($snmp_index, $sort_field_value) = each($sort_field_data)) {
$node = build_html_file($leaf, "dqi", $data_query, $snmp_index);
}
}
}
}
}
}else{
$node = build_html_file($leaf, "leaf", "", "", "", $node);
}
}
}
}
function build_html_file($leaf, $type = "", $array_data = array(), $snmp_index = "", $prev_node = "") {
$cacti_export_path = read_config_option("path_html_export");
/* auth check for hosts on the trees */
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
$sql_join = "LEFT JOIN user_auth_perms ON (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . read_config_option("export_user_id") . ")";
$sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
$sql_where = (empty($sql_where) ? "" : "AND $sql_where");
switch ($type) {
case "index":
$sql_where = "";
$filename = "index.html";
break;
case "tree":
$sql_join = "LEFT JOIN user_auth_perms ON (graph_templates_graph.local_graph_id=user_auth_perms.item_id AND user_auth_perms.type=1 AND user_auth_perms.user_id=" . read_config_option("export_user_id") . ")";
/* searching for the graph_tree_items of the tree_id which are graphs */
if ($leaf["tree_id"] == 0) {
$sql_where = "WHERE graph_templates_graph.local_graph_id!=0
$sql_where
AND graph_templates_graph.export='on'";
$filename = "index.html";
}else{
$search_key = "";
/* get the "starting leaf" if the user clicked on a specific branch */
if (!empty($leaf["id"])) {
$search_key = substr($leaf["order_key"], 0, (tree_tier($leaf["order_key"]) * CHARS_PER_TIER));
}
$sql_where = "WHERE graph_tree_items.graph_tree_id=" . $leaf["tree_id"] . "
$sql_where
AND graph_templates_graph.local_graph_id!=0
AND graph_templates_graph.export='on'
AND graph_tree_items.order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'";
if ($current_user["policy_graphs"] == 2) {
$sql_where .= " AND user_auth_perms.item_id=graph_tree_items.local_graph_id";
}
$filename = clean_up_export_name(get_tree_name($leaf["tree_id"])) . "_" . $leaf['tree_id'] . ".html";
}
break;
case "leaf":
$sql_join = "LEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $current_user["id"] . "))";
/* searching for the graph_tree_items of the tree_id which are graphs */
if ($leaf["tree_id"] == 0) {
$sql_where = "WHERE graph_templates_graph.local_graph_id!=0
$sql_where
AND graph_templates_graph.export='on'";
$filename = "index.html";
}else{
$search_key = "";
/* get the "starting leaf" if the user clicked on a specific branch */
if (!empty($leaf["id"])) {
$search_key = substr($leaf["order_key"], 0, (tree_tier($leaf["order_key"]) * CHARS_PER_TIER));
}
$sql_where = "WHERE graph_tree_items.graph_tree_id=" . $leaf["tree_id"] . "
$sql_where
AND graph_templates_graph.local_graph_id!=0
AND graph_templates_graph.export='on'
AND graph_tree_items.order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'";
if ($current_user["policy_graphs"] == 2) {
$sql_where .= " AND user_auth_perms.item_id=graph_tree_items.local_graph_id";
}
if (strlen($leaf["title"])) {
$filename = clean_up_export_name(get_tree_name($leaf["tree_id"]) . "_" . $leaf["title"]) . "_" . $leaf["id"] . ".html";
}else{
$filename = clean_up_export_name(get_tree_name($leaf["tree_id"])) . "_" . $leaf["id"] . ".html";
$i++;
}
}
break;
case "host":
$sql_where = "WHERE graph_templates_graph.local_graph_id!=0
$sql_where
AND graph_local.host_id=" . $leaf["host_id"] . "
AND graph_templates_graph.export='on'";
$filename = clean_up_export_name($leaf["hostname"]) . "_" . $leaf["id"] . ".html";
break;
case "gt":
$sql_where = "WHERE graph_templates_graph.local_graph_id!=0
$sql_where
AND graph_local.host_id=" . $leaf["host_id"] . "
AND graph_templates_graph.export='on'
AND graph_templates_graph.graph_template_id=" . $array_data["id"];
$filename = clean_up_export_name($leaf["hostname"]) . "_gt_" . $leaf["id"] . "_" . $array_data["id"] . ".html";
break;
case "dq":
$sql_where = "WHERE graph_templates_graph.local_graph_id!=0
$sql_where
AND graph_local.host_id=" . $leaf["host_id"] . "
AND graph_local.snmp_query_id=" . $array_data["id"] . "
AND graph_templates_graph.export='on'";
$filename = clean_up_export_name($leaf["hostname"]) . "_dq_" . $leaf["id"] . "_" . $array_data["id"] . ".html";
break;
case "dqi":
$sql_where = "WHERE graph_templates_graph.local_graph_id<>0
$sql_where
AND graph_local.host_id=" . $leaf["host_id"] . "
AND graph_local.snmp_query_id=" . $array_data["id"] . "
AND graph_local.snmp_index=" . $snmp_index . "
AND graph_templates_graph.export='on'";
$filename = clean_up_export_name($leaf["hostname"]) . "_dqi_" . $leaf["id"] . "_" . $array_data["id"] . "_" . $snmp_index . ".html";
break;
}
switch ($type) {
case "index":
break;
case "tree":
case "leaf":
$request = "SELECT DISTINCT
graph_tree_items.id,
graph_tree_items.title,
graph_tree_items.local_graph_id,
graph_tree_items.rra_id,
graph_tree_items.order_key,
graph_templates_graph.title_cache as title_cache
FROM (graph_tree_items,graph_local)
LEFT JOIN host ON (host.id=graph_local.host_id)
LEFT JOIN graph_templates_graph ON (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id AND graph_tree_items.local_graph_id>0)
LEFT JOIN graph_templates ON (graph_templates_graph.graph_template_id=graph_templates.id)
$sql_join
$sql_where
GROUP BY graph_tree_items.id
ORDER BY graph_tree_items.order_key";
break;
case "host":
case "gt":
case "dq":
case "dqi":
$request = "SELECT DISTINCT
graph_templates_graph.id,
graph_templates_graph.local_graph_id,
graph_templates_graph.height,
graph_templates_graph.width,
graph_templates_graph.title_cache,
graph_templates.name
FROM (graph_tree_items, graph_templates_graph)
LEFT JOIN graph_templates ON (graph_templates_graph.graph_template_id=graph_templates.id)
LEFT JOIN graph_local ON (graph_templates_graph.local_graph_id=graph_local.id)
LEFT JOIN host ON (host.id=graph_local.host_id)
$sql_join
$sql_where" . (strlen($sql_where) ? " AND ":"WHERE ") .
"graph_templates_graph.export='on'
ORDER BY graph_templates_graph.title_cache";
break;
}
if ($type == "index") {
$graphs = array();
}else{
$graphs = db_fetch_assoc($request);
}
/* get the path name */
if (read_config_option("export_tree_isolation") == "off") {
$path = "";
}else{
$path = clean_up_export_name(get_tree_name($leaf["tree_id"]));
}
export_log("Creating File '" . $cacti_export_path . "/" . $path . "/" . $filename . "'");
/* assign the node id */
$new_node = str_replace(".html", "", $filename);
/* open pointer to the new file */
$fp = fopen($cacti_export_path . "/" . $path . "/" . $filename, "w");
/* begin old stuff */
$cacti_export_path = read_config_option("path_html_export");
/* write the html header data to the file */
fwrite($fp, HTML_HEADER_TREE);
/* write the code for the tree at the left */
draw_html_left_tree($fp, $leaf["tree_id"], $prev_node);
/* write the associated graphs for this graph_tree_item or graph_tree*/
fwrite($fp, HTML_GRAPH_HEADER_ONE_TREE);
switch($type) {
case "index":
fwrite($fp, "<strong>Graphs Last Updated on :</strong></td></tr>" .
"<tr bgcolor='#a9b7cb'>" .
"<td colspan='3' class='textHeaderDark'>" .
"Export Date: " . $array_data["timestamp"] . "<br>" .
"Total Graphs: " . $array_data["total_graphs_created"] .
"</td>" .
"</tr><tr>");
break;
case "tree":
fwrite($fp, "<strong>Tree:</strong> " . get_tree_name($leaf["tree_id"]) . " - Associated Graphs" . "</td></tr><tr>");
break;
case "leaf":
fwrite($fp, "<strong>Tree:</strong> " . get_tree_name($leaf["tree_id"]) . "</td></tr><tr bgcolor='#a9b7cb'><td colspan='3' class='textHeaderDark'><strong>Leaf:</strong> " . $leaf["title"] . " - Associated Graphs" . "</td></tr><tr>");
break;
case "host":
fwrite($fp, "<strong>Host:</strong> " . $leaf["hostname"] . " - Associated Graphs" . "</td></tr><tr>");
break;
case "gt":
fwrite($fp, "<strong>Host:</strong> " . $leaf["hostname"] . "</td></tr><tr bgcolor='#a9b7cb'><td colspan='3' class='textHeaderDark'><strong>Graph Template:</strong> " . $array_data["name"] . " - Associated Graphs" . "</td></tr><tr>");
break;
case "dq":
fwrite($fp, "<strong>Host:</strong> " . $leaf["hostname"] . "</td></tr><tr bgcolor='#a9b7cb'><td colspan='3' class='textHeaderDark'><strong>Data Query:</strong> " . $array_data["name"] . " - Associated Graphs" . "</td></tr><tr>");
break;
case "dqi":
fwrite($fp, "<strong>Host:</strong> " . $leaf["hostname"] . "</td></tr><tr bgcolor='#a9b7cb'><td colspan='3' class='textHeaderDark'><strong>Data Query Index:</strong> " . $array_data["name"] . " " . $snmp_index . " - Graph" . "</td></tr><tr>");
break;
}
$i = 0;
if (sizeof($graphs)) {
foreach($graphs as $graph) {
/* write the right pane syntax */
if ($leaf["tree_id"] != 0) {
/* main graph page html */
fwrite($fp, "<td align='center'><a href='" . "graph_" . $graph["local_graph_id"] . ".html'><img src='graphs/thumb_" . $graph["local_graph_id"] . ".png' border='0' alt='" . $graph["title_cache"] . "'></a></td>\n");
/* do new column processing */
$i++;
if ($i >= read_config_option("export_num_columns")) {
fwrite($fp, "</tr><tr>");
$i = 0;
}
}
}
}
/* write the html footer to the file */
fwrite($fp, HTML_FOOTER_TREE);
fclose($fp);
return $new_node;
}
function explore_tree($path, $tree_id, $parent_tree_item_id) {
/* seek graph_tree_items of the tree_id which are NOT graphs but headers */
$links = db_fetch_assoc("SELECT
id,
title,
host_id
FROM graph_tree_items
WHERE rra_id = 0
AND graph_tree_id = " . $tree_id);
$total_graphs_created = 0;
foreach($links as $link) {
/* this test gives us the parent of the curent graph_tree_item */
if (get_parent_id($link["id"], "graph_tree_items", "graph_tree_id = " . $tree_id) == $parent_tree_item_id) {
if (get_tree_item_type($link["id"]) == "host") {
if (read_config_option("export_tree_isolation") == "off") {
$total_graphs_created += export_build_tree_single(clean_up_export_name($path), clean_up_export_name(get_host_description($link["host_id"]) . "_" . $link["id"] . ".html"), $tree_id, $link["id"]);
}else{
$total_graphs_created += export_build_tree_isolated(clean_up_export_name($path), clean_up_export_name(get_host_description($link["host_id"]) . "_" . $link["id"] . ".html"), $tree_id, $link["id"]);
}
}else {
/*now, this graph_tree_item is the parent of others graph_tree_items*/
if (read_config_option("export_tree_isolation") == "off") {
$total_graphs_created += export_build_tree_single(clean_up_export_name($path), clean_up_export_name($link["title"] . "_" . $link["id"] . ".html"), $tree_id, $link["id"]);
}else{
$total_graphs_created += export_build_tree_isolated(clean_up_export_name($path), clean_up_export_name($link["title"] . "_" . $link["id"] . ".html"), $tree_id, $link["id"]);
}
}
}
}
return $total_graphs_created;
}
/* export_is_tree_allowed - determines whether the export user is allowed to view a certain graph tree
@arg $tree_id - (int) the ID of the graph tree to check permissions for
@returns - (bool) whether the current user is allowed the view the specified graph tree or not */
function export_is_tree_allowed($tree_id) {
$current_user = db_fetch_row("select policy_trees from user_auth where id=" . read_config_option("export_user_id"));
$trees = db_fetch_assoc("select
user_id
from user_auth_perms
where user_id=" . read_config_option("export_user_id") . "
and type=2
and item_id=$tree_id");
/* policy == allow AND matches = DENY */
if ((sizeof($trees) > 0) && ($current_user["policy_trees"] == "1")) {
return false;
/* policy == deny AND matches = ALLOW */
}elseif ((sizeof($trees) > 0) && ($current_user["policy_trees"] == "2")) {
return true;
/* policy == allow AND no matches = ALLOW */
}elseif ((sizeof($trees) == 0) && ($current_user["policy_trees"] == "1")) {
return true;
/* policy == deny AND no matches = DENY */
}elseif ((sizeof($trees) == 0) && ($current_user["policy_trees"] == "2")) {
return false;
}
}
function export_tree_graphs_and_graph_html($path, $tree_id) {
global $colors, $config;
include_once($config["library_path"] . "/tree.php");
include_once($config["library_path"] . "/data_query.php");
/* start the count of graphs */
$total_graphs_created = 0;
$exported_files = array();
$cacti_export_path = read_config_option("path_html_export");
/* auth check for hosts on the trees */
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
if (!export_is_tree_allowed($tree_id)) {
return 0;
}
$sql_join = "LEFT JOIN graph_local ON (graph_templates_graph.local_graph_id=graph_local.id)
LEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)
LEFT JOIN host ON (host.id=graph_local.host_id)
LEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $current_user["id"] . "))";
$sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
$sql_where = (empty($sql_where) ? "" : "AND $sql_where");
$graphs = array();
if ($tree_id == 0) {
$hosts = db_fetch_assoc("SELECT DISTINCT host_id FROM graph_tree_items");
}else{
$hosts = db_fetch_assoc("SELECT DISTINCT host_id FROM graph_tree_items WHERE graph_tree_id=" . $tree_id);
}
/* get a list of host graphs first */
if (sizeof($hosts)) {
foreach ($hosts as $host) {
$hosts_sql = "SELECT DISTINCT
graph_templates_graph.id,
graph_templates_graph.local_graph_id,
graph_templates_graph.height,
graph_templates_graph.width,
graph_templates_graph.title_cache,
graph_templates.name,
graph_local.host_id,
graph_tree_items.rra_id
FROM (graph_tree_items, graph_templates_graph)
$sql_join
WHERE ((graph_templates_graph.local_graph_id<>0)
$sql_where
AND (graph_local.host_id=" . $host["host_id"] . ")
AND (graph_templates_graph.export='on'))
ORDER BY graph_templates_graph.title_cache";
$host_graphs = db_fetch_assoc($hosts_sql);
if (sizeof($host_graphs)) {
if (sizeof($graphs)) {
$graphs = array_merge($host_graphs, $graphs);
}else{
$graphs = $host_graphs;
}
}
}
}
/* now get the list of graphs placed within the tree */
if ($tree_id == 0) {
$sql_where = "WHERE graph_templates_graph.local_graph_id!=0
$sql_where
AND graph_templates_graph.export='on'";
}else{
$sql_where = "WHERE graph_tree_items.graph_tree_id =" . $tree_id . "
$sql_where
AND graph_templates_graph.local_graph_id!=0
AND graph_templates_graph.export='on'";
}
$non_host_sql = "SELECT
graph_templates_graph.id,
graph_templates_graph.local_graph_id,
graph_templates_graph.height,
graph_templates_graph.width,
graph_templates_graph.title_cache,
graph_templates.name,
graph_local.host_id,
graph_tree_items.rra_id,
graph_tree_items.id AS gtid
FROM (graph_tree_items, graph_templates_graph)
$sql_join
$sql_where
AND graph_tree_items.local_graph_id = graph_templates_graph.local_graph_id
AND graph_templates_graph.export='on'
ORDER BY graph_templates_graph.title_cache";
$non_host_graphs = db_fetch_assoc($non_host_sql);
if (sizeof($non_host_graphs)) {
if (sizeof($graphs)) {
$graphs = array_merge($non_host_graphs, $graphs);
}else{
$graphs = $non_host_graphs;
}
}
/* open a pipe to rrdtool for writing */
$rrdtool_pipe = rrd_init();
/* for each graph... */
$i = 0;
if (sizeof($graphs) > 0) {
foreach($graphs as $graph) {
$rras = get_associated_rras($graph["local_graph_id"]);
/* settings for preview graphs */
$graph_data_array["graph_height"] = read_config_option("export_default_height");
$graph_data_array["graph_width"] = read_config_option("export_default_width");
$graph_data_array["graph_nolegend"] = true;
$graph_data_array["export"] = true;
if (read_config_option("export_tree_isolation") == "on") {
$graph_data_array["export_filename"] = "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
$export_filename = $cacti_export_path . "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
}else{
$graph_data_array["export_filename"] = "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
$export_filename = $cacti_export_path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
}
if (!array_search($export_filename, $exported_files)) {
/* add the graph to the exported list */
array_push($exported_files, $export_filename);
export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
/* generate the graph */
@rrdtool_function_graph($graph["local_graph_id"], $graph["rra_id"], $graph_data_array, $rrdtool_pipe);
$total_graphs_created++;
/* generate html files for each graph */
if (read_config_option("export_tree_isolation") == "on") {
export_log("Creating File '" . $cacti_export_path . "/" . $path ."/graph_" . $graph["local_graph_id"] . ".html'");
$fp_graph_index = fopen($cacti_export_path . "/" . $path ."/graph_" . $graph["local_graph_id"] . ".html", "w");
}else{
export_log("Creating File '" . $cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html'");
$fp_graph_index = fopen($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
}
/* assign the node id */
$node = '';
fwrite($fp_graph_index, HTML_HEADER_TREE);
/* write the code for the tree at the left */
draw_html_left_tree($fp_graph_index, $tree_id, $node);
fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE_TREE);
fwrite($fp_graph_index, "<strong>Graph - " . $graph["title_cache"] . "</strong></td></tr>");
fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO_TREE);
fwrite($fp_graph_index, "<td>");
/* reset vars for actual graph image creation */
reset($rras);
unset($graph_data_array);
/* generate graphs for each rra */
foreach ($rras as $rra) {
$graph_data_array["export"] = true;
if (read_config_option("export_tree_isolation") == "on") {
$graph_data_array["export_filename"] = "/" . $path . "/graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png";
}else{
$graph_data_array["export_filename"] = "/graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png";
}
export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
@rrdtool_function_graph($graph["local_graph_id"], $rra["id"], $graph_data_array, $rrdtool_pipe);
$total_graphs_created++;
/* write image related html */
if (read_config_option("export_tree_isolation") == "off") {
fwrite($fp_graph_index, "<div align=center><img src='graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png' border=0></div>\n
<div align=center><strong>".$rra["name"]."</strong></div><br>");
}else{
fwrite($fp_graph_index, "<div align=center><img src='" . "graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png' border=0></div>\n
<div align=center><strong>".$rra["name"]."</strong></div><br>");
}
}
fwrite($fp_graph_index, "</td></tr></table></td></tr></table>");
fwrite($fp_graph_index, HTML_FOOTER_TREE);
fclose($fp_graph_index);
}
}
}
/* close the rrdtool pipe */
rrd_close($rrdtool_pipe);
return $total_graphs_created;
}
function draw_html_left_tree($fp, $tree_id, $node) {
/* create the treeview representation for the html data */
grow_dhtml_trees_export($fp, $tree_id, $node);
fwrite($fp,"</td></tr></table></td>\n");
fwrite($fp,"<td valign='top' style='padding: 5px; border-right: #aaaaaa 1px solid;'>\n");
fwrite($fp,"<div id='main' style='position:static;'>\n");
}
function grow_dhtml_trees_export($fp, $tree_id, $node) {
global $config, $dhtml_trees;
include_once($config["library_path"] . "/tree.php");
include_once($config["library_path"] . "/data_query.php");
fwrite($fp, "\t<div id=\"jstree\">\n");
if (read_config_option("export_tree_isolation") == "off") {
$dhtml_tree_base = 0;
}else{
$dhtml_tree_base = $tree_id;
}
if (!isset($dhtml_trees[$dhtml_tree_base])) {
$dhtml_tree = create_dhtml_tree_export($dhtml_tree_base);
$dhtml_trees[$dhtml_tree_base] = $dhtml_tree;
}else{
$dhtml_tree = $dhtml_trees[$dhtml_tree_base];
}
foreach($dhtml_tree as $key => $item){
if ($key > 1) {
fwrite($fp,$item);
}
}
fwrite($fp, "</div>\n");
fwrite($fp, "<script type=\"text/javascript\">\n");
fwrite($fp, "
//var node='$node';
var node='';
if (node == '') {
node = basename(document.location.pathname, '.html');
}
function basename(path, suffix) {
var b = path;
var lastChar = b.charAt(b.length - 1);
if (lastChar === '/' || lastChar === '\\\\') {
b = b.slice(0, -1);
}
b = b.replace(/^.*[\\/\\\\]/g, '');
if (typeof suffix === 'string' && b.substr(b.length - suffix.length) == suffix) {
b = b.substr(0, b.length - suffix.length);
}
return b;
}
$(function () {
$('#navigation').css('height', ($(window).height()-80)+'px');
$(window).resize(function() {
$('#navigation').css('height', ($(window).height()-80)+'px');
});
$('#jstree')
.on('ready.jstree', function(e, data) {
if (node!='') {
$('#jstree').jstree('set_theme', 'default', './js/themes/default/style.css');
if (node.substring(0,6) != 'graph_') {
$('#jstree').jstree('deselect_all', node);
$('#jstree').jstree('select_node', node);
$('#jstree').jstree('save_state');
}
}
})
.on('set_state.jstree', function(e, data) {
if (node.substring(0,6) != 'graph_') {
$('#jstree').jstree('deselect_all', node);
$('#jstree').jstree('select_node', node);
$('#jstree').jstree('save_state');
}
})
.on('activate_node.jstree', function(e, data) {
if (data.node.id) {
document.location = $('#'+data.node.id+' > a').attr('href');
}
})
.jstree({
'core' : {
'animation' : 0
},
'themes' : {
'name' : 'default',
'responsive' : true,
'url' : true,
'dots' : true
},
'plugins' : [ 'state', 'wholerow' ]
});
});\n");
fwrite($fp, "\t\t</script>\n");
fwrite($fp, "\t</div>\n");
}
/* get_graph_tree_array_export - returns a list of graph trees taking permissions into account if
necessary
@arg $return_sql - (bool) Whether to return the SQL to create the dropdown rather than an array
@arg $force_refresh - (bool) Force the refresh of the array from the database
@returns - (array) an array containing a list of graph trees */
function get_graph_tree_array_export($return_sql = false, $force_refresh = false) {
global $config;
/* set the tree update time if not already set */
if (!isset($config["config_options_array"]["tree_update_time"])) {
$config["config_options_array"]["tree_update_time"] = time();
}
/* build tree array */
if (!isset($config["config_options_array"]["tree_array"]) || ($force_refresh) ||
(($config["config_options_array"]["tree_update_time"] + read_graph_config_option("page_refresh")) < time())) {
if (read_config_option("auth_method") != 0) {
$current_user = db_fetch_row("SELECT id, policy_trees FROM user_auth WHERE id=" . read_config_option("export_user_id"));
if ($current_user["policy_trees"] == "1") {
$sql_where = "WHERE user_auth_perms.user_id IS NULL";
}elseif ($current_user["policy_trees"] == "2") {
$sql_where = "WHERE user_auth_perms.user_id IS NOT NULL";
}
$sql = "SELECT
graph_tree.id,
graph_tree.name,
user_auth_perms.user_id
FROM graph_tree
LEFT JOIN user_auth_perms ON (graph_tree.id=user_auth_perms.item_id AND user_auth_perms.type=2 AND user_auth_perms.user_id=" . $current_user["id"] . ")
$sql_where
ORDER BY graph_tree.name";
}else{
$sql = "SELECT * FROM graph_tree ORDER BY name";
}
$config["config_options_array"]["tree_array"] = $sql;
$config["config_options_array"]["tree_update_time"] = time();
} else {
$sql = $config["config_options_array"]["tree_array"];
}
if ($return_sql == true) {
return $sql;
}else{
return db_fetch_assoc($sql);
}
}
function create_dhtml_tree_export($tree_id) {
/* record start time */
list($micro,$seconds) = explode(" ", microtime());
$start = $seconds + $micro;
$search_key = "";
$dhtml_tree = array();
$dhtml_tree[0] = $start;
$dhtml_tree[1] = read_graph_config_option("expand_hosts");
$i = 1;
$tree_list = get_graph_tree_array_export();
/* auth check for hosts on the trees */
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
$sql_join = "LEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $current_user["id"] . "))";
if ($current_user["policy_hosts"] == "1") {
$sql_where = "AND !(user_auth_perms.user_id IS NOT NULL AND graph_tree_items.host_id>0)";
}elseif ($current_user["policy_hosts"] == "2") {
$sql_where = "AND !(user_auth_perms.user_id IS NULL AND graph_tree_items.host_id>0)";
}
if (sizeof($tree_list) > 0) {
foreach ($tree_list as $tree) {
if (((read_config_option("export_tree_isolation") == "on") && ($tree_id == $tree["id"])) ||
(read_config_option("export_tree_isolation") == "off")) {
$hier_sql = "SELECT DISTINCT
graph_tree_items.id,
graph_tree_items.title,
graph_tree_items.order_key,
graph_tree_items.host_id,
graph_tree_items.host_grouping_type,
host.description as hostname
FROM (graph_tree_items, graph_templates_graph)
LEFT JOIN host ON (host.id=graph_tree_items.host_id)
LEFT JOIN graph_templates ON (graph_templates_graph.graph_template_id=graph_templates.id)
$sql_join
WHERE graph_tree_items.graph_tree_id=" . $tree["id"] . "
$sql_where
AND graph_tree_items.local_graph_id = 0
ORDER BY graph_tree_items.order_key";
$hierarchy = db_fetch_assoc($hier_sql);
$dhtml_tree_id = 0;
if (sizeof($hierarchy) > 0) {
$last_tier = 1;
$openli = false;
$lasthost = false;
$opentree = false;
foreach ($hierarchy as $leaf) {
if ($dhtml_tree_id <> $tree["id"]) {
if ($opentree) {
$i++;
$dhtml_tree[$i] = "\t\t\t</ul>\n\t\t</li>\n\t</ul>\n";
}
$i++;
$clean_id = clean_up_export_name(get_tree_name($tree["id"]) . "_" . $tree['id']);
$dhtml_tree[$i] = "\t<ul>\n\t\t<li id='$clean_id'><a href='" . $clean_id . ".html'>" . get_tree_name($tree["id"]) . "</a>\n\t\t\t<ul>\n";
$opentree = true;
}
$dhtml_tree_id = $tree["id"];
$tier = tree_tier($leaf["order_key"]);
if ($leaf["host_id"] > 0) { //It's a host
if ($tier > $last_tier) {
$i++;
$dhtml_tree[$i] = "\t\t\t<ul>\n";
} elseif ($tier < $last_tier) {
if (!$lasthost) {
$i++;
$dhtml_tree[$i] = "\t\t\t\t</li>\n";
}
for ($x = $tier; $x < $last_tier; $x++) {
$i++;
$dhtml_tree[$i] = "\t\t\t</ul>\n\t\t\t\t</li>\n";
$openli = false;
}
} elseif ($openli && !$lasthost) {
$i++;
$dhtml_tree[$i] = "\t\t\t\t</li>\n";
$openli = false;
}
$last_tier = $tier;
$lasthost = true;
$i++;
$clean_id = clean_up_export_name($leaf["hostname"] . "_" . $leaf["id"]);
$dhtml_tree[$i] = "\t\t\t\t<li id='$clean_id' data-jstree='{ \"icon\" : \"./server.png\" }'><a href=\"" . $clean_id . ".html\">Host: " . htmlspecialchars($leaf["hostname"]) . "</a>\n";
if (read_config_option("export_tree_expand_hosts") == "on") {
$i++;
$dhtml_tree[$i] = "\t\t\t\t\t<ul>\n";
if ($leaf["host_grouping_type"] == HOST_GROUPING_GRAPH_TEMPLATE) {
$graph_templates = db_fetch_assoc("SELECT
graph_templates.id,
graph_templates.name,
graph_templates_graph.local_graph_id,
graph_templates_graph.title_cache
FROM (graph_local,graph_templates,graph_templates_graph)
WHERE graph_local.id=graph_templates_graph.local_graph_id
AND graph_templates_graph.graph_template_id=graph_templates.id
AND graph_local.host_id=" . $leaf["host_id"] . "
AND graph_templates_graph.export='on'
GROUP BY graph_templates.id
ORDER BY graph_templates.name");
if (sizeof($graph_templates) > 0) {
foreach ($graph_templates as $graph_template) {
$i++;
$clean_id = clean_up_export_name($leaf["hostname"] . "_gt_" . $leaf["id"] . "_" . $graph_template["id"]);
$dhtml_tree[$i] = "\t\t\t\t\t\t<li id='" . $clean_id . "' data-jstree='{ \"icon\" : \"./server_chart.png\" }'><a href=\"" . $clean_id . ".html\">" . htmlspecialchars($graph_template["name"]) . "</a></li>\n";
}
}
}else if ($leaf["host_grouping_type"] == HOST_GROUPING_DATA_QUERY_INDEX) {
$data_queries = db_fetch_assoc("SELECT
snmp_query.id,
snmp_query.name
FROM (graph_local,snmp_query)
WHERE graph_local.snmp_query_id=snmp_query.id
AND graph_local.host_id=" . $leaf["host_id"] . "
GROUP BY snmp_query.id
ORDER BY snmp_query.name");
array_push($data_queries, array(
"id" => "0",
"name" => "Non Query Based"
));
if (sizeof($data_queries) > 0) {
foreach ($data_queries as $data_query) {
$i++;
$clean_id = clean_up_export_name($leaf["hostname"] . "_dq_" . $leaf["title"] . "_" . $leaf["id"] . "_" . $data_query["id"]);
if ($data_query['name'] != 'Non Query Based') {
$dhtml_tree[$i] = "\t\t\t\t\t\t<li id='" . $clean_id . "' data-jstree='{ \"icon\" : \"./server_dataquery.png\" }'><a href=\"" . $clean_id . ".html\">" . htmlspecialchars($data_query["name"]) . "</a>\n";
}else{
$dhtml_tree[$i] = "\t\t\t\t\t\t<li id='" . $clean_id . "' data-jstree='{ \"icon\" : \"./server_chart.png\" }'><a href=\"" . $clean_id . ".html\">" . htmlspecialchars($data_query["name"]) . "</a>\n";
}
/* fetch a list of field names that are sorted by the preferred sort field */
$sort_field_data = get_formatted_data_query_indexes($leaf["host_id"], $data_query["id"]);
if ($data_query["id"] > 0) {
$i++;
$dhtml_tree[$i] = "\t\t\t\t\t\t\t<ul>\n";
while (list($snmp_index, $sort_field_value) = each($sort_field_data)) {
$i++;
$clean_id = clean_up_export_name($leaf["hostname"] . "_dqi_" . $leaf["id"] . "_" . $data_query["id"] . "_" . $snmp_index);
$dhtml_tree[$i] = "\t\t\t\t\t\t\t\t<li id='" . $clean_id . "' data-jstree='{ \"icon\" : \"./server_chart_curve.png\" }'><a href=\"" . $clean_id . ".html\">" . htmlspecialchars($sort_field_value) . "</a></li>\n";
}
$i++;
$dhtml_tree[$i] = "\t\t\t\t\t\t\t</ul>\n";
}
$i++;
$dhtml_tree[$i] = "\t\t\t\t\t\t</li>\n";
}
}
}
$i++;
$dhtml_tree[$i] = "\t\t\t\t\t</ul>\n";
}
$i++;
$dhtml_tree[$i] = "\t\t\t\t</li>\n";
}else { //It's not a host
if ($tier > $last_tier) {
$i++;
$dhtml_tree[$i] = "\t\t\t<ul>\n";
} elseif ($tier < $last_tier) {
if (!$lasthost) {
$i++;
$dhtml_tree[$i] = "</li>\n";
}
for ($x = $tier; $x < $last_tier; $x++) {
$i++;
$dhtml_tree[$i] = "\t\t\t\t</ul>\n\t\t\t\t</li>\n";
$openli = false;
}
} elseif ($openli && !$lasthost) {
$i++;
$dhtml_tree[$i] = "</li>\n";
$openli = false;
}
$last_tier = $tier;
$i++;
$clean_id = clean_up_export_name(get_tree_name($tree["id"]) . "_" . $leaf["title"] . "_" . $leaf["id"]);
$dhtml_tree[$i] = "\t\t\t\t<li id=\"" . $clean_id . "\"><a href=\"" . $clean_id . ".html\">" . htmlspecialchars($leaf["title"]) . "</a>\n";
$openli = true;
$lasthost = false;
}
}
for ($x = $last_tier; $x > 1; $x--) {
$i++;
$dhtml_tree[$i] = "\t\t\t\t\t</ul>\n\t\t\t\t</li>\n";
}
$i++;
$dhtml_tree[$i] = "\t\t\t</ul>\n\t\t</li>\n\t</ul>\n";
}else{
if ($dhtml_tree_id <> $tree["id"]) {
$i++;
$clean_id = clean_up_export_name(get_tree_name($tree["id"]) . "_" . $tree['id']);
$dhtml_tree[$i] = "\t<ul>\n\t\t<li id=\"" . $clean_id . "\"><a href=\"" . $clean_id . ".html\">" . get_tree_name($tree["id"]) . "</a></li>\n\t</ul>";
}
}
}
}
}
return $dhtml_tree;
}
/* create_export_directory_structure - builds the export directory strucutre and copies
graphics and treeview scripts to those directories.
@arg $cacti_root_path - the directory where Cacti is installed
$dir - the export directory where graphs will either be staged or located.
*/
function create_export_directory_structure($cacti_root_path, $dir) {
/* create the treeview sub-directory */
if (!is_dir("$dir/js")) {
if (!mkdir("$dir/js", 0755, true)) {
export_fatal("Create directory '" . $dir . "/js' failed. Can not continue");
}
if (!mkdir("$dir/js/themes/default", 0755, true)) {
export_fatal("Create directory '" . $dir . "/js/themes/default' failed. Can not continue");
}
if (!mkdir("$dir/js/images", 0755, true)) {
export_fatal("Create directory '" . $dir . "/js/images' failed. Can not continue");
}
}
/* create the graphs sub-directory */
if (!is_dir("$dir/graphs")) {
if (!mkdir("$dir/graphs", 0755, true)) {
export_fatal("Create directory '" . $dir . "/graphs' failed. Can not continue");
}
}
/* css */
copy("$cacti_root_path/include/main.css", "$dir/main.css");
/* images for html */
copy("$cacti_root_path/images/tab_cacti.gif", "$dir/tab_cacti.gif");
copy("$cacti_root_path/images/cacti_backdrop.gif", "$dir/cacti_backdrop.gif");
copy("$cacti_root_path/images/transparent_line.gif", "$dir/transparent_line.gif");
copy("$cacti_root_path/images/shadow.gif", "$dir/shadow.gif");
copy("$cacti_root_path/images/shadow_gray.gif", "$dir/shadow_gray.gif");
$files = array("server_chart_curve.png", "server_chart.png", "server_dataquery.png", "server.png");
foreach($files as $file) {
copy("$cacti_root_path/images/$file", "$dir/$file");
}
/* jstree theme files */
$files = array("32px.png", "40px.png", "style.css", "style.min.css", "throbber.gif");
foreach($files as $file) {
copy("$cacti_root_path/include/js/themes/default/$file", "$dir/js/themes/default/$file");
}
/* jquery-ui theme files */
$files = array(
"ui-bg_diagonals-thick_18_b81900_40x40.png",
"ui-bg_diagonals-thick_20_666666_40x40.png",
"ui-bg_flat_10_000000_40x100.png",
"ui-bg_glass_100_f6f6f6_1x400.png",
"ui-bg_glass_100_fdf5ce_1x400.png",
"ui-bg_glass_65_ffffff_1x400.png",
"ui-bg_gloss-wave_35_f6a828_500x100.png",
"ui-bg_highlight-soft_100_eeeeee_1x100.png",
"ui-bg_highlight-soft_75_ffe45c_1x100.png",
"ui-icons_222222_256x240.png",
"ui-icons_228ef1_256x240.png",
"ui-icons_ef8c08_256x240.png",
"ui-icons_ffd27a_256x240.png",
"ui-icons_ffffff_256x240.png"
);
foreach($files as $file) {
copy("$cacti_root_path/include/js/images/$file", "$dir/js/images/$file");
}
/* java scripts for the tree */
copy("$cacti_root_path/include/js/jquery.js", "$dir/js/jquery.js");
copy("$cacti_root_path/include/js/jquery-ui.js", "$dir/js/jquery-ui.js");
copy("$cacti_root_path/include/js/jstree.js", "$dir/js/jstree.js");
copy("$cacti_root_path/include/js/jquery.cookie.js", "$dir/js/jquery.cookie.js");
copy("$cacti_root_path/include/js/jquery-ui.css", "$dir/js/jquery-ui.css");
}
function get_host_description($host_id) {
$host = db_fetch_row("SELECT description FROM host WHERE id='".$host_id."'");
return $host["description"];
}
function get_host_id($tree_item_id) {
$graph_tree_item=db_fetch_row("SELECT host_id FROM graph_tree_items WHERE id='".$tree_item_id."'");
return $graph_tree_item["host_id"];
}
function get_tree_name($tree_id) {
$graph_tree=db_fetch_row("SELECT id, name FROM graph_tree WHERE id='".$tree_id."'");
return $graph_tree["name"];
}
function get_tree_item_title($tree_item_id) {
if (get_tree_item_type($tree_item_id) == "host") {
$tree_item=db_fetch_row("SELECT host_id FROM graph_tree_items WHERE id='".$tree_item_id."'");
return get_host_description($tree_item["host_id"]);
}else{
$tree_item=db_fetch_row("SELECT title FROM graph_tree_items WHERE id='".$tree_item_id."'");
return $tree_item["title"];
}
}
/* clean_up_export_name - runs a string through a series of regular expressions designed to
eliminate "bad" characters
@arg $string - the string to modify/clean
@returns - the modified string */
function clean_up_export_name($string) {
$string = preg_replace("/[\s\ ]+/", "_", $string);
$string = preg_replace("/[^a-zA-Z0-9_.]+/", "", $string);
$string = preg_replace("/_{2,}/", "_", $string);
return $string;
}
/* $path to the directory to delete or clean */
/* $deldir (optionnal parameter, true as default) delete the diretory (true) or just clean it (false) */
function del_directory($path, $deldir = true) {
/* check if the directory name have a "/" at the end, add if not */
if ($path[strlen($path)-1] != "/") {
$path .= "/";
}
/* cascade through the directory structure(s) until they are all delected */
if (is_dir($path)) {
$d = opendir($path);
while ($f = readdir($d)) {
if ($f != "." && $f != "..") {
$rf = $path . $f;
/* if it is a directory, recursive call to the function */
if (is_dir($rf)) {
del_directory($rf);
}else if (is_file($rf) && is_writable($rf)) {
unlink($rf);
}
}
}
closedir($d);
/* if $deldir is true, remove the directory */
if ($deldir && is_writable($path)) {
rmdir($path);
}
}
}
function check_remove($filename) {
if (file_exists($filename) && is_writable($filename)) {
unlink($filename);
}
}
define("HTML_HEADER_TREE",
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='edge'>
<title>Cacti</title>
<link rel='stylesheet' href='main.css' rel='stylesheet'>
<link rel='stylesheet' href='./js/jquery-ui.css'>
<link rel='stylesheet' href='./js/themes/default/style.css'>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
<meta http-equiv=Pragma content=no-cache>
<meta http-equiv=cache-control content=no-cache>
<script type='text/javascript' src='./js/jquery.js'></script>
<script type='text/jsvascript' src='./js/jquery-ui.js'></script>
<script type='text/javascript' src='./js/jstree.js'></script>
<script type='text/javascript' src='./js/jquery.cookie.js'></script>
</head>
<body>
<table style='width:100%;height:100%;' cellspacing='0' cellpadding='0'>
<tr style='height:37px;' bgcolor='#a9a9a9'>
<td colspan='2' valign='bottom' nowrap>
<table width='100%' cellspacing='0' cellpadding='0'>
<tr>
<td nowrap>
<a href='http://www.cacti.net/'><img src='tab_cacti.gif' alt='Cacti - http://www.cacti.net/' align='middle' border='0'></a>
</td>
<td align='right'>
<img src='cacti_backdrop.gif' align='middle'>
</td>
</tr>
</table>
</td>
</tr>
<tr style='height:2px;' colspan='2' bgcolor='#183c8f'>
<td colspan='2'>
<img src='transparent_line.gif' style='width:170px;height:2px;' border='0'><br>
</td>
</tr>
<tr style='height:5px;' bgcolor='#e9e9e9'>
<td colspan='2'>
<table width='100%'>
<tr>
<td>
Exported Graphs
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor='#efefef' colspan='1' style='height:8px;background-image: url(shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;'>
<img src='transparent_line.gif' width='200' style='height:2px;' border='0'><br>
</td>
<td bgcolor='#ffffff' colspan='1' style='height:8px;background-image: url(shadow.gif); background-repeat: repeat-x;'>
</td>
</tr>
<tr>
<td valign='top' style='padding: 5px; border-right: #aaaaaa 1px solid;' bgcolor='#efefef' width='200'>
<table width='100%' border=0 cellpadding=0 cellspacing=0>
<tr>
<td id='navigation' valign='top' style='padding: 5px; border-right: #aaaaaa 1px solid;background-repeat:repeat-y;background-color:#efefef;' bgcolor='#efefef' width='200' class='noprint'>\n"
);
define("HTML_GRAPH_HEADER_ONE_TREE", "
<table width='100%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center' cellpadding='3'>
<tr bgcolor='#6d88ad'>
<td width='390' colspan='3' class='textHeaderDark'>");
define("HTML_GRAPH_HEADER_TWO_TREE", "
<tr>"
);
define("HTML_GRAPH_HEADER_ICE_TREE", "</td></tr></table><br><br> <br>
</td>
</tr>
</table>\n");
define("HTML_GRAPH_FOOTER_TREE", "
</tr></table>\n"
);
define("HTML_FOOTER_TREE", "
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>"
);
/* HTML header for the Classic Presentation */
define("HTML_HEADER_CLASSIC", "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<title>cacti</title>
<link href='main.css' rel='stylesheet'>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
<meta http-equiv=refresh content='300'; url='index.html'>
<meta http-equiv=Pragma content=no-cache>
<meta http-equiv=cache-control content=no-cache>
</head>
<body>
<table width='100%' cellspacing='0' cellpadding='0'>
<tr style='height:37px;' bgcolor='#a9a9a9'>
<td valign='bottom' colspan='3' nowrap>
<table width='100%' cellspacing='0' cellpadding='0'>
<tr>
<td valign='bottom'>
<a href='http://www.cacti.net/'><img src='tab_cacti.gif' alt='Cacti - http://www.cacti.net/' align='middle' border='0'></a>
</td>
<td align='right'>
<img src='cacti_backdrop.gif' align='middle'>
</td>
</tr>
</table>
</td>
</tr>\n
<tr style='height:2px;' bgcolor='#183c8f'>
<td colspan='3'>
<img src='transparent_line.gif' style='width:170px;height:2px;' border='0'><br>
</td>
</tr>\n
<tr style='height:5px;' bgcolor='#e9e9e9'>
<td colspan='3'>
<table width='100%'>
<tr>
<td>
Exported Graphs
</td>
</tr>
</table>
</td>
</tr>\n
<tr>
<td colspan='3' style='height:8px;background-image: url(shadow.gif); background-repeat: repeat-x;' bgcolor='#ffffff'>
</td>
</tr>\n
</table>
<br>"
);
/* Traditional Graph Export Representation Graph Headers */
define("HTML_GRAPH_HEADER_ONE_CLASSIC", "
<table width='100%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center'>
<tr>
<td class='textSubHeaderDark' colspan='" . read_config_option("export_num_columns") . "'>
<table width='100%' cellspacing='0' cellpadding='3' border='0'>
<tr>
<td align='center' class='textHeaderDark'>"
);
define("HTML_GRAPH_HEADER_TWO_CLASSIC", "
</tr>
</table>
</td>
</tr>
<tr>"
);
define("HTML_GRAPH_FOOTER_CLASSIC", "
</tr></table>\n
<br><br>"
);
define("HTML_FOOTER_CLASSIC", "
<br>
</body>
</html>"
);
?>
| howardjones/cacti088c | lib/graph_export.php | PHP | gpl-2.0 | 76,174 | [
30522,
1026,
1029,
25718,
1013,
1008,
1009,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
manage
======
manage organisational resources
Developers :
Manmay Mohanty
Pragati Prusty
| Manmay/manage | README.md | Markdown | apache-2.0 | 91 | [
30522,
6133,
1027,
1027,
1027,
1027,
1027,
1027,
6133,
5502,
2389,
4219,
9797,
1024,
2158,
27871,
18529,
3723,
10975,
16098,
3775,
10975,
19966,
2100,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 print render($content); ?>
<?php if (isset($content['field_figurelabel_ref'])): ?>
<?php print render($content['field_figurelabel_ref'][0]); ?>
<?php endif; ?> | bterp-web/elmsln | core/dslmcode/shared/drupal-7.x/themes/elmsln_contrib/foundation_access/templates/node/elmsmedia-image/node--inherit--elmsmedia-image--accessible-fallback.tpl.php | PHP | gpl-3.0 | 167 | [
30522,
1026,
1029,
25718,
6140,
17552,
1006,
1002,
4180,
1007,
1025,
1029,
1028,
1026,
1029,
25718,
2065,
1006,
26354,
3388,
1006,
1002,
4180,
1031,
1005,
2492,
1035,
3275,
20470,
2884,
1035,
25416,
1005,
1033,
1007,
1007,
1024,
1029,
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... |
---
layout: page
title: Guardian Quality Technologies Award Ceremony
date: 2016-05-24
author: Peter Simmons
tags: weekly links, java
status: published
summary: Sed consequat quis sapien eget malesuada. Morbi semper tempor nunc.
banner: images/banner/meeting-01.jpg
booking:
startDate: 12/25/2019
endDate: 12/28/2019
ctyhocn: MSLOHHX
groupCode: GQTAC
published: true
---
Aliquam bibendum sit amet nibh et feugiat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam feugiat dictum sapien, eget vestibulum mauris tincidunt ut. Quisque suscipit diam vel aliquet suscipit. Donec at sollicitudin orci. Integer est nulla, elementum quis viverra non, semper nec nibh. Mauris pellentesque ligula ac nisl mollis, sit amet semper sapien luctus. Aenean dignissim in lacus sed convallis. Quisque ac dignissim tellus, vel blandit diam. Maecenas consequat ligula ut purus semper, a condimentum tellus volutpat.
Aliquam quis lorem ante. Quisque tempus pretium urna. Proin justo nisi, maximus et velit vitae, dictum pretium dui. Ut ut luctus magna. Phasellus lectus justo, varius sed ultrices nec, malesuada id massa. Mauris nulla justo, finibus commodo lobortis sed, pulvinar id ipsum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla fermentum lobortis arcu, id elementum diam tempor vitae. Aliquam erat volutpat. Nulla lacinia metus sit amet cursus lacinia.
* Suspendisse congue velit sed varius malesuada
* Nulla et ante luctus, sollicitudin justo ullamcorper, aliquet nulla
* Proin tincidunt sem quis venenatis cursus
* Pellentesque a ipsum tincidunt nisi aliquet varius in sit amet metus
* Vestibulum eu ante sit amet lectus vestibulum pretium ut et libero.
Nullam molestie felis quis nunc tincidunt, at vestibulum enim tempus. Vivamus imperdiet nec est non tempor. Curabitur at scelerisque leo. Morbi tempor arcu at ex finibus pulvinar. Curabitur ullamcorper tincidunt hendrerit. Donec quam nibh, viverra non feugiat sit amet, dictum ac libero. Ut dignissim neque sit amet tortor lobortis efficitur. Curabitur id consectetur turpis, quis facilisis augue. Interdum et malesuada fames ac ante ipsum primis in faucibus. Maecenas sit amet rhoncus erat, nec pulvinar metus.
| KlishGroup/prose-pogs | pogs/M/MSLOHHX/GQTAC/index.md | Markdown | mit | 2,265 | [
30522,
1011,
1011,
1011,
9621,
1024,
3931,
2516,
1024,
6697,
3737,
6786,
2400,
5103,
3058,
1024,
2355,
1011,
5709,
1011,
2484,
3166,
1024,
2848,
13672,
22073,
1024,
4882,
6971,
1010,
9262,
3570,
1024,
2405,
12654,
1024,
7367,
2094,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
--
-- Copyright 2015-2016 USEF Foundation
--
-- 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.
--
INSERT INTO DISTRIBUTION_SYSTEM_OPERATOR ( ID, DOMAIN) VALUES (1, 'usef-example.com');
INSERT INTO DISTRIBUTION_SYSTEM_OPERATOR ( ID, DOMAIN) VALUES (2, 'usef-dummy.com');
INSERT INTO AGGREGATOR (ID, DOMAIN) VALUES (1, 'tesla.com');
INSERT INTO AGGREGATOR (ID, DOMAIN) VALUES (2, 'mijn-groene-energie.com');
INSERT INTO AGGREGATOR (ID, DOMAIN) VALUES (3, 'ik-ben-een-aggregator.com');
INSERT INTO BALANCE_RESPONSIBLE_PARTY (ID, DOMAIN) VALUES (1, 'brp.test.com');
INSERT INTO BALANCE_RESPONSIBLE_PARTY (ID, DOMAIN) VALUES (2, 'brp.abcd.com');
INSERT INTO METER_DATA_COMPANY (ID, DOMAIN) VALUES (1, 'mdc.test.com');
INSERT INTO CONGESTION_POINT (ID, ENTITY_ADDRESS, DISTRIBUTION_SYSTEM_OPERATOR_ID) VALUES (1, 'ea1.1992-01.com.example:gridpoint.4f76ff19-a53b-49f5-84e6', 1);
INSERT INTO CONGESTION_POINT (ID, ENTITY_ADDRESS, DISTRIBUTION_SYSTEM_OPERATOR_ID) VALUES (2, 'ea1.1992-02.com.otherexample:gridpoint.4f76ff19-a53b-49f5-99e9', 2);
INSERT INTO CONGESTION_POINT (ID, ENTITY_ADDRESS, DISTRIBUTION_SYSTEM_OPERATOR_ID) VALUES (3, 'ea1.1992-03.com.otherexample:gridpoint.4f76ff19-a53b-49f5-99e9', 1);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, CONGESTION_POINT_ID, AGGREGATOR_ID, BALANCE_RESPONSIBLE_PARTY_ID) VALUES (1, 'ean.871685900012636543', 1, 1, 1);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, CONGESTION_POINT_ID, AGGREGATOR_ID) VALUES (2, 'ean.121685900012636999', 1, 1);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, CONGESTION_POINT_ID, AGGREGATOR_ID) VALUES (3, 'ean.789685900012636123', 1, 2);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, CONGESTION_POINT_ID, AGGREGATOR_ID) VALUES (4, 'ean.673685900012637348', NULL, 2);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, CONGESTION_POINT_ID, AGGREGATOR_ID) VALUES (5, 'ean.673685923012637348', 3, 3);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, AGGREGATOR_ID) VALUES (6, 'ean.789685900012636129', 3);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, AGGREGATOR_ID) VALUES (7, 'ean.673685900012637341', 3);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, CONGESTION_POINT_ID) VALUES (8, 'ean.789685901012636129', 1);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, CONGESTION_POINT_ID) VALUES (9, 'ean.673685902012637341', 1);
INSERT INTO CONNECTION (ID, ENTITY_ADDRESS, CONGESTION_POINT_ID, AGGREGATOR_ID) VALUES (10, 'ean.771685900112636461', 2, 1);
| USEF-Foundation/ri.usef.energy | usef-build/usef-workflow/usef-cro/src/test/resources/repository_test_data.sql | SQL | apache-2.0 | 2,901 | [
30522,
1011,
1011,
1011,
1011,
9385,
2325,
1011,
2355,
2224,
2546,
3192,
1011,
1011,
1011,
1011,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1011,
1011,
2017,
2089,
2025,
2224,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* qrest
*
* Copyright (C) 2008-2012 - Frédéric CORNU
*
* 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/>.
*/
#ifndef QT_NO_DEBUG
#include <QDebug>
#endif
#include "progressPie.h"
#include "../../../constants.h"
#include <QPaintEvent>
#include <QPainter>
#include <QLineEdit>
////////////////////////////////////////////////////////////////////////////
//
// INIT
//
////////////////////////////////////////////////////////////////////////////
ProgressPie::ProgressPie(QWidget* parent) :
QWidget(parent),
_value(Constants::PROGRESSPIE_DEFAULT_VALUE),
_pRedBrush(new QBrush(Qt::red)),
_pGreenBrush(new QBrush(Qt::darkGreen)) {
/*
* we want this widget to be enclosed within a square that has the same
* height as a default QLineEdit.
*/
QLineEdit usedForSizeHintHeight;
int size = usedForSizeHintHeight.sizeHint().height();
setFixedSize(size, size);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
}
ProgressPie::~ProgressPie() {
delete _pGreenBrush;
delete _pRedBrush;
}
////////////////////////////////////////////////////////////////////////////
//
// OVERRIDES
//
////////////////////////////////////////////////////////////////////////////
void ProgressPie::paintEvent(QPaintEvent* event) {
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.setRenderHint(QPainter::Antialiasing, true);
/*
* Qt draws angles with 1/16 degree precision.
*/
static const int STEPS = 16;
/*
* pie is drawn starting from top, so we set startAngle at -270°
*/
static const int TOP = -270* STEPS ;
/*
* how many degrees in a full circle ?
*/
static const int FULL_CIRCLE = 360;
/*
* draw red circle
*/
painter.setBrush(*_pRedBrush);
painter.drawEllipse(this->visibleRegion().boundingRect());
/*
* draw green pie
*/
painter.setBrush(*_pGreenBrush);
painter.drawPie(this->visibleRegion().boundingRect(), TOP,
static_cast<int> (-FULL_CIRCLE * _value * STEPS));
event->accept();
}
////////////////////////////////////////////////////////////////////////////
//
// SLOTS
//
////////////////////////////////////////////////////////////////////////////
void ProgressPie::setValue(const double value) {
_value = value;
repaint();
}
| deufrai/qrest_deb_packaging | src/gui/widgets/custom/progressPie.cpp | C++ | gpl-3.0 | 3,060 | [
30522,
1013,
1008,
1008,
1053,
28533,
1008,
1008,
9385,
1006,
1039,
1007,
2263,
1011,
2262,
1011,
15296,
9781,
2226,
1008,
1008,
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... |
package org.hl7.v3;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
/**
* <p>EpiduralRouteのJavaクラス。
*
* <p>次のスキーマ・フラグメントは、このクラス内に含まれる予期されるコンテンツを指定します。
* <p>
* <pre>
* <simpleType name="EpiduralRoute">
* <restriction base="{urn:hl7-org:v3}cs">
* <enumeration value="EPI"/>
* <enumeration value="EPIDURINJ"/>
* <enumeration value="EPIINJ"/>
* <enumeration value="EPINJSP"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "EpiduralRoute")
@XmlEnum
public enum EpiduralRoute {
EPI,
EPIDURINJ,
EPIINJ,
EPINJSP;
public String value() {
return name();
}
public static EpiduralRoute fromValue(String v) {
return valueOf(v);
}
}
| ricecakesoftware/CommunityMedicalLink | ricecakesoftware.communitymedicallink.hl7/src/org/hl7/v3/EpiduralRoute.java | Java | gpl-3.0 | 928 | [
30522,
7427,
8917,
1012,
1044,
2140,
2581,
1012,
1058,
2509,
1025,
12324,
9262,
2595,
1012,
20950,
1012,
14187,
1012,
5754,
17287,
3508,
1012,
20950,
2368,
2819,
1025,
12324,
9262,
2595,
1012,
20950,
1012,
14187,
1012,
5754,
17287,
3508,
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... |
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) 2015, Joyent, Inc.
*/
var test = require('./test-namer')('vm-to-zones');
var util = require('util');
var bunyan = require('bunyan');
var utils = require('../../lib/utils');
var buildZonesFromVm = require('../../lib/vm-to-zones');
var log = bunyan.createLogger({name: 'cns'});
test('basic single container', function (t) {
var config = {
forward_zones: {
'foo': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
services: [],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones), ['foo', '3.2.1.in-addr.arpa']);
t.deepEqual(Object.keys(zones['foo']), ['abc123.inst.def432']);
t.deepEqual(Object.keys(zones['3.2.1.in-addr.arpa']), ['4']);
var fwd = zones['foo']['abc123.inst.def432'];
t.deepEqual(fwd, [
{constructor: 'A', args: ['1.2.3.4']},
{constructor: 'TXT', args: ['abc123']}
]);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['abc123.inst.def432.foo']}
]);
t.end();
});
test('cloudapi instance', function (t) {
var config = {
forward_zones: {
'foo': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
services: [ { name: 'cloudapi', ports: [] } ],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432',
login: 'admin'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones), ['foo', '3.2.1.in-addr.arpa']);
t.deepEqual(Object.keys(zones['foo']), [
'abc123.inst.def432', 'cloudapi.svc.def432', 'cloudapi']);
t.deepEqual(Object.keys(zones['3.2.1.in-addr.arpa']), ['4']);
var fwd = zones['foo']['cloudapi'];
t.deepEqual(fwd, [
{constructor: 'A', args: ['1.2.3.4'], src: 'abc123'},
{constructor: 'TXT', args: ['abc123'], src: 'abc123'}
]);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['abc123.inst.def432.foo']}
]);
t.end();
});
test('with use_alias', function (t) {
var config = {
use_alias: true,
forward_zones: {
'foo': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
alias: 'test',
services: [],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones), ['foo', '3.2.1.in-addr.arpa']);
t.deepEqual(Object.keys(zones['foo']),
['abc123.inst.def432', 'test.inst.def432']);
t.deepEqual(Object.keys(zones['3.2.1.in-addr.arpa']), ['4']);
var fwd = zones['foo']['test.inst.def432'];
t.deepEqual(fwd, [
{constructor: 'A', args: ['1.2.3.4']},
{constructor: 'TXT', args: ['abc123']}
]);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['test.inst.def432.foo']}
]);
t.end();
});
test('with use_login', function (t) {
var config = {
use_login: true,
forward_zones: {
'foo': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
alias: 'test',
services: [],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432',
login: 'bar'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones), ['foo', '3.2.1.in-addr.arpa']);
t.deepEqual(Object.keys(zones['foo']),
['abc123.inst.def432', 'abc123.inst.bar']);
t.deepEqual(Object.keys(zones['3.2.1.in-addr.arpa']), ['4']);
var fwd = zones['foo']['abc123.inst.bar'];
t.deepEqual(fwd, [
{constructor: 'A', args: ['1.2.3.4']},
{constructor: 'TXT', args: ['abc123']}
]);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['abc123.inst.bar.foo']}
]);
t.end();
});
test('with use_alias and use_login', function (t) {
var config = {
use_alias: true,
use_login: true,
forward_zones: {
'foo': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
alias: 'test',
services: [],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432',
login: 'bar'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones), ['foo', '3.2.1.in-addr.arpa']);
t.deepEqual(Object.keys(zones['foo']),
['abc123.inst.def432', 'abc123.inst.bar', 'test.inst.def432',
'test.inst.bar']);
t.deepEqual(Object.keys(zones['3.2.1.in-addr.arpa']), ['4']);
var fwd = zones['foo']['test.inst.bar'];
t.deepEqual(fwd, [
{constructor: 'A', args: ['1.2.3.4']},
{constructor: 'TXT', args: ['abc123']}
]);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['test.inst.bar.foo']}
]);
t.end();
});
test('using a PTR name', function (t) {
var config = {
use_alias: true,
use_login: true,
forward_zones: {
'foo': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
alias: 'test',
services: [],
ptrname: 'test.something.com',
listInstance: true,
listServices: true,
owner: {
uuid: 'def432',
login: 'bar'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones), ['foo', '3.2.1.in-addr.arpa']);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['test.something.com']}
]);
t.end();
});
test('multi-zone', function (t) {
var config = {
use_alias: true,
use_login: true,
forward_zones: {
'foo': {},
'bar': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
alias: 'test',
services: [],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432',
login: 'bar'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo']
},
{
ip: '3.2.1.4',
zones: ['bar']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones).sort(),
['1.2.3.in-addr.arpa', '3.2.1.in-addr.arpa', 'bar', 'foo']);
t.deepEqual(Object.keys(zones['foo']).sort(),
['abc123.inst.bar', 'abc123.inst.def432', 'test.inst.bar',
'test.inst.def432']);
t.deepEqual(Object.keys(zones['bar']).sort(),
Object.keys(zones['foo']).sort());
t.deepEqual(Object.keys(zones['3.2.1.in-addr.arpa']), ['4']);
t.deepEqual(Object.keys(zones['1.2.3.in-addr.arpa']), ['4']);
var fwd = zones['foo']['test.inst.bar'];
t.deepEqual(fwd, [
{constructor: 'A', args: ['1.2.3.4']},
{constructor: 'TXT', args: ['abc123']}
]);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['test.inst.bar.foo']}
]);
var rev2 = zones['1.2.3.in-addr.arpa']['4'];
t.deepEqual(rev2, [
{constructor: 'PTR', args: ['test.inst.bar.bar']}
]);
t.end();
});
test('multi-zone, single PTRs', function (t) {
var config = {
use_alias: true,
use_login: true,
forward_zones: {
'foo': {},
'bar': {},
'baz': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
alias: 'test',
services: [],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432',
login: 'bar'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo', 'bar']
},
{
ip: '3.2.1.4',
zones: ['baz']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones).sort(),
['1.2.3.in-addr.arpa', '3.2.1.in-addr.arpa', 'bar', 'baz', 'foo']);
t.deepEqual(Object.keys(zones['foo']).sort(),
['abc123.inst.bar', 'abc123.inst.def432', 'test.inst.bar',
'test.inst.def432']);
t.deepEqual(Object.keys(zones['bar']).sort(),
Object.keys(zones['foo']).sort());
t.deepEqual(Object.keys(zones['3.2.1.in-addr.arpa']), ['4']);
t.deepEqual(Object.keys(zones['1.2.3.in-addr.arpa']), ['4']);
var fwd = zones['foo']['test.inst.bar'];
t.deepEqual(fwd, [
{constructor: 'A', args: ['1.2.3.4']},
{constructor: 'TXT', args: ['abc123']}
]);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['test.inst.bar.foo']}
]);
var rev2 = zones['1.2.3.in-addr.arpa']['4'];
t.deepEqual(rev2, [
{constructor: 'PTR', args: ['test.inst.bar.baz']}
]);
t.end();
});
test('multi-zone, shortest zone priority PTR', function (t) {
var config = {
use_alias: true,
use_login: true,
forward_zones: {
'foobarbaz': {},
'foobar': {},
'baz': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
alias: 'test',
services: [],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432',
login: 'bar'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foobar', 'foobarbaz', 'baz']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
var rev = zones['3.2.1.in-addr.arpa']['4'];
t.deepEqual(rev, [
{constructor: 'PTR', args: ['test.inst.bar.baz']}
]);
t.end();
});
test('service with srvs', function (t) {
var config = {
use_alias: true,
forward_zones: {
'foo': {}
},
reverse_zones: {}
};
var vm = {
uuid: 'abc123',
alias: 'test',
services: [
{ name: 'svc1', ports: [1234, 1235] }
],
listInstance: true,
listServices: true,
owner: {
uuid: 'def432'
},
nics: [
{
ip: '1.2.3.4',
zones: ['foo']
}
]
};
var zones = buildZonesFromVm(vm, config, log);
t.deepEqual(Object.keys(zones), ['foo', '3.2.1.in-addr.arpa']);
t.deepEqual(Object.keys(zones['foo']),
['abc123.inst.def432', 'test.inst.def432', 'svc1.svc.def432']);
var fwd = zones['foo']['test.inst.def432'];
t.deepEqual(fwd, [
{constructor: 'A', args: ['1.2.3.4']},
{constructor: 'TXT', args: ['abc123']}
]);
var svc = zones['foo']['svc1.svc.def432'];
t.deepEqual(svc, [
{constructor: 'A', args: ['1.2.3.4'], src: 'abc123'},
{constructor: 'TXT', args: ['abc123'], src: 'abc123'},
{constructor: 'SRV', args: ['test.inst.def432.foo', 1234],
src: 'abc123'},
{constructor: 'SRV', args: ['test.inst.def432.foo', 1235],
src: 'abc123'}
]);
t.end();
});
| eait-itig/triton-cns | test/unit/vm-to-zones.test.js | JavaScript | mpl-2.0 | 10,814 | [
30522,
1013,
1008,
1008,
2023,
3120,
3642,
2433,
2003,
3395,
2000,
1996,
3408,
1997,
1996,
9587,
5831,
4571,
2270,
1008,
6105,
1010,
1058,
1012,
1016,
1012,
1014,
1012,
2065,
1037,
6100,
1997,
1996,
6131,
2140,
2001,
2025,
5500,
2007,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
var jsonfile = require('jsonfile');
var file = '../data1.json';
var tasksController = require('../public/js/tasks.js');
jsonfile.writeFile(file,data1);
*/
// var User = require('../public/js/mongoUser.js');
var Task = require('../public/js/mongoTasks.js');
var MongoClient = require('mongodb').MongoClient, format = require('util').format;
var dJ = require('../data1.json');
var tasksCount, taskList, groupList;
exports.viewTasks = function(req, res){
MongoClient.connect('mongodb://heroku_2s7m53vj:lqb9p32ov0u6akts4hoekc7h5l@ds153677.mlab.com:53677/heroku_2s7m53vj', function(err, db) {
if(err) throw err;
var collection = db.collection('tasks');
var collection2 = db.collection('groups');
// collection.count(function(err, count) {
// //console.log(format("count = %s", count));
// tasksCount = count;
// });
// Locate all the entries using find
collection.find().toArray(function(err, results) {
taskList = results;
});
collection2.find().toArray(function(err,results) {
groupList = results;
// console.dir(groupList);
});
db.close();
})
res.render('tasks', {
dataJson: dJ,
tasks: taskList,
groups: groupList
});
};
exports.updateTasks = function(req,res) {
var name = req.body.name;
var reward = req.body.reward;
var description = req.body.description;
var userSelected = "";
var newTask = new Task({
name: name,
reward: reward,
description: description,
userSelected: userSelected
});
Task.createTask(newTask, function(err,task) {
if(err) throw err;
//console.log(task);
});
res.redirect(req.get('referer'));
// res.redirect('/index');
}
exports.editTasks = function(req,res) {
MongoClient.connect('mongodb://heroku_2s7m53vj:lqb9p32ov0u6akts4hoekc7h5l@ds153677.mlab.com:53677/heroku_2s7m53vj', function(err, db) {
if(err) throw err;
var collection = db.collection('tasks');
var oldName = req.body.oldName || req.query.oldName;
var oldReward = req.body.oldReward || req.query.oldReward;
var oldDescription = req.body.oldDescription || req.query.oldDescription;
var taskName = req.body.taskName || req.query.taskName;
var taskReward = req.body.taskReward || req.query.taskReward;
var taskDescription = req.body.taskDescription || req.query.taskDescription;
//console.dir(taskName);
//collection.remove({"name": memberName});
collection.update({'name': oldName},{$set:{'name':taskName}});
collection.update({'reward': parseInt(oldReward)},{$set:{'reward': parseInt(taskReward)}});
collection.update({'description': oldDescription},{$set:{'description':taskDescription}});
db.close()
// Group.removeMember(memberName, function(err,group){
// if(err) throw err;
// console.log(group);
// })
})
res.redirect(req.get('referer'));
}
exports.removeTasks = function(req,res){
MongoClient.connect('mongodb://heroku_2s7m53vj:lqb9p32ov0u6akts4hoekc7h5l@ds153677.mlab.com:53677/heroku_2s7m53vj', function(err, db) {
if(err) throw err;
var collection = db.collection('tasks');
var taskName = req.body.taskID || req.query.taskID;
//console.dir(taskName);
collection.remove({ $or: [{"name": taskName}, {"name": ''}] });
db.close()
// Group.removeMember(memberName, function(err,group){
// if(err) throw err;
// console.log(group);
// })
})
res.redirect(req.get('referer'));
}
exports.selectUser = function(req,res){
MongoClient.connect('mongodb://heroku_2s7m53vj:lqb9p32ov0u6akts4hoekc7h5l@ds153677.mlab.com:53677/heroku_2s7m53vj', function(err, db) {
if(err) throw err;
var collection = db.collection('tasks');
var selectedUser = req.body.selectedUser || req.query.selectedUser;
var taskName = req.body.taskName || req.query.taskName;
// console.dir(selectedUser);
collection.update({'name': taskName},{$set:{'userSelected': selectedUser}});
db.close()
})
}
| odangitsdjang/CleaningApp | routes/tasks.js | JavaScript | mit | 4,170 | [
30522,
1013,
1008,
13075,
1046,
3385,
8873,
2571,
1027,
5478,
1006,
1005,
1046,
3385,
8873,
2571,
1005,
1007,
1025,
13075,
5371,
1027,
1005,
1012,
1012,
1013,
2951,
2487,
1012,
1046,
3385,
1005,
1025,
13075,
8518,
8663,
13181,
10820,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* $RCSfile$
* $Revision: 1653 $
* $Date: 2005-07-20 00:21:40 -0300 (Wed, 20 Jul 2005) $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.openfire.handler;
import java.util.Iterator;
import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.openfire.IQHandlerInfo;
import org.jivesoftware.openfire.PacketException;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.openfire.vcard.VCardManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
/**
* Implements the TYPE_IQ vcard-temp protocol. Clients
* use this protocol to set and retrieve the vCard information
* associated with someone's account.
* <p>
* A 'get' query retrieves the vcard for the addressee.
* A 'set' query sets the vcard information for the sender's account.
* </p>
* <p>
* Currently an empty implementation to allow usage with normal
* clients. Future implementation needed.
* </p>
* <h2>Assumptions</h2>
* This handler assumes that the request is addressed to the server.
* An appropriate TYPE_IQ tag matcher should be placed in front of this
* one to route TYPE_IQ requests not addressed to the server to
* another channel (probably for direct delivery to the recipient).
* <h2>Warning</h2>
* There should be a way of determining whether a session has
* authorization to access this feature. I'm not sure it is a good
* idea to do authorization in each handler. It would be nice if
* the framework could assert authorization policies across channels.
* <h2>Warning</h2>
* I have noticed incompatibility between vCard XML used by Exodus and Psi.
* There is a new vCard standard going through the JSF JEP process. We might
* want to start either standardizing on clients (probably the most practical),
* sending notices for non-conformance (useful),
* or attempting to translate between client versions (not likely).
*
* @author Iain Shigeoka
*/
public class IQvCardHandler extends IQHandler {
private static final Logger Log = LoggerFactory.getLogger(IQvCardHandler.class);
private IQHandlerInfo info;
private XMPPServer server;
private UserManager userManager;
public IQvCardHandler() {
super("XMPP vCard Handler");
info = new IQHandlerInfo("vCard", "vcard-temp");
}
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException, PacketException {
IQ result = IQ.createResultIQ(packet);
IQ.Type type = packet.getType();
if (type.equals(IQ.Type.set)) {
try {
User user = userManager.getUser(packet.getFrom().getNode());
Element vcard = packet.getChildElement();
if (vcard != null) {
VCardManager.getInstance().setVCard(user.getUsername(), vcard);
}
}
catch (UserNotFoundException e) {
result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.item_not_found);
}
catch (Exception e) {
Log.error(e.getMessage(), e);
result.setError(PacketError.Condition.internal_server_error);
}
}
else if (type.equals(IQ.Type.get)) {
JID recipient = packet.getTo();
// If no TO was specified then get the vCard of the sender of the packet
if (recipient == null) {
recipient = packet.getFrom();
}
// By default return an empty vCard
result.setChildElement("vCard", "vcard-temp");
// Only try to get the vCard values of non-anonymous users
if (recipient != null) {
if (recipient.getNode() != null && server.isLocal(recipient)) {
VCardManager vManager = VCardManager.getInstance();
Element userVCard = vManager.getVCard(recipient.getNode());
if (userVCard != null) {
// Check if the requester wants to ignore some vCard's fields
Element filter = packet.getChildElement()
.element(QName.get("filter", "vcard-temp-filter"));
if (filter != null) {
// Create a copy so we don't modify the original vCard
userVCard = userVCard.createCopy();
// Ignore fields requested by the user
for (Iterator toFilter = filter.elementIterator(); toFilter.hasNext();)
{
Element field = (Element) toFilter.next();
Element fieldToRemove = userVCard.element(field.getName());
if (fieldToRemove != null) {
fieldToRemove.detach();
}
}
}
result.setChildElement(userVCard);
}
}
else {
result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.item_not_found);
}
} else {
result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.item_not_found);
}
}
else {
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_acceptable);
}
return result;
}
@Override
public void initialize(XMPPServer server) {
super.initialize(server);
this.server = server;
userManager = server.getUserManager();
}
@Override
public IQHandlerInfo getInfo() {
return info;
}
}
| haipeng-ssy/openfire_src | src/java/org/jivesoftware/openfire/handler/IQvCardHandler.java | Java | apache-2.0 | 6,967 | [
30522,
1013,
1008,
1008,
1008,
1002,
22110,
22747,
9463,
1002,
1008,
1002,
13921,
1024,
29309,
1002,
1008,
1002,
3058,
1024,
2384,
1011,
5718,
1011,
2322,
4002,
1024,
2538,
1024,
2871,
1011,
6021,
8889,
1006,
21981,
1010,
2322,
21650,
2384,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: http://github.com/azerothcore/azerothcore-wotlk/LICENSE-GPL2
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
#include "GameObjectAI.h"
//GameObjectAI::GameObjectAI(GameObject* g) : go(g) {}
int GameObjectAI::Permissible(const GameObject* go)
{
if (go->GetAIName() == "GameObjectAI")
return PERMIT_BASE_SPECIAL;
return PERMIT_BASE_NO;
}
NullGameObjectAI::NullGameObjectAI(GameObject* g) : GameObjectAI(g) {}
| DantestyleXD/azerothcore-wotlk | src/game/AI/CoreAI/GameObjectAI.cpp | C++ | agpl-3.0 | 609 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2355,
1009,
17207,
10624,
2705,
17345,
1026,
7479,
1012,
17207,
10624,
2705,
17345,
1012,
8917,
1028,
1010,
2207,
2104,
27004,
14246,
2140,
1058,
2475,
6105,
1024,
8299,
1024,
1013,
1013,
210... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// license:BSD-3-Clause
// copyright-holders:Takahiro Nogi, David Haywood
/******************************************************************************
Gomoku Narabe Renju
(c)1981 Nihon Bussan Co.,Ltd.
Driver by Takahiro Nogi <nogi@kt.rim.or.jp> 1999/11/06 -
Updated to compile again by David Haywood 19th Oct 2002
******************************************************************************/
#include "emu.h"
#include "includes/gomoku.h"
/******************************************************************************
palette RAM
******************************************************************************/
void gomoku_state::palette(palette_device &palette) const
{
const uint8_t *color_prom = memregion("proms")->base();
for (int i = 0; i < palette.entries(); i++)
{
int bit0, bit1, bit2;
// red component
bit0 = BIT(*color_prom, 0);
bit1 = BIT(*color_prom, 1);
bit2 = BIT(*color_prom, 2);
int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
// green component
bit0 = BIT(*color_prom, 3);
bit1 = BIT(*color_prom, 4);
bit2 = BIT(*color_prom, 5);
int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
// blue component
bit0 = 0;
bit1 = BIT(*color_prom, 6);
bit2 = BIT(*color_prom, 7);
int const b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
palette.set_pen_color(i, rgb_t(r, g, b));
color_prom++;
}
}
/******************************************************************************
Tilemap callbacks
******************************************************************************/
TILE_GET_INFO_MEMBER(gomoku_state::get_fg_tile_info)
{
int code = (m_videoram[tile_index]);
int attr = (m_colorram[tile_index]);
int color = (attr& 0x0f);
int flipyx = (attr & 0xc0) >> 6;
tileinfo.set(0,
code,
color,
TILE_FLIPYX(flipyx));
}
void gomoku_state::videoram_w(offs_t offset, uint8_t data)
{
m_videoram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
void gomoku_state::colorram_w(offs_t offset, uint8_t data)
{
m_colorram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
void gomoku_state::flipscreen_w(int state)
{
m_flipscreen = state ? 0 : 1;
}
void gomoku_state::bg_dispsw_w(int state)
{
m_bg_dispsw = state ? 0 : 1;
}
/******************************************************************************
Start the video hardware emulation
******************************************************************************/
void gomoku_state::video_start()
{
m_screen->register_screen_bitmap(m_bg_bitmap);
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(gomoku_state::get_fg_tile_info)),TILEMAP_SCAN_ROWS,8,8,32, 32);
m_fg_tilemap->set_transparent_pen(0);
// make background bitmap
m_bg_bitmap.fill(0x20);
// board
for (int y = 0; y < 256; y++)
{
for (int x = 0; x < 256; x++)
{
int bgdata = m_bg_d[m_bg_x[x] + (m_bg_y[y] << 4)];
int color = 0x20; // outside frame (black)
if (bgdata & 0x01) color = 0x21; // board (brown)
if (bgdata & 0x02) color = 0x20; // frame line (while)
m_bg_bitmap.pix((255 - y - 1) & 0xff, (255 - x + 7) & 0xff) = color;
}
}
save_item(NAME(m_flipscreen)); // set but never used?
save_item(NAME(m_bg_dispsw));
}
/******************************************************************************
Display refresh
******************************************************************************/
uint32_t gomoku_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int color;
// draw background layer
if (m_bg_dispsw)
{
// copy bg bitmap
copybitmap(bitmap, m_bg_bitmap, 0, 0, 0, 0, cliprect);
// stone
for (int y = 0; y < 256; y++)
{
for (int x = 0; x < 256; x++)
{
int bgoffs = ((((255 - x - 2) / 14) | (((255 - y - 10) / 14) << 4)) & 0xff);
int bgdata = m_bg_d[m_bg_x[x] + (m_bg_y[y] << 4) ];
int bgram = m_bgram[bgoffs];
if (bgdata & 0x04)
{
if (bgram & 0x01)
{
color = 0x2f; // stone (black)
}
else if (bgram & 0x02)
{
color = 0x22; // stone (white)
}
else continue;
}
else continue;
bitmap.pix((255 - y - 1) & 0xff, (255 - x + 7) & 0xff) = color;
}
}
// cursor
for (int y = 0; y < 256; y++)
{
for (int x = 0; x < 256; x++)
{
int bgoffs = ((((255 - x - 2) / 14) | (((255 - y - 10) / 14) << 4)) & 0xff);
int bgdata = m_bg_d[m_bg_x[x] + (m_bg_y[y] << 4) ];
int bgram = m_bgram[bgoffs];
if (bgdata & 0x08)
{
if (bgram & 0x04)
{
color = 0x2f; // cursor (black)
}
else if (bgram & 0x08)
{
color = 0x22; // cursor (white)
}
else continue;
}
else continue;
bitmap.pix((255 - y - 1) & 0xff, (255 - x + 7) & 0xff) = color;
}
}
}
else
{
bitmap.fill(0x20);
}
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
return 0;
}
| johnparker007/mame | src/mame/video/gomoku.cpp | C++ | gpl-2.0 | 4,956 | [
30522,
1013,
1013,
6105,
1024,
18667,
2094,
1011,
1017,
1011,
11075,
1013,
1013,
9385,
1011,
13304,
1024,
27006,
4430,
9711,
2053,
5856,
1010,
2585,
10974,
3702,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright (C) 2002-2007 The FreeCol Team
*
* This file is part of FreeCol.
*
* FreeCol 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.
*
* FreeCol 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 FreeCol. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.freecol.common.model;
import java.util.Arrays;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import net.sf.freecol.Reformation;
import net.sf.freecol.client.gui.i18n.Messages;
/**
* Contains a message about a change in the model.
*/
public class ModelMessage extends FreeColObject {
/** Constants describing the type of message. */
public static enum MessageType {
DEFAULT,
WARNING,
SONS_OF_LIBERTY,
GOVERNMENT_EFFICIENCY,
WAREHOUSE_CAPACITY,
UNIT_IMPROVED,
UNIT_DEMOTED,
UNIT_LOST,
UNIT_ADDED,
BUILDING_COMPLETED,
FOREIGN_DIPLOMACY,
MARKET_PRICES,
LOST_CITY_RUMOUR,
GIFT_GOODS,
MISSING_GOODS,
TUTORIAL,
COMBAT_RESULT,
ACCEPTED_DEMANDS,
REJECTED_DEMANDS
}
private Player owner;
private FreeColGameObject source;
private Location sourceLocation;
private FreeColObject display;
private MessageType type;
private String[] data;
private boolean beenDisplayed = false;
public ModelMessage() {
}
private static String[] convertData(String[][] data) {
if (data == null) {
return null;
}
String[] strings = new String[data.length * 2];
for (int index = 0; index < data.length; index++) {
strings[index * 2] = data[index][0];
strings[index * 2 + 1] = data[index][1];
}
return strings;
}
/**
* Creates a new <code>ModelMessage</code>.
*
* @param source The source of the message. This is what the message should be
* associated with. In addition, the owner of the source is the
* player getting the message.
* @param id The ID of the message to display.
* @param data Contains data to be displayed in the message or <i>null</i>.
* @param type The type of this model message.
* @param display The Object to display.
*/
@Deprecated
public ModelMessage(FreeColGameObject source, String id, String[][] data, MessageType type, FreeColObject display) {
this(source, type, display, id, convertData(data));
}
/**
* Creates a new <code>ModelMessage</code>.
*
* @param source The source of the message. This is what the message should be
* associated with. In addition, the owner of the source is the
* player getting the message.
* @param type The type of this model message.
* @param display The Object to display.
* @param id The ID of the message to display.
* @param data Contains data to be displayed in the message or <i>null</i>.
*/
public ModelMessage(FreeColGameObject source, MessageType type, FreeColObject display,
String id, String... data) {
this.source = source;
this.sourceLocation = null;
if (source instanceof Unit) {
Unit u = (Unit) source;
this.owner = u.getOwner();
if (u.getTile() != null) {
this.sourceLocation = u.getTile();
} else if (u.getColony() != null) {
this.sourceLocation = u.getColony().getTile();
} else if (u.getIndianSettlement() != null) {
this.sourceLocation = u.getIndianSettlement().getTile();
} else if (u.isInEurope()) {
this.sourceLocation = u.getOwner().getEurope();
}
} else if (source instanceof Settlement) {
this.owner = ((Settlement) source).getOwner();
this.sourceLocation = ((Settlement) source).getTile();
} else if (source instanceof Europe) {
this.owner = ((Europe) source).getOwner();
} else if (source instanceof Player) {
this.owner = (Player) source;
} else if (source instanceof Ownable) {
this.owner = ((Ownable) source).getOwner();
}
setId(id);
this.data = data;
this.type = type;
if (display == null) {
this.display = getDefaultDisplay(type, source);
} else {
this.display = display;
}
verifyFields();
}
/**
* Checks that all the fields as they are set in the constructor are valid.
*/
private void verifyFields() {
if (getId() == null) {
throw new IllegalArgumentException("ModelMessage should not have a null id.");
}
if (source == null) {
throw new IllegalArgumentException("ModelMessage with ID " + this.toString() + " should not have a null source.");
}
if (owner == null) {
throw new IllegalArgumentException("ModelMessage with ID " + this.getId() + " should not have a null owner.");
}
if (!(display == null ||
display instanceof FreeColGameObject ||
display instanceof FreeColGameObjectType)) {
throw new IllegalArgumentException("The display must be a FreeColGameObject or FreeColGameObjectType!");
}
if (data != null && data.length % 2 != 0) {
throw new IllegalArgumentException("Data length must be multiple of 2.");
}
}
/**
* Creates a new <code>ModelMessage</code>.
*
* @param source The source of the message. This is what the message should be
* associated with. In addition, the owner of the source is the
* player getting the message.
* @param id The ID of the message to display.
* @param data Contains data to be displayed in the message or <i>null</i>.
* @param type The type of this model message.
*/
public ModelMessage(FreeColGameObject source, String id, String[][] data, MessageType type) {
this(source, type, getDefaultDisplay(type, source), id, convertData(data));
}
/**
* Creates a new <code>ModelMessage</code>.
*
* @param source The source of the message. This is what the message should be
* associated with. In addition, the owner of the source is the
* player getting the message.
* @param id The ID of the message to display.
* @param data Contains data to be displayed in the message or <i>null</i>.
*/
public ModelMessage(FreeColGameObject source, String id, String[][] data) {
this(source, MessageType.DEFAULT, getDefaultDisplay(MessageType.DEFAULT, source), id, convertData(data));
}
/**
* Returns the default display object for the given type.
* @param type the type for which to find the default display object.
* @param source the source object
* @return an object to be displayed for the message.
*/
static private FreeColObject getDefaultDisplay(MessageType type, FreeColGameObject source) {
FreeColObject newDisplay = null;
switch(type) {
case SONS_OF_LIBERTY:
case GOVERNMENT_EFFICIENCY:
newDisplay = Reformation.getSpecification().getGoodsType("model.goods.bells");
break;
case LOST_CITY_RUMOUR:
case UNIT_IMPROVED:
case UNIT_DEMOTED:
case UNIT_LOST:
case UNIT_ADDED:
case COMBAT_RESULT:
newDisplay = source;
break;
case BUILDING_COMPLETED:
newDisplay = Reformation.getSpecification().getGoodsType("model.goods.hammers");
break;
case TUTORIAL:
case DEFAULT:
case WARNING:
case WAREHOUSE_CAPACITY:
case FOREIGN_DIPLOMACY:
case MARKET_PRICES:
case GIFT_GOODS:
case MISSING_GOODS:
default:
if (source instanceof Player) {
newDisplay = source;
}
}
return newDisplay;
}
/**
* Checks if this <code>ModelMessage</code> has been displayed.
* @return <i>true</i> if this <code>ModelMessage</code> has been displayed.
* @see #setBeenDisplayed
*/
public boolean hasBeenDisplayed() {
return beenDisplayed;
}
/**
* Sets the <code>beenDisplayed</code> value of this <code>ModelMessage</code>.
* This is used to avoid showing the same message twice.
*
* @param beenDisplayed Should be set to <code>true</code> after the
* message has been displayed.
*/
public void setBeenDisplayed(boolean beenDisplayed) {
this.beenDisplayed = beenDisplayed;
}
/**
* Gets the source of the message. This is what the message
* should be associated with. In addition, the owner of the source is the
* player getting the message.
*
* @return The source of the message.
* @see #getOwner
*/
public FreeColGameObject getSource() {
return source;
}
/**
* Sets the source of the message.
* @param newSource a new source for this message
*/
public void setSource(FreeColGameObject newSource) {
source = newSource;
}
/**
* Returns the data to be displayed in the message.
* @return The data as a <code>String[]</code> or <i>null</i>
* if no data applies.
*/
public String[] getData() {
return data;
}
/**
* Gets the type of the message to display.
* @return The type.
*/
public MessageType getType() {
return type;
}
public String getTypeName() {
return Messages.message("model.message." + type.toString());
}
/**
* Gets the Object to display.
* @return The Object to display.
*/
public FreeColObject getDisplay() {
return display;
}
/**
* Sets the Object to display.
* @param newDisplay the new object to display
*/
public void setDisplay(FreeColGameObject newDisplay) {
display = newDisplay;
}
/**
* Returns the owner of this message. The owner of this method
* is the owner of the {@link #getSource source}.
*
* @return The owner of the message. This is the <code>Player</code>
* who should receive the message.
*/
public Player getOwner() {
return owner;
}
/**
* Set the owner of this message.
*
* @param newOwner A <code>Player</code> to own this message.
*/
public void setOwner(Player newOwner) {
newOwner = owner;
}
/**
* Checks if this <code>ModelMessage</code> is equal to another <code>ModelMessage</code>.
* @return <i>true</i> if the sources, message IDs and data are equal.
*/
@Override
public boolean equals(Object o) {
if ( ! (o instanceof ModelMessage) ) { return false; }
ModelMessage m = (ModelMessage) o;
// Check that the content of the data array is equal
if (!Arrays.equals(data, m.data)) {
return false;
}
return ( source.equals(m.source)
&& getId().equals(m.getId())
&& type == m.type );
}
@Override
public int hashCode() {
int value = 1;
value = 37 * value + ((source == null) ? 0 : source.hashCode());
value = 37 * value + getId().hashCode();
if (data != null) {
for (String s : data) {
value = 37 * value + s.hashCode();
}
}
value = 37 * value + type.ordinal();
return value;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ModelMessage<");
sb.append(hashCode() + ", " + ((source == null) ? "null" : source.getId()) + ", " + getId() + ", " + ((display==null) ? "null" : display.getId()) + ", ");
if (data != null) {
for (String s : data) {
sb.append(s + "/");
}
}
sb.append(", " + type + " >");
return sb.toString();
}
public static String getXMLElementTagName() {
return "modelMessage";
}
@Override
public void toXMLImpl(XMLStreamWriter out) throws XMLStreamException {
out.writeStartElement(getXMLElementTagName());
out.writeAttribute("owner", owner.getId());
if (source!=null) {
if ((source instanceof Unit && ((Unit)source).isDisposed())
||(source instanceof Settlement && ((Settlement)source).isDisposed())) {
if (sourceLocation==null) {
logger.warning("sourceLocation==null for source "+source.getId());
out.writeAttribute("source", owner.getId());
} else {
out.writeAttribute("source", sourceLocation.getId());
}
} else {
out.writeAttribute("source", source.getId());
}
}
if (display != null) {
out.writeAttribute("display", display.getId());
}
out.writeAttribute("type", type.toString());
out.writeAttribute("ID", getId());
out.writeAttribute("hasBeenDisplayed", String.valueOf(beenDisplayed));
if (data != null) {
toArrayElement("data", data, out);
}
out.writeEndElement();
}
/**
* Initialize this object from an XML-representation of this object.
* @param in The input stream with the XML.
* @throws XMLStreamException if a problem was encountered
* during parsing.
*/
@Override
public void readFromXMLImpl(XMLStreamReader in) throws XMLStreamException {
setId(in.getAttributeValue(null, "ID"));
type = Enum.valueOf(MessageType.class, getAttribute(in, "type", MessageType.DEFAULT.toString()));
beenDisplayed = Boolean.parseBoolean(in.getAttributeValue(null, "hasBeenDisplayed"));
while (in.nextTag() != XMLStreamConstants.END_ELEMENT) {
if (in.getLocalName().equals("data")) {
data = readFromArrayElement("data", in, new String[0]);
}
}
}
/**
* Initialize this object from an XML-representation of this object.
* @param in The input stream with the XML.
* @param game a <code>Game</code> value
* @exception XMLStreamException if a problem was encountered
* during parsing.
*/
public void readFromXML(XMLStreamReader in, Game game) throws XMLStreamException {
setId(in.getAttributeValue(null, "ID"));
String ownerPlayer = in.getAttributeValue(null, "owner");
owner = (Player)game.getFreeColGameObject(ownerPlayer);
type = Enum.valueOf(MessageType.class, getAttribute(in, "type", MessageType.DEFAULT.toString()));
beenDisplayed = Boolean.parseBoolean(in.getAttributeValue(null, "hasBeenDisplayed"));
String sourceString = in.getAttributeValue(null, "source");
source = game.getFreeColGameObject(sourceString);
if (source == null) {
logger.warning("source null from string " + sourceString);
source = owner;
}
String displayString = in.getAttributeValue(null, "display");
if (displayString != null) {
// usually referring to a unit, colony or player
display = game.getFreeColGameObject(displayString);
if (display==null) {
// either the unit, colony has been killed/destroyed
// or the message refers to goods or building type
try {
display = Reformation.getSpecification().getType(displayString);
} catch (IllegalArgumentException e) {
// do nothing
display = owner;
logger.warning("display null from string " + displayString);
}
}
}
while (in.nextTag() != XMLStreamConstants.END_ELEMENT) {
if (in.getLocalName().equals("data")) {
data = readFromArrayElement("data", in, new String[0]);
}
}
verifyFields();
owner.addModelMessage(this);
}
}
| tectronics/reformationofeurope | src/net/sf/freecol/common/model/ModelMessage.java | Java | gpl-2.0 | 16,955 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2526,
1011,
2289,
1996,
2489,
25778,
2136,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
2489,
25778,
1012,
1008,
1008,
2489,
25778,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# path
Create a 2d path using SVG syntax.
* `d` is the path descriptor
{% craftml %}
<!-- rectangle -->
<path d="M10 10 h 10 v 10 h -10 z"/>
<!-- triangle -->
<path d="M30 10 l 10 10 l 10 -10 z"/>
{% endcraftml %}
Typically, you would use another drawing program to draw a path and export
it as an SVG tag to use in CraftML, because it is quite difficult to write
out a path descriptor manually.
{% craftml %}
<path d="M425.714,298.795c-3.315-25.56-31.224-50.174-59.725-52.675c-1.32-0.116-2.678-0.175-4.035-0.175
c-7.841,0-15.145,1.899-22.876,3.909c-8.474,2.204-17.236,4.482-27.593,4.482c-24.627,0-51.939-13.673-85.951-43.03
c-15.99-13.803-37.649-30.563-60.579-48.309c-35.625-27.57-72.464-56.078-92.513-76.923c-0.966-1.005-2.134-2.422-3.485-4.063
c-5.524-6.71-13.871-16.849-23.975-16.849c-7.007,0-13.556,4.88-19.463,14.506c-17.969,29.272-40.64,92.412-11.632,143.381
c22.454,39.516,27.952,104.224,29.102,123.114c0.583,9.583,7.556,12.261,11.214,12.338h33.836c6.576,0,10.445-4.408,10.615-12.095
c0.141-6.393,0.801-30.128,3.351-67.172c2.102-30.806,8.488-34.369,13.109-34.369c10.056,0,27.157,16.668,50.825,39.738
c15.363,14.975,34.483,33.61,56.618,52.296c19.095,16.12,42.025,23.956,70.1,23.956c36.682,0,74.746-13.709,105.331-24.725
l2.09-0.752C418.524,328.739,427.869,315.404,425.714,298.795z"/>
{% endcraftml %}
| craftml/docs | language/primitives/2d/path.md | Markdown | mit | 1,313 | [
30522,
1001,
4130,
3443,
1037,
14134,
4130,
2478,
17917,
2290,
20231,
1012,
1008,
1036,
1040,
1036,
2003,
1996,
4130,
4078,
23235,
2953,
1063,
1003,
7477,
19968,
1003,
1065,
1026,
999,
1011,
1011,
28667,
23395,
1011,
1011,
1028,
1026,
4130,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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>regexp-brzozowski: 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.7.0 / regexp-brzozowski - 1.0</a></li>
</ul>
</div>
</div>
</div>
<div class="article">
<div class="row">
<div class="col-md-12">
<a href="../..">« Up</a>
<h1>
regexp-brzozowski
<small>
1.0
<span class="label label-info">Not compatible 👼</span>
</small>
</h1>
<p>📅 <em><script>document.write(moment("2022-03-04 08:05:14 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2022-03-04 08:05:14 UTC)</em><p>
<h2>Context</h2>
<pre># Packages matching: installed
# Name # Installed # Synopsis
base-bigarray base
base-threads base
base-unix base
camlp5 7.14 Preprocessor-pretty-printer of OCaml
conf-findutils 1 Virtual package relying on findutils
conf-perl 2 Virtual package relying on perl
coq 8.7.0 Formal proof management system
num 1.4 The legacy Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.06.1 The OCaml compiler (virtual package)
ocaml-base-compiler 4.06.1 Official 4.06.1 release
ocaml-config 1 OCaml Switch Configuration
ocamlfind 1.9.3 A library manager for OCaml
# opam file:
opam-version: "2.0"
maintainer: "palmskog@gmail.com"
homepage: "https://github.com/coq-community/regexp-Brzozowski"
dev-repo: "git+https://github.com/coq-community/regexp-Brzozowski.git"
bug-reports: "https://github.com/coq-community/regexp-Brzozowski/issues"
license: "MIT"
synopsis: "Decision procedures for regular expression equivalence in Coq using Mathematical Components"
description: """
Coq library that formalizes decision procedures for regular
expression equivalence, using the Mathematical Components
library. The formalization builds on Brzozowski's derivatives
of regular expressions for correctness."""
build: [make "-j%{jobs}%"]
install: [make "install"]
depends: [
"coq" {>= "8.10"}
"coq-mathcomp-ssreflect" {>= "1.12.0"}
"coq-reglang" {>= "1.1.3"}
]
tags: [
"category:Computer Science/Decision Procedures and Certified Algorithms/Correctness proofs of algorithms"
"category:Computer Science/Formal Languages Theory and Automata"
"keyword:regular expressions"
"keyword:decision procedure"
"keyword:relation algebra"
"logpath:RegexpBrzozowski"
"date:2022-01-22"
]
authors: [
"Thierry Coquand"
"Vincent Siles"
]
url {
src: "https://github.com/coq-community/regexp-Brzozowski/archive/v1.0.tar.gz"
checksum: "sha512=bc837c5c76ec5e6751fcff7f00bf5fffbfb4ad53ca4212f259f2d61f61df65efd588c97fcb5ce45a6eec3e4f2339a2cf06ca1977d1d13569b0fec856d3522a02"
}
</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-regexp-brzozowski.1.0 coq.8.7.0</code></dd>
<dt>Return code</dt>
<dd>5120</dd>
<dt>Output</dt>
<dd><pre>[NOTE] Package coq is already installed (current version is 8.7.0).
The following dependencies couldn't be met:
- coq-regexp-brzozowski -> coq >= 8.10
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-regexp-brzozowski.1.0</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Install dependencies</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Install 🚀</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Installation size</h2>
<p>No files were installed.</p>
<h2>Uninstall 🧹</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Missing removes</dt>
<dd>
none
</dd>
<dt>Wrong removes</dt>
<dd>
none
</dd>
</dl>
</div>
</div>
</div>
<hr/>
<div class="footer">
<p class="text-center">
Sources are on <a href="https://github.com/coq-bench">GitHub</a> © Guillaume Claret 🐣
</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../../../../bootstrap.min.js"></script>
</body>
</html>
| coq-bench/coq-bench.github.io | clean/Linux-x86_64-4.06.1-2.0.5/released/8.7.0/regexp-brzozowski/1.0.html | HTML | mit | 7,435 | [
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... |
module OAWidget
module Preserver
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
# Preserve ivars between widgets, rendering and ajax calls
# example:
# class MyWidget < OAWidget
# preserves_attr :page, :from => '../content'
# preserves_attr :display
# ...
# end
#
# Usage:
# preserves_attr :attribute_name [, OPTIONS]
#
# By default it will preserve the attribute_name from the parent.
# That is, the parent is responsible for having the right getter/setter for the attribute
#
# OPTIONS:
# :from => String, a relative path to the widget from which we must sync the param
# example: preserves_attr :page, :from => '../pager'
#
def preserves_attr(*attrs)
@preserved_vars ||= []
@preserved_vars << attrs
end
def preserved_vars
@preserved_vars
end
end # ClassMethods
def preserves_attrs(attrs=nil)
return if attrs.blank?
attrs.each do |attribute|
self.class.preserves_attr attribute
end
end
def preserved_params(*except)
return {} if self.class.preserved_vars.nil?
params_hash = {}
self.class.preserved_vars.each do |ivar, options|
value = self.instance_variable_get("@#{ivar}")
# RAILS_DEFAULT_LOGGER.debug("(#{self.name}) export to params: #{ivar} = #{value}")
params_hash.merge!(ivar => self.instance_variable_get("@#{ivar}"))
end
except.each {|e| params_hash.delete(e)}
params_hash
end
def preserved_attrs
return if self.class.preserved_vars.nil?
self.class.preserved_vars.each do |ivar, options|
options ||= {}
managing_widget = options.include?(:from) ? self.widget_from_path(options[:from]) : self.parent
next if managing_widget.nil?
if param(ivar)
# RAILS_DEFAULT_LOGGER.debug("(#{self.name}) [PARAMS]: setting #{ivar} = #{param(ivar)} on widget: #{managing_widget.name}")
# push the value to the widget managing it
managing_widget.instance_variable_set("@#{ivar}", param(ivar))
end
# get the value of a preserved attr from the widget managing it
value = managing_widget.instance_variable_get("@#{ivar}")
if value.blank?
if (options[:default])
value = options[:default]
managing_widget.instance_variable_set("@#{ivar}", value)
end
end
# RAILS_DEFAULT_LOGGER.debug("(#{self.name}) [NOPARAMS]: setting #{ivar} = #{value} on widget: #{self.name}") unless (param(ivar))
self.instance_variable_set("@#{ivar}", value)
end
end
# Search for the widget identified by its id in the specified relative path
# example:
# self.widget_from_path('../content') will look for the child widget named 'content' of the parent widget of self
def widget_from_path(relative_path)
raise 'relative_path must be a string' unless relative_path.class == String
raise 'relative_path should not start with / (hence "relative")' if relative_path =~ /^\//
path_components = relative_path.split(/\//)
path_components.shift if path_components[0] == '.'
# RAILS_DEFAULT_LOGGER.debug("starting search at self: #{self.name}, self.parent: #{self.parent.name}, self.root: #{self.root.name}")
start = self
while path_components[0] == '..'
# RAILS_DEFAULT_LOGGER.debug("path components: #{path_components.to_json}")
start = self.parent
path_components.shift
end
path_components.each do |w|
# RAILS_DEFAULT_LOGGER.debug("start: #{start.name}")
break if start.nil?
start = start.find_widget(w)
end
start
end
end # module OAPreserver
end | Orion98MC/oa_widget | lib/oa_widget/preserver.rb | Ruby | mit | 3,948 | [
30522,
11336,
1051,
10376,
13623,
2102,
11336,
7969,
2099,
13366,
2969,
1012,
2443,
1006,
2918,
1007,
2918,
1012,
7949,
1006,
2465,
11368,
6806,
5104,
1007,
2203,
11336,
2465,
11368,
6806,
5104,
1001,
7969,
4921,
11650,
2090,
15536,
28682,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 "code.h"
/**
* Returns whether or not the Code is a termination code.
*/
int is_termination_code(const Code code) { return code == CODE_QUIT || code == CODE_CLOSE; }
| walls-of-doom/walls-of-doom | walls-of-doom/code.c | C | bsd-3-clause | 178 | [
30522,
1001,
2421,
1000,
3642,
1012,
1044,
1000,
1013,
1008,
1008,
1008,
5651,
3251,
2030,
2025,
1996,
3642,
2003,
1037,
18287,
3642,
1012,
1008,
1013,
20014,
2003,
1035,
18287,
1035,
3642,
1006,
9530,
3367,
3642,
3642,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 demo;
import org.apache.geode.spark.connector.GeodeConnectionConf;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.PairFunction;
import scala.Tuple2;
import java.util.ArrayList;
import java.util.List;
import static org.apache.geode.spark.connector.javaapi.GeodeJavaUtil.*;
/**
* This Spark application demonstrates how to save a RDD to Geode using Geode Spark
* Connector with Java.
* <p/>
* In order to run it, you will need to start Geode cluster, and create the following region
* with GFSH:
* <pre>
* gfsh> create region --name=str_int_region --type=REPLICATE \
* --key-constraint=java.lang.String --value-constraint=java.lang.Integer
* </pre>
*
* Once you compile and package the demo, the jar file basic-demos_2.10-0.5.0.jar
* should be generated under geode-spark-demos/basic-demos/target/scala-2.10/.
* Then run the following command to start a Spark job:
* <pre>
* <path to spark>/bin/spark-submit --master=local[2] --class demo.RDDSaveJavaDemo \
* <path to>/basic-demos_2.10-0.5.0.jar <locator host>:<port>
* </pre>
*
* Verify the data was saved to Geode with GFSH:
* <pre>gfsh> query --query="select * from /str_int_region.entrySet" </pre>
*/
public class RDDSaveJavaDemo {
public static void main(String[] argv) {
if (argv.length != 1) {
System.err.printf("Usage: RDDSaveJavaDemo <locators>\n");
return;
}
SparkConf conf = new SparkConf().setAppName("RDDSaveJavaDemo");
conf.set(GeodeLocatorPropKey, argv[0]);
JavaSparkContext sc = new JavaSparkContext(conf);
List<String> data = new ArrayList<String>();
data.add("abcdefg");
data.add("abcdefgh");
data.add("abcdefghi");
JavaRDD<String> rdd = sc.parallelize(data);
GeodeConnectionConf connConf = GeodeConnectionConf.apply(conf);
PairFunction<String, String, Integer> func = new PairFunction<String, String, Integer>() {
@Override public Tuple2<String, Integer> call(String s) throws Exception {
return new Tuple2<String, Integer>(s, s.length());
}
};
javaFunctions(rdd).saveToGeode("str_int_region", func, connConf);
sc.stop();
}
}
| prasi-in/geode | geode-spark-connector/geode-spark-demos/basic-demos/src/main/java/demo/RDDSaveJavaDemo.java | Java | apache-2.0 | 3,078 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
1008,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
1008,
2023,
2147,
2005,
3176,
2592,
4953,
9385,
6095,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>CQRS.NET: Cqrs.Azure.BlobStorage.Events.BlobStorageEventStore.Get</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" async="async" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="ChinChilla-Software-Red.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">CQRS.NET
 <span id="projectnumber">4.1</span>
</div>
<div id="projectbrief">A lightweight enterprise Function as a Service (FaaS) framework to write function based serverless and micro-service applications in hybrid multi-datacentre, on-premise and Azure environments.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classCqrs_1_1Azure_1_1BlobStorage_1_1Events_1_1BlobStorageEventStore_ab68b594c54ae5a79e3b8d5db1902752d.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="contents">
<a id="ab68b594c54ae5a79e3b8d5db1902752d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab68b594c54ae5a79e3b8d5db1902752d">◆ </a></span>Get() <span class="overload">[2/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">override IEnumerable<<a class="el" href="interfaceCqrs_1_1Events_1_1IEvent.html">IEvent</a><TAuthenticationToken> > <a class="el" href="classCqrs_1_1Azure_1_1BlobStorage_1_1Events_1_1BlobStorageEventStore.html">Cqrs.Azure.BlobStorage.Events.BlobStorageEventStore</a>< TAuthenticationToken >.Get </td>
<td>(</td>
<td class="paramtype">Type </td>
<td class="paramname"><em>aggregateRootType</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">Guid </td>
<td class="paramname"><em>aggregateId</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool </td>
<td class="paramname"><em>useLastEventOnly</em> = <code>false</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>fromVersion</em> = <code>-1</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets a collection of IEvent<TAuthenticationToken> for the IAggregateRoot<TAuthenticationToken> of type <em>aggregateRootType</em> with the ID matching the provided <em>aggregateId</em> . </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">aggregateRootType</td><td>Type of the IAggregateRoot<TAuthenticationToken> the IEvent<TAuthenticationToken> was raised in.</td></tr>
<tr><td class="paramname">aggregateId</td><td>The IAggregateRoot<TAuthenticationToken>.Id of the IAggregateRoot<TAuthenticationToken>.</td></tr>
<tr><td class="paramname">useLastEventOnly</td><td>Loads only the last eventIEvent<TAuthenticationToken>.</td></tr>
<tr><td class="paramname">fromVersion</td><td>Load events starting from this version</td></tr>
</table>
</dd>
</dl>
<p>Implements <a class="el" href="classCqrs_1_1Events_1_1EventStore_aa1d0d399a35c1e3b0759e27202695d8b.html#aa1d0d399a35c1e3b0759e27202695d8b">Cqrs.Events.EventStore< TAuthenticationToken ></a>.</p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="namespaceCqrs.html">Cqrs</a></li><li class="navelem"><a class="el" href="namespaceCqrs_1_1Azure.html">Azure</a></li><li class="navelem"><a class="el" href="namespaceCqrs_1_1Azure_1_1BlobStorage.html">BlobStorage</a></li><li class="navelem"><a class="el" href="namespaceCqrs_1_1Azure_1_1BlobStorage_1_1Events.html">Events</a></li><li class="navelem"><a class="el" href="classCqrs_1_1Azure_1_1BlobStorage_1_1Events_1_1BlobStorageEventStore.html">BlobStorageEventStore</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.16 </li>
</ul>
</div>
</body>
</html>
| cdmdotnet/CQRS | wiki/docs/4.1/html/classCqrs_1_1Azure_1_1BlobStorage_1_1Events_1_1BlobStorageEventStore_ab68b594c54ae5a79e3b8d5db1902752d.html | HTML | lgpl-2.1 | 7,854 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1000,
16770,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#pragma once
#ifndef _UTIL_OGRE_
#define _UTIL_OGRE_
namespace util
{
/// <summary> Creates a new material based on the information given, this can then be used by entities. </summary>
/// <param name="materialName"> The name the material should be referenced by. </param>
/// <param name="textureName"> The name of the texture file to apply to the material. </param>
void createMaterial (const Ogre::String& materialName, const Ogre::String& textureName);
}
#endif // _UTIL_OGRE_ | storm20200/UniversityAnimationSimulation | Project/OgreTutorialFramework_2014/src/Utility/Ogre.h | C | unlicense | 501 | [
30522,
1001,
10975,
8490,
2863,
2320,
1001,
2065,
13629,
2546,
1035,
21183,
4014,
1035,
13958,
2890,
1035,
1001,
9375,
1035,
21183,
4014,
1035,
13958,
30524,
12654,
1028,
9005,
1037,
2047,
3430,
2241,
2006,
1996,
2592,
2445,
1010,
2023,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace Google\Service\SQLAdmin;
class BackupConfiguration extends \Google\Model
{
protected $backupRetentionSettingsType = BackupRetentionSettings::class;
protected $backupRetentionSettingsDataType = '';
/**
* @var bool
*/
public $binaryLogEnabled;
/**
* @var bool
*/
public $enabled;
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $location;
/**
* @var bool
*/
public $pointInTimeRecoveryEnabled;
/**
* @var bool
*/
public $replicationLogArchivingEnabled;
/**
* @var string
*/
public $startTime;
/**
* @var int
*/
public $transactionLogRetentionDays;
/**
* @param BackupRetentionSettings
*/
public function setBackupRetentionSettings(BackupRetentionSettings $backupRetentionSettings)
{
$this->backupRetentionSettings = $backupRetentionSettings;
}
/**
* @return BackupRetentionSettings
*/
public function getBackupRetentionSettings()
{
return $this->backupRetentionSettings;
}
/**
* @param bool
*/
public function setBinaryLogEnabled($binaryLogEnabled)
{
$this->binaryLogEnabled = $binaryLogEnabled;
}
/**
* @return bool
*/
public function getBinaryLogEnabled()
{
return $this->binaryLogEnabled;
}
/**
* @param bool
*/
public function setEnabled($enabled)
{
$this->enabled = $enabled;
}
/**
* @return bool
*/
public function getEnabled()
{
return $this->enabled;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setLocation($location)
{
$this->location = $location;
}
/**
* @return string
*/
public function getLocation()
{
return $this->location;
}
/**
* @param bool
*/
public function setPointInTimeRecoveryEnabled($pointInTimeRecoveryEnabled)
{
$this->pointInTimeRecoveryEnabled = $pointInTimeRecoveryEnabled;
}
/**
* @return bool
*/
public function getPointInTimeRecoveryEnabled()
{
return $this->pointInTimeRecoveryEnabled;
}
/**
* @param bool
*/
public function setReplicationLogArchivingEnabled($replicationLogArchivingEnabled)
{
$this->replicationLogArchivingEnabled = $replicationLogArchivingEnabled;
}
/**
* @return bool
*/
public function getReplicationLogArchivingEnabled()
{
return $this->replicationLogArchivingEnabled;
}
/**
* @param string
*/
public function setStartTime($startTime)
{
$this->startTime = $startTime;
}
/**
* @return string
*/
public function getStartTime()
{
return $this->startTime;
}
/**
* @param int
*/
public function setTransactionLogRetentionDays($transactionLogRetentionDays)
{
$this->transactionLogRetentionDays = $transactionLogRetentionDays;
}
/**
* @return int
*/
public function getTransactionLogRetentionDays()
{
return $this->transactionLogRetentionDays;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
class_alias(BackupConfiguration::class, 'Google_Service_SQLAdmin_BackupConfiguration');
| googleapis/google-api-php-client-services | src/SQLAdmin/BackupConfiguration.php | PHP | apache-2.0 | 3,849 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
9385,
2297,
8224,
4297,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
2025,
1008,
2224,
2023,
5371,
3272,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**************************************************************************
*
* Copyright 2011-2015 by Andrey Butok. FNET Community.
* Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
*
***************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License Version 3
* or later (the "LGPL").
*
* As a special exception, the copyright holders of the FNET project give you
* permission to link the FNET sources with independent modules to produce an
* executable, regardless of the license terms of these independent modules,
* and to copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent module,
* the terms and conditions of the license of that module.
* An independent module is a module which is not derived from or based
* on this library.
* If you modify the FNET sources, you may extend this exception
* to your version of the FNET sources, but you are not obligated
* to do so. If you do not wish to do so, delete this
* exception statement from your 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.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
**********************************************************************/ /*!
*
* @file fnet_fs.h
*
* @author Andrey Butok
*
* @brief FNET File System API.
*
***************************************************************************/
#ifndef _FNET_FS_H_
#define _FNET_FS_H_
#include "fnet_config.h"
#if FNET_CFG_FS || defined(__DOXYGEN__)
/*! @addtogroup fnet_fs
* The FNET File System (FS) API provides standard interface for
* file and directory manipulations. @n
* The FNET File System API is inspired by standard ANSI C and POSIX-based APIs. @n
*
* The following table summarizes the supported File System API functions:
* <table>
* <caption>File System API</caption>
* <tr class="fnet_td_grey">
* <th ALIGN=CENTER>Functions</th><th ALIGN=CENTER>Description</th>
* </tr>
* <tr>
* <td>@ref fnet_fs_init(), @ref fnet_fs_release()</td>
* <td>FNET file system interface initialization/release.</td>
* </tr>
* <tr>
* <td>@ref fnet_fs_mount(), @ref fnet_fs_unmount()</td>
* <td>Mount/unmount a file system image.</td>
* </tr>
* <tr>
* <td>@ref fnet_fs_fopen(), @ref fnet_fs_fopen_re(), fnet_fs_fclose()</td>
* <td>Open/close a file.</td>
* </tr>
* <tr>
* <td>@ref fnet_fs_fread(), @ref fnet_fs_fgetc()</td>
* <td>Read a file.</td>
* </tr>
* <tr>
* <td>@ref fnet_fs_rewind(), @ref fnet_fs_fseek(), @ref fnet_fs_feof(), @ref fnet_fs_ftell()</td>
* <td>Move/get a file pointer.</td>
* </tr>
* <tr>
* <td>@ref fnet_fs_opendir(), @ref fnet_fs_closedir()</td>
* <td>Open/close a directory.</td>
* </tr>
* <tr>
* <td>@ref fnet_fs_readdir(), @ref fnet_fs_rewinddir()</td>
* <td>Read a directory.</td>
* </tr>
* </table>
*
* The path name that points to a file or directory has the following format:@n
* @verbatim /[mount name][/directory name]..[/file name] @endverbatim
*
* @n
* After the FS is initialized by calling the @ref fnet_fs_init()
* function, a user application should call a FS registration
* function (for example the @ref fnet_fs_rom_register() for the FNET ROM FS registration), and
* finally mount a FS image by the @ref fnet_fs_mount() function. Thereafter
* an application has access to files and directories on the mounted FS image.
*
* For example:
* @code
* ...
* // FNET FS initialization.
* if( fnet_fs_init( ) == FNET_OK)
* {
* // Register ROM FS.
* fnet_fs_rom_register( );
*
* // Mount ROM FS image.
* if( fnet_fs_mount( FNET_FS_ROM_NAME, "rom", (void *)&fnet_fs_image ) == FNET_ERR )
* fnet_println("ERROR: FS image mount is failed!");
* ...
*
* // Print directory content.
* {
* struct fnet_fs_dirent ep;
* FNET_FS_DIR dir;
* char name[FNET_CFG_FS_MOUNT_NAME_MAX+1];
*
* // Open dir.
* dir = fnet_fs_opendir("\rom");
*
* if (dir)
* {
* fnet_memset(&ep, 0, sizeof(struct fnet_fs_dirent) );
* ep.d_name = name;
* ep.d_name_size = sizeof(name);
*
* // Print the dir content.
* while ((fnet_fs_readdir (dir, &ep))==FNET_OK)
* fnet_println ("%7s - %s", (ep.d_type == DT_DIR)?"<DIR>":"<FILE>",ep.d_name);
*
* // Close dir.
* fnet_fs_closedir(dir);
* }
* else
* fnet_println("ERROR: The directory is failed!");
* }
* ...
* }
* else
* {
* fnet_println("ERROR: FNET FS initialization is failed!");
* }
* ...
* @endcode
* @n
* Configuration parameters:
* - @ref FNET_CFG_FS
* - @ref FNET_CFG_FS_MOUNT_MAX
* - @ref FNET_CFG_FS_MOUNT_NAME_MAX
* - @ref FNET_CFG_FS_DESC_MAX
*/
/** @{ */
/**************************************************************************/ /*!
* @brief Directory descriptor. @n
* This is the abstract key for accessing a directory.
******************************************************************************/
typedef void * FNET_FS_DIR;
/**************************************************************************/ /*!
* @brief File descriptor. @n
* This is the abstract key for accessing a file.
******************************************************************************/
typedef void * FNET_FS_FILE;
/**************************************************************************/ /*!
* @brief File-path splitter. @n
* This symbol is used to delimit directories and files in a pathname string.
******************************************************************************/
#define FNET_FS_SPLITTER '/'
/**************************************************************************/ /*!
* @brief End-of-file condition. @n
* This is a condition, where no data can be read from a data source.
******************************************************************************/
#define FNET_FS_EOF (-1)
/**************************************************************************/ /*!
* @brief Origin position. @n
* Used by @ref fnet_fs_fseek() function.
*
* @see fnet_fs_fseek()
******************************************************************************/
typedef enum
{
FNET_FS_SEEK_SET = 0, /**< @brief Origin is the start of the file.*/
FNET_FS_SEEK_CUR, /**< @brief Origin is the current position. */
FNET_FS_SEEK_END /**< @brief Origin is the end of the file. */
}
fnet_fs_seek_origin_t;
/**************************************************************************/ /*!
* @brief Directory entry type.
* @see fnet_fs_dirent
******************************************************************************/
typedef enum
{
DT_UNKNOWN = 0, /**< @brief Unspecified. */
DT_REG, /**< @brief A regular file. */
DT_DIR /**< @brief A directory. */
} fnet_fs_d_type_t;
/**************************************************************************/ /*!
* @brief This structure is used by the @ref fnet_fs_finfo() and
* the @ref fnet_fs_readdir() function to
* get information about directory entries (files or directories).
* @see fnet_fs_readdir(), fnet_fs_finfo()
******************************************************************************/
struct fnet_fs_dirent
{
unsigned long d_ino; /**< @brief Entry serial number. */
fnet_fs_d_type_t d_type; /**< @brief Type of the entry defined by
* the @ref fnet_fs_d_type_t.*/
const char *d_name; /**< @brief Name of the entry (null-terminated
* string).*/
unsigned long d_size; /**< @brief Size of the file entry. @n
* If the entry is a directory this field is set to @c 0.*/
};
/***************************************************************************/ /*!
*
* @brief Initializes the FNET File System Interface.
*
* @return This function returns:
* - @ref FNET_OK if no error occurs.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_release()
*
******************************************************************************
*
* This function executes the initialization of the File System interface. @n
* Only after a successful initialization the application may use FNET FS API
* functions.
*
******************************************************************************/
int fnet_fs_init(void);
/***************************************************************************/ /*!
*
* @brief Releases the FNET File System Interface.
*
* @see fnet_fs_init()
*
******************************************************************************
*
* This function releases the NET File System Interface.
*
******************************************************************************/
void fnet_fs_release(void);
/***************************************************************************/ /*!
*
* @brief Mounts a file system.
*
* @param fs_name File System name associated with the mount point
* (null-terminated string). @n
* For the FNET ROM FS this parameter
* should be set to the @ref FNET_FS_ROM_NAME value.
*
* @param mount_name Mount point name (null-terminated string). @n
* The name size must not exceed the
* @ref FNET_CFG_FS_MOUNT_NAME_MAX value.
*
* @param arg Pointer to the FS-specific mount argument.@n
* For the FNET ROM FS this parameter is the pointer to
* the @ref fnet_fs_rom_image structure.
*
*
* @return This function returns:
* - @ref FNET_OK if no error occurs.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_unmount()
*
******************************************************************************
*
* This function instructs FNET File System interface that the file system
* named by the @c fs_name is associated with a
* mount point named by the @c mount_name and is ready to use.
*
******************************************************************************/
int fnet_fs_mount( char *fs_name, const char *mount_name, const void *arg );
/***************************************************************************/ /*!
*
* @brief Unmounts a file system.
*
* @param mount_name Mount point name (null-terminated string).
*
* @return This function returns:
* - @ref FNET_OK if no error occurs.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_mount()
*
******************************************************************************
*
* This function instructs the FNET File System interface that the file
* system should be disassociated from its mount point named by the
* @c mount_name making it no longer accessible.
*
******************************************************************************/
int fnet_fs_unmount( const char *mount_name );
/***************************************************************************/ /*!
*
* @brief Opens a directory descriptor.
*
* @param dirname The directory pathname.
*
* @return This function returns:
* - Directory descriptor if no error occurs.
* - @c 0 if an error occurs.
*
* @see fnet_fs_closedir(),
*
******************************************************************************
*
* This function opens and returns a directory descriptor corresponding
* to the directory named by the @c dirname.
*
******************************************************************************/
FNET_FS_DIR fnet_fs_opendir( const char *dirname);
/***************************************************************************/ /*!
*
* @brief Closes a directory descriptor.
*
* @param dir Directory descriptor to be closed.
*
* @return This function returns:
* - @ref FNET_OK if no error occurs.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_opendir()
*
******************************************************************************
*
* This function closes the directory descriptor reffered to by the @c dir.
*
******************************************************************************/
int fnet_fs_closedir( FNET_FS_DIR dir);
/***************************************************************************/ /*!
*
* @brief Reads a directory entry.
*
* @param dir Directory descriptor.
*
* @param dirent Pointer to the entry information structure.
*
* @return This function returns:
* - @ref FNET_OK if no error occurs.
* - @ref FNET_ERR if an error occurs or end of directory stream is reached.
*
* @see fnet_fs_opendir(), fnet_fs_rewinddir(), fnet_fs_finfo()
*
******************************************************************************
*
* This function fills the @c dirent structure representing the directory
* entry at the current position and increments the position to the next entry.@n
* When the end of the directory is encountered, the @ref FNET_ERR is returned.@n
* The function reads directory entries in sequence. All items in the directory
* can be read by calling the @ref fnet_fs_readdir() function repeatedly.@n
*
******************************************************************************/
int fnet_fs_readdir(FNET_FS_DIR dir, struct fnet_fs_dirent* dirent);
/***************************************************************************/ /*!
*
* @brief Resets a directory position.
*
* @param dir Directory descriptor.
*
* @see fnet_fs_readdir()
*
******************************************************************************
*
* This function resets the position of the directory descriptor @c dir to
* the beginning of the directory, so that if the @ref fnet_fs_readdir()
* function will be called it returns information about the first
* entry in the directory again.
*
******************************************************************************/
void fnet_fs_rewinddir( FNET_FS_DIR dir );
/***************************************************************************/ /*!
*
* @brief Opens a file descriptor.
*
* @param filename The file pathname (null-terminated string).
*
* @param mode String containing a file access modes. It can be:
* - "r" = open a file for reading. The file must exist.
* - "w" = create an empty file for writing. If a file with
* the same name already exists its content is erased
* and the file is treated as a new empty file.@n @n
* The current version of FS API des not support this mode.
* - "a" = append to a file. Writing operations append data
* at the end of the file. The file is created if
* it does not exist.@n @n
* The current version of FS API des not support this mode.
* - "r+" = open a file for update for both reading and writing.
* The file must exist.@n @n
* The current version of FS API does not support this mode.
* - "w+" = create an empty file for both reading and writing.
* If a file with the same name already exists its
* content is erased and the file is treated as a
* new empty file.@n @n
* The current version of FS API does not support this mode.
* - "a+" = open a file for reading and appending. All
* writing operations are performed at the end
* of the file. The initial file position for
* reading is at the beginning of the file, but output
* is always appended to the end of the file. The file
* is created if it does not exist.@n @n
* The current version of FS API does not support this mode.
*
* @return This function returns:
* - File descriptor @ref FNET_FS_FILE if no error occurs.
* - @c 0 if an error occurs.
*
* @see fnet_fs_fopen_re(), fnet_fs_fclose()
*
******************************************************************************
*
* This function opens the file, whose pathname is specified by the @c filename, and
* associates it with a returned file descriptor. @n
* The operations that are allowed on the file, and how these are performed,
* is defined by the @c mode parameter.@n
* NOTE: The current version of FS API supports the reading mode only.
*
******************************************************************************/
FNET_FS_FILE fnet_fs_fopen(const char *filename, const char *mode);
/***************************************************************************/ /*!
*
* @brief Opens a file relatively in an opened directory.
*
* @param filename File pathnamem, which is relative to the @c dir directory
* (null-terminated string).
*
* @param mode String containing a file access modes. It can be:
* - "r" = open a file for reading. The file must exist.
* - "w" = create an empty file for writing. If a file with
* the same name already exists its content is erased
* and the file is treated as a new empty file.@n @n
* The current version of FS API des not support this mode.
* - "a" = append to a file. Writing operations append data
* at the end of the file. The file is created if
* it does not exist.@n @n
* The current version of FS API des not support this mode.
* - "r+" = open a file for update for both reading and writing.
* The file must exist.@n @n
* The current version of FS API does not support this mode.
* - "w+" = create an empty file for both reading and writing.
* If a file with the same name already exists its
* content is erased and the file is treated as a
* new empty file.@n @n
* The current version of FS API does not support this mode.
* - "a+" = open a file for reading and appending. All
* writing operations are performed at the end
* of the file. The initial file position for
* reading is at the beginning of the file, but output
* is always appended to the end of the file. The file
* is created if it does not exist.@n @n
* The current version of FS API does not support this mode.
*
* @param dir Directory descriptor.
*
* @return This function returns:
* - File descriptor if no error occurs.
* - @c 0 if an error occurs.
*
* @see fnet_fs_fopen(), fnet_fs_fclose()
*
******************************************************************************
*
* This function opens the file whose pathname is specified by the @c filename,
* which is relative to the directory @c dir, and associates
* it with a returned file descriptor. @n
* The operations that are allowed on the file and how these are performed
* are defined by the @c mode parameter.@n
* NOTE: The current version of FS API supports the reading mode only.
*
******************************************************************************/
FNET_FS_FILE fnet_fs_fopen_re(const char *filename, const char *mode, FNET_FS_FILE dir);
/***************************************************************************/ /*!
*
* @brief Closes a file descriptor.
*
* @param file File descriptor to be closed.
*
* @return This function returns:
* - @ref FNET_OK if no error occurs.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_fopen(), fnet_fs_fopen_re()
*
******************************************************************************
*
* This function closes the file associated with the @c file descriptor
* and disassociates it.
*
******************************************************************************/
int fnet_fs_fclose(FNET_FS_FILE file);
/***************************************************************************/ /*!
*
* @brief Reads data from a file.
*
* @param buf Pointer to the buffer to store the read data.
*
* @param size Number of bytes to read.
*
* @param file File descriptor.
*
* @return This function returns:
* - The total number of bytes successfully read.
*
* @see fnet_fs_fgetc(), fnet_fs_rewind(), fnet_fs_feof()
*
******************************************************************************
*
* This function reads an array of bytes from the @c file and stores them
* in the block of memory specified by @c buf.@n
* The position indicator of the @c file descriptor is advanced by the
* total amount of bytes read.
*
******************************************************************************/
unsigned long fnet_fs_fread(void * buf, unsigned long size, FNET_FS_FILE file);
/***************************************************************************/ /*!
*
* @brief Resets a file position.
*
* @param file File descriptor.
*
* @see fnet_fs_fseek()
*
******************************************************************************
*
* This function sets the position indicator associated with the @c file
* descriptor to the beginning of the file.
*
******************************************************************************/
void fnet_fs_rewind( FNET_FS_FILE file );
/***************************************************************************/ /*!
*
* @brief Checks the End-of-File indicator.
*
* @param file File descriptor.
*
* @return This function returns:
* - @ref FNET_FS_EOF in the case that the End-of-File is set.
* - @c 0 in the case that the End-of-File is NOT set.
*
* @see fnet_fs_fread()
*
******************************************************************************
*
* This function checks, whether the End-of-File indicator associated with
* the @c file descriptor is set. @n
* This indicator is generally set by a previous operation on the @c file
* that reached the End-of-File. @n
* Further read operations on the @c file - once the End-of-File has been
* reached - will fail until either @ref fnet_fs_rewind() or @ref fnet_fs_fseek()
* is successfully called to set the position indicator to a new value.
*
******************************************************************************/
int fnet_fs_feof(FNET_FS_FILE file);
/***************************************************************************/ /*!
*
* @brief Gets a character from a file.
*
* @param file File descriptor.
*
* @return This function returns:
* - The character read is returned as an int value.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_fread()
*
******************************************************************************
*
* This function returns the character currently pointed to by the internal
* file position indicator of the specified @c file.@n
* The internal file position indicator is advanced by one character
* to point to the next character.
*
******************************************************************************/
int fnet_fs_fgetc(FNET_FS_FILE file);
/***************************************************************************/ /*!
*
* @brief Changes the file-position indicator for the specified file.
*
* @param file File descriptor, of which the position indicator should
* be changed.
*
* @param offset Specifies the number of bytes from @c origin,
* where the position indicator should be placed.
*
* @param origin Origin position defined by @ref fnet_fs_seek_origin_t.
*
* @return This function returns:
* - @ref FNET_OK if no error occurs.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_ftell()
*
******************************************************************************
*
* This function sets the position indicator associated with the @c file
* descriptor to a new position defined by adding @c offset to a reference
* position specified by @c origin.
*
******************************************************************************/
int fnet_fs_fseek (FNET_FS_FILE file, long offset, int origin);
/***************************************************************************/ /*!
*
* @brief Gets the current position in a file.
*
* @param file File descriptor.
*
* @return This function returns:
* - The current value of the position indicator if no error occurs.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_fseek()
*
******************************************************************************
*
* This function returns the current value of the position indicator of
* the @c file. The returned value corresponds to the number of bytes
* from the beginning of the file.
*
******************************************************************************/
long fnet_fs_ftell (FNET_FS_FILE file);
/***************************************************************************/ /*!
*
* @brief Gets a file information.
*
* @param file File descriptor.
*
* @param dirent Pointer to the entry/file information structure.
*
* @return This function returns:
* - @ref FNET_OK if no error occurs.
* - @ref FNET_ERR if an error occurs.
*
* @see fnet_fs_readdir(), fnet_fs_fopen()
*
******************************************************************************
*
* This function fills the @c dirent structure with information about the @c file.
* The information is defined by the @ref fnet_fs_dirent structure.
*
******************************************************************************/
int fnet_fs_finfo (FNET_FS_FILE file, struct fnet_fs_dirent *dirent);
/*! @} */
#endif /* FNET_CFG_FS */
#endif /* _FNET_FS_H_ */
| EdizonTN/FNET-NXPLPC | fnet_stack/services/fs/fnet_fs.h | C | lgpl-3.0 | 26,750 | [
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... |
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-user',
template: '<router-outlet></router-outlet>'
})
export class UserComponent implements OnInit {
constructor(public router: Router) { }
ngOnInit() {
if (this.router.url === '/user') {
this.router.navigate(['/dashboard']);
}
}
} | ahmelessawy/Hospital-Dashboard | Client/src/app/layouts/user/user.component.ts | TypeScript | mit | 402 | [
30522,
12324,
1063,
6922,
1010,
2006,
5498,
2102,
1065,
2013,
1005,
1030,
16108,
1013,
4563,
1005,
1025,
12324,
1063,
2799,
2099,
1065,
2013,
1005,
1030,
16108,
1013,
2799,
2099,
1005,
1025,
1030,
6922,
1006,
1063,
27000,
1024,
1005,
10439,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 lejos.robotics.mapping;
import java.io.*;
import java.util.ArrayList;
import lejos.geom.Line;
import lejos.geom.Rectangle;
/*
* WARNING: THIS CLASS IS SHARED BETWEEN THE classes AND pccomms PROJECTS.
* DO NOT EDIT THE VERSION IN pccomms AS IT WILL BE OVERWRITTEN WHEN THE PROJECT IS BUILT.
*/
/**
* <p>This class loads map data from a Shapefile and produces a LineMap object, which can
* be used by the leJOS navigation package.</p>
*
* <p>There are many map editors which can use the Shapefile format (OpenEV, Global Mapper). Once you
* have created a map, export it as Shapefile. This will produce three files ending in .shp .shx and
* .dbf. The only file used by this class is .shp.</p>
*
* <p>NOTE: Shapefiles can only contain one type of shape data (polygon or polyline, not both). A single file can't
* mix polylines with polygons.</p>
*
* <p>This class' code can parse points and multipoints. However, a LineMap object can't deal with
* points (only lines) so points and multipoints are discarded.</p>
*
* @author BB
*
*/
public class ShapefileLoader {
/* OTHER POTENTIAL MAP FILE FORMATS TO ADD:
* (none have really been researched yet for viability)
* KML
* GML
* WMS? (more of a service than a file)
* MIF/MID (MapInfo)
* SVG (Scalable Vector Graphics)
* EPS (Encapsulated Post Script)
* DXF (Autodesk)
* AI (Adobe Illustrator)
*
*/
// 2D shape types types:
private static final byte NULL_SHAPE = 0;
private static final byte POINT = 1;
private static final byte POLYLINE = 3;
private static final byte POLYGON = 5;
private static final byte MULTIPOINT = 8;
private final int SHAPEFILE_ID = 0x0000270a;
DataInputStream data_is = null;
/**
* Creates a ShapefileLoader object using an input stream. Likely you will use a FileInputStream
* which points to the *.shp file containing the map data.
* @param in
*/
public ShapefileLoader(InputStream in) {
this.data_is = new DataInputStream(in);
}
/**
* Retrieves a LineMap object from the Shapefile input stream.
* @return the line map
* @throws IOException
*/
public LineMap readLineMap() throws IOException {
ArrayList <Line> lines = new ArrayList <Line> ();
int fileCode = data_is.readInt(); // Big Endian
if(fileCode != SHAPEFILE_ID) throw new IOException("File is not a Shapefile");
data_is.skipBytes(20); // Five int32 unused by Shapefile
/*int fileLength =*/ data_is.readInt();
//System.out.println("Length: " + fileLength); // TODO: Docs say length is in 16-bit words. Unsure if this is strictly correct. Seems higher than what hex editor shows.
/*int version =*/ readLEInt();
//System.out.println("Version: " + version);
/*int shapeType =*/ readLEInt();
//System.out.println("Shape type: " + shapeType);
// These x and y min/max values define bounding rectangle:
double xMin = readLEDouble();
double yMin = readLEDouble();
double xMax = readLEDouble();
double yMax = readLEDouble();
// Create bounding rectangle:
Rectangle rect = new Rectangle((float)xMin, (float)yMin, (float)(xMax - xMin), (float)(yMax - yMin));
/*double zMin =*/ readLEDouble();
/*double zMax =*/ readLEDouble();
/*double mMin =*/ readLEDouble();
/*double mMax =*/ readLEDouble();
// TODO These values seem to be rounded down to nearest 0.5. Must round them up?
//System.out.println("Xmin " + xMin + " Ymin " + yMin);
//System.out.println("Xmax " + xMax + " Ymax " + yMax);
try { // TODO: This is a cheesy way to detect EOF condition. Not very good coding.
while(2 > 1) { // TODO: Temp code to keep it looping. Should really detect EOF condition.
// NOW ONTO READING INDIVIDUAL SHAPES:
// Record Header (2 values):
/*int recordNum =*/ data_is.readInt();
int recordLen = data_is.readInt(); // TODO: in 16-bit words. Might cause bug if number of shapes gets bigger than 16-bit short?
// Record (variable length depending on shape type):
int recShapeType = readLEInt();
// Now to read the actual shape data
switch (recShapeType) {
case NULL_SHAPE:
break;
case POINT:
// DO WE REALLY NEED TO DEAL WITH POINT? Feature might use them possibly.
/*double pointX =*/ readLEDouble(); // TODO: skip bytes instead
/*double pointY =*/ readLEDouble();
break;
case POLYLINE:
// NOTE: Data structure for polygon/polyline is identical. Code should work for both.
case POLYGON:
// Polygons can contain multiple polygons, such as a donut with outer ring and inner ring for hole.
// Max bounding rect: 4 doubles in a row. TODO: Discard bounding rect. values and skip instead.
/*double polyxMin =*/ readLEDouble();
/*double polyyMin =*/ readLEDouble();
/*double polyxMax =*/ readLEDouble();
/*double polyyMax =*/ readLEDouble();
int numParts = readLEInt();
int numPoints = readLEInt();
// Retrieve array of indexes for each part in the polygon
int [] partIndex = new int[numParts];
for(int i=0;i<numParts;i++) {
partIndex[i] = readLEInt();
}
// Now go through numParts times pulling out points
double firstX=0;
double firstY=0;
for(int i=0;i<numPoints-1;i++) {
// Could check here if onto new polygon (i = next index). If so, do something with line formation.
for(int j=0;j<numParts;j++) {
if(i == partIndex[j]) {
firstX = readLEDouble();
firstY = readLEDouble();
continue;
}
}
double secondX = readLEDouble();
double secondY = readLEDouble();
Line myLine = new Line((float)firstX, (float)firstY, (float)secondX, (float)secondY);
lines.add(myLine);
firstX = secondX;
firstY = secondY;
}
break;
case MULTIPOINT:
// TODO: DO WE REALLY NEED TO DEAL WITH MULTIPOINT? Comment out and skip bytes?
/*double multixMin = */readLEDouble();
/*double multiyMin = */readLEDouble();
/*double multixMax = */readLEDouble();
/*double multiyMax = */readLEDouble();
int multiPoints = readLEInt();
double [] xVals = new double[multiPoints];
double [] yVals = new double[multiPoints];
for(int i=0;i<multiPoints;i++) {
xVals[i] = readLEDouble();
yVals[i] = readLEDouble();
}
break;
default:
// IGNORE REST OF SHAPE TYPES and skip over data using recordLen value
//System.out.println("Some other unknown shape");
data_is.skipBytes(recordLen); // TODO: Check if this works on polyline or point
}
} // END OF WHILE
} catch(EOFException e) {
// End of File, just needs to continue
}
Line [] arrList = new Line [lines.size()];
return new LineMap(lines.toArray(arrList), rect);
}
/**
* Translates a little endian int into a big endian int
*
* @return int A big endian int
*/
private int readLEInt() throws IOException {
int byte1, byte2, byte3, byte4;
synchronized (this) {
byte1 = data_is.read();
byte2 = data_is.read();
byte3 = data_is.read();
byte4 = data_is.read();
}
if (byte4 == -1) {
throw new EOFException();
}
return (byte4 << 24) + (byte3 << 16) + (byte2 << 8) + byte1;
}
/**
* Reads a little endian double into a big endian double
*
* @return double A big endian double
*/
private final double readLEDouble() throws IOException {
return Double.longBitsToDouble(this.readLELong());
}
/**
* Translates a little endian long into a big endian long
*
* @return long A big endian long
*/
private long readLELong() throws IOException {
long byte1 = data_is.read();
long byte2 = data_is.read();
long byte3 = data_is.read();
long byte4 = data_is.read();
long byte5 = data_is.read();
long byte6 = data_is.read();
long byte7 = data_is.read();
long byte8 = data_is.read();
if (byte8 == -1) {
throw new EOFException();
}
return (byte8 << 56) + (byte7 << 48) + (byte6 << 40) + (byte5 << 32)
+ (byte4 << 24) + (byte3 << 16) + (byte2 << 8) + byte1;
}
}
| atsoc0ocsav/IEEE-Firefighter | ieeefirefighter-beta/pc/pccomm-src/lejos/robotics/mapping/ShapefileLoader.java | Java | gpl-2.0 | 9,323 | [
30522,
7427,
3393,
19929,
1012,
21331,
1012,
12375,
1025,
12324,
9262,
1012,
22834,
1012,
30524,
1012,
9140,
9863,
1025,
12324,
3393,
19929,
1012,
20248,
2213,
1012,
2240,
1025,
12324,
3393,
19929,
1012,
20248,
2213,
1012,
28667,
23395,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.