code stringlengths 3 1.01M | repo_name stringlengths 5 116 | path stringlengths 3 311 | language stringclasses 30 values | license stringclasses 15 values | size int64 3 1.01M |
|---|---|---|---|---|---|
package AnyDBM_File;
use warnings;
use strict;
use 5.006_001;
our $VERSION = '1.01';
our @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
my $mod;
for $mod (@ISA) {
if (eval "require $mod") {
@ISA = ($mod); # if we leave @ISA alone, warnings abound
return 1;
}
}
die "No DBM package was successfully found or installed";
__END__
=head1 NAME
AnyDBM_File - provide framework for multiple DBMs
NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations
=head1 SYNOPSIS
use AnyDBM_File;
=head1 DESCRIPTION
This module is a "pure virtual base class"--it has nothing of its own.
It's just there to inherit from one of the various DBM packages. It
prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See
L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and
finally ODBM. This way old programs that used to use NDBM via dbmopen()
can still do so, but new ones can reorder @ISA:
BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
use AnyDBM_File;
Having multiple DBM implementations makes it trivial to copy database formats:
use Fcntl; use NDBM_File; use DB_File;
tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR;
tie %oldhash, 'NDBM_File', $old_filename, 1, 0;
%newhash = %oldhash;
=head2 DBM Comparisons
Here's a partial table of features the different packages offer:
odbm ndbm sdbm gdbm bsd-db
---- ---- ---- ---- ------
Linkage comes w/ perl yes yes yes yes yes
Src comes w/ perl no no yes no no
Comes w/ many unix os yes yes[0] no no no
Builds ok on !unix ? ? yes yes ?
Code Size ? ? small big big
Database Size ? ? small big? ok[1]
Speed ? ? slow ok fast
FTPable no no yes yes yes
Easy to build N/A N/A yes yes ok[2]
Size limits 1k 4k 1k[3] none none
Byte-order independent no no no no yes
Licensing restrictions ? ? no yes no
=over 4
=item [0]
on mixed universe machines, may be in the bsd compat library,
which is often shunned.
=item [1]
Can be trimmed if you compile for one access method.
=item [2]
See L<DB_File>.
Requires symbolic links.
=item [3]
By default, but can be redefined.
=back
=head1 SEE ALSO
dbm(3), ndbm(3), DB_File(3), L<perldbmfilter>
=cut
| operepo/ope | client_tools/svc/rc/usr/share/perl5/core_perl/AnyDBM_File.pm | Perl | mit | 2,611 |
// Copyright (c) 2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <policy/fees.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <cstdint>
#include <vector>
void initialize()
{
InitializeFuzzingContext();
}
void test_one_input(const std::vector<uint8_t>& buffer)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
CAutoFile fuzzed_auto_file = fuzzed_auto_file_provider.open();
// Re-using block_policy_estimator across runs to avoid costly creation of CBlockPolicyEstimator object.
static CBlockPolicyEstimator block_policy_estimator;
if (block_policy_estimator.Read(fuzzed_auto_file)) {
block_policy_estimator.Write(fuzzed_auto_file);
}
}
| rnicoll/dogecoin | src/test/fuzz/policy_estimator_io.cpp | C++ | mit | 988 |
//
// TKDataFormNamePhoneEditor.h
// TelerikUI
//
// Copyright © 2015 Telerik. All rights reserved.
//
#import "TKDataFormTextFieldEditor.h"
@interface TKDataFormNamePhoneEditor : TKDataFormTextFieldEditor
@end
| danik121/HAN-MAD-DT-NATIVESCRIPT | node_modules/nativescript-telerik-ui/platforms/ios/TelerikUI.framework/Headers/TKDataFormNamePhoneEditor.h | C | mit | 218 |
<div class="umb-property-editor umb-mediapicker" ng-class="{'umb-mediapicker-multi':isMultiPicker, 'umb-mediapicker-single':!isMultiPicker}" ng-controller="Umbraco.PropertyEditors.MediaPickerController as vm">
<p ng-if="(vm.mediaItems|filter:{trashed:true}).length == 1"><localize key="mediaPicker_pickedTrashedItem">You have picked a media item currently deleted or in the recycle bin</localize></p>
<p ng-if="(vm.mediaItems|filter:{trashed:true}).length > 1"><localize key="mediaPicker_pickedTrashedItems">You have picked media items currently deleted or in the recycle bin</localize></p>
<div data-element="sortable-thumbnails" class="umb-sortable-thumbnails-container error">
<ul ui-sortable="sortableOptions" ng-model="vm.mediaItems" class="umb-sortable-thumbnails">
<li data-element="sortable-thumbnail-{{$index}}" class="umb-sortable-thumbnails__wrapper" ng-repeat="media in vm.mediaItems track by $index">
<p class="label label__trashed" ng-if="media.trashed">
<localize key="mediaPicker_trashed">Trashed</localize>
<umb-icon icon="icon-trash"></umb-icon>
</p>
<div ng-if="image.loading" class="umb-sortable-thumbnails__loading">
<div class="umb-button__progress"></div>
</div>
<!-- IMAGE -->
<img ng-if="media.thumbnail && media.extension !== 'svg'"
ng-class="{'trashed': media.trashed}" ng-src="{{media.thumbnail}}"
ng-attr-title="{{media.trashed ? (vm.labels.trashed || 'Trashed') + ': ' + media.name : media.name}}"
alt="{{media.name}}" />
<!-- SVG -->
<img ng-if="media.thumbnail && media.extension === 'svg'"
ng-class="{'trashed': media.trashed}" ng-src="{{media.thumbnail}}"
ng-attr-title="{{media.trashed ? (vm.labels.trashed || 'Trashed') + ': ' + media.name : media.name}}"
alt="{{media.name}}" />
<!-- FILE -->
<umb-file-icon ng-hide="media.thumbnail" ng-class="{'trashed': media.trashed}"
extension="{{media.extension}}"
icon="{{media.icon}}"
size="s"
text="{{media.name}}">
</umb-file-icon>
<div class="umb-sortable-thumbnails__actions" data-element="sortable-thumbnail-actions">
<button type="button" aria-label="Edit media" ng-if="allowEditMedia && !media.trashed" class="umb-sortable-thumbnails__action btn-reset" data-element="action-edit" ng-click="vm.editItem(media)">
<umb-icon icon="icon-edit" class="icon"></umb-icon>
</button>
<button type="button" aria-label="Remove" class="umb-sortable-thumbnails__action -red btn-reset" data-element="action-remove" ng-click="vm.remove($index)">
<umb-icon icon="icon-delete" class="icon"></umb-icon>
</button>
</div>
</li>
<li style="border: none;" class="add-wrapper unsortable" ng-if="vm.showAdd() && allowAddMedia">
<button type="button" aria-label="Open media picker" data-element="sortable-thumbnails-add" class="add-link btn-reset umb-outline umb-outline--surrounding" ng-click="vm.add()" ng-class="{'add-link-square': (vm.mediaItems.length === 0 || isMultiPicker)}">
<umb-icon icon="icon-add" class="icon large"></umb-icon>
</button>
</li>
</ul>
</div>
<ng-form name="vm.modelValueForm">
<input type="hidden" name="modelValue" ng-model="vm.mediaItems.length" ng-required="model.validation.mandatory && !vm.mediaItems.length" />
</ng-form>
</div>
| umbraco/Umbraco-CMS | src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.html | HTML | mit | 3,925 |
/*
Highcharts JS v7.1.0 (2019-04-01)
(c) 2010-2019 Highsoft AS
Author: Sebastian Domas
License: www.highcharts.com/license
*/
(function(a){"object"===typeof module&&module.exports?(a["default"]=a,module.exports=a):"function"===typeof define&&define.amd?define("highcharts/modules/histogram-bellcurve",["highcharts"],function(c){a(c);a.Highcharts=c;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function c(b,a,g,m){b.hasOwnProperty(a)||(b[a]=m.apply(null,g))}a=a?a._modules:{};c(a,"mixins/derived-series.js",[a["parts/Globals.js"]],function(a){var b=a.Series,g=a.addEvent;return{hasDerivedData:!0,
init:function(){b.prototype.init.apply(this,arguments);this.initialised=!1;this.baseSeries=null;this.eventRemovers=[];this.addEvents()},setDerivedData:a.noop,setBaseSeries:function(){var a=this.chart,b=this.options.baseSeries;this.baseSeries=b&&(a.series[b]||a.get(b))||null},addEvents:function(){var a=this,b;b=g(this.chart,"afterLinkSeries",function(){a.setBaseSeries();a.baseSeries&&!a.initialised&&(a.setDerivedData(),a.addBaseSeriesEvents(),a.initialised=!0)});this.eventRemovers.push(b)},addBaseSeriesEvents:function(){var a=
this,b,e;b=g(a.baseSeries,"updatedData",function(){a.setDerivedData()});e=g(a.baseSeries,"destroy",function(){a.baseSeries=null;a.initialised=!1});a.eventRemovers.push(b,e)},destroy:function(){this.eventRemovers.forEach(function(a){a()});b.prototype.destroy.apply(this,arguments)}}});c(a,"modules/histogram.src.js",[a["parts/Globals.js"],a["mixins/derived-series.js"]],function(a,c){function b(a){return function(f){for(var b=1;a[b]<=f;)b++;return a[--b]}}var m=a.objectEach,k=a.seriesType,e=a.correctFloat,
n=a.isNumber,q=a.arrayMax,r=a.arrayMin;a=a.merge;var d={"square-root":function(a){return Math.ceil(Math.sqrt(a.options.data.length))},sturges:function(a){return Math.ceil(Math.log(a.options.data.length)*Math.LOG2E)},rice:function(a){return Math.ceil(2*Math.pow(a.options.data.length,1/3))}};k("histogram","column",{binsNumber:"square-root",binWidth:void 0,pointPadding:0,groupPadding:0,grouping:!1,pointPlacement:"between",tooltip:{headerFormat:"",pointFormat:'\x3cspan style\x3d"font-size: 10px"\x3e{point.x} - {point.x2}\x3c/span\x3e\x3cbr/\x3e\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name} \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3e'}},
a(c,{setDerivedData:function(){var a=this.derivedData(this.baseSeries.yData,this.binsNumber(),this.options.binWidth);this.setData(a,!1)},derivedData:function(a,h,d){var f=q(a),l=e(r(a)),c=[],g={},p=[],k;d=this.binWidth=this.options.pointRange=e(n(d)?d||1:(f-l)/h);for(h=l;h<f&&(this.userOptions.binWidth||e(f-h)>=d||0>=e(l+c.length*d-h));h=e(h+d))c.push(h),g[h]=0;0!==g[l]&&(c.push(e(l)),g[e(l)]=0);k=b(c.map(function(a){return parseFloat(a)}));a.forEach(function(a){a=e(k(a));g[a]++});m(g,function(a,
b){p.push({x:Number(b),y:a,x2:e(Number(b)+d)})});p.sort(function(a,b){return a.x-b.x});return p},binsNumber:function(){var a=this.options.binsNumber,b=d[a]||"function"===typeof a&&a;return Math.ceil(b&&b(this.baseSeries)||(n(a)?a:d["square-root"](this.baseSeries)))}}))});c(a,"modules/bellcurve.src.js",[a["parts/Globals.js"],a["mixins/derived-series.js"]],function(a,c){function b(a){var b=a.length;a=a.reduce(function(a,b){return a+b},0);return 0<b&&a/b}function m(a,d){var f=a.length;d=q(d)?d:b(a);
a=a.reduce(function(a,b){b-=d;return a+b*b},0);return 1<f&&Math.sqrt(a/(f-1))}function k(a,b,f){a-=b;return Math.exp(-(a*a)/(2*f*f))/(f*Math.sqrt(2*Math.PI))}var e=a.seriesType,n=a.correctFloat,q=a.isNumber;a=a.merge;e("bellcurve","areaspline",{intervals:3,pointsInInterval:3,marker:{enabled:!1}},a(c,{setMean:function(){this.mean=n(b(this.baseSeries.yData))},setStandardDeviation:function(){this.standardDeviation=n(m(this.baseSeries.yData,this.mean))},setDerivedData:function(){1<this.baseSeries.yData.length&&
(this.setMean(),this.setStandardDeviation(),this.setData(this.derivedData(this.mean,this.standardDeviation),!1))},derivedData:function(a,b){var f=this.options.intervals,c=this.options.pointsInInterval,d=a-f*b,f=f*c*2+1,c=b/c,e=[],g;for(g=0;g<f;g++)e.push([d,k(d,a,b)]),d+=c;return e}}))});c(a,"masters/modules/histogram-bellcurve.src.js",[],function(){})});
//# sourceMappingURL=histogram-bellcurve.js.map | joeyparrish/cdnjs | ajax/libs/highcharts/7.1.0/modules/histogram-bellcurve.js | JavaScript | mit | 4,265 |
#!/bin/bash
set -e
# set variables
PREFIX="/usr/local"
BASE_DIR="$PREFIX/share/vibe"
SRC_DIR=$(dirname $0)
CONFIG_DIR="/etc/vibe"
CONFIG_FILE="$CONFIG_DIR/vibe.conf"
LOG_DIR="/var/spool/vibe"
LOG_FILE="$LOG_DIR/install.log"
MENU_DIR="$PREFIX/share/applications"
MENU_FILE="$MENU_DIR/vibe.desktop"
USER_NAME="www-vibe"
GROUP_NAME="www-vibe"
USER_COMMENT="Vibe user"
DEBIAN_USER="www-data"
DEBIAN_GROUP="www-data"
# throw error
ferror()
{
for I in "$@"
do
echo "$I" >&2
done
exit 1
}
# script help
fhelp()
{
echo "Script to install and remove 'vibe' on Linux."
echo
echo "Usage:"
echo " $0 [ -i | -r | -h ] "
echo
echo "Options:"
echo " -i installs vibe"
echo
echo " -r removes vibe"
echo
echo " -h show this help"
}
# force to be root
froot()
{
test "root" != "$USER" && echo "'root' privileges required..." && exec sudo "$@"
echo -en "\033[0A \015"
}
fremove()
{
# remove user if present in log file
if grep "^user: $USER_NAME$" $LOG_FILE >/dev/null 2>&1
then
/usr/sbin/userdel $USER_NAME >/dev/null 2>&1 && echo "'$USER_NAME' user removed."
sed -i "/^user: $USER_NAME$/d" $LOG_FILE >/dev/null 2>&1
fi
# remove group if present in log file
if grep "^group: $GROUP_NAME$" $LOG_FILE >/dev/null 2>&1
then
/usr/sbin/groupdel $GROUP_NAME >/dev/null 2>&1 && echo "'$GROUP_NAME' group removed."
sed -i "/^group: $GROUP_NAME$/d" $LOG_FILE >/dev/null 2>&1
fi
# remove log file if no data
if [ -f $LOG_FILE ] && [ -z $(tr -d '[ \t\r\n]' 2>/dev/null <$LOG_FILE) ]
then
rm -f $LOG_FILE
fi
rmdir $LOG_DIR >/dev/null 2>&1 || :
# remove config file
echo "Removing configuration file $CONFIG_FILE..."
rm -f $CONFIG_FILE
rmdir $CONFIG_DIR >/dev/null 2>&1 || :
# remove menu entry
rm -f $MENU_FILE
rmdir $MENU_DIR >/dev/null 2>&1 || :
# remove files
echo "Removing 'vibe' files in $BASE_DIR/..."
rm -Rf $BASE_DIR/
}
finstall()
{
# check if vibe sources
if [ ! -f $SRC_DIR/source/vibe/vibe.d ]
then
ferror "$0: FATAL ERROR! missing 'vibe' sources!" "Try '$0 -h' for more information."
fi
# install files
echo "Installing 'vibe' files in $BASE_DIR/..."
cp -Rf $SRC_DIR/{source/,docs/,examples/} $BASE_DIR/
# create menu entry
if [ -f $BASE_DIR/docs/index.html ]
then
mkdir -p $MENU_DIR
echo "[Desktop Entry]" >$MENU_FILE
echo "Type=Application" >>$MENU_FILE
echo "Name=Vibe Documentation" >>$MENU_FILE
echo "Comment=Vibe web framework documentation" >>$MENU_FILE
echo "Exec=xdg-open $BASE_DIR/docs/index.html" >>$MENU_FILE
echo "Icon=html" >>$MENU_FILE
echo "Categories=Development;" >>$MENU_FILE
else
unset MENU_DIR MENU_FILE
fi
# user/group administration
if getent group $DEBIAN_GROUP >/dev/null && getent passwd $DEBIAN_USER >/dev/null
then
GROUP_NAME=$DEBIAN_GROUP
USER_NAME=$DEBIAN_USER
else
# creating group if he isn't already there
if ! getent group $GROUP_NAME >/dev/null
then
echo "Creating group $GROUP_NAME..."
/usr/sbin/groupadd -r $GROUP_NAME
mkdir -p $LOG_DIR
echo "group: $GROUP_NAME" >>$LOG_FILE
fi
# creating user if he isn't already there
if ! getent passwd $USER_NAME >/dev/null
then
echo "Creating user $USER_NAME..."
/usr/sbin/useradd -r -g $GROUP_NAME -c "$USER_COMMENT" $USER_NAME
mkdir -p $LOG_DIR
echo "user: $USER_NAME" >>$LOG_FILE
fi
fi
# create/update config file
echo "Creating config file $CONFIG_FILE..."
mkdir -p $CONFIG_DIR
echo '{' >$CONFIG_FILE
echo ' "user": "'$USER_NAME'",' >>$CONFIG_FILE
echo ' "group": "'$GROUP_NAME'"' >>$CONFIG_FILE
echo '}' >>$CONFIG_FILE
# set files/folders permissions
chmod 0755 $(find $BASE_DIR/ -type d) $CONFIG_DIR $MENU_DIR
chmod 0644 $(find $BASE_DIR/ ! -type d) $CONFIG_FILE $MENU_FILE
# if everything went fine
echo -e "\n \033[32;40;7;1mvibe.d installed successfully!\033[0m\n"
echo "You need to have the following dependencies installed:"
echo " ·dmd - http://dlang.org"
echo " ·libssl (development files) - http://www.openssl.org/"
echo -e "\ntake a look at examples on $BASE_DIR/examples/"
}
# check if more than one argument
if [ $# -gt 1 ]
then
ferror "$0: too many arguments" "Try '$0 -h' for more information."
fi
# check first argument
case "$1" in
-h|-H)
fhelp
;;
-i|-I)
froot $0 "$@"
finstall
;;
-r|-R)
froot $0 "$@"
fremove
;;
"")
ferror "$0: missing argument" "Try '$0 -h' for more information."
;;
*)
ferror "$0: unknown argument '$1'" "Try '$0 -h' for more information."
;;
esac
| rejectedsoftware/vibe.d | setup-linux.sh | Shell | mit | 4,524 |
/*
* This file provided by Facebook is for non-commercial testing and evaluation
* purposes only. Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.facebook.samples.comparison.urlsfetcher;
import com.facebook.common.internal.Preconditions;
import java.util.Map;
/**
* Encapsulates url and set of image types together with corresponding
* resizing options.
*/
public class ImageUrlsRequest {
final private String mEndpointUrl;
Map<ImageFormat, ImageSize> mRequestedImageFormats;
ImageUrlsRequest(final String endpointUrl, Map<ImageFormat, ImageSize> requestedTypes) {
mEndpointUrl = Preconditions.checkNotNull(endpointUrl);
mRequestedImageFormats = Preconditions.checkNotNull(requestedTypes);
}
public String getEndpointUrl() {
return mEndpointUrl;
}
public ImageSize getImageSize(ImageFormat imageFormat) {
return mRequestedImageFormats.get(imageFormat);
}
}
| s1rius/fresco | samples/comparison/src/main/java/com/facebook/samples/comparison/urlsfetcher/ImageUrlsRequest.java | Java | mit | 1,379 |
The MIT License
Copyright (c) 2013 Markit On Demand, Inc. http://markitondemand.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| crumudgin/DataApis | LICENSE.md | Markdown | mit | 1,118 |
package org.multibit.hd.ui.views.wizards.edit_contact;
import org.multibit.hd.core.dto.Contact;
import org.multibit.hd.ui.views.wizards.AbstractWizardModel;
import java.util.List;
/**
* <p>Model object to provide the following to "edit contact" wizard:</p>
* <ul>
* <li>Storage of panel data</li>
* <li>State transition management</li>
* </ul>
*
* @since 0.0.1
*
*/
public class EditContactWizardModel extends AbstractWizardModel<EditContactState> {
private final List<Contact> contacts;
/**
* @param state The state object
* @param contacts The contacts to edit
*/
public EditContactWizardModel(EditContactState state, List<Contact> contacts) {
super(state);
this.contacts = contacts;
}
/**
* @return The edited contacts
*/
public List<Contact> getContacts() {
return contacts;
}
}
| bitcoin-solutions/multibit-hd | mbhd-swing/src/main/java/org/multibit/hd/ui/views/wizards/edit_contact/EditContactWizardModel.java | Java | mit | 844 |
#!/usr/bin/env python3
# Copyright (C) 2010-2011 Marcin Kościelnicki <koriakin@0x04.net>
# Copyright (C) 2010 Luca Barbieri <luca@luca-barbieri.com>
# Copyright (C) 2010 Marcin Slusarz <marcin.slusarz@gmail.com>
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
import rnn
import sys
startcol = 64
fouts = {}
def printdef(name, val, file):
fout = fouts[file]
fout.write("#define {}{} {}\n".format(name, " " * (startcol - len(name)), val))
def printvalue(val, shift):
if val.varinfo.dead:
return
if val.value is not None:
printdef(val.fullname, hex(val.value << shift), val.file)
def printtypeinfo(ti, prefix, shift, file):
if isinstance(ti, rnn.TypeHex) or isinstance(ti, rnn.TypeInt):
if ti.shr:
printdef (prefix + "__SHR", str(ti.shr), file)
if ti.min is not None:
printdef (prefix + "__MIN", hex(ti.min), file)
if ti.max is not None:
printdef (prefix + "__MAX", hex(ti.max), file)
if ti.align is not None:
printdef (prefix + "__ALIGN", hex(ti.align), file)
if isinstance(ti, rnn.TypeFixed):
if ti.min is not None:
printdef (prefix + "__MIN", hex(ti.min), file)
if ti.max is not None:
printdef (prefix + "__MAX", hex(ti.max), file)
if ti.radix is not None:
printdef (prefix + "__RADIX", str(ti.radix), file)
if isinstance(ti, rnn.Enum) and ti.inline:
for val in ti.vals:
printvalue(val, shift)
if isinstance(ti, rnn.Bitset) and ti.inline:
for bitfield in ti.bitfields:
printbitfield(bitfield, shift)
def printbitfield(bf, shift):
if bf.varinfo.dead:
return
if isinstance(bf.typeinfo, rnn.TypeBoolean):
printdef(bf.fullname, hex(bf.mask << shift), bf.file)
else:
printdef(bf.fullname + "__MASK", hex(bf.mask << shift), bf.file)
printdef(bf.fullname + "__SHIFT", str(bf.low + shift), bf.file)
printtypeinfo(bf.typeinfo, bf.fullname, bf.low + shift, bf.file)
def printdelem(elem, offset, strides):
if elem.varinfo.dead:
return
if elem.length != 1:
strides = strides + [elem.stride]
offset = offset + elem.offset
if elem.name:
if strides:
name = elem.fullname + '(' + ", ".join("i{}".format(i) for i in range(len(strides))) + ')'
val = '(' + hex(offset) + "".join(" + {:x} * i{}".format(stride, i) for i, stride in enumerate(strides)) + ')'
printdef(name, val, elem.file)
else:
printdef(elem.fullname, hex(offset), elem.file)
if elem.stride:
printdef(elem.fullname +"__ESIZE", hex(elem.stride), elem.file)
if elem.length != 1:
printdef(elem.fullname + "__LEN", hex(elem.length), elem.file)
if isinstance(elem, rnn.Reg):
printtypeinfo(elem.typeinfo, elem.fullname, 0, elem.file)
fouts[elem.file].write("\n")
if isinstance(elem, rnn.Stripe):
for subelem in elem.elems:
printdelem(subelem, offset, strides)
def print_file_info(fout, file):
#struct stat sb;
#struct tm tm;
#stat(file, &sb);
#gmtime_r(&sb.st_mtime, &tm);
#char timestr[64];
#strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", tm);
#fprintf(dst, "(%7Lu bytes, from %s)\n", (unsigned long long)sb->st_size, timestr);
fout.write("\n")
def printhead(file, db):
fout = fouts[file]
fout.write("#ifndef {}\n".format(guard(file)))
fout.write("#define {}\n".format(guard(file)))
fout.write("\n")
fout.write(
"/* Autogenerated file, DO NOT EDIT manually!\n"
"\n"
"This file was generated by the rules-ng-ng headergen tool in this git repository:\n"
"http://github.com/envytools/envytools/\n"
"git clone https://github.com/envytools/envytools.git\n"
"\n"
"The rules-ng-ng source files this header was generated from are:\n")
#struct stat sb;
#struct tm tm;
#stat(f.name, &sb);
#gmtime_r(&sb.st_mtime, &tm);
maxlen = max(len(file) for file in db.files)
for file in db.files:
fout.write("- {} ".format(file + " " * (maxlen - len(file))))
print_file_info(fout, file)
fout.write(
"\n"
"Copyright (C) ")
#if(db->copyright.firstyear && db->copyright.firstyear < (1900 + tm.tm_year))
# fout.write("%u-", db->copyright.firstyear);
#fout.write("%u", 1900 + tm.tm_year);
if db.copyright.authors:
fout.write(" by the following authors:")
for author in db.copyright.authors:
fout.write("\n- ")
if author.name:
fout.write(author.name)
if author.email:
fout.write(" <{}>".format(author.email))
if author.nicknames:
fout.write(" ({})".format(", ".join(author.nicknames)))
fout.write("\n")
if db.copyright.license:
fout.write("\n{}\n".format(db.copyright.license))
fout.write("*/\n\n\n")
def guard(file):
return ''.join(c.upper() if c.isalnum() else '_' for c in file)
def process(mainfile):
db = rnn.Database()
rnn.parsefile(db, mainfile)
db.prep()
for file in db.files:
fouts[file] = open(file.replace('/', '_') + '.h', 'w')
printhead(file, db)
for enum in db.enums:
if not enum.inline:
for val in enum.vals:
printvalue(val, 0)
for bitset in db.bitsets:
if not bitset.inline:
for bitfield in bitset.bitfields:
printbitfield(bitfield, 0)
for domain in db.domains:
if domain.size:
printdef(domain.fullname + "__SIZE", hex(domain.size), domain.file)
for elem in domain.elems:
printdelem(elem, 0, [])
for file in fouts:
fouts[file].write("\n#endif /* {} */\n".format(guard(file)))
fouts[file].close()
return db.estatus
if len(sys.argv) < 2:
sys.stdout.write ("Usage:\n"
"\theadergen file.xml\n"
)
sys.exit(2)
sys.exit(process(sys.argv[1]))
| hakzsam/envytools | rnn/headergen.py | Python | mit | 7,156 |
#!/usr/bin/env perl
########################################################################
# Authors: Christopher Henry, Scott Devoid, Paul Frybarger
# Contact email: chenry@mcs.anl.gov
# Development location: Mathematics and Computer Science Division, Argonne National Lab
########################################################################
use strict;
use warnings;
use Bio::KBase::workspace::ScriptHelpers qw( get_ws_client workspace workspaceURL parseObjectMeta parseWorkspaceMeta printObjectMeta);
use Bio::KBase::fbaModelServices::ScriptHelpers qw(fbaws printJobData get_fba_client runFBACommand universalFBAScriptCode );
#Defining globals describing behavior
my $primaryArgs = ["Model ID","Phenotype set"];
my $servercommand = "queue_reconciliation_sensitivity_analysis";
my $script = "fba-phenosensitivity";
my $translation = {
"Model ID" => "model",
"Phenotype set" => "phenotypeSet",
modelws => "model_workspace",
phenows => "phenotypeSet_workspace",
workspace => "workspace",
auth => "auth",
overwrite => "overwrite",
nosubmit => "donot_submit_job",
};
my $fbaTranslation = {
objfraction => "objfraction",
allrev => "allreversible",
maximize => "maximizeObjective",
defaultmaxflux => "defaultmaxflux",
defaultminuptake => "defaultminuptake",
defaultmaxuptake => "defaultmaxuptake",
simplethermo => "simplethermoconst",
thermoconst => "thermoconst",
nothermoerror => "nothermoerror",
minthermoerror => "minthermoerror"
};
#Defining usage and options
my $specs = [
[ 'phenows:s', 'Workspace with phenotype data object' ],
[ 'modelws:s', 'Workspace with model object' ],
[ 'maximize:s', 'Maximize objective', { "default" => 1 } ],
[ 'gapfills:s@', 'List of gapfillings to assess' ],
[ 'gapgens:s@', 'List of gapgenerations to assess' ],
[ 'objterms:s@', 'Objective terms' ],
[ 'geneko:s@', 'List of gene KO (; delimiter)' ],
[ 'rxnko:s@', 'List of reaction KO (; delimiter)' ],
[ 'bounds:s@', 'Custom bounds' ],
[ 'constraints:s@', 'Custom constraints' ],
[ 'defaultmaxflux:s', 'Default maximum reaction flux' ],
[ 'defaultminuptake:s', 'Default minimum nutrient uptake' ],
[ 'defaultmaxuptake:s', 'Default maximum nutrient uptake' ],
[ 'uptakelim:s@', 'Atom uptake limits' ],
[ 'simplethermo', 'Use simple thermodynamic constraints' ],
[ 'thermoconst', 'Use full thermodynamic constraints' ],
[ 'nothermoerror', 'No uncertainty in thermodynamic constraints' ],
[ 'minthermoerror', 'Minimize uncertainty in thermodynamic constraints' ],
[ 'allrev', 'Treat all reactions as reversible', { "default" => 0 } ],
[ 'objfraction:s', 'Fraction of objective for follow on analysis', { "default" => 0.1 }],
[ 'notes:s', 'Notes for flux balance analysis' ],
[ 'nosubmit', 'Do not submit job to cluster', { "default" => 0 } ],
[ 'workspace|w:s', 'Workspace to save FBA results', { "default" => fbaws() } ],
[ 'overwrite|o', 'Overwrite any existing FBA with same name' ]
];
my ($opt,$params) = universalFBAScriptCode($specs,$script,$primaryArgs,$translation);
if (defined($opt->{gapfills})) {
foreach my $gfs (@{$opt->{gapfills}}) {
push(@{$params->{gapFills}},split(/;/,$gfs));
}
}
if (defined($opt->{gapgens})) {
foreach my $ggs (@{$opt->{gapgens}}) {
push(@{$params->{gapGens}},split(/;/,$ggs));
}
}
$params->{formulation} = {
geneko => [],
rxnko => [],
bounds => [],
constraints => [],
uptakelim => {},
additionalcpds => []
};
foreach my $key (keys(%{$fbaTranslation})) {
if (defined($opt->{$key})) {
$params->{formulation}->{$fbaTranslation->{$key}} = $opt->{$key};
}
}
if (defined($opt->{objterms})) {
foreach my $terms (@{$opt->{objterms}}) {
my $array = [split(/;/,$terms)];
foreach my $term (@{$array}) {
my $termArray = [split(/:/,$term)];
if (defined($termArray->[2])) {
push(@{$params->{formulation}->{objectiveTerms}},$termArray);
}
}
}
}
if (defined($opt->{geneko})) {
foreach my $gene (@{$opt->{geneko}}) {
push(@{$params->{formulation}->{geneko}},split(/;/,$gene));
}
}
if (defined($opt->{rxnko})) {
foreach my $rxn (@{$opt->{rxnko}}) {
push(@{$params->{formulation}->{rxnko}},split(/;/,$rxn));
}
}
if (defined($opt->{bounds})) {
foreach my $terms (@{$opt->{bounds}}) {
my $array = [split(/;/,$terms)];
foreach my $term (@{$array}) {
my $termArray = [split(/:/,$term)];
if (defined($termArray->[3])) {
push(@{$params->{formulation}->{bounds}},$termArray);
}
}
}
}
if (defined($opt->{constraints})) {
my $count = 0;
foreach my $constraint (@{$opt->{constraints}}) {
my $array = [split(/;/,$constraint)];
my $rhs = shift(@{$array});
my $sign = shift(@{$array});
my $terms = [];
foreach my $term (@{$array}) {
my $termArray = [split(/:/,$term)];
if (defined($termArray->[2])) {
push(@{$terms},$termArray)
}
}
push(@{$params->{formulation}->{constraints}},[$rhs,$sign,$terms,"Constraint ".$count]);
$count++;
}
}
if (defined($opt->{uptakelim})) {
foreach my $uplims (@{$opt->{rxnko}}) {
my $array = [split(/;/,$uplims)];
foreach my $uplim (@{$array}) {
my $pair = [split(/:/,$uplim)];
if (defined($pair->[1])) {
$params->{formulation}->{uptakelim}->{$pair->[0]} = $pair->[1];
}
}
}
}
#Calling the server
my $output = runFBACommand($params,$servercommand,$opt);
#Checking output and report results
if (!defined($output)) {
print "Phenotype sensitivity analysis failed!\n";
} else {
print "Phenotype sensitivity analysis successful:\n";
printJobData($output);
}
| kbase/KBaseFBAModeling | scripts/fba-phenosensitivity.pl | Perl | mit | 5,501 |
<?php
namespace Kunstmaan\AdminBundle\Service;
use Kunstmaan\AdminBundle\Entity\UserInterface;
use Kunstmaan\AdminBundle\Event\ChangePasswordSuccessEvent;
use Kunstmaan\AdminBundle\Event\Events;
use Kunstmaan\AdminBundle\Service\AuthenticationMailer\AuthenticationMailerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
class PasswordResetService
{
/** @var UserManager */
private $userManager;
/** @var UrlGeneratorInterface */
private $urlGenerator;
/** @var EventDispatcherInterface */
private $eventDispatcher;
/** @var AuthenticationMailerInterface */
private $authenticationMailer;
public function __construct(UserManager $userManager, UrlGeneratorInterface $urlGenerator, EventDispatcherInterface $eventDispatcher, AuthenticationMailerInterface $authenticationMailer)
{
$this->userManager = $userManager;
$this->urlGenerator = $urlGenerator;
$this->eventDispatcher = $eventDispatcher;
$this->authenticationMailer = $authenticationMailer;
}
public function processResetRequest(string $email, string $locale): void
{
$user = $this->userManager->findUserByUsernameOrEmail($email);
if (null === $user) {
throw new UsernameNotFoundException(sprintf('No user not found with identifier "%s"', $email));
}
$this->userManager->setResetToken($user);
$this->authenticationMailer->sendPasswordResetEmail($user, $locale);
}
public function resetPassword(UserInterface $user, string $newPassword): Response
{
$user->setPlainPassword($newPassword);
$this->userManager->updatePassword($user);
$response = new RedirectResponse($this->urlGenerator->generate('KunstmaanAdminBundle_homepage'));
$this->dispatch(new ChangePasswordSuccessEvent($user, $response), Events::CHANGE_PASSWORD_COMPLETED);
return $response;
}
/**
* @param object $event
*/
private function dispatch($event, string $eventName): object
{
if (class_exists(LegacyEventDispatcherProxy::class)) {
$eventDispatcher = LegacyEventDispatcherProxy::decorate($this->eventDispatcher);
return $eventDispatcher->dispatch($event, $eventName);
}
return $this->eventDispatcher->dispatch($eventName, $event);
}
}
| dbeerten/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Service/PasswordResetService.php | PHP | mit | 2,663 |
var vows = require('vows'),
_ = require('underscore')._,
RawTests = require('./selenium.vows');
// makeSuite takes a configuration and makes a batch of tests, splitting
// up tests according to 'conf.processes'
exports.makeSuite = function(conf) {
var getCapText = function(conf, cap) {
return " (" + cap.browserName+"_"+cap.version+"_"+cap.platform+"_"+conf.serviceName+")";
};
// gets a version of the testbase relativized to a particular config
// and capability request
var getTestsForCap = function(cap) {
var capText = getCapText(conf, cap);
var allTests = RawTests.allTests(conf, cap, capText);
var capTests = {};
// Replace the name of each test with a relativized name showing
// which conf and caps we are using
_.each(allTests, function(test, testName) {
capTests[testName+capText] = test;
});
return capTests;
};
// Gather tests for all capabilities requests into one big dict
var allTests = {};
_.each(conf.caps, function(cap) {
var tests = getTestsForCap(cap);
_.each(tests, function(test, testName) {
allTests[testName] = test;
});
});
// Split tests into batches according to how parallelized we want to be
var numTests = _.size(allTests);
if (conf.maxTests && conf.maxTests < numTests) {
numTests = conf.maxTests;
}
var numBatches = Math.ceil(numTests / conf.processes);
if (numBatches >= 1) {
var batches = {};
var testsPerBatch = numBatches * conf.processes;
var i = 0;
var total = 0;
_.each(allTests, function(test, testName) {
if (!conf.maxTests || total < conf.maxTests) {
if (typeof batches[i] === 'undefined') {
batches[i] = {};
}
batches[i][testName] = test;
if (i < numBatches - 1) {
i++;
} else {
i = 0;
}
total++;
}
});
return batches;
}
};
| UziTech/jquery.kinetic | test/selenium/makeSuite.js | JavaScript | mit | 1,904 |
#include "Config.h"
using namespace std;
using namespace ramulator;
//Config::Config() {}
//Config::Config(const char* config_fname) : file(config_fname)
void Config::parse(const string& fname)
{
ifstream file(fname);
assert(file.good() && "Bad config file");
string line;
while (getline(file, line)) {
char delim[] = " \t=";
vector<string> tokens;
while (true) {
size_t start = line.find_first_not_of(delim);
if (start == string::npos)
break;
size_t end = line.find_first_of(delim, start);
if (end == string::npos) {
tokens.push_back(line.substr(start));
break;
}
tokens.push_back(line.substr(start, end - start));
line = line.substr(end);
}
// empty line
if (!tokens.size())
continue;
// comment line
if (tokens[0][0] == '#')
continue;
// parameter line
assert(tokens.size() == 2 && "Only allow two tokens in one line");
options[tokens[0]] = tokens[1];
}
file.close();
}
| i7mist/ramulator | src/Config.cpp | C++ | mit | 1,155 |
/*
* The MIT License (MIT)
*
* Copyright (c) 2007-2015 Broad Institute
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.broad.igv.track;
import org.broad.igv.feature.Exon;
import org.broad.igv.feature.IExon;
import org.broad.igv.feature.IGVFeature;
import org.broad.igv.renderer.SelectableFeatureRenderer;
import htsjdk.tribble.Feature;
import java.awt.event.MouseEvent;
import java.util.HashSet;
import java.util.Set;
/**
* A FeatureTrack designed for selecting features/exons. Created to support Sashimi plot
* window
* User: jacob
* Date: 2013-Jan-28
*/
public class SelectableFeatureTrack extends FeatureTrack {
protected Set<IExon> selectedExons = new HashSet<IExon>();
public SelectableFeatureTrack(FeatureTrack geneTrack) {
super(geneTrack);
this.setRendererClass(SelectableFeatureRenderer.class);
}
@Override
public boolean handleDataClick(TrackClickEvent te) {
MouseEvent e = te.getMouseEvent();
Feature f = getFeatureAtMousePosition(te);
//We allow any of these modifier keys for multi-select
if (!e.isShiftDown() && !e.isControlDown() && !e.isMetaDown()) {
clearSelectedExons();
}
boolean foundExon = false;
if (f != null && f instanceof IGVFeature) {
selectedFeature = (IGVFeature) f;
double location = te.getFrame().getChromosomePosition(e.getX());
if (selectedFeature.getExons() != null) {
for (Exon exon : selectedFeature.getExons()) {
if (location >= exon.getStart() && location < exon.getEnd()) {
selectedExons.add(exon);
foundExon = true;
break;
}
}
}
}
((SelectableFeatureRenderer) getRenderer()).setSelectedExons(selectedExons);
return foundExon;
}
private void clearSelectedExons() {
this.selectedExons.clear();
}
public Set<IExon> getSelectedExons() {
return selectedExons;
}
}
| godotgildor/igv | src/org/broad/igv/track/SelectableFeatureTrack.java | Java | mit | 3,124 |
id_mappings = {
"EX1_097": "Abomination",
"CS2_188": "Abusive Sergeant",
"EX1_007": "Acolyte of Pain",
"NEW1_010": "Al'Akir the Windlord",
"EX1_006": "Alarm-o-Bot",
"EX1_382": "Aldor Peacekeeper",
"EX1_561": "Alexstrasza",
"EX1_393": "Amani Berserker",
"CS2_038": "Ancestral Spirit",
"EX1_057": "Ancient Brewmaster",
"EX1_584": "Ancient Mage",
"NEW1_008b": "Ancient Secrets",
"NEW1_008a": "Ancient Teachings",
"EX1_045": "Ancient Watcher",
"NEW1_008": "Ancient of Lore",
"EX1_178": "Ancient of War",
"EX1_009": "Angry Chicken",
"EX1_398": "Arathi Weaponsmith",
"EX1_089": "Arcane Golem",
"EX1_559": "Archmage Antonidas",
"EX1_067": "Argent Commander",
"EX1_362": "Argent Protector",
"EX1_008": "Argent Squire",
"EX1_402": "Armorsmith",
"EX1_383t": "Ashbringer",
"EX1_591": "Auchenai Soulpriest",
"EX1_384": "Avenging Wrath",
"EX1_284": "Azure Drake",
"EX1_110t": "Baine Bloodhoof",
"EX1_014t": "Bananas",
"EX1_320": "Bane of Doom",
"EX1_249": "Baron Geddon",
"EX1_398t": "Battle Axe",
"EX1_392": "Battle Rage",
"EX1_165b": "Bear Form",
"EX1_549": "Bestial Wrath",
"EX1_126": "Betrayal",
"EX1_005": "Big Game Hunter",
"EX1_570": "Bite",
"CS2_233": "Blade Flurry",
"EX1_355": "Blessed Champion",
"EX1_363": "Blessing of Wisdom",
"CS2_028": "Blizzard",
"EX1_323w": "Blood Fury",
"CS2_059": "Blood Imp",
"EX1_590": "Blood Knight",
"EX1_012": "Bloodmage Thalnos",
"NEW1_025": "Bloodsail Corsair",
"NEW1_018": "Bloodsail Raider",
"EX1_407": "Brawl",
"EX1_091": "Cabal Shadow Priest",
"EX1_110": "Cairne Bloodhoof",
"NEW1_024": "Captain Greenskin",
"EX1_165a": "Cat Form",
"EX1_573": "Cenarius",
"EX1_621": "Circle of Healing",
"CS2_073": "Cold Blood",
"EX1_050": "Coldlight Oracle",
"EX1_103": "Coldlight Seer",
"NEW1_036": "Commanding Shout",
"EX1_128": "Conceal",
"EX1_275": "Cone of Cold",
"EX1_287": "Counterspell",
"EX1_059": "Crazed Alchemist",
"EX1_603": "Cruel Taskmaster",
"EX1_595": "Cult Master",
"skele21": "Damaged Golem",
"EX1_046": "Dark Iron Dwarf",
"EX1_617": "Deadly Shot",
"NEW1_030": "Deathwing",
"EX1_130a": "Defender",
"EX1_093": "Defender of Argus",
"EX1_131t": "Defias Bandit",
"EX1_131": "Defias Ringleader",
"EX1_573a": "Demigod's Favor",
"EX1_102": "Demolisher",
"EX1_596": "Demonfire",
"EX1_tk29": "Devilsaur",
"EX1_162": "Dire Wolf Alpha",
"EX1_166b": "Dispel",
"EX1_349": "Divine Favor",
"EX1_310": "Doomguard",
"EX1_567": "Doomhammer",
"NEW1_021": "Doomsayer",
"NEW1_022": "Dread Corsair",
"DREAM_04": "Dream",
"EX1_165t2": "Druid of the Claw (bear)",
"EX1_165": "Druid of the Claw",
"EX1_165t1": "Druid of the Claw (cat)",
"EX1_243": "Dust Devil",
"EX1_536": "Eaglehorn Bow",
"EX1_250": "Earth Elemental",
"EX1_245": "Earth Shock",
"CS2_117": "Earthen Ring Farseer",
"EX1_613": "Edwin VanCleef",
"DREAM_03": "Emerald Drake",
"EX1_170": "Emperor Cobra",
"EX1_619": "Equality",
"EX1_274": "Ethereal Arcanist",
"EX1_124": "Eviscerate",
"EX1_537": "Explosive Shot",
"EX1_610": "Explosive Trap",
"EX1_132": "Eye for an Eye",
"EX1_564": "Faceless Manipulator",
"NEW1_023": "Faerie Dragon",
"CS2_053": "Far Sight",
"EX1_301": "Felguard",
"CS1_069": "Fen Creeper",
"EX1_248": "Feral Spirit",
"EX1_finkle": "Finkle Einhorn",
"EX1_319": "Flame Imp",
"EX1_614t": "Flame of Azzinoth",
"EX1_544": "Flare",
"tt_004": "Flesheating Ghoul",
"EX1_571": "Force of Nature",
"EX1_251": "Forked Lightning",
"EX1_611": "Freezing Trap",
"EX1_283": "Frost Elemental",
"EX1_604": "Frothing Berserker",
"EX1_095": "Gadgetzan Auctioneer",
"DS1_188": "Gladiator's Longbow",
"NEW1_040t": "Gnoll",
"EX1_411": "Gorehowl",
"EX1_414": "Grommash Hellscream",
"NEW1_038": "Gruul",
"EX1_558": "Harrison Jones",
"EX1_556": "Harvest Golem",
"EX1_137": "Headcrack",
"EX1_409t": "Heavy Axe",
"NEW1_040": "Hogger",
"EX1_624": "Holy Fire",
"EX1_365": "Holy Wrath",
"EX1_538t": "Hound",
"NEW1_017": "Hungry Crab",
"EX1_534t": "Hyena",
"EX1_289": "Ice Barrier",
"EX1_295": "Ice Block",
"CS2_031": "Ice Lance",
"EX1_614": "Illidan Stormrage",
"EX1_598": "Imp",
"EX1_597": "Imp Master",
"EX1_tk34": "Infernal",
"CS2_181": "Injured Blademaster",
"CS1_129": "Inner Fire",
"EX1_607": "Inner Rage",
"CS2_203": "Ironbeak Owl",
"EX1_017": "Jungle Panther",
"EX1_166": "Keeper of the Grove",
"NEW1_005": "Kidnapper",
"EX1_543": "King Krush",
"EX1_014": "King Mukla",
"EX1_612": "Kirin Tor Mage",
"NEW1_019": "Knife Juggler",
"DREAM_01": "Laughing Sister",
"EX1_241": "Lava Burst",
"EX1_354": "Lay on Hands",
"EX1_160b": "Leader of the Pack",
"EX1_116": "Leeroy Jenkins",
"EX1_029": "Leper Gnome",
"EX1_238": "Lightning Bolt",
"EX1_259": "Lightning Storm",
"EX1_335": "Lightspawn",
"EX1_001": "Lightwarden",
"EX1_341": "Lightwell",
"EX1_096": "Loot Hoarder",
"EX1_323": "Lord Jaraxxus",
"EX1_100": "Lorewalker Cho",
"EX1_082": "Mad Bomber",
"EX1_563": "Malygos",
"EX1_055": "Mana Addict",
"EX1_575": "Mana Tide Totem",
"EX1_616": "Mana Wraith",
"NEW1_012": "Mana Wyrm",
"EX1_155": "Mark of Nature",
"EX1_155b": "Mark of Nature",
"EX1_155a": "Mark of Nature",
"EX1_626": "Mass Dispel",
"NEW1_037": "Master Swordsmith",
"NEW1_014": "Master of Disguise",
"NEW1_029": "Millhouse Manastorm",
"EX1_085": "Mind Control Tech",
"EX1_345": "Mindgames",
"EX1_294": "Mirror Entity",
"EX1_533": "Misdirection",
"EX1_396": "Mogu'shan Warden",
"EX1_620": "Molten Giant",
"EX1_166a": "Moonfire",
"EX1_408": "Mortal Strike",
"EX1_105": "Mountain Giant",
"EX1_509": "Murloc Tidecaller",
"EX1_507": "Murloc Warleader",
"EX1_557": "Nat Pagle",
"EX1_161": "Naturalize",
"DREAM_05": "Nightmare",
"EX1_130": "Noble Sacrifice",
"EX1_164b": "Nourish",
"EX1_164a": "Nourish",
"EX1_164": "Nourish",
"EX1_560": "Nozdormu",
"EX1_562": "Onyxia",
"EX1_160t": "Panther",
"EX1_522": "Patient Assassin",
"EX1_133": "Perdition's Blade",
"EX1_076": "Pint-Sized Summoner",
"EX1_313": "Pit Lord",
"EX1_316": "Power Overwhelming",
"EX1_160": "Power of the Wild",
"EX1_145": "Preparation",
"EX1_583": "Priestess of Elune",
"EX1_350": "Prophet Velen",
"EX1_279": "Pyroblast",
"EX1_044": "Questing Adventurer",
"EX1_412": "Raging Worgen",
"EX1_298": "Ragnaros the Firelord",
"CS2_104": "Rampage",
"CS2_161": "Ravenholdt Assassin",
"EX1_136": "Redemption",
"EX1_379": "Repentance",
"EX1_178a": "Rooted",
"EX1_134": "SI:7 Agent",
"EX1_578": "Savagery",
"EX1_534": "Savannah Highmane",
"EX1_020": "Scarlet Crusader",
"EX1_531": "Scavenging Hyena",
"EX1_586": "Sea Giant",
"EX1_080": "Secretkeeper",
"EX1_317": "Sense Demons",
"EX1_334": "Shadow Madness",
"EX1_345t": "Shadow of Nothing",
"EX1_303": "Shadowflame",
"EX1_625": "Shadowform",
"EX1_144": "Shadowstep",
"EX1_573b": "Shan'do's Lesson",
"EX1_410": "Shield Slam",
"EX1_405": "Shieldbearer",
"EX1_332": "Silence",
"CS2_151": "Silver Hand Knight",
"EX1_023": "Silvermoon Guardian",
"EX1_309": "Siphon Soul",
"EX1_391": "Slam",
"EX1_554t": "Snake",
"EX1_554": "Snake Trap",
"EX1_609": "Snipe",
"EX1_608": "Sorcerer's Apprentice",
"EX1_158": "Soul of the Forest",
"NEW1_027": "Southsea Captain",
"CS2_146": "Southsea Deckhand",
"tt_010a": "Spellbender (minion)",
"tt_010": "Spellbender",
"EX1_048": "Spellbreaker",
"EX1_tk11": "Spirit Wolf",
"CS2_221": "Spiteful Smith",
"CS2_152": "Squire",
"EX1_tk28": "Squirrel",
"NEW1_041": "Stampeding Kodo",
"NEW1_007a": "Starfall",
"NEW1_007b": "Starfall",
"NEW1_007": "Starfall",
"EX1_247": "Stormforged Axe",
"EX1_028": "Stranglethorn Tiger",
"EX1_160a": "Summon a Panther",
"EX1_315": "Summoning Portal",
"EX1_058": "Sunfury Protector",
"EX1_032": "Sunwalker",
"EX1_366": "Sword of Justice",
"EX1_016": "Sylvanas Windrunner",
"EX1_390": "Tauren Warrior",
"EX1_623": "Temple Enforcer",
"EX1_577": "The Beast",
"EX1_002": "The Black Knight",
"EX1_339": "Thoughtsteal",
"EX1_021": "Thrallmar Farseer",
"EX1_083": "Tinkmaster Overspark",
"EX1_383": "Tirion Fordring",
"EX1_tk9": "Treant (charge)",
"EX1_573t": "Treant (taunt)",
"EX1_158t": "Treant",
"EX1_043": "Twilight Drake",
"EX1_312": "Twisting Nether",
"EX1_258": "Unbound Elemental",
"EX1_538": "Unleash the Hounds",
"EX1_409": "Upgrade!",
"EX1_178b": "Uproot",
"EX1_594": "Vaporize",
"CS2_227": "Venture Co. Mercenary",
"NEW1_026t": "Violet Apprentice",
"NEW1_026": "Violet Teacher",
"EX1_304": "Void Terror",
"ds1_whelptoken": "Whelp",
"EX1_116t": "Whelp",
"NEW1_020": "Wild Pyromancer",
"EX1_033": "Windfury Harpy",
"CS2_231": "Wisp",
"EX1_010": "Worgen Infiltrator",
"EX1_317t": "Worthless Imp",
"EX1_154b": "Wrath",
"EX1_154a": "Wrath",
"EX1_154": "Wrath",
"CS2_169": "Young Dragonhawk",
"EX1_004": "Young Priestess",
"EX1_049": "Youthful Brewmaster",
"EX1_572": "Ysera",
"DREAM_02": "Ysera Awakens",
"EX1_066": "Acidic Swamp Ooze",
"CS2_041": "Ancestral Healing",
"NEW1_031": "Animal Companion",
"CS2_025": "Arcane Explosion",
"CS2_023": "Arcane Intellect",
"EX1_277": "Arcane Missiles",
"DS1_185": "Arcane Shot",
"CS2_112": "Arcanite Reaper",
"CS2_155": "Archmage",
"CS2_080": "Assassin's Blade",
"CS2_076": "Assassinate",
"GAME_002": "Avatar of the Coin",
"CS2_072": "Backstab",
"CS2_092": "Blessing of Kings",
"CS2_087": "Blessing of Might",
"CS2_172": "Bloodfen Raptor",
"CS2_046": "Bloodlust",
"CS2_173": "Bluegill Warrior",
"CS2_boar": "Boar",
"CS2_187": "Booty Bay Bodyguard",
"CS2_200": "Boulderfist Ogre",
"CS2_103": "Charge",
"CS2_182": "Chillwind Yeti",
"CS2_005": "Claw",
"CS2_114": "Cleave",
"CS2_093": "Consecration",
"CS2_201": "Core Hound",
"CS2_063": "Corruption",
"EX1_582": "Dalaran Mage",
"DS1_055": "Darkscale Healer",
"CS2_074": "Deadly Poison",
"CS2_236": "Divine Spirit",
"EX1_025": "Dragonling Mechanic",
"CS2_061": "Drain Life",
"CS2_064": "Dread Infernal",
"CS2_189": "Elven Archer",
"CS2_013t": "Excess Mana",
"CS2_108": "Execute",
"EX1_129": "Fan of Knives",
"CS2_106": "Fiery War Axe",
"CS2_042": "Fire Elemental",
"CS2_029": "Fireball",
"CS2_032": "Flamestrike",
"EX1_565": "Flametongue Totem",
"hexfrog": "Frog",
"CS2_026": "Frost Nova",
"CS2_037": "Frost Shock",
"CS2_024": "Frostbolt",
"CS2_121": "Frostwolf Grunt",
"CS2_226": "Frostwolf Warlord",
"CS2_147": "Gnomish Inventor",
"CS1_042": "Goldshire Footman",
"EX1_508": "Grimscale Oracle",
"CS2_088": "Guardian of Kings",
"EX1_399": "Gurubashi Berserker",
"CS2_094": "Hammer of Wrath",
"EX1_371": "Hand of Protection",
"NEW1_009": "Healing Totem",
"CS2_007": "Healing Touch",
"CS2_062": "Hellfire",
"CS2_105": "Heroic Strike",
"EX1_246": "Hex",
"CS2_089": "Holy Light",
"CS1_112": "Holy Nova",
"CS1_130": "Holy Smite",
"DS1_070": "Houndmaster",
"NEW1_034": "Huffer",
"EX1_360": "Humility",
"CS2_084": "Hunter's Mark",
"EX1_169": "Innervate",
"CS2_232": "Ironbark Protector",
"CS2_141": "Ironforge Rifleman",
"CS2_125": "Ironfur Grizzly",
"EX1_539": "Kill Command",
"CS2_142": "Kobold Geomancer",
"NEW1_011": "Kor'kron Elite",
"NEW1_033": "Leokk",
"CS2_091": "Light's Justice",
"CS2_162": "Lord of the Arena",
"CS2_118": "Magma Rager",
"CS2_009": "Mark of the Wild",
"EX1_025t": "Mechanical Dragonling",
"DS1_233": "Mind Blast",
"CS1_113": "Mind Control",
"CS2_003": "Mind Vision",
"CS2_mirror": "Mirror Image (minion)",
"CS2_027": "Mirror Image",
"NEW1_032": "Misha",
"CS2_008": "Moonfire",
"EX1_302": "Mortal Coil",
"DS1_183": "Multi-Shot",
"CS2_168": "Murloc Raider",
"EX1_506a": "Murloc Scout",
"EX1_506": "Murloc Tidehunter",
"GAME_006": "NOOOOOOOOOOOO",
"EX1_593": "Nightblade",
"CS2_235": "Northshire Cleric",
"EX1_015": "Novice Engineer",
"CS2_119": "Oasis Snapjaw",
"CS2_197": "Ogre Magi",
"CS2_022": "Polymorph",
"CS2_004": "Power Word: Shield",
"CS2_122": "Raid Leader",
"CS2_196": "Razorfen Hunter",
"CS2_213": "Reckless Rocketeer",
"CS2_120": "River Crocolisk",
"CS2_045": "Rockbiter Weapon",
"NEW1_003": "Sacrificial Pact",
"EX1_581": "Sap",
"CS2_011": "Savage Roar",
"CS2_050": "Searing Totem",
"CS2_179": "Sen'jin Shieldmasta",
"CS2_057": "Shadow Bolt",
"EX1_622": "Shadow Word: Death",
"CS2_234": "Shadow Word: Pain",
"EX1_019": "Shattered Sun Cleric",
"CS2_tk1": "Sheep",
"EX1_606": "Shield Block",
"EX1_278": "Shiv",
"CS2_101t": "Silver Hand Recruit",
"CS2_127": "Silverback Patriarch",
"CS2_075": "Sinister Strike",
"skele11": "Skeleton",
"EX1_308": "Soulfire",
"CS2_077": "Sprint",
"EX1_173": "Starfire",
"CS2_237": "Starving Buzzard",
"CS2_051": "Stoneclaw Totem",
"CS2_171": "Stonetusk Boar",
"CS2_150": "Stormpike Commando",
"CS2_222": "Stormwind Champion",
"CS2_131": "Stormwind Knight",
"EX1_306": "Succubus",
"CS2_012": "Swipe",
"GAME_005": "The Coin",
"DS1_175": "Timber Wolf",
"EX1_244": "Totemic Might",
"DS1_184": "Tracking",
"CS2_097": "Truesilver Champion",
"DS1_178": "Tundra Rhino",
"NEW1_004": "Vanish",
"CS2_065": "Voidwalker",
"EX1_011": "Voodoo Doctor",
"CS2_186": "War Golem",
"EX1_084": "Warsong Commander",
"CS2_033": "Water Elemental",
"EX1_400": "Whirlwind",
"CS2_082": "Wicked Knife",
"CS2_013": "Wild Growth",
"CS2_039": "Windfury",
"EX1_587": "Windspeaker",
"CS2_124": "Wolfrider",
"CS2_052": "Wrath of Air Totem",
"FP1_026": "Anub'ar Ambusher",
"FP1_020": "Avenge",
"FP1_031": "Baron Rivendare",
"FP1_029": "Dancing Swords",
"FP1_023": "Dark Cultist",
"FP1_021": "Death's Bite",
"NAX6_03": "Deathbloom",
"FP1_006": "Deathcharger",
"FP1_009": "Deathlord",
"FP1_018": "Duplicate",
"FP1_003": "Echoing Ooze",
"NAX12_04": "Enrage",
"NAX11_03": "Fallout Slime",
"NAX13_04H": "Feugen",
"FP1_015": "Feugen",
"NAX14_03": "Frozen Champion",
"NAX15_03t": "Guardian of Icecrown",
"NAX15_03n": "Guardian of Icecrown",
"FP1_002": "Haunted Creeper",
"NAX10_02": "Hook",
"NAX10_02H": "Hook",
"NAX12_03": "Jaws",
"NAX12_03H": "Jaws",
"FP1_013": "Kel'Thuzad",
"NAX9_02H": "Lady Blaumeux",
"NAX9_02": "Lady Blaumeux",
"FP1_030": "Loatheb",
"NAX1_05": "Locust Swarm",
"FP1_004": "Mad Scientist",
"FP1_010": "Maexxna",
"NAX9_07": "Mark of the Horsemen",
"NAX7_04H": "Massive Runeblade",
"NAX7_04": "Massive Runeblade",
"NAX7_05": "Mind Control Crystal",
"NAX5_03": "Mindpocalypse",
"NAX15_05": "Mr. Bigglesworth",
"NAX11_04": "Mutating Injection",
"NAXM_001": "Necroknight",
"NAX3_03": "Necrotic Poison",
"FP1_017": "Nerub'ar Weblord",
"NAX1h_03": "Nerubian (normal)",
"NAX1_03": "Nerubian (heroic)",
"FP1_007t": "Nerubian",
"FP1_007": "Nerubian Egg",
"NAX4_05": "Plague",
"FP1_019": "Poison Seeds",
"NAX14_04": "Pure Cold",
"FP1_025": "Reincarnate",
"NAX9_05H": "Runeblade",
"NAX9_05": "Runeblade",
"FP1_005": "Shade of Naxxramas",
"NAX9_04": "Sir Zeliek",
"NAX9_04H": "Sir Zeliek",
"NAXM_002": "Skeletal Smith",
"NAX4_03H": "Skeleton",
"NAX4_03": "Skeleton",
"FP1_012t": "Slime",
"FP1_012": "Sludge Belcher",
"FP1_008": "Spectral Knight",
"NAX8_05t": "Spectral Rider",
"FP1_002t": "Spectral Spider",
"NAX8_03t": "Spectral Trainee",
"NAX8_04t": "Spectral Warrior",
"NAX6_03t": "Spore",
"NAX6_04": "Sporeburst",
"NAX13_05H": "Stalagg",
"FP1_014": "Stalagg",
"FP1_027": "Stoneskin Gargoyle",
"NAX13_03": "Supercharge",
"FP1_014t": "Thaddius",
"NAX9_03H": "Thane Korth'azz",
"NAX9_03": "Thane Korth'azz",
"FP1_019t": "Treant (poison seeds)",
"NAX7_02": "Understudy",
"FP1_028": "Undertaker",
"NAX8_05": "Unrelenting Rider",
"NAX8_03": "Unrelenting Trainee",
"NAX8_04": "Unrelenting Warrior",
"FP1_024": "Unstable Ghoul",
"FP1_022": "Voidcaller",
"FP1_016": "Wailing Soul",
"FP1_011": "Webspinner",
"NAX2_05": "Worshipper",
"NAX2_05H": "Worshipper",
"FP1_001": "Zombie Chow",
"GVG_029": "Ancestor's Call",
"GVG_077": "Anima Golem",
"GVG_085": "Annoy-o-Tron",
"GVG_030": "Anodized Robo Cub",
"GVG_069": "Antique Healbot",
"GVG_091": "Arcane Nullifier X-21",
"PART_001": "Armor Plating",
"GVG_030a": "Attack Mode",
"GVG_119": "Blingtron 3000",
"GVG_063": "Bolvar Fordragon",
"GVG_099": "Bomb Lobber",
"GVG_110t": "Boom Bot",
"GVG_050": "Bouncing Blade",
"GVG_068": "Burly Rockjaw Trogg",
"GVG_056t": "Burrowing Mine",
"GVG_017": "Call Pet",
"GVG_092t": "Chicken (Gnomish Experimenter)",
"GVG_121": "Clockwork Giant",
"GVG_082": "Clockwork Gnome",
"GVG_062": "Cobalt Guardian",
"GVG_073": "Cobra Shot",
"GVG_059": "Coghammer",
"GVG_013": "Cogmaster",
"GVG_024": "Cogmaster's Wrench",
"GVG_038": "Crackle",
"GVG_052": "Crush",
"GVG_041": "Dark Wispers",
"GVG_041b": "Dark Wispers",
"GVG_041a": "Dark Wispers",
"GVG_015": "Darkbomb",
"GVG_019": "Demonheart",
"GVG_110": "Dr. Boom",
"GVG_080t": "Druid of the Fang (cobra)",
"GVG_080": "Druid of the Fang",
"GVG_066": "Dunemaul Shaman",
"GVG_005": "Echo of Medivh",
"PART_005": "Emergency Coolant",
"GVG_107": "Enhance-o Mechano",
"GVG_076": "Explosive Sheep",
"GVG_026": "Feign Death",
"GVG_020": "Fel Cannon",
"GVG_016": "Fel Reaver",
"PART_004": "Finicky Cloakfield",
"GVG_007": "Flame Leviathan",
"GVG_001": "Flamecannon",
"GVG_100": "Floating Watcher",
"GVG_084": "Flying Machine",
"GVG_113": "Foe Reaper 4000",
"GVG_079": "Force-Tank MAX",
"GVG_049": "Gahz'rilla",
"GVG_028t": "Gallywix's Coin",
"GVG_117": "Gazlowe",
"GVG_032b": "Gift of Cards",
"GVG_032a": "Gift of Mana",
"GVG_081": "Gilblin Stalker",
"GVG_043": "Glaivezooka",
"GVG_098": "Gnomeregan Infantry",
"GVG_092": "Gnomish Experimenter",
"GVG_023": "Goblin Auto-Barber",
"GVG_004": "Goblin Blastmage",
"GVG_095": "Goblin Sapper",
"GVG_032": "Grove Tender",
"GVG_120": "Hemet Nesingwary",
"GVG_104": "Hobgoblin",
"GVG_089": "Illuminator",
"GVG_045t": "Imp (warlock)",
"GVG_045": "Imp-losion",
"GVG_056": "Iron Juggernaut",
"GVG_027": "Iron Sensei",
"GVG_094": "Jeeves",
"GVG_106": "Junkbot",
"GVG_074": "Kezan Mystic",
"GVG_046": "King of Beasts",
"GVG_012": "Light of the Naaru",
"GVG_008": "Lightbomb",
"GVG_097": "Lil' Exorcist",
"GVG_071": "Lost Tallstrider",
"GVG_090": "Madder Bomber",
"GVG_021": "Mal'Ganis",
"GVG_035": "Malorne",
"GVG_034": "Mech-Bear-Cat",
"GVG_078": "Mechanical Yeti",
"GVG_006": "Mechwarper",
"GVG_116": "Mekgineer Thermaplugg",
"GVG_048": "Metaltooth Leaper",
"GVG_103": "Micro Machine",
"GVG_111": "Mimiron's Head",
"GVG_109": "Mini-Mage",
"GVG_018": "Mistress of Pain",
"GVG_112": "Mogor the Ogre",
"GVG_061": "Muster for Battle",
"GVG_042": "Neptulon",
"GVG_065": "Ogre Brute",
"GVG_088": "Ogre Ninja",
"GVG_054": "Ogre Warmaul",
"GVG_025": "One-eyed Cheat",
"GVG_096": "Piloted Shredder",
"GVG_105": "Piloted Sky Golem",
"GVG_036": "Powermace",
"GVG_064": "Puddlestomper",
"GVG_060": "Quartermaster",
"GVG_108": "Recombobulator",
"GVG_031": "Recycle",
"PART_006": "Reversing Switch",
"PART_003": "Rusty Horn",
"GVG_047": "Sabotage",
"GVG_070": "Salty Dog",
"GVG_101": "Scarlet Purifier",
"GVG_055": "Screwjank Clunker",
"GVG_057": "Seal of Light",
"GVG_009": "Shadowbomber",
"GVG_072": "Shadowboxer",
"GVG_058": "Shielded Minibot",
"GVG_053": "Shieldmaiden",
"GVG_075": "Ship's Cannon",
"GVG_011": "Shrinkmeister",
"GVG_086": "Siege Engine",
"GVG_040": "Siltfin Spiritwalker",
"GVG_114": "Sneed's Old Shredder",
"GVG_002": "Snowchugger",
"GVG_123": "Soot Spewer",
"GVG_044": "Spider Tank",
"GVG_087": "Steamwheedle Sniper",
"GVG_067": "Stonesplinter Trogg",
"GVG_030b": "Tank Mode",
"GVG_093": "Target Dummy",
"PART_002": "Time Rewinder",
"GVG_022": "Tinker's Sharpsword Oil",
"GVG_102": "Tinkertown Technician",
"GVG_115": "Toshley",
"GVG_028": "Trade Prince Gallywix",
"GVG_033": "Tree of Life",
"GVG_118": "Troggzor the Earthinator",
"GVG_003": "Unstable Portal",
"GVG_083": "Upgraded Repair Bot",
"GVG_111t": "V-07-TR-0N",
"GVG_010": "Velen's Chosen",
"GVG_039": "Vitality Totem",
"GVG_014": "Vol'jin",
"GVG_051": "Warbot",
"GVG_122": "Wee Spellstopper",
"PART_007": "Whirling Blades",
"GVG_037": "Whirling Zap-o-matic",
"NEW1_016": "Captain's Parrot",
"EX1_062": "Old Murk-Eye",
"Mekka4t": "Chicken",
"PRO_001": "Elite Tauren Chieftain",
"Mekka3": "Emboldener 3000",
"EX1_112": "Gelbin Mekkatorque",
"Mekka1": "Homing Chicken",
"PRO_001a": "I Am Murloc",
"PRO_001at": "Murloc",
"Mekka4": "Poultryizer",
"PRO_001c": "Power of the Horde",
"Mekka2": "Repair Bot",
"PRO_001b": "Rogues Do It...",
"BRM_016": "Axe Flinger",
"BRM_034": "Blackwing Corruptor",
"BRM_033": "Blackwing Technician",
"BRM_031": "Chromaggus",
"BRM_014": "Core Rager",
"BRM_008": "Dark Iron Skulker",
"BRM_005": "Demonwrath",
"BRM_018": "Dragon Consort",
"BRM_022": "Dragon Egg",
"BRM_003": "Dragon's Breath",
"BRM_020": "Dragonkin Sorcerer",
"BRM_024": "Drakonid Crusher",
"BRM_010": "Druid of the Flame",
"BRM_028": "Emperor Thaurissan",
"BRM_012": "Fireguard Destroyer",
"BRM_002": "Flamewaker",
"BRM_007": "Gang Up",
"BRM_019": "Grim Patron",
"BRM_026": "Hungry Dragon",
"BRM_006": "Imp Gang Boss",
"BRM_011": "Lava Shock",
"BRM_027": "Majordomo Executus",
"BRM_030": "Nefarian",
"BRM_013": "Quick Shot",
"BRM_029": "Rend Blackhand",
"BRM_017": "Resurrect",
"BRM_015": "Revenge",
"BRM_001": "Solemn Vigil",
"BRM_004": "Twilight Whelp",
"BRM_025": "Volcanic Drake",
"BRM_009": "Volcanic Lumberer",
}
| slaymaker1907/hearthbreaker | tests/card_tests/id_mapping.py | Python | mit | 23,324 |
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link rel="stylesheet" href="{{ "/assets/css/bootstrap.min.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{ "/assets/css/icard_resume.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{ "/assets/css/font-awesome.min.css" | prepend: site.baseurl }}">
<link rel="icon" type="image/png" href="{{ site.favicon }}">
<!-- Google fonts -->
<link rel='stylesheet' href='//fonts.googleapis.com/css?family=Open+Sans:300' type='text/css'>
<link rel='stylesheet' href='//fonts.googleapis.com/css?family=Source+Sans+Pro' type='text/css'>
<!-- 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="assets/js/html5shiv.min.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->
</head>
| mrbriandavis/resumecard | _includes/head.html | HTML | mit | 1,420 |
/*
* Copyright (c) 2000-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
*/
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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 REGENTS 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.
*
* @(#)ip_var.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NETINET6_IP6_VAR_H_
#define _NETINET6_IP6_VAR_H_
#include <sys/appleapiopts.h>
#define IP6S_SRCRULE_COUNT 16
#include <netinet6/scope6_var.h>
struct ip6stat {
u_quad_t ip6s_total; /* total packets received */
u_quad_t ip6s_tooshort; /* packet too short */
u_quad_t ip6s_toosmall; /* not enough data */
u_quad_t ip6s_fragments; /* fragments received */
u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */
u_quad_t ip6s_fragtimeout; /* fragments timed out */
u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */
u_quad_t ip6s_forward; /* packets forwarded */
u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */
u_quad_t ip6s_redirectsent; /* packets forwarded on same net */
u_quad_t ip6s_delivered; /* datagrams delivered to upper level */
u_quad_t ip6s_localout; /* total ip packets generated here */
u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */
u_quad_t ip6s_reassembled; /* total packets reassembled ok */
u_quad_t ip6s_atmfrag_rcvd; /* atomic fragments received */
u_quad_t ip6s_fragmented; /* datagrams successfully fragmented */
u_quad_t ip6s_ofragments; /* output fragments created */
u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */
u_quad_t ip6s_badoptions; /* error in option processing */
u_quad_t ip6s_noroute; /* packets discarded due to no route */
u_quad_t ip6s_badvers; /* ip6 version != 6 */
u_quad_t ip6s_rawout; /* total raw ip packets generated */
u_quad_t ip6s_badscope; /* scope error */
u_quad_t ip6s_notmember; /* don't join this multicast group */
u_quad_t ip6s_nxthist[256]; /* next header history */
u_quad_t ip6s_m1; /* one mbuf */
u_quad_t ip6s_m2m[32]; /* two or more mbuf */
u_quad_t ip6s_mext1; /* one ext mbuf */
u_quad_t ip6s_mext2m; /* two or more ext mbuf */
u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */
u_quad_t ip6s_nogif; /* no match gif found */
u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */
/*
* statistics for improvement of the source address selection
* algorithm:
*/
/* number of times that address selection fails */
u_quad_t ip6s_sources_none;
/* number of times that an address on the outgoing I/F is chosen */
u_quad_t ip6s_sources_sameif[SCOPE6_ID_MAX];
/* number of times that an address on a non-outgoing I/F is chosen */
u_quad_t ip6s_sources_otherif[SCOPE6_ID_MAX];
/*
* number of times that an address that has the same scope
* from the destination is chosen.
*/
u_quad_t ip6s_sources_samescope[SCOPE6_ID_MAX];
/*
* number of times that an address that has a different scope
* from the destination is chosen.
*/
u_quad_t ip6s_sources_otherscope[SCOPE6_ID_MAX];
/* number of times that a deprecated address is chosen */
u_quad_t ip6s_sources_deprecated[SCOPE6_ID_MAX];
u_quad_t ip6s_forward_cachehit;
u_quad_t ip6s_forward_cachemiss;
/* number of times that each rule of source selection is applied. */
u_quad_t ip6s_sources_rule[IP6S_SRCRULE_COUNT];
/* number of times we ignored address on expensive secondary interfaces */
u_quad_t ip6s_sources_skip_expensive_secondary_if;
/* pkt dropped, no mbufs for control data */
u_quad_t ip6s_pktdropcntrl;
/* total packets trimmed/adjusted */
u_quad_t ip6s_adj;
/* hwcksum info discarded during adjustment */
u_quad_t ip6s_adj_hwcsum_clr;
/* duplicate address detection collisions */
u_quad_t ip6s_dad_collide;
/* DAD NS looped back */
u_quad_t ip6s_dad_loopcount;
};
enum ip6s_sources_rule_index {
IP6S_SRCRULE_0, IP6S_SRCRULE_1, IP6S_SRCRULE_2, IP6S_SRCRULE_3, IP6S_SRCRULE_4,
IP6S_SRCRULE_5, IP6S_SRCRULE_5_5, IP6S_SRCRULE_6, IP6S_SRCRULE_7,
IP6S_SRCRULE_7x, IP6S_SRCRULE_8
};
#endif /* !_NETINET6_IP6_VAR_H_ */
| e-t-h-a-n/esdarwin | macos-10124/esdarwin-destroot-b1/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/netinet6/ip6_var.h | C | mit | 8,526 |
package scorex.crypto.ads.merkle
import java.io.File
import org.mapdb.{DBMaker, HTreeMap, Serializer}
import scorex.crypto.hash.CryptographicHash.Digest
import scorex.storage.Storage
import scorex.utils.ScorexLogging
import scala.util.{Failure, Success, Try}
@deprecated("Use tree storage from scrypto library", "1.2.2")
class TreeStorage(fileName: String, levels: Int) extends Storage[(Int, Long), Array[Byte]] with ScorexLogging {
import TreeStorage._
private val dbs =
(0 to levels) map { n: Int =>
DBMaker.fileDB(new File(fileName + n + ".mapDB"))
.fileMmapEnableIfSupported()
.closeOnJvmShutdown()
.checksumEnable()
.make()
}
private val maps: Map[Int, HTreeMap[Long, Digest]] = {
val t = (0 to levels) map { n: Int =>
val m: HTreeMap[Long, Digest] = dbs(n).hashMapCreate("map_" + n)
.keySerializer(Serializer.LONG)
.valueSerializer(Serializer.BYTE_ARRAY)
.makeOrGet()
n -> m
}
t.toMap
}
override def set(key: Key, value: Digest): Unit = Try {
maps(key._1.asInstanceOf[Int]).put(key._2, value)
}.recoverWith { case t: Throwable =>
log.warn("Failed to set key:" + key, t)
Failure(t)
}
override def commit(): Unit = dbs.foreach(_.commit())
override def close(): Unit = {
commit()
dbs.foreach(_.close())
}
override def get(key: Key): Option[Digest] = {
Try {
maps(key._1).get(key._2)
} match {
case Success(v) =>
Option(v)
case Failure(e) =>
if (key._1 == 0) {
log.debug("Enable to load key for level 0: " + key)
}
None
}
}
}
object TreeStorage {
type Level = Int
type Position = Long
type Key = (Level, Position)
type Value = Digest
}
| ScorexProject/Scorex-Lagonaki | scorex-basics/src/main/scala/scorex/crypto/ads/merkle/TreeStorage.scala | Scala | cc0-1.0 | 1,770 |
/*******************************************************************************
* Copyright (c) 2017 Red Hat, Inc and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc - initial API and implementation
*******************************************************************************/
package org.eclipse.reddeer.eclipse.test;
import java.io.File;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.reddeer.eclipse.test"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
private static File location;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
location = FileLocator.getBundleFile(context.getBundle());
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
public static File getTestResourcesLocation(Class<?> testClass){
String packagePath = testClass.getPackage().getName().replace(".", "/");
return new File(new File(location, "resources"), packagePath);
}
}
| jboss-reddeer/reddeer | tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/Activator.java | Java | epl-1.0 | 1,910 |
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.forge.addon.maven.projects.facets;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import org.apache.maven.model.Model;
import org.jboss.forge.addon.facets.AbstractFacet;
import org.jboss.forge.addon.facets.constraints.FacetConstraint;
import org.jboss.forge.addon.maven.projects.MavenFacet;
import org.jboss.forge.addon.parser.java.facets.JavaCompilerFacet;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.furnace.util.Assert;
/**
* Configures the maven-compiler-plugin
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
* @author <a href="ggastald@redhat.com">George Gastaldi</a>
*/
@FacetConstraint(MavenFacet.class)
public class MavenJavaCompilerFacet extends AbstractFacet<Project>implements JavaCompilerFacet
{
static final String MAVEN_COMPILER_SOURCE_KEY = "maven.compiler.source";
static final String MAVEN_COMPILER_TARGET_KEY = "maven.compiler.target";
static final String MAVEN_COMPILER_ENCODING_KEY = "project.build.sourceEncoding";
@Override
public boolean isInstalled()
{
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
Properties properties = pom.getProperties();
List<String> keys = Arrays.asList(MAVEN_COMPILER_SOURCE_KEY, MAVEN_COMPILER_TARGET_KEY,
MAVEN_COMPILER_ENCODING_KEY);
return properties.keySet().containsAll(keys);
}
@Override
public boolean install()
{
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
Properties properties = pom.getProperties();
setMavenCompilerSource(properties, DEFAULT_COMPILER_VERSION.toString());
setMavenCompilerTarget(properties, DEFAULT_COMPILER_VERSION.toString());
properties.setProperty(MAVEN_COMPILER_ENCODING_KEY, "UTF-8");
maven.setModel(pom);
return true;
}
@Override
public void setSourceCompilerVersion(CompilerVersion version)
{
Assert.notNull(version, "The source compiler version must not be null");
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
setMavenCompilerSource(pom.getProperties(), version.toString());
maven.setModel(pom);
}
@Override
public void setTargetCompilerVersion(CompilerVersion version)
{
Assert.notNull(version, "The target compiler version must not be null");
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
setMavenCompilerTarget(pom.getProperties(), version.toString());
maven.setModel(pom);
}
@Override
public CompilerVersion getSourceCompilerVersion()
{
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
String sourceVersion = pom.getProperties().getProperty(MAVEN_COMPILER_SOURCE_KEY);
return sourceVersion != null ? CompilerVersion.getValue(sourceVersion) : DEFAULT_COMPILER_VERSION;
}
@Override
public CompilerVersion getTargetCompilerVersion()
{
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
String targetVersion = pom.getProperties().getProperty(MAVEN_COMPILER_TARGET_KEY);
return targetVersion != null ? CompilerVersion.getValue(targetVersion) : DEFAULT_COMPILER_VERSION;
}
private Properties setMavenCompilerSource(Properties mavenProps, String sourceCompilerVersion)
{
mavenProps.setProperty(MAVEN_COMPILER_SOURCE_KEY, sourceCompilerVersion);
return mavenProps;
}
private void setMavenCompilerTarget(Properties mavenProps, String targetCompilerVersion)
{
mavenProps.setProperty(MAVEN_COMPILER_TARGET_KEY, targetCompilerVersion);
}
}
| agoncal/core | maven/impl-projects/src/main/java/org/jboss/forge/addon/maven/projects/facets/MavenJavaCompilerFacet.java | Java | epl-1.0 | 3,999 |
package org.restlet.example.book.restlet.ch05.sec6.server;
import org.restlet.example.book.restlet.ch03.sect5.sub5.common.RootResource;
import org.restlet.resource.ServerResource;
/**
* Root resource implementation.
*/
public class RootServerResource extends ServerResource implements RootResource {
public String represent() {
return "Welcome to the " + getApplication().getName() + " !";
}
}
| debrief/debrief | org.mwc.asset.comms/docs/restlet_src/org.restlet.example/org/restlet/example/book/restlet/ch05/sec6/server/RootServerResource.java | Java | epl-1.0 | 431 |
/*
* Copyright (c) 2012-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.api.system.shared.event.service;
import java.util.Objects;
import org.eclipse.che.api.system.shared.event.SystemEvent;
/**
* The base class for system service events.
*
* @author Yevhenii Voevodin
*/
public abstract class SystemServiceEvent implements SystemEvent {
protected final String serviceName;
protected SystemServiceEvent(String serviceName) {
this.serviceName = Objects.requireNonNull(serviceName, "Service name required");
}
public String getServiceName() {
return serviceName;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof SystemServiceEvent)) {
return false;
}
final SystemServiceEvent that = (SystemServiceEvent) obj;
return Objects.equals(getType(), that.getType())
&& Objects.equals(serviceName, that.serviceName);
}
@Override
public int hashCode() {
int hash = 17;
hash = 31 * hash + Objects.hashCode(getType());
hash = 31 * hash + Objects.hashCode(serviceName);
return hash;
}
@Override
public String toString() {
return getClass().getSimpleName()
+ "{eventType='"
+ getType()
+ "', serviceName="
+ serviceName
+ "'}";
}
}
| TypeFox/che | wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceEvent.java | Java | epl-1.0 | 1,640 |
/**
* Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Eclipse Public License (EPL).
* Please see the license.txt included with this distribution for details.
* Any modifications to this file must keep this entire header intact.
*/
/*
* Created on Oct 13, 2004
*
* @author Fabio Zadrozny
*/
package org.python.pydev.tree;
import java.io.File;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
/**
* @author Fabio Zadrozny
*/
public class AllowValidPathsFilter extends ViewerFilter {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return ((File) element).exists();
}
} | akurtakov/Pydev | plugins/org.python.pydev/src/org/python/pydev/tree/AllowValidPathsFilter.java | Java | epl-1.0 | 917 |
/**
* Copyright 2005-2010 Noelios Technologies.
*
* The contents of this file are subject to the terms of one of the following
* open source licenses: LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL 1.0 (the
* "Licenses"). You can select the license that you prefer but you may not use
* this file except in compliance with one of these Licenses.
*
* You can obtain a copy of the LGPL 3.0 license at
* http://www.opensource.org/licenses/lgpl-3.0.html
*
* You can obtain a copy of the LGPL 2.1 license at
* http://www.opensource.org/licenses/lgpl-2.1.php
*
* You can obtain a copy of the CDDL 1.0 license at
* http://www.opensource.org/licenses/cddl1.php
*
* You can obtain a copy of the EPL 1.0 license at
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* See the Licenses for the specific language governing permissions and
* limitations under the Licenses.
*
* Alternatively, you can obtain a royalty free commercial license with less
* limitations, transferable or non-transferable, directly at
* http://www.noelios.com/products/restlet-engine
*
* Restlet is a registered trademark of Noelios Technologies.
*/
package org.restlet.engine.log;
import java.util.concurrent.ThreadFactory;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Thread factory that logs uncaught exceptions thrown by the created threads.
*
* @author Jerome Louvel
*/
public class LoggingThreadFactory implements ThreadFactory {
/**
* Handle uncaught thread exceptions.
*/
private class LoggingExceptionHandler implements
Thread.UncaughtExceptionHandler {
public void uncaughtException(Thread t, Throwable ex) {
logger.log(Level.SEVERE, "Thread: " + t.getName()
+ " terminated with exception: " + ex.getMessage(), ex);
}
}
/** The associated logger. */
private final Logger logger;
/** Indicates if threads should be created as daemons. */
private final boolean daemon;
/**
* Constructor.
*
* @param logger
* The associated logger.
*/
public LoggingThreadFactory(Logger logger) {
this(logger, false);
}
/**
* Constructor.
*
* @param logger
* The associated logger.
* @param daemon
* Indicates if threads should be created as daemons.
*/
public LoggingThreadFactory(Logger logger, boolean daemon) {
this.logger = logger;
this.daemon = daemon;
}
/**
* Creates a new thread.
*
* @param r
* The runnable task.
*/
public Thread newThread(Runnable r) {
Thread result = new Thread(r);
result.setName("Restlet-" + result.hashCode());
result.setUncaughtExceptionHandler(new LoggingExceptionHandler());
result.setDaemon(this.daemon);
return result;
}
}
| debrief/debrief | org.mwc.asset.comms/docs/restlet_src/org.restlet/org/restlet/engine/log/LoggingThreadFactory.java | Java | epl-1.0 | 3,017 |
/**
* Copyright (c) 2011, 2014 Eurotech and/or its affiliates
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eurotech
*/
package org.eclipse.kura.core.cloud;
import java.io.IOException;
/**
* Common interface for the PayloadEncoders
*/
public interface CloudPayloadEncoder
{
public byte[] getBytes() throws IOException;
}
| mhddurrah/kura | kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/cloud/CloudPayloadEncoder.java | Java | epl-1.0 | 561 |
/*****************************************************************************
* posterize.c : Posterize video plugin for vlc
*****************************************************************************
* Copyright (C) 2010 VLC authors and VideoLAN
* $Id: 4f80ff2a53336271b7e6a64f1a744023eb89a6d0 $
*
* Authors: Branko Kokanovic <branko.kokanovic@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_atomic.h>
#include <vlc_filter.h>
#include "filter_picture.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Create ( vlc_object_t * );
static void Destroy ( vlc_object_t * );
static picture_t *Filter( filter_t *, picture_t * );
static void PlanarYUVPosterize( picture_t *, picture_t *, int);
static void PackedYUVPosterize( picture_t *, picture_t *, int);
static void RVPosterize( picture_t *, picture_t *, bool, int );
static void YuvPosterization( uint8_t *, uint8_t *, uint8_t *, uint8_t *,
uint8_t, uint8_t, uint8_t, uint8_t, int );
static const char *const ppsz_filter_options[] = {
"level", NULL
};
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define POSTERIZE_LEVEL_TEXT N_("Posterize level")
#define POSTERIZE_LEVEL_LONGTEXT N_("Posterize level "\
"(number of colors is cube of this value)" )
#define CFG_PREFIX "posterize-"
vlc_module_begin ()
set_description( N_("Posterize video filter") )
set_shortname( N_("Posterize" ) )
set_help( N_("Posterize video by lowering the number of colors") )
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_VFILTER )
set_capability( "video filter2", 0 )
add_integer_with_range( CFG_PREFIX "level", 6, 2, 256,
POSTERIZE_LEVEL_TEXT, POSTERIZE_LEVEL_LONGTEXT,
false )
set_callbacks( Create, Destroy )
vlc_module_end ()
/*****************************************************************************
* callback prototypes
*****************************************************************************/
static int FilterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* filter_sys_t: adjust filter method descriptor
*****************************************************************************/
struct filter_sys_t
{
atomic_int i_level;
};
/*****************************************************************************
* Create: allocates Posterize video thread output method
*****************************************************************************
* This function allocates and initializes a Posterize vout method.
*****************************************************************************/
static int Create( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
switch( p_filter->fmt_in.video.i_chroma )
{
CASE_PLANAR_YUV_SQUARE
break;
CASE_PACKED_YUV_422
break;
case VLC_CODEC_RGB24:
break;
case VLC_CODEC_RGB32:
break;
default:
msg_Err( p_filter, "Unsupported input chroma (%4.4s)",
(char*)&(p_filter->fmt_in.video.i_chroma) );
return VLC_EGENERIC;
}
if( p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma )
{
msg_Err( p_filter, "Input and output chromas don't match" );
return VLC_EGENERIC;
}
/* Allocate structure */
p_sys = p_filter->p_sys = (filter_sys_t *)malloc( sizeof( filter_sys_t ) ); // sunqueen modify
if( p_filter->p_sys == NULL )
return VLC_ENOMEM;
config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
p_filter->p_cfg );
atomic_init( &p_sys->i_level,
var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "level" ) );
var_AddCallback( p_filter, CFG_PREFIX "level", FilterCallback, p_sys );
p_filter->pf_video_filter = Filter;
return VLC_SUCCESS;
}
/*****************************************************************************
* Destroy: destroy Posterize video thread output method
*****************************************************************************
* Terminate an output method created by PosterizeCreateOutputMethod
*****************************************************************************/
static void Destroy( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
var_DelCallback( p_filter, CFG_PREFIX "level", FilterCallback, p_sys );
free( p_sys );
}
/*****************************************************************************
* Render: displays previously rendered output
*****************************************************************************
* This function send the currently rendered image to Posterize image, waits
* until it is displayed and switch the two rendering buffers, preparing next
* frame.
*****************************************************************************/
static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
picture_t *p_outpic;
if( !p_pic ) return NULL;
filter_sys_t *p_sys = p_filter->p_sys;
int level = atomic_load( &p_sys->i_level );
p_outpic = filter_NewPicture( p_filter );
if( !p_outpic )
{
msg_Warn( p_filter, "can't get output picture" );
picture_Release( p_pic );
return NULL;
}
switch( p_pic->format.i_chroma )
{
case VLC_CODEC_RGB24:
RVPosterize( p_pic, p_outpic, false, level );
break;
case VLC_CODEC_RGB32:
RVPosterize( p_pic, p_outpic, true, level );
break;
CASE_PLANAR_YUV_SQUARE
PlanarYUVPosterize( p_pic, p_outpic, level );
break;
CASE_PACKED_YUV_422
PackedYUVPosterize( p_pic, p_outpic, level );
break;
default:
assert( false );
}
return CopyInfoAndRelease( p_outpic, p_pic );
}
/*****************************************************************************
* For a given level, calculates new posterized value for pixel whose value x
* is in range of 0-255
*****************************************************************************/
#define POSTERIZE_PIXEL(x, level) \
(((( x * level ) >> 8 ) * 255 ) / ( level - 1 ))
/*****************************************************************************
* PlanarYUVPosterize: Posterize one frame of the planar YUV video
*****************************************************************************
* This function posterizes one frame of the video by iterating through video
* lines. In every pass, start of Y, U and V planes is calculated and for
* every pixel we calculate new values of YUV values.
*****************************************************************************/
static void PlanarYUVPosterize( picture_t *p_pic, picture_t *p_outpic,
int i_level )
{
uint8_t *p_in_y, *p_in_u, *p_in_v, *p_in_end_y, *p_line_end_y, *p_out_y,
*p_out_u, *p_out_v;
int i_current_line = 0;
p_in_y = p_pic->p[Y_PLANE].p_pixels;
p_in_end_y = p_in_y + p_pic->p[Y_PLANE].i_visible_lines
* p_pic->p[Y_PLANE].i_pitch;
p_out_y = p_outpic->p[Y_PLANE].p_pixels;
/* iterate for every visible line in the frame */
while( p_in_y < p_in_end_y )
{
p_line_end_y = p_in_y + p_pic->p[Y_PLANE].i_visible_pitch;
/* calculate start of U plane line */
p_in_u = p_pic->p[U_PLANE].p_pixels
+ p_pic->p[U_PLANE].i_pitch * ( i_current_line / 2 );
p_out_u = p_outpic->p[U_PLANE].p_pixels
+ p_outpic->p[U_PLANE].i_pitch * ( i_current_line / 2 );
/* calculate start of V plane line */
p_in_v = p_pic->p[V_PLANE].p_pixels
+ p_pic->p[V_PLANE].i_pitch * ( i_current_line / 2 );
p_out_v = p_outpic->p[V_PLANE].p_pixels
+ p_outpic->p[V_PLANE].i_pitch * ( i_current_line / 2 );
/* iterate for every two pixels in line */
while( p_in_y < p_line_end_y )
{
uint8_t y1, y2, u, v;
uint8_t posterized_y1, posterized_y2, posterized_u, posterized_v;
/* retrieve original YUV values */
y1 = *p_in_y++;
y2 = *p_in_y++;
u = *p_in_u++;
v = *p_in_v++;
/* do posterization */
YuvPosterization( &posterized_y1, &posterized_y2, &posterized_u,
&posterized_v, y1, y2, u, v, i_level );
/* put posterized valued */
*p_out_y++ = posterized_y1;
*p_out_y++ = posterized_y2;
*p_out_u++ = posterized_u;
*p_out_v++ = posterized_v;
}
p_in_y += p_pic->p[Y_PLANE].i_pitch
- p_pic->p[Y_PLANE].i_visible_pitch;
p_out_y += p_outpic->p[Y_PLANE].i_pitch
- p_outpic->p[Y_PLANE].i_visible_pitch;
i_current_line++;
}
}
/*****************************************************************************
* PackedYUVPosterize: Posterize one frame of the packed YUV video
*****************************************************************************
* This function posterizes one frame of the video by iterating through video
* lines. In every pass, we calculate new values for pixels (UYVY, VYUY, YUYV
* and YVYU formats are supported)
*****************************************************************************/
static void PackedYUVPosterize( picture_t *p_pic, picture_t *p_outpic, int i_level )
{
uint8_t *p_in, *p_in_end, *p_line_end, *p_out;
uint8_t y1, y2, u, v;
p_in = p_pic->p[0].p_pixels;
p_in_end = p_in + p_pic->p[0].i_visible_lines
* p_pic->p[0].i_pitch;
p_out = p_outpic->p[0].p_pixels;
while( p_in < p_in_end )
{
p_line_end = p_in + p_pic->p[0].i_visible_pitch;
while( p_in < p_line_end )
{
uint8_t posterized_y1, posterized_y2, posterized_u, posterized_v;
/* extract proper pixel values */
switch( p_pic->format.i_chroma )
{
case VLC_CODEC_UYVY:
u = *p_in++;
y1 = *p_in++;
v = *p_in++;
y2 = *p_in++;
break;
case VLC_CODEC_VYUY:
v = *p_in++;
y1 = *p_in++;
u = *p_in++;
y2 = *p_in++;
break;
case VLC_CODEC_YUYV:
y1 = *p_in++;
u = *p_in++;
y2 = *p_in++;
v = *p_in++;
break;
case VLC_CODEC_YVYU:
y1 = *p_in++;
v = *p_in++;
y2 = *p_in++;
u = *p_in++;
break;
default:
assert( false );
}
/* do posterization */
YuvPosterization( &posterized_y1, &posterized_y2, &posterized_u,
&posterized_v, y1, y2, u, v, i_level );
/* put posterized values in proper place */
switch( p_pic->format.i_chroma )
{
case VLC_CODEC_UYVY:
*p_out++ = posterized_u;
*p_out++ = posterized_y1;
*p_out++ = posterized_v;
*p_out++ = posterized_y2;
break;
case VLC_CODEC_VYUY:
*p_out++ = posterized_v;
*p_out++ = posterized_y1;
*p_out++ = posterized_u;
*p_out++ = posterized_y2;
break;
case VLC_CODEC_YUYV:
*p_out++ = posterized_y1;
*p_out++ = posterized_u;
*p_out++ = posterized_y2;
*p_out++ = posterized_v;
break;
case VLC_CODEC_YVYU:
*p_out++ = posterized_y1;
*p_out++ = posterized_v;
*p_out++ = posterized_y2;
*p_out++ = posterized_u;
break;
default:
assert( false );
}
}
p_in += p_pic->p[0].i_pitch - p_pic->p[0].i_visible_pitch;
p_out += p_outpic->p[0].i_pitch
- p_outpic->p[0].i_visible_pitch;
}
}
/*****************************************************************************
* RVPosterize: Posterize one frame of the RV24/RV32 video
*****************************************************************************
* This function posterizes one frame of the video by iterating through video
* lines and calculating new values for every byte in chunks of 3 (RV24) or
* 4 (RV32) bytes
*****************************************************************************/
static void RVPosterize( picture_t *p_pic, picture_t *p_outpic,
bool rv32, int level )
{
uint8_t *p_in, *p_in_end, *p_line_end, *p_out, pixel;
p_in = p_pic->p[0].p_pixels;
p_in_end = p_in + p_pic->p[0].i_visible_lines
* p_pic->p[0].i_pitch;
p_out = p_outpic->p[0].p_pixels;
while( p_in < p_in_end )
{
p_line_end = p_in + p_pic->p[0].i_visible_pitch;
while( p_in < p_line_end )
{
pixel = *p_in++;
*p_out++ = POSTERIZE_PIXEL( pixel, level );
pixel = *p_in++;
*p_out++ = POSTERIZE_PIXEL( pixel, level );
pixel = *p_in++;
*p_out++ = POSTERIZE_PIXEL( pixel, level );
/* for rv32 we take 4 chunks at the time */
if ( rv32 )
{
pixel = *p_in++;
*p_out++ = POSTERIZE_PIXEL( pixel, level );
}
}
p_in += p_pic->p[0].i_pitch - p_pic->p[0].i_visible_pitch;
p_out += p_outpic->p[0].i_pitch
- p_outpic->p[0].i_visible_pitch;
}
}
/*****************************************************************************
* YuvPosterization: Lowers the color depth of YUV color space
*****************************************************************************
* This function lowers the color level of YUV color space to specified level
* by converting YUV color values to theirs RGB equivalents, calculates new
* values and then converts RGB values to YUV values again.
*****************************************************************************/
static void YuvPosterization( uint8_t* posterized_y1, uint8_t* posterized_y2,
uint8_t* posterized_u, uint8_t* posterized_v,
uint8_t y1, uint8_t y2, uint8_t u, uint8_t v,
int i_level ) {
int r1, g1, b1; /* for y1 new value */
int r2, b2, g2; /* for y2 new value */
int r3, g3, b3; /* for new values of u and v */
/* fist convert YUV -> RGB */
yuv_to_rgb( &r1, &g1, &b1, y1, u, v );
yuv_to_rgb( &r2, &g2, &b2, y1, u, v );
yuv_to_rgb( &r3, &g3, &b3, ( y1 + y2 ) / 2, u, v );
/* round RGB values to specified posterize level */
r1 = POSTERIZE_PIXEL( r1, i_level );
g1 = POSTERIZE_PIXEL( g1, i_level );
b1 = POSTERIZE_PIXEL( b1, i_level );
r2 = POSTERIZE_PIXEL( r2, i_level );
g2 = POSTERIZE_PIXEL( g2, i_level );
b2 = POSTERIZE_PIXEL( b2, i_level );
r3 = POSTERIZE_PIXEL( r3, i_level );
g3 = POSTERIZE_PIXEL( g3, i_level );
b3 = POSTERIZE_PIXEL( b3, i_level );
/* convert from calculated RGB -> YUV */
*posterized_y1 = ( ( 66 * r1 + 129 * g1 + 25 * b1 + 128 ) >> 8 ) + 16;
*posterized_y2 = ( ( 66 * r2 + 129 * g2 + 25 * b2 + 128 ) >> 8 ) + 16;
*posterized_u = ( ( -38 * r3 - 74 * g3 + 112 * b3 + 128 ) >> 8 ) + 128;
*posterized_v = ( ( 112 * r3 - 94 * g3 - 18 * b3 + 128 ) >> 8 ) + 128;
}
static int FilterCallback ( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
(void)p_this; (void)oldval;
filter_sys_t *p_sys = (filter_sys_t *)p_data; // sunqueen modify
if( !strcmp( psz_var, CFG_PREFIX "level" ) )
atomic_store( &p_sys->i_level, (atomic_int)newval.i_int ); // sunqueen modify
return VLC_SUCCESS;
}
| sunqueen/vlc-2.1.4.32.subproject-2013-update2 | modules/video_filter/posterize.c | C | gpl-2.0 | 17,843 |
<?php
/**
* @version $Id: default.php 39490 2011-07-05 06:50:31Z btowles $
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
?>
<?php if ($that->show_page_heading): ?>
<h1><?php echo $that->page_heading; ?></h1>
<?php endif; ?>
<div class="rg-list-view-container<?php echo $that->pageclass_sfx; ?>">
<?php echo RokCommon_Composite::get($that->context)->load('header.php', array('that' => $that));?>
<div class="rg-list-view rg-col2">
<?php
foreach ($that->images as $that->image):
$that->slice = $that->slices[$that->image->id];
echo RokCommon_Composite::get($that->context)->load('default_row.php', array('that' => $that));
$that->item_number++;
endforeach;
?>
</div>
</div>
<?php echo RokCommon_Composite::get($that->context)->load('pagination.php', array('that' => $that));?> | larenz/Gokujo | components/com_rokgallery/templates/gallery/list-2col/default.php | PHP | gpl-2.0 | 1,003 |
<?php
/**
* @file
* Contains Drupal\page_manager\Form\PageVariantAddForm.
*/
namespace Drupal\page_manager\Form;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a form for adding a variant.
*/
class PageVariantAddForm extends PageVariantFormBase {
/**
* {@inheritdoc}
*/
protected function submitText() {
return $this->t('Add variant');
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
$form_state->setRedirectUrl($this->getEntity()->toUrl('edit-form'));
}
}
| ccatalina/panopoly8.x-2.0-alpha1 | profiles/panopoly/modules/contrib/page_manager/src/Form/PageVariantAddForm.php | PHP | gpl-2.0 | 593 |
#!/bin/sh
# /**
# * ---------------------------------------------------------------------
# * GLPI - Gestionnaire Libre de Parc Informatique
# * Copyright (C) 2015-2018 Teclib' and contributors.
# *
# * http://glpi-project.org
# *
# * based on GLPI - Gestionnaire Libre de Parc Informatique
# * Copyright (C) 2003-2014 by the INDEPNET Development Team.
# *
# * ---------------------------------------------------------------------
# *
# * LICENSE
# *
# * This file is part of GLPI.
# *
# * GLPI 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.
# *
# * GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>.
# * ---------------------------------------------------------------------
# */
cd $(dirname $0)
if which apigen &>/dev/null
then
version=$(php -r '
require __DIR__ . "/../inc/define.php";
echo GLPI_VERSION;
')
apigen generate \
--access-levels=public,protected,private \
--todo \
--deprecated \
--tree \
--title "GLPI version $version API" \
--source ../inc \
--destination api
else
echo -e "\nApiGen not found, see http://www.apigen.org/\n"
fi
| orouet/glpi | tools/genapidoc.sh | Shell | gpl-2.0 | 1,662 |
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
CONTROLS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
typedef struct {
char *command;
char *label;
int id;
int anim;
int defaultbind1;
int defaultbind2;
int bind1;
int bind2;
} bind_t;
typedef struct
{
char* name;
float defaultvalue;
float value;
} configcvar_t;
#define SAVE_NOOP 0
#define SAVE_YES 1
#define SAVE_NO 2
#define SAVE_CANCEL 3
// control sections
#define C_MOVEMENT 0
#define C_LOOKING 1
#define C_WEAPONS 2
#define C_MISC 3
#define C_MAX 4
#define ID_MOVEMENT 100
#define ID_LOOKING 101
#define ID_WEAPONS 102
#define ID_MISC 103
#define ID_DEFAULTS 104
#define ID_BACK 105
#define ID_SAVEANDEXIT 106
#define ID_EXIT 107
// bindable actions
#define ID_SHOWSCORES 0
#define ID_USEITEM 1
#define ID_SPEED 2
#define ID_FORWARD 3
#define ID_BACKPEDAL 4
#define ID_MOVELEFT 5
#define ID_MOVERIGHT 6
#define ID_MOVEUP 7
#define ID_MOVEDOWN 8
#define ID_LEFT 9
#define ID_RIGHT 10
#define ID_STRAFE 11
#define ID_LOOKUP 12
#define ID_LOOKDOWN 13
#define ID_MOUSELOOK 14
#define ID_CENTERVIEW 15
#define ID_ZOOMVIEW 16
#define ID_WEAPON1 17
#define ID_WEAPON2 18
#define ID_WEAPON3 19
#define ID_WEAPON4 20
#define ID_WEAPON5 21
#define ID_WEAPON6 22
#define ID_WEAPON7 23
#define ID_WEAPON8 24
#define ID_WEAPON9 25
#define ID_ATTACK 26
#define ID_WEAPPREV 27
#define ID_WEAPNEXT 28
#define ID_GESTURE 29
#define ID_CHAT 30
#define ID_CHAT2 31
#define ID_CHAT3 32
#define ID_CHAT4 33
// all others
#define ID_FREELOOK 34
#define ID_INVERTMOUSE 35
#define ID_ALWAYSRUN 36
#define ID_AUTOSWITCH 37
#define ID_MOUSESPEED 38
#define ID_JOYENABLE 39
#define ID_JOYTHRESHOLD 40
#define ID_SMOOTHMOUSE 41
#define ANIM_IDLE 0
#define ANIM_RUN 1
#define ANIM_WALK 2
#define ANIM_BACK 3
#define ANIM_JUMP 4
#define ANIM_CROUCH 5
#define ANIM_STEPLEFT 6
#define ANIM_STEPRIGHT 7
#define ANIM_TURNLEFT 8
#define ANIM_TURNRIGHT 9
#define ANIM_LOOKUP 10
#define ANIM_LOOKDOWN 11
#define ANIM_WEAPON1 12
#define ANIM_WEAPON2 13
#define ANIM_WEAPON3 14
#define ANIM_WEAPON4 15
#define ANIM_WEAPON5 16
#define ANIM_WEAPON6 17
#define ANIM_WEAPON7 18
#define ANIM_WEAPON8 19
#define ANIM_WEAPON9 20
#define ANIM_WEAPON10 21
#define ANIM_ATTACK 22
#define ANIM_GESTURE 23
#define ANIM_DIE 24
#define ANIM_CHAT 25
typedef struct
{
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menubitmap_s player;
menutext_s movement;
menutext_s looking;
menutext_s weapons;
menutext_s misc;
menuaction_s walkforward;
menuaction_s backpedal;
menuaction_s stepleft;
menuaction_s stepright;
menuaction_s moveup;
menuaction_s movedown;
menuaction_s turnleft;
menuaction_s turnright;
menuaction_s sidestep;
menuaction_s run;
menuaction_s machinegun;
menuaction_s chainsaw;
menuaction_s shotgun;
menuaction_s grenadelauncher;
menuaction_s rocketlauncher;
menuaction_s lightning;
menuaction_s railgun;
menuaction_s plasma;
menuaction_s bfg;
menuaction_s attack;
menuaction_s prevweapon;
menuaction_s nextweapon;
menuaction_s lookup;
menuaction_s lookdown;
menuaction_s mouselook;
menuradiobutton_s freelook;
menuaction_s centerview;
menuaction_s zoomview;
menuaction_s gesture;
menuradiobutton_s invertmouse;
menuslider_s sensitivity;
menuradiobutton_s smoothmouse;
menuradiobutton_s alwaysrun;
menuaction_s showscores;
menuradiobutton_s autoswitch;
menuaction_s useitem;
playerInfo_t playerinfo;
qboolean changesmade;
menuaction_s chat;
menuaction_s chat2;
menuaction_s chat3;
menuaction_s chat4;
menuradiobutton_s joyenable;
menuslider_s joythreshold;
int section;
qboolean waitingforkey;
char playerModel[64];
vec3_t playerViewangles;
vec3_t playerMoveangles;
int playerLegs;
int playerTorso;
int playerWeapon;
qboolean playerChat;
menubitmap_s back;
menutext_s name;
} controls_t;
static controls_t s_controls;
static vec4_t controls_binding_color = {1.00f, 0.43f, 0.00f, 1.00f}; // bk: Win32 C4305
static bind_t g_bindings[] =
{
{"+scores", "show scores", ID_SHOWSCORES, ANIM_IDLE, K_TAB, -1, -1, -1},
{"+button2", "use item", ID_USEITEM, ANIM_IDLE, K_ENTER, -1, -1, -1},
{"+speed", "run / walk", ID_SPEED, ANIM_RUN, K_SHIFT, -1, -1, -1},
{"+forward", "walk forward", ID_FORWARD, ANIM_WALK, K_UPARROW, -1, -1, -1},
{"+back", "backpedal", ID_BACKPEDAL, ANIM_BACK, K_DOWNARROW, -1, -1, -1},
{"+moveleft", "step left", ID_MOVELEFT, ANIM_STEPLEFT, ',', -1, -1, -1},
{"+moveright", "step right", ID_MOVERIGHT, ANIM_STEPRIGHT, '.', -1, -1, -1},
{"+moveup", "up / jump", ID_MOVEUP, ANIM_JUMP, K_SPACE, -1, -1, -1},
{"+movedown", "down / crouch", ID_MOVEDOWN, ANIM_CROUCH, 'c', -1, -1, -1},
{"+left", "turn left", ID_LEFT, ANIM_TURNLEFT, K_LEFTARROW, -1, -1, -1},
{"+right", "turn right", ID_RIGHT, ANIM_TURNRIGHT, K_RIGHTARROW, -1, -1, -1},
{"+strafe", "sidestep / turn", ID_STRAFE, ANIM_IDLE, K_ALT, -1, -1, -1},
{"+lookup", "look up", ID_LOOKUP, ANIM_LOOKUP, K_PGDN, -1, -1, -1},
{"+lookdown", "look down", ID_LOOKDOWN, ANIM_LOOKDOWN, K_DEL, -1, -1, -1},
{"+mlook", "mouse look", ID_MOUSELOOK, ANIM_IDLE, '/', -1, -1, -1},
{"centerview", "center view", ID_CENTERVIEW, ANIM_IDLE, K_END, -1, -1, -1},
{"+zoom", "zoom view", ID_ZOOMVIEW, ANIM_IDLE, -1, -1, -1, -1},
{"weapon 1", "gauntlet", ID_WEAPON1, ANIM_WEAPON1, '1', -1, -1, -1},
{"weapon 2", "machinegun", ID_WEAPON2, ANIM_WEAPON2, '2', -1, -1, -1},
{"weapon 3", "shotgun", ID_WEAPON3, ANIM_WEAPON3, '3', -1, -1, -1},
{"weapon 4", "grenade launcher", ID_WEAPON4, ANIM_WEAPON4, '4', -1, -1, -1},
{"weapon 5", "rocket launcher", ID_WEAPON5, ANIM_WEAPON5, '5', -1, -1, -1},
{"weapon 6", "lightning", ID_WEAPON6, ANIM_WEAPON6, '6', -1, -1, -1},
{"weapon 7", "railgun", ID_WEAPON7, ANIM_WEAPON7, '7', -1, -1, -1},
{"weapon 8", "plasma gun", ID_WEAPON8, ANIM_WEAPON8, '8', -1, -1, -1},
{"weapon 9", "BFG", ID_WEAPON9, ANIM_WEAPON9, '9', -1, -1, -1},
{"+attack", "attack", ID_ATTACK, ANIM_ATTACK, K_CTRL, -1, -1, -1},
{"weapprev", "prev weapon", ID_WEAPPREV, ANIM_IDLE, '[', -1, -1, -1},
{"weapnext", "next weapon", ID_WEAPNEXT, ANIM_IDLE, ']', -1, -1, -1},
{"+button3", "gesture", ID_GESTURE, ANIM_GESTURE, K_MOUSE3, -1, -1, -1},
{"messagemode", "chat", ID_CHAT, ANIM_CHAT, 't', -1, -1, -1},
{"messagemode2", "chat - team", ID_CHAT2, ANIM_CHAT, -1, -1, -1, -1},
{"messagemode3", "chat - target", ID_CHAT3, ANIM_CHAT, -1, -1, -1, -1},
{"messagemode4", "chat - attacker", ID_CHAT4, ANIM_CHAT, -1, -1, -1, -1},
{(char*)NULL, (char*)NULL, 0, 0, -1, -1, -1, -1},
};
static configcvar_t g_configcvars[] =
{
{"cl_run", 0, 0},
{"m_pitch", 0, 0},
{"cg_autoswitch", 0, 0},
{"sensitivity", 0, 0},
{"in_joystick", 0, 0},
{"joy_threshold", 0, 0},
{"m_filter", 0, 0},
{"cl_freelook", 0, 0},
{NULL, 0, 0}
};
static menucommon_s *g_movement_controls[] =
{
(menucommon_s *)&s_controls.alwaysrun,
(menucommon_s *)&s_controls.run,
(menucommon_s *)&s_controls.walkforward,
(menucommon_s *)&s_controls.backpedal,
(menucommon_s *)&s_controls.stepleft,
(menucommon_s *)&s_controls.stepright,
(menucommon_s *)&s_controls.moveup,
(menucommon_s *)&s_controls.movedown,
(menucommon_s *)&s_controls.turnleft,
(menucommon_s *)&s_controls.turnright,
(menucommon_s *)&s_controls.sidestep,
NULL
};
static menucommon_s *g_weapons_controls[] = {
(menucommon_s *)&s_controls.attack,
(menucommon_s *)&s_controls.nextweapon,
(menucommon_s *)&s_controls.prevweapon,
(menucommon_s *)&s_controls.autoswitch,
(menucommon_s *)&s_controls.chainsaw,
(menucommon_s *)&s_controls.machinegun,
(menucommon_s *)&s_controls.shotgun,
(menucommon_s *)&s_controls.grenadelauncher,
(menucommon_s *)&s_controls.rocketlauncher,
(menucommon_s *)&s_controls.lightning,
(menucommon_s *)&s_controls.railgun,
(menucommon_s *)&s_controls.plasma,
(menucommon_s *)&s_controls.bfg,
NULL,
};
static menucommon_s *g_looking_controls[] = {
(menucommon_s *)&s_controls.sensitivity,
(menucommon_s *)&s_controls.smoothmouse,
(menucommon_s *)&s_controls.invertmouse,
(menucommon_s *)&s_controls.lookup,
(menucommon_s *)&s_controls.lookdown,
(menucommon_s *)&s_controls.mouselook,
(menucommon_s *)&s_controls.freelook,
(menucommon_s *)&s_controls.centerview,
(menucommon_s *)&s_controls.zoomview,
(menucommon_s *)&s_controls.joyenable,
(menucommon_s *)&s_controls.joythreshold,
NULL,
};
static menucommon_s *g_misc_controls[] = {
(menucommon_s *)&s_controls.showscores,
(menucommon_s *)&s_controls.useitem,
(menucommon_s *)&s_controls.gesture,
(menucommon_s *)&s_controls.chat,
(menucommon_s *)&s_controls.chat2,
(menucommon_s *)&s_controls.chat3,
(menucommon_s *)&s_controls.chat4,
NULL,
};
static menucommon_s **g_controls[] = {
g_movement_controls,
g_looking_controls,
g_weapons_controls,
g_misc_controls,
};
/*
=================
Controls_InitCvars
=================
*/
static void Controls_InitCvars( void )
{
int i;
configcvar_t* cvarptr;
cvarptr = g_configcvars;
for (i=0; ;i++,cvarptr++)
{
if (!cvarptr->name)
break;
// get current value
cvarptr->value = trap_Cvar_VariableValue( cvarptr->name );
// get default value
trap_Cvar_Reset( cvarptr->name );
cvarptr->defaultvalue = trap_Cvar_VariableValue( cvarptr->name );
// restore current value
trap_Cvar_SetValue( cvarptr->name, cvarptr->value );
}
}
/*
=================
Controls_GetCvarDefault
=================
*/
static float Controls_GetCvarDefault( char* name )
{
configcvar_t* cvarptr;
int i;
cvarptr = g_configcvars;
for (i=0; ;i++,cvarptr++)
{
if (!cvarptr->name)
return (0);
if (!strcmp(cvarptr->name,name))
break;
}
return (cvarptr->defaultvalue);
}
/*
=================
Controls_GetCvarValue
=================
*/
static float Controls_GetCvarValue( char* name )
{
configcvar_t* cvarptr;
int i;
cvarptr = g_configcvars;
for (i=0; ;i++,cvarptr++)
{
if (!cvarptr->name)
return (0);
if (!strcmp(cvarptr->name,name))
break;
}
return (cvarptr->value);
}
/*
=================
Controls_UpdateModel
=================
*/
static void Controls_UpdateModel( int anim ) {
VectorClear( s_controls.playerViewangles );
VectorClear( s_controls.playerMoveangles );
s_controls.playerViewangles[YAW] = 180 - 30;
s_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW];
s_controls.playerLegs = LEGS_IDLE;
s_controls.playerTorso = TORSO_STAND;
s_controls.playerWeapon = -1;
s_controls.playerChat = qfalse;
switch( anim ) {
case ANIM_RUN:
s_controls.playerLegs = LEGS_RUN;
break;
case ANIM_WALK:
s_controls.playerLegs = LEGS_WALK;
break;
case ANIM_BACK:
s_controls.playerLegs = LEGS_BACK;
break;
case ANIM_JUMP:
s_controls.playerLegs = LEGS_JUMP;
break;
case ANIM_CROUCH:
s_controls.playerLegs = LEGS_IDLECR;
break;
case ANIM_TURNLEFT:
s_controls.playerViewangles[YAW] += 90;
break;
case ANIM_TURNRIGHT:
s_controls.playerViewangles[YAW] -= 90;
break;
case ANIM_STEPLEFT:
s_controls.playerLegs = LEGS_WALK;
s_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW] + 90;
break;
case ANIM_STEPRIGHT:
s_controls.playerLegs = LEGS_WALK;
s_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW] - 90;
break;
case ANIM_LOOKUP:
s_controls.playerViewangles[PITCH] = -45;
break;
case ANIM_LOOKDOWN:
s_controls.playerViewangles[PITCH] = 45;
break;
case ANIM_WEAPON1:
s_controls.playerWeapon = WP_GAUNTLET;
break;
case ANIM_WEAPON2:
s_controls.playerWeapon = WP_MACHINEGUN;
break;
case ANIM_WEAPON3:
s_controls.playerWeapon = WP_SHOTGUN;
break;
case ANIM_WEAPON4:
s_controls.playerWeapon = WP_GRENADE_LAUNCHER;
break;
case ANIM_WEAPON5:
s_controls.playerWeapon = WP_ROCKET_LAUNCHER;
break;
case ANIM_WEAPON6:
s_controls.playerWeapon = WP_LIGHTNING;
break;
case ANIM_WEAPON7:
s_controls.playerWeapon = WP_RAILGUN;
break;
case ANIM_WEAPON8:
s_controls.playerWeapon = WP_PLASMAGUN;
break;
case ANIM_WEAPON9:
s_controls.playerWeapon = WP_BFG;
break;
case ANIM_WEAPON10:
s_controls.playerWeapon = WP_GRAPPLING_HOOK;
break;
case ANIM_ATTACK:
s_controls.playerTorso = TORSO_ATTACK;
break;
case ANIM_GESTURE:
s_controls.playerTorso = TORSO_GESTURE;
break;
case ANIM_DIE:
s_controls.playerLegs = BOTH_DEATH1;
s_controls.playerTorso = BOTH_DEATH1;
s_controls.playerWeapon = WP_NONE;
break;
case ANIM_CHAT:
s_controls.playerChat = qtrue;
break;
default:
break;
}
UI_PlayerInfo_SetInfo( &s_controls.playerinfo, s_controls.playerLegs, s_controls.playerTorso, s_controls.playerViewangles, s_controls.playerMoveangles, s_controls.playerWeapon, s_controls.playerChat );
}
/*
=================
Controls_Update
=================
*/
static void Controls_Update( void ) {
int i;
int j;
int y;
menucommon_s **controls;
menucommon_s *control;
// disable all controls in all groups
for( i = 0; i < C_MAX; i++ ) {
controls = g_controls[i];
// bk001204 - parentheses
for( j = 0; (control = controls[j]) ; j++ ) {
control->flags |= (QMF_HIDDEN|QMF_INACTIVE);
}
}
controls = g_controls[s_controls.section];
// enable controls in active group (and count number of items for vertical centering)
// bk001204 - parentheses
for( j = 0; (control = controls[j]) ; j++ ) {
control->flags &= ~(QMF_GRAYED|QMF_HIDDEN|QMF_INACTIVE);
}
// position controls
y = ( SCREEN_HEIGHT - j * SMALLCHAR_HEIGHT ) / 2;
// bk001204 - parentheses
for( j = 0; (control = controls[j]) ; j++, y += SMALLCHAR_HEIGHT ) {
control->x = 320;
control->y = y;
control->left = 320 - 19*SMALLCHAR_WIDTH;
control->right = 320 + 21*SMALLCHAR_WIDTH;
control->top = y;
control->bottom = y + SMALLCHAR_HEIGHT;
}
if( s_controls.waitingforkey ) {
// disable everybody
for( i = 0; i < s_controls.menu.nitems; i++ ) {
((menucommon_s*)(s_controls.menu.items[i]))->flags |= QMF_GRAYED;
}
// enable action item
((menucommon_s*)(s_controls.menu.items[s_controls.menu.cursor]))->flags &= ~QMF_GRAYED;
// don't gray out player's name
s_controls.name.generic.flags &= ~QMF_GRAYED;
return;
}
// enable everybody
for( i = 0; i < s_controls.menu.nitems; i++ ) {
((menucommon_s*)(s_controls.menu.items[i]))->flags &= ~QMF_GRAYED;
}
// makes sure flags are right on the group selection controls
s_controls.looking.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
s_controls.movement.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
s_controls.weapons.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
s_controls.misc.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
s_controls.looking.generic.flags |= QMF_PULSEIFFOCUS;
s_controls.movement.generic.flags |= QMF_PULSEIFFOCUS;
s_controls.weapons.generic.flags |= QMF_PULSEIFFOCUS;
s_controls.misc.generic.flags |= QMF_PULSEIFFOCUS;
// set buttons
switch( s_controls.section ) {
case C_MOVEMENT:
s_controls.movement.generic.flags &= ~QMF_PULSEIFFOCUS;
s_controls.movement.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
break;
case C_LOOKING:
s_controls.looking.generic.flags &= ~QMF_PULSEIFFOCUS;
s_controls.looking.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
break;
case C_WEAPONS:
s_controls.weapons.generic.flags &= ~QMF_PULSEIFFOCUS;
s_controls.weapons.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
break;
case C_MISC:
s_controls.misc.generic.flags &= ~QMF_PULSEIFFOCUS;
s_controls.misc.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
break;
}
}
/*
=================
Controls_DrawKeyBinding
=================
*/
static void Controls_DrawKeyBinding( void *self )
{
menuaction_s* a;
int x;
int y;
int b1;
int b2;
qboolean c;
char name[32];
char name2[32];
a = (menuaction_s*) self;
x = a->generic.x;
y = a->generic.y;
c = (Menu_ItemAtCursor( a->generic.parent ) == a);
b1 = g_bindings[a->generic.id].bind1;
if (b1 == -1)
strcpy(name,"???");
else
{
trap_Key_KeynumToStringBuf( b1, name, 32 );
Q_strupr(name);
b2 = g_bindings[a->generic.id].bind2;
if (b2 != -1)
{
trap_Key_KeynumToStringBuf( b2, name2, 32 );
Q_strupr(name2);
strcat( name, " or " );
strcat( name, name2 );
}
}
if (c)
{
UI_FillRect( a->generic.left, a->generic.top, a->generic.right-a->generic.left+1, a->generic.bottom-a->generic.top+1, listbar_color );
UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_highlight );
UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT|UI_PULSE, text_color_highlight );
if (s_controls.waitingforkey)
{
UI_DrawChar( x, y, '=', UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight);
UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.80, "Waiting for new key ... ESCAPE to cancel", UI_SMALLFONT|UI_CENTER|UI_PULSE, colorWhite );
}
else
{
UI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight);
UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.78, "Press ENTER or CLICK to change", UI_SMALLFONT|UI_CENTER, colorWhite );
UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.82, "Press BACKSPACE to clear", UI_SMALLFONT|UI_CENTER, colorWhite );
}
}
else
{
if (a->generic.flags & QMF_GRAYED)
{
UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_disabled );
UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, text_color_disabled );
}
else
{
UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, controls_binding_color );
UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, controls_binding_color );
}
}
}
/*
=================
Controls_StatusBar
=================
*/
static void Controls_StatusBar( void *self )
{
UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.80, "Use Arrow Keys or CLICK to change", UI_SMALLFONT|UI_CENTER, colorWhite );
}
/*
=================
Controls_DrawPlayer
=================
*/
static void Controls_DrawPlayer( void *self ) {
menubitmap_s *b;
char buf[MAX_QPATH];
trap_Cvar_VariableStringBuffer( "model", buf, sizeof( buf ) );
if ( strcmp( buf, s_controls.playerModel ) != 0 ) {
UI_PlayerInfo_SetModel( &s_controls.playerinfo, buf );
strcpy( s_controls.playerModel, buf );
Controls_UpdateModel( ANIM_IDLE );
}
b = (menubitmap_s*) self;
UI_DrawPlayer( b->generic.x, b->generic.y, b->width, b->height, &s_controls.playerinfo, uis.realtime/2 );
}
/*
=================
Controls_GetKeyAssignment
=================
*/
static void Controls_GetKeyAssignment (char *command, int *twokeys)
{
int count;
int j;
char b[256];
twokeys[0] = twokeys[1] = -1;
count = 0;
for ( j = 0; j < 256; j++ )
{
trap_Key_GetBindingBuf( j, b, 256 );
if ( *b == 0 ) {
continue;
}
if ( !Q_stricmp( b, command ) ) {
twokeys[count] = j;
count++;
if (count == 2)
break;
}
}
}
/*
=================
Controls_GetConfig
=================
*/
static void Controls_GetConfig( void )
{
int i;
int twokeys[2];
bind_t* bindptr;
// put the bindings into a local store
bindptr = g_bindings;
// iterate each command, get its numeric binding
for (i=0; ;i++,bindptr++)
{
if (!bindptr->label)
break;
Controls_GetKeyAssignment(bindptr->command, twokeys);
bindptr->bind1 = twokeys[0];
bindptr->bind2 = twokeys[1];
}
s_controls.invertmouse.curvalue = Controls_GetCvarValue( "m_pitch" ) < 0;
s_controls.smoothmouse.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "m_filter" ) );
s_controls.alwaysrun.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cl_run" ) );
s_controls.autoswitch.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cg_autoswitch" ) );
s_controls.sensitivity.curvalue = UI_ClampCvar( 2, 30, Controls_GetCvarValue( "sensitivity" ) );
s_controls.joyenable.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "in_joystick" ) );
s_controls.joythreshold.curvalue = UI_ClampCvar( 0.05f, 0.75f, Controls_GetCvarValue( "joy_threshold" ) );
s_controls.freelook.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cl_freelook" ) );
}
/*
=================
Controls_SetConfig
=================
*/
static void Controls_SetConfig( void )
{
int i;
bind_t* bindptr;
// set the bindings from the local store
bindptr = g_bindings;
// iterate each command, get its numeric binding
for (i=0; ;i++,bindptr++)
{
if (!bindptr->label)
break;
if (bindptr->bind1 != -1)
{
trap_Key_SetBinding( bindptr->bind1, bindptr->command );
if (bindptr->bind2 != -1)
trap_Key_SetBinding( bindptr->bind2, bindptr->command );
}
}
if ( s_controls.invertmouse.curvalue )
trap_Cvar_SetValue( "m_pitch", -fabs( trap_Cvar_VariableValue( "m_pitch" ) ) );
else
trap_Cvar_SetValue( "m_pitch", fabs( trap_Cvar_VariableValue( "m_pitch" ) ) );
trap_Cvar_SetValue( "m_filter", s_controls.smoothmouse.curvalue );
trap_Cvar_SetValue( "cl_run", s_controls.alwaysrun.curvalue );
trap_Cvar_SetValue( "cg_autoswitch", s_controls.autoswitch.curvalue );
trap_Cvar_SetValue( "sensitivity", s_controls.sensitivity.curvalue );
trap_Cvar_SetValue( "in_joystick", s_controls.joyenable.curvalue );
trap_Cvar_SetValue( "joy_threshold", s_controls.joythreshold.curvalue );
trap_Cvar_SetValue( "cl_freelook", s_controls.freelook.curvalue );
trap_Cmd_ExecuteText( EXEC_APPEND, "in_restart\n" );
}
/*
=================
Controls_SetDefaults
=================
*/
static void Controls_SetDefaults( void )
{
int i;
bind_t* bindptr;
// set the bindings from the local store
bindptr = g_bindings;
// iterate each command, set its default binding
for (i=0; ;i++,bindptr++)
{
if (!bindptr->label)
break;
bindptr->bind1 = bindptr->defaultbind1;
bindptr->bind2 = bindptr->defaultbind2;
}
s_controls.invertmouse.curvalue = Controls_GetCvarDefault( "m_pitch" ) < 0;
s_controls.smoothmouse.curvalue = Controls_GetCvarDefault( "m_filter" );
s_controls.alwaysrun.curvalue = Controls_GetCvarDefault( "cl_run" );
s_controls.autoswitch.curvalue = Controls_GetCvarDefault( "cg_autoswitch" );
s_controls.sensitivity.curvalue = Controls_GetCvarDefault( "sensitivity" );
s_controls.joyenable.curvalue = Controls_GetCvarDefault( "in_joystick" );
s_controls.joythreshold.curvalue = Controls_GetCvarDefault( "joy_threshold" );
s_controls.freelook.curvalue = Controls_GetCvarDefault( "cl_freelook" );
}
/*
=================
Controls_MenuKey
=================
*/
static sfxHandle_t Controls_MenuKey( int key )
{
int id;
int i;
qboolean found;
bind_t* bindptr;
found = qfalse;
if (!s_controls.waitingforkey)
{
switch (key)
{
case K_BACKSPACE:
case K_DEL:
case K_KP_DEL:
key = -1;
break;
case K_MOUSE2:
case K_ESCAPE:
if (s_controls.changesmade)
Controls_SetConfig();
goto ignorekey;
default:
goto ignorekey;
}
}
else
{
if (key & K_CHAR_FLAG)
goto ignorekey;
switch (key)
{
case K_ESCAPE:
s_controls.waitingforkey = qfalse;
Controls_Update();
return (menu_out_sound);
case '`':
goto ignorekey;
}
}
s_controls.changesmade = qtrue;
if (key != -1)
{
// remove from any other bind
bindptr = g_bindings;
for (i=0; ;i++,bindptr++)
{
if (!bindptr->label)
break;
if (bindptr->bind2 == key)
bindptr->bind2 = -1;
if (bindptr->bind1 == key)
{
bindptr->bind1 = bindptr->bind2;
bindptr->bind2 = -1;
}
}
}
// assign key to local store
id = ((menucommon_s*)(s_controls.menu.items[s_controls.menu.cursor]))->id;
bindptr = g_bindings;
for (i=0; ;i++,bindptr++)
{
if (!bindptr->label)
break;
if (bindptr->id == id)
{
found = qtrue;
if (key == -1)
{
if( bindptr->bind1 != -1 ) {
trap_Key_SetBinding( bindptr->bind1, "" );
bindptr->bind1 = -1;
}
if( bindptr->bind2 != -1 ) {
trap_Key_SetBinding( bindptr->bind2, "" );
bindptr->bind2 = -1;
}
}
else if (bindptr->bind1 == -1) {
bindptr->bind1 = key;
}
else if (bindptr->bind1 != key && bindptr->bind2 == -1) {
bindptr->bind2 = key;
}
else
{
trap_Key_SetBinding( bindptr->bind1, "" );
trap_Key_SetBinding( bindptr->bind2, "" );
bindptr->bind1 = key;
bindptr->bind2 = -1;
}
break;
}
}
s_controls.waitingforkey = qfalse;
if (found)
{
Controls_Update();
return (menu_out_sound);
}
ignorekey:
return Menu_DefaultKey( &s_controls.menu, key );
}
/*
=================
Controls_ResetDefaults_Action
=================
*/
static void Controls_ResetDefaults_Action( qboolean result ) {
if( !result ) {
return;
}
s_controls.changesmade = qtrue;
Controls_SetDefaults();
Controls_Update();
}
/*
=================
Controls_ResetDefaults_Draw
=================
*/
static void Controls_ResetDefaults_Draw( void ) {
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This will reset all", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "controls to their default values.", UI_CENTER|UI_SMALLFONT, color_yellow );
}
/*
=================
Controls_MenuEvent
=================
*/
static void Controls_MenuEvent( void* ptr, int event )
{
switch (((menucommon_s*)ptr)->id)
{
case ID_MOVEMENT:
if (event == QM_ACTIVATED)
{
s_controls.section = C_MOVEMENT;
Controls_Update();
}
break;
case ID_LOOKING:
if (event == QM_ACTIVATED)
{
s_controls.section = C_LOOKING;
Controls_Update();
}
break;
case ID_WEAPONS:
if (event == QM_ACTIVATED)
{
s_controls.section = C_WEAPONS;
Controls_Update();
}
break;
case ID_MISC:
if (event == QM_ACTIVATED)
{
s_controls.section = C_MISC;
Controls_Update();
}
break;
case ID_DEFAULTS:
if (event == QM_ACTIVATED)
{
UI_ConfirmMenu( "SET TO DEFAULTS?", Controls_ResetDefaults_Draw, Controls_ResetDefaults_Action );
}
break;
case ID_BACK:
if (event == QM_ACTIVATED)
{
if (s_controls.changesmade)
Controls_SetConfig();
UI_PopMenu();
}
break;
case ID_SAVEANDEXIT:
if (event == QM_ACTIVATED)
{
Controls_SetConfig();
UI_PopMenu();
}
break;
case ID_EXIT:
if (event == QM_ACTIVATED)
{
UI_PopMenu();
}
break;
case ID_FREELOOK:
case ID_MOUSESPEED:
case ID_INVERTMOUSE:
case ID_SMOOTHMOUSE:
case ID_ALWAYSRUN:
case ID_AUTOSWITCH:
case ID_JOYENABLE:
case ID_JOYTHRESHOLD:
if (event == QM_ACTIVATED)
{
s_controls.changesmade = qtrue;
}
break;
}
}
/*
=================
Controls_ActionEvent
=================
*/
static void Controls_ActionEvent( void* ptr, int event )
{
if (event == QM_LOSTFOCUS)
{
Controls_UpdateModel( ANIM_IDLE );
}
else if (event == QM_GOTFOCUS)
{
Controls_UpdateModel( g_bindings[((menucommon_s*)ptr)->id].anim );
}
else if ((event == QM_ACTIVATED) && !s_controls.waitingforkey)
{
s_controls.waitingforkey = 1;
Controls_Update();
}
}
/*
=================
Controls_InitModel
=================
*/
static void Controls_InitModel( void )
{
memset( &s_controls.playerinfo, 0, sizeof(playerInfo_t) );
UI_PlayerInfo_SetModel( &s_controls.playerinfo, UI_Cvar_VariableString( "model" ) );
Controls_UpdateModel( ANIM_IDLE );
}
/*
=================
Controls_InitWeapons
=================
*/
static void Controls_InitWeapons( void ) {
gitem_t * item;
for ( item = bg_itemlist + 1 ; item->classname ; item++ ) {
if ( item->giType != IT_WEAPON ) {
continue;
}
trap_R_RegisterModel( item->world_model[0] );
}
}
/*
=================
Controls_MenuInit
=================
*/
static void Controls_MenuInit( void )
{
static char playername[32];
// zero set all our globals
memset( &s_controls, 0 ,sizeof(controls_t) );
Controls_Cache();
s_controls.menu.key = Controls_MenuKey;
s_controls.menu.wrapAround = qtrue;
s_controls.menu.fullscreen = qtrue;
s_controls.banner.generic.type = MTYPE_BTEXT;
s_controls.banner.generic.flags = QMF_CENTER_JUSTIFY;
s_controls.banner.generic.x = 320;
s_controls.banner.generic.y = 16;
s_controls.banner.string = "CONTROLS";
s_controls.banner.color = color_white;
s_controls.banner.style = UI_CENTER;
s_controls.framel.generic.type = MTYPE_BITMAP;
s_controls.framel.generic.name = ART_FRAMEL;
s_controls.framel.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
s_controls.framel.generic.x = 0;
s_controls.framel.generic.y = 78;
s_controls.framel.width = 256;
s_controls.framel.height = 329;
s_controls.framer.generic.type = MTYPE_BITMAP;
s_controls.framer.generic.name = ART_FRAMER;
s_controls.framer.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
s_controls.framer.generic.x = 376;
s_controls.framer.generic.y = 76;
s_controls.framer.width = 256;
s_controls.framer.height = 334;
s_controls.looking.generic.type = MTYPE_PTEXT;
s_controls.looking.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_controls.looking.generic.id = ID_LOOKING;
s_controls.looking.generic.callback = Controls_MenuEvent;
s_controls.looking.generic.x = 152;
s_controls.looking.generic.y = 240 - 2 * PROP_HEIGHT;
s_controls.looking.string = "LOOK";
s_controls.looking.style = UI_RIGHT;
s_controls.looking.color = color_red;
s_controls.movement.generic.type = MTYPE_PTEXT;
s_controls.movement.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_controls.movement.generic.id = ID_MOVEMENT;
s_controls.movement.generic.callback = Controls_MenuEvent;
s_controls.movement.generic.x = 152;
s_controls.movement.generic.y = 240 - PROP_HEIGHT;
s_controls.movement.string = "MOVE";
s_controls.movement.style = UI_RIGHT;
s_controls.movement.color = color_red;
s_controls.weapons.generic.type = MTYPE_PTEXT;
s_controls.weapons.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_controls.weapons.generic.id = ID_WEAPONS;
s_controls.weapons.generic.callback = Controls_MenuEvent;
s_controls.weapons.generic.x = 152;
s_controls.weapons.generic.y = 240;
s_controls.weapons.string = "SHOOT";
s_controls.weapons.style = UI_RIGHT;
s_controls.weapons.color = color_red;
s_controls.misc.generic.type = MTYPE_PTEXT;
s_controls.misc.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_controls.misc.generic.id = ID_MISC;
s_controls.misc.generic.callback = Controls_MenuEvent;
s_controls.misc.generic.x = 152;
s_controls.misc.generic.y = 240 + PROP_HEIGHT;
s_controls.misc.string = "MISC";
s_controls.misc.style = UI_RIGHT;
s_controls.misc.color = color_red;
s_controls.back.generic.type = MTYPE_BITMAP;
s_controls.back.generic.name = ART_BACK0;
s_controls.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_controls.back.generic.x = 0;
s_controls.back.generic.y = 480-64;
s_controls.back.generic.id = ID_BACK;
s_controls.back.generic.callback = Controls_MenuEvent;
s_controls.back.width = 128;
s_controls.back.height = 64;
s_controls.back.focuspic = ART_BACK1;
s_controls.player.generic.type = MTYPE_BITMAP;
s_controls.player.generic.flags = QMF_INACTIVE;
s_controls.player.generic.ownerdraw = Controls_DrawPlayer;
s_controls.player.generic.x = 400;
s_controls.player.generic.y = -40;
s_controls.player.width = 32*10;
s_controls.player.height = 56*10;
s_controls.walkforward.generic.type = MTYPE_ACTION;
s_controls.walkforward.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.walkforward.generic.callback = Controls_ActionEvent;
s_controls.walkforward.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.walkforward.generic.id = ID_FORWARD;
s_controls.backpedal.generic.type = MTYPE_ACTION;
s_controls.backpedal.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.backpedal.generic.callback = Controls_ActionEvent;
s_controls.backpedal.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.backpedal.generic.id = ID_BACKPEDAL;
s_controls.stepleft.generic.type = MTYPE_ACTION;
s_controls.stepleft.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.stepleft.generic.callback = Controls_ActionEvent;
s_controls.stepleft.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.stepleft.generic.id = ID_MOVELEFT;
s_controls.stepright.generic.type = MTYPE_ACTION;
s_controls.stepright.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.stepright.generic.callback = Controls_ActionEvent;
s_controls.stepright.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.stepright.generic.id = ID_MOVERIGHT;
s_controls.moveup.generic.type = MTYPE_ACTION;
s_controls.moveup.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.moveup.generic.callback = Controls_ActionEvent;
s_controls.moveup.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.moveup.generic.id = ID_MOVEUP;
s_controls.movedown.generic.type = MTYPE_ACTION;
s_controls.movedown.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.movedown.generic.callback = Controls_ActionEvent;
s_controls.movedown.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.movedown.generic.id = ID_MOVEDOWN;
s_controls.turnleft.generic.type = MTYPE_ACTION;
s_controls.turnleft.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.turnleft.generic.callback = Controls_ActionEvent;
s_controls.turnleft.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.turnleft.generic.id = ID_LEFT;
s_controls.turnright.generic.type = MTYPE_ACTION;
s_controls.turnright.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.turnright.generic.callback = Controls_ActionEvent;
s_controls.turnright.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.turnright.generic.id = ID_RIGHT;
s_controls.sidestep.generic.type = MTYPE_ACTION;
s_controls.sidestep.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.sidestep.generic.callback = Controls_ActionEvent;
s_controls.sidestep.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.sidestep.generic.id = ID_STRAFE;
s_controls.run.generic.type = MTYPE_ACTION;
s_controls.run.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.run.generic.callback = Controls_ActionEvent;
s_controls.run.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.run.generic.id = ID_SPEED;
s_controls.chainsaw.generic.type = MTYPE_ACTION;
s_controls.chainsaw.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.chainsaw.generic.callback = Controls_ActionEvent;
s_controls.chainsaw.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.chainsaw.generic.id = ID_WEAPON1;
s_controls.machinegun.generic.type = MTYPE_ACTION;
s_controls.machinegun.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.machinegun.generic.callback = Controls_ActionEvent;
s_controls.machinegun.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.machinegun.generic.id = ID_WEAPON2;
s_controls.shotgun.generic.type = MTYPE_ACTION;
s_controls.shotgun.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.shotgun.generic.callback = Controls_ActionEvent;
s_controls.shotgun.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.shotgun.generic.id = ID_WEAPON3;
s_controls.grenadelauncher.generic.type = MTYPE_ACTION;
s_controls.grenadelauncher.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.grenadelauncher.generic.callback = Controls_ActionEvent;
s_controls.grenadelauncher.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.grenadelauncher.generic.id = ID_WEAPON4;
s_controls.rocketlauncher.generic.type = MTYPE_ACTION;
s_controls.rocketlauncher.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.rocketlauncher.generic.callback = Controls_ActionEvent;
s_controls.rocketlauncher.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.rocketlauncher.generic.id = ID_WEAPON5;
s_controls.lightning.generic.type = MTYPE_ACTION;
s_controls.lightning.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.lightning.generic.callback = Controls_ActionEvent;
s_controls.lightning.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.lightning.generic.id = ID_WEAPON6;
s_controls.railgun.generic.type = MTYPE_ACTION;
s_controls.railgun.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.railgun.generic.callback = Controls_ActionEvent;
s_controls.railgun.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.railgun.generic.id = ID_WEAPON7;
s_controls.plasma.generic.type = MTYPE_ACTION;
s_controls.plasma.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.plasma.generic.callback = Controls_ActionEvent;
s_controls.plasma.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.plasma.generic.id = ID_WEAPON8;
s_controls.bfg.generic.type = MTYPE_ACTION;
s_controls.bfg.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.bfg.generic.callback = Controls_ActionEvent;
s_controls.bfg.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.bfg.generic.id = ID_WEAPON9;
s_controls.attack.generic.type = MTYPE_ACTION;
s_controls.attack.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.attack.generic.callback = Controls_ActionEvent;
s_controls.attack.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.attack.generic.id = ID_ATTACK;
s_controls.prevweapon.generic.type = MTYPE_ACTION;
s_controls.prevweapon.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.prevweapon.generic.callback = Controls_ActionEvent;
s_controls.prevweapon.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.prevweapon.generic.id = ID_WEAPPREV;
s_controls.nextweapon.generic.type = MTYPE_ACTION;
s_controls.nextweapon.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.nextweapon.generic.callback = Controls_ActionEvent;
s_controls.nextweapon.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.nextweapon.generic.id = ID_WEAPNEXT;
s_controls.lookup.generic.type = MTYPE_ACTION;
s_controls.lookup.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.lookup.generic.callback = Controls_ActionEvent;
s_controls.lookup.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.lookup.generic.id = ID_LOOKUP;
s_controls.lookdown.generic.type = MTYPE_ACTION;
s_controls.lookdown.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.lookdown.generic.callback = Controls_ActionEvent;
s_controls.lookdown.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.lookdown.generic.id = ID_LOOKDOWN;
s_controls.mouselook.generic.type = MTYPE_ACTION;
s_controls.mouselook.generic.flags = QMF_LEFT_JUSTIFY|QMF_HIGHLIGHT_IF_FOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.mouselook.generic.callback = Controls_ActionEvent;
s_controls.mouselook.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.mouselook.generic.id = ID_MOUSELOOK;
s_controls.freelook.generic.type = MTYPE_RADIOBUTTON;
s_controls.freelook.generic.flags = QMF_SMALLFONT;
s_controls.freelook.generic.x = SCREEN_WIDTH/2;
s_controls.freelook.generic.name = "free look";
s_controls.freelook.generic.id = ID_FREELOOK;
s_controls.freelook.generic.callback = Controls_MenuEvent;
s_controls.freelook.generic.statusbar = Controls_StatusBar;
s_controls.centerview.generic.type = MTYPE_ACTION;
s_controls.centerview.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.centerview.generic.callback = Controls_ActionEvent;
s_controls.centerview.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.centerview.generic.id = ID_CENTERVIEW;
s_controls.zoomview.generic.type = MTYPE_ACTION;
s_controls.zoomview.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.zoomview.generic.callback = Controls_ActionEvent;
s_controls.zoomview.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.zoomview.generic.id = ID_ZOOMVIEW;
s_controls.useitem.generic.type = MTYPE_ACTION;
s_controls.useitem.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.useitem.generic.callback = Controls_ActionEvent;
s_controls.useitem.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.useitem.generic.id = ID_USEITEM;
s_controls.showscores.generic.type = MTYPE_ACTION;
s_controls.showscores.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.showscores.generic.callback = Controls_ActionEvent;
s_controls.showscores.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.showscores.generic.id = ID_SHOWSCORES;
s_controls.invertmouse.generic.type = MTYPE_RADIOBUTTON;
s_controls.invertmouse.generic.flags = QMF_SMALLFONT;
s_controls.invertmouse.generic.x = SCREEN_WIDTH/2;
s_controls.invertmouse.generic.name = "invert mouse";
s_controls.invertmouse.generic.id = ID_INVERTMOUSE;
s_controls.invertmouse.generic.callback = Controls_MenuEvent;
s_controls.invertmouse.generic.statusbar = Controls_StatusBar;
s_controls.smoothmouse.generic.type = MTYPE_RADIOBUTTON;
s_controls.smoothmouse.generic.flags = QMF_SMALLFONT;
s_controls.smoothmouse.generic.x = SCREEN_WIDTH/2;
s_controls.smoothmouse.generic.name = "smooth mouse";
s_controls.smoothmouse.generic.id = ID_SMOOTHMOUSE;
s_controls.smoothmouse.generic.callback = Controls_MenuEvent;
s_controls.smoothmouse.generic.statusbar = Controls_StatusBar;
s_controls.alwaysrun.generic.type = MTYPE_RADIOBUTTON;
s_controls.alwaysrun.generic.flags = QMF_SMALLFONT;
s_controls.alwaysrun.generic.x = SCREEN_WIDTH/2;
s_controls.alwaysrun.generic.name = "always run";
s_controls.alwaysrun.generic.id = ID_ALWAYSRUN;
s_controls.alwaysrun.generic.callback = Controls_MenuEvent;
s_controls.alwaysrun.generic.statusbar = Controls_StatusBar;
s_controls.autoswitch.generic.type = MTYPE_RADIOBUTTON;
s_controls.autoswitch.generic.flags = QMF_SMALLFONT;
s_controls.autoswitch.generic.x = SCREEN_WIDTH/2;
s_controls.autoswitch.generic.name = "autoswitch weapons";
s_controls.autoswitch.generic.id = ID_AUTOSWITCH;
s_controls.autoswitch.generic.callback = Controls_MenuEvent;
s_controls.autoswitch.generic.statusbar = Controls_StatusBar;
s_controls.sensitivity.generic.type = MTYPE_SLIDER;
s_controls.sensitivity.generic.x = SCREEN_WIDTH/2;
s_controls.sensitivity.generic.flags = QMF_SMALLFONT;
s_controls.sensitivity.generic.name = "mouse speed";
s_controls.sensitivity.generic.id = ID_MOUSESPEED;
s_controls.sensitivity.generic.callback = Controls_MenuEvent;
s_controls.sensitivity.minvalue = 2;
s_controls.sensitivity.maxvalue = 30;
s_controls.sensitivity.generic.statusbar = Controls_StatusBar;
s_controls.gesture.generic.type = MTYPE_ACTION;
s_controls.gesture.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.gesture.generic.callback = Controls_ActionEvent;
s_controls.gesture.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.gesture.generic.id = ID_GESTURE;
s_controls.chat.generic.type = MTYPE_ACTION;
s_controls.chat.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.chat.generic.callback = Controls_ActionEvent;
s_controls.chat.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.chat.generic.id = ID_CHAT;
s_controls.chat2.generic.type = MTYPE_ACTION;
s_controls.chat2.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.chat2.generic.callback = Controls_ActionEvent;
s_controls.chat2.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.chat2.generic.id = ID_CHAT2;
s_controls.chat3.generic.type = MTYPE_ACTION;
s_controls.chat3.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.chat3.generic.callback = Controls_ActionEvent;
s_controls.chat3.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.chat3.generic.id = ID_CHAT3;
s_controls.chat4.generic.type = MTYPE_ACTION;
s_controls.chat4.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.chat4.generic.callback = Controls_ActionEvent;
s_controls.chat4.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.chat4.generic.id = ID_CHAT4;
s_controls.joyenable.generic.type = MTYPE_RADIOBUTTON;
s_controls.joyenable.generic.flags = QMF_SMALLFONT;
s_controls.joyenable.generic.x = SCREEN_WIDTH/2;
s_controls.joyenable.generic.name = "joystick";
s_controls.joyenable.generic.id = ID_JOYENABLE;
s_controls.joyenable.generic.callback = Controls_MenuEvent;
s_controls.joyenable.generic.statusbar = Controls_StatusBar;
s_controls.joythreshold.generic.type = MTYPE_SLIDER;
s_controls.joythreshold.generic.x = SCREEN_WIDTH/2;
s_controls.joythreshold.generic.flags = QMF_SMALLFONT;
s_controls.joythreshold.generic.name = "joystick threshold";
s_controls.joythreshold.generic.id = ID_JOYTHRESHOLD;
s_controls.joythreshold.generic.callback = Controls_MenuEvent;
s_controls.joythreshold.minvalue = 0.05f;
s_controls.joythreshold.maxvalue = 0.75f;
s_controls.joythreshold.generic.statusbar = Controls_StatusBar;
s_controls.name.generic.type = MTYPE_PTEXT;
s_controls.name.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE;
s_controls.name.generic.x = 320;
s_controls.name.generic.y = 440;
s_controls.name.string = playername;
s_controls.name.style = UI_CENTER;
s_controls.name.color = text_color_normal;
Menu_AddItem( &s_controls.menu, &s_controls.banner );
Menu_AddItem( &s_controls.menu, &s_controls.framel );
Menu_AddItem( &s_controls.menu, &s_controls.framer );
Menu_AddItem( &s_controls.menu, &s_controls.player );
Menu_AddItem( &s_controls.menu, &s_controls.name );
Menu_AddItem( &s_controls.menu, &s_controls.looking );
Menu_AddItem( &s_controls.menu, &s_controls.movement );
Menu_AddItem( &s_controls.menu, &s_controls.weapons );
Menu_AddItem( &s_controls.menu, &s_controls.misc );
Menu_AddItem( &s_controls.menu, &s_controls.sensitivity );
Menu_AddItem( &s_controls.menu, &s_controls.smoothmouse );
Menu_AddItem( &s_controls.menu, &s_controls.invertmouse );
Menu_AddItem( &s_controls.menu, &s_controls.lookup );
Menu_AddItem( &s_controls.menu, &s_controls.lookdown );
Menu_AddItem( &s_controls.menu, &s_controls.mouselook );
Menu_AddItem( &s_controls.menu, &s_controls.freelook );
Menu_AddItem( &s_controls.menu, &s_controls.centerview );
Menu_AddItem( &s_controls.menu, &s_controls.zoomview );
Menu_AddItem( &s_controls.menu, &s_controls.joyenable );
Menu_AddItem( &s_controls.menu, &s_controls.joythreshold );
Menu_AddItem( &s_controls.menu, &s_controls.alwaysrun );
Menu_AddItem( &s_controls.menu, &s_controls.run );
Menu_AddItem( &s_controls.menu, &s_controls.walkforward );
Menu_AddItem( &s_controls.menu, &s_controls.backpedal );
Menu_AddItem( &s_controls.menu, &s_controls.stepleft );
Menu_AddItem( &s_controls.menu, &s_controls.stepright );
Menu_AddItem( &s_controls.menu, &s_controls.moveup );
Menu_AddItem( &s_controls.menu, &s_controls.movedown );
Menu_AddItem( &s_controls.menu, &s_controls.turnleft );
Menu_AddItem( &s_controls.menu, &s_controls.turnright );
Menu_AddItem( &s_controls.menu, &s_controls.sidestep );
Menu_AddItem( &s_controls.menu, &s_controls.attack );
Menu_AddItem( &s_controls.menu, &s_controls.nextweapon );
Menu_AddItem( &s_controls.menu, &s_controls.prevweapon );
Menu_AddItem( &s_controls.menu, &s_controls.autoswitch );
Menu_AddItem( &s_controls.menu, &s_controls.chainsaw );
Menu_AddItem( &s_controls.menu, &s_controls.machinegun );
Menu_AddItem( &s_controls.menu, &s_controls.shotgun );
Menu_AddItem( &s_controls.menu, &s_controls.grenadelauncher );
Menu_AddItem( &s_controls.menu, &s_controls.rocketlauncher );
Menu_AddItem( &s_controls.menu, &s_controls.lightning );
Menu_AddItem( &s_controls.menu, &s_controls.railgun );
Menu_AddItem( &s_controls.menu, &s_controls.plasma );
Menu_AddItem( &s_controls.menu, &s_controls.bfg );
Menu_AddItem( &s_controls.menu, &s_controls.showscores );
Menu_AddItem( &s_controls.menu, &s_controls.useitem );
Menu_AddItem( &s_controls.menu, &s_controls.gesture );
Menu_AddItem( &s_controls.menu, &s_controls.chat );
Menu_AddItem( &s_controls.menu, &s_controls.chat2 );
Menu_AddItem( &s_controls.menu, &s_controls.chat3 );
Menu_AddItem( &s_controls.menu, &s_controls.chat4 );
Menu_AddItem( &s_controls.menu, &s_controls.back );
trap_Cvar_VariableStringBuffer( "name", s_controls.name.string, 16 );
Q_CleanStr( s_controls.name.string );
// initialize the configurable cvars
Controls_InitCvars();
// initialize the current config
Controls_GetConfig();
// intialize the model
Controls_InitModel();
// intialize the weapons
Controls_InitWeapons ();
// initial default section
s_controls.section = C_LOOKING;
// update the ui
Controls_Update();
}
/*
=================
Controls_Cache
=================
*/
void Controls_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
}
/*
=================
UI_ControlsMenu
=================
*/
void UI_ControlsMenu( void ) {
Controls_MenuInit();
UI_PushMenu( &s_controls.menu );
}
| sethk/quake3-ios | code/q3_ui/ui_controls2.c | C | gpl-2.0 | 53,979 |
/*************************************************************************
*
* AVRGAMING LLC
* __________________
*
* [2013] AVRGAMING LLC
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of AVRGAMING LLC and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to AVRGAMING LLC
* and its suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from AVRGAMING LLC.
*/
package com.avrgaming.civcraft.command.debug;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.entity.Player;
import com.avrgaming.civcraft.command.CommandBase;
import com.avrgaming.civcraft.exception.CivException;
import com.avrgaming.civcraft.main.CivGlobal;
import com.avrgaming.civcraft.main.CivMessage;
import com.avrgaming.civcraft.structure.farm.FarmChunk;
import com.avrgaming.civcraft.structure.farm.FarmGrowthSyncTask;
import com.avrgaming.civcraft.structure.farm.FarmPreCachePopulateTimer;
import com.avrgaming.civcraft.threading.TaskMaster;
import com.avrgaming.civcraft.util.BlockCoord;
import com.avrgaming.civcraft.util.ChunkCoord;
public class DebugFarmCommand extends CommandBase {
@Override
public void init() {
command = "/dbg farm ";
displayName = "Farm Commands";
commands.put("showgrowth", "Highlight the crops that grew last tick.");
commands.put("grow", "[x] grows ALL farm chunks x many times.");
commands.put("cropcache", "show the crop cache for this plot.");
commands.put("unloadchunk", "[x] [z] unloads this farm chunk");
commands.put("cache", "Runs the crop cache task.");
}
public void unloadchunk_cmd() throws CivException {
int x = getNamedInteger(1);
int z = getNamedInteger(2);
Bukkit.getWorld("world").unloadChunk(x, z);
CivMessage.sendSuccess(sender, "Chunk "+x+","+z+" unloaded");
}
public void showgrowth_cmd() throws CivException {
Player player = getPlayer();
ChunkCoord coord = new ChunkCoord(player.getLocation());
FarmChunk fc = CivGlobal.getFarmChunk(coord);
if (fc == null) {
throw new CivException("This is not a farm.");
}
for(BlockCoord bcoord : fc.getLastGrownCrops()) {
bcoord.getBlock().getWorld().playEffect(bcoord.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
}
CivMessage.sendSuccess(player, "Flashed last grown crops");
}
public void cropcache_cmd() throws CivException {
Player player = getPlayer();
ChunkCoord coord = new ChunkCoord(player.getLocation());
FarmChunk fc = CivGlobal.getFarmChunk(coord);
if (fc == null) {
throw new CivException("This is not a farm.");
}
for (BlockCoord bcoord : fc.cropLocationCache) {
bcoord.getBlock().getWorld().playEffect(bcoord.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
}
CivMessage.sendSuccess(player, "Flashed cached crops.");
}
public void grow_cmd() throws CivException {
int count = getNamedInteger(1);
for (int i = 0; i < count; i++) {
TaskMaster.asyncTask(new FarmGrowthSyncTask(), 0);
}
CivMessage.sendSuccess(sender, "Grew all farms.");
}
public void cache_cmd() {
TaskMaster.syncTask(new FarmPreCachePopulateTimer());
}
@Override
public void doDefaultAction() throws CivException {
showHelp();
}
@Override
public void showHelp() {
showBasicHelp();
}
@Override
public void permissionCheck() throws CivException {
}
}
| help3r/civcraft-1 | civcraft/src/com/avrgaming/civcraft/command/debug/DebugFarmCommand.java | Java | gpl-2.0 | 3,603 |
# -*- coding: utf-8 -*-
## $Id: webmessage_templates.py,v 1.32 2008/03/26 23:26:23 tibor Exp $
##
## handles rendering of webmessage module
##
## This file is part of Invenio.
## Copyright (C) 2009, 2010, 2011 CERN.
##
## Invenio 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.
##
## Invenio 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 Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
""" Templates for field exporter plugin """
__revision__ = "$Id: webmessage_templates.py,v 1.32 2008/03/26 23:26:23 tibor Exp $"
import cgi
from invenio.config import CFG_SITE_LANG, CFG_SITE_URL
from invenio.base.i18n import gettext_set_language
from invenio.utils.date import convert_datestruct_to_datetext, convert_datetext_to_dategui, convert_datestruct_to_dategui
from invenio.legacy.bibexport.fieldexporter_dblayer import Job, JobResult
class Template:
"""Templates for field exporter plugin"""
_JOBS_URL = "%s/exporter/jobs" % (CFG_SITE_URL, )
_EDIT_JOB_URL = "%s/exporter/edit_job" % (CFG_SITE_URL, )
_EDIT_QUERY_URL = "%s/exporter/edit_query" % (CFG_SITE_URL, )
_JOB_RESULTS_URL = "%s/exporter/job_results" % (CFG_SITE_URL, )
_DISPLAY_JOB_RESULT_URL = "%s/exporter/display_job_result" % (CFG_SITE_URL, )
_DOWNLOAD_JOB_RESULT_URL = "%s/exporter/download_job_result" % (CFG_SITE_URL, )
_JOB_HISTORY_URL = "%s/exporter/history" % (CFG_SITE_URL, )
def tmpl_styles(self):
"""Defines the local CSS styles used in the plugin"""
styles = """
<style type="text/css">
.label{
white-space: nowrap;
padding-right: 15px;
}
.textentry{
width: 350px;
}
table.spacedcells td{
padding-right: 20px;
white-space: nowrap;
}
table.spacedcells th{
padding-right: 20px;
text-align: left;
}
</style>
<script type="text/javascript">
<!--
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.forms[FormName].elements[FieldName];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
// -->
</script>
"""
return styles
def tmpl_navigation_menu(self, language = CFG_SITE_LANG):
"""Returns HTML representing navigation menu for field exporter."""
_ = gettext_set_language(language)
navigation_menu = """
<table class="headermodulebox">
<tbody><tr>
<td class="headermoduleboxbody">
<a class="header" href="%(job_verview_url)s?ln=%(language)s">%(label_job_overview)s</a>
</td>
<td class="headermoduleboxbody">
<a class="header" href="%(edit_job_url)s?ln=%(language)s">%(label_new_job)s</a>
</td>
<td class="headermoduleboxbody">
<a class="header" href="%(job_history_url)s?ln=%(language)s">%(label_job_history)s</a>
</td>
</tr></tbody></table>
""" % {"edit_job_url" : self._EDIT_JOB_URL,
"job_verview_url" : self._JOBS_URL,
"job_history_url" : self._JOB_HISTORY_URL,
"language" : language,
"label_job_overview" : _("Export Job Overview"),
"label_new_job" : _("New Export Job"),
"label_job_history" : _("Export Job History")
}
return navigation_menu
def tmpl_display_jobs(self, jobs, language = CFG_SITE_LANG):
"""
Creates page for displaying of all the jobs.
@param jobs: list of the jobs that have to be displayed
@param language: language of the page
"""
_ = gettext_set_language(language)
table_rows = ""
for current_job in jobs:
# convert last run date into text proper to be shown to the user
datetext = convert_datestruct_to_datetext(current_job.get_last_run())
last_run = convert_datetext_to_dategui(datetext, language)
# obtain text corresponding to the frequency of execution
frequency = current_job.get_frequency()
frequency_text = self._get_frequency_text(frequency)
row = """<tr>
<td><input type="checkbox" name="selected_jobs" value="%(job_id)s"></input></td>
<td><a href="%(edit_job_url)s?id=%(job_id)s&ln=%(language)s">%(name)s</a></td>
<td>%(frequency)s</td>
<td>%(last_run)s</td>
</tr>""" % self._html_escape_dictionary({
"edit_job_url" : self._EDIT_JOB_URL,
"job_id" : current_job.get_id(),
"name" : current_job.get_name(),
"frequency" : frequency_text,
"language" : language,
"last_run" : last_run
})
table_rows += row
select_all_none_row = """
<tr><td colspan="4">
<small>%s</small><br><br>
</td></tr>""" \
%(self._get_select_all_none_html("jobsForm",
"selected_jobs",
language))
table_rows += select_all_none_row
buttons_row = """<tr>
<td colspan="3">
<input type="Submit" name="run_button" value="%(label_run)s" class="formbutton">
<input type="Submit" name="delete_button" value="%(label_delete)s" class="formbutton">
</td>
<td align="right">
<input type="Submit" name="new_button" value="%(label_new)s" class="formbutton">
</td>
</tr>""" % {
"label_run" : _("Run"),
"label_delete" : _("Delete"),
"label_new" : _("New")
}
table_rows += buttons_row
body = """
<form method="post" name="jobsForm">
<table class="spacedcells">
<th></th>
<th>%(label_name)s</th>
<th>%(label_frequency)s</th>
<th>%(label_last_run)s</th>
%(table_rows)s
</table>
</form>
""" % {
"table_rows" : table_rows,
"label_name" : _("Name"),
"label_frequency" : _("Run"),
"label_last_run" : _("Last run")
}
return body
def tmpl_edit_job(self, job, language = CFG_SITE_LANG):
"""
Creates page for editing of jobs.
@param job: The job that will be edited
@param language: language of the page
"""
_ = gettext_set_language(language)
job_frequency = job.get_frequency()
frequency_select_box_html = self._create_frequency_select_box("job_frequency", job_frequency, language)
output_format_select_box_html = self._create_output_format_select_box(selected_value = job.get_output_format())
body = """
<form method="post">
<input type="Hidden" name="id" value="%(job_id)s">
<table>
<tr>
<td class = "label">%(name_label)s</td>
<td colspan="2"><input type="text" name="job_name" class="textentry" value="%(job_name)s"></td>
</tr>
<tr>
<td class = "label">%(frequency_label)s</td>
<td colspan="2">%(frequency_select_box)s</td>
</tr>
<tr>
<td class = "label">%(output_format_label)s</td>
<td colspan="2">%(output_format_select_box)s</td>
</tr>
<tr>
<td class = "label">%(start_label)s</td>
<td colspan="2"><input type="text" name="last_run" class="textentry" value="%(job_last_run)s"></td>
</tr>
<tr>
<td class = "label">%(output_directory_label)s</td>
<td colspan="2"><input type="text" name="output_directory" class="textentry" value="%(output_directory)s"></td>
</tr>
<tr>
<td></td>
<td>
<input type="Submit" name="save_button" value="%(save_label)s" class="formbutton">
<input type="Submit" name="cancel_button" value="%(cancel_label)s" class="formbutton">
</td>
<td align="right">
<input type="Submit" name="edit_queries_button" value="%(edit_queries_label)s" class="formbutton">
</td>
</tr>
</table>
</form>
""" % {
"name_label" : _("Name"),
"frequency_label" : _("Frequency"),
"output_format_label" : _("Output Format"),
"start_label" : _("Start"),
"output_directory_label" : _("Output Directory"),
"save_label" : _("Save"),
"cancel_label" : _("Cancel"),
"edit_queries_label" : _("Edit Queries"),
"job_id" : self._html_escape_content(job.get_id()),
"job_name" : self._html_escape_content(job.get_name()),
"frequency_select_box" : frequency_select_box_html,
"output_format_select_box" : output_format_select_box_html,
"job_last_run" : convert_datestruct_to_datetext(job.get_last_run()),
"output_directory" : self._html_escape_content(job.get_output_directory())
}
return body
def tmpl_display_job_queries(self, job_queries, job_id, language = CFG_SITE_LANG):
"""
Creates page for displaying of queries of a given jobs.
@param job_queries: list of JobQuery objects that have to be displayed
@param job_id: identifier of the job that own the queries
@param language: language of the page
"""
_ = gettext_set_language(language)
table_rows = ""
for current_query in job_queries:
output_fields = ", ".join(current_query.get_output_fields())
row = """<tr>
<td><input type="checkbox" name="selected_queries" value="%(query_id)s"></input></td>
<td><a href="%(edit_query_url)s?id=%(query_id)s&job_id=%(job_id)s&ln=%(language)s">%(name)s</a></td>
<td><input type="text" value="%(search_criteria)s" readonly style="border: none; width: 130px"></td>
<td><input type="text" value="%(output_fields)s" readonly style="border: none; width: 130px"></td>
<td><input type="text" value="%(comment)s" readonly style="border: none; width: 130px"></td>
</tr>""" % self._html_escape_dictionary({
"edit_query_url" : self._EDIT_QUERY_URL,
"language" : language,
"query_id" : current_query.get_id(),
"search_criteria" : current_query.get_search_criteria(),
"name" : current_query.get_name(),
"comment" : current_query.get_comment(),
"output_fields" : output_fields,
"job_id" : job_id
})
table_rows += row
select_all_none_row = """
<tr><td colspan="4">
<small>%s</small><br><br>
</td></tr>""" \
% (self._get_select_all_none_html("queriesForm",
"selected_queries",
language))
table_rows += select_all_none_row
buttons_row = """<tr>
<td colspan="4">
<input type="Submit" name="run_button" value="%(label_run)s" class="formbutton">
<input type="Submit" name="delete_button" value="%(label_delete)s" class="formbutton">
</td>
<td align="right">
<input type="Submit" name="new_button" value="%(label_new)s" class="formbutton">
</td>
</tr>""" % {
"label_run" : _("Run"),
"label_delete" : _("Delete"),
"label_new" : _("New")
}
table_rows += buttons_row
body = """
<form method="post" name="queriesForm">
<input type="Hidden" name="job_id" value="%(job_id)s">
<table class="spacedcells">
<th></th>
<th>%(label_name)s</th>
<th>%(label_search_criteria)s</th>
<th>%(label_output_fields)s</th>
<th>%(label_comment)s</th>
%(table_rows)s
</table>
</form>
""" % {
"table_rows" : table_rows,
"label_name" : _("Name"),
"label_search_criteria" : _("Query"),
"label_comment" : _("Comment"),
"label_output_fields" : _("Output Fields"),
"job_id" : self._html_escape_content(job_id)
}
return body
def tmpl_edit_query(self, query, job_id, language = CFG_SITE_LANG):
"""
Creates page for editing of a query.
@param query: the query that will be edited
@param language: language of the page
@return: The HTML content of the page
"""
_ = gettext_set_language(language)
body = """
<form method="post">
<input type="Hidden" name="id" value="%(id)s">
<input type="Hidden" name="job_id" value="%(job_id)s">
<table >
<tr>
<td class = "label">%(name_label)s</td>
<td><input type="text" name="name" class="textentry" value="%(name)s"></td>
</tr>
<tr>
<td class = "label">%(query_label)s</td>
<td><input type="text" name="search_criteria" class="textentry" value="%(search_criteria)s"></td>
</tr>
<tr>
<td class = "label">%(output_fields_label)s</td>
<td><input type="text" name="output_fields" class="textentry" value="%(output_fields)s"></td>
</tr>
<tr>
<td class = "label">%(comment_label)s</td>
<td><textarea name="comment" rows="6" class="textentry">%(comment)s</textarea></td>
</tr>
<tr>
<td></td>
<td>
<input type="Submit" name="save_button" value="%(save_label)s" class="formbutton">
<input type="Submit" name="cancel_button" value="%(cancel_label)s" class="formbutton">
</td>
</tr>
</table>
</form>
""" % self._html_escape_dictionary({
"name_label" : _("Name"),
"query_label" : _("Query"),
"output_fields_label" : _("Output fields"),
"comment_label" : _("Comment"),
"save_label" : _("Save"),
"cancel_label" : _("Cancel"),
"job_id" : job_id,
"id" : query.get_id(),
"name" : query.get_name(),
"search_criteria" : query.get_search_criteria(),
"output_fields" : ", ".join(query.get_output_fields()),
"comment" : query.get_comment(),
})
return body
def tmpl_display_queries_results(self, job_result, language = CFG_SITE_LANG):
"""Creates a page displaying results from execution of multiple queries.
@param job_result: JobResult object containing the job results
that will be displayed
@param language: language of the page
@return: The HTML content of the page
"""
_ = gettext_set_language(language)
queries_results = job_result.get_query_results()
output_format = job_result.get_job().get_output_format()
job_result_id = job_result.get_id()
body = ""
if job_result_id != JobResult.ID_MISSING:
download_and_format_html = """
<a href="%(download_job_results_url)s?result_id=%(job_result_id)s&ln=%(language)s"><input type="button" value="%(label_download)s" class="formbutton"></a>
<strong>%(label_view_as)s</strong>
<a href="%(display_job_result_url)s?result_id=%(job_result_id)s&output_format=%(output_format_marcxml)s&ln=%(language)s">MARCXML</a>
<a href="%(display_job_result_url)s?result_id=%(job_result_id)s&output_format=%(output_format_marc)s&ln=%(language)s">MARC</a>
""" % self._html_escape_dictionary({
"label_download" : _("Download"),
"label_view_as" : _("View as: "),
"output_format_marcxml" : Job.OUTPUT_FORMAT_MARCXML,
"output_format_marc" : Job.OUTPUT_FORMAT_MARC,
"download_job_results_url" : self._DOWNLOAD_JOB_RESULT_URL,
"language" : language,
"display_job_result_url" : self._DISPLAY_JOB_RESULT_URL,
"job_result_id" : job_result_id
})
body += download_and_format_html
for query_result in queries_results:
query = query_result.get_query()
results = query_result.get_result(output_format)
html = """
<h2>%(name)s</h2>
<strong>%(query_label)s: </strong>%(search_criteria)s<br>
<strong>%(output_fields_label)s: </strong>%(output_fields)s<br>
<textarea rows="10" style="width: 100%%" wrap="off" readonly>%(results)s</textarea></td>
""" % self._html_escape_dictionary({
"query_label" : _("Query"),
"output_fields_label" : _("Output fields"),
"name" : query.get_name(),
"search_criteria" : query.get_search_criteria(),
"output_fields" : ",".join(query.get_output_fields()),
"results" : results
})
body += html
return body
def tmpl_display_job_history(self, job_results, language = CFG_SITE_LANG):
"""Creates a page displaying information about
the job results given as a parameter.
@param job_results: List of JobResult objects containing
information about the job results that have to be displayed
@param language: language of the page
@return: The HTML content of the page
"""
_ = gettext_set_language(language)
table_rows = ""
for current_job_result in job_results:
current_job = current_job_result.get_job()
# convert execution date into text proper to be shown to the user
execution_date_time = current_job_result.get_execution_date_time()
date = convert_datestruct_to_dategui(execution_date_time)
# obtain text corresponding to the frequency of execution
frequency = current_job.get_frequency()
frequency_text = self._get_frequency_text(frequency, language)
# set the status text
if current_job_result.STATUS_CODE_OK == current_job_result.get_status():
status = _("OK")
else:
status = _("Error")
records_found = current_job_result.get_number_of_records_found()
row = """<tr>
<td><a href="%(job_results_url)s?result_id=%(job_result_id)s&ln=%(language)s">%(job_name)s</a></td>
<td>%(job_frequency)s</td>
<td>%(execution_date)s</td>
<td><b>%(status)s</b>
<a href="%(display_job_result_url)s?result_id=%(job_result_id)s&ln=%(language)s">
<small>%(number_of_records_found)s %(label_records_found)s</small>
</a>
</td>
</tr>""" % self._html_escape_dictionary({
"job_name" : current_job.get_name(),
"job_frequency" : frequency_text,
"execution_date" : date,
"status" : status,
"number_of_records_found" : records_found,
"label_records_found" : _("records found"),
"job_results_url" : self._JOB_RESULTS_URL,
"display_job_result_url" : self._DISPLAY_JOB_RESULT_URL,
"language" : language,
"job_result_id" : current_job_result.get_id()
})
table_rows += row
body = """
<table class="spacedcells">
<th>%(label_job_name)s</th>
<th>%(label_job_frequency)s</th>
<th>%(label_execution_date)s</th>
<th>%(label_status)s</th>
%(table_rows)s
</table>
""" % {
"table_rows" : table_rows,
"label_job_name" : _("Job"),
"label_job_frequency" : _("Run"),
"label_execution_date" : _("Date"),
"label_status" : _("Status")
}
return body
def tmpl_display_job_result_information(self, job_result, language = CFG_SITE_LANG):
"""Creates a page with information about a given job result
@param job_result: JobResult object with containg the job result
@param language: language of the page
@return: The HTML content of the page
"""
_ = gettext_set_language(language)
table_rows = ""
for current_query_result in job_result.get_query_results():
current_query_name = current_query_result.get_query().get_name()
# set the status text
if current_query_result.STATUS_CODE_OK == current_query_result.get_status():
status = _("OK")
else:
status = _("Error")
records_found = current_query_result.get_number_of_records_found()
row = """<tr>
<td>%(query_name)s</td>
<td><b>%(status)s</b></td>
<td><small>%(number_of_records_found)s %(label_records_found)s</small></td>
</tr>""" % self._html_escape_dictionary({
"query_name" : current_query_name,
"status" : status,
"number_of_records_found" : records_found,
"label_records_found" : _("records found")
})
table_rows += row
number_of_all_records_found = job_result.get_number_of_records_found()
job_result_id = job_result.get_id()
final_row = """
<tr>
<td></td>
<td><b>%(label_total)s</b></td>
<td>
<a href="%(display_job_results_url)s?result_id=%(job_result_id)s&ln=%(language)s">
<b>%(number_of_all_records_found)s %(label_records_found)s</b>
</a>
</td>
</tr>""" % self._html_escape_dictionary({
"label_total" : _("Total"),
"number_of_all_records_found" : number_of_all_records_found,
"label_records_found" : _("records found"),
"display_job_results_url" : self._DISPLAY_JOB_RESULT_URL,
"language" : language,
"job_result_id" : job_result_id
})
table_rows += final_row
download_row = """
<tr>
<td></td><td></td><td>
<a href="%(download_job_results_url)s?result_id=%(job_result_id)s&ln=%(language)s">
<input type="button" value="%(label_download)s" class="formbutton">
</a>
</td>
</tr>""" % self._html_escape_dictionary({
"label_download" : _("Download"),
"download_job_results_url" : self._DOWNLOAD_JOB_RESULT_URL,
"language" : language,
"job_result_id" : job_result_id
})
table_rows += download_row
job_name = self._html_escape_content(job_result.get_job().get_name())
if(job_result.get_status() == job_result.STATUS_CODE_ERROR):
status_messasge = job_result.get_status_message()
else:
status_messasge = ""
status_messasge = self._html_escape_content(status_messasge)
body = """
<h2>%(job_name)s</h2>
<table class="spacedcells">
<th>%(label_query)s</th>
<th>%(label_status)s</th>
<th></th>
%(table_rows)s
</table>
<br>
<pre style="color: Red;">%(status_message)s</pre>
""" % {
"table_rows" : table_rows,
"label_query" : _("Query"),
"label_status" : _("Status"),
"job_name" : job_name,
"status_message" : status_messasge
}
return body
def _get_select_all_none_html(self, form_name, field_name, language = CFG_SITE_LANG):
"""Returns HTML providing Select All|None links
@param form_name: the name of the form containing the checkboxes
@param field_name: the name of the checkbox fields that will be affected
@param language: language for output
"""
_ = gettext_set_language(language)
output_html = """
%(label_select)s: <a href="javascript:SetAllCheckBoxes('%(form_name)s', '%(field_name)s', true);">%(label_all)s</a>, <a href="javascript:SetAllCheckBoxes('%(form_name)s', '%(field_name)s', false);">%(label_none)s</a>
"""% {
"label_select" : _("Select"),
"label_all" : _("All"),
"label_none" : _("None"),
"form_name" : form_name,
"field_name" : field_name
}
return output_html
def _get_frequency_text(self, frequency, language = CFG_SITE_LANG):
"""
Returns text representation of the frequency: Manually, Daily, Weekly, Monthly
@param frequency: integer containg the number of hours between every execution.
@param language: language for output
"""
_ = gettext_set_language(language)
if 0 == frequency:
frequency_text = _("Manually")
elif 24 == frequency:
frequency_text = _("Daily")
elif 168 == frequency:
frequency_text = _("Weekly")
elif 720 == frequency:
frequency_text = _("Monthly")
else:
frequency_text = "Every %s hours" % (frequency,)
return frequency_text
def _create_output_format_select_box(self, selected_value = 0):
"""
Creates a select box for output format of a job.
@param name: name of the control
@param language: language of the menu
@param selected_value: value selected in the control
@return: HTML string representing HTML select control.
"""
items = [("MARCXML", Job.OUTPUT_FORMAT_MARCXML),
("MARC", Job.OUTPUT_FORMAT_MARC)]
html_output = self._create_select_box("output_format", items, selected_value)
return html_output
def _create_frequency_select_box(self, name, selected_value = 0, language = CFG_SITE_LANG):
"""
Creates a select box for frequency of an action/task.
@param name: name of the control
@param language: language of the menu
@param selected_value: value selected in the control
@return: HTML string representing HTML select control.
"""
items = [(self._get_frequency_text(0, language), 0),
(self._get_frequency_text(24, language), 24),
(self._get_frequency_text(168, language), 168),
(self._get_frequency_text(720, language), 720)]
html_output = self._create_select_box(name, items, selected_value)
return html_output
def _create_select_box(self, name, items, selected_value = None):
""" Returns the HTML code for a select box.
@param name: the name of the control
@param items: list of (text, value) tuples where text is the text to be displayed
and value is the value corresponding to the text in the select box
e.g. [("first", 1), ("second", 2), ("third", 3)]
@param selected_value: the value that will be selected
in the select box.
"""
html_output = """<select name="%s">""" % name
for text, value in items:
if selected_value == value:
selected = 'selected="selected"'
else:
selected = ""
current_option = """<option value="%(value)s" %(selected)s>%(text)s</option>""" % self._html_escape_dictionary({
"value" : value,
"text" : text,
"selected" :selected
})
html_output += current_option
html_output += """</select>"""
return html_output
def _html_escape_dictionary(self, dictionaty_to_escape):
"""Escapes all the values in the dictionary and transform
them in strings that are safe to siplay in HTML page.
HTML special symbols are replaced with their sage equivalents.
@param dictionaty_to_escape: dictionary containing values
that have to be escaped.
@return: returns dictionary with the same keys where the
values are escaped strings"""
for key in dictionaty_to_escape:
value = "%s" % dictionaty_to_escape[key]
dictionaty_to_escape[key] = cgi.escape(value)
return dictionaty_to_escape
def _html_escape_content(self, content_to_escape):
"""Escapes the value given as parameter and
trasforms it to a string that is safe for display in HTML page.
@param content_to_escape: contains the content that have to be escaped.
@return: string containing the escaped content
"""
text_content = "%s" % content_to_escape
escaped_content = cgi.escape(text_content)
return escaped_content
| MSusik/invenio | invenio/legacy/bibexport/templates.py | Python | gpl-2.0 | 29,937 |
/* rescoff.c -- read and write resources in Windows COFF files.
Copyright 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils.
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. */
/* This file contains function that read and write Windows resources
in COFF files. */
#include "bfd.h"
#include "bucomm.h"
#include "libiberty.h"
#include "windres.h"
#include <assert.h>
/* In order to use the address of a resource data entry, we need to
get the image base of the file. Right now we extract it from
internal BFD information. FIXME. */
#include "coff/internal.h"
#include "libcoff.h"
/* Information we extract from the file. */
struct coff_file_info
{
/* File name. */
const char *filename;
/* Data read from the file. */
const bfd_byte *data;
/* End of data read from file. */
const bfd_byte *data_end;
/* Address of the resource section minus the image base of the file. */
bfd_vma secaddr;
/* Non-zero if the file is big endian. */
int big_endian;
};
/* A resource directory table in a COFF file. */
struct extern_res_directory
{
/* Characteristics. */
bfd_byte characteristics[4];
/* Time stamp. */
bfd_byte time[4];
/* Major version number. */
bfd_byte major[2];
/* Minor version number. */
bfd_byte minor[2];
/* Number of named directory entries. */
bfd_byte name_count[2];
/* Number of directory entries with IDs. */
bfd_byte id_count[2];
};
/* A resource directory entry in a COFF file. */
struct extern_res_entry
{
/* Name or ID. */
bfd_byte name[4];
/* Address of resource entry or subdirectory. */
bfd_byte rva[4];
};
/* A resource data entry in a COFF file. */
struct extern_res_data
{
/* Address of resource data. This is apparently a file relative
address, rather than a section offset. */
bfd_byte rva[4];
/* Size of resource data. */
bfd_byte size[4];
/* Code page. */
bfd_byte codepage[4];
/* Reserved. */
bfd_byte reserved[4];
};
/* Macros to swap in values. */
#define getfi_16(fi, s) ((fi)->big_endian ? bfd_getb16 (s) : bfd_getl16 (s))
#define getfi_32(fi, s) ((fi)->big_endian ? bfd_getb32 (s) : bfd_getl32 (s))
/* Local functions. */
static void overrun PARAMS ((const struct coff_file_info *, const char *));
static struct res_directory *read_coff_res_dir
PARAMS ((const bfd_byte *, const struct coff_file_info *,
const struct res_id *, int));
static struct res_resource *read_coff_data_entry
PARAMS ((const bfd_byte *, const struct coff_file_info *,
const struct res_id *));
/* Read the resources in a COFF file. */
struct res_directory *
read_coff_rsrc (filename, target)
const char *filename;
const char *target;
{
bfd *abfd;
char **matching;
asection *sec;
bfd_size_type size;
bfd_byte *data;
struct coff_file_info finfo;
if (filename == NULL)
fatal (_("filename required for COFF input"));
abfd = bfd_openr (filename, target);
if (abfd == NULL)
bfd_fatal (filename);
if (! bfd_check_format_matches (abfd, bfd_object, &matching))
{
bfd_nonfatal (bfd_get_filename (abfd));
if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
list_matching_formats (matching);
xexit (1);
}
sec = bfd_get_section_by_name (abfd, ".rsrc");
if (sec == NULL)
{
fatal (_("%s: no resource section"), filename);
}
size = bfd_section_size (abfd, sec);
data = (bfd_byte *) res_alloc (size);
if (! bfd_get_section_contents (abfd, sec, data, 0, size))
bfd_fatal (_("can't read resource section"));
finfo.filename = filename;
finfo.data = data;
finfo.data_end = data + size;
finfo.secaddr = (bfd_get_section_vma (abfd, sec)
- pe_data (abfd)->pe_opthdr.ImageBase);
finfo.big_endian = bfd_big_endian (abfd);
bfd_close (abfd);
/* Now just read in the top level resource directory. Note that we
don't free data, since we create resource entries that point into
it. If we ever want to free up the resource information we read,
this will have to be cleaned up. */
return read_coff_res_dir (data, &finfo, (const struct res_id *) NULL, 0);
}
/* Give an error if we are out of bounds. */
static void
overrun (finfo, msg)
const struct coff_file_info *finfo;
const char *msg;
{
fatal (_("%s: %s: address out of bounds"), finfo->filename, msg);
}
/* Read a resource directory. */
static struct res_directory *
read_coff_res_dir (data, finfo, type, level)
const bfd_byte *data;
const struct coff_file_info *finfo;
const struct res_id *type;
int level;
{
const struct extern_res_directory *erd;
struct res_directory *rd;
int name_count, id_count, i;
struct res_entry **pp;
const struct extern_res_entry *ere;
if ((size_t) (finfo->data_end - data) < sizeof (struct extern_res_directory))
overrun (finfo, _("directory"));
erd = (const struct extern_res_directory *) data;
rd = (struct res_directory *) res_alloc (sizeof *rd);
rd->characteristics = getfi_32 (finfo, erd->characteristics);
rd->time = getfi_32 (finfo, erd->time);
rd->major = getfi_16 (finfo, erd->major);
rd->minor = getfi_16 (finfo, erd->minor);
rd->entries = NULL;
name_count = getfi_16 (finfo, erd->name_count);
id_count = getfi_16 (finfo, erd->id_count);
pp = &rd->entries;
/* The resource directory entries immediately follow the directory
table. */
ere = (const struct extern_res_entry *) (erd + 1);
for (i = 0; i < name_count; i++, ere++)
{
unsigned long name, rva;
struct res_entry *re;
const bfd_byte *ers;
int length, j;
if ((const bfd_byte *) ere >= finfo->data_end)
overrun (finfo, _("named directory entry"));
name = getfi_32 (finfo, ere->name);
rva = getfi_32 (finfo, ere->rva);
/* For some reason the high bit in NAME is set. */
name &=~ 0x80000000;
if (name > (size_t) (finfo->data_end - finfo->data))
overrun (finfo, _("directory entry name"));
ers = finfo->data + name;
re = (struct res_entry *) res_alloc (sizeof *re);
re->next = NULL;
re->id.named = 1;
length = getfi_16 (finfo, ers);
re->id.u.n.length = length;
re->id.u.n.name = (unichar *) res_alloc (length * sizeof (unichar));
for (j = 0; j < length; j++)
re->id.u.n.name[j] = getfi_16 (finfo, ers + j * 2 + 2);
if (level == 0)
type = &re->id;
if ((rva & 0x80000000) != 0)
{
rva &=~ 0x80000000;
if (rva >= (size_t) (finfo->data_end - finfo->data))
overrun (finfo, _("named subdirectory"));
re->subdir = 1;
re->u.dir = read_coff_res_dir (finfo->data + rva, finfo, type,
level + 1);
}
else
{
if (rva >= (size_t) (finfo->data_end - finfo->data))
overrun (finfo, _("named resource"));
re->subdir = 0;
re->u.res = read_coff_data_entry (finfo->data + rva, finfo, type);
}
*pp = re;
pp = &re->next;
}
for (i = 0; i < id_count; i++, ere++)
{
unsigned long name, rva;
struct res_entry *re;
if ((const bfd_byte *) ere >= finfo->data_end)
overrun (finfo, _("ID directory entry"));
name = getfi_32 (finfo, ere->name);
rva = getfi_32 (finfo, ere->rva);
re = (struct res_entry *) res_alloc (sizeof *re);
re->next = NULL;
re->id.named = 0;
re->id.u.id = name;
if (level == 0)
type = &re->id;
if ((rva & 0x80000000) != 0)
{
rva &=~ 0x80000000;
if (rva >= (size_t) (finfo->data_end - finfo->data))
overrun (finfo, _("ID subdirectory"));
re->subdir = 1;
re->u.dir = read_coff_res_dir (finfo->data + rva, finfo, type,
level + 1);
}
else
{
if (rva >= (size_t) (finfo->data_end - finfo->data))
overrun (finfo, _("ID resource"));
re->subdir = 0;
re->u.res = read_coff_data_entry (finfo->data + rva, finfo, type);
}
*pp = re;
pp = &re->next;
}
return rd;
}
/* Read a resource data entry. */
static struct res_resource *
read_coff_data_entry (data, finfo, type)
const bfd_byte *data;
const struct coff_file_info *finfo;
const struct res_id *type;
{
const struct extern_res_data *erd;
struct res_resource *r;
unsigned long size, rva;
const bfd_byte *resdata;
if (type == NULL)
fatal (_("resource type unknown"));
if ((size_t) (finfo->data_end - data) < sizeof (struct extern_res_data))
overrun (finfo, _("data entry"));
erd = (const struct extern_res_data *) data;
size = getfi_32 (finfo, erd->size);
rva = getfi_32 (finfo, erd->rva);
if (rva < finfo->secaddr
|| rva - finfo->secaddr >= (size_t) (finfo->data_end - finfo->data))
overrun (finfo, _("resource data"));
resdata = finfo->data + (rva - finfo->secaddr);
if (size > (size_t) (finfo->data_end - resdata))
overrun (finfo, _("resource data size"));
r = bin_to_res (*type, resdata, size, finfo->big_endian);
memset (&r->res_info, 0, sizeof (struct res_res_info));
r->coff_info.codepage = getfi_32 (finfo, erd->codepage);
r->coff_info.reserved = getfi_32 (finfo, erd->reserved);
return r;
}
/* This structure is used to build a list of bindata structures. */
struct bindata_build
{
/* The data. */
struct bindata *d;
/* The last structure we have added to the list. */
struct bindata *last;
/* The size of the list as a whole. */
unsigned long length;
};
/* This structure keeps track of information as we build the directory
tree. */
struct coff_write_info
{
/* These fields are based on the BFD. */
/* The BFD itself. */
bfd *abfd;
/* Non-zero if the file is big endian. */
int big_endian;
/* Pointer to section symbol used to build RVA relocs. */
asymbol **sympp;
/* These fields are computed initially, and then not changed. */
/* Length of directory tables and entries. */
unsigned long dirsize;
/* Length of directory entry strings. */
unsigned long dirstrsize;
/* Length of resource data entries. */
unsigned long dataentsize;
/* These fields are updated as we add data. */
/* Directory tables and entries. */
struct bindata_build dirs;
/* Directory entry strings. */
struct bindata_build dirstrs;
/* Resource data entries. */
struct bindata_build dataents;
/* Actual resource data. */
struct bindata_build resources;
/* Relocations. */
arelent **relocs;
/* Number of relocations. */
unsigned int reloc_count;
};
/* Macros to swap out values. */
#define putcwi_16(cwi, v, s) \
((cwi->big_endian) ? bfd_putb16 ((v), (s)) : bfd_putl16 ((v), (s)))
#define putcwi_32(cwi, v, s) \
((cwi->big_endian) ? bfd_putb32 ((v), (s)) : bfd_putl32 ((v), (s)))
static void coff_bin_sizes
PARAMS ((const struct res_directory *, struct coff_write_info *));
static unsigned char *coff_alloc PARAMS ((struct bindata_build *, size_t));
static void coff_to_bin
PARAMS ((const struct res_directory *, struct coff_write_info *));
static void coff_res_to_bin
PARAMS ((const struct res_resource *, struct coff_write_info *));
/* Write resources to a COFF file. RESOURCES should already be
sorted.
Right now we always create a new file. Someday we should also
offer the ability to merge resources into an existing file. This
would require doing the basic work of objcopy, just modifying or
adding the .rsrc section. */
void
write_coff_file (filename, target, resources)
const char *filename;
const char *target;
const struct res_directory *resources;
{
bfd *abfd;
asection *sec;
struct coff_write_info cwi;
struct bindata *d;
unsigned long length, offset;
if (filename == NULL)
fatal (_("filename required for COFF output"));
abfd = bfd_openw (filename, target);
if (abfd == NULL)
bfd_fatal (filename);
if (! bfd_set_format (abfd, bfd_object))
bfd_fatal ("bfd_set_format");
#if defined DLLTOOL_SH
if (! bfd_set_arch_mach (abfd, bfd_arch_sh, 0))
bfd_fatal ("bfd_set_arch_mach(sh)");
#elif defined DLLTOOL_MIPS
if (! bfd_set_arch_mach (abfd, bfd_arch_mips, 0))
bfd_fatal ("bfd_set_arch_mach(mips)");
#elif defined DLLTOOL_ARM
if (! bfd_set_arch_mach (abfd, bfd_arch_arm, 0))
bfd_fatal ("bfd_set_arch_mach(arm)");
#else
/* FIXME: This is obviously i386 specific. */
if (! bfd_set_arch_mach (abfd, bfd_arch_i386, 0))
bfd_fatal ("bfd_set_arch_mach(i386)");
#endif
if (! bfd_set_file_flags (abfd, HAS_SYMS | HAS_RELOC))
bfd_fatal ("bfd_set_file_flags");
sec = bfd_make_section (abfd, ".rsrc");
if (sec == NULL)
bfd_fatal ("bfd_make_section");
if (! bfd_set_section_flags (abfd, sec,
(SEC_HAS_CONTENTS | SEC_ALLOC
| SEC_LOAD | SEC_DATA)))
bfd_fatal ("bfd_set_section_flags");
if (! bfd_set_symtab (abfd, sec->symbol_ptr_ptr, 1))
bfd_fatal ("bfd_set_symtab");
/* Requiring this is probably a bug in BFD. */
sec->output_section = sec;
/* The order of data in the .rsrc section is
resource directory tables and entries
resource directory strings
resource data entries
actual resource data
We build these different types of data in different lists. */
cwi.abfd = abfd;
cwi.big_endian = bfd_big_endian (abfd);
cwi.sympp = sec->symbol_ptr_ptr;
cwi.dirsize = 0;
cwi.dirstrsize = 0;
cwi.dataentsize = 0;
cwi.dirs.d = NULL;
cwi.dirs.last = NULL;
cwi.dirs.length = 0;
cwi.dirstrs.d = NULL;
cwi.dirstrs.last = NULL;
cwi.dirstrs.length = 0;
cwi.dataents.d = NULL;
cwi.dataents.last = NULL;
cwi.dataents.length = 0;
cwi.resources.d = NULL;
cwi.resources.last = NULL;
cwi.resources.length = 0;
cwi.relocs = NULL;
cwi.reloc_count = 0;
/* Work out the sizes of the resource directory entries, so that we
know the various offsets we will need. */
coff_bin_sizes (resources, &cwi);
/* Force the directory strings to be 32 bit aligned. Every other
structure is 32 bit aligned anyhow. */
cwi.dirstrsize = (cwi.dirstrsize + 3) &~ 3;
/* Actually convert the resources to binary. */
coff_to_bin (resources, &cwi);
/* Add another 2 bytes to the directory strings if needed for
alignment. */
if ((cwi.dirstrs.length & 3) != 0)
{
unsigned char *ex;
ex = coff_alloc (&cwi.dirstrs, 2);
ex[0] = 0;
ex[1] = 0;
}
/* Make sure that the data we built came out to the same size as we
calculated initially. */
assert (cwi.dirs.length == cwi.dirsize);
assert (cwi.dirstrs.length == cwi.dirstrsize);
assert (cwi.dataents.length == cwi.dataentsize);
length = (cwi.dirsize
+ cwi.dirstrsize
+ cwi.dataentsize
+ cwi.resources.length);
if (! bfd_set_section_size (abfd, sec, length))
bfd_fatal ("bfd_set_section_size");
bfd_set_reloc (abfd, sec, cwi.relocs, cwi.reloc_count);
offset = 0;
for (d = cwi.dirs.d; d != NULL; d = d->next)
{
if (! bfd_set_section_contents (abfd, sec, d->data, offset, d->length))
bfd_fatal ("bfd_set_section_contents");
offset += d->length;
}
for (d = cwi.dirstrs.d; d != NULL; d = d->next)
{
if (! bfd_set_section_contents (abfd, sec, d->data, offset, d->length))
bfd_fatal ("bfd_set_section_contents");
offset += d->length;
}
for (d = cwi.dataents.d; d != NULL; d = d->next)
{
if (! bfd_set_section_contents (abfd, sec, d->data, offset, d->length))
bfd_fatal ("bfd_set_section_contents");
offset += d->length;
}
for (d = cwi.resources.d; d != NULL; d = d->next)
{
if (! bfd_set_section_contents (abfd, sec, d->data, offset, d->length))
bfd_fatal ("bfd_set_section_contents");
offset += d->length;
}
assert (offset == length);
if (! bfd_close (abfd))
bfd_fatal ("bfd_close");
/* We allocated the relocs array using malloc. */
free (cwi.relocs);
}
/* Work out the sizes of the various fixed size resource directory
entries. This updates fields in CWI. */
static void
coff_bin_sizes (resdir, cwi)
const struct res_directory *resdir;
struct coff_write_info *cwi;
{
const struct res_entry *re;
cwi->dirsize += sizeof (struct extern_res_directory);
for (re = resdir->entries; re != NULL; re = re->next)
{
cwi->dirsize += sizeof (struct extern_res_entry);
if (re->id.named)
cwi->dirstrsize += re->id.u.n.length * 2 + 2;
if (re->subdir)
coff_bin_sizes (re->u.dir, cwi);
else
cwi->dataentsize += sizeof (struct extern_res_data);
}
}
/* Allocate data for a particular list. */
static unsigned char *
coff_alloc (bb, size)
struct bindata_build *bb;
size_t size;
{
struct bindata *d;
d = (struct bindata *) reswr_alloc (sizeof *d);
d->next = NULL;
d->data = (unsigned char *) reswr_alloc (size);
d->length = size;
if (bb->d == NULL)
bb->d = d;
else
bb->last->next = d;
bb->last = d;
bb->length += size;
return d->data;
}
/* Convert the resource directory RESDIR to binary. */
static void
coff_to_bin (resdir, cwi)
const struct res_directory *resdir;
struct coff_write_info *cwi;
{
struct extern_res_directory *erd;
int ci, cn;
const struct res_entry *e;
struct extern_res_entry *ere;
/* Write out the directory table. */
erd = ((struct extern_res_directory *)
coff_alloc (&cwi->dirs, sizeof (*erd)));
putcwi_32 (cwi, resdir->characteristics, erd->characteristics);
putcwi_32 (cwi, resdir->time, erd->time);
putcwi_16 (cwi, resdir->major, erd->major);
putcwi_16 (cwi, resdir->minor, erd->minor);
ci = 0;
cn = 0;
for (e = resdir->entries; e != NULL; e = e->next)
{
if (e->id.named)
++cn;
else
++ci;
}
putcwi_16 (cwi, cn, erd->name_count);
putcwi_16 (cwi, ci, erd->id_count);
/* Write out the data entries. Note that we allocate space for all
the entries before writing them out. That permits a recursive
call to work correctly when writing out subdirectories. */
ere = ((struct extern_res_entry *)
coff_alloc (&cwi->dirs, (ci + cn) * sizeof (*ere)));
for (e = resdir->entries; e != NULL; e = e->next, ere++)
{
if (! e->id.named)
putcwi_32 (cwi, e->id.u.id, ere->name);
else
{
unsigned char *str;
int i;
/* For some reason existing files seem to have the high bit
set on the address of the name, although that is not
documented. */
putcwi_32 (cwi,
0x80000000 | (cwi->dirsize + cwi->dirstrs.length),
ere->name);
str = coff_alloc (&cwi->dirstrs, e->id.u.n.length * 2 + 2);
putcwi_16 (cwi, e->id.u.n.length, str);
for (i = 0; i < e->id.u.n.length; i++)
putcwi_16 (cwi, e->id.u.n.name[i], str + i * 2 + 2);
}
if (e->subdir)
{
putcwi_32 (cwi, 0x80000000 | cwi->dirs.length, ere->rva);
coff_to_bin (e->u.dir, cwi);
}
else
{
putcwi_32 (cwi,
cwi->dirsize + cwi->dirstrsize + cwi->dataents.length,
ere->rva);
coff_res_to_bin (e->u.res, cwi);
}
}
}
/* Convert the resource RES to binary. */
static void
coff_res_to_bin (res, cwi)
const struct res_resource *res;
struct coff_write_info *cwi;
{
arelent *r;
struct extern_res_data *erd;
struct bindata *d;
unsigned long length;
/* For some reason, although every other address is a section
offset, the address of the resource data itself is an RVA. That
means that we need to generate a relocation for it. We allocate
the relocs array using malloc so that we can use realloc. FIXME:
This relocation handling is correct for the i386, but probably
not for any other target. */
r = (arelent *) reswr_alloc (sizeof (arelent));
r->sym_ptr_ptr = cwi->sympp;
r->address = cwi->dirsize + cwi->dirstrsize + cwi->dataents.length;
r->addend = 0;
r->howto = bfd_reloc_type_lookup (cwi->abfd, BFD_RELOC_RVA);
if (r->howto == NULL)
bfd_fatal (_("can't get BFD_RELOC_RVA relocation type"));
cwi->relocs = xrealloc (cwi->relocs,
(cwi->reloc_count + 2) * sizeof (arelent *));
cwi->relocs[cwi->reloc_count] = r;
cwi->relocs[cwi->reloc_count + 1] = NULL;
++cwi->reloc_count;
erd = (struct extern_res_data *) coff_alloc (&cwi->dataents, sizeof (*erd));
putcwi_32 (cwi,
(cwi->dirsize
+ cwi->dirstrsize
+ cwi->dataentsize
+ cwi->resources.length),
erd->rva);
putcwi_32 (cwi, res->coff_info.codepage, erd->codepage);
putcwi_32 (cwi, res->coff_info.reserved, erd->reserved);
d = res_to_bin (res, cwi->big_endian);
if (cwi->resources.d == NULL)
cwi->resources.d = d;
else
cwi->resources.last->next = d;
length = 0;
for (; d->next != NULL; d = d->next)
length += d->length;
length += d->length;
cwi->resources.last = d;
cwi->resources.length += length;
putcwi_32 (cwi, length, erd->size);
/* Force the next resource to have 32 bit alignment. */
if ((length & 3) != 0)
{
int add;
unsigned char *ex;
add = 4 - (length & 3);
ex = coff_alloc (&cwi->resources, add);
memset (ex, 0, add);
}
}
| nslu2/Build-binutils-2.13.2 | binutils/rescoff.c | C | gpl-2.0 | 21,675 |
.banner_url_form_field fieldset {
float: left;
clear: left;
margin-bottom: 20px;
}
.banner_url_form_field .button,
.banner_url_form_field label {
float: left;
margin-right: 10px;
}
.banner_url_form_field label {
line-height: 2em;
}
.banner_url_form_field img {
float: left;
clear: left;
margin-top: 10px;
max-height: 100px;
} | thazinthein/universal | wp-content/plugins/woocommerce-category-banner/assets/css/wcb-admin.css | CSS | gpl-2.0 | 339 |
obj-y += io.o dma.o memory.o
ifndef CONFIG_ARM_ARCH_TIMER
obj-y += timer.o
endif
obj-$(CONFIG_USE_OF) += board-dt.o
obj-y += acpuclock.o
obj-$(CONFIG_HW_PERF_EVENTS) += perf_trace_counters.o perf_trace_user.o
obj-$(CONFIG_ARCH_MSM_KRAIT) += msm-krait-l2-accessors.o perf_event_msm_krait_l2.o
obj-$(CONFIG_ARCH_MSM_KRAIT) += krait-scm.o
obj-$(CONFIG_DEBUG_FS) += perf_debug.o
obj-$(CONFIG_SMP) += headsmp.o platsmp.o
obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
obj-$(CONFIG_MSM_TEST_QMI_CLIENT) += kernel_test_service_v01.o test_qmi_client.o
obj-$(CONFIG_MSM_PCIE) += pcie.o pcie_irq.o pcie_phy.o
obj-$(CONFIG_MSM_DMA_TEST) += dma_test.o
obj-$(CONFIG_SURF_FFA_GPIO_KEYPAD) += keypad-surf-ffa.o
obj-$(CONFIG_ARCH_FSM9900) += board-fsm9900.o board-fsm9900-gpiomux.o
obj-$(CONFIG_ARCH_FSM9900) += clock-fsm9900.o
obj-$(CONFIG_ARCH_FSM9900) += rfic-fsm9900.o bbif-fsm9900.o
obj-$(CONFIG_ARCH_FSM9010) += board-fsm9010.o
obj-$(CONFIG_ARCH_FSM9010) += rfic-fsm9010.o bbif-fsm9010.o
obj-$(CONFIG_QPNP_BMS) += bms-batterydata.o bms-batterydata-desay.o
obj-$(CONFIG_QPNP_BMS) += bms-batterydata-oem.o bms-batterydata-qrd-4v35-2000mah.o bms-batterydata-qrd-4v2-1300mah.o
obj-$(CONFIG_ARCH_APQ8084) += board-8084.o board-8084-gpiomux.o
obj-$(CONFIG_ARCH_APQ8084) += clock-8084.o clock-mdss-8974.o
obj-$(CONFIG_ARCH_MSM8974) += board-8974.o board-8974-gpiomux.o
obj-$(CONFIG_ARCH_MSM8974) += clock-rpm-8974.o clock-gcc-8974.o clock-mmss-8974.o clock-lpass-8974.o clock-mdss-8974.o
obj-$(CONFIG_KRAIT_REGULATOR) += krait-regulator.o krait-regulator-pmic.o
obj-$(CONFIG_ARCH_MDM9630) += board-9630.o board-9630-gpiomux.o
obj-$(CONFIG_MSM_PP2S_FEMTO) += pp2s.o
obj-$(CONFIG_ARCH_MSM8909) += board-8909.o
obj-$(CONFIG_ARCH_MSM8916) += board-8916.o
obj-$(CONFIG_ARCH_MSM8226) += board-8226.o board-8226-gpiomux.o
obj-$(CONFIG_ARCH_MSM8226) += clock-8226.o clock-mdss-8974.o
obj-$(CONFIG_ARCH_MSM8610) += board-8610.o board-8610-gpiomux.o
obj-$(CONFIG_ARCH_MSM8610) += clock-8610.o
obj-$(CONFIG_ARCH_MSM8610) += clock-dsi-8610.o
obj-$(CONFIG_ARCH_MDM9630) += clock-9630.o
obj-$(CONFIG_ARCH_MDM9640) += board-9640.o
obj-$(CONFIG_ARCH_MDMFERMIUM) += board-fermium.o
obj-$(CONFIG_ARCH_MDMCALIFORNIUM) += board-californium.o
obj-$(CONFIG_ARCH_MSMVPIPA) += board-vpipa.o
obj-$(CONFIG_MSM_PM) += ext-buck-control.o
CFLAGS_msm_vibrator.o += -Idrivers/staging/android
obj-$(CONFIG_MSM_LPM_TEST) += test-lpm.o
obj-$(CONFIG_ARCH_MSM8974) += gpiomux-v2.o gpiomux.o
obj-$(CONFIG_ARCH_MDM9630) += gpiomux-v2.o gpiomux.o
obj-$(CONFIG_ARCH_MSM8226) += gpiomux-v2.o gpiomux.o
obj-$(CONFIG_ARCH_MSM8610) += gpiomux-v2.o gpiomux.o
obj-$(CONFIG_ARCH_APQ8084) += gpiomux-v2.o gpiomux.o
obj-$(CONFIG_ARCH_FSM9900) += gpiomux-v2.o gpiomux.o
obj-$(CONFIG_MSM_CACHE_ERP) += cache_erp.o
obj-$(CONFIG_MSM_HSIC_SYSMON) += hsic_sysmon.o
obj-$(CONFIG_MSM_HSIC_SYSMON_TEST) += hsic_sysmon_test.o
obj-$(CONFIG_MSM_RPC_USB) += rpc_hsusb.o rpc_fsusb.o
obj-$(CONFIG_MEMORY_HOLE_CARVEOUT) += msm_mem_hole.o
obj-$(CONFIG_MSM_SMCMOD) += smcmod.o
obj-$(CONFIG_ARCH_MSM8974) += msm_mpmctr.o
obj-$(CONFIG_PERFMAP) += perfmap.o
obj-$(CONFIG_HAS_MACH_MEMUTILS) += memutils/
| rostifaner/android_kernel_xiaomi_msm8956 | arch/arm/mach-msm/Makefile | Makefile | gpl-2.0 | 3,128 |
from autotest.client.shared import error
from virttest import qemu_monitor
def run(test, params, env):
"""
QMP Specification test-suite: this checks if the *basic* protocol conforms
to its specification, which is file QMP/qmp-spec.txt in QEMU's source tree.
IMPORTANT NOTES:
o Most tests depend heavily on QMP's error information (eg. classes),
this might have bad implications as the error interface is going to
change in QMP
o Command testing is *not* covered in this suite. Each command has its
own specification and should be tested separately
o We use the same terminology as used by the QMP specification,
specially with regard to JSON types (eg. a Python dict is called
a json-object)
o This is divided in sub test-suites, please check the bottom of this
file to check the order in which they are run
TODO:
o Finding which test failed is not as easy as it should be
o Are all those check_*() functions really needed? Wouldn't a
specialized class (eg. a Response class) do better?
"""
def fail_no_key(qmp_dict, key):
if not isinstance(qmp_dict, dict):
raise error.TestFail("qmp_dict is not a dict (it's '%s')" %
type(qmp_dict))
if key not in qmp_dict:
raise error.TestFail("'%s' key doesn't exist in dict ('%s')" %
(key, str(qmp_dict)))
def check_dict_key(qmp_dict, key, keytype):
"""
Performs the following checks on a QMP dict key:
1. qmp_dict is a dict
2. key exists in qmp_dict
3. key is of type keytype
If any of these checks fails, error.TestFail is raised.
"""
fail_no_key(qmp_dict, key)
if not isinstance(qmp_dict[key], keytype):
raise error.TestFail("'%s' key is not of type '%s', it's '%s'" %
(key, keytype, type(qmp_dict[key])))
def check_key_is_dict(qmp_dict, key):
check_dict_key(qmp_dict, key, dict)
def check_key_is_list(qmp_dict, key):
check_dict_key(qmp_dict, key, list)
def check_key_is_str(qmp_dict, key):
check_dict_key(qmp_dict, key, unicode)
def check_str_key(qmp_dict, keyname, value=None):
check_dict_key(qmp_dict, keyname, unicode)
if value and value != qmp_dict[keyname]:
raise error.TestFail("'%s' key value '%s' should be '%s'" %
(keyname, str(qmp_dict[keyname]), str(value)))
def check_key_is_int(qmp_dict, key):
fail_no_key(qmp_dict, key)
try:
int(qmp_dict[key])
except Exception:
raise error.TestFail("'%s' key is not of type int, it's '%s'" %
(key, type(qmp_dict[key])))
def check_bool_key(qmp_dict, keyname, value=None):
check_dict_key(qmp_dict, keyname, bool)
if value and value != qmp_dict[keyname]:
raise error.TestFail("'%s' key value '%s' should be '%s'" %
(keyname, str(qmp_dict[keyname]), str(value)))
def check_success_resp(resp, empty=False):
"""
Check QMP OK response.
:param resp: QMP response
:param empty: if True, response should not contain data to return
"""
check_key_is_dict(resp, "return")
if empty and len(resp["return"]) > 0:
raise error.TestFail("success response is not empty ('%s')" %
str(resp))
def check_error_resp(resp, classname=None, datadict=None):
"""
Check QMP error response.
:param resp: QMP response
:param classname: Expected error class name
:param datadict: Expected error data dictionary
"""
check_key_is_dict(resp, "error")
check_key_is_str(resp["error"], "class")
if classname and resp["error"]["class"] != classname:
raise error.TestFail("got error class '%s' expected '%s'" %
(resp["error"]["class"], classname))
def test_version(version):
"""
Check the QMP greeting message version key which, according to QMP's
documentation, should be:
{ "qemu": { "major": json-int, "minor": json-int, "micro": json-int }
"package": json-string }
"""
check_key_is_dict(version, "qemu")
for key in ("major", "minor", "micro"):
check_key_is_int(version["qemu"], key)
check_key_is_str(version, "package")
def test_greeting(greeting):
check_key_is_dict(greeting, "QMP")
check_key_is_dict(greeting["QMP"], "version")
check_key_is_list(greeting["QMP"], "capabilities")
def greeting_suite(monitor):
"""
Check the greeting message format, as described in the QMP
specfication section '2.2 Server Greeting'.
{ "QMP": { "version": json-object, "capabilities": json-array } }
"""
greeting = monitor.get_greeting()
test_greeting(greeting)
test_version(greeting["QMP"]["version"])
def json_parsing_errors_suite(monitor):
"""
Check that QMP's parser is able to recover from parsing errors, please
check the JSON spec for more info on the JSON syntax (RFC 4627).
"""
# We're quite simple right now and the focus is on parsing errors that
# have already biten us in the past.
#
# TODO: The following test-cases are missing:
#
# - JSON numbers, strings and arrays
# - More invalid characters or malformed structures
# - Valid, but not obvious syntax, like zillion of spaces or
# strings with unicode chars (different suite maybe?)
bad_json = []
# A JSON value MUST be an object, array, number, string, true, false,
# or null
#
# NOTE: QMP seems to ignore a number of chars, like: | and ?
bad_json.append(":")
bad_json.append(",")
# Malformed json-objects
#
# NOTE: sending only "}" seems to break QMP
# NOTE: Duplicate keys are accepted (should it?)
bad_json.append("{ \"execute\" }")
bad_json.append("{ \"execute\": \"query-version\", }")
bad_json.append("{ 1: \"query-version\" }")
bad_json.append("{ true: \"query-version\" }")
bad_json.append("{ []: \"query-version\" }")
bad_json.append("{ {}: \"query-version\" }")
for cmd in bad_json:
resp = monitor.cmd_raw(cmd)
check_error_resp(resp, "GenericError")
def test_id_key(monitor):
"""
Check that QMP's "id" key is correctly handled.
"""
# The "id" key must be echoed back in error responses
id_key = "virt-test"
resp = monitor.cmd_qmp("eject", {"foobar": True}, q_id=id_key)
check_error_resp(resp)
check_str_key(resp, "id", id_key)
# The "id" key must be echoed back in success responses
resp = monitor.cmd_qmp("query-status", q_id=id_key)
check_success_resp(resp)
check_str_key(resp, "id", id_key)
# The "id" key can be any json-object
for id_key in (True, 1234, "string again!", [1, [], {}, True, "foo"],
{"key": {}}):
resp = monitor.cmd_qmp("query-status", q_id=id_key)
check_success_resp(resp)
if resp["id"] != id_key:
raise error.TestFail("expected id '%s' but got '%s'" %
(str(id_key), str(resp["id"])))
def test_invalid_arg_key(monitor):
"""
Currently, the only supported keys in the input object are: "execute",
"arguments" and "id". Although expansion is supported, invalid key
names must be detected.
"""
resp = monitor.cmd_obj({"execute": "eject", "foobar": True})
check_error_resp(resp, "GenericError", {"member": "foobar"})
def test_bad_arguments_key_type(monitor):
"""
The "arguments" key must be an json-object.
We use the eject command to perform the tests, but that's a random
choice, any command that accepts arguments will do, as the command
doesn't get called.
"""
for item in (True, [], 1, "foo"):
resp = monitor.cmd_obj({"execute": "eject", "arguments": item})
check_error_resp(resp, "GenericError",
{"member": "arguments", "expected": "object"})
def test_bad_execute_key_type(monitor):
"""
The "execute" key must be a json-string.
"""
for item in (False, 1, {}, []):
resp = monitor.cmd_obj({"execute": item})
check_error_resp(resp, "GenericError",
{"member": "execute", "expected": "string"})
def test_no_execute_key(monitor):
"""
The "execute" key must exist, we also test for some stupid parsing
errors.
"""
for cmd in ({}, {"execut": "qmp_capabilities"},
{"executee": "qmp_capabilities"}, {"foo": "bar"}):
resp = monitor.cmd_obj(cmd)
check_error_resp(resp) # XXX: check class and data dict?
def test_bad_input_obj_type(monitor):
"""
The input object must be... an json-object.
"""
for cmd in ("foo", [], True, 1):
resp = monitor.cmd_obj(cmd)
check_error_resp(resp, "GenericError", {"expected": "object"})
def test_good_input_obj(monitor):
"""
Basic success tests for issuing QMP commands.
"""
# NOTE: We don't use the cmd_qmp() method here because the command
# object is in a 'random' order
resp = monitor.cmd_obj({"execute": "query-version"})
check_success_resp(resp)
resp = monitor.cmd_obj({"arguments": {}, "execute": "query-version"})
check_success_resp(resp)
idd = "1234foo"
resp = monitor.cmd_obj({"id": idd, "execute": "query-version",
"arguments": {}})
check_success_resp(resp)
check_str_key(resp, "id", idd)
# TODO: would be good to test simple argument usage, but we don't have
# a read-only command that accepts arguments.
def input_object_suite(monitor):
"""
Check the input object format, as described in the QMP specfication
section '2.3 Issuing Commands'.
{ "execute": json-string, "arguments": json-object, "id": json-value }
"""
test_good_input_obj(monitor)
test_bad_input_obj_type(monitor)
test_no_execute_key(monitor)
test_bad_execute_key_type(monitor)
test_bad_arguments_key_type(monitor)
test_id_key(monitor)
test_invalid_arg_key(monitor)
def argument_checker_suite(monitor):
"""
Check that QMP's argument checker is detecting all possible errors.
We use a number of different commands to perform the checks, but the
command used doesn't matter much as QMP performs argument checking
_before_ calling the command.
"""
# stop doesn't take arguments
resp = monitor.cmd_qmp("stop", {"foo": 1})
check_error_resp(resp, "GenericError", {"name": "foo"})
# required argument omitted
resp = monitor.cmd_qmp("screendump")
check_error_resp(resp, "GenericError", {"name": "filename"})
# 'bar' is not a valid argument
resp = monitor.cmd_qmp("screendump", {"filename": "outfile",
"bar": "bar"})
check_error_resp(resp, "GenericError", {"name": "bar"})
# test optional argument: 'force' is omitted, but it's optional, so
# the handler has to be called. Test this happens by checking an
# error that is generated by the handler itself.
resp = monitor.cmd_qmp("eject", {"device": "foobar"})
check_error_resp(resp, "DeviceNotFound")
# filename argument must be a json-string
for arg in ({}, [], 1, True):
resp = monitor.cmd_qmp("screendump", {"filename": arg})
check_error_resp(resp, "GenericError",
{"name": "filename", "expected": "string"})
# force argument must be a json-bool
for arg in ({}, [], 1, "foo"):
resp = monitor.cmd_qmp("eject", {"force": arg, "device": "foo"})
check_error_resp(resp, "GenericError",
{"name": "force", "expected": "bool"})
# val argument must be a json-int
for arg in ({}, [], True, "foo"):
resp = monitor.cmd_qmp("memsave", {"val": arg, "filename": "foo",
"size": 10})
check_error_resp(resp, "GenericError",
{"name": "val", "expected": "int"})
# value argument must be a json-number
for arg in ({}, [], True, "foo"):
resp = monitor.cmd_qmp("migrate_set_speed", {"value": arg})
check_error_resp(resp, "GenericError",
{"name": "value", "expected": "number"})
# qdev-type commands have their own argument checker, all QMP does
# is to skip its checking and pass arguments through. Check this
# works by providing invalid options to device_add and expecting
# an error message from qdev
resp = monitor.cmd_qmp("device_add", {"driver": "e1000", "foo": "bar"})
check_error_resp(resp, "GenericError",
{"device": "e1000", "property": "foo"})
def unknown_commands_suite(monitor):
"""
Check that QMP handles unknown commands correctly.
"""
# We also call a HMP-only command, to be sure it will fail as expected
for cmd in ("bar", "query-", "query-foo", "q", "help"):
resp = monitor.cmd_qmp(cmd)
check_error_resp(resp, "CommandNotFound", {"name": cmd})
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
# Look for the first qmp monitor available, otherwise, fail the test
qmp_monitor = vm.get_monitors_by_type("qmp")
if qmp_monitor:
qmp_monitor = qmp_monitor[0]
else:
raise error.TestError('Could not find a QMP monitor, aborting test')
# Run all suites
greeting_suite(qmp_monitor)
input_object_suite(qmp_monitor)
argument_checker_suite(qmp_monitor)
unknown_commands_suite(qmp_monitor)
json_parsing_errors_suite(qmp_monitor)
# check if QMP is still alive
if not qmp_monitor.is_responsive():
raise error.TestFail('QMP monitor is not responsive after testing')
| uni-peter-zheng/tp-qemu | qemu/tests/qmp_basic.py | Python | gpl-2.0 | 14,858 |
/*
* Driver O/S-independent utility routines
*
* $Copyright Open Broadcom Corporation$
* $Id: bcmutils.c 496061 2014-08-11 06:14:48Z $
*/
#include <bcm_cfg.h>
#include <typedefs.h>
#include <bcmdefs.h>
#include <stdarg.h>
#ifdef BCMDRIVER
#include <osl.h>
#include <bcmutils.h>
#else /* !BCMDRIVER */
#include <stdio.h>
#include <string.h>
#include <bcmutils.h>
#if defined(BCMEXTSUP)
#include <bcm_osl.h>
#endif
#ifndef ASSERT
#define ASSERT(exp)
#endif
#endif /* !BCMDRIVER */
#include <bcmendian.h>
#include <bcmdevs.h>
#include <proto/ethernet.h>
#include <proto/vlan.h>
#include <proto/bcmip.h>
#include <proto/802.1d.h>
#include <proto/802.11.h>
void *_bcmutils_dummy_fn = NULL;
#ifdef CUSTOM_DSCP_TO_PRIO_MAPPING
#define CUST_IPV4_TOS_PREC_MASK 0x3F
#define DCSP_MAX_VALUE 64
/* 0:BE,1:BK,2:RESV(BK):,3:EE,:4:CL,5:VI,6:VO,7:NC */
int dscp2priomap[DCSP_MAX_VALUE]=
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, /* BK->BE */
2, 0, 0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0,
6, 0, 0, 0, 0, 0, 0, 0,
7, 0, 0, 0, 0, 0, 0, 0
};
#endif /* CUSTOM_DSCP_TO_PRIO_MAPPING */
#ifdef BCMDRIVER
/* copy a pkt buffer chain into a buffer */
uint
pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf)
{
uint n, ret = 0;
if (len < 0)
len = 4096; /* "infinite" */
/* skip 'offset' bytes */
for (; p && offset; p = PKTNEXT(osh, p)) {
if (offset < (uint)PKTLEN(osh, p))
break;
offset -= PKTLEN(osh, p);
}
if (!p)
return 0;
/* copy the data */
for (; p && len; p = PKTNEXT(osh, p)) {
n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len);
bcopy(PKTDATA(osh, p) + offset, buf, n);
buf += n;
len -= n;
ret += n;
offset = 0;
}
return ret;
}
/* copy a buffer into a pkt buffer chain */
uint
pktfrombuf(osl_t *osh, void *p, uint offset, int len, uchar *buf)
{
uint n, ret = 0;
/* skip 'offset' bytes */
for (; p && offset; p = PKTNEXT(osh, p)) {
if (offset < (uint)PKTLEN(osh, p))
break;
offset -= PKTLEN(osh, p);
}
if (!p)
return 0;
/* copy the data */
for (; p && len; p = PKTNEXT(osh, p)) {
n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len);
bcopy(buf, PKTDATA(osh, p) + offset, n);
buf += n;
len -= n;
ret += n;
offset = 0;
}
return ret;
}
/* return total length of buffer chain */
uint BCMFASTPATH
pkttotlen(osl_t *osh, void *p)
{
uint total;
int len;
total = 0;
for (; p; p = PKTNEXT(osh, p)) {
len = PKTLEN(osh, p);
total += len;
#ifdef BCMLFRAG
if (BCMLFRAG_ENAB()) {
if (PKTISFRAG(osh, p)) {
total += PKTFRAGTOTLEN(osh, p);
}
}
#endif
}
return (total);
}
/* return the last buffer of chained pkt */
void *
pktlast(osl_t *osh, void *p)
{
for (; PKTNEXT(osh, p); p = PKTNEXT(osh, p))
;
return (p);
}
/* count segments of a chained packet */
uint BCMFASTPATH
pktsegcnt(osl_t *osh, void *p)
{
uint cnt;
for (cnt = 0; p; p = PKTNEXT(osh, p)) {
cnt++;
#ifdef BCMLFRAG
if (BCMLFRAG_ENAB()) {
if (PKTISFRAG(osh, p)) {
cnt += PKTFRAGTOTNUM(osh, p);
}
}
#endif
}
return cnt;
}
/* count segments of a chained packet */
uint BCMFASTPATH
pktsegcnt_war(osl_t *osh, void *p)
{
uint cnt;
uint8 *pktdata;
uint len, remain, align64;
for (cnt = 0; p; p = PKTNEXT(osh, p)) {
cnt++;
len = PKTLEN(osh, p);
if (len > 128) {
pktdata = (uint8 *)PKTDATA(osh, p); /* starting address of data */
/* Check for page boundary straddle (2048B) */
if (((uintptr)pktdata & ~0x7ff) != ((uintptr)(pktdata+len) & ~0x7ff))
cnt++;
align64 = (uint)((uintptr)pktdata & 0x3f); /* aligned to 64B */
align64 = (64 - align64) & 0x3f;
len -= align64; /* bytes from aligned 64B to end */
/* if aligned to 128B, check for MOD 128 between 1 to 4B */
remain = len % 128;
if (remain > 0 && remain <= 4)
cnt++; /* add extra seg */
}
}
return cnt;
}
uint8 * BCMFASTPATH
pktdataoffset(osl_t *osh, void *p, uint offset)
{
uint total = pkttotlen(osh, p);
uint pkt_off = 0, len = 0;
uint8 *pdata = (uint8 *) PKTDATA(osh, p);
if (offset > total)
return NULL;
for (; p; p = PKTNEXT(osh, p)) {
pdata = (uint8 *) PKTDATA(osh, p);
pkt_off = offset - len;
len += PKTLEN(osh, p);
if (len > offset)
break;
}
return (uint8*) (pdata+pkt_off);
}
/* given a offset in pdata, find the pkt seg hdr */
void *
pktoffset(osl_t *osh, void *p, uint offset)
{
uint total = pkttotlen(osh, p);
uint len = 0;
if (offset > total)
return NULL;
for (; p; p = PKTNEXT(osh, p)) {
len += PKTLEN(osh, p);
if (len > offset)
break;
}
return p;
}
#endif /* BCMDRIVER */
#if !defined(BCMROMOFFLOAD_EXCLUDE_BCMUTILS_FUNCS)
const unsigned char bcm_ctype[] = {
_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */
_BCM_C, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C,
_BCM_C, /* 8-15 */
_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */
_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */
_BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */
_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */
_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */
_BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */
_BCM_P, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X,
_BCM_U|_BCM_X, _BCM_U, /* 64-71 */
_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */
_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */
_BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */
_BCM_P, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X,
_BCM_L|_BCM_X, _BCM_L, /* 96-103 */
_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */
_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */
_BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128-143 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 144-159 */
_BCM_S|_BCM_SP, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P,
_BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 160-175 */
_BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P,
_BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 176-191 */
_BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U,
_BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, /* 192-207 */
_BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_P, _BCM_U, _BCM_U, _BCM_U,
_BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_L, /* 208-223 */
_BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L,
_BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, /* 224-239 */
_BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_P, _BCM_L, _BCM_L, _BCM_L,
_BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L /* 240-255 */
};
ulong
bcm_strtoul(const char *cp, char **endp, uint base)
{
ulong result, last_result = 0, value;
bool minus;
minus = FALSE;
while (bcm_isspace(*cp))
cp++;
if (cp[0] == '+')
cp++;
else if (cp[0] == '-') {
minus = TRUE;
cp++;
}
if (base == 0) {
if (cp[0] == '0') {
if ((cp[1] == 'x') || (cp[1] == 'X')) {
base = 16;
cp = &cp[2];
} else {
base = 8;
cp = &cp[1];
}
} else
base = 10;
} else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) {
cp = &cp[2];
}
result = 0;
while (bcm_isxdigit(*cp) &&
(value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) {
result = result*base + value;
/* Detected overflow */
if (result < last_result && !minus)
return (ulong)-1;
last_result = result;
cp++;
}
if (minus)
result = (ulong)(-(long)result);
if (endp)
*endp = DISCARD_QUAL(cp, char);
return (result);
}
int
bcm_atoi(const char *s)
{
return (int)bcm_strtoul(s, NULL, 10);
}
/* return pointer to location of substring 'needle' in 'haystack' */
char *
bcmstrstr(const char *haystack, const char *needle)
{
int len, nlen;
int i;
if ((haystack == NULL) || (needle == NULL))
return DISCARD_QUAL(haystack, char);
nlen = (int)strlen(needle);
len = (int)strlen(haystack) - nlen + 1;
for (i = 0; i < len; i++)
if (memcmp(needle, &haystack[i], nlen) == 0)
return DISCARD_QUAL(&haystack[i], char);
return (NULL);
}
char *
bcmstrnstr(const char *s, uint s_len, const char *substr, uint substr_len)
{
for (; s_len >= substr_len; s++, s_len--)
if (strncmp(s, substr, substr_len) == 0)
return DISCARD_QUAL(s, char);
return NULL;
}
char *
bcmstrcat(char *dest, const char *src)
{
char *p;
p = dest + strlen(dest);
while ((*p++ = *src++) != '\0')
;
return (dest);
}
char *
bcmstrncat(char *dest, const char *src, uint size)
{
char *endp;
char *p;
p = dest + strlen(dest);
endp = p + size;
while (p != endp && (*p++ = *src++) != '\0')
;
return (dest);
}
/****************************************************************************
* Function: bcmstrtok
*
* Purpose:
* Tokenizes a string. This function is conceptually similiar to ANSI C strtok(),
* but allows strToken() to be used by different strings or callers at the same
* time. Each call modifies '*string' by substituting a NULL character for the
* first delimiter that is encountered, and updates 'string' to point to the char
* after the delimiter. Leading delimiters are skipped.
*
* Parameters:
* string (mod) Ptr to string ptr, updated by token.
* delimiters (in) Set of delimiter characters.
* tokdelim (out) Character that delimits the returned token. (May
* be set to NULL if token delimiter is not required).
*
* Returns: Pointer to the next token found. NULL when no more tokens are found.
*****************************************************************************
*/
char *
bcmstrtok(char **string, const char *delimiters, char *tokdelim)
{
unsigned char *str;
unsigned long map[8];
int count;
char *nextoken;
if (tokdelim != NULL) {
/* Prime the token delimiter */
*tokdelim = '\0';
}
/* Clear control map */
for (count = 0; count < 8; count++) {
map[count] = 0;
}
/* Set bits in delimiter table */
do {
map[*delimiters >> 5] |= (1 << (*delimiters & 31));
}
while (*delimiters++);
str = (unsigned char*)*string;
/* Find beginning of token (skip over leading delimiters). Note that
* there is no token iff this loop sets str to point to the terminal
* null (*str == '\0')
*/
while (((map[*str >> 5] & (1 << (*str & 31))) && *str) || (*str == ' ')) {
str++;
}
nextoken = (char*)str;
/* Find the end of the token. If it is not the end of the string,
* put a null there.
*/
for (; *str; str++) {
if (map[*str >> 5] & (1 << (*str & 31))) {
if (tokdelim != NULL) {
*tokdelim = *str;
}
*str++ = '\0';
break;
}
}
*string = (char*)str;
/* Determine if a token has been found. */
if (nextoken == (char *) str) {
return NULL;
}
else {
return nextoken;
}
}
#define xToLower(C) \
((C >= 'A' && C <= 'Z') ? (char)((int)C - (int)'A' + (int)'a') : C)
/****************************************************************************
* Function: bcmstricmp
*
* Purpose: Compare to strings case insensitively.
*
* Parameters: s1 (in) First string to compare.
* s2 (in) Second string to compare.
*
* Returns: Return 0 if the two strings are equal, -1 if t1 < t2 and 1 if
* t1 > t2, when ignoring case sensitivity.
*****************************************************************************
*/
int
bcmstricmp(const char *s1, const char *s2)
{
char dc, sc;
while (*s2 && *s1) {
dc = xToLower(*s1);
sc = xToLower(*s2);
if (dc < sc) return -1;
if (dc > sc) return 1;
s1++;
s2++;
}
if (*s1 && !*s2) return 1;
if (!*s1 && *s2) return -1;
return 0;
}
/****************************************************************************
* Function: bcmstrnicmp
*
* Purpose: Compare to strings case insensitively, upto a max of 'cnt'
* characters.
*
* Parameters: s1 (in) First string to compare.
* s2 (in) Second string to compare.
* cnt (in) Max characters to compare.
*
* Returns: Return 0 if the two strings are equal, -1 if t1 < t2 and 1 if
* t1 > t2, when ignoring case sensitivity.
*****************************************************************************
*/
int
bcmstrnicmp(const char* s1, const char* s2, int cnt)
{
char dc, sc;
while (*s2 && *s1 && cnt) {
dc = xToLower(*s1);
sc = xToLower(*s2);
if (dc < sc) return -1;
if (dc > sc) return 1;
s1++;
s2++;
cnt--;
}
if (!cnt) return 0;
if (*s1 && !*s2) return 1;
if (!*s1 && *s2) return -1;
return 0;
}
/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
int
bcm_ether_atoe(const char *p, struct ether_addr *ea)
{
int i = 0;
char *ep;
for (;;) {
ea->octet[i++] = (char) bcm_strtoul(p, &ep, 16);
p = ep;
if (!*p++ || i == 6)
break;
}
return (i == 6);
}
int
bcm_atoipv4(const char *p, struct ipv4_addr *ip)
{
int i = 0;
char *c;
for (;;) {
ip->addr[i++] = (uint8)bcm_strtoul(p, &c, 0);
if (*c++ != '.' || i == IPV4_ADDR_LEN)
break;
p = c;
}
return (i == IPV4_ADDR_LEN);
}
#endif /* !BCMROMOFFLOAD_EXCLUDE_BCMUTILS_FUNCS */
#if defined(CONFIG_USBRNDIS_RETAIL) || defined(NDIS_MINIPORT_DRIVER)
/* registry routine buffer preparation utility functions:
* parameter order is like strncpy, but returns count
* of bytes copied. Minimum bytes copied is null char(1)/wchar(2)
*/
ulong
wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen)
{
ulong copyct = 1;
ushort i;
if (abuflen == 0)
return 0;
/* wbuflen is in bytes */
wbuflen /= sizeof(ushort);
for (i = 0; i < wbuflen; ++i) {
if (--abuflen == 0)
break;
*abuf++ = (char) *wbuf++;
++copyct;
}
*abuf = '\0';
return copyct;
}
#endif /* CONFIG_USBRNDIS_RETAIL || NDIS_MINIPORT_DRIVER */
char *
bcm_ether_ntoa(const struct ether_addr *ea, char *buf)
{
static const char hex[] =
{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
const uint8 *octet = ea->octet;
char *p = buf;
int i;
for (i = 0; i < 6; i++, octet++) {
*p++ = hex[(*octet >> 4) & 0xf];
*p++ = hex[*octet & 0xf];
*p++ = ':';
}
*(p-1) = '\0';
return (buf);
}
char *
bcm_ip_ntoa(struct ipv4_addr *ia, char *buf)
{
snprintf(buf, 16, "%d.%d.%d.%d",
ia->addr[0], ia->addr[1], ia->addr[2], ia->addr[3]);
return (buf);
}
char *
bcm_ipv6_ntoa(void *ipv6, char *buf)
{
/* Implementing RFC 5952 Sections 4 + 5 */
/* Not thoroughly tested */
uint16 tmp[8];
uint16 *a = &tmp[0];
char *p = buf;
int i, i_max = -1, cnt = 0, cnt_max = 1;
uint8 *a4 = NULL;
memcpy((uint8 *)&tmp[0], (uint8 *)ipv6, IPV6_ADDR_LEN);
for (i = 0; i < IPV6_ADDR_LEN/2; i++) {
if (a[i]) {
if (cnt > cnt_max) {
cnt_max = cnt;
i_max = i - cnt;
}
cnt = 0;
} else
cnt++;
}
if (cnt > cnt_max) {
cnt_max = cnt;
i_max = i - cnt;
}
if (i_max == 0 &&
/* IPv4-translated: ::ffff:0:a.b.c.d */
((cnt_max == 4 && a[4] == 0xffff && a[5] == 0) ||
/* IPv4-mapped: ::ffff:a.b.c.d */
(cnt_max == 5 && a[5] == 0xffff)))
a4 = (uint8*) (a + 6);
for (i = 0; i < IPV6_ADDR_LEN/2; i++) {
if ((uint8*) (a + i) == a4) {
snprintf(p, 16, ":%u.%u.%u.%u", a4[0], a4[1], a4[2], a4[3]);
break;
} else if (i == i_max) {
*p++ = ':';
i += cnt_max - 1;
p[0] = ':';
p[1] = '\0';
} else {
if (i)
*p++ = ':';
p += snprintf(p, 8, "%x", ntoh16(a[i]));
}
}
return buf;
}
#ifdef BCMDRIVER
void
bcm_mdelay(uint ms)
{
uint i;
for (i = 0; i < ms; i++) {
OSL_DELAY(1000);
}
}
#if defined(DHD_DEBUG)
/* pretty hex print a pkt buffer chain */
void
prpkt(const char *msg, osl_t *osh, void *p0)
{
void *p;
if (msg && (msg[0] != '\0'))
printf("%s:\n", msg);
for (p = p0; p; p = PKTNEXT(osh, p))
prhex(NULL, PKTDATA(osh, p), PKTLEN(osh, p));
}
#endif
/* Takes an Ethernet frame and sets out-of-bound PKTPRIO.
* Also updates the inplace vlan tag if requested.
* For debugging, it returns an indication of what it did.
*/
uint BCMFASTPATH
pktsetprio(void *pkt, bool update_vtag)
{
struct ether_header *eh;
struct ethervlan_header *evh;
uint8 *pktdata;
int priority = 0;
int rc = 0;
pktdata = (uint8 *)PKTDATA(OSH_NULL, pkt);
ASSERT(ISALIGNED((uintptr)pktdata, sizeof(uint16)));
eh = (struct ether_header *) pktdata;
if (eh->ether_type == hton16(ETHER_TYPE_8021Q)) {
uint16 vlan_tag;
int vlan_prio, dscp_prio = 0;
evh = (struct ethervlan_header *)eh;
vlan_tag = ntoh16(evh->vlan_tag);
vlan_prio = (int) (vlan_tag >> VLAN_PRI_SHIFT) & VLAN_PRI_MASK;
if ((evh->ether_type == hton16(ETHER_TYPE_IP)) ||
(evh->ether_type == hton16(ETHER_TYPE_IPV6))) {
uint8 *ip_body = pktdata + sizeof(struct ethervlan_header);
uint8 tos_tc = IP_TOS46(ip_body);
dscp_prio = (int)(tos_tc >> IPV4_TOS_PREC_SHIFT);
}
/* DSCP priority gets precedence over 802.1P (vlan tag) */
if (dscp_prio != 0) {
priority = dscp_prio;
rc |= PKTPRIO_VDSCP;
} else {
priority = vlan_prio;
rc |= PKTPRIO_VLAN;
}
/*
* If the DSCP priority is not the same as the VLAN priority,
* then overwrite the priority field in the vlan tag, with the
* DSCP priority value. This is required for Linux APs because
* the VLAN driver on Linux, overwrites the skb->priority field
* with the priority value in the vlan tag
*/
if (update_vtag && (priority != vlan_prio)) {
vlan_tag &= ~(VLAN_PRI_MASK << VLAN_PRI_SHIFT);
vlan_tag |= (uint16)priority << VLAN_PRI_SHIFT;
evh->vlan_tag = hton16(vlan_tag);
rc |= PKTPRIO_UPD;
}
} else if ((eh->ether_type == hton16(ETHER_TYPE_IP)) ||
(eh->ether_type == hton16(ETHER_TYPE_IPV6))) {
uint8 *ip_body = pktdata + sizeof(struct ether_header);
uint8 tos_tc = IP_TOS46(ip_body);
uint8 dscp = tos_tc >> IPV4_TOS_DSCP_SHIFT;
switch (dscp) {
case DSCP_EF:
priority = PRIO_8021D_VO;
break;
case DSCP_AF31:
case DSCP_AF32:
case DSCP_AF33:
priority = PRIO_8021D_CL;
break;
case DSCP_AF21:
case DSCP_AF22:
case DSCP_AF23:
case DSCP_AF11:
case DSCP_AF12:
case DSCP_AF13:
priority = PRIO_8021D_EE;
break;
default:
#ifndef CUSTOM_DSCP_TO_PRIO_MAPPING
priority = (int)(tos_tc >> IPV4_TOS_PREC_SHIFT);
#else
priority = (int)dscp2priomap[((tos_tc >> IPV4_TOS_DSCP_SHIFT)
& CUST_IPV4_TOS_PREC_MASK)];
#endif
break;
}
rc |= PKTPRIO_DSCP;
}
ASSERT(priority >= 0 && priority <= MAXPRIO);
PKTSETPRIO(pkt, priority);
return (rc | priority);
}
/* Returns TRUE and DSCP if IP header found, FALSE otherwise.
*/
bool BCMFASTPATH
pktgetdscp(uint8 *pktdata, uint pktlen, uint8 *dscp)
{
struct ether_header *eh;
struct ethervlan_header *evh;
uint8 *ip_body;
bool rc = FALSE;
/* minimum length is ether header and IP header */
if (pktlen < sizeof(struct ether_header) + IPV4_MIN_HEADER_LEN)
return FALSE;
eh = (struct ether_header *) pktdata;
if (eh->ether_type == HTON16(ETHER_TYPE_IP)) {
ip_body = pktdata + sizeof(struct ether_header);
*dscp = IP_DSCP46(ip_body);
rc = TRUE;
}
else if (eh->ether_type == HTON16(ETHER_TYPE_8021Q)) {
evh = (struct ethervlan_header *)eh;
/* minimum length is ethervlan header and IP header */
if (pktlen >= sizeof(struct ethervlan_header) + IPV4_MIN_HEADER_LEN &&
evh->ether_type == HTON16(ETHER_TYPE_IP)) {
ip_body = pktdata + sizeof(struct ethervlan_header);
*dscp = IP_DSCP46(ip_body);
rc = TRUE;
}
}
return rc;
}
/* Add to adjust the 802.1x priority */
void
pktset8021xprio(void *pkt, int prio)
{
struct ether_header *eh;
uint8 *pktdata;
if(prio == PKTPRIO(pkt))
return;
pktdata = (uint8 *)PKTDATA(OSH_NULL, pkt);
ASSERT(ISALIGNED((uintptr)pktdata, sizeof(uint16)));
eh = (struct ether_header *) pktdata;
if (eh->ether_type == hton16(ETHER_TYPE_802_1X)) {
ASSERT(prio >= 0 && prio <= MAXPRIO);
PKTSETPRIO(pkt, prio);
}
}
/* The 0.5KB string table is not removed by compiler even though it's unused */
static char bcm_undeferrstr[32];
static const char *bcmerrorstrtable[] = BCMERRSTRINGTABLE;
/* Convert the error codes into related error strings */
const char *
bcmerrorstr(int bcmerror)
{
/* check if someone added a bcmerror code but forgot to add errorstring */
ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(bcmerrorstrtable) - 1));
if (bcmerror > 0 || bcmerror < BCME_LAST) {
snprintf(bcm_undeferrstr, sizeof(bcm_undeferrstr), "Undefined error %d", bcmerror);
return bcm_undeferrstr;
}
ASSERT(strlen(bcmerrorstrtable[-bcmerror]) < BCME_STRLEN);
return bcmerrorstrtable[-bcmerror];
}
/* iovar table lookup */
/* could mandate sorted tables and do a binary search */
const bcm_iovar_t*
bcm_iovar_lookup(const bcm_iovar_t *table, const char *name)
{
const bcm_iovar_t *vi;
const char *lookup_name;
/* skip any ':' delimited option prefixes */
lookup_name = strrchr(name, ':');
if (lookup_name != NULL)
lookup_name++;
else
lookup_name = name;
ASSERT(table != NULL);
for (vi = table; vi->name; vi++) {
if (!strcmp(vi->name, lookup_name))
return vi;
}
/* ran to end of table */
return NULL; /* var name not found */
}
int
bcm_iovar_lencheck(const bcm_iovar_t *vi, void *arg, int len, bool set)
{
int bcmerror = 0;
/* length check on io buf */
switch (vi->type) {
case IOVT_BOOL:
case IOVT_INT8:
case IOVT_INT16:
case IOVT_INT32:
case IOVT_UINT8:
case IOVT_UINT16:
case IOVT_UINT32:
/* all integers are int32 sized args at the ioctl interface */
if (len < (int)sizeof(int)) {
bcmerror = BCME_BUFTOOSHORT;
}
break;
case IOVT_BUFFER:
/* buffer must meet minimum length requirement */
if (len < vi->minlen) {
bcmerror = BCME_BUFTOOSHORT;
}
break;
case IOVT_VOID:
if (!set) {
/* Cannot return nil... */
bcmerror = BCME_UNSUPPORTED;
} else if (len) {
/* Set is an action w/o parameters */
bcmerror = BCME_BUFTOOLONG;
}
break;
default:
/* unknown type for length check in iovar info */
ASSERT(0);
bcmerror = BCME_UNSUPPORTED;
}
return bcmerror;
}
#endif /* BCMDRIVER */
uint8 *
bcm_write_tlv(int type, const void *data, int datalen, uint8 *dst)
{
uint8 *new_dst = dst;
bcm_tlv_t *dst_tlv = (bcm_tlv_t *)dst;
/* dst buffer should always be valid */
ASSERT(dst);
/* data len must be within valid range */
ASSERT((datalen >= 0) && (datalen <= BCM_TLV_MAX_DATA_SIZE));
/* source data buffer pointer should be valid, unless datalen is 0
* meaning no data with this TLV
*/
ASSERT((data != NULL) || (datalen == 0));
/* only do work if the inputs are valid
* - must have a dst to write to AND
* - datalen must be within range AND
* - the source data pointer must be non-NULL if datalen is non-zero
* (this last condition detects datalen > 0 with a NULL data pointer)
*/
if ((dst != NULL) &&
((datalen >= 0) && (datalen <= BCM_TLV_MAX_DATA_SIZE)) &&
((data != NULL) || (datalen == 0))) {
/* write type, len fields */
dst_tlv->id = (uint8)type;
dst_tlv->len = (uint8)datalen;
/* if data is present, copy to the output buffer and update
* pointer to output buffer
*/
if (datalen > 0) {
memcpy(dst_tlv->data, data, datalen);
}
/* update the output destination poitner to point past
* the TLV written
*/
new_dst = dst + BCM_TLV_HDR_SIZE + datalen;
}
return (new_dst);
}
uint8 *
bcm_write_tlv_safe(int type, const void *data, int datalen, uint8 *dst, int dst_maxlen)
{
uint8 *new_dst = dst;
if ((datalen >= 0) && (datalen <= BCM_TLV_MAX_DATA_SIZE)) {
/* if len + tlv hdr len is more than destlen, don't do anything
* just return the buffer untouched
*/
if ((int)(datalen + BCM_TLV_HDR_SIZE) <= dst_maxlen) {
new_dst = bcm_write_tlv(type, data, datalen, dst);
}
}
return (new_dst);
}
uint8 *
bcm_copy_tlv(const void *src, uint8 *dst)
{
uint8 *new_dst = dst;
const bcm_tlv_t *src_tlv = (const bcm_tlv_t *)src;
uint totlen;
ASSERT(dst && src);
if (dst && src) {
totlen = BCM_TLV_HDR_SIZE + src_tlv->len;
memcpy(dst, src_tlv, totlen);
new_dst = dst + totlen;
}
return (new_dst);
}
uint8 *bcm_copy_tlv_safe(const void *src, uint8 *dst, int dst_maxlen)
{
uint8 *new_dst = dst;
const bcm_tlv_t *src_tlv = (const bcm_tlv_t *)src;
ASSERT(src);
if (src) {
if (bcm_valid_tlv(src_tlv, dst_maxlen)) {
new_dst = bcm_copy_tlv(src, dst);
}
}
return (new_dst);
}
#if !defined(BCMROMOFFLOAD_EXCLUDE_BCMUTILS_FUNCS)
/*******************************************************************************
* crc8
*
* Computes a crc8 over the input data using the polynomial:
*
* x^8 + x^7 +x^6 + x^4 + x^2 + 1
*
* The caller provides the initial value (either CRC8_INIT_VALUE
* or the previous returned value) to allow for processing of
* discontiguous blocks of data. When generating the CRC the
* caller is responsible for complementing the final return value
* and inserting it into the byte stream. When checking, a final
* return value of CRC8_GOOD_VALUE indicates a valid CRC.
*
* Reference: Dallas Semiconductor Application Note 27
* Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
* ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
* ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
*
* ****************************************************************************
*/
static const uint8 crc8_table[256] = {
0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
};
#define CRC_INNER_LOOP(n, c, x) \
(c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
uint8
hndcrc8(
uint8 *pdata, /* pointer to array of data to process */
uint nbytes, /* number of input data bytes to process */
uint8 crc /* either CRC8_INIT_VALUE or previous return value */
)
{
/* hard code the crc loop instead of using CRC_INNER_LOOP macro
* to avoid the undefined and unnecessary (uint8 >> 8) operation.
*/
while (nbytes-- > 0)
crc = crc8_table[(crc ^ *pdata++) & 0xff];
return crc;
}
/*******************************************************************************
* crc16
*
* Computes a crc16 over the input data using the polynomial:
*
* x^16 + x^12 +x^5 + 1
*
* The caller provides the initial value (either CRC16_INIT_VALUE
* or the previous returned value) to allow for processing of
* discontiguous blocks of data. When generating the CRC the
* caller is responsible for complementing the final return value
* and inserting it into the byte stream. When checking, a final
* return value of CRC16_GOOD_VALUE indicates a valid CRC.
*
* Reference: Dallas Semiconductor Application Note 27
* Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
* ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
* ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
*
* ****************************************************************************
*/
static const uint16 crc16_table[256] = {
0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
};
uint16
hndcrc16(
uint8 *pdata, /* pointer to array of data to process */
uint nbytes, /* number of input data bytes to process */
uint16 crc /* either CRC16_INIT_VALUE or previous return value */
)
{
while (nbytes-- > 0)
CRC_INNER_LOOP(16, crc, *pdata++);
return crc;
}
static const uint32 crc32_table[256] = {
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
/*
* crc input is CRC32_INIT_VALUE for a fresh start, or previous return value if
* accumulating over multiple pieces.
*/
uint32
hndcrc32(uint8 *pdata, uint nbytes, uint32 crc)
{
uint8 *pend;
pend = pdata + nbytes;
while (pdata < pend)
CRC_INNER_LOOP(32, crc, *pdata++);
return crc;
}
#ifdef notdef
#define CLEN 1499 /* CRC Length */
#define CBUFSIZ (CLEN+4)
#define CNBUFS 5 /* # of bufs */
void
testcrc32(void)
{
uint j, k, l;
uint8 *buf;
uint len[CNBUFS];
uint32 crcr;
uint32 crc32tv[CNBUFS] =
{0xd2cb1faa, 0xd385c8fa, 0xf5b4f3f3, 0x55789e20, 0x00343110};
ASSERT((buf = MALLOC(CBUFSIZ*CNBUFS)) != NULL);
/* step through all possible alignments */
for (l = 0; l <= 4; l++) {
for (j = 0; j < CNBUFS; j++) {
len[j] = CLEN;
for (k = 0; k < len[j]; k++)
*(buf + j*CBUFSIZ + (k+l)) = (j+k) & 0xff;
}
for (j = 0; j < CNBUFS; j++) {
crcr = crc32(buf + j*CBUFSIZ + l, len[j], CRC32_INIT_VALUE);
ASSERT(crcr == crc32tv[j]);
}
}
MFREE(buf, CBUFSIZ*CNBUFS);
return;
}
#endif /* notdef */
/*
* Advance from the current 1-byte tag/1-byte length/variable-length value
* triple, to the next, returning a pointer to the next.
* If the current or next TLV is invalid (does not fit in given buffer length),
* NULL is returned.
* *buflen is not modified if the TLV elt parameter is invalid, or is decremented
* by the TLV parameter's length if it is valid.
*/
bcm_tlv_t *
bcm_next_tlv(bcm_tlv_t *elt, int *buflen)
{
int len;
/* validate current elt */
if (!bcm_valid_tlv(elt, *buflen)) {
return NULL;
}
/* advance to next elt */
len = elt->len;
elt = (bcm_tlv_t*)(elt->data + len);
*buflen -= (TLV_HDR_LEN + len);
/* validate next elt */
if (!bcm_valid_tlv(elt, *buflen)) {
return NULL;
}
return elt;
}
/*
* Traverse a string of 1-byte tag/1-byte length/variable-length value
* triples, returning a pointer to the substring whose first element
* matches tag
*/
bcm_tlv_t *
bcm_parse_tlvs(void *buf, int buflen, uint key)
{
bcm_tlv_t *elt;
int totlen;
elt = (bcm_tlv_t*)buf;
totlen = buflen;
/* find tagged parameter */
while (totlen >= TLV_HDR_LEN) {
int len = elt->len;
/* validate remaining totlen */
if ((elt->id == key) && (totlen >= (int)(len + TLV_HDR_LEN))) {
return (elt);
}
elt = (bcm_tlv_t*)((uint8*)elt + (len + TLV_HDR_LEN));
totlen -= (len + TLV_HDR_LEN);
}
return NULL;
}
/*
* Traverse a string of 1-byte tag/1-byte length/variable-length value
* triples, returning a pointer to the substring whose first element
* matches tag
* return NULL if not found or length field < min_varlen
*/
bcm_tlv_t *
bcm_parse_tlvs_min_bodylen(void *buf, int buflen, uint key, int min_bodylen)
{
bcm_tlv_t * ret = bcm_parse_tlvs(buf, buflen, key);
if (ret == NULL || ret->len < min_bodylen) {
return NULL;
}
return ret;
}
/*
* Traverse a string of 1-byte tag/1-byte length/variable-length value
* triples, returning a pointer to the substring whose first element
* matches tag. Stop parsing when we see an element whose ID is greater
* than the target key.
*/
bcm_tlv_t *
bcm_parse_ordered_tlvs(void *buf, int buflen, uint key)
{
bcm_tlv_t *elt;
int totlen;
elt = (bcm_tlv_t*)buf;
totlen = buflen;
/* find tagged parameter */
while (totlen >= TLV_HDR_LEN) {
uint id = elt->id;
int len = elt->len;
/* Punt if we start seeing IDs > than target key */
if (id > key) {
return (NULL);
}
/* validate remaining totlen */
if ((id == key) && (totlen >= (int)(len + TLV_HDR_LEN))) {
return (elt);
}
elt = (bcm_tlv_t*)((uint8*)elt + (len + TLV_HDR_LEN));
totlen -= (len + TLV_HDR_LEN);
}
return NULL;
}
#endif /* !BCMROMOFFLOAD_EXCLUDE_BCMUTILS_FUNCS */
#if defined(WLMSG_PRHDRS) || defined(WLMSG_PRPKT) || defined(WLMSG_ASSOC) || \
defined(DHD_DEBUG)
int
bcm_format_field(const bcm_bit_desc_ex_t *bd, uint32 flags, char* buf, int len)
{
int i, slen = 0;
uint32 bit, mask;
const char *name;
mask = bd->mask;
if (len < 2 || !buf)
return 0;
buf[0] = '\0';
for (i = 0; (name = bd->bitfield[i].name) != NULL; i++) {
bit = bd->bitfield[i].bit;
if ((flags & mask) == bit) {
if (len > (int)strlen(name)) {
slen = strlen(name);
strncpy(buf, name, slen+1);
}
break;
}
}
return slen;
}
int
bcm_format_flags(const bcm_bit_desc_t *bd, uint32 flags, char* buf, int len)
{
int i;
char* p = buf;
char hexstr[16];
int slen = 0, nlen = 0;
uint32 bit;
const char* name;
if (len < 2 || !buf)
return 0;
buf[0] = '\0';
for (i = 0; flags != 0; i++) {
bit = bd[i].bit;
name = bd[i].name;
if (bit == 0 && flags != 0) {
/* print any unnamed bits */
snprintf(hexstr, 16, "0x%X", flags);
name = hexstr;
flags = 0; /* exit loop */
} else if ((flags & bit) == 0)
continue;
flags &= ~bit;
nlen = strlen(name);
slen += nlen;
/* count btwn flag space */
if (flags != 0)
slen += 1;
/* need NULL char as well */
if (len <= slen)
break;
/* copy NULL char but don't count it */
strncpy(p, name, nlen + 1);
p += nlen;
/* copy btwn flag space and NULL char */
if (flags != 0)
p += snprintf(p, 2, " ");
}
/* indicate the str was too short */
if (flags != 0) {
if (len < 2)
p -= 2 - len; /* overwrite last char */
p += snprintf(p, 2, ">");
}
return (int)(p - buf);
}
#endif
/* print bytes formatted as hex to a string. return the resulting string length */
int
bcm_format_hex(char *str, const void *bytes, int len)
{
int i;
char *p = str;
const uint8 *src = (const uint8*)bytes;
for (i = 0; i < len; i++) {
p += snprintf(p, 3, "%02X", *src);
src++;
}
return (int)(p - str);
}
/* pretty hex print a contiguous buffer */
void
prhex(const char *msg, uchar *buf, uint nbytes)
{
char line[128], *p;
int len = sizeof(line);
int nchar;
uint i;
if (msg && (msg[0] != '\0'))
printf("%s:\n", msg);
p = line;
for (i = 0; i < nbytes; i++) {
if (i % 16 == 0) {
nchar = snprintf(p, len, " %04d: ", i); /* line prefix */
p += nchar;
len -= nchar;
}
if (len > 0) {
nchar = snprintf(p, len, "%02x ", buf[i]);
p += nchar;
len -= nchar;
}
if (i % 16 == 15) {
printf("%s\n", line); /* flush line */
p = line;
len = sizeof(line);
}
}
/* flush last partial line */
if (p != line)
printf("%s\n", line);
}
static const char *crypto_algo_names[] = {
"NONE",
"WEP1",
"TKIP",
"WEP128",
"AES_CCM",
"AES_OCB_MSDU",
"AES_OCB_MPDU",
#ifdef BCMCCX
"CKIP",
"CKIP_MMH",
"WEP_MMH",
"NALG",
#else
"NALG",
"UNDEF",
"UNDEF",
"UNDEF",
#endif /* BCMCCX */
"WAPI",
"PMK",
"BIP",
"AES_GCM",
"AES_CCM256",
"AES_GCM256",
"BIP_CMAC256",
"BIP_GMAC",
"BIP_GMAC256",
"UNDEF"
};
const char *
bcm_crypto_algo_name(uint algo)
{
return (algo < ARRAYSIZE(crypto_algo_names)) ? crypto_algo_names[algo] : "ERR";
}
char *
bcm_chipname(uint chipid, char *buf, uint len)
{
const char *fmt;
fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x";
snprintf(buf, len, fmt, chipid);
return buf;
}
/* Produce a human-readable string for boardrev */
char *
bcm_brev_str(uint32 brev, char *buf)
{
if (brev < 0x100)
snprintf(buf, 8, "%d.%d", (brev & 0xf0) >> 4, brev & 0xf);
else
snprintf(buf, 8, "%c%03x", ((brev & 0xf000) == 0x1000) ? 'P' : 'A', brev & 0xfff);
return (buf);
}
#define BUFSIZE_TODUMP_ATONCE 512 /* Buffer size */
/* dump large strings to console */
void
printbig(char *buf)
{
uint len, max_len;
char c;
len = (uint)strlen(buf);
max_len = BUFSIZE_TODUMP_ATONCE;
while (len > max_len) {
c = buf[max_len];
buf[max_len] = '\0';
printf("%s", buf);
buf[max_len] = c;
buf += max_len;
len -= max_len;
}
/* print the remaining string */
printf("%s\n", buf);
return;
}
/* routine to dump fields in a fileddesc structure */
uint
bcmdumpfields(bcmutl_rdreg_rtn read_rtn, void *arg0, uint arg1, struct fielddesc *fielddesc_array,
char *buf, uint32 bufsize)
{
uint filled_len;
int len;
struct fielddesc *cur_ptr;
filled_len = 0;
cur_ptr = fielddesc_array;
while (bufsize > 1) {
if (cur_ptr->nameandfmt == NULL)
break;
len = snprintf(buf, bufsize, cur_ptr->nameandfmt,
read_rtn(arg0, arg1, cur_ptr->offset));
/* check for snprintf overflow or error */
if (len < 0 || (uint32)len >= bufsize)
len = bufsize - 1;
buf += len;
bufsize -= len;
filled_len += len;
cur_ptr++;
}
return filled_len;
}
uint
bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
{
uint len;
len = (uint)strlen(name) + 1;
if ((len + datalen) > buflen)
return 0;
strncpy(buf, name, buflen);
/* append data onto the end of the name string */
memcpy(&buf[len], data, datalen);
len += datalen;
return len;
}
/* Quarter dBm units to mW
* Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153
* Table is offset so the last entry is largest mW value that fits in
* a uint16.
*/
#define QDBM_OFFSET 153 /* Offset for first entry */
#define QDBM_TABLE_LEN 40 /* Table size */
/* Smallest mW value that will round up to the first table entry, QDBM_OFFSET.
* Value is ( mW(QDBM_OFFSET - 1) + mW(QDBM_OFFSET) ) / 2
*/
#define QDBM_TABLE_LOW_BOUND 6493 /* Low bound */
/* Largest mW value that will round down to the last table entry,
* QDBM_OFFSET + QDBM_TABLE_LEN-1.
* Value is ( mW(QDBM_OFFSET + QDBM_TABLE_LEN - 1) + mW(QDBM_OFFSET + QDBM_TABLE_LEN) ) / 2.
*/
#define QDBM_TABLE_HIGH_BOUND 64938 /* High bound */
static const uint16 nqdBm_to_mW_map[QDBM_TABLE_LEN] = {
/* qdBm: +0 +1 +2 +3 +4 +5 +6 +7 */
/* 153: */ 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000,
/* 161: */ 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849,
/* 169: */ 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119,
/* 177: */ 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811,
/* 185: */ 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096
};
uint16
bcm_qdbm_to_mw(uint8 qdbm)
{
uint factor = 1;
int idx = qdbm - QDBM_OFFSET;
if (idx >= QDBM_TABLE_LEN) {
/* clamp to max uint16 mW value */
return 0xFFFF;
}
/* scale the qdBm index up to the range of the table 0-40
* where an offset of 40 qdBm equals a factor of 10 mW.
*/
while (idx < 0) {
idx += 40;
factor *= 10;
}
/* return the mW value scaled down to the correct factor of 10,
* adding in factor/2 to get proper rounding.
*/
return ((nqdBm_to_mW_map[idx] + factor/2) / factor);
}
uint8
bcm_mw_to_qdbm(uint16 mw)
{
uint8 qdbm;
int offset;
uint mw_uint = mw;
uint boundary;
/* handle boundary case */
if (mw_uint <= 1)
return 0;
offset = QDBM_OFFSET;
/* move mw into the range of the table */
while (mw_uint < QDBM_TABLE_LOW_BOUND) {
mw_uint *= 10;
offset -= 40;
}
for (qdbm = 0; qdbm < QDBM_TABLE_LEN-1; qdbm++) {
boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm+1] -
nqdBm_to_mW_map[qdbm])/2;
if (mw_uint < boundary) break;
}
qdbm += (uint8)offset;
return (qdbm);
}
uint
bcm_bitcount(uint8 *bitmap, uint length)
{
uint bitcount = 0, i;
uint8 tmp;
for (i = 0; i < length; i++) {
tmp = bitmap[i];
while (tmp) {
bitcount++;
tmp &= (tmp - 1);
}
}
return bitcount;
}
#ifdef BCMDRIVER
/* Initialization of bcmstrbuf structure */
void
bcm_binit(struct bcmstrbuf *b, char *buf, uint size)
{
b->origsize = b->size = size;
b->origbuf = b->buf = buf;
}
/* Buffer sprintf wrapper to guard against buffer overflow */
int
bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...)
{
va_list ap;
int r;
va_start(ap, fmt);
r = vsnprintf(b->buf, b->size, fmt, ap);
/* Non Ansi C99 compliant returns -1,
* Ansi compliant return r >= b->size,
* bcmstdlib returns 0, handle all
*/
/* r == 0 is also the case when strlen(fmt) is zero.
* typically the case when "" is passed as argument.
*/
if ((r == -1) || (r >= (int)b->size)) {
b->size = 0;
} else {
b->size -= r;
b->buf += r;
}
va_end(ap);
return r;
}
void
bcm_bprhex(struct bcmstrbuf *b, const char *msg, bool newline, uint8 *buf, int len)
{
int i;
if (msg != NULL && msg[0] != '\0')
bcm_bprintf(b, "%s", msg);
for (i = 0; i < len; i ++)
bcm_bprintf(b, "%02X", buf[i]);
if (newline)
bcm_bprintf(b, "\n");
}
void
bcm_inc_bytes(uchar *num, int num_bytes, uint8 amount)
{
int i;
for (i = 0; i < num_bytes; i++) {
num[i] += amount;
if (num[i] >= amount)
break;
amount = 1;
}
}
int
bcm_cmp_bytes(const uchar *arg1, const uchar *arg2, uint8 nbytes)
{
int i;
for (i = nbytes - 1; i >= 0; i--) {
if (arg1[i] != arg2[i])
return (arg1[i] - arg2[i]);
}
return 0;
}
void
bcm_print_bytes(const char *name, const uchar *data, int len)
{
int i;
int per_line = 0;
printf("%s: %d \n", name ? name : "", len);
for (i = 0; i < len; i++) {
printf("%02x ", *data++);
per_line++;
if (per_line == 16) {
per_line = 0;
printf("\n");
}
}
printf("\n");
}
/* Look for vendor-specific IE with specified OUI and optional type */
bcm_tlv_t *
bcm_find_vendor_ie(void *tlvs, int tlvs_len, const char *voui, uint8 *type, int type_len)
{
bcm_tlv_t *ie;
uint8 ie_len;
ie = (bcm_tlv_t*)tlvs;
/* make sure we are looking at a valid IE */
if (ie == NULL || !bcm_valid_tlv(ie, tlvs_len)) {
return NULL;
}
/* Walk through the IEs looking for an OUI match */
do {
ie_len = ie->len;
if ((ie->id == DOT11_MNG_PROPR_ID) &&
(ie_len >= (DOT11_OUI_LEN + type_len)) &&
!bcmp(ie->data, voui, DOT11_OUI_LEN))
{
/* compare optional type */
if (type_len == 0 ||
!bcmp(&ie->data[DOT11_OUI_LEN], type, type_len)) {
return (ie); /* a match */
}
}
} while ((ie = bcm_next_tlv(ie, &tlvs_len)) != NULL);
return NULL;
}
#if defined(WLTINYDUMP) || defined(WLMSG_INFORM) || defined(WLMSG_ASSOC) || \
defined(WLMSG_PRPKT) || defined(WLMSG_WSEC)
#define SSID_FMT_BUF_LEN ((4 * DOT11_MAX_SSID_LEN) + 1)
int
bcm_format_ssid(char* buf, const uchar ssid[], uint ssid_len)
{
uint i, c;
char *p = buf;
char *endp = buf + SSID_FMT_BUF_LEN;
if (ssid_len > DOT11_MAX_SSID_LEN) ssid_len = DOT11_MAX_SSID_LEN;
for (i = 0; i < ssid_len; i++) {
c = (uint)ssid[i];
if (c == '\\') {
*p++ = '\\';
*p++ = '\\';
} else if (bcm_isprint((uchar)c)) {
*p++ = (char)c;
} else {
p += snprintf(p, (endp - p), "\\x%02X", c);
}
}
*p = '\0';
ASSERT(p < endp);
return (int)(p - buf);
}
#endif
#endif /* BCMDRIVER */
/*
* ProcessVars:Takes a buffer of "<var>=<value>\n" lines read from a file and ending in a NUL.
* also accepts nvram files which are already in the format of <var1>=<value>\0\<var2>=<value2>\0
* Removes carriage returns, empty lines, comment lines, and converts newlines to NULs.
* Shortens buffer as needed and pads with NULs. End of buffer is marked by two NULs.
*/
unsigned int
process_nvram_vars(char *varbuf, unsigned int len)
{
char *dp;
bool findNewline;
int column;
unsigned int buf_len, n;
unsigned int pad = 0;
dp = varbuf;
findNewline = FALSE;
column = 0;
// terence 20130914: print out NVRAM version
if (varbuf[0] == '#') {
printf("NVRAM version: ");
for (n=1; n<len; n++) {
if (varbuf[n] == '\n')
break;
printk("%c", varbuf[n]);
}
printk("\n");
}
for (n = 0; n < len; n++) {
if (varbuf[n] == '\r')
continue;
if (findNewline && varbuf[n] != '\n')
continue;
findNewline = FALSE;
if (varbuf[n] == '#') {
findNewline = TRUE;
continue;
}
if (varbuf[n] == '\n') {
if (column == 0)
continue;
*dp++ = 0;
column = 0;
continue;
}
*dp++ = varbuf[n];
column++;
}
buf_len = (unsigned int)(dp - varbuf);
if (buf_len % 4) {
pad = 4 - buf_len % 4;
if (pad && (buf_len + pad <= len)) {
buf_len += pad;
}
}
while (dp < varbuf + n)
*dp++ = 0;
return buf_len;
}
/* calculate a * b + c */
void
bcm_uint64_multiple_add(uint32* r_high, uint32* r_low, uint32 a, uint32 b, uint32 c)
{
#define FORMALIZE(var) {cc += (var & 0x80000000) ? 1 : 0; var &= 0x7fffffff;}
uint32 r1, r0;
uint32 a1, a0, b1, b0, t, cc = 0;
a1 = a >> 16;
a0 = a & 0xffff;
b1 = b >> 16;
b0 = b & 0xffff;
r0 = a0 * b0;
FORMALIZE(r0);
t = (a1 * b0) << 16;
FORMALIZE(t);
r0 += t;
FORMALIZE(r0);
t = (a0 * b1) << 16;
FORMALIZE(t);
r0 += t;
FORMALIZE(r0);
FORMALIZE(c);
r0 += c;
FORMALIZE(r0);
r0 |= (cc % 2) ? 0x80000000 : 0;
r1 = a1 * b1 + ((a1 * b0) >> 16) + ((b1 * a0) >> 16) + (cc / 2);
*r_high = r1;
*r_low = r0;
}
/* calculate a / b */
void
bcm_uint64_divide(uint32* r, uint32 a_high, uint32 a_low, uint32 b)
{
uint32 a1 = a_high, a0 = a_low, r0 = 0;
if (b < 2)
return;
while (a1 != 0) {
r0 += (0xffffffff / b) * a1;
bcm_uint64_multiple_add(&a1, &a0, ((0xffffffff % b) + 1) % b, a1, a0);
}
r0 += a0 / b;
*r = r0;
}
#ifndef setbit /* As in the header file */
#ifdef BCMUTILS_BIT_MACROS_USE_FUNCS
/* Set bit in byte array. */
void
setbit(void *array, uint bit)
{
((uint8 *)array)[bit / NBBY] |= 1 << (bit % NBBY);
}
/* Clear bit in byte array. */
void
clrbit(void *array, uint bit)
{
((uint8 *)array)[bit / NBBY] &= ~(1 << (bit % NBBY));
}
/* Test if bit is set in byte array. */
bool
isset(const void *array, uint bit)
{
return (((const uint8 *)array)[bit / NBBY] & (1 << (bit % NBBY)));
}
/* Test if bit is clear in byte array. */
bool
isclr(const void *array, uint bit)
{
return ((((const uint8 *)array)[bit / NBBY] & (1 << (bit % NBBY))) == 0);
}
#endif /* BCMUTILS_BIT_MACROS_USE_FUNCS */
#endif /* setbit */
void
set_bitrange(void *array, uint start, uint end, uint maxbit)
{
uint startbyte = start/NBBY;
uint endbyte = end/NBBY;
uint i, startbytelastbit, endbytestartbit;
if (end >= start) {
if (endbyte - startbyte > 1)
{
startbytelastbit = (startbyte+1)*NBBY - 1;
endbytestartbit = endbyte*NBBY;
for (i = startbyte+1; i < endbyte; i++)
((uint8 *)array)[i] = 0xFF;
for (i = start; i <= startbytelastbit; i++)
setbit(array, i);
for (i = endbytestartbit; i <= end; i++)
setbit(array, i);
} else {
for (i = start; i <= end; i++)
setbit(array, i);
}
}
else {
set_bitrange(array, start, maxbit, maxbit);
set_bitrange(array, 0, end, maxbit);
}
}
void
bcm_bitprint32(const uint32 u32)
{
int i;
for (i = NBITS(uint32) - 1; i >= 0; i--) {
isbitset(u32, i) ? printf("1") : printf("0");
if ((i % NBBY) == 0) printf(" ");
}
printf("\n");
}
/* calculate checksum for ip header, tcp / udp header / data */
uint16
bcm_ip_cksum(uint8 *buf, uint32 len, uint32 sum)
{
while (len > 1) {
sum += (buf[0] << 8) | buf[1];
buf += 2;
len -= 2;
}
if (len > 0) {
sum += (*buf) << 8;
}
while (sum >> 16) {
sum = (sum & 0xffff) + (sum >> 16);
}
return ((uint16)~sum);
}
#ifdef BCMDRIVER
/*
* Hierarchical Multiword bitmap based small id allocator.
*
* Multilevel hierarchy bitmap. (maximum 2 levels)
* First hierarchy uses a multiword bitmap to identify 32bit words in the
* second hierarchy that have at least a single bit set. Each bit in a word of
* the second hierarchy represents a unique ID that may be allocated.
*
* BCM_MWBMAP_ITEMS_MAX: Maximum number of IDs managed.
* BCM_MWBMAP_BITS_WORD: Number of bits in a bitmap word word
* BCM_MWBMAP_WORDS_MAX: Maximum number of bitmap words needed for free IDs.
* BCM_MWBMAP_WDMAP_MAX: Maximum number of bitmap wordss identifying first non
* non-zero bitmap word carrying at least one free ID.
* BCM_MWBMAP_SHIFT_OP: Used in MOD, DIV and MUL operations.
* BCM_MWBMAP_INVALID_IDX: Value ~0U is treated as an invalid ID
*
* Design Notes:
* BCM_MWBMAP_USE_CNTSETBITS trades CPU for memory. A runtime count of how many
* bits are computed each time on allocation and deallocation, requiring 4
* array indexed access and 3 arithmetic operations. When not defined, a runtime
* count of set bits state is maintained. Upto 32 Bytes per 1024 IDs is needed.
* In a 4K max ID allocator, up to 128Bytes are hence used per instantiation.
* In a memory limited system e.g. dongle builds, a CPU for memory tradeoff may
* be used by defining BCM_MWBMAP_USE_CNTSETBITS.
*
* Note: wd_bitmap[] is statically declared and is not ROM friendly ... array
* size is fixed. No intention to support larger than 4K indice allocation. ID
* allocators for ranges smaller than 4K will have a wastage of only 12Bytes
* with savings in not having to use an indirect access, had it been dynamically
* allocated.
*/
#define BCM_MWBMAP_ITEMS_MAX (4 * 1024) /* May increase to 16K */
#define BCM_MWBMAP_BITS_WORD (NBITS(uint32))
#define BCM_MWBMAP_WORDS_MAX (BCM_MWBMAP_ITEMS_MAX / BCM_MWBMAP_BITS_WORD)
#define BCM_MWBMAP_WDMAP_MAX (BCM_MWBMAP_WORDS_MAX / BCM_MWBMAP_BITS_WORD)
#define BCM_MWBMAP_SHIFT_OP (5)
#define BCM_MWBMAP_MODOP(ix) ((ix) & (BCM_MWBMAP_BITS_WORD - 1))
#define BCM_MWBMAP_DIVOP(ix) ((ix) >> BCM_MWBMAP_SHIFT_OP)
#define BCM_MWBMAP_MULOP(ix) ((ix) << BCM_MWBMAP_SHIFT_OP)
/* Redefine PTR() and/or HDL() conversion to invoke audit for debugging */
#define BCM_MWBMAP_PTR(hdl) ((struct bcm_mwbmap *)(hdl))
#define BCM_MWBMAP_HDL(ptr) ((void *)(ptr))
#if defined(BCM_MWBMAP_DEBUG)
#define BCM_MWBMAP_AUDIT(mwb) \
do { \
ASSERT((mwb != NULL) && \
(((struct bcm_mwbmap *)(mwb))->magic == (void *)(mwb))); \
bcm_mwbmap_audit(mwb); \
} while (0)
#define MWBMAP_ASSERT(exp) ASSERT(exp)
#define MWBMAP_DBG(x) printf x
#else /* !BCM_MWBMAP_DEBUG */
#define BCM_MWBMAP_AUDIT(mwb) do {} while (0)
#define MWBMAP_ASSERT(exp) do {} while (0)
#define MWBMAP_DBG(x)
#endif /* !BCM_MWBMAP_DEBUG */
typedef struct bcm_mwbmap { /* Hierarchical multiword bitmap allocator */
uint16 wmaps; /* Total number of words in free wd bitmap */
uint16 imaps; /* Total number of words in free id bitmap */
int16 ifree; /* Count of free indices. Used only in audits */
uint16 total; /* Total indices managed by multiword bitmap */
void * magic; /* Audit handle parameter from user */
uint32 wd_bitmap[BCM_MWBMAP_WDMAP_MAX]; /* 1st level bitmap of */
#if !defined(BCM_MWBMAP_USE_CNTSETBITS)
int8 wd_count[BCM_MWBMAP_WORDS_MAX]; /* free id running count, 1st lvl */
#endif /* ! BCM_MWBMAP_USE_CNTSETBITS */
uint32 id_bitmap[0]; /* Second level bitmap */
} bcm_mwbmap_t;
/* Incarnate a hierarchical multiword bitmap based small index allocator. */
struct bcm_mwbmap *
bcm_mwbmap_init(osl_t *osh, uint32 items_max)
{
struct bcm_mwbmap * mwbmap_p;
uint32 wordix, size, words, extra;
/* Implementation Constraint: Uses 32bit word bitmap */
MWBMAP_ASSERT(BCM_MWBMAP_BITS_WORD == 32U);
MWBMAP_ASSERT(BCM_MWBMAP_SHIFT_OP == 5U);
MWBMAP_ASSERT(ISPOWEROF2(BCM_MWBMAP_ITEMS_MAX));
MWBMAP_ASSERT((BCM_MWBMAP_ITEMS_MAX % BCM_MWBMAP_BITS_WORD) == 0U);
ASSERT(items_max <= BCM_MWBMAP_ITEMS_MAX);
/* Determine the number of words needed in the multiword bitmap */
extra = BCM_MWBMAP_MODOP(items_max);
words = BCM_MWBMAP_DIVOP(items_max) + ((extra != 0U) ? 1U : 0U);
/* Allocate runtime state of multiword bitmap */
/* Note: wd_count[] or wd_bitmap[] are not dynamically allocated */
size = sizeof(bcm_mwbmap_t) + (sizeof(uint32) * words);
mwbmap_p = (bcm_mwbmap_t *)MALLOC(osh, size);
if (mwbmap_p == (bcm_mwbmap_t *)NULL) {
ASSERT(0);
goto error1;
}
memset(mwbmap_p, 0, size);
/* Initialize runtime multiword bitmap state */
mwbmap_p->imaps = (uint16)words;
mwbmap_p->ifree = (int16)items_max;
mwbmap_p->total = (uint16)items_max;
/* Setup magic, for use in audit of handle */
mwbmap_p->magic = BCM_MWBMAP_HDL(mwbmap_p);
/* Setup the second level bitmap of free indices */
/* Mark all indices as available */
for (wordix = 0U; wordix < mwbmap_p->imaps; wordix++) {
mwbmap_p->id_bitmap[wordix] = (uint32)(~0U);
#if !defined(BCM_MWBMAP_USE_CNTSETBITS)
mwbmap_p->wd_count[wordix] = BCM_MWBMAP_BITS_WORD;
#endif /* ! BCM_MWBMAP_USE_CNTSETBITS */
}
/* Ensure that extra indices are tagged as un-available */
if (extra) { /* fixup the free ids in last bitmap and wd_count */
uint32 * bmap_p = &mwbmap_p->id_bitmap[mwbmap_p->imaps - 1];
*bmap_p ^= (uint32)(~0U << extra); /* fixup bitmap */
#if !defined(BCM_MWBMAP_USE_CNTSETBITS)
mwbmap_p->wd_count[mwbmap_p->imaps - 1] = (int8)extra; /* fixup count */
#endif /* ! BCM_MWBMAP_USE_CNTSETBITS */
}
/* Setup the first level bitmap hierarchy */
extra = BCM_MWBMAP_MODOP(mwbmap_p->imaps);
words = BCM_MWBMAP_DIVOP(mwbmap_p->imaps) + ((extra != 0U) ? 1U : 0U);
mwbmap_p->wmaps = (uint16)words;
for (wordix = 0U; wordix < mwbmap_p->wmaps; wordix++)
mwbmap_p->wd_bitmap[wordix] = (uint32)(~0U);
if (extra) {
uint32 * bmap_p = &mwbmap_p->wd_bitmap[mwbmap_p->wmaps - 1];
*bmap_p ^= (uint32)(~0U << extra); /* fixup bitmap */
}
return mwbmap_p;
error1:
return BCM_MWBMAP_INVALID_HDL;
}
/* Release resources used by multiword bitmap based small index allocator. */
void
bcm_mwbmap_fini(osl_t * osh, struct bcm_mwbmap * mwbmap_hdl)
{
bcm_mwbmap_t * mwbmap_p;
BCM_MWBMAP_AUDIT(mwbmap_hdl);
mwbmap_p = BCM_MWBMAP_PTR(mwbmap_hdl);
MFREE(osh, mwbmap_p, sizeof(struct bcm_mwbmap)
+ (sizeof(uint32) * mwbmap_p->imaps));
return;
}
/* Allocate a unique small index using a multiword bitmap index allocator. */
uint32 BCMFASTPATH
bcm_mwbmap_alloc(struct bcm_mwbmap * mwbmap_hdl)
{
bcm_mwbmap_t * mwbmap_p;
uint32 wordix, bitmap;
BCM_MWBMAP_AUDIT(mwbmap_hdl);
mwbmap_p = BCM_MWBMAP_PTR(mwbmap_hdl);
/* Start with the first hierarchy */
for (wordix = 0; wordix < mwbmap_p->wmaps; ++wordix) {
bitmap = mwbmap_p->wd_bitmap[wordix]; /* get the word bitmap */
if (bitmap != 0U) {
uint32 count, bitix, *bitmap_p;
bitmap_p = &mwbmap_p->wd_bitmap[wordix];
/* clear all except trailing 1 */
bitmap = (uint32)(((int)(bitmap)) & (-((int)(bitmap))));
MWBMAP_ASSERT(C_bcm_count_leading_zeros(bitmap) ==
bcm_count_leading_zeros(bitmap));
bitix = (BCM_MWBMAP_BITS_WORD - 1)
- bcm_count_leading_zeros(bitmap); /* use asm clz */
wordix = BCM_MWBMAP_MULOP(wordix) + bitix;
/* Clear bit if wd count is 0, without conditional branch */
#if defined(BCM_MWBMAP_USE_CNTSETBITS)
count = bcm_cntsetbits(mwbmap_p->id_bitmap[wordix]) - 1;
#else /* ! BCM_MWBMAP_USE_CNTSETBITS */
mwbmap_p->wd_count[wordix]--;
count = mwbmap_p->wd_count[wordix];
MWBMAP_ASSERT(count ==
(bcm_cntsetbits(mwbmap_p->id_bitmap[wordix]) - 1));
#endif /* ! BCM_MWBMAP_USE_CNTSETBITS */
MWBMAP_ASSERT(count >= 0);
/* clear wd_bitmap bit if id_map count is 0 */
bitmap = (count == 0) << bitix;
MWBMAP_DBG((
"Lvl1: bitix<%02u> wordix<%02u>: %08x ^ %08x = %08x wfree %d",
bitix, wordix, *bitmap_p, bitmap, (*bitmap_p) ^ bitmap, count));
*bitmap_p ^= bitmap;
/* Use bitix in the second hierarchy */
bitmap_p = &mwbmap_p->id_bitmap[wordix];
bitmap = mwbmap_p->id_bitmap[wordix]; /* get the id bitmap */
MWBMAP_ASSERT(bitmap != 0U);
/* clear all except trailing 1 */
bitmap = (uint32)(((int)(bitmap)) & (-((int)(bitmap))));
MWBMAP_ASSERT(C_bcm_count_leading_zeros(bitmap) ==
bcm_count_leading_zeros(bitmap));
bitix = BCM_MWBMAP_MULOP(wordix)
+ (BCM_MWBMAP_BITS_WORD - 1)
- bcm_count_leading_zeros(bitmap); /* use asm clz */
mwbmap_p->ifree--; /* decrement system wide free count */
MWBMAP_ASSERT(mwbmap_p->ifree >= 0);
MWBMAP_DBG((
"Lvl2: bitix<%02u> wordix<%02u>: %08x ^ %08x = %08x ifree %d",
bitix, wordix, *bitmap_p, bitmap, (*bitmap_p) ^ bitmap,
mwbmap_p->ifree));
*bitmap_p ^= bitmap; /* mark as allocated = 1b0 */
return bitix;
}
}
ASSERT(mwbmap_p->ifree == 0);
return BCM_MWBMAP_INVALID_IDX;
}
/* Force an index at a specified position to be in use */
void
bcm_mwbmap_force(struct bcm_mwbmap * mwbmap_hdl, uint32 bitix)
{
bcm_mwbmap_t * mwbmap_p;
uint32 count, wordix, bitmap, *bitmap_p;
BCM_MWBMAP_AUDIT(mwbmap_hdl);
mwbmap_p = BCM_MWBMAP_PTR(mwbmap_hdl);
ASSERT(bitix < mwbmap_p->total);
/* Start with second hierarchy */
wordix = BCM_MWBMAP_DIVOP(bitix);
bitmap = (uint32)(1U << BCM_MWBMAP_MODOP(bitix));
bitmap_p = &mwbmap_p->id_bitmap[wordix];
ASSERT((*bitmap_p & bitmap) == bitmap);
mwbmap_p->ifree--; /* update free count */
ASSERT(mwbmap_p->ifree >= 0);
MWBMAP_DBG(("Lvl2: bitix<%u> wordix<%u>: %08x ^ %08x = %08x ifree %d",
bitix, wordix, *bitmap_p, bitmap, (*bitmap_p) ^ bitmap,
mwbmap_p->ifree));
*bitmap_p ^= bitmap; /* mark as in use */
/* Update first hierarchy */
bitix = wordix;
wordix = BCM_MWBMAP_DIVOP(bitix);
bitmap_p = &mwbmap_p->wd_bitmap[wordix];
#if defined(BCM_MWBMAP_USE_CNTSETBITS)
count = bcm_cntsetbits(mwbmap_p->id_bitmap[bitix]);
#else /* ! BCM_MWBMAP_USE_CNTSETBITS */
mwbmap_p->wd_count[bitix]--;
count = mwbmap_p->wd_count[bitix];
MWBMAP_ASSERT(count == bcm_cntsetbits(mwbmap_p->id_bitmap[bitix]));
#endif /* ! BCM_MWBMAP_USE_CNTSETBITS */
MWBMAP_ASSERT(count >= 0);
bitmap = (count == 0) << BCM_MWBMAP_MODOP(bitix);
MWBMAP_DBG(("Lvl1: bitix<%02lu> wordix<%02u>: %08x ^ %08x = %08x wfree %d",
BCM_MWBMAP_MODOP(bitix), wordix, *bitmap_p, bitmap,
(*bitmap_p) ^ bitmap, count));
*bitmap_p ^= bitmap; /* mark as in use */
return;
}
/* Free a previously allocated index back into the multiword bitmap allocator */
void BCMFASTPATH
bcm_mwbmap_free(struct bcm_mwbmap * mwbmap_hdl, uint32 bitix)
{
bcm_mwbmap_t * mwbmap_p;
uint32 wordix, bitmap, *bitmap_p;
BCM_MWBMAP_AUDIT(mwbmap_hdl);
mwbmap_p = BCM_MWBMAP_PTR(mwbmap_hdl);
ASSERT(bitix < mwbmap_p->total);
/* Start with second level hierarchy */
wordix = BCM_MWBMAP_DIVOP(bitix);
bitmap = (1U << BCM_MWBMAP_MODOP(bitix));
bitmap_p = &mwbmap_p->id_bitmap[wordix];
ASSERT((*bitmap_p & bitmap) == 0U); /* ASSERT not a double free */
mwbmap_p->ifree++; /* update free count */
ASSERT(mwbmap_p->ifree <= mwbmap_p->total);
MWBMAP_DBG(("Lvl2: bitix<%02u> wordix<%02u>: %08x | %08x = %08x ifree %d",
bitix, wordix, *bitmap_p, bitmap, (*bitmap_p) | bitmap,
mwbmap_p->ifree));
*bitmap_p |= bitmap; /* mark as available */
/* Now update first level hierarchy */
bitix = wordix;
wordix = BCM_MWBMAP_DIVOP(bitix); /* first level's word index */
bitmap = (1U << BCM_MWBMAP_MODOP(bitix));
bitmap_p = &mwbmap_p->wd_bitmap[wordix];
#if !defined(BCM_MWBMAP_USE_CNTSETBITS)
mwbmap_p->wd_count[bitix]++;
#endif
#if defined(BCM_MWBMAP_DEBUG)
{
uint32 count;
#if defined(BCM_MWBMAP_USE_CNTSETBITS)
count = bcm_cntsetbits(mwbmap_p->id_bitmap[bitix]);
#else /* ! BCM_MWBMAP_USE_CNTSETBITS */
count = mwbmap_p->wd_count[bitix];
MWBMAP_ASSERT(count == bcm_cntsetbits(mwbmap_p->id_bitmap[bitix]));
#endif /* ! BCM_MWBMAP_USE_CNTSETBITS */
MWBMAP_ASSERT(count <= BCM_MWBMAP_BITS_WORD);
MWBMAP_DBG(("Lvl1: bitix<%02u> wordix<%02u>: %08x | %08x = %08x wfree %d",
bitix, wordix, *bitmap_p, bitmap, (*bitmap_p) | bitmap, count));
}
#endif /* BCM_MWBMAP_DEBUG */
*bitmap_p |= bitmap;
return;
}
/* Fetch the toal number of free indices in the multiword bitmap allocator */
uint32
bcm_mwbmap_free_cnt(struct bcm_mwbmap * mwbmap_hdl)
{
bcm_mwbmap_t * mwbmap_p;
BCM_MWBMAP_AUDIT(mwbmap_hdl);
mwbmap_p = BCM_MWBMAP_PTR(mwbmap_hdl);
ASSERT(mwbmap_p->ifree >= 0);
return mwbmap_p->ifree;
}
/* Determine whether an index is inuse or free */
bool
bcm_mwbmap_isfree(struct bcm_mwbmap * mwbmap_hdl, uint32 bitix)
{
bcm_mwbmap_t * mwbmap_p;
uint32 wordix, bitmap;
BCM_MWBMAP_AUDIT(mwbmap_hdl);
mwbmap_p = BCM_MWBMAP_PTR(mwbmap_hdl);
ASSERT(bitix < mwbmap_p->total);
wordix = BCM_MWBMAP_DIVOP(bitix);
bitmap = (1U << BCM_MWBMAP_MODOP(bitix));
return ((mwbmap_p->id_bitmap[wordix] & bitmap) != 0U);
}
/* Debug dump a multiword bitmap allocator */
void
bcm_mwbmap_show(struct bcm_mwbmap * mwbmap_hdl)
{
uint32 ix, count;
bcm_mwbmap_t * mwbmap_p;
BCM_MWBMAP_AUDIT(mwbmap_hdl);
mwbmap_p = BCM_MWBMAP_PTR(mwbmap_hdl);
printf("mwbmap_p %p wmaps %u imaps %u ifree %d total %u\n", mwbmap_p,
mwbmap_p->wmaps, mwbmap_p->imaps, mwbmap_p->ifree, mwbmap_p->total);
for (ix = 0U; ix < mwbmap_p->wmaps; ix++) {
printf("\tWDMAP:%2u. 0x%08x\t", ix, mwbmap_p->wd_bitmap[ix]);
bcm_bitprint32(mwbmap_p->wd_bitmap[ix]);
printf("\n");
}
for (ix = 0U; ix < mwbmap_p->imaps; ix++) {
#if defined(BCM_MWBMAP_USE_CNTSETBITS)
count = bcm_cntsetbits(mwbmap_p->id_bitmap[ix]);
#else /* ! BCM_MWBMAP_USE_CNTSETBITS */
count = mwbmap_p->wd_count[ix];
MWBMAP_ASSERT(count == bcm_cntsetbits(mwbmap_p->id_bitmap[ix]));
#endif /* ! BCM_MWBMAP_USE_CNTSETBITS */
printf("\tIDMAP:%2u. 0x%08x %02u\t", ix, mwbmap_p->id_bitmap[ix], count);
bcm_bitprint32(mwbmap_p->id_bitmap[ix]);
printf("\n");
}
return;
}
/* Audit a hierarchical multiword bitmap */
void
bcm_mwbmap_audit(struct bcm_mwbmap * mwbmap_hdl)
{
bcm_mwbmap_t * mwbmap_p;
uint32 count, free_cnt = 0U, wordix, idmap_ix, bitix, *bitmap_p;
mwbmap_p = BCM_MWBMAP_PTR(mwbmap_hdl);
for (wordix = 0U; wordix < mwbmap_p->wmaps; ++wordix) {
bitmap_p = &mwbmap_p->wd_bitmap[wordix];
for (bitix = 0U; bitix < BCM_MWBMAP_BITS_WORD; bitix++) {
if ((*bitmap_p) & (1 << bitix)) {
idmap_ix = BCM_MWBMAP_MULOP(wordix) + bitix;
#if defined(BCM_MWBMAP_USE_CNTSETBITS)
count = bcm_cntsetbits(mwbmap_p->id_bitmap[idmap_ix]);
#else /* ! BCM_MWBMAP_USE_CNTSETBITS */
count = mwbmap_p->wd_count[idmap_ix];
ASSERT(count == bcm_cntsetbits(mwbmap_p->id_bitmap[idmap_ix]));
#endif /* ! BCM_MWBMAP_USE_CNTSETBITS */
ASSERT(count != 0U);
free_cnt += count;
}
}
}
ASSERT((int)free_cnt == mwbmap_p->ifree);
}
/* END : Multiword bitmap based 64bit to Unique 32bit Id allocator. */
/* Simple 16bit Id allocator using a stack implementation. */
typedef struct id16_map {
uint16 total; /* total number of ids managed by allocator */
uint16 start; /* start value of 16bit ids to be managed */
uint32 failures; /* count of failures */
void *dbg; /* debug placeholder */
int stack_idx; /* index into stack of available ids */
uint16 stack[0]; /* stack of 16 bit ids */
} id16_map_t;
#define ID16_MAP_SZ(items) (sizeof(id16_map_t) + \
(sizeof(uint16) * (items)))
#if defined(BCM_DBG)
/* Uncomment BCM_DBG_ID16 to debug double free */
/* #define BCM_DBG_ID16 */
typedef struct id16_map_dbg {
uint16 total;
bool avail[0];
} id16_map_dbg_t;
#define ID16_MAP_DBG_SZ(items) (sizeof(id16_map_dbg_t) + \
(sizeof(bool) * (items)))
#define ID16_MAP_MSG(x) print x
#else
#define ID16_MAP_MSG(x)
#endif /* BCM_DBG */
void * /* Construct an id16 allocator: [start_val16 .. start_val16+total_ids) */
id16_map_init(osl_t *osh, uint16 total_ids, uint16 start_val16)
{
uint16 idx, val16;
id16_map_t * id16_map;
ASSERT(total_ids > 0);
ASSERT((start_val16 + total_ids) < ID16_INVALID);
id16_map = (id16_map_t *) MALLOC(osh, ID16_MAP_SZ(total_ids));
if (id16_map == NULL) {
return NULL;
}
id16_map->total = total_ids;
id16_map->start = start_val16;
id16_map->failures = 0;
id16_map->dbg = NULL;
/* Populate stack with 16bit id values, commencing with start_val16 */
id16_map->stack_idx = 0;
val16 = start_val16;
for (idx = 0; idx < total_ids; idx++, val16++) {
id16_map->stack_idx = idx;
id16_map->stack[id16_map->stack_idx] = val16;
}
#if defined(BCM_DBG) && defined(BCM_DBG_ID16)
id16_map->dbg = MALLOC(osh, ID16_MAP_DBG_SZ(total_ids));
if (id16_map->dbg) {
id16_map_dbg_t *id16_map_dbg = (id16_map_dbg_t *)id16_map->dbg;
id16_map_dbg->total = total_ids;
for (idx = 0; idx < total_ids; idx++) {
id16_map_dbg->avail[idx] = TRUE;
}
}
#endif /* BCM_DBG && BCM_DBG_ID16 */
return (void *)id16_map;
}
void * /* Destruct an id16 allocator instance */
id16_map_fini(osl_t *osh, void * id16_map_hndl)
{
uint16 total_ids;
id16_map_t * id16_map;
if (id16_map_hndl == NULL)
return NULL;
id16_map = (id16_map_t *)id16_map_hndl;
total_ids = id16_map->total;
ASSERT(total_ids > 0);
#if defined(BCM_DBG) && defined(BCM_DBG_ID16)
if (id16_map->dbg) {
MFREE(osh, id16_map->dbg, ID16_MAP_DBG_SZ(total_ids));
id16_map->dbg = NULL;
}
#endif /* BCM_DBG && BCM_DBG_ID16 */
id16_map->total = 0;
MFREE(osh, id16_map, ID16_MAP_SZ(total_ids));
return NULL;
}
void
id16_map_clear(void * id16_map_hndl, uint16 total_ids, uint16 start_val16)
{
uint16 idx, val16;
id16_map_t * id16_map;
ASSERT(total_ids > 0);
ASSERT((start_val16 + total_ids) < ID16_INVALID);
id16_map = (id16_map_t *)id16_map_hndl;
if (id16_map == NULL) {
return;
}
id16_map->total = total_ids;
id16_map->start = start_val16;
id16_map->failures = 0;
/* Populate stack with 16bit id values, commencing with start_val16 */
id16_map->stack_idx = 0;
val16 = start_val16;
for (idx = 0; idx < total_ids; idx++, val16++) {
id16_map->stack_idx = idx;
id16_map->stack[id16_map->stack_idx] = val16;
}
#if defined(BCM_DBG) && defined(BCM_DBG_ID16)
if (id16_map->dbg) {
id16_map_dbg_t *id16_map_dbg = (id16_map_dbg_t *)id16_map->dbg;
id16_map_dbg->total = total_ids;
for (idx = 0; idx < total_ids; idx++) {
id16_map_dbg->avail[idx] = TRUE;
}
}
#endif /* BCM_DBG && BCM_DBG_ID16 */
}
uint16 BCMFASTPATH /* Allocate a unique 16bit id */
id16_map_alloc(void * id16_map_hndl)
{
uint16 val16;
id16_map_t * id16_map;
ASSERT(id16_map_hndl != NULL);
id16_map = (id16_map_t *)id16_map_hndl;
ASSERT(id16_map->total > 0);
if (id16_map->stack_idx < 0) {
id16_map->failures++;
return ID16_INVALID;
}
val16 = id16_map->stack[id16_map->stack_idx];
id16_map->stack_idx--;
#if defined(BCM_DBG) && defined(BCM_DBG_ID16)
ASSERT(val16 < (id16_map->start + id16_map->total));
if (id16_map->dbg) { /* Validate val16 */
id16_map_dbg_t *id16_map_dbg = (id16_map_dbg_t *)id16_map->dbg;
ASSERT(id16_map_dbg->avail[val16 - id16_map->start] == TRUE);
id16_map_dbg->avail[val16 - id16_map->start] = FALSE;
}
#endif /* BCM_DBG && BCM_DBG_ID16 */
return val16;
}
void BCMFASTPATH /* Free a 16bit id value into the id16 allocator */
id16_map_free(void * id16_map_hndl, uint16 val16)
{
id16_map_t * id16_map;
ASSERT(id16_map_hndl != NULL);
id16_map = (id16_map_t *)id16_map_hndl;
#if defined(BCM_DBG) && defined(BCM_DBG_ID16)
ASSERT(val16 < (id16_map->start + id16_map->total));
if (id16_map->dbg) { /* Validate val16 */
id16_map_dbg_t *id16_map_dbg = (id16_map_dbg_t *)id16_map->dbg;
ASSERT(id16_map_dbg->avail[val16 - id16_map->start] == FALSE);
id16_map_dbg->avail[val16 - id16_map->start] = TRUE;
}
#endif /* BCM_DBG && BCM_DBG_ID16 */
id16_map->stack_idx++;
id16_map->stack[id16_map->stack_idx] = val16;
}
uint32 /* Returns number of failures to allocate an unique id16 */
id16_map_failures(void * id16_map_hndl)
{
ASSERT(id16_map_hndl != NULL);
return ((id16_map_t *)id16_map_hndl)->failures;
}
bool
id16_map_audit(void * id16_map_hndl)
{
int idx;
int insane = 0;
id16_map_t * id16_map;
ASSERT(id16_map_hndl != NULL);
id16_map = (id16_map_t *)id16_map_hndl;
ASSERT((id16_map->stack_idx > 0) && (id16_map->stack_idx < id16_map->total));
for (idx = 0; idx <= id16_map->stack_idx; idx++) {
ASSERT(id16_map->stack[idx] >= id16_map->start);
ASSERT(id16_map->stack[idx] < (id16_map->start + id16_map->total));
#if defined(BCM_DBG) && defined(BCM_DBG_ID16)
if (id16_map->dbg) {
uint16 val16 = id16_map->stack[idx];
if (((id16_map_dbg_t *)(id16_map->dbg))->avail[val16] != TRUE) {
insane |= 1;
ID16_MAP_MSG(("id16_map<%p>: stack_idx %u invalid val16 %u\n",
id16_map_hndl, idx, val16));
}
}
#endif /* BCM_DBG && BCM_DBG_ID16 */
}
#if defined(BCM_DBG) && defined(BCM_DBG_ID16)
if (id16_map->dbg) {
uint16 avail = 0; /* Audit available ids counts */
for (idx = 0; idx < id16_map_dbg->total; idx++) {
if (((id16_map_dbg_t *)(id16_map->dbg))->avail[idx16] == TRUE)
avail++;
}
if (avail && (avail != (id16_map->stack_idx + 1))) {
insane |= 1;
ID16_MAP_MSG(("id16_map<%p>: avail %u stack_idx %u\n",
id16_map_hndl, avail, id16_map->stack_idx));
}
}
#endif /* BCM_DBG && BCM_DBG_ID16 */
return (!!insane);
}
/* END: Simple id16 allocator */
#endif /* BCMDRIVER */
/* calculate a >> b; and returns only lower 32 bits */
void
bcm_uint64_right_shift(uint32* r, uint32 a_high, uint32 a_low, uint32 b)
{
uint32 a1 = a_high, a0 = a_low, r0 = 0;
if (b == 0) {
r0 = a_low;
*r = r0;
return;
}
if (b < 32) {
a0 = a0 >> b;
a1 = a1 & ((1 << b) - 1);
a1 = a1 << (32 - b);
r0 = a0 | a1;
*r = r0;
return;
} else {
r0 = a1 >> (b - 32);
*r = r0;
return;
}
}
/* calculate a + b where a is a 64 bit number and b is a 32 bit number */
void
bcm_add_64(uint32* r_hi, uint32* r_lo, uint32 offset)
{
uint32 r1_lo = *r_lo;
(*r_lo) += offset;
if (*r_lo < r1_lo)
(*r_hi) ++;
}
/* calculate a - b where a is a 64 bit number and b is a 32 bit number */
void
bcm_sub_64(uint32* r_hi, uint32* r_lo, uint32 offset)
{
uint32 r1_lo = *r_lo;
(*r_lo) -= offset;
if (*r_lo > r1_lo)
(*r_hi) --;
}
#ifdef DEBUG_COUNTER
#if (OSL_SYSUPTIME_SUPPORT == TRUE)
void counter_printlog(counter_tbl_t *ctr_tbl)
{
uint32 now;
if (!ctr_tbl->enabled)
return;
now = OSL_SYSUPTIME();
if (now - ctr_tbl->prev_log_print > ctr_tbl->log_print_interval) {
uint8 i = 0;
printf("counter_print(%s %d):", ctr_tbl->name, now - ctr_tbl->prev_log_print);
for (i = 0; i < ctr_tbl->needed_cnt; i++) {
printf(" %u", ctr_tbl->cnt[i]);
}
printf("\n");
ctr_tbl->prev_log_print = now;
bzero(ctr_tbl->cnt, CNTR_TBL_MAX * sizeof(uint));
}
}
#else
/* OSL_SYSUPTIME is not supported so no way to get time */
#define counter_printlog(a) do {} while (0)
#endif /* OSL_SYSUPTIME_SUPPORT == TRUE */
#endif /* DEBUG_COUNTER */
#ifdef BCMDRIVER
void
dll_pool_detach(void * osh, dll_pool_t * pool, uint16 elems_max, uint16 elem_size)
{
uint32 mem_size;
mem_size = sizeof(dll_pool_t) + (elems_max * elem_size);
if (pool)
MFREE(osh, pool, mem_size);
}
dll_pool_t *
dll_pool_init(void * osh, uint16 elems_max, uint16 elem_size)
{
uint32 mem_size, i;
dll_pool_t * dll_pool_p;
dll_t * elem_p;
ASSERT(elem_size > sizeof(dll_t));
mem_size = sizeof(dll_pool_t) + (elems_max * elem_size);
if ((dll_pool_p = (dll_pool_t *)MALLOC(osh, mem_size)) == NULL) {
printf("dll_pool_init: elems_max<%u> elem_size<%u> malloc failure\n",
elems_max, elem_size);
ASSERT(0);
return dll_pool_p;
}
bzero(dll_pool_p, mem_size);
dll_init(&dll_pool_p->free_list);
dll_pool_p->elems_max = elems_max;
dll_pool_p->elem_size = elem_size;
elem_p = dll_pool_p->elements;
for (i = 0; i < elems_max; i++) {
dll_append(&dll_pool_p->free_list, elem_p);
elem_p = (dll_t *)((uintptr)elem_p + elem_size);
}
dll_pool_p->free_count = elems_max;
return dll_pool_p;
}
void *
dll_pool_alloc(dll_pool_t * dll_pool_p)
{
dll_t * elem_p;
if (dll_pool_p->free_count == 0) {
ASSERT(dll_empty(&dll_pool_p->free_list));
return NULL;
}
elem_p = dll_head_p(&dll_pool_p->free_list);
dll_delete(elem_p);
dll_pool_p->free_count -= 1;
return (void *)elem_p;
}
void
dll_pool_free(dll_pool_t * dll_pool_p, void * elem_p)
{
dll_t * node_p = (dll_t *)elem_p;
dll_prepend(&dll_pool_p->free_list, node_p);
dll_pool_p->free_count += 1;
}
void
dll_pool_free_tail(dll_pool_t * dll_pool_p, void * elem_p)
{
dll_t * node_p = (dll_t *)elem_p;
dll_append(&dll_pool_p->free_list, node_p);
dll_pool_p->free_count += 1;
}
#endif /* BCMDRIVER */
| alyubomirov/Amlogic_s905-kernel | drivers/amlogic/wifi/bcmdhd/bcmutils.c | C | gpl-2.0 | 78,045 |
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_AnnGlaciol_JGlaciol.php
// Repository: $HeadURL: http://svn.code.sf.net/p/refbase/code/trunk/cite/styles/cite_AnnGlaciol_JGlaciol.php $
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 07-Sep-05, 14:53
// Modified: $Date: 2012-02-27 12:25:30 -0800 (Mon, 27 Feb 2012) $
// $Author: msteffens $
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the journals "Annals of Glaciology" and "Journal of Glaciology" (International Glaciological Society, www.igsoc.org).
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
".", // 9.
false, // 10.
true, // 11.
true, // 12.
"6", // 13.
"1", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['year'] . ".";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
// if there's no abbreviated journal name, we'll use the full journal name
elseif (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
if (!empty($row['volume'])) // volume
{
if (!empty($row['abbrev_journal']) || !empty($row['publication']))
$record .= ",";
$record .= " " . $markupPatternsArray["bold-prefix"] . $row['volume'] . $markupPatternsArray["bold-suffix"];
}
if (!empty($row['issue'])) // issue
$record .= "(" . $row['issue'] . ")";
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// instead of any pages info (which normally doesn't exist for online publications) we append
// an optional string (given in 'online_citation') plus the DOI:
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty
$record .= ",";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "," if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
$record .= " (" . $row['doi'] . ".)";
}
}
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead:
{
if (!empty($row['pages'])) // pages
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
}
if (!preg_match("/\.\)? *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
".", // 9.
false, // 10.
true, // 11.
true, // 12.
"6", // 13.
"1", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['year'] . ".";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
".", // 9.
false, // 10.
true, // 11.
true, // 12.
"6", // 13.
"1", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= " " . $markupPatternsArray["italic-prefix"] . "In" . $markupPatternsArray["italic-suffix"] . " " . $editor;
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= ", " . $markupPatternsArray["italic-prefix"] . "eds" . $markupPatternsArray["italic-suffix"] . ".";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= ", " . $markupPatternsArray["italic-prefix"] . "ed" . $markupPatternsArray["italic-suffix"] . ".";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"] . ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ",";
$record .= " " . $row['publisher'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['place']) || !empty($row['publisher']))
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= " (";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "(" . $row['series_issue'] . ")";
$record .= ".)";
}
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
".", // 9.
false, // 10.
true, // 11.
true, // 12.
"6", // 13.
"1", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . ", " . $markupPatternsArray["italic-prefix"] . "ed" . $markupPatternsArray["italic-suffix"];
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . ", " . $markupPatternsArray["italic-prefix"] . "eds" . $markupPatternsArray["italic-suffix"];
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['year'] . ".";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
}
if (!empty($row['thesis'])) // thesis
{
$record .= " (" . $row['thesis'];
$record .= ", " . $row['publisher'] . ".)";
}
else // not a thesis
{
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ",";
$record .= " " . $row['publisher'];
}
// if (!empty($row['pages'])) // pages
// {
// if (!empty($row['place']) || !empty($row['publisher']))
// $record .= ", ";
//
// $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
// }
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= " (";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "(" . $row['series_issue'] . ")";
$record .= ".)";
}
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>
| Olari0/Finugriling | cite/styles/cite_AnnGlaciol_JGlaciol.php | PHP | gpl-2.0 | 27,347 |
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Apigee Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
'use strict';
var _ = require('lodash-compat');
var async = require('async');
var bp = require('body-parser');
var cHelpers = require('../lib/helpers');
var debug = require('debug')('swagger-tools:middleware:metadata');
var mHelpers = require('./helpers');
var multer = require('multer');
var parseurl = require('parseurl');
var pathToRegexp = require('path-to-regexp');
// Upstream middlewares
var bodyParserOptions = {
extended: false
};
var multerOptions = {
storage: multer.memoryStorage()
};
var textBodyParserOptions = {
type: '*/*'
};
var jsonBodyParser = bp.json();
var parseQueryString = mHelpers.parseQueryString;
var queryParser = function (req, res, next) {
if (_.isUndefined(req.query)) {
req.query = parseQueryString(req);
}
return next();
};
var realTextBodyParser = bp.text(textBodyParserOptions);
var textBodyParser = function (req, res, next) {
if (_.isUndefined(req.body)) {
realTextBodyParser(req, res, next);
} else {
next();
}
};
var urlEncodedBodyParser = bp.urlencoded(bodyParserOptions);
var bodyParser = function (req, res, next) {
if (_.isUndefined(req.body)) {
urlEncodedBodyParser(req, res, function (err) {
if (err) {
next(err);
} else {
jsonBodyParser(req, res, next);
}
});
} else {
next();
}
};
var realMultiPartParser = multer(multerOptions);
var makeMultiPartParser = function (parser) {
return function (req, res, next) {
if (_.isUndefined(req.files)) {
parser(req, res, next);
} else {
next();
}
};
};
// Helper functions
var expressStylePath = function (basePath, apiPath) {
basePath = parseurl({url: basePath || '/'}).pathname || '/';
// Make sure the base path starts with '/'
if (basePath.charAt(0) !== '/') {
basePath = '/' + basePath;
}
// Make sure the base path ends with '/'
if (basePath.charAt(basePath.length - 1) !== '/') {
basePath = basePath + '/';
}
// Make sure the api path does not start with '/' since the base path will end with '/'
if (apiPath.charAt(0) === '/') {
apiPath = apiPath.substring(1);
}
// Replace Swagger syntax for path parameters with Express' version (All Swagger path parameters are required)
return (basePath + apiPath).replace(/{/g, ':').replace(/}/g, '');
};
var processOperationParameters = function (swaggerMetadata, pathKeys, pathMatch, req, res, next) {
var version = swaggerMetadata.swaggerVersion;
var spec = cHelpers.getSpec(cHelpers.getSwaggerVersion(version === '1.2' ?
swaggerMetadata.resourceListing :
swaggerMetadata.swaggerObject), true);
var parameters = !_.isUndefined(swaggerMetadata) ?
(version === '1.2' ? swaggerMetadata.operation.parameters : swaggerMetadata.operationParameters) :
undefined;
if (!parameters) {
return next();
}
debug(' Processing Parameters');
var parsers = _.reduce(parameters, function (requestParsers, parameter) {
var contentType = req.headers['content-type'];
var paramLocation = version === '1.2' ? parameter.paramType : parameter.schema.in;
var paramType = mHelpers.getParameterType(version === '1.2' ? parameter : parameter.schema);
var parsableBody = mHelpers.isModelType(spec, paramType) || ['array', 'object'].indexOf(paramType) > -1;
var parser;
switch (paramLocation) {
case 'body':
case 'form':
case 'formData':
if (paramType.toLowerCase() === 'file' || (contentType && contentType.split(';')[0] === 'multipart/form-data')) {
// Do not add a parser, multipart will be handled after
break;
} else if (paramLocation !== 'body' || parsableBody) {
parser = bodyParser;
} else {
parser = textBodyParser;
}
break;
case 'query':
parser = queryParser;
break;
}
if (parser && requestParsers.indexOf(parser) === -1) {
requestParsers.push(parser);
}
return requestParsers;
}, []);
// Multipart is handled by multer, which needs an array of {parameterName, maxCount}
var multiPartFields = _.reduce(parameters, function (fields, parameter) {
var paramLocation = version === '1.2' ? parameter.paramType : parameter.schema.in;
var paramType = mHelpers.getParameterType(version === '1.2' ? parameter : parameter.schema);
var paramName = version === '1.2' ? parameter.name : parameter.schema.name;
switch (paramLocation) {
case 'body':
case 'form':
case 'formData':
if (paramType.toLowerCase() === 'file') {
// Swagger spec does not allow array of files, so maxCount should be 1
fields.push({name: paramName, maxCount: 1});
}
break;
}
return fields;
}, []);
var contentType = req.headers['content-type'];
if (multiPartFields.length) {
// If there are files, use multer#fields
parsers.push(makeMultiPartParser(realMultiPartParser.fields(multiPartFields)));
} else if (contentType && contentType.split(';')[0] === 'multipart/form-data') {
// If no files but multipart form, use empty multer#array for text fields
parsers.push(makeMultiPartParser(realMultiPartParser.array()));
}
async.map(parsers, function (parser, callback) {
parser(req, res, callback);
}, function (err) {
if (err) {
return next(err);
}
_.each(parameters, function (parameterOrMetadata, index) {
var parameter = version === '1.2' ? parameterOrMetadata : parameterOrMetadata.schema;
var pType = mHelpers.getParameterType(parameter);
var oVal;
var value;
debug(' %s', parameter.name);
debug(' Type: %s%s', pType, !_.isUndefined(parameter.format) ? ' (format: ' + parameter.format + ')': '');
// Located here to make the debug output pretty
oVal = mHelpers.getParameterValue(version, parameter, pathKeys, pathMatch, req, debug);
value = mHelpers.convertValue(oVal, _.isUndefined(parameter.schema) ? parameter : parameter.schema, pType);
debug(' Value: %s', value);
swaggerMetadata.params[parameter.name] = {
path: version === '1.2' ?
swaggerMetadata.operationPath.concat(['parameters', index.toString()]) :
parameterOrMetadata.path,
schema: parameter,
originalValue: oVal,
value: value
};
});
return next();
});
};
var processSwaggerDocuments = function (rlOrSO, apiDeclarations) {
if (_.isUndefined(rlOrSO)) {
throw new Error('rlOrSO is required');
} else if (!_.isPlainObject(rlOrSO)) {
throw new TypeError('rlOrSO must be an object');
}
var spec = cHelpers.getSpec(cHelpers.getSwaggerVersion(rlOrSO), true);
var apiCache = {};
var composeParameters = function (apiPath, method, path, operation) {
var cParams = [];
var seenParams = [];
_.each(operation.parameters, function (parameter, index) {
cParams.push({
path: apiPath.concat([method, 'parameters', index.toString()]),
schema: parameter
});
seenParams.push(parameter.name + ':' + parameter.in);
});
_.each(path.parameters, function (parameter, index) {
if (seenParams.indexOf(parameter.name + ':' + parameter.in) === -1) {
cParams.push({
path: apiPath.concat(['parameters', index.toString()]),
schema: parameter
});
}
});
return cParams;
};
var createCacheEntry = function (adOrSO, apiOrPath, indexOrName, indent) {
var apiPath = spec.version === '1.2' ? apiOrPath.path : indexOrName;
var expressPath = expressStylePath(adOrSO.basePath, spec.version === '1.2' ? apiOrPath.path: indexOrName);
var keys = [];
var handleSubPaths = !(rlOrSO.paths && rlOrSO.paths[apiPath]['x-swagger-router-handle-subpaths']);
var re = pathToRegexp(expressPath, keys, { end: handleSubPaths });
var cacheKey = re.toString();
var cacheEntry;
// This is an absolute path, use it as the cache key
if (expressPath.indexOf('{') === -1) {
cacheKey = expressPath;
}
debug(new Array(indent + 1).join(' ') + 'Found %s: %s',
(spec.version === '1.2' ? 'API' : 'Path'),
apiPath);
cacheEntry = apiCache[cacheKey] = spec.version === '1.2' ?
{
api: apiOrPath,
apiDeclaration: adOrSO,
apiIndex: indexOrName,
keys: keys,
params: {},
re: re,
operations: {},
resourceListing: rlOrSO
} :
{
apiPath: indexOrName,
path: apiOrPath,
keys: keys,
re: re,
operations: {},
swaggerObject: {
original: rlOrSO,
resolved: adOrSO
}
};
return cacheEntry;
};
debug(' Identified Swagger version: %s', spec.version);
if (spec.version === '1.2') {
if (_.isUndefined(apiDeclarations)) {
throw new Error('apiDeclarations is required');
} else if (!_.isArray(apiDeclarations)) {
throw new TypeError('apiDeclarations must be an array');
}
debug(' Number of API Declarations: %d', apiDeclarations.length);
_.each(apiDeclarations, function (apiDeclaration, adIndex) {
debug(' Processing API Declaration %d', adIndex);
_.each(apiDeclaration.apis, function (api, apiIndex) {
var cacheEntry = createCacheEntry(apiDeclaration, api, apiIndex, 4);
cacheEntry.resourceIndex = adIndex;
_.each(api.operations, function (operation, operationIndex) {
cacheEntry.operations[operation.method.toLowerCase()] = {
operation: operation,
operationPath: ['apis', apiIndex.toString(), 'operations', operationIndex.toString()],
operationParameters: operation.parameters
};
});
});
});
} else {
// To avoid running into issues with references throughout the Swagger object we will use the resolved version.
// Getting the resolved version is an asynchronous process but since initializeMiddleware caches the resolved document
// this is a synchronous action at this point.
spec.resolve(rlOrSO, function (err, resolved) {
// Gather the paths, their path regex patterns and the corresponding operations
_.each(resolved.paths, function (path, pathName) {
var cacheEntry = createCacheEntry(resolved, path, pathName, 2);
_.each(['get', 'put', 'post', 'delete', 'options', 'head', 'patch'], function (method) {
var operation = path[method];
if (!_.isUndefined(operation)) {
cacheEntry.operations[method] = {
operation: operation,
operationPath: ['paths', pathName, method],
// Required since we have to compose parameters based on the operation and the path
operationParameters: composeParameters(['paths', pathName], method, path, operation)
};
}
});
});
});
}
return apiCache;
};
/**
* Middleware for providing Swagger information to downstream middleware and request handlers. For all requests that
* match a Swagger path, 'req.swagger' will be provided with pertinent Swagger details. Since Swagger 1.2 and 2.0
* differ a bit, the structure of this object will change so please view the documentation below for more details:
*
* https://github.com/apigee-127/swagger-tools/blob/master/docs/Middleware.md#swagger-metadata
*
* @param {object} rlOrSO - The Resource Listing (Swagger 1.2) or Swagger Object (Swagger 2.0)
* @param {object[]} apiDeclarations - The array of API Declarations (Swagger 1.2)
*
* @returns the middleware function
*/
exports = module.exports = function (rlOrSO, apiDeclarations) {
debug('Initializing swagger-metadata middleware');
var apiCache = processSwaggerDocuments(rlOrSO, apiDeclarations);
var swaggerVersion = cHelpers.getSwaggerVersion(rlOrSO);
if (_.isUndefined(rlOrSO)) {
throw new Error('rlOrSO is required');
} else if (!_.isPlainObject(rlOrSO)) {
throw new TypeError('rlOrSO must be an object');
}
if (swaggerVersion === '1.2') {
if (_.isUndefined(apiDeclarations)) {
throw new Error('apiDeclarations is required');
} else if (!_.isArray(apiDeclarations)) {
throw new TypeError('apiDeclarations must be an array');
}
}
return function swaggerMetadata (req, res, next) {
var method = req.method.toLowerCase();
var path = parseurl(req).pathname;
var cacheEntry;
var match;
var metadata;
cacheEntry = apiCache[path] || _.find(apiCache, function (metadata) {
match = metadata.re.exec(path);
return _.isArray(match);
});
debug('%s %s', req.method, req.url);
debug(' Is a Swagger path: %s', !_.isUndefined(cacheEntry));
// Request does not match an API defined in the Swagger document(s)
if (!cacheEntry) {
return next();
}
metadata = swaggerVersion === '1.2' ?
{
api: cacheEntry.api,
apiDeclaration: cacheEntry.apiDeclaration,
apiIndex: cacheEntry.apiIndex,
params: {},
resourceIndex: cacheEntry.resourceIndex,
resourceListing: cacheEntry.resourceListing
} :
{
apiPath : cacheEntry.apiPath,
path: cacheEntry.path,
params: {},
swaggerObject: cacheEntry.swaggerObject.resolved
};
if (_.isPlainObject(cacheEntry.operations[method])) {
metadata.operation = cacheEntry.operations[method].operation;
metadata.operationPath = cacheEntry.operations[method].operationPath;
if (swaggerVersion === '1.2') {
metadata.authorizations = metadata.operation.authorizations || cacheEntry.apiDeclaration.authorizations;
} else {
metadata.operationParameters = cacheEntry.operations[method].operationParameters;
metadata.security = metadata.operation.security || metadata.swaggerObject.security || [];
}
}
metadata.swaggerVersion = swaggerVersion;
req.swagger = metadata;
debug(' Is a Swagger operation: %s', !_.isUndefined(metadata.operation));
if (metadata.operation) {
// Process the operation parameters
return processOperationParameters(metadata, cacheEntry.keys, match, req, res, next, debug);
} else {
return next();
}
};
};
| rgparkins/http-stub | src/tests/node_modules/swagger-tools/middleware/swagger-metadata.js | JavaScript | gpl-2.0 | 15,539 |
/* ---------- Preview Styles ----------- */
.js #preview {
clear: both;
float: none !important;
}
#preview {
background-color: #fff;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 14px;
line-height: 1.5;
overflow: hidden;
word-wrap: break-word;
margin-bottom: 10px;
}
#preview-header {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
position: relative;
}
#preview-logo {
float: left;
padding: 15px;
}
#preview-site-name {
color: #686868;
font-weight: normal;
font-size: 1.821em;
line-height: 1;
margin-bottom: 30px;
margin-left: 15px;
padding-top: 34px;
}
#preview-main-menu {
clear: both;
padding: 0 15px 3px;
}
#preview-main-menu-links a {
color: #d9d9d9;
padding: 0.6em 1em 0.4em;
}
#preview-main-menu-links {
font-size: 0.929em;
margin: 0;
padding: 0;
}
#preview-main-menu-links a {
color: #333;
background: #ccc;
background: rgba(255, 255, 255, 0.7);
text-shadow: 0 1px #eee;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
#preview-main-menu-links a:hover,
#preview-main-menu-links a:focus {
background: #eee;
background: rgba(255, 255, 255, 0.95);
text-decoration: none;
cursor: pointer;
}
#preview-main-menu-links li a.active {
background: #fff;
border-bottom: none;
}
#preview-main-menu-links li {
display: inline;
list-style-type: none;
padding: 0.6em 0 0.4em;
}
#preview-sidebar,
#preview-content {
display: inline;
float: left;
position: relative;
}
#preview-sidebar {
margin-left: 15px;
width: 210px;
}
#preview-content {
margin-left: 30px;
width: 26.5em;
}
#preview-sidebar .preview-block {
border: 1px solid;
margin: 20px 0;
padding: 15px 20px;
}
#preview-sidebar h2 {
border-bottom: 1px solid #d6d6d6;
font-size: 1.071em;
font-weight: normal;
line-height: 1.2;
margin: 0 0 0.5em;
padding-bottom: 5px;
text-shadow: 0 1px 0 #fff;
}
#preview .preview-block .preview-content {
margin-top: 1em;
}
#preview .preview-block-menu .preview-content,
#preview .preview-block-menu .preview-content ul {
margin-top: 0;
}
#preview-main {
margin-bottom: 40px;
margin-top: 20px;
}
#preview-page-title {
font-size: 2em;
font-weight: normal;
line-height: 1;
margin: 1em 0 0.5em;
}
#preview-footer-wrapper {
color: #c0c0c0;
color: rgba(255, 255, 255, 0.65);
display: block !important;
font-size: 0.857em;
padding: 20px 20px 25px;
}
#preview-footer-wrapper a {
color: #fcfcfc;
color: rgba(255, 255, 255, 0.8);
}
#preview-footer-wrapper a:hover,
#preview-footer-wrapper a:focus {
color: #fefefe;
color: rgba(255, 255, 255, 0.95);
text-decoration: underline;
}
#preview-footer-wrapper .preview-footer-column {
display: inline;
float: left;
padding: 0 10px;
position: relative;
width: 220px;
}
#preview-footer-wrapper .preview-block {
border: 1px solid #444;
border-color: rgba(255, 255, 255, 0.1);
margin: 20px 0;
padding: 10px;
}
#preview-footer-columns .preview-block-menu {
border: none;
margin: 0;
padding: 0;
}
#preview-footer-columns h2 {
border-bottom: 1px solid #555;
border-color: rgba(255, 255, 255, 0.15);
font-size: 1em;
margin-bottom: 0;
padding-bottom: 3px;
text-transform: uppercase;
}
#preview-footer-columns .preview-content {
margin-top: 0;
}
#preview-footer-columns .preview-content ul {
margin-left: 0;
padding-left: 0;
}
#preview-footer-columns .preview-content li {
list-style: none;
list-style-image: none;
margin: 0;
padding: 0;
}
#preview-footer-columns .preview-content li a {
border-bottom: 1px solid #555;
border-color: rgba(255, 255, 255, 0.15);
display: block;
line-height: 1.2;
padding: 0.8em 2px 0.8em 20px;
text-indent: -15px;
}
#preview-footer-columns .preview-content li a:hover,
#preview-footer-columns .preview-content li a:focus {
background-color: #1f1f21;
background-color: rgba(255, 255, 255, 0.05);
text-decoration: none;
}
| marceliotstein/mes8 | core/themes/bartik/color/preview.css | CSS | gpl-2.0 | 3,927 |
<P>
Line 1.
</P>
<TABLE CELLPADDING="4">
<TR>
<TD>one</TD>
<TD>two</TD>
<TD>three</TD>
<TD>four</TD>
</TR>
<TR>
<TD>one</TD>
<TD>two</TD>
<TD>three</TD>
</TR>
<TR>
<TD>one</TD>
<TD>two</TD>
</TR>
<TR>
<TD>one</TD>
</TR>
</TABLE>
<P>
Line 2.
</P>
| farvardin/txt2tags-test | test/csv/ok/cell-decrease.html | HTML | gpl-2.0 | 248 |
<?php
/**
* This file belongs to the YIT Plugin Framework.
*
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.gnu.org/licenses/gpl-3.0.txt
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$firebase_url = '<a target="_blank" href="http://www.firebase.com">http://www.firebase.com</a>';
$defaults = YITH_Live_Chat()->defaults;
$vendor_only = ( !defined( 'YLC_PREMIUM' ) && !defined( 'YITH_WPV_PREMIUM' ) ) ? '' : array(
'name' => __( 'Show popup only in vendors\' pages', 'yith-live-chat' ),
'desc' => __( 'Show the chat popup only in vendors\' pages and hide it in entire shop pages (You must have enabled the premium version of YITH WooCommerce Multi Vendor)', 'yith-live-chat' ),
'id' => 'only-vendor-chat',
'type' => 'on-off',
'std' => $defaults['only-vendor-chat'],
);
return array(
'general' => array(
/* =================== HOME =================== */
'home' => array(
array(
'name' => __( 'YITH Live Chat: General Settings', 'yith-live-chat' ),
'type' => 'title'
),
array(
'type' => 'close'
)
),
/* =================== END SKIN =================== */
/* =================== GENERAL =================== */
'settings' => array(
array(
'name' => __( 'Enable Live Chat', 'yith-live-chat' ),
'desc' => __( 'Activate/Deactivate the live chat features. ', 'yith-live-chat' ),
'id' => 'plugin-enable',
'type' => 'on-off',
'std' => $defaults['plugin-enable']
),
array(
'name' => __( 'Firebase App URL', 'yith-live-chat' ),
'desc' => __( 'URL of your Firebase application. If you don\'t have one, get a free Firebase application here: ', 'yith-live-chat' ) . $firebase_url,
'id' => 'firebase-appurl',
'type' => 'custom-text',
'std' => $defaults['firebase-appurl'],
'custom_attributes' => array(
'required' => 'required',
'style' => 'width: 200px'
)
),
array(
'name' => __( 'Firebase App Secret', 'yith-live-chat' ),
'desc' => __( 'It can be found under the "Secrets" menu in your Firebase app dashboard', 'yith-live-chat' ),
'id' => 'firebase-appsecret',
'type' => 'text',
'std' => $defaults['firebase-appsecret'],
'custom_attributes' => array(
'required' => 'required',
'style' => 'width: 100%'
)
),
$vendor_only,
)
)
); | lieison/IndustriasFenix | wp-content/plugins/yith-live-chat/plugin-options/general-options.php | PHP | gpl-2.0 | 3,192 |
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\DataTable\Renderer;
use Piwik\DataTable\Manager;
use Piwik\DataTable;
use Piwik\DataTable\Renderer;
/**
* Simple output
*/
class Console extends Renderer
{
/**
* Prefix
*
* @var string
*/
protected $prefixRows = '#';
/**
* Computes the dataTable output and returns the string/binary
*
* @return string
*/
public function render()
{
$this->renderHeader();
return $this->renderTable($this->table);
}
/**
* Computes the exception output and returns the string/binary
*
* @return string
*/
public function renderException()
{
$this->renderHeader();
$exceptionMessage = $this->getExceptionMessage();
return 'Error: ' . $exceptionMessage;
}
/**
* Sets the prefix to be used
*
* @param string $str new prefix
*/
public function setPrefixRow($str)
{
$this->prefixRows = $str;
}
/**
* Computes the output of the given array of data tables
*
* @param DataTable\Map $map data tables to render
* @param string $prefix prefix to output before table data
* @return string
*/
protected function renderDataTableMap(DataTable\Map $map, $prefix)
{
$output = "Set<hr />";
$prefix = $prefix . ' ';
foreach ($map->getDataTables() as $descTable => $table) {
$output .= $prefix . "<b>" . $descTable . "</b><br />";
$output .= $prefix . $this->renderTable($table, $prefix . ' ');
$output .= "<hr />";
}
return $output;
}
/**
* Computes the given dataTable output and returns the string/binary
*
* @param DataTable $table data table to render
* @param string $prefix prefix to output before table data
* @return string
*/
protected function renderTable($table, $prefix = "")
{
if (is_array($table)) // convert array to DataTable
{
$table = DataTable::makeFromSimpleArray($table);
}
if ($table instanceof DataTable\Map) {
return $this->renderDataTableMap($table, $prefix);
}
if ($table->getRowsCount() == 0) {
return "Empty table<br />\n";
}
static $depth = 0;
$output = '';
$i = 1;
foreach ($table->getRows() as $row) {
$dataTableMapBreak = false;
$columns = array();
foreach ($row->getColumns() as $column => $value) {
if ($value instanceof DataTable\Map) {
$output .= $this->renderDataTableMap($value, $prefix);
$dataTableMapBreak = true;
break;
}
if (is_string($value)) $value = "'$value'";
elseif (is_array($value)) $value = var_export($value, true);
$columns[] = "'$column' => $value";
}
if ($dataTableMapBreak === true) {
continue;
}
$columns = implode(", ", $columns);
$metadata = array();
foreach ($row->getMetadata() as $name => $value) {
if (is_string($value)) $value = "'$value'";
elseif (is_array($value)) $value = var_export($value, true);
$metadata[] = "'$name' => $value";
}
$metadata = implode(", ", $metadata);
$output .= str_repeat($this->prefixRows, $depth)
. "- $i [" . $columns . "] [" . $metadata . "] [idsubtable = "
. $row->getIdSubDataTable() . "]<br />\n";
if (!is_null($row->getIdSubDataTable())) {
if ($row->isSubtableLoaded()) {
$depth++;
$output .= $this->renderTable(
Manager::getInstance()->getTable(
$row->getIdSubDataTable()
),
$prefix . ' '
);
$depth--;
} else {
$output .= "-- Sub DataTable not loaded<br />\n";
}
}
$i++;
}
$metadata = $table->getAllTableMetadata();
if (!empty($metadata)) {
$output .= "<hr />Metadata<br />";
foreach ($metadata as $id => $metadata) {
$output .= "<br />";
$output .= $prefix . " <b>$id</b><br />";
foreach ($metadata as $name => $value) {
$output .= $prefix . $prefix . "$name => $value";
}
}
}
return $output;
}
}
| agiza/vs-port | piwik/core/DataTable/Renderer/Console.php | PHP | gpl-2.0 | 4,950 |
<?php
if (function_exists('load_plugin_textdomain')) {
load_plugin_textdomain('newsletter-statistics', false, 'newsletter/statistics/languages');
load_plugin_textdomain('newsletter', false, 'newsletter/languages');
}
require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
$module = NewsletterStatistics::instance();
$controls = new NewsletterControls();
$emails = Newsletter::instance()->get_emails();
if (!$controls->is_action()) {
$controls->data = $module->options;
}
if ($controls->is_action('save')) {
$module->save_options($controls->data);
$controls->messages = 'Saved.';
}
?>
<div class="wrap">
<?php $help_url = 'http://www.thenewsletterplugin.com/plugins/newsletter/statistics-module'; ?>
<?php include NEWSLETTER_DIR . '/header-new.php'; ?>
<div id="newsletter-title">
<h2>Configuration and Email List</h2>
<p>
This module is a core part of Newsletter that collects statistics about sent emails: how many have
been read, how many have been clicked and so on.
</p>
<p>
To see the statistics of each single email, you should click the "statistics" button
you will find near each message where they are listed (like on Newsletters panel). For your
convenience, below there is a list of each email sent by Newsletter till now.
</p>
<p>
<strong>Advanced reports for each email can be generated installing the
<a href="http://www.thenewsletterplugin.com/plugins/newsletter/reports-module?utm_source=plugin&utm_medium=link&utm_campaign=newsletter-report&utm_content=<?php echo NEWSLETTER_VERSION?>" target="_blank">Reports Extension</a></strong>.
</p>
</div>
<div class="newsletter-separator"></div>
<form method="post" action="">
<?php $controls->init(); ?>
<table class="form-table">
<!--
<tr>
<th><?php _e('Tracking URL', 'newsletter-statistics') ?></th>
<td>
<?php $controls->select('tracking_url', array(0=>__('Standard', 'newsletter-statistics'),
1=>__('Blog Home URL with parameters', 'newsletter-statistics'))) ?>
<p class="description">
<?php _e('How the links inside newsletters are rewritten to track clicks.', 'newsletter-statistics') ?>
<?php _e('Since spam filters check links inside emails, <a href="http://www.thenewsletterplugin.com/plugins/newsletter/statistics-module#tracking-url" target="_blank">read more about this setting</a>.', 'newsletter-statistics') ?>
</p>
</td>
</tr>
-->
<tr>
<th><?php _e('Secret key', 'newsletter-statistics') ?></th>
<td>
<?php $controls->text('key') ?>
<p class="description">
<?php _e('This auto-generated key is used to protect the click tracking. If you change it old tracking links to external domains won\'t be registered anymore.', 'newsletter-statistics') ?>
</p>
</td>
</tr>
</table>
<p>
<?php $controls->button_save() ?>
</p>
</form>
<table class="widefat" style="width: auto">
<thead>
<tr>
<th>Id</th>
<th><?php _e('Subject', 'newsletter')?></th>
<th>Type</th>
<th><?php _e('Status', 'newsletter')?></th>
<th> </th>
<th> </th>
<th><?php _e('Tracking', 'newsletter')?></th>
<th> </th>
</tr>
</thead>
<tbody>
<?php foreach ($emails as &$email) { ?>
<?php if ($email->type != 'message' && $email->type != 'feed') continue; ?>
<tr>
<td><?php echo $email->id; ?></td>
<td><?php echo htmlspecialchars($email->subject); ?></td>
<td><?php echo $email->type; ?></td>
<td>
<?php
if ($email->status == 'sending') {
if ($email->send_on > time()) {
_e('Scheduled', 'newsletter-emails');
}
else {
_e('Sending', 'newsletter-emails');
}
} else {
echo $email->status;
}
?>
</td>
<td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $email->sent . ' ' . __('of', 'newsletter'). ' ' . $email->total; ?></td>
<td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $module->format_date($email->send_on); ?></td>
<td><?php echo $email->track==1?'Yes':'No'; ?></td>
<td>
<a class="button" href="<?php echo NewsletterStatistics::instance()->get_statistics_url($email->id); ?>">statistics</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
| dragonshivan/learninglife | wp-content/plugins/newsletter/statistics/index.php | PHP | gpl-2.0 | 5,339 |
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2003-2008 Martin Freij
//
// This file is part of Nestopia.
//
// Nestopia 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.
//
// Nestopia 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 Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#include "NstInpDevice.hpp"
#include "NstInpAdapter.hpp"
namespace Nes
{
namespace Core
{
namespace Input
{
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("s", on)
#endif
Adapter::Adapter(Type t)
: type(t) {}
AdapterTwo::AdapterTwo(Device& a,Device& b,Type t)
: Adapter(t)
{
devices[0] = &a;
devices[1] = &b;
}
bool AdapterTwo::SetType(Type t)
{
if (type != t)
{
type = t;
return true;
}
return false;
}
Device& AdapterTwo::Connect(uint port,Device& device)
{
NST_ASSERT( port < 2 );
Device& old = *devices[port];
devices[port] = &device;
return old;
}
void AdapterTwo::Initialize(bool arcade)
{
for (uint i=0; i < 2; ++i)
devices[i]->Initialize( arcade );
}
void AdapterTwo::Reset()
{
for (uint i=0; i < 2; ++i)
devices[i]->Reset();
}
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("", on)
#endif
uint AdapterTwo::NumPorts() const
{
return 2;
}
Device& AdapterTwo::GetDevice(uint port) const
{
NST_ASSERT( port < 2 );
return *devices[port];
}
void AdapterTwo::BeginFrame(Controllers* input)
{
devices[0]->BeginFrame( input );
devices[1]->BeginFrame( input );
}
void AdapterTwo::EndFrame()
{
devices[0]->EndFrame();
devices[1]->EndFrame();
}
void AdapterTwo::Poke(uint data)
{
devices[0]->Poke( data );
devices[1]->Poke( data );
}
uint AdapterTwo::Peek(uint line)
{
NST_ASSERT( line < 2 );
return devices[line]->Peek( line );
}
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("s", on)
#endif
AdapterFour::AdapterFour(Device& a,Device& b,Device& c,Device& d,Type t)
: Adapter(t), increaser(1)
{
count[0] = 0;
count[1] = 0;
devices[0] = &a;
devices[1] = &b;
devices[2] = &c;
devices[3] = &d;
}
Device& AdapterFour::Connect(uint port,Device& device)
{
NST_ASSERT( port < 4 );
Device& old = *devices[port];
devices[port] = &device;
return old;
}
void AdapterFour::Initialize(bool arcade)
{
for (uint i=0; i < 4; ++i)
devices[i]->Initialize( arcade );
}
void AdapterFour::Reset()
{
increaser = 1;
count[0] = 0;
count[1] = 0;
for (uint i=0; i < 4; ++i)
devices[i]->Reset();
}
bool AdapterFour::SetType(Type t)
{
if (type != t)
{
type = t;
increaser = 1;
count[0] = 0;
count[1] = 0;
return true;
}
return false;
}
void AdapterFour::SaveState(State::Saver& state,const dword chunk) const
{
if (type == Api::Input::ADAPTER_NES)
{
const byte data[3] =
{
increaser ^ 1, count[0], count[1]
};
state.Begin( chunk ).Write( data ).End();
}
}
void AdapterFour::LoadState(State::Loader& state)
{
if (type == Api::Input::ADAPTER_NES)
{
State::Loader::Data<3> data( state );
increaser = ~data[0] & 0x1;
count[0] = (data[1] <= 20) ? data[1] : 0;
count[1] = (data[2] <= 20) ? data[2] : 0;
}
}
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("", on)
#endif
uint AdapterFour::NumPorts() const
{
return 4;
}
Device& AdapterFour::GetDevice(uint port) const
{
NST_ASSERT( port < 4 );
return *devices[port];
}
void AdapterFour::BeginFrame(Controllers* input)
{
for (uint i=0; i < 4; ++i)
devices[i]->BeginFrame( input );
}
void AdapterFour::EndFrame()
{
for (uint i=0; i < 4; ++i)
devices[i]->EndFrame();
}
void AdapterFour::Poke(const uint data)
{
if (type == Api::Input::ADAPTER_NES)
{
increaser = ~data & 0x1;
if (!increaser)
{
count[0] = 0;
count[1] = 0;
}
}
for (uint i=0; i < 4; ++i)
devices[i]->Poke( data );
}
uint AdapterFour::Peek(const uint line)
{
NST_ASSERT( line < 2 );
if (type == Api::Input::ADAPTER_NES)
{
const uint index = count[line];
if (index < 20)
{
count[line] += increaser;
if (index < 16)
{
return devices[line + (index < 8 ? 0 : 2)]->Peek( line );
}
else if (index >= 18)
{
return (index - 18) ^ line;
}
}
return 0;
}
else
{
return
(
(devices[line+0]->Peek( line ) << 0 & 0x1) |
(devices[line+2]->Peek( line ) << 1 & 0x2)
);
}
}
}
}
}
| JasonGoemaat/NestopiaDx9 | source/core/input/NstInpAdapter.cpp | C++ | gpl-2.0 | 5,464 |
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Tax\Test\Unit\Model\TaxClass;
use Magento\Framework\Api\SortOrder;
use \Magento\Tax\Model\TaxClass\Repository;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\LocalizedException;
class RepositoryTest extends \PHPUnit_Framework_TestCase
{
/** @var Repository */
protected $model;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $searchResultFactory;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $searchResultMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $taxClassResourceMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $classModelRegistryMock;
/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
*/
protected $objectManager;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $taxClassCollectionFactory;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $extensionAttributesJoinProcessorMock;
/**
* @return void
*/
protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->searchResultFactory = $this->getMock(
'\Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory',
['create'],
[],
'',
false
);
$this->searchResultMock = $this->getMock(
'\Magento\Tax\Api\Data\TaxClassSearchResultsInterface',
[],
[],
'',
false
);
$this->classModelRegistryMock = $this->getMock(
'\Magento\Tax\Model\ClassModelRegistry',
[],
[],
'',
false
);
$this->taxClassCollectionFactory = $this->getMock(
'\Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory',
['create'],
[],
'',
false
);
$this->taxClassResourceMock = $this->getMock('\Magento\Tax\Model\ResourceModel\TaxClass', [], [], '', false);
$this->extensionAttributesJoinProcessorMock = $this->getMock(
'\Magento\Framework\Api\ExtensionAttribute\JoinProcessor',
['process'],
[],
'',
false
);
$this->model = $this->objectManager->getObject(
'Magento\Tax\Model\TaxClass\Repository',
[
'classModelRegistry' => $this->classModelRegistryMock,
'taxClassResource' => $this->taxClassResourceMock,
'searchResultsFactory' => $this->searchResultFactory,
'taxClassCollectionFactory' => $this->taxClassCollectionFactory,
'joinProcessor' => $this->extensionAttributesJoinProcessorMock
]
);
}
/**
* @return void
*/
public function testDelete()
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$taxClass->expects($this->once())->method('getClassId')->willReturn(1);
$this->taxClassResourceMock->expects($this->once())->method('delete')->with($taxClass);
$this->classModelRegistryMock->expects($this->once())->method('remove')->with(1);
$this->assertTrue($this->model->delete($taxClass));
}
/**
* @return void
* @expectedException \Magento\Framework\Exception\CouldNotDeleteException
* @expectedExceptionMessage Some Message
*/
public function testDeleteResourceException()
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$taxClass->expects($this->once())->method('getClassId')->willReturn(1);
$this->taxClassResourceMock
->expects($this->once())
->method('delete')
->willThrowException(new CouldNotDeleteException(__('Some Message')));
$this->model->delete($taxClass);
}
/**
* @return void
*/
public function testDeleteWithException()
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$taxClass->expects($this->once())->method('getClassId')->willReturn(1);
$this->taxClassResourceMock
->expects($this->once())
->method('delete')
->willThrowException(new \Exception('Some Message'));
$this->assertFalse($this->model->delete($taxClass));
}
/**
* @return void
*/
public function testGet()
{
$taxClass = $this->getMock('\Magento\Tax\Api\Data\TaxClassInterface');
$classId = 1;
$this->classModelRegistryMock
->expects($this->once())
->method('retrieve')
->with($classId)
->willReturn($taxClass);
$this->assertEquals($taxClass, $this->model->get($classId));
}
/**
* @return void
*/
public function testDeleteById()
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$classId = 1;
$this->classModelRegistryMock
->expects($this->once())
->method('retrieve')
->with($classId)
->willReturn($taxClass);
$taxClass->expects($this->once())->method('getClassId')->willReturn(1);
$this->taxClassResourceMock->expects($this->once())->method('delete')->with($taxClass);
$this->classModelRegistryMock->expects($this->once())->method('remove')->with(1);
$this->assertTrue($this->model->deleteById($classId));
}
/**
* @return void
*/
public function testGetList()
{
$taxClassOne = $this->getMock('\Magento\Tax\Api\Data\TaxClassInterface');
$taxClassTwo = $this->getMock('\Magento\Tax\Api\Data\TaxClassInterface');
$searchCriteria = $this->getMock('\Magento\Framework\Api\SearchCriteriaInterface');
$filterGroup = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false);
$filter = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false);
$collection = $this->getMock('\Magento\Tax\Model\ResourceModel\TaxClass\Collection', [], [], '', false);
$sortOrder = $this->getMock('\Magento\Framework\Api\SortOrder', [], [], '', false);
$this->extensionAttributesJoinProcessorMock->expects($this->once())
->method('process')
->with($collection);
$searchCriteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
$filterGroup->expects($this->once())->method('getFilters')->willReturn([$filter]);
$filter->expects($this->atLeastOnce())->method('getConditionType')->willReturn('eq');
$filter->expects($this->once())->method('getField')->willReturn('field');
$filter->expects($this->once())->method('getValue')->willReturn('value');
$collection->expects($this->once())->method('addFieldToFilter')->with(['field'], [['eq' => 'value']]);
$searchCriteria->expects($this->exactly(2))->method('getSortOrders')->willReturn([$sortOrder]);
$sortOrder->expects($this->once())->method('getField')->willReturn('field');
$sortOrder->expects($this->once())->method('getDirection')->willReturn(SortOrder::SORT_ASC);
$collection->expects($this->once())->method('addOrder')->with('field', 'ASC');
$searchCriteria->expects($this->once())->method('getPageSize')->willReturn(20);
$searchCriteria->expects($this->once())->method('getCurrentPage')->willReturn(0);
$collection->expects($this->any())->method('getSize')->willReturn(2);
$collection->expects($this->any())->method('setItems')->with([$taxClassOne, $taxClassTwo]);
$collection->expects($this->any())->method('getItems')->willReturn([$taxClassOne, $taxClassTwo]);
$collection->expects($this->once())->method('setCurPage')->with(0);
$collection->expects($this->once())->method('setPageSize')->with(20);
$this->searchResultMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteria);
$this->searchResultMock->expects($this->once())->method('setTotalCount')->with(2);
$this->searchResultFactory->expects($this->once())->method('create')->willReturn($this->searchResultMock);
$this->taxClassCollectionFactory->expects($this->once())->method('create')->willReturn($collection);
$this->assertEquals($this->searchResultMock, $this->model->getList($searchCriteria));
}
/**
* @return void
*/
public function testSave()
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$taxClass->expects($this->any())->method('getClassName')->willReturn('Class Name');
$taxClass->expects($this->any())->method('getClassType')->willReturn('PRODUCT');
$taxClass->expects($this->any())->method('getClassId')->willReturn(10);
$this->classModelRegistryMock->expects($this->once())->method('registerTaxClass')->with($taxClass);
$originTaxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$originTaxClass->expects($this->once())->method('getClassType')->willReturn('PRODUCT');
$this->classModelRegistryMock
->expects($this->once())
->method('retrieve')
->with(10)
->willReturn($originTaxClass);
$this->taxClassResourceMock->expects($this->once())->method('save')->with($taxClass);
$this->assertEquals(10, $this->model->save($taxClass));
}
/**
* @return void
* @expectedException \Magento\Framework\Exception\InputException
* @expectedExceptionMessage Updating classType is not allowed.
*/
public function testSaveWithInputException()
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$originalTax = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$taxClass->expects($this->exactly(2))->method('getClassId')->willReturn(10);
$this->classModelRegistryMock->expects($this->once())->method('retrieve')->with(10)->willReturn($originalTax);
$originalTax->expects($this->once())->method('getClassType')->willReturn('PRODUCT');
$taxClass->expects($this->once())->method('getClassType')->willReturn('PRODUCT2');
$this->model->save($taxClass);
}
/**
* @return void
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Something went wrong
*/
public function testSaveWithLocalizedException()
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$taxClass->expects($this->any())->method('getClassName')->willReturn('Class Name');
$taxClass->expects($this->atLeastOnce())->method('getClassType')->willReturn('PRODUCT');
$taxClass->expects($this->any())->method('getClassId')->willReturn(10);
$originTaxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$originTaxClass->expects($this->once())->method('getClassType')->willReturn('PRODUCT');
$this->classModelRegistryMock
->expects($this->once())
->method('retrieve')
->with(10)
->willReturn($originTaxClass);
$this->taxClassResourceMock->expects($this->once())->method('save')->with($taxClass)
->willThrowException(new LocalizedException(__("Something went wrong")));
$this->model->save($taxClass);
}
/**
* @return void
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage A class with the same name already exists for ClassType PRODUCT.
*/
public function testSaveWithSameClassException()
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$taxClass->expects($this->any())->method('getClassName')->willReturn('Class Name');
$taxClass->expects($this->atLeastOnce())->method('getClassType')->willReturn('PRODUCT');
$taxClass->expects($this->any())->method('getClassId')->willReturn(10);
$originTaxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$originTaxClass->expects($this->once())->method('getClassType')->willReturn('PRODUCT');
$this->classModelRegistryMock
->expects($this->once())
->method('retrieve')
->with(10)
->willReturn($originTaxClass);
$this->taxClassResourceMock->expects($this->once())->method('save')->with($taxClass)
->willThrowException(new LocalizedException(__('Class name and class type')));
$this->model->save($taxClass);
}
/**
* @param string $classType
* @return void
* @dataProvider validateTaxClassDataProvider
* @expectedException \Magento\Framework\Exception\InputException
* @expectedExceptionMessage One or more input exceptions have occurred.
*/
public function testSaveWithValidateTaxClassDataException($classType)
{
$taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$taxClass->expects($this->any())->method('getClassName')->willReturn('');
$taxClass->expects($this->atLeastOnce())->method('getClassType')->willReturn($classType);
$taxClass->expects($this->any())->method('getClassId')->willReturn(10);
$originTaxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
$originTaxClass->expects($this->once())->method('getClassType')->willReturn($classType);
$this->classModelRegistryMock
->expects($this->once())
->method('retrieve')
->with(10)
->willReturn($originTaxClass);
$this->model->save($taxClass);
}
/**
* @return array
*/
public function validateTaxClassDataProvider()
{
return [
[''],
['ERROR']
];
}
}
| FPLD/project0 | vendor/magento/module-tax/Test/Unit/Model/TaxClass/RepositoryTest.php | PHP | gpl-2.0 | 14,359 |
// closure to avoid namespace collision
(function(){
var edTest = '';
// creates the plugin
tinymce.create('tinymce.plugins.js_columns', {
init : function(ed, url) {
ed.addButton('js_columns_button', {
title : 'Add Column',
image : url+'/icon_columns.png',
onclick : function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
edTest = ed;
tb_show( 'Add Column', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=js_columns-form' );
}
});
},
createControl : function(n, cm) {
return null;
},
});
// registers the plugin. DON'T MISS THIS STEP!!!
tinymce.PluginManager.add('js_columns', tinymce.plugins.js_columns);
// executes this when the DOM is ready
jQuery(function(){
// creates a form to be displayed everytime the button is clicked
// you should achieve this using AJAX instead of direct html code like this
var form = jQuery('<div id="js_columns-form"><div class="shortcode-form">\
<h2>Add Column</h2>\
<table id="js_columns-table" class="form-table">\
<tr>\
<th><label for="js_columns-size">Column Size</label></th>\
<td><select name="size" id="js_columns-size">\
<option value="one_third">One Third (1/3)</option>\
<option value="two_third">Two Thirds (2/3)</option>\
<option value="one_half">One Half (1/2)</option>\
<option value="one_fourth">One Fourth (1/4)</option>\
<option value="three_fourth">Three Fourths (3/4)</option>\
<option value="one_fifth">One Fifth (1/5)</option>\
<option value="two_fifth">Two Fifths (2/5)</option>\
<option value="three_fifth">Three Fifths (3/5)</option>\
<option value="four_fifth">Four Fifths (4/5)</option>\
<option value="one_sixth">One Sixth (1/6)</option>\
<option value="five_sixth">Five Sixths (5/6)</option>\
</select><br />\
<small>Specify a column size to use.</small></td>\
</tr>\
<tr>\
<th><label>Is this the last column in the row?</label></th>\
<td><input type="checkbox" name="last" id="js_columns-last" value="1" /> <label for="js_columns-last">Last Column</label><br />\
<small>Check this to end a row of columns.</small>\
</tr>\
</table>\
<p class="submit">\
<input type="button" id="js_columns-submit" class="button-primary" value="Add Column" name="submit" />\
</p>\
</div></div>');
var table = form.find('table');
form.appendTo('body').hide();
// handles the click event of the submit button
form.find('#js_columns-submit').click(function(){
// defines the options and their default values
// again, this is not the most elegant way to do this
// but well, this gets the job done nonetheless
var options = {
'size' : '',
'last' : ''
};
for( var index in options) {
var currentInput = table.find('#js_columns-' + index);
var type = currentInput.attr('type');
if (index == 'size'){
var value = currentInput.val();
var shortcode = '['+value;
}
if (index == 'last'){
if (currentInput.is(':checked')){
shortcode += '_last';
}
}
}
var selectedContent = tinyMCE.activeEditor.selection.getContent();
shortcode += ']';
endShortcode = shortcode.replace('[','[/');
shortcode += '<p>' + selectedContent + '</p>';
shortcode += endShortcode;
// inserts the shortcode into the active editor
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
// closes Thickbox
tb_remove();
});
});
})() | marcminor/citywell | wp-content/themes/savior/_theme_settings/shortcodes/columns/script.js | JavaScript | gpl-2.0 | 3,717 |
#include "builtin.h"
#include "cache.h"
#include "refs.h"
#include "parse-options.h"
static const char * const git_symbolic_ref_usage[] = {
N_("git symbolic-ref [<options>] <name> [<ref>]"),
N_("git symbolic-ref -d [-q] <name>"),
NULL
};
static int check_symref(const char *HEAD, int quiet, int shorten, int print)
{
unsigned char sha1[20];
int flag;
const char *refname = resolve_ref_unsafe(HEAD, 0, sha1, &flag);
if (!refname)
die("No such ref: %s", HEAD);
else if (!(flag & REF_ISSYMREF)) {
if (!quiet)
die("ref %s is not a symbolic ref", HEAD);
else
return 1;
}
if (print) {
if (shorten)
refname = shorten_unambiguous_ref(refname, 0);
puts(refname);
}
return 0;
}
int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
{
int quiet = 0, delete = 0, shorten = 0, ret = 0;
const char *msg = NULL;
struct option options[] = {
OPT__QUIET(&quiet,
N_("suppress error message for non-symbolic (detached) refs")),
OPT_BOOL('d', "delete", &delete, N_("delete symbolic ref")),
OPT_BOOL(0, "short", &shorten, N_("shorten ref output")),
OPT_STRING('m', NULL, &msg, N_("reason"), N_("reason of the update")),
OPT_END(),
};
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options,
git_symbolic_ref_usage, 0);
if (msg && !*msg)
die("Refusing to perform update with empty message");
if (delete) {
if (argc != 1)
usage_with_options(git_symbolic_ref_usage, options);
ret = check_symref(argv[0], 1, 0, 0);
if (ret)
die("Cannot delete %s, not a symbolic ref", argv[0]);
if (!strcmp(argv[0], "HEAD"))
die("deleting '%s' is not allowed", argv[0]);
return delete_ref(argv[0], NULL, REF_NODEREF);
}
switch (argc) {
case 1:
ret = check_symref(argv[0], quiet, shorten, 1);
break;
case 2:
if (!strcmp(argv[0], "HEAD") &&
!starts_with(argv[1], "refs/"))
die("Refusing to point HEAD outside of refs/");
ret = !!create_symref(argv[0], argv[1], msg);
break;
default:
usage_with_options(git_symbolic_ref_usage, options);
}
return ret;
}
| cpackham/git | builtin/symbolic-ref.c | C | gpl-2.0 | 2,070 |
<?php
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
/**
* Gets all the vocabularies based on the node types that have Taxonomy enabled.
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary_per_type",
* source_module = "taxonomy"
* )
*/
class VocabularyPerType extends Vocabulary {
/**
* {@inheritdoc}
*/
public function query() {
$query = parent::query();
$query->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
$query->fields('nt', ['type']);
return $query;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// Get the i18n taxonomy translation setting for this vocabulary.
// 0 - No multilingual options
// 1 - Localizable terms. Run through the localization system.
// 2 - Predefined language for a vocabulary and its terms.
// 3 - Per-language terms, translatable (referencing terms with different
// languages) but not localizable.
$i18ntaxonomy_vocab = $this->variableGet('i18ntaxonomy_vocabulary', NULL);
$vid = $row->getSourceProperty('vid');
$i18ntaxonomy_vocabulary = FALSE;
if (array_key_exists($vid, $i18ntaxonomy_vocab)) {
$i18ntaxonomy_vocabulary = $i18ntaxonomy_vocab[$vid];
}
$row->setSourceProperty('i18ntaxonomy_vocabulary', $i18ntaxonomy_vocabulary);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['vid']['type'] = 'integer';
$ids['vid']['alias'] = 'nt';
$ids['type']['type'] = 'string';
return $ids;
}
}
| morethanthemes/magazine-lite | site/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php | PHP | gpl-2.0 | 1,560 |
package ProFTPD::Tests::Commands::HELP;
use lib qw(t/lib);
use base qw(ProFTPD::TestSuite::Child);
use strict;
use File::Spec;
use IO::Handle;
use ProFTPD::TestSuite::FTP;
use ProFTPD::TestSuite::Utils qw(:auth :config :features :running :test :testsuite);
$| = 1;
my $order = 0;
my $TESTS = {
help_ok => {
order => ++$order,
test_class => [qw(forking)],
},
};
sub new {
return shift()->SUPER::new(@_);
}
sub list_tests {
return testsuite_get_runnable_tests($TESTS);
}
sub help_ok {
my $self = shift;
my $tmpdir = $self->{tmpdir};
my $config_file = "$tmpdir/cmds.conf";
my $pid_file = File::Spec->rel2abs("$tmpdir/cmds.pid");
my $scoreboard_file = File::Spec->rel2abs("$tmpdir/cmds.scoreboard");
my $log_file = test_get_logfile();
my $auth_user_file = File::Spec->rel2abs("$tmpdir/cmds.passwd");
my $auth_group_file = File::Spec->rel2abs("$tmpdir/cmds.group");
my $user = 'proftpd';
my $passwd = 'test';
my $group = 'ftpd';
my $home_dir = File::Spec->rel2abs($tmpdir);
my $uid = 500;
my $gid = 500;
# Make sure that, if we're running as root, that the home directory has
# permissions/privs set for the account we create
if ($< == 0) {
unless (chmod(0755, $home_dir)) {
die("Can't set perms on $home_dir to 0755: $!");
}
unless (chown($uid, $gid, $home_dir)) {
die("Can't set owner of $home_dir to $uid/$gid: $!");
}
}
auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir,
'/bin/bash');
auth_group_write($auth_group_file, $group, $gid, $user);
my $config = {
PidFile => $pid_file,
ScoreboardFile => $scoreboard_file,
SystemLog => $log_file,
AuthUserFile => $auth_user_file,
AuthGroupFile => $auth_group_file,
IfModules => {
'mod_delay.c' => {
DelayEngine => 'off',
},
},
};
my ($port, $config_user, $config_group) = config_write($config_file, $config);
my $auth_helps = [
' NOOP FEAT OPTS AUTH* CCC* CONF* ENC* MIC* ',
' PBSZ* PROT* TYPE STRU MODE RETR STOR STOU ',
];
# Open pipes, for use between the parent and child processes. Specifically,
# the child will indicate when it's done with its test by writing a message
# to the parent.
my ($rfh, $wfh);
unless (pipe($rfh, $wfh)) {
die("Can't open pipe: $!");
}
my $ex;
# Fork child
$self->handle_sigchld();
defined(my $pid = fork()) or die("Can't fork: $!");
if ($pid) {
eval {
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
$client->help();
my $resp_code = $client->response_code();
my $resp_msgs = $client->response_msgs();
my $expected;
$expected = 214;
$self->assert($expected == $resp_code,
test_msg("Expected $expected, got $resp_code"));
$expected = 9;
my $nhelp = scalar(@$resp_msgs);
$self->assert($expected == $nhelp,
test_msg("Expected $expected, got $nhelp"));
my $helps = [(
'The following commands are recognized (* =>\'s unimplemented):',
' CWD XCWD CDUP XCUP SMNT* QUIT PORT PASV ',
' EPRT EPSV ALLO* RNFR RNTO DELE MDTM RMD ',
' XRMD MKD XMKD PWD XPWD SIZE SYST HELP ',
@$auth_helps,
' APPE REST ABOR USER PASS ACCT* REIN* LIST ',
' NLST STAT SITE MLSD MLST ',
'Direct comments to root@127.0.0.1',
)];
for (my $i = 0; $i < $nhelp; $i++) {
$expected = $helps->[$i];
$self->assert($expected eq $resp_msgs->[$i],
test_msg("Expected '$expected', got '$resp_msgs->[$i]'"));
}
};
if ($@) {
$ex = $@;
}
$wfh->print("done\n");
$wfh->flush();
} else {
eval { server_wait($config_file, $rfh) };
if ($@) {
warn($@);
exit 1;
}
exit 0;
}
# Stop server
server_stop($pid_file);
$self->assert_child_ok($pid);
if ($ex) {
test_append_logfile($log_file, $ex);
unlink($log_file);
die($ex);
}
unlink($log_file);
}
1;
| pghmcfc/proftpd | tests/t/lib/ProFTPD/Tests/Commands/HELP.pm | Perl | gpl-2.0 | 4,152 |
--- Screen module
--- Screen fields.
-- Inherits from Object.
-- @see object.Object
-- @table Screen
-- @int[opt=0] x x position
-- @int[opt=0] y y position
-- @int[opt=0] width width
-- @int[opt=0] height height
-- @tparam control.Control activeControl active control
-- @tparam control.Control focusedControl focused control
-- @tparam control.Control hoveredControl hovered control
Screen = Object:Inherit{
--Screen = Control:Inherit{
classname = 'screen',
x = 0,
y = 0,
width = 0,
height = 0,
preserveChildrenOrder = true,
-- The active control is the control currently receiving mouse events
activeControl = nil,
-- we also store the mouse button that was clicked
activeControlBtn = nil,
focusedControl = nil,
hoveredControl = nil,
currentTooltip = nil,
_lastHoveredControl = nil,
_lastClicked = Spring.GetTimer(),
_lastClickedX = 0,
_lastClickedY = 0,
}
local this = Screen
local inherited = this.inherited
--//=============================================================================
function Screen:New(obj)
local vsx,vsy = gl.GetViewSizes()
if ((obj.width or -1) <= 0) then
obj.width = vsx
end
if ((obj.height or -1) <= 0) then
obj.height = vsy
end
obj = inherited.New(self,obj)
TaskHandler.RequestGlobalDispose(obj)
obj:RequestUpdate()
return obj
end
function Screen:OnGlobalDispose(obj)
if CompareLinks(self.activeControl, obj) then
self.activeControl = nil
end
if CompareLinks(self.hoveredControl, obj) then
self.hoveredControl = nil
end
if CompareLinks(self._lastHoveredControl, obj) then
self._lastHoveredControl = nil
end
if CompareLinks(self.focusedControl, obj) then
self.focusedControl = nil
end
end
--//=============================================================================
--FIXME add new coordspace Device (which does y-invert)
function Screen:ParentToLocal(x,y)
return x, y
end
function Screen:LocalToParent(x,y)
return x, y
end
function Screen:LocalToScreen(x,y)
return x, y
end
function Screen:ScreenToLocal(x,y)
return x, y
end
function Screen:ScreenToClient(x,y)
return x, y
end
function Screen:ClientToScreen(x,y)
return x, y
end
function Screen:IsRectInView(x,y,w,h)
return
(x <= self.width) and
(x + w >= 0) and
(y <= self.height) and
(y + h >= 0)
end
--//=============================================================================
function Screen:Resize(w,h)
self.width = w
self.height = h
self:CallChildren("RequestRealign")
end
--//=============================================================================
function Screen:Update(...)
--//FIXME create a passive MouseMove event and use it instead?
self:RequestUpdate()
local hoveredControl = UnlinkSafe(self.hoveredControl)
local activeControl = UnlinkSafe(self.activeControl)
if hoveredControl and (not activeControl) then
local x, y = Spring.GetMouseState()
if math.abs(x - self.width/2) <= 1 and math.abs(y - self.height/2) <= 1 then
-- Do not register a hit if the mouse is not hovered over Spring
-- See https://springrts.com/mantis/view.php?id=5311
if self.currentTooltip then
self.currentTooltip = nil
end
if self.activeControl then
self.activeControl:MouseOut()
self.activeControl = nil
end
if self.hoveredControl then
self.hoveredControl:MouseOut()
self.hoveredControl = nil
end
return
end
y = select(2,gl.GetViewSizes()) - y
local cx,cy = hoveredControl:ScreenToLocal(x, y)
hoveredControl:MouseMove(cx, cy, 0, 0)
end
end
function Screen:IsAbove(x,y,...)
if math.abs(x - self.width/2) <= 1 and math.abs(y - self.height/2) <= 1 then
-- Do not register a hit if the mouse is not hovered over Spring
-- See https://springrts.com/mantis/view.php?id=5311
return
end
y = select(2,gl.GetViewSizes()) - y
local hoveredControl = inherited.IsAbove(self,x,y,...)
--// tooltip
if not CompareLinks(hoveredControl, self._lastHoveredControl) then
if self._lastHoveredControl then
self._lastHoveredControl:MouseOut()
end
if hoveredControl then
hoveredControl:MouseOver()
end
self.hoveredControl = MakeWeakLink(hoveredControl, self.hoveredControl)
if (hoveredControl) then
local control = hoveredControl
--// find tooltip in hovered control or its parents
while (not control.tooltip)and(control.parent) do
control = control.parent
end
self.currentTooltip = control.tooltip
else
self.currentTooltip = nil
end
self._lastHoveredControl = self.hoveredControl
elseif (self._lastHoveredControl) then
self.currentTooltip = self._lastHoveredControl.tooltip
end
return (not not hoveredControl)
end
function Screen:FocusControl(control)
--UnlinkSafe(self.activeControl)
if not CompareLinks(control, self.focusedControl) then
local focusedControl = UnlinkSafe(self.focusedControl)
if focusedControl then
focusedControl.state.focused = false
focusedControl:FocusUpdate() --rename FocusLost()
end
self.focusedControl = nil
if control then
self.focusedControl = MakeWeakLink(control, self.focusedControl)
self.focusedControl.state.focused = true
self.focusedControl:FocusUpdate() --rename FocusGain()
end
end
end
function Screen:MouseDown(x,y,btn,...)
y = select(2,gl.GetViewSizes()) - y
local activeControl = inherited.MouseDown(self,x,y,btn,...)
local oldActiveControl = UnlinkSafe(self.activeControl)
if activeControl ~= oldActiveControl and oldActiveControl ~= nil then
-- send the mouse up to controls so they know to release
self:MouseUp(x,y,self.activeControlBtn,...)
end
self:FocusControl(activeControl)
self.activeControl = MakeWeakLink(activeControl, self.activeControl)
self.activeControlBtn = btn
return (not not activeControl)
end
function Screen:MouseUp(x,y,...)
y = select(2,gl.GetViewSizes()) - y
local activeControl = UnlinkSafe(self.activeControl)
if activeControl then
local cx,cy = activeControl:ScreenToLocal(x,y)
local now = Spring.GetTimer()
local obj
local hoveredControl = inherited.IsAbove(self,x,y,...)
if CompareLinks(hoveredControl, activeControl) then
--//FIXME send this to controls too, when they didn't `return self` in MouseDown!
if (math.abs(x - self._lastClickedX)<3) and
(math.abs(y - self._lastClickedY)<3) and
(Spring.DiffTimers(now,self._lastClicked) < 0.45 ) --FIXME 0.45 := doubleClick time (use spring config?)
then
obj = activeControl:MouseDblClick(cx,cy,...)
end
if (obj == nil) then
obj = activeControl:MouseClick(cx,cy,...)
end
end
self._lastClicked = now
self._lastClickedX = x
self._lastClickedY = y
obj = activeControl:MouseUp(cx,cy,...) or obj
self.activeControl = nil
return (not not obj)
else
return (not not inherited.MouseUp(self,x,y,...))
end
end
function Screen:MouseMove(x,y,dx,dy,...)
y = select(2,gl.GetViewSizes()) - y
local activeControl = UnlinkSafe(self.activeControl)
if activeControl then
local cx,cy = activeControl:ScreenToLocal(x,y)
local obj = activeControl:MouseMove(cx,cy,dx,-dy,...)
if (obj==false) then
self.activeControl = nil
elseif (not not obj)and(obj ~= activeControl) then
self.activeControl = MakeWeakLink(obj, self.activeControl)
return true
else
return true
end
end
return (not not inherited.MouseMove(self,x,y,dx,-dy,...))
end
function Screen:MouseWheel(x,y,...)
y = select(2,gl.GetViewSizes()) - y
local activeControl = UnlinkSafe(self.activeControl)
if activeControl then
local cx,cy = activeControl:ScreenToLocal(x,y)
local obj = activeControl:MouseWheel(cx,cy,...)
if not obj then
return false
elseif obj ~= activeControl then
self.activeControl = MakeWeakLink(obj, self.activeControl)
return true
else
return true
end
end
return (not not inherited.MouseWheel(self,x,y,...))
end
function Screen:KeyPress(...)
local focusedControl = UnlinkSafe(self.focusedControl)
if focusedControl then
return (not not focusedControl:KeyPress(...))
end
return (not not inherited:KeyPress(...))
end
function Screen:TextInput(...)
local focusedControl = UnlinkSafe(self.focusedControl)
if focusedControl then
return (not not focusedControl:TextInput(...))
end
return (not not inherited:TextInput(...))
end
--//=============================================================================
| g0g0dancer/searework | LuaUI/Widgets/chili_new/controls/screen.lua | Lua | gpl-2.0 | 8,646 |
/*
* This file is part of the OregonCore Project. See AUTHORS file for Copyright information
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef OREGON_FORMULAS_H
#define OREGON_FORMULAS_H
#include "World.h"
namespace Oregon
{
namespace Honor
{
inline uint32 hk_honor_at_level(uint32 level, uint32 count = 1)
{
return (uint32)ceil(count * (-0.53177f + 0.59357f * exp((level + 23.54042f) / 26.07859f)));
}
}
namespace XP
{
enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY };
inline uint32 GetGrayLevel(uint32 pl_level)
{
if (pl_level <= 5)
return 0;
else if (pl_level <= 39)
return pl_level - 5 - pl_level / 10;
else if (pl_level <= 59)
return pl_level - 1 - pl_level / 5;
else
return pl_level - 9;
}
inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level)
{
if (mob_level >= pl_level + 5)
return RED;
else if (mob_level >= pl_level + 3)
return ORANGE;
else if (mob_level >= pl_level - 2)
return YELLOW;
else if (mob_level > GetGrayLevel(pl_level))
return GREEN;
else
return GRAY;
}
inline uint32 GetZeroDifference(uint32 pl_level)
{
if (pl_level < 8) return 5;
if (pl_level < 10) return 6;
if (pl_level < 12) return 7;
if (pl_level < 16) return 8;
if (pl_level < 20) return 9;
if (pl_level < 30) return 11;
if (pl_level < 40) return 12;
if (pl_level < 45) return 13;
if (pl_level < 50) return 14;
if (pl_level < 55) return 15;
if (pl_level < 60) return 16;
return 17;
}
inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content)
{
const uint32 nBaseExp = content == CONTENT_1_60 ? 45 : 235;
if (mob_level >= pl_level)
{
uint32 nLevelDiff = mob_level - pl_level;
if (nLevelDiff > 4)
nLevelDiff = 4;
return ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2;
}
else
{
uint32 gray_level = GetGrayLevel(pl_level);
if (mob_level > gray_level)
{
uint32 ZD = GetZeroDifference(pl_level);
return (pl_level * 5 + nBaseExp) * (ZD + mob_level - pl_level) / ZD;
}
return 0;
}
}
inline uint32 Gain(Player* pl, Unit* u)
{
if (u->GetTypeId() == TYPEID_UNIT && (
((Creature*)u)->IsTotem() || ((Creature*)u)->IsPet() ||
(((Creature*)u)->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) ||
((Creature*)u)->GetCreatureTemplate()->type == CREATURE_TYPE_CRITTER))
return 0;
uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId()));
if (xp_gain == 0)
return 0;
if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isElite())
xp_gain *= 2;
return (uint32)(xp_gain * sWorld.getRate(RATE_XP_KILL));
}
inline uint32 Gain(Pet* pet, Unit* u)
{
if (u->GetTypeId() == TYPEID_UNIT && (
((Creature*)u)->IsTotem() || ((Creature*)u)->IsPet() ||
(((Creature*)u)->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL)))
return 0;
uint32 xp_gain = BaseGain(pet->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId()));
if (xp_gain == 0)
return 0;
if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isElite())
xp_gain *= 2;
return (uint32)(xp_gain * sWorld.getRate(RATE_XP_KILL));
}
inline uint32 xp_Diff(uint32 lvl)
{
if (lvl < 29)
return 0;
if (lvl == 29)
return 1;
if (lvl == 30)
return 3;
if (lvl == 31)
return 6;
else
return (5 * (lvl - 30));
}
inline uint32 mxp(uint32 lvl)
{
if (lvl < 60)
return (45 + (5 * lvl));
else
return (235 + (5 * lvl));
}
inline uint32 xp_to_level(uint32 lvl)
{
uint32 xp = 0;
if (lvl < 60)
xp = (8 * lvl + xp_Diff(lvl)) * mxp(lvl);
else if (lvl == 60)
xp = (155 + mxp(lvl) * (1344 - 70 - ((69 - lvl) * (7 + (69 - lvl) * 8 - 1) / 2)));
else if (lvl < 70)
xp = (155 + mxp(lvl) * (1344 - ((69 - lvl) * (7 + (69 - lvl) * 8 - 1) / 2)));
else
{
// level higher than 70 is not supported
xp = (uint32)(779700 * (pow(sWorld.getRate(RATE_XP_PAST_70), (int32)lvl - 69)));
return ((xp < 0x7fffffff) ? xp : 0x7fffffff);
}
// The XP to Level is always rounded to the nearest 100 points (50 rounded to high).
xp = ((xp + 50) / 100) * 100; // use additional () for prevent free association operations in C++
if ((lvl > 10) && (lvl < 60)) // compute discount added in 2.3.x
{
uint32 discount = (lvl < 28) ? (lvl - 10) : 18;
xp = (xp * (100 - discount)) / 100; // apply discount
xp = (xp / 100) * 100; // floor to hundreds
}
return xp;
}
inline float xp_in_group_rate(uint32 count, bool isRaid)
{
if (isRaid)
{
// FIX ME: must apply decrease modifiers dependent from raid size
return 1.0f;
}
else
{
switch (count)
{
case 0:
case 1:
case 2:
return 1.0f;
case 3:
return 1.166f;
case 4:
return 1.3f;
case 5:
default:
return 1.4f;
}
}
}
}
}
#endif
| superwow/foton.core | src/game/Formulas.h | C | gpl-2.0 | 6,022 |
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef ANGLE_CLASS
AngleStyle(quartic,AngleQuartic)
#else
#ifndef LMP_ANGLE_QUARTIC_H
#define LMP_ANGLE_QUARTIC_H
#include "angle.h"
namespace LAMMPS_NS {
class AngleQuartic : public Angle {
public:
AngleQuartic(class LAMMPS *);
virtual ~AngleQuartic();
virtual void compute(int, int);
void coeff(int, char **);
double equilibrium_angle(int);
void write_restart(FILE *);
void read_restart(FILE *);
void write_data(FILE *);
double single(int, int, int, int);
protected:
double *k2, *k3, *k4, *theta0;
void allocate();
};
}
#endif
#endif
| Pakketeretet2/lammps | src/USER-MISC/angle_quartic.h | C | gpl-2.0 | 1,198 |
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 ULTIMA_SHARED_ENGINE_DATA_ARCHIVE_H
#define ULTIMA_SHARED_ENGINE_DATA_ARCHIVE_H
#include "common/archive.h"
#include "common/fs.h"
#include "common/str.h"
namespace Ultima {
namespace Shared {
/**
* The data archive class encapsulates access to a specific subfolder within
* the ultima.dat data file for a game. It wraps up the subfolder so it can
* be accessed in each game as a generic "data" subfolder. This allows the
* individual games to simplify their data loading code.
*/
class UltimaDataArchive : public Common::Archive {
private:
Common::Archive *_zip;
Common::String _publicFolder;
Common::String _innerfolder;
UltimaDataArchive(Common::Archive *zip, const Common::String &subfolder) :
_zip(zip), _publicFolder("data/"), _innerfolder(subfolder + "/") {}
Common::String innerToPublic(const Common::String &filename) const {
assert(filename.hasPrefixIgnoreCase(_publicFolder));
return _innerfolder + Common::String(filename.c_str() + _publicFolder.size());
}
public:
/**
* Creates a data archive wrapper for the ultima.dat datafile.
* Firstly, for debugging purposes, if a "files" folder exists on any path that
* has the given subfolder, it will be used first. This will allow for setting
* the ScummVM Extra Path to the create_ultima folder, and it will give preference
* the files there. Otherwise, it checks for the presence of ultima.dat, and
* if the required data is found, it returns the new archive.
* Otherwise, returns an error message in the errorMsg field
*/
static bool load(const Common::String &subfolder,
int reqMajorVersion, int reqMinorVersion, Common::U32String &errorMsg);
public:
~UltimaDataArchive() override {
delete _zip;
}
/**
* Check if a member with the given name is present in the Archive.
* Patterns are not allowed, as this is meant to be a quick File::exists()
* replacement.
*/
bool hasFile(const Common::Path &path) const override;
/**
* Add all members of the Archive matching the specified pattern to list.
* Must only append to list, and not remove elements from it.
*
* @return the number of members added to list
*/
int listMatchingMembers(Common::ArchiveMemberList &list,
const Common::Path &pattern) const override;
/**
* Add all members of the Archive to list.
* Must only append to list, and not remove elements from it.
*
* @return the number of names added to list
*/
int listMembers(Common::ArchiveMemberList &list) const override;
/**
* Returns a ArchiveMember representation of the given file.
*/
const Common::ArchiveMemberPtr getMember(const Common::Path &path)
const override;
/**
* Create a stream bound to a member with the specified name in the
* archive. If no member with this name exists, 0 is returned.
* @return the newly created input stream
*/
Common::SeekableReadStream *createReadStreamForMember(
const Common::Path &path) const override;
};
#ifndef RELEASE_BUILD
/**
* The data archive proxy class is used for debugging purposes to access engine data
* files when the create_ultima folder is in the search path. It will allow for
* local mucking around with the data files and committing changes without having to
* recreate the ultima.dat file every time a change is made. ultima.dat then just has
* to be recreated prior to a release or when the changes are completed and stable
*/
class UltimaDataArchiveProxy : public Common::Archive {
friend class UltimaDataArchive;
private:
Common::FSNode _folder;
const Common::String _publicFolder;
UltimaDataArchiveProxy(const Common::FSNode &folder) : _folder(folder), _publicFolder("data/") {}
/**
* Gets a file node from the passed filename
*/
Common::FSNode getNode(const Common::String &name) const;
public:
~UltimaDataArchiveProxy() override {
}
/**
* Check if a member with the given name is present in the Archive.
* Patterns are not allowed, as this is meant to be a quick File::exists()
* replacement.
*/
bool hasFile(const Common::Path &path) const override {
Common::String name = path.toString();
return name.hasPrefixIgnoreCase(_publicFolder) && getNode(name).exists();
}
/**
* Add all members of the Archive matching the specified pattern to list.
* Must only append to list, and not remove elements from it.
*
* @return the number of members added to list
*/
int listMatchingMembers(Common::ArchiveMemberList &list,
const Common::Path &pattern) const override {
return 0;
}
/**
* Add all members of the Archive to list.
* Must only append to list, and not remove elements from it.
*
* @return the number of names added to list
*/
int listMembers(Common::ArchiveMemberList &list) const override {
return 0;
}
/**
* Returns a ArchiveMember representation of the given file.
*/
const Common::ArchiveMemberPtr getMember(const Common::Path &path)
const override;
/**
* Create a stream bound to a member with the specified name in the
* archive. If no member with this name exists, 0 is returned.
* @return the newly created input stream
*/
Common::SeekableReadStream *createReadStreamForMember(
const Common::Path &path) const override;
};
#endif
} // End of namespace Shared
} // End of namespace Ultima
#endif
| vanfanel/scummvm | engines/ultima/shared/engine/data_archive.h | C | gpl-2.0 | 6,204 |
<?php
/**
* @version: $Id: list.php 626 2011-01-19 18:13:09Z Sigrid Suski $
* @package: SobiPro Template
* ===================================================
* @author
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: http://www.Sigsiu.NET
* ===================================================
* @copyright Copyright (C) 2006 - 2011 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
* @license see http://www.gnu.org/licenses/gpl.html GNU/GPL Version 3.
* You can use, redistribute this file and/or modify it under the terms of the GNU General Public License version 3
* ===================================================
* $Date: 2011-01-19 19:13:09 +0100 (Wed, 19 Jan 2011) $
* $Revision: 626 $
* $Author: Sigrid Suski $
* File location: administrator/components/com_sobipro/acl/list.php $
*/
defined( 'SOBIPRO' ) || exit( 'Restricted access' );
?>
<?php $this->trigger( 'Start' ); ?>
<div style="float: left; width: 20em; margin-left: 3px;">
<?php $this->menu(); ?>
</div>
<?php $this->trigger( 'AfterDisplayMenu' ); ?>
<div style="margin-left: 20.8em; margin-top: 3px;">
<table class="adminlist" cellspacing="1" style="width: 100%">
<thead>
<tr>
<th width="5%">
<?php $this->show( 'header.rid' ); ?>
</th>
<th width="5%">
<?php $this->show( 'header.checkbox' ); ?>
</th>
<th class="title">
<?php $this->show( 'header.name' ); ?>
</th>
<th width="10%">
<?php $this->show( 'header.state' ); ?>
</th>
<th width="10%">
<?php $this->show( 'header.validSince' ); ?>
</th>
<th width="10%">
<?php $this->show( 'header.validUntil' ); ?>
</th><!--
<th width="15%">
<?php $this->show( 'header.perms_count' ); ?>
</th>
<th width="15%">
<?php $this->show( 'header.group_count' ); ?>
</th>
--></tr>
</thead>
<?php
$c = $this->count( 'rules' );
for ( $i = 0; $i < $c ; $i++ ) {
$style = $i%2;
?>
<tr class="row<?php echo $style;?>">
<td style="text-align: center">
<?php $this->show( 'rules.id', $i ); ?>
</td>
<td style="text-align: center">
<?php $this->show( 'rules.checkbox', $i ); ?>
</td>
<td>
<?php $this->show( 'rules.name', $i ); ?>
</td>
<td style="text-align: center">
<?php $this->show( 'rules.state', $i ); ?>
</td>
<td style="text-align: center">
<?php $this->show( 'rules.validSince', $i ); ?>
</td>
<td style="text-align: center">
<?php $this->show( 'rules.validUntil', $i ); ?>
</td><!--
<td style="text-align: center">
<?php $this->show( 'rules.perms_count', $i ); ?>
</td>
<td style="text-align: center">
<?php $this->show( 'rules.group_count', $i ); ?>
</td>
--></tr>
<?php } ?>
</table>
<br />
</div>
<?php $this->trigger( 'End' ); ?>
| kiennd146/nhazz.com | tmp/install_50053093b34b9/Admin/acl/list.php | PHP | gpl-2.0 | 2,949 |
<html>
<head>
<title>DragMath Documentation - License</title>
</head>
<body>
<span style=" color: #000099; font-size: x-large; font-family: Arial;"><strong>DragMath copyright information</strong></span>
<span style=" font-size: small; font-family: Arial;">
<p>DragMath is licensed under the GNU General Public License (GPL) (<a href="http://www.gnu.org/copyleft/gpl.html">http://www.gnu.org/copyleft/gpl.html</a>)
</p><p>
All source code in this package is written by <a href="http://www.abillingsley.co.uk">Alex Billingsley</a> except the libraries used. The copyright information for the libaries is included below:</p>
<br>
<p>
<h4>JDOM<br> <a href="http://www.jdom.org">http://www.jdom.org</a></h4>
JDOM is available under an Apache-style open source license, with the acknowledgment clause removed. This license is among the least restrictive license available, enabling developers to use JDOM in creating new products without requiring them to release their own products as open source. This is the license model used by the Apache Project, which created the Apache server. The license is available at the top of every source file and in LICENSE.txt in the root of the distribution.
</p>
<br>
<p>
<h4>JEP<br><a href="https://sourceforge.net/projects/jep/">https://sourceforge.net/projects/jep/</a></h4>
JEP is licensed under the GNU General Public License (GPL) (<a href="http://www.gnu.org/copyleft/gpl.html">http://www.gnu.org/copyleft/gpl.html</a>)</p>
<p>
<br>
<h4>glyFX Common Toolbar Set Icons<br> <a href="http://www.glyfx.com">http://www.glyfx.com</a></h4>
Icons used in software, license found at; <a href="http://www.glyfx.com/license-toolbar.html">http://www.glyfx.com/license-toolbar.html</a></p>
</span>
</body>
</html> | nadavkav/MoodleTAO | lib/editor/common/dragmath/COPYRIGHT.html | HTML | gpl-2.0 | 1,774 |
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ObjectMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "BattlegroundMgr.h"
#include "Battleground.h"
#include "BattlegroundEY.h"
#include "Creature.h"
#include "Language.h"
#include "Object.h"
#include "Player.h"
#include "Util.h"
// these variables aren't used outside of this file, so declare them only here
uint32 BG_EY_HonorScoreTicks[BG_HONOR_MODE_NUM] =
{
260, // normal honor
160 // holiday
};
BattlegroundEY::BattlegroundEY()
{
m_BuffChange = true;
BgObjects.resize(BG_EY_OBJECT_MAX);
BgCreatures.resize(BG_EY_CREATURES_MAX);
m_Points_Trigger[FEL_REAVER] = TR_FEL_REAVER_BUFF;
m_Points_Trigger[BLOOD_ELF] = TR_BLOOD_ELF_BUFF;
m_Points_Trigger[DRAENEI_RUINS] = TR_DRAENEI_RUINS_BUFF;
m_Points_Trigger[MAGE_TOWER] = TR_MAGE_TOWER_BUFF;
StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_BG_EY_START_TWO_MINUTES;
StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_EY_START_ONE_MINUTE;
StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_EY_START_HALF_MINUTE;
StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_EY_HAS_BEGUN;
}
BattlegroundEY::~BattlegroundEY()
{
}
void BattlegroundEY::PostUpdateImpl(uint32 diff)
{
if (GetStatus() == STATUS_IN_PROGRESS)
{
m_PointAddingTimer -= diff;
if (m_PointAddingTimer <= 0)
{
m_PointAddingTimer = BG_EY_FPOINTS_TICK_TIME;
if (m_TeamPointsCount[BG_TEAM_ALLIANCE] > 0)
AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_ALLIANCE] - 1]);
if (m_TeamPointsCount[BG_TEAM_HORDE] > 0)
AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]);
}
if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND)
{
m_FlagsTimer -= diff;
if (m_FlagsTimer < 0)
{
m_FlagsTimer = 0;
if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN)
RespawnFlag(true);
else
RespawnFlagAfterDrop();
}
}
m_TowerCapCheckTimer -= diff;
if (m_TowerCapCheckTimer <= 0)
{
//check if player joined point
/*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times
but we can count of players on current point in CheckSomeoneLeftPoint
*/
this->CheckSomeoneJoinedPoint();
//check if player left point
this->CheckSomeoneLeftPoint();
this->UpdatePointStatuses();
m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME;
}
}
if (GetStatus() == STATUS_WAIT_JOIN)
{
m_CheatersCheckTimer -= diff;
if (m_CheatersCheckTimer <= 0)
{
for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
Player * plr = ObjectAccessor::FindPlayer(itr->first);
if (!plr || !plr->IsInWorld())
continue;
if (plr->GetPositionZ() < 1249)
{
if (plr->GetTeam() == HORDE)
plr->TeleportTo(566, 1807.73f, 1539.41f, 1267.63f, plr->GetOrientation(), 0);
else
plr->TeleportTo(566, 2523.68f, 1596.59f, 1269.35f, plr->GetOrientation(), 0);
}
}
m_CheatersCheckTimer = 3000;
}
}
}
void BattlegroundEY::StartingEventCloseDoors()
{
SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_IMMEDIATELY);
SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_IMMEDIATELY);
for (uint32 i = BG_EY_OBJECT_A_BANNER_FEL_REAVER_CENTER; i < BG_EY_OBJECT_MAX; ++i)
SpawnBGObject(i, RESPAWN_ONE_DAY);
}
void BattlegroundEY::StartingEventOpenDoors()
{
SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_ONE_DAY);
SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_ONE_DAY);
for (uint32 i = BG_EY_OBJECT_N_BANNER_FEL_REAVER_CENTER; i <= BG_EY_OBJECT_FLAG_NETHERSTORM; ++i)
SpawnBGObject(i, RESPAWN_IMMEDIATELY);
for (uint32 i = 0; i < EY_POINTS_MAX; ++i)
{
//randomly spawn buff
uint8 buff = urand(0, 2);
SpawnBGObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + buff + i * 3, RESPAWN_IMMEDIATELY);
}
// Achievement: Flurry
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EY_EVENT_START_BATTLE);
}
void BattlegroundEY::AddPoints(uint32 Team, uint32 Points)
{
BattlegroundTeamId team_index = GetTeamIndexByTeamId(Team);
m_TeamScores[team_index] += Points;
m_HonorScoreTics[team_index] += Points;
if (m_HonorScoreTics[team_index] >= m_HonorTics)
{
RewardHonorToTeam(GetBonusHonorFromKill(1), Team);
m_HonorScoreTics[team_index] -= m_HonorTics;
}
UpdateTeamScore(Team);
}
void BattlegroundEY::CheckSomeoneJoinedPoint()
{
GameObject* obj = NULL;
for (uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
obj = HashMapHolder<GameObject>::Find(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]);
if (obj)
{
uint8 j = 0;
while (j < m_PlayersNearPoint[EY_POINTS_MAX].size())
{
Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]);
if (!player)
{
sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY:CheckSomeoneJoinedPoint: Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[EY_POINTS_MAX][j]));
++j;
continue;
}
if (player->CanCaptureTowerPoint() && player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
{
//player joined point!
//show progress bar
UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, player);
UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], player);
UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, player);
//add player to point
m_PlayersNearPoint[i].push_back(m_PlayersNearPoint[EY_POINTS_MAX][j]);
//remove player from "free space"
m_PlayersNearPoint[EY_POINTS_MAX].erase(m_PlayersNearPoint[EY_POINTS_MAX].begin() + j);
}
else
++j;
}
}
}
}
void BattlegroundEY::CheckSomeoneLeftPoint()
{
//reset current point counts
for (uint8 i = 0; i < 2*EY_POINTS_MAX; ++i)
m_CurrentPointPlayersCount[i] = 0;
GameObject* obj = NULL;
for (uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
obj = HashMapHolder<GameObject>::Find(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]);
if (obj)
{
uint8 j = 0;
while (j < m_PlayersNearPoint[i].size())
{
Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[i][j]);
if (!player)
{
sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY:CheckSomeoneLeftPoint Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[i][j]));
//move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug
m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]);
m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j);
continue;
}
if (!player->CanCaptureTowerPoint() || !player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
//move player out of point (add him to players that are out of points
{
m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]);
m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j);
this->UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, player);
}
else
{
//player is neat flag, so update count:
m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(player->GetTeam())]++;
++j;
}
}
}
}
}
void BattlegroundEY::UpdatePointStatuses()
{
for (uint8 point = 0; point < EY_POINTS_MAX; ++point)
{
if (m_PlayersNearPoint[point].empty())
continue;
//count new point bar status:
m_PointBarStatus[point] += (m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] < BG_EY_POINT_MAX_CAPTURERS_COUNT) ? m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] : BG_EY_POINT_MAX_CAPTURERS_COUNT;
if (m_PointBarStatus[point] > BG_EY_PROGRESS_BAR_ALI_CONTROLLED)
//point is fully alliance's
m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_ALI_CONTROLLED;
if (m_PointBarStatus[point] < BG_EY_PROGRESS_BAR_HORDE_CONTROLLED)
//point is fully horde's
m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_HORDE_CONTROLLED;
uint32 pointOwnerTeamId = 0;
//find which team should own this point
if (m_PointBarStatus[point] <= BG_EY_PROGRESS_BAR_NEUTRAL_LOW)
pointOwnerTeamId = HORDE;
else if (m_PointBarStatus[point] >= BG_EY_PROGRESS_BAR_NEUTRAL_HIGH)
pointOwnerTeamId = ALLIANCE;
else
pointOwnerTeamId = EY_POINT_NO_OWNER;
for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i)
{
Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[point][i]);
if (player)
{
this->UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], player);
//if point owner changed we must evoke event!
if (pointOwnerTeamId != m_PointOwnedByTeam[point])
{
//point was uncontrolled and player is from team which captured point
if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && player->GetTeam() == pointOwnerTeamId)
this->EventTeamCapturedPoint(player, point);
//point was under control and player isn't from team which controlled it
if (m_PointState[point] == EY_POINT_UNDER_CONTROL && player->GetTeam() != m_PointOwnedByTeam[point])
this->EventTeamLostPoint(player, point);
}
// hack fix for Fel Reaver Ruins
if (point == FEL_REAVER && m_PointOwnedByTeam[point] == player->GetTeam())
if (m_FlagState && GetFlagPickerGUID() == player->GetGUID())
if (player->GetDistance2d(2044,1730) < 2)
EventPlayerCapturedFlag(player, BG_EY_OBJECT_FLAG_FEL_REAVER);
}
}
}
}
void BattlegroundEY::UpdateTeamScore(uint32 Team)
{
uint32 score = GetTeamScore(Team);
//TODO there should be some sound played when one team is near victory!! - and define variables
/*if (!m_IsInformedNearVictory && score >= BG_EY_WARNING_NEAR_VICTORY_SCORE)
{
if (Team == ALLIANCE)
SendMessageToAll(LANG_BG_EY_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
else
SendMessageToAll(LANG_BG_EY_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
PlaySoundToAll(BG_EY_SOUND_NEAR_VICTORY);
m_IsInformedNearVictory = true;
}*/
if (score >= BG_EY_MAX_TEAM_SCORE)
{
score = BG_EY_MAX_TEAM_SCORE;
EndBattleground(Team);
}
if (Team == ALLIANCE)
UpdateWorldState(EY_ALLIANCE_RESOURCES, score);
else
UpdateWorldState(EY_HORDE_RESOURCES, score);
}
void BattlegroundEY::EndBattleground(uint32 winner)
{
//win reward
if (winner == ALLIANCE)
RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
if (winner == HORDE)
RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
//complete map reward
RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
Battleground::EndBattleground(winner);
}
void BattlegroundEY::UpdatePointsCount(uint32 Team)
{
if (Team == ALLIANCE)
UpdateWorldState(EY_ALLIANCE_BASE, m_TeamPointsCount[BG_TEAM_ALLIANCE]);
else
UpdateWorldState(EY_HORDE_BASE, m_TeamPointsCount[BG_TEAM_HORDE]);
}
void BattlegroundEY::UpdatePointsIcons(uint32 Team, uint32 Point)
{
//we MUST firstly send 0, after that we can send 1!!!
if (m_PointState[Point] == EY_POINT_UNDER_CONTROL)
{
UpdateWorldState(m_PointsIconStruct[Point].WorldStateControlIndex, 0);
if (Team == ALLIANCE)
UpdateWorldState(m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 1);
else
UpdateWorldState(m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 1);
}
else
{
if (Team == ALLIANCE)
UpdateWorldState(m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 0);
else
UpdateWorldState(m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 0);
UpdateWorldState(m_PointsIconStruct[Point].WorldStateControlIndex, 1);
}
}
void BattlegroundEY::AddPlayer(Player* player)
{
Battleground::AddPlayer(player);
//create score and add it to map
BattlegroundEYScore* sc = new BattlegroundEYScore;
m_PlayersNearPoint[EY_POINTS_MAX].push_back(player->GetGUID());
PlayerScores[player->GetGUID()] = sc;
}
void BattlegroundEY::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
{
// sometimes flag aura not removed :(
for (int j = EY_POINTS_MAX; j >= 0; --j)
{
for (size_t i = 0; i < m_PlayersNearPoint[j].size(); ++i)
if (m_PlayersNearPoint[j][i] == guid)
m_PlayersNearPoint[j].erase(m_PlayersNearPoint[j].begin() + i);
}
if (IsFlagPickedup())
{
if (m_FlagKeeper == guid)
{
if (player)
EventPlayerDroppedFlag(player);
else
{
SetFlagPicker(0);
RespawnFlag(true);
}
}
}
}
void BattlegroundEY::HandleAreaTrigger(Player* Source, uint32 Trigger)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
if (!Source->isAlive()) //hack code, must be removed later
return;
switch (Trigger)
{
case TR_BLOOD_ELF_POINT:
if (m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[BLOOD_ELF] == Source->GetTeam())
if (m_FlagState && GetFlagPickerGUID() == Source->GetGUID())
EventPlayerCapturedFlag(Source, BG_EY_OBJECT_FLAG_BLOOD_ELF);
break;
case TR_FEL_REAVER_POINT:
if (m_PointState[FEL_REAVER] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[FEL_REAVER] == Source->GetTeam())
if (m_FlagState && GetFlagPickerGUID() == Source->GetGUID())
EventPlayerCapturedFlag(Source, BG_EY_OBJECT_FLAG_FEL_REAVER);
break;
case TR_MAGE_TOWER_POINT:
if (m_PointState[MAGE_TOWER] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[MAGE_TOWER] == Source->GetTeam())
if (m_FlagState && GetFlagPickerGUID() == Source->GetGUID())
EventPlayerCapturedFlag(Source, BG_EY_OBJECT_FLAG_MAGE_TOWER);
break;
case TR_DRAENEI_RUINS_POINT:
if (m_PointState[DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[DRAENEI_RUINS] == Source->GetTeam())
if (m_FlagState && GetFlagPickerGUID() == Source->GetGUID())
EventPlayerCapturedFlag(Source, BG_EY_OBJECT_FLAG_DRAENEI_RUINS);
break;
case 4512:
case 4515:
case 4517:
case 4519:
case 4530:
case 4531:
case 4568:
case 4569:
case 4570:
case 4571:
case 5866:
break;
default:
sLog->outError(LOG_FILTER_BATTLEGROUND, "WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger);
Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
break;
}
}
bool BattlegroundEY::SetupBattleground()
{
// doors
if (!AddObject(BG_EY_OBJECT_DOOR_A, BG_OBJECT_A_DOOR_EY_ENTRY, 2527.6f, 1596.91f, 1262.13f, -3.12414f, -0.173642f, -0.001515f, 0.98477f, -0.008594f, RESPAWN_IMMEDIATELY)
|| !AddObject(BG_EY_OBJECT_DOOR_H, BG_OBJECT_H_DOOR_EY_ENTRY, 1803.21f, 1539.49f, 1261.09f, 3.14159f, 0.173648f, 0, 0.984808f, 0, RESPAWN_IMMEDIATELY)
// banners (alliance)
|| !AddObject(BG_EY_OBJECT_A_BANNER_FEL_REAVER_CENTER, BG_OBJECT_A_BANNER_EY_ENTRY, 2057.46f, 1735.07f, 1187.91f, -0.925024f, 0, 0, 0.446198f, -0.894934f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_FEL_REAVER_LEFT, BG_OBJECT_A_BANNER_EY_ENTRY, 2032.25f, 1729.53f, 1190.33f, 1.8675f, 0, 0, 0.803857f, 0.594823f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_FEL_REAVER_RIGHT, BG_OBJECT_A_BANNER_EY_ENTRY, 2092.35f, 1775.46f, 1187.08f, -0.401426f, 0, 0, 0.199368f, -0.979925f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_BLOOD_ELF_CENTER, BG_OBJECT_A_BANNER_EY_ENTRY, 2047.19f, 1349.19f, 1189.0f, -1.62316f, 0, 0, 0.725374f, -0.688354f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_BLOOD_ELF_LEFT, BG_OBJECT_A_BANNER_EY_ENTRY, 2074.32f, 1385.78f, 1194.72f, 0.488692f, 0, 0, 0.241922f, 0.970296f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_BLOOD_ELF_RIGHT, BG_OBJECT_A_BANNER_EY_ENTRY, 2025.13f, 1386.12f, 1192.74f, 2.3911f, 0, 0, 0.930418f, 0.366501f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_DRAENEI_RUINS_CENTER, BG_OBJECT_A_BANNER_EY_ENTRY, 2276.8f, 1400.41f, 1196.33f, 2.44346f, 0, 0, 0.939693f, 0.34202f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_DRAENEI_RUINS_LEFT, BG_OBJECT_A_BANNER_EY_ENTRY, 2305.78f, 1404.56f, 1199.38f, 1.74533f, 0, 0, 0.766044f, 0.642788f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_DRAENEI_RUINS_RIGHT, BG_OBJECT_A_BANNER_EY_ENTRY, 2245.4f, 1366.41f, 1195.28f, 2.21657f, 0, 0, 0.894934f, 0.446198f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_MAGE_TOWER_CENTER, BG_OBJECT_A_BANNER_EY_ENTRY, 2270.84f, 1784.08f, 1186.76f, 2.42601f, 0, 0, 0.936672f, 0.350207f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_MAGE_TOWER_LEFT, BG_OBJECT_A_BANNER_EY_ENTRY, 2269.13f, 1737.7f, 1186.66f, 0.994838f, 0, 0, 0.477159f, 0.878817f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_MAGE_TOWER_RIGHT, BG_OBJECT_A_BANNER_EY_ENTRY, 2300.86f, 1741.25f, 1187.7f, -0.785398f, 0, 0, 0.382683f, -0.92388f, RESPAWN_ONE_DAY)
// banners (horde)
|| !AddObject(BG_EY_OBJECT_H_BANNER_FEL_REAVER_CENTER, BG_OBJECT_H_BANNER_EY_ENTRY, 2057.46f, 1735.07f, 1187.91f, -0.925024f, 0, 0, 0.446198f, -0.894934f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_FEL_REAVER_LEFT, BG_OBJECT_H_BANNER_EY_ENTRY, 2032.25f, 1729.53f, 1190.33f, 1.8675f, 0, 0, 0.803857f, 0.594823f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_FEL_REAVER_RIGHT, BG_OBJECT_H_BANNER_EY_ENTRY, 2092.35f, 1775.46f, 1187.08f, -0.401426f, 0, 0, 0.199368f, -0.979925f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_BLOOD_ELF_CENTER, BG_OBJECT_H_BANNER_EY_ENTRY, 2047.19f, 1349.19f, 1189.0f, -1.62316f, 0, 0, 0.725374f, -0.688354f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_BLOOD_ELF_LEFT, BG_OBJECT_H_BANNER_EY_ENTRY, 2074.32f, 1385.78f, 1194.72f, 0.488692f, 0, 0, 0.241922f, 0.970296f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_BLOOD_ELF_RIGHT, BG_OBJECT_H_BANNER_EY_ENTRY, 2025.13f, 1386.12f, 1192.74f, 2.3911f, 0, 0, 0.930418f, 0.366501f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_DRAENEI_RUINS_CENTER, BG_OBJECT_H_BANNER_EY_ENTRY, 2276.8f, 1400.41f, 1196.33f, 2.44346f, 0, 0, 0.939693f, 0.34202f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_DRAENEI_RUINS_LEFT, BG_OBJECT_H_BANNER_EY_ENTRY, 2305.78f, 1404.56f, 1199.38f, 1.74533f, 0, 0, 0.766044f, 0.642788f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_DRAENEI_RUINS_RIGHT, BG_OBJECT_H_BANNER_EY_ENTRY, 2245.4f, 1366.41f, 1195.28f, 2.21657f, 0, 0, 0.894934f, 0.446198f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_MAGE_TOWER_CENTER, BG_OBJECT_H_BANNER_EY_ENTRY, 2270.84f, 1784.08f, 1186.76f, 2.42601f, 0, 0, 0.936672f, 0.350207f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_MAGE_TOWER_LEFT, BG_OBJECT_H_BANNER_EY_ENTRY, 2269.13f, 1737.7f, 1186.66f, 0.994838f, 0, 0, 0.477159f, 0.878817f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_MAGE_TOWER_RIGHT, BG_OBJECT_H_BANNER_EY_ENTRY, 2300.86f, 1741.25f, 1187.7f, -0.785398f, 0, 0, 0.382683f, -0.92388f, RESPAWN_ONE_DAY)
// banners (natural)
|| !AddObject(BG_EY_OBJECT_N_BANNER_FEL_REAVER_CENTER, BG_OBJECT_N_BANNER_EY_ENTRY, 2057.46f, 1735.07f, 1187.91f, -0.925024f, 0, 0, 0.446198f, -0.894934f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_FEL_REAVER_LEFT, BG_OBJECT_N_BANNER_EY_ENTRY, 2032.25f, 1729.53f, 1190.33f, 1.8675f, 0, 0, 0.803857f, 0.594823f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_FEL_REAVER_RIGHT, BG_OBJECT_N_BANNER_EY_ENTRY, 2092.35f, 1775.46f, 1187.08f, -0.401426f, 0, 0, 0.199368f, -0.979925f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_BLOOD_ELF_CENTER, BG_OBJECT_N_BANNER_EY_ENTRY, 2047.19f, 1349.19f, 1189.0f, -1.62316f, 0, 0, 0.725374f, -0.688354f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_BLOOD_ELF_LEFT, BG_OBJECT_N_BANNER_EY_ENTRY, 2074.32f, 1385.78f, 1194.72f, 0.488692f, 0, 0, 0.241922f, 0.970296f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_BLOOD_ELF_RIGHT, BG_OBJECT_N_BANNER_EY_ENTRY, 2025.13f, 1386.12f, 1192.74f, 2.3911f, 0, 0, 0.930418f, 0.366501f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_DRAENEI_RUINS_CENTER, BG_OBJECT_N_BANNER_EY_ENTRY, 2276.8f, 1400.41f, 1196.33f, 2.44346f, 0, 0, 0.939693f, 0.34202f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_DRAENEI_RUINS_LEFT, BG_OBJECT_N_BANNER_EY_ENTRY, 2305.78f, 1404.56f, 1199.38f, 1.74533f, 0, 0, 0.766044f, 0.642788f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_DRAENEI_RUINS_RIGHT, BG_OBJECT_N_BANNER_EY_ENTRY, 2245.4f, 1366.41f, 1195.28f, 2.21657f, 0, 0, 0.894934f, 0.446198f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_MAGE_TOWER_CENTER, BG_OBJECT_N_BANNER_EY_ENTRY, 2270.84f, 1784.08f, 1186.76f, 2.42601f, 0, 0, 0.936672f, 0.350207f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_MAGE_TOWER_LEFT, BG_OBJECT_N_BANNER_EY_ENTRY, 2269.13f, 1737.7f, 1186.66f, 0.994838f, 0, 0, 0.477159f, 0.878817f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_MAGE_TOWER_RIGHT, BG_OBJECT_N_BANNER_EY_ENTRY, 2300.86f, 1741.25f, 1187.7f, -0.785398f, 0, 0, 0.382683f, -0.92388f, RESPAWN_ONE_DAY)
// flags
|| !AddObject(BG_EY_OBJECT_FLAG_NETHERSTORM, BG_OBJECT_FLAG2_EY_ENTRY, 2174.782227f, 1569.054688f, 1160.361938f, -1.448624f, 0, 0, 0.662620f, -0.748956f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_FLAG_FEL_REAVER, BG_OBJECT_FLAG1_EY_ENTRY, 2044.28f, 1729.68f, 1189.96f, -0.017453f, 0, 0, 0.008727f, -0.999962f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_FLAG_BLOOD_ELF, BG_OBJECT_FLAG1_EY_ENTRY, 2048.83f, 1393.65f, 1194.49f, 0.20944f, 0, 0, 0.104528f, 0.994522f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_FLAG_DRAENEI_RUINS, BG_OBJECT_FLAG1_EY_ENTRY, 2286.56f, 1402.36f, 1197.11f, 3.72381f, 0, 0, 0.957926f, -0.287016f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_FLAG_MAGE_TOWER, BG_OBJECT_FLAG1_EY_ENTRY, 2284.48f, 1731.23f, 1189.99f, 2.89725f, 0, 0, 0.992546f, 0.121869f, RESPAWN_ONE_DAY)
// tower cap
|| !AddObject(BG_EY_OBJECT_TOWER_CAP_FEL_REAVER, BG_OBJECT_FR_TOWER_CAP_EY_ENTRY, 2024.600708f, 1742.819580f, 1195.157715f, 2.443461f, 0, 0, 0.939693f, 0.342020f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_TOWER_CAP_BLOOD_ELF, BG_OBJECT_BE_TOWER_CAP_EY_ENTRY, 2050.493164f, 1372.235962f, 1194.563477f, 1.710423f, 0, 0, 0.754710f, 0.656059f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_TOWER_CAP_DRAENEI_RUINS, BG_OBJECT_DR_TOWER_CAP_EY_ENTRY, 2301.010498f, 1386.931641f, 1197.183472f, 1.570796f, 0, 0, 0.707107f, 0.707107f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_TOWER_CAP_MAGE_TOWER, BG_OBJECT_HU_TOWER_CAP_EY_ENTRY, 2282.121582f, 1760.006958f, 1189.707153f, 1.919862f, 0, 0, 0.819152f, 0.573576f, RESPAWN_ONE_DAY)
)
{
sLog->outError(LOG_FILTER_SQL, "BatteGroundEY: Failed to spawn some object Battleground not created!");
return false;
}
//buffs
for (int i = 0; i < EY_POINTS_MAX; ++i)
{
AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(m_Points_Trigger[i]);
if (!at)
{
sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY: Unknown trigger: %u", m_Points_Trigger[i]);
continue;
}
if (!AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3, Buff_Entries[0], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 1, Buff_Entries[1], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 2, Buff_Entries[2], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY)
)
sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY: Cannot spawn buff");
}
WorldSafeLocsEntry const* sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_ALLIANCE);
if (!sg || !AddSpiritGuide(EY_SPIRIT_MAIN_ALLIANCE, sg->x, sg->y, sg->z, 3.124139f, ALLIANCE))
{
sLog->outError(LOG_FILTER_SQL, "BatteGroundEY: Failed to spawn spirit guide! Battleground not created!");
return false;
}
sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_HORDE);
if (!sg || !AddSpiritGuide(EY_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, HORDE))
{
sLog->outError(LOG_FILTER_SQL, "BatteGroundEY: Failed to spawn spirit guide! Battleground not created!");
return false;
}
return true;
}
void BattlegroundEY::Reset()
{
//call parent's class reset
Battleground::Reset();
m_TeamScores[BG_TEAM_ALLIANCE] = 0;
m_TeamScores[BG_TEAM_HORDE] = 0;
m_TeamPointsCount[BG_TEAM_ALLIANCE] = 0;
m_TeamPointsCount[BG_TEAM_HORDE] = 0;
m_HonorScoreTics[BG_TEAM_ALLIANCE] = 0;
m_HonorScoreTics[BG_TEAM_HORDE] = 0;
m_FlagState = BG_EY_FLAG_STATE_ON_BASE;
m_FlagCapturedBgObjectType = 0;
m_FlagKeeper = 0;
m_DroppedFlagGUID = 0;
m_PointAddingTimer = 0;
m_TowerCapCheckTimer = 0;
m_CheatersCheckTimer = 0;
bool isBGWeekend = sBattlegroundMgr->IsBGWeekend(GetTypeID());
m_HonorTics = (isBGWeekend) ? BG_EY_EYWeekendHonorTicks : BG_EY_NotEYWeekendHonorTicks;
for (uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
m_PointOwnedByTeam[i] = EY_POINT_NO_OWNER;
m_PointState[i] = EY_POINT_STATE_UNCONTROLLED;
m_PointBarStatus[i] = BG_EY_PROGRESS_BAR_STATE_MIDDLE;
m_PlayersNearPoint[i].clear();
m_PlayersNearPoint[i].reserve(15); //tip size
}
m_PlayersNearPoint[EY_PLAYERS_OUT_OF_POINTS].clear();
m_PlayersNearPoint[EY_PLAYERS_OUT_OF_POINTS].reserve(30);
}
void BattlegroundEY::RespawnFlag(bool send_message)
{
if (m_FlagCapturedBgObjectType > 0)
SpawnBGObject(m_FlagCapturedBgObjectType, RESPAWN_ONE_DAY);
m_FlagCapturedBgObjectType = 0;
m_FlagState = BG_EY_FLAG_STATE_ON_BASE;
SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_IMMEDIATELY);
if (send_message)
{
SendMessageToAll(LANG_BG_EY_RESETED_FLAG, CHAT_MSG_BG_SYSTEM_NEUTRAL);
PlaySoundToAll(BG_EY_SOUND_FLAG_RESET); // flags respawned sound...
}
UpdateWorldState(NETHERSTORM_FLAG, 1);
}
void BattlegroundEY::RespawnFlagAfterDrop()
{
RespawnFlag(true);
GameObject* obj = HashMapHolder<GameObject>::Find(GetDroppedFlagGUID());
if (obj)
obj->Delete();
else
sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY: Unknown dropped flag guid: %u", GUID_LOPART(GetDroppedFlagGUID()));
SetDroppedFlagGUID(0);
}
void BattlegroundEY::HandleKillPlayer(Player* player, Player* killer)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
Battleground::HandleKillPlayer(player, killer);
EventPlayerDroppedFlag(player);
}
void BattlegroundEY::EventPlayerDroppedFlag(Player* Source)
{
if (GetStatus() != STATUS_IN_PROGRESS)
{
// if not running, do not cast things at the dropper player, neither send unnecessary messages
// just take off the aura
if (IsFlagPickedup() && GetFlagPickerGUID() == Source->GetGUID())
{
SetFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
}
return;
}
if (!IsFlagPickedup())
return;
if (GetFlagPickerGUID() != Source->GetGUID())
return;
SetFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
m_FlagState = BG_EY_FLAG_STATE_ON_GROUND;
m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME;
Source->CastSpell(Source, SPELL_RECENTLY_DROPPED_FLAG, true);
Source->CastSpell(Source, BG_EY_PLAYER_DROPPED_FLAG_SPELL, true);
//this does not work correctly :((it should remove flag carrier name)
UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_WAIT_RESPAWN);
UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_WAIT_RESPAWN);
if (Source->GetTeam() == ALLIANCE)
SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL);
else
SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL);
}
void BattlegroundEY::EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj)
{
if (GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedup() || !Source->IsWithinDistInMap(target_obj, 10))
return;
if (Source->GetTeam() == ALLIANCE)
{
UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_ON_PLAYER);
PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE);
}
else
{
UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_ON_PLAYER);
PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_HORDE);
}
if (m_FlagState == BG_EY_FLAG_STATE_ON_BASE)
UpdateWorldState(NETHERSTORM_FLAG, 0);
m_FlagState = BG_EY_FLAG_STATE_ON_PLAYER;
SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_ONE_DAY);
SetFlagPicker(Source->GetGUID());
//get flag aura on player
Source->CastSpell(Source, BG_EY_NETHERSTORM_FLAG_SPELL, true);
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if (Source->GetTeam() == ALLIANCE)
PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, Source->GetName());
else
PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, Source->GetName());
}
void BattlegroundEY::EventTeamLostPoint(Player* Source, uint32 Point)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
//Natural point
uint32 Team = m_PointOwnedByTeam[Point];
if (!Team)
return;
if (Team == ALLIANCE)
{
m_TeamPointsCount[BG_TEAM_ALLIANCE]--;
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance, RESPAWN_ONE_DAY);
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance + 1, RESPAWN_ONE_DAY);
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance + 2, RESPAWN_ONE_DAY);
}
else
{
m_TeamPointsCount[BG_TEAM_HORDE]--;
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde, RESPAWN_ONE_DAY);
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde + 1, RESPAWN_ONE_DAY);
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde + 2, RESPAWN_ONE_DAY);
}
SpawnBGObject(m_LosingPointTypes[Point].SpawnNeutralObjectType, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_LosingPointTypes[Point].SpawnNeutralObjectType + 1, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_LosingPointTypes[Point].SpawnNeutralObjectType + 2, RESPAWN_IMMEDIATELY);
//buff isn't despawned
m_PointOwnedByTeam[Point] = EY_POINT_NO_OWNER;
m_PointState[Point] = EY_POINT_NO_OWNER;
if (Team == ALLIANCE)
SendMessageToAll(m_LosingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
else
SendMessageToAll(m_LosingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source);
UpdatePointsIcons(Team, Point);
UpdatePointsCount(Team);
//remove bonus honor aura trigger creature when node is lost
if (Point < EY_POINTS_MAX)
DelCreature(Point + 6);//NULL checks are in DelCreature! 0-5 spirit guides
}
void BattlegroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
uint32 Team = Source->GetTeam();
SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType, RESPAWN_ONE_DAY);
SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, RESPAWN_ONE_DAY);
SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 2, RESPAWN_ONE_DAY);
if (Team == ALLIANCE)
{
m_TeamPointsCount[BG_TEAM_ALLIANCE]++;
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 1, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 2, RESPAWN_IMMEDIATELY);
}
else
{
m_TeamPointsCount[BG_TEAM_HORDE]++;
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, RESPAWN_IMMEDIATELY);
}
//buff isn't respawned
m_PointOwnedByTeam[Point] = Team;
m_PointState[Point] = EY_POINT_UNDER_CONTROL;
if (Team == ALLIANCE)
SendMessageToAll(m_CapturingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
else
SendMessageToAll(m_CapturingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source);
if (BgCreatures[Point])
DelCreature(Point);
WorldSafeLocsEntry const* sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveYardId);
if (!sg || !AddSpiritGuide(Point, sg->x, sg->y, sg->z, 3.124139f, Team))
sLog->outError(LOG_FILTER_BATTLEGROUND, "BatteGroundEY: Failed to spawn spirit guide! point: %u, team: %u, graveyard_id: %u",
Point, Team, m_CapturingPointTypes[Point].GraveYardId);
// SpawnBGCreature(Point, RESPAWN_IMMEDIATELY);
UpdatePointsIcons(Team, Point);
UpdatePointsCount(Team);
if (Point >= EY_POINTS_MAX)
return;
Creature* trigger = GetBGCreature(Point + 6);//0-5 spirit guides
if (!trigger)
trigger = AddCreature(WORLD_TRIGGER, Point+6, Team, BG_EY_TriggerPositions[Point][0], BG_EY_TriggerPositions[Point][1], BG_EY_TriggerPositions[Point][2], BG_EY_TriggerPositions[Point][3]);
//add bonus honor aura trigger creature when node is accupied
//cast bonus aura (+50% honor in 25yards)
//aura should only apply to players who have accupied the node, set correct faction for trigger
if (trigger)
{
trigger->setFaction(Team == ALLIANCE ? 84 : 83);
trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false);
}
}
void BattlegroundEY::EventPlayerCapturedFlag(Player* Source, uint32 BgObjectType)
{
if (GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGUID() != Source->GetGUID())
return;
SetFlagPicker(0);
m_FlagState = BG_EY_FLAG_STATE_WAIT_RESPAWN;
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if (Source->GetTeam() == ALLIANCE)
PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE);
else
PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_HORDE);
SpawnBGObject(BgObjectType, RESPAWN_IMMEDIATELY);
m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME;
m_FlagCapturedBgObjectType = BgObjectType;
uint8 team_id = 0;
if (Source->GetTeam() == ALLIANCE)
{
team_id = BG_TEAM_ALLIANCE;
SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_A, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
}
else
{
team_id = BG_TEAM_HORDE;
SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_H, CHAT_MSG_BG_SYSTEM_HORDE, Source);
}
if (m_TeamPointsCount[team_id] > 0)
AddPoints(Source->GetTeam(), BG_EY_FlagPoints[m_TeamPointsCount[team_id] - 1]);
UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1);
}
void BattlegroundEY::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor)
{
BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID());
if (itr == PlayerScores.end()) // player not found
return;
switch (type)
{
case SCORE_FLAG_CAPTURES: // flags captured
((BattlegroundEYScore*)itr->second)->FlagCaptures += value;
Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, EY_OBJECTIVE_CAPTURE_FLAG);
break;
default:
Battleground::UpdatePlayerScore(Source, type, value, doAddHonor);
break;
}
}
void BattlegroundEY::FillInitialWorldStates(WorldPacket& data)
{
data << uint32(EY_HORDE_BASE) << uint32(m_TeamPointsCount[BG_TEAM_HORDE]);
data << uint32(EY_ALLIANCE_BASE) << uint32(m_TeamPointsCount[BG_TEAM_ALLIANCE]);
data << uint32(0xab6) << uint32(0x0);
data << uint32(0xab5) << uint32(0x0);
data << uint32(0xab4) << uint32(0x0);
data << uint32(0xab3) << uint32(0x0);
data << uint32(0xab2) << uint32(0x0);
data << uint32(0xab1) << uint32(0x0);
data << uint32(0xab0) << uint32(0x0);
data << uint32(0xaaf) << uint32(0x0);
data << uint32(DRAENEI_RUINS_HORDE_CONTROL) << uint32(m_PointOwnedByTeam[DRAENEI_RUINS] == HORDE && m_PointState[DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL);
data << uint32(DRAENEI_RUINS_ALLIANCE_CONTROL) << uint32(m_PointOwnedByTeam[DRAENEI_RUINS] == ALLIANCE && m_PointState[DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL);
data << uint32(DRAENEI_RUINS_UNCONTROL) << uint32(m_PointState[DRAENEI_RUINS] != EY_POINT_UNDER_CONTROL);
data << uint32(MAGE_TOWER_ALLIANCE_CONTROL) << uint32(m_PointOwnedByTeam[MAGE_TOWER] == ALLIANCE && m_PointState[MAGE_TOWER] == EY_POINT_UNDER_CONTROL);
data << uint32(MAGE_TOWER_HORDE_CONTROL) << uint32(m_PointOwnedByTeam[MAGE_TOWER] == HORDE && m_PointState[MAGE_TOWER] == EY_POINT_UNDER_CONTROL);
data << uint32(MAGE_TOWER_UNCONTROL) << uint32(m_PointState[MAGE_TOWER] != EY_POINT_UNDER_CONTROL);
data << uint32(FEL_REAVER_HORDE_CONTROL) << uint32(m_PointOwnedByTeam[FEL_REAVER] == HORDE && m_PointState[FEL_REAVER] == EY_POINT_UNDER_CONTROL);
data << uint32(FEL_REAVER_ALLIANCE_CONTROL) << uint32(m_PointOwnedByTeam[FEL_REAVER] == ALLIANCE && m_PointState[FEL_REAVER] == EY_POINT_UNDER_CONTROL);
data << uint32(FEL_REAVER_UNCONTROL) << uint32(m_PointState[FEL_REAVER] != EY_POINT_UNDER_CONTROL);
data << uint32(BLOOD_ELF_HORDE_CONTROL) << uint32(m_PointOwnedByTeam[BLOOD_ELF] == HORDE && m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL);
data << uint32(BLOOD_ELF_ALLIANCE_CONTROL) << uint32(m_PointOwnedByTeam[BLOOD_ELF] == ALLIANCE && m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL);
data << uint32(BLOOD_ELF_UNCONTROL) << uint32(m_PointState[BLOOD_ELF] != EY_POINT_UNDER_CONTROL);
data << uint32(NETHERSTORM_FLAG) << uint32(m_FlagState == BG_EY_FLAG_STATE_ON_BASE);
data << uint32(0xad2) << uint32(0x1);
data << uint32(0xad1) << uint32(0x1);
data << uint32(0xabe) << uint32(GetTeamScore(HORDE));
data << uint32(0xabd) << uint32(GetTeamScore(ALLIANCE));
data << uint32(0xa05) << uint32(0x8e);
data << uint32(0xaa0) << uint32(0x0);
data << uint32(0xa9f) << uint32(0x0);
data << uint32(0xa9e) << uint32(0x0);
data << uint32(0xc0d) << uint32(0x17b);
}
WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveYard(Player* player)
{
uint32 g_id = 0;
switch (player->GetTeam())
{
case ALLIANCE: g_id = EY_GRAVEYARD_MAIN_ALLIANCE; break;
case HORDE: g_id = EY_GRAVEYARD_MAIN_HORDE; break;
default: return NULL;
}
float distance, nearestDistance;
WorldSafeLocsEntry const* entry = NULL;
WorldSafeLocsEntry const* nearestEntry = NULL;
entry = sWorldSafeLocsStore.LookupEntry(g_id);
nearestEntry = entry;
if (!entry)
{
sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY: Not found the main team graveyard. Graveyard system isn't working!");
return NULL;
}
float plr_x = player->GetPositionX();
float plr_y = player->GetPositionY();
float plr_z = player->GetPositionZ();
distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z);
nearestDistance = distance;
for (uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
if (m_PointOwnedByTeam[i] == player->GetTeam() && m_PointState[i] == EY_POINT_UNDER_CONTROL)
{
entry = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[i].GraveYardId);
if (!entry)
sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY: Not found graveyard: %u", m_CapturingPointTypes[i].GraveYardId);
else
{
distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z);
if (distance < nearestDistance)
{
nearestDistance = distance;
nearestEntry = entry;
}
}
}
}
return nearestEntry;
}
bool BattlegroundEY::IsAllNodesConrolledByTeam(uint32 team) const
{
uint32 count = 0;
for (int i = 0; i < EY_POINTS_MAX; ++i)
if (m_PointOwnedByTeam[i] == team && m_PointState[i] == EY_POINT_UNDER_CONTROL)
++count;
return count == EY_POINTS_MAX;
}
| MistCore/MistCore | src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp | C++ | gpl-2.0 | 44,296 |
/* C type extensions */
typedef unsigned char uint8_t;
typedef char int8_t;
typedef unsigned short int uint16_t;
typedef short int int16_t;
typedef unsigned int uint32_t;
typedef int int32_t;
typedef unsigned long long uint64_t;
typedef long long int64_t;
typedef unsigned long size_t;
typedef void (*funcptr)();
/* disable interrupts, return previous int status / enable interrupts */
#define _di() _interrupt_set(0)
#define _ei(S) _interrupt_set(S)
/* configure, read and write board pins */
#define _port_setup(a, opts) *(volatile uint32_t *)(a) = (opts)
#define _port_read(a) (*(volatile uint32_t *)(a))
#define _port_write(a, v) *(volatile uint32_t *)(a) = (v)
/* memory address map */
#define ADDR_ROM_BASE 0x00000000
#define ADDR_RAM_BASE 0x40000000
#define ADDR_RESERVED_BASE 0x80000000
/* peripheral addresses and irq lines */
#define PERIPHERALS_BASE 0xf0000000
#define IRQ_VECTOR (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x000))
#define IRQ_CAUSE (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x010))
#define IRQ_MASK (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x020))
#define IRQ_STATUS (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x030))
#define IRQ_EPC (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x040))
#define COUNTER (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x050))
#define COMPARE (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x060))
#define COMPARE2 (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x070))
#define EXTIO_IN (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x080))
#define EXTIO_OUT (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x090))
#define EXTIO_DIR (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x0a0))
#define DEBUG_ADDR (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x0d0))
#define UART (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x0e0))
#define UART_DIVISOR (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x0f0))
#define IRQ_COUNTER 0x00000001
#define IRQ_COUNTER_NOT 0x00000002
#define IRQ_COUNTER2 0x00000004
#define IRQ_COUNTER2_NOT 0x00000008
#define IRQ_COMPARE 0x00000010
#define IRQ_COMPARE2 0x00000020
#define IRQ_UART_READ_AVAILABLE 0x00000040
#define IRQ_UART_WRITE_AVAILABLE 0x00000080
#define EXT_IRQ0 0x00010000
#define EXT_IRQ1 0x00020000
#define EXT_IRQ2 0x00040000
#define EXT_IRQ3 0x00080000
#define EXT_IRQ4 0x00100000
#define EXT_IRQ5 0x00200000
#define EXT_IRQ6 0x00400000
#define EXT_IRQ7 0x00800000
#define EXT_IRQ0_NOT 0x01000000
#define EXT_IRQ1_NOT 0x02000000
#define EXT_IRQ2_NOT 0x04000000
#define EXT_IRQ3_NOT 0x08000000
#define EXT_IRQ4_NOT 0x10000000
#define EXT_IRQ5_NOT 0x20000000
#define EXT_IRQ6_NOT 0x40000000
#define EXT_IRQ7_NOT 0x80000000
/* SPI read / write ports */
#define SPI_INPORT 0xf0000080
#define SPI_OUTPORT 0xf0000090
/* SPI interface - EXTIO_OUT */
#define SPI_SCK 0x01
#define SPI_MOSI 0x02
#define SPI_CS0 0x04
#define SPI_CS1 0x08
#define SPI_CS2 0x10
#define SPI_CS3 0x20
/* SPI interface - EXTIO_IN */
#define SPI_MISO 0x02
#define SPI_IRQ0 0x04
#define SPI_IRQ1 0x08
#define SPI_IRQ2 0x10
#define SPI_IRQ3 0x20
/* hardware dependent stuff */
#define STACK_MAGIC 0xb00bb00b
typedef uint32_t context[20];
int32_t _interrupt_set(int32_t s);
void _irq_mask_set(uint32_t mask);
uint32_t _irq_mask_clr(uint32_t mask);
void _restoreexec(context env, int32_t val, int32_t ctask);
/* hardware dependent C library stuff */
int32_t setjmp(context env);
void longjmp(context env, int32_t val);
void putchar(int32_t value);
int32_t kbhit(void);
int32_t getchar(void);
void dputchar(int32_t value);
/* hardware dependent stuff */
void delay_ms(uint32_t msec);
void delay_us(uint32_t usec);
void led_set(uint16_t led, uint8_t val);
uint8_t button_get(uint16_t btn);
uint8_t switch_get(uint16_t sw);
/* hardware dependent basic kernel stuff */
void _hardware_init(void);
void _vm_init(void);
void _task_init(void);
void _sched_init(void);
void _timer_init(void);
void _irq_init(void);
void _device_init(void);
void _set_task_sp(uint16_t task, size_t stack);
size_t _get_task_sp(uint16_t task);
void _set_task_tp(uint16_t task, void (*entry)());
void *_get_task_tp(uint16_t task);
void _timer_reset(void);
void _cpu_idle(void);
uint32_t _readcounter(void);
uint64_t _read_us(void);
void _panic(void);
| eduardocrn/tp1HellFireOs | arch/mips/hf-risc/include/hal.h | C | gpl-2.0 | 4,317 |
/** -*- c++ -*-
* Copyright (C) 2008 Doug Judd (Zvents, Inc.)
*
* This file is part of Hypertable.
*
* Hypertable 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; version 2 of the
* License, or any later version.
*
* Hypertable is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include "Common/Compat.h"
#include "Common/Error.h"
#include "Common/Serialization.h"
#include "BlockCompressionHeaderCommitLog.h"
using namespace Hypertable;
using namespace Serialization;
const size_t BlockCompressionHeaderCommitLog::LENGTH;
BlockCompressionHeaderCommitLog::BlockCompressionHeaderCommitLog()
: BlockCompressionHeader(), m_revision(0) {
}
BlockCompressionHeaderCommitLog::BlockCompressionHeaderCommitLog(
const char *magic, int64_t revision)
: BlockCompressionHeader(magic), m_revision(revision) {
}
void BlockCompressionHeaderCommitLog::encode(uint8_t **bufp) {
uint8_t *base = *bufp;
BlockCompressionHeader::encode(bufp);
encode_i64(bufp, m_revision);
if ((size_t)(*bufp - base) + 2 == length())
write_header_checksum(base, bufp);
}
void BlockCompressionHeaderCommitLog::decode(const uint8_t **bufp,
size_t *remainp) {
const uint8_t *base = *bufp;
BlockCompressionHeader::decode(bufp, remainp);
m_revision = decode_i64(bufp, remainp);
if ((size_t)(*bufp - base) == length() - 2) {
*bufp += 2;
*remainp -= 2;
}
}
| sjhalaz/hypertable | src/cc/Hypertable/Lib/BlockCompressionHeaderCommitLog.cc | C++ | gpl-2.0 | 1,930 |
<?php
$HOME = realpath(dirname(__FILE__)) . "/../../../..";
require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php");
/*
* This file is part of EC-CUBE
*
* Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*
* 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.
*/
/**
* SC_Helper_Purchase::sfUpdateOrderNameCol()のテストクラス.
*
*
* @author Hiroko Tamagawa
* @version $Id$
*/
class SC_Helper_Purchase_sfUpdateOrderNameColTest extends SC_Helper_Purchase_TestBase
{
var $helper;
protected function setUp()
{
parent::setUp();
$this->setUpOrder();
$this->setUpOrderTemp();
$this->setUpPayment();
$this->setUpDeliv();
$this->setUpDelivTime();
$this->setUpShippingOnDb();
$this->helper = new SC_Helper_Purchase();
}
protected function tearDown()
{
parent::tearDown();
}
/////////////////////////////////////////
public function testSfUpdateOrderNameCol_TEMPフラグがOFFの場合_受注テーブルと発送テーブルが更新される()
{
$order_id = '1002';
$this->helper->sfUpdateOrderNameCol($order_id);
$this->expected['shipping'] = array(array('shipping_time' => '午前'));
$this->expected['order'] = array(array('payment_method' => '支払方法1002'));
$this->expected['order_temp'] = array(array('payment_method' => '支払方法1001')); // 変更されていない
$this->actual['shipping'] = $this->objQuery->select(
'shipping_time', 'dtb_shipping', 'order_id = ?', array($order_id)
);
$this->actual['order'] = $this->objQuery->select(
'payment_method', 'dtb_order', 'order_id = ?', array($order_id)
);
$this->actual['order_temp'] = $this->objQuery->select(
'payment_method', 'dtb_order_temp', 'order_temp_id = ?', array($order_id)
);
$this->verify();
}
public function testSfUpdateOrderNameCol_TEMPフラグがONの場合_一時テーブルが更新される()
{
$order_id = '1002';
$this->helper->sfUpdateOrderNameCol($order_id, true);
$this->expected['shipping'] = array(array('shipping_time' => '午後')); // 変更されていない
$this->expected['order'] = array(array('payment_method' => '支払方法1001')); // 変更されていない
$this->expected['order_temp'] = array(array('payment_method' => '支払方法1002'));
$this->actual['shipping'] = $this->objQuery->select(
'shipping_time', 'dtb_shipping', 'order_id = ?', array($order_id)
);
$this->actual['order'] = $this->objQuery->select(
'payment_method', 'dtb_order', 'order_id = ?', array($order_id)
);
$this->actual['order_temp'] = $this->objQuery->select(
'payment_method', 'dtb_order_temp', 'order_temp_id = ?', array($order_id)
);
$this->verify();
}
//////////////////////////////////////////
}
| poego/eccube-2_13 | tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderNameColTest.php | PHP | gpl-2.0 | 3,552 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_55) on Tue Aug 12 22:14:04 PDT 2014 -->
<title>Uses of Class org.apache.nutch.plugin.PluginDescriptor (apache-nutch 1.9 API)</title>
<meta name="date" content="2014-08-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class org.apache.nutch.plugin.PluginDescriptor (apache-nutch 1.9 API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/nutch/plugin/class-use/PluginDescriptor.html" target="_top">Frames</a></li>
<li><a href="PluginDescriptor.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class org.apache.nutch.plugin.PluginDescriptor" class="title">Uses of Class<br>org.apache.nutch.plugin.PluginDescriptor</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation">
<caption><span>Packages that use <a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="#org.apache.nutch.plugin">org.apache.nutch.plugin</a></td>
<td class="colLast">
<div class="block">The Nutch <a href="../../../../../org/apache/nutch/plugin/Pluggable.html" title="interface in org.apache.nutch.plugin"><code>Plugin</code></a> System.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="org.apache.nutch.plugin">
<!-- -->
</a>
<h3>Uses of <a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a> in <a href="../../../../../org/apache/nutch/plugin/package-summary.html">org.apache.nutch.plugin</a></h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation">
<caption><span>Methods in <a href="../../../../../org/apache/nutch/plugin/package-summary.html">org.apache.nutch.plugin</a> that return <a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a></code></td>
<td class="colLast"><span class="strong">Plugin.</span><code><strong><a href="../../../../../org/apache/nutch/plugin/Plugin.html#getDescriptor()">getDescriptor</a></strong>()</code>
<div class="block">Returns the plugin descriptor</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a></code></td>
<td class="colLast"><span class="strong">Extension.</span><code><strong><a href="../../../../../org/apache/nutch/plugin/Extension.html#getDescriptor()">getDescriptor</a></strong>()</code>
<div class="block">return the plugin descriptor.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a></code></td>
<td class="colLast"><span class="strong">PluginRepository.</span><code><strong><a href="../../../../../org/apache/nutch/plugin/PluginRepository.html#getPluginDescriptor(java.lang.String)">getPluginDescriptor</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> pPluginId)</code>
<div class="block">Returns the descriptor of one plugin identified by a plugin id.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a>[]</code></td>
<td class="colLast"><span class="strong">PluginRepository.</span><code><strong><a href="../../../../../org/apache/nutch/plugin/PluginRepository.html#getPluginDescriptors()">getPluginDescriptors</a></strong>()</code>
<div class="block">Returns all registed plugin descriptors.</div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation">
<caption><span>Methods in <a href="../../../../../org/apache/nutch/plugin/package-summary.html">org.apache.nutch.plugin</a> that return types with arguments of type <a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code><a href="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a>></code></td>
<td class="colLast"><span class="strong">PluginManifestParser.</span><code><strong><a href="../../../../../org/apache/nutch/plugin/PluginManifestParser.html#parsePluginFolder(java.lang.String[])">parsePluginFolder</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[] pluginFolders)</code>
<div class="block">Returns a list of all found plugin descriptors.</div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation">
<caption><span>Methods in <a href="../../../../../org/apache/nutch/plugin/package-summary.html">org.apache.nutch.plugin</a> with parameters of type <a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code><a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a></code></td>
<td class="colLast"><span class="strong">PluginRepository.</span><code><strong><a href="../../../../../org/apache/nutch/plugin/PluginRepository.html#getCachedClass(org.apache.nutch.plugin.PluginDescriptor, java.lang.String)">getCachedClass</a></strong>(<a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a> pDescriptor,
<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> className)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/nutch/plugin/Plugin.html" title="class in org.apache.nutch.plugin">Plugin</a></code></td>
<td class="colLast"><span class="strong">PluginRepository.</span><code><strong><a href="../../../../../org/apache/nutch/plugin/PluginRepository.html#getPluginInstance(org.apache.nutch.plugin.PluginDescriptor)">getPluginInstance</a></strong>(<a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a> pDescriptor)</code>
<div class="block">Returns a instance of a plugin.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><span class="strong">Extension.</span><code><strong><a href="../../../../../org/apache/nutch/plugin/Extension.html#setDescriptor(org.apache.nutch.plugin.PluginDescriptor)">setDescriptor</a></strong>(<a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a> pDescriptor)</code>
<div class="block">Sets the plugin descriptor and is only used until model creation at system
start up.</div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing constructors, and an explanation">
<caption><span>Constructors in <a href="../../../../../org/apache/nutch/plugin/package-summary.html">org.apache.nutch.plugin</a> with parameters of type <a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colLast"><code><strong><a href="../../../../../org/apache/nutch/plugin/Extension.html#Extension(org.apache.nutch.plugin.PluginDescriptor, java.lang.String, java.lang.String, java.lang.String, org.apache.hadoop.conf.Configuration, org.apache.nutch.plugin.PluginRepository)">Extension</a></strong>(<a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a> pDescriptor,
<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> pExtensionPoint,
<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> pId,
<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> pExtensionClass,
org.apache.hadoop.conf.Configuration conf,
<a href="../../../../../org/apache/nutch/plugin/PluginRepository.html" title="class in org.apache.nutch.plugin">PluginRepository</a> pluginRepository)</code> </td>
</tr>
<tr class="rowColor">
<td class="colLast"><code><strong><a href="../../../../../org/apache/nutch/plugin/Plugin.html#Plugin(org.apache.nutch.plugin.PluginDescriptor, org.apache.hadoop.conf.Configuration)">Plugin</a></strong>(<a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">PluginDescriptor</a> pDescriptor,
org.apache.hadoop.conf.Configuration conf)</code>
<div class="block">Constructor</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../org/apache/nutch/plugin/PluginDescriptor.html" title="class in org.apache.nutch.plugin">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/nutch/plugin/class-use/PluginDescriptor.html" target="_top">Frames</a></li>
<li><a href="PluginDescriptor.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright © 2014 The Apache Software Foundation</small></p>
</body>
</html>
| aglne/nutcher | nutch-chinese/apache-nutch-1.9/docs/api/org/apache/nutch/plugin/class-use/PluginDescriptor.html | HTML | gpl-2.0 | 14,528 |
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.javafx.event;
import javafx.event.Event;
import javafx.event.EventTarget;
import javafx.event.EventType;
/**
* Used as a wrapper in {@code EventRedirector} to distinquish between normal
* "direct" events and the events "redirected" from the parent dispatcher(s).
*/
public class RedirectedEvent extends Event {
private static final long serialVersionUID = 20121107L;
public static final EventType<RedirectedEvent> REDIRECTED =
new EventType<RedirectedEvent>(Event.ANY, "REDIRECTED");
private final Event originalEvent;
public RedirectedEvent(final Event originalEvent) {
this(originalEvent, null, null);
}
public RedirectedEvent(final Event originalEvent,
final Object source,
final EventTarget target) {
super(source, target, REDIRECTED);
this.originalEvent = originalEvent;
}
public Event getOriginalEvent() {
return originalEvent;
}
}
| teamfx/openjfx-9-dev-rt | modules/javafx.base/src/main/java/com/sun/javafx/event/RedirectedEvent.java | Java | gpl-2.0 | 2,213 |
<?php
/*
* Copyright (c) 2009 Bouncing Minds - Option 3 Ventures Limited
*
* This file is part of the Regions plug-in for Flowplayer.
*
* The Regions plug-in 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.
*
* The Regions plug-in 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 the plug-in. If not, see <http://www.gnu.org/licenses/>.
*/
require_once MAX_PATH . '/plugins/bannerTypeHtml/vastInlineBannerTypeHtml/commonDelivery.php';
if(!is_callable('MAX_adSelect')) {
require_once MAX_PATH . '/lib/max/Delivery/adSelect.php';
}
/**
*
* @package OpenXPlugin
* @subpackage Plugins_BannerTypes
*
* @param array $aBanner The ad-array for the ad to render code for
* @param int $zoneId The zone ID of the zone used to select this ad (if zone-selected)
* @param string $source The "source" parameter passed into the adcall
* @param string $ct0 The 3rd party click tracking URL to redirect to after logging
* @param int $withText Should "text below banner" be appended to the generated code
* @param bookean $logClick Should this click be logged (clicks in admin should not be logged)
* @param boolean $logView Should this view be logged (views in admin should not be logged
* also - 3rd party callback logging should not be logged at view time)
* @param boolean $useAlt Should the backup file be used for this code
* @param string $loc The "current page" URL
* @param string $referer The "referring page" URL
*
* @return string The HTML to display this ad
*/
function Plugin_bannerTypeHtml_vastOverlayBannerTypeHtml_vastOverlayHtml_Delivery_adRender(&$aBanner, $zoneId=0, $source='', $ct0='', $withText=false, $logClick=true, $logView=true, $useAlt=false, $loc, $referer)
{
return deliverVastAd('vastOverlay', $aBanner, $zoneId, $source, $ct0, $withText, $logClick, $logView, $useAlt, $loc, $referer);
}
| adqio/revive-adserver | plugins_repo/openXVideoAds/plugins/bannerTypeHtml/vastOverlayBannerTypeHtml/vastOverlayHtml.delivery.php | PHP | gpl-2.0 | 2,446 |
/*
* Renamed dm_getopt because MySQL keeps putting things in my_ space.
*
* getopt.h - cpp wrapper for dm_getopt to make it look like getopt.
* Copyright 1997, 2000, 2001, 2002, Benjamin Sittler
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef USE_DM_GETOPT
# include <getopt.h>
#endif
#ifdef USE_DM_GETOPT
# ifndef DM_GETOPT_H
/* Our include guard first. */
# define DM_GETOPT_H
/* Try to kill the system getopt.h */
# define _GETOPT_DECLARED
# define _GETOPT_H
# define GETOPT_H
# undef getopt
# define getopt dm_getopt
# undef getopt_long
# define getopt_long dm_getopt_long
# undef getopt_long_only
# define getopt_long_only dm_getopt_long_only
# undef _getopt_internal
# define _getopt_internal _dm_getopt_internal
# undef opterr
# define opterr dm_opterr
# undef optind
# define optind dm_optind
# undef optopt
# define optopt dm_optopt
# undef optarg
# define optarg dm_optarg
# ifdef __cplusplus
extern "C" {
# endif
/* UNIX-style short-argument parser */
extern int dm_getopt(int argc, char * argv[], const char *opts);
extern int dm_optind, dm_opterr, dm_optopt;
extern char *dm_optarg;
struct option {
const char *name;
int has_arg;
int *flag;
int val;
};
/* human-readable values for has_arg */
# undef no_argument
# define no_argument 0
# undef required_argument
# define required_argument 1
# undef optional_argument
# define optional_argument 2
/* GNU-style long-argument parsers */
extern int dm_getopt_long(int argc, char * argv[], const char *shortopts,
const struct option *longopts, int *longind);
extern int dm_getopt_long_only(int argc, char * argv[], const char *shortopts,
const struct option *longopts, int *longind);
extern int _dm_getopt_internal(int argc, char * argv[], const char *shortopts,
const struct option *longopts, int *longind,
int long_only);
# ifdef __cplusplus
}
# endif
# endif /* DM_GETOPT_H */
#endif /* USE_DM_GETOPT */
| moveone/dbmail | src/dm_getopt.h | C | gpl-2.0 | 3,174 |
/*
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
*
* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
*
* Copyright (C) 2009-2010 TrinityZero <http://www.trinityzero.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
*/
#ifndef TRINITY_SINGLETON_H
#define TRINITY_SINGLETON_H
/**
* @brief class Singleton
*/
#include "CreationPolicy.h"
#include "ThreadingModel.h"
#include "ObjectLifeTime.h"
namespace Trinity
{
template
<
typename T,
class ThreadingModel = Trinity::SingleThreaded<T>,
class CreatePolicy = Trinity::OperatorNew<T>,
class LifeTimePolicy = Trinity::ObjectLifeTime<T>
>
class TRINITY_DLL_DECL Singleton
{
public:
static T& Instance();
protected:
Singleton() {};
private:
// Prohibited actions...this does not prevent hijacking.
Singleton(const Singleton &);
Singleton& operator=(const Singleton &);
// Singleton Helpers
static void DestroySingleton();
// data structure
typedef typename ThreadingModel::Lock Guard;
static T *si_instance;
static bool si_destroyed;
};
}
#endif
| brotalnia/TrinityZero | src/framework/Policies/Singleton.h | C | gpl-2.0 | 1,927 |
/* Copyright (C) 2005-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysdep.h>
#include <unistd.h>
/* Consider moving to syscalls.list. */
/* Read the contents of the symbolic link PATH relative to FD into no
more than LEN bytes of BUF. */
ssize_t
readlinkat (fd, path, buf, len)
int fd;
const char *path;
char *buf;
size_t len;
{
return INLINE_SYSCALL (readlinkat, 4, fd, path, buf, len);
}
libc_hidden_def (readlinkat)
| infoburp/glibc | sysdeps/unix/sysv/linux/readlinkat.c | C | gpl-2.0 | 1,298 |
<?php
/**
*
* NOTICE OF LICENSE
*
* This source file is subject to the GNU General Public License (GPL 3)
* that is bundled with this package in the file LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Payone to newer
* versions in the future. If you wish to customize Payone for your
* needs please refer to http://www.payone.de for more information.
*
* @category Payone
* @package Payone_Api
* @subpackage Response
* @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
* @author Matthias Walter <info@noovias.com>
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
* @link http://www.noovias.com
*/
/**
*
* @category Payone
* @package Payone_Api
* @subpackage Response
* @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
* @link http://www.noovias.com
*/
class Payone_Api_Response_Management_GetFile extends Payone_Api_Response_Abstract
{
/**
* @var string
*/
protected $response = NULL;
/**
* @param string $response
*/
public function setResponse($response)
{
$this->response = $response;
}
/**
* @return string
*/
public function getResponse()
{
return $this->response;
}
/**
* @return string
*/
public function __toString()
{
if ($this->isError()) {
$result = parent::__toString();
}
else {
$stringArray = array('status=' . $this->getStatus(), 'data=PDF-Content');
$result = implode('|', $stringArray);
}
return $result;
}
}
| ReichardtIT/modified-inkl-bootstrap-by-karl | includes/external/payone/php/Payone/Api/Response/Management/GetFile.php | PHP | gpl-2.0 | 1,824 |
/*
* Copyright (C) 2007 Google, Inc.
* Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved.
* Author: Brian Swetland <swetland@google.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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.
*
*
* The MSM peripherals are spread all over across 768MB of physical
* space, which makes just having a simple IO_ADDRESS macro to slide
* them into the right virtual location rough. Instead, we will
* provide a master phys->virt mapping for peripherals here.
*
*/
#ifndef __ASM_ARCH_MSM_IOMAP_8X50_H
#define __ASM_ARCH_MSM_IOMAP_8X50_H
/* Physical base address and size of peripherals.
* Ordered by the virtual base addresses they will be mapped at.
*
* MSM_VIC_BASE must be an value that can be loaded via a "mov"
* instruction, otherwise entry-macro.S will not compile.
*
* If you add or remove entries here, you'll want to edit the
* msm_io_desc array in arch/arm/mach-msm/io.c to reflect your
* changes.
*
*/
#define MSM_VIC_BASE IOMEM(0xF8000000)
#define MSM_VIC_PHYS 0xAC000000
#define MSM_VIC_SIZE SZ_4K
#define MSM_CSR_BASE IOMEM(0xF8001000)
#define MSM_CSR_PHYS 0xAC100000
#define MSM_CSR_SIZE SZ_4K
#define MSM_TMR_PHYS MSM_CSR_PHYS
#define MSM_TMR_BASE MSM_CSR_BASE
#define MSM_TMR_SIZE SZ_4K
#define MSM_GPIO1_BASE IOMEM(0xF8003000)
#define MSM_GPIO1_PHYS 0xA9000000
#define MSM_GPIO1_SIZE SZ_4K
#define MSM_GPIO2_BASE IOMEM(0xF8004000)
#define MSM_GPIO2_PHYS 0xA9100000
#define MSM_GPIO2_SIZE SZ_4K
#define MSM_CLK_CTL_BASE IOMEM(0xF8005000)
#define MSM_CLK_CTL_PHYS 0xA8600000
#define MSM_CLK_CTL_SIZE SZ_4K
#define MSM_SIRC_BASE IOMEM(0xF8006000)
#define MSM_SIRC_PHYS 0xAC200000
#define MSM_SIRC_SIZE SZ_4K
#define MSM_SCPLL_BASE IOMEM(0xF8007000)
#define MSM_SCPLL_PHYS 0xA8800000
#define MSM_SCPLL_SIZE SZ_4K
#define MSM_TCSR_BASE IOMEM(0xF8008000)
#define MSM_TCSR_PHYS 0xA8700000
#define MSM_TCSR_SIZE SZ_4K
#define MSM_SHARED_RAM_BASE IOMEM(0xF8100000)
#define MSM_SHARED_RAM_PHYS 0x00100000
#define MSM_SHARED_RAM_SIZE SZ_1M
#define MSM_UART1_PHYS 0xA9A00000
#define MSM_UART1_SIZE SZ_4K
#define MSM_UART2_PHYS 0xA9B00000
#define MSM_UART2_SIZE SZ_4K
#define MSM_UART3_PHYS 0xA9C00000
#define MSM_UART3_SIZE SZ_4K
#define MSM_HSUSB_PHYS 0xA0800000
#define MSM_HSUSB_SIZE SZ_4K
#define MSM_VFE_PHYS 0xA0F00000
#define MSM_VFE_SIZE SZ_1M
#define MSM_MDC_BASE IOMEM(0xF8200000)
#define MSM_MDC_PHYS 0xAA500000
#define MSM_MDC_SIZE SZ_1M
#define MSM_AD5_BASE IOMEM(0xF8300000)
#define MSM_AD5_PHYS 0xAC000000
#define MSM_AD5_SIZE (SZ_1M*13)
#define MSM_GPIOCFG2_BASE IOMEM(0xF9005000)
#define MSM_GPIOCFG2_PHYS 0xA8F00000
#define MSM_GPIOCFG2_SIZE SZ_4K
#define MSM_RAM_CONSOLE_BASE IOMEM(0xF9100000)
#define MSM_RAM_CONSOLE_PHYS 0x2FFC0000
#define MSM_RAM_CONSOLE_SIZE 0x00040000
#endif
| maniacx/android_kernel_htcleo-3.0_old | arch/arm/mach-msm/include/mach/msm_iomap-8x50.h | C | gpl-2.0 | 3,500 |
#
# Makefile for the Linux AX.25 layer.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#
# Note 2! The CFLAGS definition is now in the main makefile...
O_TARGET := ax25.o
O_OBJS := ax25_addr.o ax25_dev.o ax25_iface.o ax25_in.o ax25_ip.o ax25_out.o \
ax25_route.o ax25_std_in.o ax25_std_subr.o ax25_std_timer.o \
ax25_subr.o ax25_timer.o ax25_uid.o
M_OBJS := $(O_TARGET)
OX_OBJS += af_ax25.o
ifeq ($(CONFIG_AX25_DAMA_SLAVE),y)
O_OBJS += ax25_ds_in.o ax25_ds_subr.o ax25_ds_timer.o
endif
ifeq ($(CONFIG_SYSCTL),y)
O_OBJS += sysctl_net_ax25.o
endif
include $(TOPDIR)/Rules.make
tar:
tar -cvf /dev/f1 .
| jur/linux-2.2.1-ps2 | net/ax25/Makefile | Makefile | gpl-2.0 | 768 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="categories" content="prime">
<meta name="product" content="Prime">
<title>Prime Navigation and the Guide</title>
<link rel="stylesheet" type="text/css" href="../support/help.css">
</head>
<script type="text/javascript">
function setTitle()
{
top.document.title = document.title + " - " + parent.parent.WINDOW_TITLE;
}
</script>
<body onload="setTitle();">
<table border=0 cellspacing=0 bgcolor=#dcdcdc width=100%>
<tr><td>
<p><img src="../support/schrodinger_logo.gif" border=0 alt="" align="left" vspace=5 hspace=5 /></p>
</td></tr>
<tr><td>
<h1 class=title><span class="prime">Prime Navigation and the Guide</span></h1>
</td></tr>
</table>
<ul>
<li><a href="#PspNav1">Summary</a></li>
<li><a href="#PspNav2">The Guide</a></li>
<li><a href="#PspNav3">Navigation</a></li>
<li><a href="#PspNav5">Related Topics</a></li>
</ul>
<a name="PspNav1"></a>
<h2>Summary</h2>
<p>Prime Structure Prediction provides more than one way of moving from one step
to another. While the simplest workflow can be navigated by clicking the <span
class="GUI">Next</span> button after completing each step, sometimes it is
useful to go back to previous steps, make different choices, and proceed forward
again, using the <span class="GUI">Next</span> button or the Guide. These more
complex forms of navigation are described in this topic.</p>
<a name="PspNav2"></a>
<h2>The Guide</h2>
<p>The Guide represents the Prime Structure Prediction workflow as a series of
buttons corresponding to steps.
</p>
<p>Your current step location is highlighted in the Guide. Clicking on an
available step button in the Guide brings you to that step. If a step is not
yet available, its button appears dimmed. Available steps include those you have
already passed through in the current run, plus the step immediately beyond your
current location -- your next step.)</p>
<p>Searches and jobs cannot be launched by clicking the steps in the Guide,
which is a display and navigation tool. To launch actions pertaining to a step,
click the appropriate buttons within the step panel.</p>
<a name="PspNav3"></a>
<h2>Navigation</h2>
<p>There are several situations in which you might find it necessary to navigate
to a previous step. For example, if you chose a particular template in Find
Homologs and then after building the structure decide that you want to try and
build on a different template, you can navigate back to Find Homologs and choose
a different homolog. Since you may want to compare your new results with those
produced with the previous template, it is recommended that the workflows using
the different templates be saved as different runs. Select <span
class="GUI">Save As</span> from the <span class="GUI">File</span> menu. This
will create a copy of the current run, allowing you to select a new template and
build on it. You will then be able to compare results from each run.</p>
<p>If you have gone back to a previous step and changed your selections, when
you proceed to the next step, either with the <span class="GUI">Next</span>
button or the Guide, you are presented with three choices, in a dialog box:
<ul>
<li>If you want to proceed with the new selections and clear the original data
in the subsequent steps, click <span class="GUI">Overwrite</span>.
</li>
<li>If you want to discard the changes you made in the previous step, and return
to the next step without changing the original data, click <span
class="GUI">Ignore Changes</span>.
</li>
<li>If you want to go back to the previous step and not proceed forward, click
<span class="GUI">Cancel</span>.
</li>
</ul>
<a name="PspNav5"></a>
<h2>Related Topics</h2>
<ul>
<li><a href="info_help.html">Prime General Help</a></li>
<li><a href="info_layout.html">Prime Structure Prediction Panel Layout and
Use</a></li>
<li><a href="info_runs.html">Using Prime Runs</a></li>
<li><a href="info_jobs.html">Prime Job Options and Results</a></li>
<li><a href="info_menu.html">The Prime Menu Bar</a></li>
<li><a href="toolbar.html">The Prime Toolbar</a></li>
</ul>
<hr />
<table width="100%">
<td><p class="small"><a href="../support/legal_notice.html" target="LegalNoticeWindow">Legal Notice</a></p></td>
<td>
<table align="right">
<td><p class="small">
File: prime/info_nav.html<br />
Last updated: 17 Feb 2012
</p></td>
</table>
</td>
</table>
</body>
</html>
| platinhom/ManualHom | Schrodinger/Schrodinger_2012_docs/maestro/help_Maestro91/prime/info_nav.html | HTML | gpl-2.0 | 4,482 |
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2002-2014 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OpenNMS(R) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/
package org.opennms.web.category;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import org.opennms.core.db.DataSourceFactory;
import org.opennms.core.utils.DBUtils;
import org.opennms.netmgt.config.CategoryFactory;
import org.opennms.netmgt.config.api.CatFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>CategoryModel class.</p>
*
* @author ranger
* @version $Id: $
*/
public class CategoryModel extends Object {
private static final Logger LOG = LoggerFactory.getLogger(CategoryModel.class);
/** The name of the category that includes all services and nodes. */
public static final String OVERALL_AVAILABILITY_CATEGORY = "Overall Service Availability";
/** The singleton instance of this class. */
private static CategoryModel m_instance;
/**
* Return the <code>CategoryModel</code>.
*
* @return a {@link org.opennms.web.category.CategoryModel} object.
* @throws java.io.IOException if any.
*/
public static synchronized CategoryModel getInstance() throws IOException {
if (CategoryModel.m_instance == null) {
CategoryModel.m_instance = new CategoryModel();
}
return m_instance;
}
/** A mapping of category names to category instances. */
private Map<String, Category> m_categoryMap = new HashMap<String, Category>();
/** A reference to the CategoryFactory to get to category definitions. */
private CatFactory m_factory = null;
/**
* Create the instance of the CategoryModel.
*/
private CategoryModel() throws IOException {
CategoryFactory.init();
m_factory = CategoryFactory.getInstance();
LOG.debug("The CategoryModel object was created");
}
/**
* Return the <code>Category</code> instance for the given category name.
* Return null if there is no match for the given name.
*
* @param categoryName a {@link java.lang.String} object.
* @return a {@link org.opennms.web.category.Category} object.
*/
public Category getCategory(String categoryName) {
if (categoryName == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
return m_categoryMap.get(categoryName);
}
/**
* Return a mapping of category names to instances.
*
* @return a {@link java.util.Map} object.
*/
public Map<String, Category> getCategoryMap() {
return Collections.unmodifiableMap(new HashMap<String, Category>(m_categoryMap));
}
/**
* Look up the category definition and return the category's normal
* threshold.
*
* @param categoryName a {@link java.lang.String} object.
* @return a double.
*/
public double getCategoryNormalThreshold(String categoryName) {
if (categoryName == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
return m_factory.getNormal(categoryName);
}
/**
* Look up the category definition and return the category's warning
* threshold.
*
* @param categoryName a {@link java.lang.String} object.
* @return a double.
*/
public double getCategoryWarningThreshold(String categoryName) {
if (categoryName == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
return m_factory.getWarning(categoryName);
}
/**
* Look up the category definition and return the category's description.
*
* @param categoryName a {@link java.lang.String} object.
* @return a {@link java.lang.String} object.
*/
public String getCategoryComment(final String categoryName) {
if (categoryName == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
String comment = null;
m_factory.getReadLock().lock();
try {
org.opennms.netmgt.config.categories.Category category = m_factory.getCategory(categoryName);
if (category != null) {
comment = category.getComment().orElse(null);
}
} finally {
m_factory.getReadLock().unlock();
}
return comment;
}
/**
* Update a category with new values.
*
* @param rtcCategory a {@link org.opennms.netmgt.xml.rtc.Category} object.
*/
public void updateCategory(final org.opennms.netmgt.xml.rtc.Category rtcCategory) {
if (rtcCategory == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
final String categoryName = rtcCategory.getCatlabel();
m_factory.getWriteLock().lock();
try {
org.opennms.netmgt.config.categories.Category categoryDef = m_factory.getCategory(categoryName);
org.opennms.web.category.Category category = new org.opennms.web.category.Category(categoryDef, rtcCategory, new Date());
synchronized (m_categoryMap) {
m_categoryMap.put(categoryName, category);
}
} finally {
m_factory.getWriteLock().unlock();
}
LOG.debug("{} was updated", categoryName);
}
/**
* Return the availability percentage for all managed services on the given
* node for the last 24 hours. If there are no managed services on this
* node, then a value of -1 is returned.
*
* @param nodeId a int.
* @return a double.
* @throws java.sql.SQLException if any.
*/
public static double getNodeAvailability(int nodeId) throws SQLException {
Calendar cal = new GregorianCalendar();
Date now = cal.getTime();
cal.add(Calendar.DATE, -1);
Date yesterday = cal.getTime();
return getNodeAvailability(nodeId, yesterday, now);
}
/**
* Return the availability percentage for all managed services on the given
* node from the given start time until the given end time. If there are no
* managed services on this node, then a value of -1 is returned.
*
* @param nodeId a int.
* @param start a {@link java.util.Date} object.
* @param end a {@link java.util.Date} object.
* @return a double.
* @throws java.sql.SQLException if any.
*/
static double getNodeAvailability(int nodeId, Date start, Date end) throws SQLException {
if (start == null || end == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
if (end.before(start)) {
throw new IllegalArgumentException("Cannot have an end time before the start time.");
}
if (end.equals(start)) {
throw new IllegalArgumentException("Cannot have an end time equal to the start time.");
}
double avail = -1;
final DBUtils d = new DBUtils(CategoryModel.class);
try {
Connection conn = DataSourceFactory.getInstance().getConnection();
d.watch(conn);
PreparedStatement stmt = conn.prepareStatement("select getManagePercentAvailNodeWindow(?, ?, ?) as avail");
d.watch(stmt);
stmt.setInt(1, nodeId);
// yes, these are supposed to be backwards, the end time first
stmt.setTimestamp(2, new Timestamp(end.getTime()));
stmt.setTimestamp(3, new Timestamp(start.getTime()));
ResultSet rs = stmt.executeQuery();
d.watch(rs);
if (rs.next()) {
avail = rs.getDouble("avail");
}
} catch (final SQLException e) {
LOG.warn("Failed to get node availability for nodeId {}", nodeId, e);
} finally {
d.cleanUp();
}
return avail;
}
/**
* Return the availability percentage for all managed services on the given
* interface for the last 24 hours. If there are no managed services on this
* interface, then a value of -1 is returned.
*
* @param nodeId a int.
* @param ipAddr a {@link java.lang.String} object.
* @return a double.
* @throws java.sql.SQLException if any.
*/
public static double getInterfaceAvailability(int nodeId, String ipAddr) throws SQLException {
if (ipAddr == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
Calendar cal = new GregorianCalendar();
Date now = cal.getTime();
cal.add(Calendar.DATE, -1);
Date yesterday = cal.getTime();
return getInterfaceAvailability(nodeId, ipAddr, yesterday, now);
}
/**
* Return the availability percentage for all managed services on the given
* interface from the given start time until the given end time. If there
* are no managed services on this interface, then a value of -1 is
* returned.
*
* @param nodeId a int.
* @param ipAddr a {@link java.lang.String} object.
* @param start a {@link java.util.Date} object.
* @param end a {@link java.util.Date} object.
* @return a double.
* @throws java.sql.SQLException if any.
*/
static double getInterfaceAvailability(int nodeId, String ipAddr, Date start, Date end) throws SQLException {
if (ipAddr == null || start == null || end == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
if (end.before(start)) {
throw new IllegalArgumentException("Cannot have an end time before the start time.");
}
if (end.equals(start)) {
throw new IllegalArgumentException("Cannot have an end time equal to the start time.");
}
double avail = -1;
final DBUtils d = new DBUtils(CategoryModel.class);
try {
Connection conn = DataSourceFactory.getInstance().getConnection();
d.watch(conn);
PreparedStatement stmt = conn.prepareStatement("select getManagePercentAvailIntfWindow(?, ?, ?, ?) as avail");
d.watch(stmt);
stmt.setInt(1, nodeId);
stmt.setString(2, ipAddr);
// yes, these are supposed to be backwards, the end time first
stmt.setTimestamp(3, new Timestamp(end.getTime()));
stmt.setTimestamp(4, new Timestamp(start.getTime()));
ResultSet rs = stmt.executeQuery();
d.watch(rs);
if (rs.next()) {
avail = rs.getDouble("avail");
}
} catch (final SQLException e) {
LOG.warn("Failed to get interface availability for nodeId {}, interface {}", nodeId, ipAddr, e);
} finally {
d.cleanUp();
}
return avail;
}
/**
* Return the availability percentage for a managed service for the last 24
* hours. If the service is not managed, then a value of -1 is returned.
*
* @param nodeId a int.
* @param ipAddr a {@link java.lang.String} object.
* @param serviceId a int.
* @return a double.
* @throws java.sql.SQLException if any.
*/
public static double getServiceAvailability(int nodeId, String ipAddr, int serviceId) throws SQLException {
if (ipAddr == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
Calendar cal = new GregorianCalendar();
Date now = cal.getTime();
cal.add(Calendar.DATE, -1);
Date yesterday = cal.getTime();
return getServiceAvailability(nodeId, ipAddr, serviceId, yesterday, now);
}
/**
* Return the availability percentage for a managed service from the given
* start time until the given end time. If the service is not managed, then
* a value of -1.0 is returned.
*
* @param nodeId a int.
* @param ipAddr a {@link java.lang.String} object.
* @param serviceId a int.
* @param start a {@link java.util.Date} object.
* @param end a {@link java.util.Date} object.
* @return a double.
* @throws java.sql.SQLException if any.
*/
static double getServiceAvailability(int nodeId, String ipAddr, int serviceId, Date start, Date end) throws SQLException {
if (ipAddr == null || start == null || end == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
if (end.before(start)) {
throw new IllegalArgumentException("Cannot have an end time before the start time.");
}
if (end.equals(start)) {
throw new IllegalArgumentException("Cannot have an end time equal to the start time.");
}
final DBUtils d = new DBUtils(CategoryModel.class);
try {
Connection conn = DataSourceFactory.getInstance().getConnection();
d.watch(conn);
PreparedStatement stmt = conn.prepareStatement("select getPercentAvailabilityInWindow(ifservices.id, ?, ?) as avail from ifservices, ipinterface, node where ifservices.ipInterfaceId = ipinterface.id and ipInterface.nodeid = node.nodeid and ifservices.status='A' and ipinterface.ismanaged='M' and node.nodetype='A' and node.nodeid=? and ipInterface.ipaddr=? and ifServices.serviceid=?");
d.watch(stmt);
// yes, these are supposed to be backwards, the end time first
stmt.setTimestamp(1, new Timestamp(end.getTime()));
stmt.setTimestamp(2, new Timestamp(start.getTime()));
stmt.setInt(3, nodeId);
stmt.setString(4, ipAddr);
stmt.setInt(5, serviceId);
ResultSet rs = stmt.executeQuery();
d.watch(rs);
if (rs.next()) {
return rs.getDouble("avail");
}
} catch (final SQLException e) {
LOG.warn("Failed to get service availability for nodeId {}, interface {}, serviceId {}", nodeId, ipAddr, serviceId, e);
} finally {
d.cleanUp();
}
return -1.0;
}
}
| jeffgdotorg/opennms | opennms-web-api/src/main/java/org/opennms/web/category/CategoryModel.java | Java | gpl-2.0 | 15,627 |
/* COVERAGE: unshare */
#define _GNU_SOURCE
#include <sched.h>
int main()
{
unshare(CLONE_FILES);
//staptest// unshare (CLONE_FILES) = 0
unshare(-1);
//staptest// unshare (CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_PTRACE|CLONE_VFORK|CLONE_PARENT|CLONE_THREAD|CLONE_NEWNS|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID[^)]+) = -NNNN
return 0;
}
| serhei/stap-experiments | testsuite/systemtap.syscall/unshare.c | C | gpl-2.0 | 376 |
/*!
* VisualEditor ContentEditable View class.
*
* @copyright 2011-2014 VisualEditor Team and others; see http://ve.mit-license.org
*/
/**
* Generic base class for CE views.
*
* @abstract
* @extends OO.ui.Element
* @mixins OO.EventEmitter
*
* @constructor
* @param {ve.dm.Model} model Model to observe
* @param {Object} [config] Configuration options
*/
ve.ce.View = function VeCeView( model, config ) {
// Setting this property before calling the parent constructor allows overridden #getTagName
// methods in view classes to have access to the model when they are called for the first time
// inside of OO.ui.Element
this.model = model;
// Parent constructor
OO.ui.Element.call( this, config );
// Mixin constructors
OO.EventEmitter.call( this );
// Properties
this.live = false;
// Events
this.connect( this, {
setup: 'onSetup',
teardown: 'onTeardown'
} );
// Initialization
this.renderAttributes();
};
/* Inheritance */
OO.inheritClass( ve.ce.View, OO.ui.Element );
OO.mixinClass( ve.ce.View, OO.EventEmitter );
/* Events */
/**
* @event setup
*/
/**
* @event teardown
*/
/* Static members */
/**
* Allowed attributes for DOM elements, in the same format as ve.dm.Model#storeHtmlAttributes
*
* This list includes attributes that are generally safe to include in HTML loaded from a
* foreign source and displaying it inside the browser. It doesn't include any event attributes,
* for instance, which would allow arbitrary JavaScript execution. This alone is not enough to
* make HTML safe to display, but it helps.
*
* TODO: Rather than use a single global list, set these on a per-view basis to something that makes
* sense for that view in particular.
*
* @static
* @property {boolean|string|RegExp|Array|Object}
* @inheritable
*/
ve.ce.View.static.renderHtmlAttributes = [
'abbr', 'about', 'align', 'alt', 'axis', 'bgcolor', 'border', 'cellpadding', 'cellspacing',
'char', 'charoff', 'cite', 'class', 'clear', 'color', 'colspan', 'datatype', 'datetime',
'dir', 'face', 'frame', 'headers', 'height', 'href', 'id', 'itemid', 'itemprop', 'itemref',
'itemscope', 'itemtype', 'lang', 'noshade', 'nowrap', 'property', 'rbspan', 'rel',
'resource', 'rev', 'rowspan', 'rules', 'scope', 'size', 'span', 'src', 'start', 'style',
'summary', 'title', 'type', 'typeof', 'valign', 'value', 'width'
];
/* Methods */
/**
* Get an HTML document from the model, to use for URL resolution.
*
* The default implementation returns null; subclasses should override this if they can provide
* a resolution document.
*
* @see #getResolvedAttribute
* @returns {HTMLDocument|null} HTML document to use for resolution, or null if not available
*/
ve.ce.View.prototype.getModelHtmlDocument = function () {
return null;
};
/**
* Handle setup event.
*
* @method
*/
ve.ce.View.prototype.onSetup = function () {
this.$element.data( 'view', this );
};
/**
* Handle teardown event.
*
* @method
*/
ve.ce.View.prototype.onTeardown = function () {
this.$element.removeData( 'view' );
};
/**
* Get the model the view observes.
*
* @method
* @returns {ve.dm.Model} Model the view observes
*/
ve.ce.View.prototype.getModel = function () {
return this.model;
};
/**
* Check if the view is attached to the live DOM.
*
* @method
* @returns {boolean} View is attached to the live DOM
*/
ve.ce.View.prototype.isLive = function () {
return this.live;
};
/**
* Set live state.
*
* @method
* @param {boolean} live The view has been attached to the live DOM (use false on detach)
* @fires setup
* @fires teardown
*/
ve.ce.View.prototype.setLive = function ( live ) {
this.live = live;
if ( this.live ) {
this.emit( 'setup' );
} else {
this.emit( 'teardown' );
}
};
/**
* Check if the node is inside a contentEditable node
*
* @return {boolean} Node is inside a contentEditable node
*/
ve.ce.View.prototype.isInContentEditable = function () {
var node = this.$element[0].parentNode;
while ( node && node.contentEditable === 'inherit' ) {
node = node.parentNode;
}
return !!( node && node.contentEditable === 'true' );
};
/**
* Render an HTML attribute list onto this.$element
*
* If no attributeList is given, the attribute list stored in the linear model will be used.
*
* @param {Object[]} [attributeList] HTML attribute list, see ve.dm.Converter#buildHtmlAttributeList
*/
ve.ce.View.prototype.renderAttributes = function ( attributeList ) {
ve.dm.Converter.renderHtmlAttributeList(
attributeList || this.model.getHtmlAttributes(),
this.$element,
this.constructor.static.renderHtmlAttributes,
true // computed attributes
);
};
/**
* Get a resolved URL from a model attribute.
*
* @abstract
* @method
* @param {string} key Attribute name whose value is a URL
* @returns {string} URL resolved according to the document's base
*/
ve.ce.View.prototype.getResolvedAttribute = function ( key ) {
var plainValue = this.model.getAttribute( key ),
doc = this.getModelHtmlDocument();
return doc && typeof plainValue === 'string' ? ve.resolveUrl( plainValue, doc ) : plainValue;
};
| felixonmars/app | extensions/VisualEditor/lib/ve/src/ce/ve.ce.View.js | JavaScript | gpl-2.0 | 5,092 |
import React from "react";
import PropTypes from "prop-types";
import Box from "grommet/components/Box";
import Heading from "grommet/components/Heading";
import Anchor from "../partials/Anchor";
import Label from "grommet/components/Label";
import Paragraph from "grommet/components/Paragraph";
import LinkIcon from "grommet/components/icons/base/Link";
import ApiIcon from "./img/api.svg";
import CultureIcon from "./img/cultures.svg";
import TerminalIcon from "./img/terminal.svg";
class Documentation extends React.Component {
render() {
return (
<span ref={this.props.scrollToRef}>
<Box
colorIndex="neutral-1"
style={{}}
pad="medium"
align="center"
justify="center"
>
<Box colorIndex="neutral-1" align="center" margin="large">
<Heading>Documentation</Heading>
</Box>
<Box
margin={{ top: "large", bottom: "large" }}
direction="row"
flex
justify="between"
pad={{ vertical: "medium" }}
size={{ width: "xxlarge" }}
responsive={false}
>
<Box>
<Box
flex={false}
size={{ width: "small", height: "medium" }}
justify="between"
colorIndex="neutral-1"
align="center"
>
<Box margin={{ bottom: "medium" }}>
<CultureIcon height="50px" />
</Box>
<Heading tag="h2">User Guide</Heading>
<Paragraph align="center">
Find out how you can use the CAP service to capture, preserve
and reuse your analysis through user guides and stories.
</Paragraph>
<Anchor href="/docs/general/" target="_blank">
<Box pad="small" colorIndex="neutral-1-a" separator="all">
<Label margin="none">
General Docs <LinkIcon size="xsmall" />
</Label>
</Box>
</Anchor>
</Box>
</Box>
<Box>
<Box
align="center"
flex={false}
size={{ width: "small", height: "medium" }}
justify="between"
margin={{ horizontal: "medium" }}
>
<Box margin={{ bottom: "medium" }}>
<TerminalIcon height="50px" />
</Box>
<Heading tag="h2">CLI Client</Heading>
<Paragraph align="center">
Learn how to interact with your analysis workspace via the
command line interface, to make the preservation process part
of your everyday work.
</Paragraph>
<Anchor href="/docs/cli/" target="_blank">
<Box pad="small" colorIndex="neutral-1-a" separator="all">
<Label margin="none">
CAP-client Guide <LinkIcon size="xsmall" />
</Label>
</Box>
</Anchor>
</Box>
</Box>
<Box>
<Box
align="center"
flex={false}
size={{ width: "small", height: "medium" }}
justify="between"
>
<Box margin={{ bottom: "medium" }}>
<ApiIcon height="50px" />
</Box>
<Heading tag="h2">RESTful API</Heading>
<Paragraph align="center">
Try using our RESTful interface, to integrate CAP with your
daily tools and services using HTTP requests.
</Paragraph>
<Anchor href="/docs/api/" target="_blank">
<Box pad="small" colorIndex="neutral-1-a" separator="all">
<Label margin="none">
API Guides & Docs <LinkIcon size="xsmall" />
</Label>
</Box>
</Anchor>
</Box>
</Box>
</Box>
</Box>
</span>
);
}
}
Documentation.propTypes = {
scrollToRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({ current: PropTypes.instanceOf(Element) })
])
};
export default Documentation;
| pamfilos/data.cern.ch | ui/cap-react/src/components/welcome/Documentation.js | JavaScript | gpl-2.0 | 4,448 |
<?php
//
// ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
// SOFTWARE NAME: eZ Flow
// SOFTWARE RELEASE: 5.0.0
// COPYRIGHT NOTICE: Copyright (C) 1999-2012 eZ Systems AS
// SOFTWARE LICENSE: GNU General Public License v2.0
// NOTICE: >
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2.0 of the GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of version 2.0 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.
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
$FunctionList = array();
$FunctionList['waiting'] = array( 'name' => 'waiting',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'extension/ezflow/modules/ezflow/functioncollection.php',
'class' => 'eZFlowFunctionCollection',
'method' => 'fetchWaiting' ),
'parameter_type' => 'standard',
'parameters' => array(
array( 'name' => 'block_id',
'type' => 'string',
'required' => true ),
) );
$FunctionList['valid'] = array( 'name' => 'valid',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'extension/ezflow/modules/ezflow/functioncollection.php',
'class' => 'eZFlowFunctionCollection',
'method' => 'fetchValid' ),
'parameter_type' => 'standard',
'parameters' => array(
array( 'name' => 'block_id',
'type' => 'string',
'required' => true ),
) );
$FunctionList['archived'] = array( 'name' => 'archived',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'extension/ezflow/modules/ezflow/functioncollection.php',
'class' => 'eZFlowFunctionCollection',
'method' => 'fetchArchived' ),
'parameter_type' => 'standard',
'parameters' => array(
array( 'name' => 'block_id',
'type' => 'string',
'required' => true ),
) );
$FunctionList['valid_nodes'] = array( 'name' => 'valid_nodes',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'extension/ezflow/modules/ezflow/functioncollection.php',
'class' => 'eZFlowFunctionCollection',
'method' => 'fetchValidNodes' ),
'parameter_type' => 'standard',
'parameters' => array(
array( 'name' => 'block_id',
'type' => 'string',
'required' => true ),
) );
$FunctionList['block'] = array( 'name' => 'block',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'extension/ezflow/modules/ezflow/functioncollection.php',
'class' => 'eZFlowFunctionCollection',
'method' => 'fetchBlock' ),
'parameter_type' => 'standard',
'parameters' => array(
array( 'name' => 'block_id',
'type' => 'string',
'required' => true ),
) );
$FunctionList['allowed_zones'] = array( 'name' => 'allowed_zones',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'extension/ezflow/modules/ezflow/functioncollection.php',
'class' => 'eZFlowFunctionCollection',
'method' => 'fetchAllowedZones' ),
'parameter_type' => 'standard',
'parameters' => array() );
?> | alafon/ezpublish-community-built | ezpublish_legacy/var/storage/packages/eZ-systems/ezflow_extension/ezextension/ezflow/modules/ezflow/function_definition.php | PHP | gpl-2.0 | 5,710 |
<?php
require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php');
/**
* UniqueTest filter form base class.
*
* @package filters
* @subpackage UniqueTest *
* @version SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $
*/
class BaseUniqueTestFormFilter extends BaseFormFilterDoctrine
{
public function setup()
{
$this->setWidgets(array(
'unique_test1' => new sfWidgetFormFilterInput(),
'unique_test2' => new sfWidgetFormFilterInput(),
'unique_test3' => new sfWidgetFormFilterInput(),
'unique_test4' => new sfWidgetFormFilterInput(),
));
$this->setValidators(array(
'unique_test1' => new sfValidatorPass(array('required' => false)),
'unique_test2' => new sfValidatorPass(array('required' => false)),
'unique_test3' => new sfValidatorPass(array('required' => false)),
'unique_test4' => new sfValidatorPass(array('required' => false)),
));
$this->widgetSchema->setNameFormat('unique_test_filters[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
public function getModelName()
{
return 'UniqueTest';
}
public function getFields()
{
return array(
'id' => 'Number',
'unique_test1' => 'Text',
'unique_test2' => 'Text',
'unique_test3' => 'Text',
'unique_test4' => 'Text',
);
}
} | gease/abajour | lib/symfony/plugins/sfDoctrinePlugin/test/functional/fixtures/lib/filter/doctrine/base/BaseUniqueTestFormFilter.class.php | PHP | gpl-2.0 | 1,456 |
<?php
/**
* Sidebar Left
*
* Content for our sidebar, provides prompt for logged in users to create widgets
*
* @package Openstrap
* @subpackage Openstrap
* @since Openstrap 0.1
*/
?>
<?php $col = openstrap_get_sidebar_cols(); ?>
<!-- Sidebar -->
<div class="col-md-<?php echo $col;?> sidebar-left" >
<?php if ( dynamic_sidebar('openstrap_sidebar_left') ) : elseif( current_user_can( 'edit_theme_options' ) ) : ?>
<h5><?php _e( 'No widgets found.', 'openstrap' ); ?></h5>
<p><?php printf( __( 'It seems you don\'t have any widgets in your sidebar! Would you like to %s now?', 'openstrap' ), '<a href=" '. get_admin_url( '', 'widgets.php' ) .' ">populate your sidebar</a>' ); ?></p>
<?php endif; ?>
</div>
<!-- End Sidebar --> | IdeasFactoryPL/stef-pol | wp-content/themes/openstrap/sidebar-left.php | PHP | gpl-2.0 | 742 |
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "engines/advancedDetector.h"
#include "base/plugins.h"
#include "toon/toon.h"
static const PlainGameDescriptor toonGames[] = {
{ "toon", "Toonstruck" },
{ 0, 0 }
};
static const DebugChannelDef debugFlagList[] = {
{Toon::kDebugAnim, "Anim", "Animation debug level"},
{Toon::kDebugCharacter, "Character", "Character debug level"},
{Toon::kDebugAudio, "Audio", "Audio debug level"},
{Toon::kDebugHotspot, "Hotspot", "Hotspot debug level"},
{Toon::kDebugFont, "Font", "Font debug level"},
{Toon::kDebugPath, "Path", "Path debug level"},
{Toon::kDebugMovie, "Movie", "Movie debug level"},
{Toon::kDebugPicture, "Picture", "Picture debug level"},
{Toon::kDebugResource, "Resource", "Resource debug level"},
{Toon::kDebugState, "State", "State debug level"},
{Toon::kDebugTools, "Tools", "Tools debug level"},
{Toon::kDebugText, "Text", "Text debug level"},
DEBUG_CHANNEL_END
};
namespace Toon {
static const ADGameDescription gameDescriptions[] = {
{
"toon", "",
{
{"local.pak", 0, "3290209ef9bc92692108dd2f45df0736", 3237611},
{"arcaddbl.svl", 0, "c418478cd2833c7c983799f948af41ac", 7844688},
{"study.svl", 0, "281efa3f33f6712c0f641a605f4d40fd", 2511090},
AD_LISTEND
},
Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GUIO_NOMIDI)
},
{
"toon", "",
{
{"local.pak", 0, "517132c3575b38806d1e7b6f59848072", 3224044},
{"arcaddbl.svl", 0, "ff74008827b62fbef1f46f104c438e44", 9699256},
{"study.svl", 0, "df056b94ea83f1ed92a539cf636053ab", 2542668},
AD_LISTEND
},
Common::FR_FRA, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GUIO_NOMIDI)
},
{
"toon", "",
{
{"local.pak", 0, "bf5da4c03f78ffbd643f12122319366e", 3250841},
{"arcaddbl.svl", 0, "7a0d74f4d66d1c722b946abbeb0834ef", 9122249},
{"study.svl", 0, "72fe96a9e10967d3138e918295babc42", 2910283},
AD_LISTEND
},
Common::DE_DEU, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GUIO_NOMIDI)
},
{
"toon", "",
{
{"local.pak", 0, "e8645168a247e2abdbfc2f9fa9d1c0fa", 3232222},
{"arcaddbl.svl", 0, "7893ac4cc78d51356baa058bbee7aa28", 8275016},
{"study.svl", 0, "b6b1ee2d9d94d53d305856039ab7bde7", 2634620},
AD_LISTEND
},
Common::ES_ESP, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GUIO_NOMIDI)
},
{
"toon", "",
{
{"local.pak", 0, "48ec60709bebbdeff791d55ee18ec910", 3417846},
{"arcaddbl.svl", 0, "1d1b96e317e03ffd3874a8ebe59556f3", 6246232},
{"study.svl", 0, "d4aff126ee27be3c3d25e2996369d7cb", 2324368},
},
Common::RU_RUS, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GUIO_NOMIDI)
},
{
"toon", "Demo",
{
{"local.pak", 0, "bf5da4c03f78ffbd643f12122319366e", 3250841},
{"wacexdbl.emc", 0, "cfbc2156a31b294b038204888407ebc8", 6974},
{"generic.svl", 0, "5eb99850ada22f0b8cf6392262d4dd07", 9404599},
AD_LISTEND
},
Common::DE_DEU, Common::kPlatformDOS, ADGF_DEMO, GUIO1(GUIO_NOMIDI)
},
{
"toon", "Demo",
{
{"local.pak", 0, "8ef3368078b9ea70b305c04db826feea", 2680573},
{"generic.svl", 0, "5c42724bb93b360dca7044d6b7ef26e5", 7739319},
AD_LISTEND
},
Common::EN_ANY, Common::kPlatformDOS, ADGF_DEMO, GUIO1(GUIO_NOMIDI)
},
{
// English 2-CD "Sold out" release
"toon", "",
{
{"local.pak", 0, "3290209ef9bc92692108dd2f45df0736", 3237611},
{"generic.svl", 0, "331eead1d20af7ee809a9e2f35b8362f", 6945180},
AD_LISTEND
},
Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GUIO_NOMIDI)
},
AD_TABLE_END_MARKER
};
static const ADFileBasedFallback fileBasedFallback[] = {
{ &gameDescriptions[0], { "local.pak", "arcaddbl.svl", "study.svl", 0 } }, // default to english version
{ 0, { 0 } }
};
} // End of namespace Toon
static const char * const directoryGlobs[] = {
"misc",
"act1",
"arcaddbl",
"act2",
"study",
0
};
class ToonMetaEngineDetection : public AdvancedMetaEngineDetection {
public:
ToonMetaEngineDetection() : AdvancedMetaEngineDetection(Toon::gameDescriptions, sizeof(ADGameDescription), toonGames) {
_maxScanDepth = 3;
_directoryGlobs = directoryGlobs;
}
ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist, ADDetectedGameExtraInfo **extra) const override {
return detectGameFilebased(allFiles, Toon::fileBasedFallback);
}
const char *getEngineId() const override {
return "toon";
}
const char *getName() const override {
return "Toonstruck";
}
const char *getOriginalCopyright() const override {
return "Toonstruck (C) 1996 Virgin Interactive";
}
const DebugChannelDef *getDebugChannels() const override {
return debugFlagList;
}
};
REGISTER_PLUGIN_STATIC(TOON_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, ToonMetaEngineDetection);
| vanfanel/scummvm | engines/toon/detection.cpp | C++ | gpl-2.0 | 5,591 |
/*
* DO NOT EDIT. THIS FILE IS GENERATED FROM e:/xr19rel/WINNT_5.2_Depend/mozilla/embedding/browser/webBrowser/nsIWebBrowserPrint.idl
*/
#ifndef __gen_nsIWebBrowserPrint_h__
#define __gen_nsIWebBrowserPrint_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
class nsIDOMWindow; /* forward declaration */
class nsIPrintSettings; /* forward declaration */
class nsIWebProgressListener; /* forward declaration */
/* starting interface: nsIWebBrowserPrint */
#define NS_IWEBBROWSERPRINT_IID_STR "9a7ca4b0-fbba-11d4-a869-00105a183419"
#define NS_IWEBBROWSERPRINT_IID \
{0x9a7ca4b0, 0xfbba, 0x11d4, \
{ 0xa8, 0x69, 0x00, 0x10, 0x5a, 0x18, 0x34, 0x19 }}
/**
* nsIWebBrowserPrint corresponds to the main interface
* for printing an embedded Gecko web browser window/document
*
* @status FROZEN
*/
class NS_NO_VTABLE NS_SCRIPTABLE nsIWebBrowserPrint : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEBBROWSERPRINT_IID)
/**
* PrintPreview Navigation Constants
*/
enum { PRINTPREVIEW_GOTO_PAGENUM = 0 };
enum { PRINTPREVIEW_PREV_PAGE = 1 };
enum { PRINTPREVIEW_NEXT_PAGE = 2 };
enum { PRINTPREVIEW_HOME = 3 };
enum { PRINTPREVIEW_END = 4 };
/**
* Returns a "global" PrintSettings object
* Creates a new the first time, if one doesn't exist.
*
* Then returns the same object each time after that.
*
* Initializes the globalPrintSettings from the default printer
*/
/* readonly attribute nsIPrintSettings globalPrintSettings; */
NS_SCRIPTABLE NS_IMETHOD GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings) = 0;
/**
* Returns a pointer to the PrintSettings object that
* that was passed into either "print" or "print preview"
*
* This enables any consumers of the interface to have access
* to the "current" PrintSetting at later points in the execution
*/
/* readonly attribute nsIPrintSettings currentPrintSettings; */
NS_SCRIPTABLE NS_IMETHOD GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSettings) = 0;
/**
* Returns a pointer to the current child DOMWindow
* that is being print previewed. (FrameSet Frames)
*
* Returns null if parent document is not a frameset or the entire FrameSet
* document is being print previewed
*
* This enables any consumers of the interface to have access
* to the "current" child DOMWindow at later points in the execution
*/
/* readonly attribute nsIDOMWindow currentChildDOMWindow; */
NS_SCRIPTABLE NS_IMETHOD GetCurrentChildDOMWindow(nsIDOMWindow * *aCurrentChildDOMWindow) = 0;
/**
* Returns whether it is in Print mode
*/
/* readonly attribute boolean doingPrint; */
NS_SCRIPTABLE NS_IMETHOD GetDoingPrint(PRBool *aDoingPrint) = 0;
/**
* Returns whether it is in Print Preview mode
*/
/* readonly attribute boolean doingPrintPreview; */
NS_SCRIPTABLE NS_IMETHOD GetDoingPrintPreview(PRBool *aDoingPrintPreview) = 0;
/**
* This returns whether the current document is a frameset document
*/
/* readonly attribute boolean isFramesetDocument; */
NS_SCRIPTABLE NS_IMETHOD GetIsFramesetDocument(PRBool *aIsFramesetDocument) = 0;
/**
* This returns whether the current document is a frameset document
*/
/* readonly attribute boolean isFramesetFrameSelected; */
NS_SCRIPTABLE NS_IMETHOD GetIsFramesetFrameSelected(PRBool *aIsFramesetFrameSelected) = 0;
/**
* This returns whether there is an IFrame selected
*/
/* readonly attribute boolean isIFrameSelected; */
NS_SCRIPTABLE NS_IMETHOD GetIsIFrameSelected(PRBool *aIsIFrameSelected) = 0;
/**
* This returns whether there is a "range" selection
*/
/* readonly attribute boolean isRangeSelection; */
NS_SCRIPTABLE NS_IMETHOD GetIsRangeSelection(PRBool *aIsRangeSelection) = 0;
/**
* This returns the total number of pages for the Print Preview
*/
/* readonly attribute long printPreviewNumPages; */
NS_SCRIPTABLE NS_IMETHOD GetPrintPreviewNumPages(PRInt32 *aPrintPreviewNumPages) = 0;
/**
* Print the specified DOM window
*
* @param aThePrintSettings - Printer Settings for the print job, if aThePrintSettings is null
* then the global PS will be used.
* @param aWPListener - is updated during the print
* @return void
*/
/* void print (in nsIPrintSettings aThePrintSettings, in nsIWebProgressListener aWPListener); */
NS_SCRIPTABLE NS_IMETHOD Print(nsIPrintSettings *aThePrintSettings, nsIWebProgressListener *aWPListener) = 0;
/**
* Print Preview the specified DOM window
*
* @param aThePrintSettings - Printer Settings for the print preview, if aThePrintSettings is null
* then the global PS will be used.
* @param aChildDOMWin - DOM Window of the child document to be PP (FrameSet frames)
* @param aWPListener - is updated during the printpreview
* @return void
*/
/* void printPreview (in nsIPrintSettings aThePrintSettings, in nsIDOMWindow aChildDOMWin, in nsIWebProgressListener aWPListener); */
NS_SCRIPTABLE NS_IMETHOD PrintPreview(nsIPrintSettings *aThePrintSettings, nsIDOMWindow *aChildDOMWin, nsIWebProgressListener *aWPListener) = 0;
/**
* Print Preview - Navigates within the window
*
* @param aNavType - navigation enum
* @param aPageNum - page num to navigate to when aNavType = ePrintPreviewGoToPageNum
* @return void
*/
/* void printPreviewNavigate (in short aNavType, in long aPageNum); */
NS_SCRIPTABLE NS_IMETHOD PrintPreviewNavigate(PRInt16 aNavType, PRInt32 aPageNum) = 0;
/**
* Cancels the current print
* @return void
*/
/* void cancel (); */
NS_SCRIPTABLE NS_IMETHOD Cancel(void) = 0;
/**
* Returns an array of the names of all documents names (Title or URL)
* and sub-documents. This will return a single item if the attr "isFramesetDocument" is false
* and may return any number of items is "isFramesetDocument" is true
*
* @param aCount - returns number of printers returned
* @param aResult - returns array of names
* @return void
*/
/* void enumerateDocumentNames (out PRUint32 aCount, [array, size_is (aCount), retval] out wstring aResult); */
NS_SCRIPTABLE NS_IMETHOD EnumerateDocumentNames(PRUint32 *aCount, PRUnichar ***aResult) = 0;
/**
* This exists PrintPreview mode and returns browser window to galley mode
* @return void
*/
/* void exitPrintPreview (); */
NS_SCRIPTABLE NS_IMETHOD ExitPrintPreview(void) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebBrowserPrint, NS_IWEBBROWSERPRINT_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIWEBBROWSERPRINT \
NS_SCRIPTABLE NS_IMETHOD GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings); \
NS_SCRIPTABLE NS_IMETHOD GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSettings); \
NS_SCRIPTABLE NS_IMETHOD GetCurrentChildDOMWindow(nsIDOMWindow * *aCurrentChildDOMWindow); \
NS_SCRIPTABLE NS_IMETHOD GetDoingPrint(PRBool *aDoingPrint); \
NS_SCRIPTABLE NS_IMETHOD GetDoingPrintPreview(PRBool *aDoingPrintPreview); \
NS_SCRIPTABLE NS_IMETHOD GetIsFramesetDocument(PRBool *aIsFramesetDocument); \
NS_SCRIPTABLE NS_IMETHOD GetIsFramesetFrameSelected(PRBool *aIsFramesetFrameSelected); \
NS_SCRIPTABLE NS_IMETHOD GetIsIFrameSelected(PRBool *aIsIFrameSelected); \
NS_SCRIPTABLE NS_IMETHOD GetIsRangeSelection(PRBool *aIsRangeSelection); \
NS_SCRIPTABLE NS_IMETHOD GetPrintPreviewNumPages(PRInt32 *aPrintPreviewNumPages); \
NS_SCRIPTABLE NS_IMETHOD Print(nsIPrintSettings *aThePrintSettings, nsIWebProgressListener *aWPListener); \
NS_SCRIPTABLE NS_IMETHOD PrintPreview(nsIPrintSettings *aThePrintSettings, nsIDOMWindow *aChildDOMWin, nsIWebProgressListener *aWPListener); \
NS_SCRIPTABLE NS_IMETHOD PrintPreviewNavigate(PRInt16 aNavType, PRInt32 aPageNum); \
NS_SCRIPTABLE NS_IMETHOD Cancel(void); \
NS_SCRIPTABLE NS_IMETHOD EnumerateDocumentNames(PRUint32 *aCount, PRUnichar ***aResult); \
NS_SCRIPTABLE NS_IMETHOD ExitPrintPreview(void);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIWEBBROWSERPRINT(_to) \
NS_SCRIPTABLE NS_IMETHOD GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings) { return _to GetGlobalPrintSettings(aGlobalPrintSettings); } \
NS_SCRIPTABLE NS_IMETHOD GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSettings) { return _to GetCurrentPrintSettings(aCurrentPrintSettings); } \
NS_SCRIPTABLE NS_IMETHOD GetCurrentChildDOMWindow(nsIDOMWindow * *aCurrentChildDOMWindow) { return _to GetCurrentChildDOMWindow(aCurrentChildDOMWindow); } \
NS_SCRIPTABLE NS_IMETHOD GetDoingPrint(PRBool *aDoingPrint) { return _to GetDoingPrint(aDoingPrint); } \
NS_SCRIPTABLE NS_IMETHOD GetDoingPrintPreview(PRBool *aDoingPrintPreview) { return _to GetDoingPrintPreview(aDoingPrintPreview); } \
NS_SCRIPTABLE NS_IMETHOD GetIsFramesetDocument(PRBool *aIsFramesetDocument) { return _to GetIsFramesetDocument(aIsFramesetDocument); } \
NS_SCRIPTABLE NS_IMETHOD GetIsFramesetFrameSelected(PRBool *aIsFramesetFrameSelected) { return _to GetIsFramesetFrameSelected(aIsFramesetFrameSelected); } \
NS_SCRIPTABLE NS_IMETHOD GetIsIFrameSelected(PRBool *aIsIFrameSelected) { return _to GetIsIFrameSelected(aIsIFrameSelected); } \
NS_SCRIPTABLE NS_IMETHOD GetIsRangeSelection(PRBool *aIsRangeSelection) { return _to GetIsRangeSelection(aIsRangeSelection); } \
NS_SCRIPTABLE NS_IMETHOD GetPrintPreviewNumPages(PRInt32 *aPrintPreviewNumPages) { return _to GetPrintPreviewNumPages(aPrintPreviewNumPages); } \
NS_SCRIPTABLE NS_IMETHOD Print(nsIPrintSettings *aThePrintSettings, nsIWebProgressListener *aWPListener) { return _to Print(aThePrintSettings, aWPListener); } \
NS_SCRIPTABLE NS_IMETHOD PrintPreview(nsIPrintSettings *aThePrintSettings, nsIDOMWindow *aChildDOMWin, nsIWebProgressListener *aWPListener) { return _to PrintPreview(aThePrintSettings, aChildDOMWin, aWPListener); } \
NS_SCRIPTABLE NS_IMETHOD PrintPreviewNavigate(PRInt16 aNavType, PRInt32 aPageNum) { return _to PrintPreviewNavigate(aNavType, aPageNum); } \
NS_SCRIPTABLE NS_IMETHOD Cancel(void) { return _to Cancel(); } \
NS_SCRIPTABLE NS_IMETHOD EnumerateDocumentNames(PRUint32 *aCount, PRUnichar ***aResult) { return _to EnumerateDocumentNames(aCount, aResult); } \
NS_SCRIPTABLE NS_IMETHOD ExitPrintPreview(void) { return _to ExitPrintPreview(); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIWEBBROWSERPRINT(_to) \
NS_SCRIPTABLE NS_IMETHOD GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetGlobalPrintSettings(aGlobalPrintSettings); } \
NS_SCRIPTABLE NS_IMETHOD GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSettings) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetCurrentPrintSettings(aCurrentPrintSettings); } \
NS_SCRIPTABLE NS_IMETHOD GetCurrentChildDOMWindow(nsIDOMWindow * *aCurrentChildDOMWindow) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetCurrentChildDOMWindow(aCurrentChildDOMWindow); } \
NS_SCRIPTABLE NS_IMETHOD GetDoingPrint(PRBool *aDoingPrint) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDoingPrint(aDoingPrint); } \
NS_SCRIPTABLE NS_IMETHOD GetDoingPrintPreview(PRBool *aDoingPrintPreview) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDoingPrintPreview(aDoingPrintPreview); } \
NS_SCRIPTABLE NS_IMETHOD GetIsFramesetDocument(PRBool *aIsFramesetDocument) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsFramesetDocument(aIsFramesetDocument); } \
NS_SCRIPTABLE NS_IMETHOD GetIsFramesetFrameSelected(PRBool *aIsFramesetFrameSelected) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsFramesetFrameSelected(aIsFramesetFrameSelected); } \
NS_SCRIPTABLE NS_IMETHOD GetIsIFrameSelected(PRBool *aIsIFrameSelected) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsIFrameSelected(aIsIFrameSelected); } \
NS_SCRIPTABLE NS_IMETHOD GetIsRangeSelection(PRBool *aIsRangeSelection) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsRangeSelection(aIsRangeSelection); } \
NS_SCRIPTABLE NS_IMETHOD GetPrintPreviewNumPages(PRInt32 *aPrintPreviewNumPages) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPrintPreviewNumPages(aPrintPreviewNumPages); } \
NS_SCRIPTABLE NS_IMETHOD Print(nsIPrintSettings *aThePrintSettings, nsIWebProgressListener *aWPListener) { return !_to ? NS_ERROR_NULL_POINTER : _to->Print(aThePrintSettings, aWPListener); } \
NS_SCRIPTABLE NS_IMETHOD PrintPreview(nsIPrintSettings *aThePrintSettings, nsIDOMWindow *aChildDOMWin, nsIWebProgressListener *aWPListener) { return !_to ? NS_ERROR_NULL_POINTER : _to->PrintPreview(aThePrintSettings, aChildDOMWin, aWPListener); } \
NS_SCRIPTABLE NS_IMETHOD PrintPreviewNavigate(PRInt16 aNavType, PRInt32 aPageNum) { return !_to ? NS_ERROR_NULL_POINTER : _to->PrintPreviewNavigate(aNavType, aPageNum); } \
NS_SCRIPTABLE NS_IMETHOD Cancel(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Cancel(); } \
NS_SCRIPTABLE NS_IMETHOD EnumerateDocumentNames(PRUint32 *aCount, PRUnichar ***aResult) { return !_to ? NS_ERROR_NULL_POINTER : _to->EnumerateDocumentNames(aCount, aResult); } \
NS_SCRIPTABLE NS_IMETHOD ExitPrintPreview(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->ExitPrintPreview(); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsWebBrowserPrint : public nsIWebBrowserPrint
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBBROWSERPRINT
nsWebBrowserPrint();
private:
~nsWebBrowserPrint();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsWebBrowserPrint, nsIWebBrowserPrint)
nsWebBrowserPrint::nsWebBrowserPrint()
{
/* member initializers and constructor code */
}
nsWebBrowserPrint::~nsWebBrowserPrint()
{
/* destructor code */
}
/* readonly attribute nsIPrintSettings globalPrintSettings; */
NS_IMETHODIMP nsWebBrowserPrint::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute nsIPrintSettings currentPrintSettings; */
NS_IMETHODIMP nsWebBrowserPrint::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute nsIDOMWindow currentChildDOMWindow; */
NS_IMETHODIMP nsWebBrowserPrint::GetCurrentChildDOMWindow(nsIDOMWindow * *aCurrentChildDOMWindow)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean doingPrint; */
NS_IMETHODIMP nsWebBrowserPrint::GetDoingPrint(PRBool *aDoingPrint)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean doingPrintPreview; */
NS_IMETHODIMP nsWebBrowserPrint::GetDoingPrintPreview(PRBool *aDoingPrintPreview)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean isFramesetDocument; */
NS_IMETHODIMP nsWebBrowserPrint::GetIsFramesetDocument(PRBool *aIsFramesetDocument)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean isFramesetFrameSelected; */
NS_IMETHODIMP nsWebBrowserPrint::GetIsFramesetFrameSelected(PRBool *aIsFramesetFrameSelected)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean isIFrameSelected; */
NS_IMETHODIMP nsWebBrowserPrint::GetIsIFrameSelected(PRBool *aIsIFrameSelected)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean isRangeSelection; */
NS_IMETHODIMP nsWebBrowserPrint::GetIsRangeSelection(PRBool *aIsRangeSelection)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute long printPreviewNumPages; */
NS_IMETHODIMP nsWebBrowserPrint::GetPrintPreviewNumPages(PRInt32 *aPrintPreviewNumPages)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void print (in nsIPrintSettings aThePrintSettings, in nsIWebProgressListener aWPListener); */
NS_IMETHODIMP nsWebBrowserPrint::Print(nsIPrintSettings *aThePrintSettings, nsIWebProgressListener *aWPListener)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void printPreview (in nsIPrintSettings aThePrintSettings, in nsIDOMWindow aChildDOMWin, in nsIWebProgressListener aWPListener); */
NS_IMETHODIMP nsWebBrowserPrint::PrintPreview(nsIPrintSettings *aThePrintSettings, nsIDOMWindow *aChildDOMWin, nsIWebProgressListener *aWPListener)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void printPreviewNavigate (in short aNavType, in long aPageNum); */
NS_IMETHODIMP nsWebBrowserPrint::PrintPreviewNavigate(PRInt16 aNavType, PRInt32 aPageNum)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void cancel (); */
NS_IMETHODIMP nsWebBrowserPrint::Cancel()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void enumerateDocumentNames (out PRUint32 aCount, [array, size_is (aCount), retval] out wstring aResult); */
NS_IMETHODIMP nsWebBrowserPrint::EnumerateDocumentNames(PRUint32 *aCount, PRUnichar ***aResult)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void exitPrintPreview (); */
NS_IMETHODIMP nsWebBrowserPrint::ExitPrintPreview()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIWebBrowserPrint_h__ */
| nikgoodley-ibboost/forklabs-javaxpcom | tools/xulrunner-1.9.0.13-sdk/sdk/include/nsIWebBrowserPrint.h | C | gpl-2.0 | 17,681 |
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Providers.Manager;
using System.Collections.Generic;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Providers.Games
{
public class GameSystemMetadataService : MetadataService<GameSystem, GameSystemInfo>
{
protected override void MergeData(MetadataResult<GameSystem> source, MetadataResult<GameSystem> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
var sourceItem = source.Item;
var targetItem = target.Item;
if (replaceData || string.IsNullOrEmpty(targetItem.GameSystemName))
{
targetItem.GameSystemName = sourceItem.GameSystemName;
}
}
public GameSystemMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
}
}
| gsnerf/MediaBrowser | MediaBrowser.Providers/Games/GameSystemMetadataService.cs | C# | gpl-2.0 | 1,499 |
/**
* This file is part of the KDE project.
*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 2000 Simon Hausmann <hausmann@kde.org>
* (C) 2000 Stefan Schimanski (1Stein@gmx.de)
* (C) 2003 Apple Computer, Inc.
* (C) 2005 Niels Leenheer <niels.leenheer@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
//#define DEBUG_LAYOUT
#include "rendering/render_frames.h"
#include "rendering/render_canvas.h"
#include "html/html_baseimpl.h"
#include "html/html_objectimpl.h"
#include "html/htmltokenizer.h"
#include "xml/dom2_eventsimpl.h"
#include "xml/dom_docimpl.h"
#include "khtmlview.h"
#include "khtml_part.h"
#include <kmessagebox.h>
#include <kmimetype.h>
#include <klocale.h>
#include <kdebug.h>
#include <QtCore/QTimer>
#include <QtGui/QPainter>
#include <QtGui/QCursor>
#include <QtGui/QApplication>
using namespace khtml;
using namespace DOM;
RenderFrameSet::RenderFrameSet( HTMLFrameSetElementImpl *frameSet)
: RenderBox(frameSet)
{
// init RenderObject attributes
setInline(false);
for (int k = 0; k < 2; ++k) {
m_gridLen[k] = -1;
m_gridDelta[k] = 0;
m_gridLayout[k] = 0;
}
m_resizing = m_clientresizing= false;
m_cursor = Qt::ArrowCursor;
m_hSplit = -1;
m_vSplit = -1;
m_hSplitVar = 0;
m_vSplitVar = 0;
}
RenderFrameSet::~RenderFrameSet()
{
for (int k = 0; k < 2; ++k) {
delete [] m_gridLayout[k];
delete [] m_gridDelta[k];
}
delete [] m_hSplitVar;
delete [] m_vSplitVar;
}
bool RenderFrameSet::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction, bool inBox)
{
RenderBox::nodeAtPoint(info, _x, _y, _tx, _ty, hitTestAction, inBox);
bool inside = m_resizing || canResize(_x, _y);
if ( inside && element() && !element()->noResize() && !info.readonly()) {
info.setInnerNode(element());
info.setInnerNonSharedNode(element());
}
return inside || m_clientresizing;
}
void RenderFrameSet::layout( )
{
KHTMLAssert( needsLayout() );
KHTMLAssert( minMaxKnown() );
if ( !parent()->isFrameSet() ) {
KHTMLView* view = canvas()->view();
m_width = view ? view->visibleWidth() : 0;
m_height = view ? view->visibleHeight() : 0;
}
#ifdef DEBUG_LAYOUT
kDebug( 6040 ) << renderName() << "(FrameSet)::layout( ) width=" << width() << ", height=" << height();
#endif
int remainingLen[2];
remainingLen[1] = m_width - (element()->totalCols()-1)*element()->border();
if(remainingLen[1]<0) remainingLen[1]=0;
remainingLen[0] = m_height - (element()->totalRows()-1)*element()->border();
if(remainingLen[0]<0) remainingLen[0]=0;
int availableLen[2];
availableLen[0] = remainingLen[0];
availableLen[1] = remainingLen[1];
if (m_gridLen[0] != element()->totalRows() || m_gridLen[1] != element()->totalCols()) {
// number of rows or cols changed
// need to zero out the deltas
m_gridLen[0] = element()->totalRows();
m_gridLen[1] = element()->totalCols();
for (int k = 0; k < 2; ++k) {
delete [] m_gridDelta[k];
m_gridDelta[k] = new int[m_gridLen[k]];
delete [] m_gridLayout[k];
m_gridLayout[k] = new int[m_gridLen[k]];
for (int i = 0; i < m_gridLen[k]; ++i)
m_gridDelta[k][i] = 0;
}
}
for (int k = 0; k < 2; ++k) {
int totalRelative = 0;
int totalFixed = 0;
int totalPercent = 0;
int countRelative = 0;
int countFixed = 0;
int countPercent = 0;
int gridLen = m_gridLen[k];
int* gridDelta = m_gridDelta[k];
khtml::Length* grid = k ? element()->m_cols : element()->m_rows;
int* gridLayout = m_gridLayout[k];
if (grid) {
// First we need to investigate how many columns of each type we have and
// how much space these columns are going to require.
for (int i = 0; i < gridLen; ++i) {
// Count the total length of all of the fixed columns/rows -> totalFixed
// Count the number of columns/rows which are fixed -> countFixed
if (grid[i].isFixed()) {
gridLayout[i] = qMax(grid[i].value(), 0);
totalFixed += gridLayout[i];
countFixed++;
}
// Count the total percentage of all of the percentage columns/rows -> totalPercent
// Count the number of columns/rows which are percentages -> countPercent
if (grid[i].isPercent()) {
gridLayout[i] = qMax(grid[i].width(availableLen[k]), 0);
totalPercent += gridLayout[i];
countPercent++;
}
// Count the total relative of all the relative columns/rows -> totalRelative
// Count the number of columns/rows which are relative -> countRelative
if (grid[i].isRelative()) {
totalRelative += qMax(grid[i].value(), 1);
countRelative++;
}
}
// Fixed columns/rows are our first priority. If there is not enough space to fit all fixed
// columns/rows we need to proportionally adjust their size.
if (totalFixed > remainingLen[k]) {
int remainingFixed = remainingLen[k];
for (int i = 0; i < gridLen; ++i) {
if (grid[i].isFixed()) {
gridLayout[i] = (gridLayout[i] * remainingFixed) / totalFixed;
remainingLen[k] -= gridLayout[i];
}
}
} else {
remainingLen[k] -= totalFixed;
}
// Percentage columns/rows are our second priority. Divide the remaining space proportionally
// over all percentage columns/rows. IMPORTANT: the size of each column/row is not relative
// to 100%, but to the total percentage. For example, if there are three columns, each of 75%,
// and the available space is 300px, each column will become 100px in width.
if (totalPercent > remainingLen[k]) {
int remainingPercent = remainingLen[k];
for (int i = 0; i < gridLen; ++i) {
if (grid[i].isPercent()) {
gridLayout[i] = (gridLayout[i] * remainingPercent) / totalPercent;
remainingLen[k] -= gridLayout[i];
}
}
} else {
remainingLen[k] -= totalPercent;
}
// Relative columns/rows are our last priority. Divide the remaining space proportionally
// over all relative columns/rows. IMPORTANT: the relative value of 0* is treated as 1*.
if (countRelative) {
int lastRelative = 0;
int remainingRelative = remainingLen[k];
for (int i = 0; i < gridLen; ++i) {
if (grid[i].isRelative()) {
gridLayout[i] = (qMax(grid[i].value(), 1) * remainingRelative) / totalRelative;
remainingLen[k] -= gridLayout[i];
lastRelative = i;
}
}
// If we could not evently distribute the available space of all of the relative
// columns/rows, the remainder will be added to the last column/row.
// For example: if we have a space of 100px and three columns (*,*,*), the remainder will
// be 1px and will be added to the last column: 33px, 33px, 34px.
if (remainingLen[k]) {
gridLayout[lastRelative] += remainingLen[k];
remainingLen[k] = 0;
}
}
// If we still have some left over space we need to divide it over the already existing
// columns/rows
if (remainingLen[k]) {
// Our first priority is to spread if over the percentage columns. The remaining
// space is spread evenly, for example: if we have a space of 100px, the columns
// definition of 25%,25% used to result in two columns of 25px. After this the
// columns will each be 50px in width.
if (countPercent && totalPercent) {
int remainingPercent = remainingLen[k];
int changePercent = 0;
for (int i = 0; i < gridLen; ++i) {
if (grid[i].isPercent()) {
changePercent = (remainingPercent * gridLayout[i]) / totalPercent;
gridLayout[i] += changePercent;
remainingLen[k] -= changePercent;
}
}
} else if (totalFixed) {
// Our last priority is to spread the remaining space over the fixed columns.
// For example if we have 100px of space and two column of each 40px, both
// columns will become exactly 50px.
int remainingFixed = remainingLen[k];
int changeFixed = 0;
for (int i = 0; i < gridLen; ++i) {
if (grid[i].isFixed()) {
changeFixed = (remainingFixed * gridLayout[i]) / totalFixed;
gridLayout[i] += changeFixed;
remainingLen[k] -= changeFixed;
}
}
}
}
// If we still have some left over space we probably ended up with a remainder of
// a division. We can not spread it evenly anymore. If we have any percentage
// columns/rows simply spread the remainder equally over all available percentage columns,
// regardless of their size.
if (remainingLen[k] && countPercent) {
int remainingPercent = remainingLen[k];
int changePercent = 0;
for (int i = 0; i < gridLen; ++i) {
if (grid[i].isPercent()) {
changePercent = remainingPercent / countPercent;
gridLayout[i] += changePercent;
remainingLen[k] -= changePercent;
}
}
}
// If we don't have any percentage columns/rows we only have fixed columns. Spread
// the remainder equally over all fixed columns/rows.
else if (remainingLen[k] && countFixed) {
int remainingFixed = remainingLen[k];
int changeFixed = 0;
for (int i = 0; i < gridLen; ++i) {
if (grid[i].isFixed()) {
changeFixed = remainingFixed / countFixed;
gridLayout[i] += changeFixed;
remainingLen[k] -= changeFixed;
}
}
}
// Still some left over... simply add it to the last column, because it is impossible
// spread it evenly or equally.
if (remainingLen[k]) {
gridLayout[gridLen - 1] += remainingLen[k];
}
// now we have the final layout, distribute the delta over it
bool worked = true;
for (int i = 0; i < gridLen; ++i) {
if (gridLayout[i] && gridLayout[i] + gridDelta[i] <= 0)
worked = false;
gridLayout[i] += gridDelta[i];
}
// now the delta's broke something, undo it and reset deltas
if (!worked)
for (int i = 0; i < gridLen; ++i) {
gridLayout[i] -= gridDelta[i];
gridDelta[i] = 0;
}
}
else
gridLayout[0] = remainingLen[k];
}
positionFrames();
RenderObject *child = firstChild();
if ( !child )
goto end2;
if(!m_hSplitVar && !m_vSplitVar)
{
#ifdef DEBUG_LAYOUT
kDebug( 6031 ) << "calculationg fixed Splitters";
#endif
if(!m_vSplitVar && element()->totalCols() > 1)
{
m_vSplitVar = new bool[element()->totalCols()];
for(int i = 0; i < element()->totalCols(); i++) m_vSplitVar[i] = true;
}
if(!m_hSplitVar && element()->totalRows() > 1)
{
m_hSplitVar = new bool[element()->totalRows()];
for(int i = 0; i < element()->totalRows(); i++) m_hSplitVar[i] = true;
}
for(int r = 0; r < element()->totalRows(); r++)
{
for(int c = 0; c < element()->totalCols(); c++)
{
bool fixed = false;
if ( child->isFrameSet() )
fixed = static_cast<RenderFrameSet *>(child)->element()->noResize();
else
fixed = static_cast<RenderFrame *>(child)->element()->noResize();
if(fixed)
{
#ifdef DEBUG_LAYOUT
kDebug( 6031 ) << "found fixed cell " << r << "/" << c << "!";
#endif
if( element()->totalCols() > 1)
{
if(c>0) m_vSplitVar[c-1] = false;
m_vSplitVar[c] = false;
}
if( element()->totalRows() > 1)
{
if(r>0) m_hSplitVar[r-1] = false;
m_hSplitVar[r] = false;
}
child = child->nextSibling();
if(!child) goto end2;
}
#ifdef DEBUG_LAYOUT
else
kDebug( 6031 ) << "not fixed: " << r << "/" << c << "!";
#endif
}
}
}
RenderContainer::layout();
end2:
setNeedsLayout(false);
}
void RenderFrameSet::positionFrames()
{
int r;
int c;
RenderObject *child = firstChild();
if ( !child )
return;
// NodeImpl *child = _first;
// if(!child) return;
int yPos = 0;
for(r = 0; r < element()->totalRows(); r++)
{
int xPos = 0;
for(c = 0; c < element()->totalCols(); c++)
{
child->setPos( xPos, yPos );
#ifdef DEBUG_LAYOUT
kDebug(6040) << "child frame at (" << xPos << "/" << yPos << ") size (" << m_gridLayout[1][c] << "/" << m_gridLayout[0][r] << ")";
#endif
// has to be resized and itself resize its contents
if ((m_gridLayout[1][c] != child->width()) || (m_gridLayout[0][r] != child->height())) {
child->setWidth( m_gridLayout[1][c] );
child->setHeight( m_gridLayout[0][r] );
child->setNeedsLayout(true);
child->layout();
}
xPos += m_gridLayout[1][c] + element()->border();
child = child->nextSibling();
if ( !child )
return;
}
yPos += m_gridLayout[0][r] + element()->border();
}
// all the remaining frames are hidden to avoid ugly
// spurious unflowed frames
while ( child ) {
child->setWidth( 0 );
child->setHeight( 0 );
child->setNeedsLayout(false);
child = child->nextSibling();
}
}
bool RenderFrameSet::userResize( MouseEventImpl *evt )
{
if (needsLayout()) return false;
bool res = false;
int _x = evt->clientX();
int _y = evt->clientY();
if ( ( !m_resizing && evt->id() == EventImpl::MOUSEMOVE_EVENT ) || evt->id() == EventImpl::MOUSEDOWN_EVENT )
{
#ifdef DEBUG_LAYOUT
kDebug( 6031 ) << "mouseEvent:check";
#endif
m_hSplit = -1;
m_vSplit = -1;
// check if we're over a horizontal or vertical boundary
int pos = m_gridLayout[1][0] + xPos();
for(int c = 1; c < element()->totalCols(); c++)
{
if(_x >= pos && _x <= pos+element()->border())
{
if(m_vSplitVar && m_vSplitVar[c-1] == true) m_vSplit = c-1;
#ifdef DEBUG_LAYOUT
kDebug( 6031 ) << "vsplit!";
#endif
res = true;
break;
}
pos += m_gridLayout[1][c] + element()->border();
}
pos = m_gridLayout[0][0] + yPos();
for(int r = 1; r < element()->totalRows(); r++)
{
if( _y >= pos && _y <= pos+element()->border())
{
if(m_hSplitVar && m_hSplitVar[r-1] == true) m_hSplit = r-1;
#ifdef DEBUG_LAYOUT
kDebug( 6031 ) << "hsplitvar = " << m_hSplitVar;
kDebug( 6031 ) << "hsplit!";
#endif
res = true;
break;
}
pos += m_gridLayout[0][r] + element()->border();
}
#ifdef DEBUG_LAYOUT
kDebug( 6031 ) << m_hSplit << "/" << m_vSplit;
#endif
}
m_cursor = Qt::ArrowCursor;
if(m_hSplit != -1 && m_vSplit != -1)
m_cursor = Qt::SizeAllCursor;
else if( m_vSplit != -1 )
m_cursor = Qt::SizeHorCursor;
else if( m_hSplit != -1 )
m_cursor = Qt::SizeVerCursor;
if(!m_resizing && evt->id() == EventImpl::MOUSEDOWN_EVENT)
{
setResizing(true);
QApplication::setOverrideCursor(QCursor(m_cursor));
m_vSplitPos = _x;
m_hSplitPos = _y;
m_oldpos = -1;
}
// ### check the resize is not going out of bounds.
if(m_resizing)
{
if (evt->id() == EventImpl::MOUSEUP_EVENT) {
setResizing(false);
QApplication::restoreOverrideCursor();
}
if(m_vSplit != -1 )
{
#ifdef DEBUG_LAYOUT
kDebug( 6031 ) << "split xpos=" << _x;
#endif
int delta = m_vSplitPos - _x;
m_gridDelta[1][m_vSplit] -= delta;
m_gridDelta[1][m_vSplit+1] += delta;
m_vSplitPos = _x;
}
if(m_hSplit != -1 )
{
#ifdef DEBUG_LAYOUT
kDebug( 6031 ) << "split ypos=" << _y;
#endif
int delta = m_hSplitPos - _y;
m_gridDelta[0][m_hSplit] -= delta;
m_gridDelta[0][m_hSplit+1] += delta;
m_hSplitPos = _y;
}
// this just schedules the relayout
// important, otherwise the moving indicator is not correctly erased
setNeedsLayout(true);
}
/*
KHTMLView *view = canvas()->view();
if ((m_resizing || evt->id() == EventImpl::MOUSEUP_EVENT) && view) {
QPainter paint( view );
paint.setPen( Qt::gray );
paint.setBrush( Qt::gray );
paint.setCompositionMode(QPainter::CompositionMode_Xor);
QRect r(xPos(), yPos(), width(), height());
const int rBord = 3;
int sw = element()->border();
int p = m_resizing ? (m_vSplit > -1 ? _x : _y) : -1;
if (m_vSplit > -1) {
if ( m_oldpos >= 0 )
paint.drawRect( m_oldpos + sw/2 - rBord , r.y(),
2*rBord, r.height() );
if ( p >= 0 )
paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
} else {
if ( m_oldpos >= 0 )
paint.drawRect( r.x(), m_oldpos + sw/2 - rBord,
r.width(), 2*rBord );
if ( p >= 0 )
paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
}
m_oldpos = p;
}
*/
return res;
}
void RenderFrameSet::paintFrameSetRules( QPainter *paint, const QRect& damageRect )
{
Q_UNUSED( damageRect );
KHTMLView *view = canvas()->view();
if (view && !noResize()) {
paint->setPen( Qt::gray );
paint->setBrush( Qt::gray );
const int rBord = 3;
int sw = element()->border();
// ### implement me
(void) rBord;
(void) sw;
}
}
void RenderFrameSet::setResizing(bool e)
{
m_resizing = e;
for (RenderObject* p = parent(); p; p = p->parent())
if (p->isFrameSet()) static_cast<RenderFrameSet*>(p)->m_clientresizing = m_resizing;
}
bool RenderFrameSet::canResize( int _x, int _y )
{
// if we haven't received a layout, then the gridLayout doesn't contain useful data yet
if (needsLayout() || !m_gridLayout[0] || !m_gridLayout[1] ) return false;
// check if we're over a horizontal or vertical boundary
int pos = m_gridLayout[1][0];
for(int c = 1; c < element()->totalCols(); c++)
if(_x >= pos && _x <= pos+element()->border())
return true;
pos = m_gridLayout[0][0];
for(int r = 1; r < element()->totalRows(); r++)
if( _y >= pos && _y <= pos+element()->border())
return true;
return false;
}
#ifdef ENABLE_DUMP
void RenderFrameSet::dump(QTextStream &stream, const QString &ind) const
{
RenderBox::dump(stream,ind);
stream << " totalrows=" << element()->totalRows();
stream << " totalcols=" << element()->totalCols();
if ( m_hSplitVar )
for (uint i = 0; i < (uint)element()->totalRows(); i++) {
stream << " hSplitvar(" << i << ")=" << m_hSplitVar[i];
}
if ( m_vSplitVar )
for (uint i = 0; i < (uint)element()->totalCols(); i++)
stream << " vSplitvar(" << i << ")=" << m_vSplitVar[i];
}
#endif
/**************************************************************************************/
RenderPart::RenderPart(DOM::HTMLElementImpl* node)
: RenderWidget(node)
{
// init RenderObject attributes
setInline(false);
// HTMLPartContainerElementImpl does memory management, not us
setDoesNotOwnWidget();
}
void RenderPart::setWidget( QWidget *widget )
{
#ifdef DEBUG_LAYOUT
kDebug(6031) << "RenderPart::setWidget()";
#endif
setQWidget( widget );
if (widget) {
widget->setFocusPolicy(Qt::WheelFocus);
if(widget->inherits("KHTMLView"))
connect( widget, SIGNAL(cleared()), this, SLOT(slotViewCleared()) );
}
setNeedsLayoutAndMinMaxRecalc();
// make sure the scrollbars are set correctly for restore
// ### find better fix
slotViewCleared();
}
short RenderPart::intrinsicWidth() const
{
return 300;
}
int RenderPart::intrinsicHeight() const
{
return 150;
}
void RenderPart::slotViewCleared()
{
}
/***************************************************************************************/
RenderFrame::RenderFrame( DOM::HTMLFrameElementImpl *frame )
: RenderPart(frame)
{
setInline( false );
}
void RenderFrame::slotViewCleared()
{
if (QScrollArea *view = qobject_cast<QScrollArea*>(m_widget)) {
#ifdef DEBUG_LAYOUT
kDebug(6031) << "frame is a scrollarea!";
#endif
if(!element()->frameBorder || !((static_cast<HTMLFrameSetElementImpl *>(element()->parentNode()))->frameBorder()))
view->setFrameStyle(QFrame::NoFrame);
if(KHTMLView *htmlView = qobject_cast<KHTMLView*>(view)) {
#ifdef DEBUG_LAYOUT
kDebug(6031) << "frame is a KHTMLview!";
#endif
htmlView->setVerticalScrollBarPolicy(element()->scrolling );
htmlView->setHorizontalScrollBarPolicy(element()->scrolling );
if(element()->marginWidth != -1) htmlView->setMarginWidth(element()->marginWidth);
if(element()->marginHeight != -1) htmlView->setMarginHeight(element()->marginHeight);
} else {
// those are no more virtual in Qt4 ;(
view->setVerticalScrollBarPolicy(element()->scrolling );
view->setHorizontalScrollBarPolicy(element()->scrolling );
}
}
}
/****************************************************************************************/
RenderPartObject::RenderPartObject( DOM::HTMLElementImpl* element )
: RenderPart( element )
{
// init RenderObject attributes
setInline(true);
}
void RenderPartObject::layout( )
{
KHTMLAssert( needsLayout() );
KHTMLAssert( minMaxKnown() );
calcWidth();
calcHeight();
RenderPart::layout();
setNeedsLayout(false);
}
void RenderPartObject::slotViewCleared()
{
if(QScrollArea *view = qobject_cast<QScrollArea*>(m_widget)) {
#ifdef DEBUG_LAYOUT
kDebug(6031) << "iframe is a scrollview!";
#endif
int frameStyle = QFrame::NoFrame;
Qt::ScrollBarPolicy scroll = Qt::ScrollBarAsNeeded;
int marginw = -1;
int marginh = -1;
if ( element()->id() == ID_IFRAME) {
HTMLIFrameElementImpl *frame = static_cast<HTMLIFrameElementImpl *>(element());
if(frame->frameBorder)
frameStyle = QFrame::Box;
scroll = frame->scrolling;
marginw = frame->marginWidth;
marginh = frame->marginHeight;
}
view->setFrameStyle(frameStyle);
if (KHTMLView *htmlView = qobject_cast<KHTMLView*>(view)) {
#ifdef DEBUG_LAYOUT
kDebug(6031) << "frame is a KHTMLview!";
#endif
htmlView->setIgnoreWheelEvents( element()->id() == ID_IFRAME );
htmlView->setVerticalScrollBarPolicy(scroll );
htmlView->setHorizontalScrollBarPolicy(scroll );
if(marginw != -1) htmlView->setMarginWidth(marginw);
if(marginh != -1) htmlView->setMarginHeight(marginh);
} else {
// those are no more virtual in Qt4 ;(
view->setVerticalScrollBarPolicy(scroll );
view->setHorizontalScrollBarPolicy(scroll );
}
}
}
#include "render_frames.moc"
| melvyn-sopacua/kdelibs | khtml/rendering/render_frames.cpp | C++ | gpl-2.0 | 25,663 |
<!-- START Category Search -->
<div class="em-search-category em-search-field">
<label><?php echo esc_html(get_option('dbem_search_form_category_label')); ?></label>
<?php
$selected = !empty($_REQUEST['category']) ? $_REQUEST['category'] : 0;
EM_Object::ms_global_switch(); //in case in global tables mode of MultiSite, grabs main site categories, if not using MS Global, nothing happens
wp_dropdown_categories(array( 'hide_empty' => 0, 'orderby' =>'name', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected, 'show_option_none' => get_option('dbem_search_form_categories_label'), 'class'=>'em-events-search-category'));
EM_Object::ms_global_switch_back(); //if switched above, switch back
?>
</div>
<!-- END Category Search --> | Christopherallen/idc-dev | wp-content/plugins/events-manager/templates/templates/search/categories.php | PHP | gpl-2.0 | 804 |
<HTML>
<CENTER><A HREF = "http://lammps.sandia.gov">LAMMPS WWW Site</A> - <A HREF = "Manual.html">LAMMPS Documentation</A> - <A HREF = "Section_commands.html#comm">LAMMPS Commands</A>
</CENTER>
<HR>
<H3>compute stress/atom command
</H3>
<P><B>Syntax:</B>
</P>
<PRE>compute ID group-ID stress/atom keyword ...
</PRE>
<UL><LI>ID, group-ID are documented in <A HREF = "compute.html">compute</A> command
<LI>stress/atom = style name of this compute command
<LI>zero or more keywords may be appended
<LI>keyword = <I>ke</I> or <I>pair</I> or <I>bond</I> or <I>angle</I> or <I>dihedral</I> or <I>improper</I> or <I>fix</I> or <I>virial</I>
</UL>
<P><B>Examples:</B>
</P>
<PRE>compute 1 mobile stress/atom
compute 1 all stress/atom pair bond
</PRE>
<P><B>Description:</B>
</P>
<P>Define a computation that computes the symmetric per-atom stress
tensor for each atom in a group. The tensor for each atom has 6
components and is stored as a 6-element vector in the following order:
xx, yy, zz, xy, xz, yz. See the <A HREF = "compute_pressure.html">compute
pressure</A> command if you want the stress tensor
(pressure) of the entire system.
</P>
<P>The stress tensor for atom <I>I</I> is given by the following formula,
where <I>a</I> and <I>b</I> take on values x,y,z to generate the 6 components of
the symmetric tensor:
</P>
<CENTER><IMG SRC = "Eqs/stress_tensor.jpg">
</CENTER>
<P>The first term is a kinetic energy contribution for atom <I>I</I>. The
second term is a pairwise energy contribution where <I>n</I> loops over the
<I>Np</I> neighbors of atom <I>I</I>, <I>r1</I> and <I>r2</I> are the positions of the 2
atoms in the pairwise interaction, and <I>F1</I> and <I>F2</I> are the forces on
the 2 atoms resulting from the pairwise interaction. The third term
is a bond contribution of similar form for the <I>Nb</I> bonds which atom
<I>I</I> is part of. There are similar terms for the <I>Na</I> angle, <I>Nd</I>
dihedral, and <I>Ni</I> improper interactions atom <I>I</I> is part of.
Finally, there is a term for the <I>Nf</I> <A HREF = "fix.html">fixes</A> that apply
internal constraint forces to atom <I>I</I>. Currently, only the <A HREF = "fix_shake.html">fix
shake</A> and <A HREF = "fix_rigid.html">fix rigid</A> commands
contribute to this term.
</P>
<P>As the coefficients in the formula imply, a virial contribution
produced by a small set of atoms (e.g. 4 atoms in a dihedral or 3
atoms in a Tersoff 3-body interaction) is assigned in equal portions
to each atom in the set. E.g. 1/4 of the dihedral virial to each of
the 4 atoms, or 1/3 of the fix virial due to SHAKE constraints applied
to atoms in a a water molecule via the <A HREF = "fix_shake.html">fix shake</A>
command.
</P>
<P>If no extra keywords are listed, all of the terms in this formula are
included in the per-atom stress tensor. If any extra keywords are
listed, only those terms are summed to compute the tensor. The
<I>virial</I> keyword means include all terms except the kinetic energy
<I>ke</I>.
</P>
<P>Note that the stress for each atom is due to its interaction with all
other atoms in the simulation, not just with other atoms in the group.
</P>
<P>The <A HREF = "dihedral_charmm.html">dihedral_style charmm</A> style calculates
pairwise interactions between 1-4 atoms. The virial contribution of
these terms is included in the pair virial, not the dihedral virial.
</P>
<P>Note that as defined in the formula, per-atom stress is the negative
of the per-atom pressure tensor. It is also really a stress*volume
formulation, meaning the computed quantity is in units of
pressure*volume. It would need to be divided by a per-atom volume to
have units of stress (pressure), but an individual atom's volume is
not well defined or easy to compute in a deformed solid or a liquid.
Thus, if the diagonal components of the per-atom stress tensor are
summed for all atoms in the system and the sum is divided by dV, where
d = dimension and V is the volume of the system, the result should be
-P, where P is the total pressure of the system.
</P>
<P>These lines in an input script for a 3d system should yield that
result. I.e. the last 2 columns of thermo output will be the same:
</P>
<PRE>compute peratom all stress/atom
compute p all reduce sum c_peratom[1] c_peratom[2] c_peratom[3]
variable press equal -(c_p[1]+c_p[2]+c_p[3])/(3*vol)
thermo_style custom step temp etotal press v_press
</PRE>
<P>IMPORTANT NOTE: The per-atom stress does NOT include contributions due
to long-range Coulombic interactions (via the
<A HREF = "kspace_style.html">kspace_style</A> command). It's not clear this
contribution can easily be computed.
</P>
<P><B>Output info:</B>
</P>
<P>This compute calculates a per-atom array with 6 columns, which can be
accessed by indices 1-6 by any command that uses per-atom values from
a compute as input. See <A HREF = "Section_howto.html#4_15">this section</A> for an
overview of LAMMPS output options.
</P>
<P>The per-atom array values will be in pressure*volume
<A HREF = "units.html">units</A> as discussed above.
</P>
<P><B>Restrictions:</B> none
</P>
<P><B>Related commands:</B>
</P>
<P><A HREF = "compute_pe.html">compute pe</A>, <A HREF = "compute_pressure.html">compute pressure</A>
</P>
<P><B>Default:</B> none
</P>
</HTML>
| nchong/icliggghts | doc/compute_stress_atom.html | HTML | gpl-2.0 | 5,266 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_66) on Mon Feb 24 12:02:36 PST 2020 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>com.marginallyclever.robotOverlord.engine.undoRedo (Robot Overlord 1.6.0 API)</title>
<meta name="date" content="2020-02-24">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<h1 class="bar"><a href="../../../../../com/marginallyclever/robotOverlord/engine/undoRedo/package-summary.html" target="classFrame">com.marginallyclever.robotOverlord.engine.undoRedo</a></h1>
<div class="indexContainer">
<h2 title="Classes">Classes</h2>
<ul title="Classes">
<li><a href="UndoHelper.html" title="class in com.marginallyclever.robotOverlord.engine.undoRedo" target="classFrame">UndoHelper</a></li>
</ul>
</div>
</body>
</html>
| i-make-robots/Arm5 | docs/com/marginallyclever/robotOverlord/engine/undoRedo/package-frame.html | HTML | gpl-2.0 | 1,039 |
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QFUNCTIONS_VXWORKS_H
#define QFUNCTIONS_VXWORKS_H
#ifdef Q_OS_VXWORKS
#include <unistd.h>
#include <pthread.h>
#include <dirent.h>
#include <signal.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/times.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <netinet/in.h>
#ifndef QT_NO_IPV6IFNAME
#include <net/if.h>
#endif
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#ifdef QT_BUILD_CORE_LIB
QT_MODULE(Core)
#endif
QT_END_NAMESPACE
QT_END_HEADER
#ifndef RTLD_LOCAL
#define RTLD_LOCAL 0
#endif
#ifndef NSIG
#define NSIG _NSIGS
#endif
#ifdef __cplusplus
extern "C" {
#endif
// isascii is missing (sometimes!!)
#ifndef isascii
inline int isascii(int c) { return (c & 0x7f); }
#endif
// no lfind() - used by the TIF image format
void *lfind(const void* key, const void* base, size_t* elements, size_t size,
int (*compare)(const void*, const void*));
// no rand_r(), but rand()
// NOTE: this implementation is wrong for multi threaded applications,
// but there is no way to get it right on VxWorks (in kernel mode)
int rand_r(unsigned int * /*seedp*/);
// no usleep() support
int usleep(unsigned int);
// gettimeofday() is declared, but is missing from the library.
// It IS however defined in the Curtis-Wright X11 libraries, so
// we have to make the symbol 'weak'
int gettimeofday(struct timeval *tv, void /*struct timezone*/ *) __attribute__((weak));
// neither getpagesize() or sysconf(_SC_PAGESIZE) are available
int getpagesize();
// symlinks are not supported (lstat is now just a call to stat - see qplatformdefs.h)
int symlink(const char *, const char *);
ssize_t readlink(const char *, char *, size_t);
// there's no truncate(), but ftruncate() support...
int truncate(const char *path, off_t length);
// VxWorks doesn't know about passwd & friends.
// in order to avoid patching the unix fs path everywhere
// we introduce some dummy functions that simulate a single
// 'root' user on the system.
uid_t getuid();
gid_t getgid();
uid_t geteuid();
struct passwd {
char *pw_name; /* user name */
char *pw_passwd; /* user password */
uid_t pw_uid; /* user ID */
gid_t pw_gid; /* group ID */
char *pw_gecos; /* real name */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group ID */
char **gr_mem; /* group members */
};
struct passwd *getpwuid(uid_t uid);
struct group *getgrgid(gid_t gid);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // Q_OS_VXWORKS
#endif // QFUNCTIONS_VXWORKS_H
| repstd/modified_vlc | contrib/i586-mingw32msvc/include/qt4/src/corelib/kernel/qfunctions_vxworks.h | C | gpl-2.0 | 4,504 |
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2009 Ralph Schreyer
Copyright (C) 2009 Klaus Spanderen
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
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 license for more details.
*/
/*! \file bicgstab.hpp
\brief bi-conjugated gradient stableized algorithm
*/
#ifndef quantlib_bicgstab_hpp
#define quantlib_bicgstab_hpp
#include <ql/math/array.hpp>
#include <boost/function.hpp>
namespace QuantLib {
struct BiCGStabResult {
Size iterations;
Real error;
Array x;
};
class BiCGstab {
public:
typedef boost::function1<Disposable<Array> , const Array& > MatrixMult;
BiCGstab(const MatrixMult& A, Size maxIter, Real relTol,
const MatrixMult& preConditioner = MatrixMult());
BiCGStabResult solve(const Array& b, const Array& x0 = Array()) const;
protected:
Real norm2(const Array& a) const;
const MatrixMult A_, M_;
const Size maxIter_;
const Real relTol_;
};
}
#endif
| EuroPlusFinance/Software | Quantum Trading Platforms/QuantLib-1.4/ql/math/matrixutilities/bicgstab.hpp | C++ | gpl-2.0 | 1,691 |
/****************************************************************************
* ixj.c
*
* Device Driver for Quicknet Technologies, Inc.'s Telephony cards
* including the Internet PhoneJACK, Internet PhoneJACK Lite,
* Internet PhoneJACK PCI, Internet LineJACK, Internet PhoneCARD and
* SmartCABLE
*
* (c) Copyright 1999-2001 Quicknet Technologies, Inc.
*
* 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.
*
* Author: Ed Okerson, <eokerson@quicknet.net>
*
* Contributors: Greg Herlein, <gherlein@quicknet.net>
* David W. Erhart, <derhart@quicknet.net>
* John Sellers, <jsellers@quicknet.net>
* Mike Preston, <mpreston@quicknet.net>
*
* Fixes: David Huggins-Daines, <dhd@cepstral.com>
* Fabio Ferrari, <fabio.ferrari@digitro.com.br>
* Artis Kugevics, <artis@mt.lv>
* Daniele Bellucci, <bellucda@tiscali.it>
*
* More information about the hardware related to this driver can be found
* at our website: http://www.quicknet.net
*
* IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET
* TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION
* TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
***************************************************************************/
/*
* $Log: ixj.c,v $
*
* Revision 4.8 2003/07/09 19:39:00 Daniele Bellucci
* Audit some copy_*_user and minor cleanup.
*
* Revision 4.7 2001/08/13 06:19:33 craigs
* Added additional changes from Alan Cox and John Anderson for
* 2.2 to 2.4 cleanup and bounds checking
*
* Revision 4.6 2001/08/13 01:05:05 craigs
* Really fixed PHONE_QUERY_CODEC problem this time
*
* Revision 4.5 2001/08/13 00:11:03 craigs
* Fixed problem in handling of PHONE_QUERY_CODEC, thanks to Shane Anderson
*
* Revision 4.4 2001/08/07 07:58:12 craigs
* Changed back to three digit version numbers
* Added tagbuild target to allow automatic and easy tagging of versions
*
* Revision 4.3 2001/08/07 07:24:47 craigs
* Added ixj-ver.h to allow easy configuration management of driver
* Added display of version number in /prox/ixj
*
* Revision 4.2 2001/08/06 07:07:19 craigs
* Reverted IXJCTL_DSP_TYPE and IXJCTL_DSP_VERSION files to original
* behaviour of returning int rather than short *
*
* Revision 4.1 2001/08/05 00:17:37 craigs
* More changes for correct PCMCIA installation
* Start of changes for backward Linux compatibility
*
* Revision 4.0 2001/08/04 12:33:12 craigs
* New version using GNU autoconf
*
* Revision 3.105 2001/07/20 23:14:32 eokerson
* More work on CallerID generation when using ring cadences.
*
* Revision 3.104 2001/07/06 01:33:55 eokerson
* Some bugfixes from Robert Vojta <vojta@ipex.cz> and a few mods to the Makefile.
*
* Revision 3.103 2001/07/05 19:20:16 eokerson
* Updated HOWTO
* Changed mic gain to 30dB on Internet LineJACK mic/speaker port.
*
* Revision 3.102 2001/07/03 23:51:21 eokerson
* Un-mute mic on Internet LineJACK when in speakerphone mode.
*
* Revision 3.101 2001/07/02 19:26:56 eokerson
* Removed initialiazation of ixjdebug and ixj_convert_loaded so they will go in the .bss instead of the .data
*
* Revision 3.100 2001/07/02 19:18:27 eokerson
* Changed driver to make dynamic allocation possible. We now pass IXJ * between functions instead of array indexes.
* Fixed the way the POTS and PSTN ports interact during a PSTN call to allow local answering.
* Fixed speaker mode on Internet LineJACK.
*
* Revision 3.99 2001/05/09 14:11:16 eokerson
* Fixed kmalloc error in ixj_build_filter_cadence. Thanks David Chan <cat@waulogy.stanford.edu>.
*
* Revision 3.98 2001/05/08 19:55:33 eokerson
* Fixed POTS hookstate detection while it is connected to PSTN port.
*
* Revision 3.97 2001/05/08 00:01:04 eokerson
* Fixed kernel oops when sending caller ID data.
*
* Revision 3.96 2001/05/04 23:09:30 eokerson
* Now uses one kernel timer for each card, instead of one for the entire driver.
*
* Revision 3.95 2001/04/25 22:06:47 eokerson
* Fixed squawking at beginning of some G.723.1 calls.
*
* Revision 3.94 2001/04/03 23:42:00 eokerson
* Added linear volume ioctls
* Added raw filter load ioctl
*
* Revision 3.93 2001/02/27 01:00:06 eokerson
* Fixed blocking in CallerID.
* Reduced size of ixj structure for smaller driver footprint.
*
* Revision 3.92 2001/02/20 22:02:59 eokerson
* Fixed isapnp and pcmcia module compatibility for 2.4.x kernels.
* Improved PSTN ring detection.
* Fixed wink generation on POTS ports.
*
* Revision 3.91 2001/02/13 00:55:44 eokerson
* Turn AEC back on after changing frame sizes.
*
* Revision 3.90 2001/02/12 16:42:00 eokerson
* Added ALAW codec, thanks to Fabio Ferrari for the table based converters to make ALAW from ULAW.
*
* Revision 3.89 2001/02/12 15:41:16 eokerson
* Fix from Artis Kugevics - Tone gains were not being set correctly.
*
* Revision 3.88 2001/02/05 23:25:42 eokerson
* Fixed lockup bugs with deregister.
*
* Revision 3.87 2001/01/29 21:00:39 eokerson
* Fix from Fabio Ferrari <fabio.ferrari@digitro.com.br> to properly handle EAGAIN and EINTR during non-blocking write.
* Updated copyright date.
*
* Revision 3.86 2001/01/23 23:53:46 eokerson
* Fixes to G.729 compatibility.
*
* Revision 3.85 2001/01/23 21:30:36 eokerson
* Added verbage about cards supported.
* Removed commands that put the card in low power mode at some times that it should not be in low power mode.
*
* Revision 3.84 2001/01/22 23:32:10 eokerson
* Some bugfixes from David Huggins-Daines, <dhd@cepstral.com> and other cleanups.
*
* Revision 3.83 2001/01/19 14:51:41 eokerson
* Fixed ixj_WriteDSPCommand to decrement usage counter when command fails.
*
* Revision 3.82 2001/01/19 00:34:49 eokerson
* Added verbosity to write overlap errors.
*
* Revision 3.81 2001/01/18 23:56:54 eokerson
* Fixed PSTN line test functions.
*
* Revision 3.80 2001/01/18 22:29:27 eokerson
* Updated AEC/AGC values for different cards.
*
* Revision 3.79 2001/01/17 02:58:54 eokerson
* Fixed AEC reset after Caller ID.
* Fixed Codec lockup after Caller ID on Call Waiting when not using 30ms frames.
*
* Revision 3.78 2001/01/16 19:43:09 eokerson
* Added support for Linux 2.4.x kernels.
*
* Revision 3.77 2001/01/09 04:00:52 eokerson
* Linetest will now test the line, even if it has previously succeded.
*
* Revision 3.76 2001/01/08 19:27:00 eokerson
* Fixed problem with standard cable on Internet PhoneCARD.
*
* Revision 3.75 2000/12/22 16:52:14 eokerson
* Modified to allow hookstate detection on the POTS port when the PSTN port is selected.
*
* Revision 3.74 2000/12/08 22:41:50 eokerson
* Added capability for G729B.
*
* Revision 3.73 2000/12/07 23:35:16 eokerson
* Added capability to have different ring pattern before CallerID data.
* Added hookstate checks in CallerID routines to stop FSK.
*
* Revision 3.72 2000/12/06 19:31:31 eokerson
* Modified signal behavior to only send one signal per event.
*
* Revision 3.71 2000/12/06 03:23:08 eokerson
* Fixed CallerID on Call Waiting.
*
* Revision 3.70 2000/12/04 21:29:37 eokerson
* Added checking to Smart Cable gain functions.
*
* Revision 3.69 2000/12/04 21:05:20 eokerson
* Changed ixjdebug levels.
* Added ioctls to change gains in Internet Phone CARD Smart Cable.
*
* Revision 3.68 2000/12/04 00:17:21 craigs
* Changed mixer voice gain to +6dB rather than 0dB
*
* Revision 3.67 2000/11/30 21:25:51 eokerson
* Fixed write signal errors.
*
* Revision 3.66 2000/11/29 22:42:44 eokerson
* Fixed PSTN ring detect problems.
*
* Revision 3.65 2000/11/29 07:31:55 craigs
* Added new 425Hz filter co-efficients
* Added card-specific DTMF prescaler initialisation
*
* Revision 3.64 2000/11/28 14:03:32 craigs
* Changed certain mixer initialisations to be 0dB rather than 12dB
* Added additional information to /proc/ixj
*
* Revision 3.63 2000/11/28 11:38:41 craigs
* Added display of AEC modes in AUTO and AGC mode
*
* Revision 3.62 2000/11/28 04:05:44 eokerson
* Improved PSTN ring detection routine.
*
* Revision 3.61 2000/11/27 21:53:12 eokerson
* Fixed flash detection.
*
* Revision 3.60 2000/11/27 15:57:29 eokerson
* More work on G.729 load routines.
*
* Revision 3.59 2000/11/25 21:55:12 eokerson
* Fixed errors in G.729 load routine.
*
* Revision 3.58 2000/11/25 04:08:29 eokerson
* Added board locks around G.729 and TS85 load routines.
*
* Revision 3.57 2000/11/24 05:35:17 craigs
* Added ability to retrieve mixer values on LineJACK
* Added complete initialisation of all mixer values at startup
* Fixed spelling mistake
*
* Revision 3.56 2000/11/23 02:52:11 robertj
* Added cvs change log keyword.
* Fixed bug in capabilities list when using G.729 module.
*
*/
#include "ixj-ver.h"
#define PERFMON_STATS
#define IXJDEBUG 0
#define MAXRINGS 5
#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/kernel.h> /* printk() */
#include <linux/fs.h> /* everything... */
#include <linux/errno.h> /* error codes */
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/pci.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/isapnp.h>
#include "ixj.h"
#define TYPE(inode) (iminor(inode) >> 4)
#define NUM(inode) (iminor(inode) & 0xf)
static int ixjdebug;
static int hertz = HZ;
static int samplerate = 100;
module_param(ixjdebug, int, 0);
/************************************************************************
*
* ixjdebug meanings are now bit mapped instead of level based
* Values can be or'ed together to turn on multiple messages
*
* bit 0 (0x0001) = any failure
* bit 1 (0x0002) = general messages
* bit 2 (0x0004) = POTS ringing related
* bit 3 (0x0008) = PSTN events
* bit 4 (0x0010) = PSTN Cadence state details
* bit 5 (0x0020) = Tone detection triggers
* bit 6 (0x0040) = Tone detection cadence details
* bit 7 (0x0080) = ioctl tracking
* bit 8 (0x0100) = signal tracking
* bit 9 (0x0200) = CallerID generation details
*
************************************************************************/
#ifdef IXJ_DYN_ALLOC
static IXJ *ixj[IXJMAX];
#define get_ixj(b) ixj[(b)]
/*
* Allocate a free IXJ device
*/
static IXJ *ixj_alloc()
{
for(cnt=0; cnt<IXJMAX; cnt++)
{
if(ixj[cnt] == NULL || !ixj[cnt]->DSPbase)
{
j = kmalloc(sizeof(IXJ), GFP_KERNEL);
if (j == NULL)
return NULL;
ixj[cnt] = j;
return j;
}
}
return NULL;
}
static void ixj_fsk_free(IXJ *j)
{
if(j->fskdata != NULL) {
kfree(j->fskdata);
j->fskdata = NULL;
}
}
static void ixj_fsk_alloc(IXJ *j)
{
if(!j->fskdata) {
j->fskdata = kmalloc(8000, GFP_KERNEL);
if (!j->fskdata) {
if(ixjdebug & 0x0200) {
printk("IXJ phone%d - allocate failed\n", j->board);
}
return;
} else {
j->fsksize = 8000;
if(ixjdebug & 0x0200) {
printk("IXJ phone%d - allocate succeded\n", j->board);
}
}
}
}
#else
static IXJ ixj[IXJMAX];
#define get_ixj(b) (&ixj[(b)])
/*
* Allocate a free IXJ device
*/
static IXJ *ixj_alloc(void)
{
int cnt;
for(cnt=0; cnt<IXJMAX; cnt++) {
if(!ixj[cnt].DSPbase)
return &ixj[cnt];
}
return NULL;
}
static inline void ixj_fsk_free(IXJ *j) {;}
static inline void ixj_fsk_alloc(IXJ *j)
{
j->fsksize = 8000;
}
#endif
#ifdef PERFMON_STATS
#define ixj_perfmon(x) ((x)++)
#else
#define ixj_perfmon(x) do { } while(0)
#endif
static int ixj_convert_loaded;
static int ixj_WriteDSPCommand(unsigned short, IXJ *j);
/************************************************************************
*
* These are function definitions to allow external modules to register
* enhanced functionality call backs.
*
************************************************************************/
static int Stub(IXJ * J, unsigned long arg)
{
return 0;
}
static IXJ_REGFUNC ixj_PreRead = &Stub;
static IXJ_REGFUNC ixj_PostRead = &Stub;
static IXJ_REGFUNC ixj_PreWrite = &Stub;
static IXJ_REGFUNC ixj_PostWrite = &Stub;
static void ixj_read_frame(IXJ *j);
static void ixj_write_frame(IXJ *j);
static void ixj_init_timer(IXJ *j);
static void ixj_add_timer(IXJ * j);
static void ixj_timeout(unsigned long ptr);
static int read_filters(IXJ *j);
static int LineMonitor(IXJ *j);
static int ixj_fasync(int fd, struct file *, int mode);
static int ixj_set_port(IXJ *j, int arg);
static int ixj_set_pots(IXJ *j, int arg);
static int ixj_hookstate(IXJ *j);
static int ixj_record_start(IXJ *j);
static void ixj_record_stop(IXJ *j);
static void set_rec_volume(IXJ *j, int volume);
static int get_rec_volume(IXJ *j);
static int set_rec_codec(IXJ *j, int rate);
static void ixj_vad(IXJ *j, int arg);
static int ixj_play_start(IXJ *j);
static void ixj_play_stop(IXJ *j);
static int ixj_set_tone_on(unsigned short arg, IXJ *j);
static int ixj_set_tone_off(unsigned short, IXJ *j);
static int ixj_play_tone(IXJ *j, char tone);
static void ixj_aec_start(IXJ *j, int level);
static int idle(IXJ *j);
static void ixj_ring_on(IXJ *j);
static void ixj_ring_off(IXJ *j);
static void aec_stop(IXJ *j);
static void ixj_ringback(IXJ *j);
static void ixj_busytone(IXJ *j);
static void ixj_dialtone(IXJ *j);
static void ixj_cpt_stop(IXJ *j);
static char daa_int_read(IXJ *j);
static char daa_CR_read(IXJ *j, int cr);
static int daa_set_mode(IXJ *j, int mode);
static int ixj_linetest(IXJ *j);
static int ixj_daa_write(IXJ *j);
static int ixj_daa_cid_read(IXJ *j);
static void DAA_Coeff_US(IXJ *j);
static void DAA_Coeff_UK(IXJ *j);
static void DAA_Coeff_France(IXJ *j);
static void DAA_Coeff_Germany(IXJ *j);
static void DAA_Coeff_Australia(IXJ *j);
static void DAA_Coeff_Japan(IXJ *j);
static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf);
static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr);
static int ixj_init_tone(IXJ *j, IXJ_TONE * ti);
static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp);
static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp);
/* Serial Control Interface funtions */
static int SCI_Control(IXJ *j, int control);
static int SCI_Prepare(IXJ *j);
static int SCI_WaitHighSCI(IXJ *j);
static int SCI_WaitLowSCI(IXJ *j);
static DWORD PCIEE_GetSerialNumber(WORD wAddress);
static int ixj_PCcontrol_wait(IXJ *j);
static void ixj_pre_cid(IXJ *j);
static void ixj_write_cid(IXJ *j);
static void ixj_write_cid_bit(IXJ *j, int bit);
static int set_base_frame(IXJ *j, int size);
static int set_play_codec(IXJ *j, int rate);
static void set_rec_depth(IXJ *j, int depth);
static int ixj_mixer(long val, IXJ *j);
/************************************************************************
CT8020/CT8021 Host Programmers Model
Host address Function Access
DSPbase +
0-1 Aux Software Status Register (reserved) Read Only
2-3 Software Status Register Read Only
4-5 Aux Software Control Register (reserved) Read Write
6-7 Software Control Register Read Write
8-9 Hardware Status Register Read Only
A-B Hardware Control Register Read Write
C-D Host Transmit (Write) Data Buffer Access Port (buffer input)Write Only
E-F Host Recieve (Read) Data Buffer Access Port (buffer input) Read Only
************************************************************************/
static inline void ixj_read_HSR(IXJ *j)
{
j->hsr.bytes.low = inb_p(j->DSPbase + 8);
j->hsr.bytes.high = inb_p(j->DSPbase + 9);
}
static inline int IsControlReady(IXJ *j)
{
ixj_read_HSR(j);
return j->hsr.bits.controlrdy ? 1 : 0;
}
static inline int IsPCControlReady(IXJ *j)
{
j->pccr1.byte = inb_p(j->XILINXbase + 3);
return j->pccr1.bits.crr ? 1 : 0;
}
static inline int IsStatusReady(IXJ *j)
{
ixj_read_HSR(j);
return j->hsr.bits.statusrdy ? 1 : 0;
}
static inline int IsRxReady(IXJ *j)
{
ixj_read_HSR(j);
ixj_perfmon(j->rxreadycheck);
return j->hsr.bits.rxrdy ? 1 : 0;
}
static inline int IsTxReady(IXJ *j)
{
ixj_read_HSR(j);
ixj_perfmon(j->txreadycheck);
return j->hsr.bits.txrdy ? 1 : 0;
}
static inline void set_play_volume(IXJ *j, int volume)
{
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: /dev/phone%d Setting Play Volume to 0x%4.4x\n", j->board, volume);
ixj_WriteDSPCommand(0xCF02, j);
ixj_WriteDSPCommand(volume, j);
}
static int set_play_volume_linear(IXJ *j, int volume)
{
int newvolume, dspplaymax;
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Play Volume to 0x%4.4x\n", j->board, volume);
if(volume > 100 || volume < 0) {
return -1;
}
/* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
switch (j->cardtype) {
case QTI_PHONEJACK:
dspplaymax = 0x380;
break;
case QTI_LINEJACK:
if(j->port == PORT_PSTN) {
dspplaymax = 0x48;
} else {
dspplaymax = 0x100;
}
break;
case QTI_PHONEJACK_LITE:
dspplaymax = 0x380;
break;
case QTI_PHONEJACK_PCI:
dspplaymax = 0x6C;
break;
case QTI_PHONECARD:
dspplaymax = 0x50;
break;
default:
return -1;
}
newvolume = (dspplaymax * volume) / 100;
set_play_volume(j, newvolume);
return 0;
}
static inline void set_play_depth(IXJ *j, int depth)
{
if (depth > 60)
depth = 60;
if (depth < 0)
depth = 0;
ixj_WriteDSPCommand(0x5280 + depth, j);
}
static inline int get_play_volume(IXJ *j)
{
ixj_WriteDSPCommand(0xCF00, j);
return j->ssr.high << 8 | j->ssr.low;
}
static int get_play_volume_linear(IXJ *j)
{
int volume, newvolume, dspplaymax;
/* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
switch (j->cardtype) {
case QTI_PHONEJACK:
dspplaymax = 0x380;
break;
case QTI_LINEJACK:
if(j->port == PORT_PSTN) {
dspplaymax = 0x48;
} else {
dspplaymax = 0x100;
}
break;
case QTI_PHONEJACK_LITE:
dspplaymax = 0x380;
break;
case QTI_PHONEJACK_PCI:
dspplaymax = 0x6C;
break;
case QTI_PHONECARD:
dspplaymax = 100;
break;
default:
return -1;
}
volume = get_play_volume(j);
newvolume = (volume * 100) / dspplaymax;
if(newvolume > 100)
newvolume = 100;
return newvolume;
}
static inline BYTE SLIC_GetState(IXJ *j)
{
if (j->cardtype == QTI_PHONECARD) {
j->pccr1.byte = 0;
j->psccr.bits.dev = 3;
j->psccr.bits.rw = 1;
outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
ixj_PCcontrol_wait(j);
j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
ixj_PCcontrol_wait(j);
if (j->pslic.bits.powerdown)
return PLD_SLIC_STATE_OC;
else if (!j->pslic.bits.ring0 && !j->pslic.bits.ring1)
return PLD_SLIC_STATE_ACTIVE;
else
return PLD_SLIC_STATE_RINGING;
} else {
j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
}
return j->pld_slicr.bits.state;
}
static BOOL SLIC_SetState(BYTE byState, IXJ *j)
{
BOOL fRetVal = FALSE;
if (j->cardtype == QTI_PHONECARD) {
if (j->flags.pcmciasct) {
switch (byState) {
case PLD_SLIC_STATE_TIPOPEN:
case PLD_SLIC_STATE_OC:
j->pslic.bits.powerdown = 1;
j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_RINGING:
if (j->readers || j->writers) {
j->pslic.bits.powerdown = 0;
j->pslic.bits.ring0 = 1;
j->pslic.bits.ring1 = 0;
fRetVal = TRUE;
}
break;
case PLD_SLIC_STATE_OHT: /* On-hook transmit */
case PLD_SLIC_STATE_STANDBY:
case PLD_SLIC_STATE_ACTIVE:
if (j->readers || j->writers) {
j->pslic.bits.powerdown = 0;
} else {
j->pslic.bits.powerdown = 1;
}
j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_APR: /* Active polarity reversal */
case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
default:
fRetVal = FALSE;
break;
}
j->psccr.bits.dev = 3;
j->psccr.bits.rw = 0;
outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
ixj_PCcontrol_wait(j);
}
} else {
/* Set the C1, C2, C3 & B2EN signals. */
switch (byState) {
case PLD_SLIC_STATE_OC:
j->pld_slicw.bits.c1 = 0;
j->pld_slicw.bits.c2 = 0;
j->pld_slicw.bits.c3 = 0;
j->pld_slicw.bits.b2en = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_RINGING:
j->pld_slicw.bits.c1 = 1;
j->pld_slicw.bits.c2 = 0;
j->pld_slicw.bits.c3 = 0;
j->pld_slicw.bits.b2en = 1;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_ACTIVE:
j->pld_slicw.bits.c1 = 0;
j->pld_slicw.bits.c2 = 1;
j->pld_slicw.bits.c3 = 0;
j->pld_slicw.bits.b2en = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_OHT: /* On-hook transmit */
j->pld_slicw.bits.c1 = 1;
j->pld_slicw.bits.c2 = 1;
j->pld_slicw.bits.c3 = 0;
j->pld_slicw.bits.b2en = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_TIPOPEN:
j->pld_slicw.bits.c1 = 0;
j->pld_slicw.bits.c2 = 0;
j->pld_slicw.bits.c3 = 1;
j->pld_slicw.bits.b2en = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_STANDBY:
j->pld_slicw.bits.c1 = 1;
j->pld_slicw.bits.c2 = 0;
j->pld_slicw.bits.c3 = 1;
j->pld_slicw.bits.b2en = 1;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_APR: /* Active polarity reversal */
j->pld_slicw.bits.c1 = 0;
j->pld_slicw.bits.c2 = 1;
j->pld_slicw.bits.c3 = 1;
j->pld_slicw.bits.b2en = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
fRetVal = TRUE;
break;
case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
j->pld_slicw.bits.c1 = 1;
j->pld_slicw.bits.c2 = 1;
j->pld_slicw.bits.c3 = 1;
j->pld_slicw.bits.b2en = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
fRetVal = TRUE;
break;
default:
fRetVal = FALSE;
break;
}
}
return fRetVal;
}
static int ixj_wink(IXJ *j)
{
BYTE slicnow;
slicnow = SLIC_GetState(j);
j->pots_winkstart = jiffies;
SLIC_SetState(PLD_SLIC_STATE_OC, j);
while (time_before(jiffies, j->pots_winkstart + j->winktime)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
SLIC_SetState(slicnow, j);
return 0;
}
static void ixj_init_timer(IXJ *j)
{
init_timer(&j->timer);
j->timer.function = ixj_timeout;
j->timer.data = (unsigned long)j;
}
static void ixj_add_timer(IXJ *j)
{
j->timer.expires = jiffies + (hertz / samplerate);
add_timer(&j->timer);
}
static void ixj_tone_timeout(IXJ *j)
{
IXJ_TONE ti;
j->tone_state++;
if (j->tone_state == 3) {
j->tone_state = 0;
if (j->cadence_t) {
j->tone_cadence_state++;
if (j->tone_cadence_state >= j->cadence_t->elements_used) {
switch (j->cadence_t->termination) {
case PLAY_ONCE:
ixj_cpt_stop(j);
break;
case REPEAT_LAST_ELEMENT:
j->tone_cadence_state--;
ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
break;
case REPEAT_ALL:
j->tone_cadence_state = 0;
if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
ixj_init_tone(j, &ti);
}
ixj_set_tone_on(j->cadence_t->ce[0].tone_on_time, j);
ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, j);
ixj_play_tone(j, j->cadence_t->ce[0].index);
break;
}
} else {
if (j->cadence_t->ce[j->tone_cadence_state].gain0) {
ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
ixj_init_tone(j, &ti);
}
ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, j);
ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, j);
ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
}
}
}
}
static inline void ixj_kill_fasync(IXJ *j, IXJ_SIGEVENT event, int dir)
{
if(j->ixj_signals[event]) {
if(ixjdebug & 0x0100)
printk("Sending signal for event %d\n", event);
/* Send apps notice of change */
/* see config.h for macro definition */
kill_fasync(&(j->async_queue), j->ixj_signals[event], dir);
}
}
static void ixj_pstn_state(IXJ *j)
{
int var;
union XOPXR0 XR0, daaint;
var = 10;
XR0.reg = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg;
daaint.reg = 0;
XR0.bitreg.RMR = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
j->pld_scrr.byte = inb_p(j->XILINXbase);
if (j->pld_scrr.bits.daaflag) {
daa_int_read(j);
if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) {
if(time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
daaint.bitreg.RING = 1;
if(ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ DAA Ring Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
}
} else {
daa_set_mode(j, SOP_PU_RESET);
}
}
if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) {
daaint.bitreg.Caller_ID = 1;
j->pstn_cid_intr = 1;
j->pstn_cid_received = jiffies;
if(ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ DAA Caller_ID Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
}
}
if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) {
daaint.bitreg.Cadence = 1;
if(ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ DAA Cadence Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
}
}
if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK != XR0.bitreg.VDD_OK) {
daaint.bitreg.VDD_OK = 1;
daaint.bitreg.SI_0 = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK;
}
}
daa_CR_read(j, 1);
if(j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR != XR0.bitreg.RMR && time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
daaint.bitreg.RMR = 1;
daaint.bitreg.SI_1 = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
if(ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ DAA RMR /dev/phone%d was %s for %ld\n", j->board, XR0.bitreg.RMR?"on":"off", jiffies - j->pstn_last_rmr);
}
j->pstn_prev_rmr = j->pstn_last_rmr;
j->pstn_last_rmr = jiffies;
}
switch(j->daa_mode) {
case SOP_PU_SLEEP:
if (daaint.bitreg.RING) {
if (!j->flags.pstn_ringing) {
if (j->daa_mode != SOP_PU_RINGING) {
j->pstn_ring_int = jiffies;
daa_set_mode(j, SOP_PU_RINGING);
}
}
}
break;
case SOP_PU_RINGING:
if (daaint.bitreg.RMR) {
if (ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ Ring Cadence a state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
}
if (daaint.bitreg.SI_1) { /* Rising edge of RMR */
j->flags.pstn_rmr = 1;
j->pstn_ring_start = jiffies;
j->pstn_ring_stop = 0;
j->ex.bits.pstn_ring = 0;
if (j->cadence_f[4].state == 0) {
j->cadence_f[4].state = 1;
j->cadence_f[4].on1min = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 - var)) / 10000);
j->cadence_f[4].on1dot = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100)) / 10000);
j->cadence_f[4].on1max = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 + var)) / 10000);
} else if (j->cadence_f[4].state == 2) {
if((time_after(jiffies, j->cadence_f[4].off1min) &&
time_before(jiffies, j->cadence_f[4].off1max))) {
if (j->cadence_f[4].on2) {
j->cadence_f[4].state = 3;
j->cadence_f[4].on2min = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 - var)) / 10000));
j->cadence_f[4].on2dot = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100)) / 10000));
j->cadence_f[4].on2max = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[4].state = 7;
}
} else {
if (ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
j->cadence_f[4].off1);
}
j->cadence_f[4].state = 0;
}
} else if (j->cadence_f[4].state == 4) {
if((time_after(jiffies, j->cadence_f[4].off2min) &&
time_before(jiffies, j->cadence_f[4].off2max))) {
if (j->cadence_f[4].on3) {
j->cadence_f[4].state = 5;
j->cadence_f[4].on3min = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 - var)) / 10000));
j->cadence_f[4].on3dot = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100)) / 10000));
j->cadence_f[4].on3max = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[4].state = 7;
}
} else {
if (ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
j->cadence_f[4].off2);
}
j->cadence_f[4].state = 0;
}
} else if (j->cadence_f[4].state == 6) {
if((time_after(jiffies, j->cadence_f[4].off3min) &&
time_before(jiffies, j->cadence_f[4].off3max))) {
j->cadence_f[4].state = 7;
} else {
if (ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
j->cadence_f[4].off3);
}
j->cadence_f[4].state = 0;
}
} else {
j->cadence_f[4].state = 0;
}
} else { /* Falling edge of RMR */
j->pstn_ring_start = 0;
j->pstn_ring_stop = jiffies;
if (j->cadence_f[4].state == 1) {
if(!j->cadence_f[4].on1) {
j->cadence_f[4].state = 7;
} else if((time_after(jiffies, j->cadence_f[4].on1min) &&
time_before(jiffies, j->cadence_f[4].on1max))) {
if (j->cadence_f[4].off1) {
j->cadence_f[4].state = 2;
j->cadence_f[4].off1min = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 - var)) / 10000));
j->cadence_f[4].off1dot = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100)) / 10000));
j->cadence_f[4].off1max = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[4].state = 7;
}
} else {
if (ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
j->cadence_f[4].on1);
}
j->cadence_f[4].state = 0;
}
} else if (j->cadence_f[4].state == 3) {
if((time_after(jiffies, j->cadence_f[4].on2min) &&
time_before(jiffies, j->cadence_f[4].on2max))) {
if (j->cadence_f[4].off2) {
j->cadence_f[4].state = 4;
j->cadence_f[4].off2min = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 - var)) / 10000));
j->cadence_f[4].off2dot = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100)) / 10000));
j->cadence_f[4].off2max = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[4].state = 7;
}
} else {
if (ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
j->cadence_f[4].on2);
}
j->cadence_f[4].state = 0;
}
} else if (j->cadence_f[4].state == 5) {
if((time_after(jiffies, j->cadence_f[4].on3min) &&
time_before(jiffies, j->cadence_f[4].on3max))) {
if (j->cadence_f[4].off3) {
j->cadence_f[4].state = 6;
j->cadence_f[4].off3min = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 - var)) / 10000));
j->cadence_f[4].off3dot = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100)) / 10000));
j->cadence_f[4].off3max = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[4].state = 7;
}
} else {
j->cadence_f[4].state = 0;
}
} else {
if (ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
j->cadence_f[4].on3);
}
j->cadence_f[4].state = 0;
}
}
if (ixjdebug & 0x0010) {
printk(KERN_INFO "IXJ Ring Cadence b state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
}
if (ixjdebug & 0x0010) {
switch(j->cadence_f[4].state) {
case 1:
printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
j->cadence_f[4].on1, j->cadence_f[4].on1min, j->cadence_f[4].on1dot, j->cadence_f[4].on1max);
break;
case 2:
printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
j->cadence_f[4].off1, j->cadence_f[4].off1min, j->cadence_f[4].off1dot, j->cadence_f[4].off1max);
break;
case 3:
printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
j->cadence_f[4].on2, j->cadence_f[4].on2min, j->cadence_f[4].on2dot, j->cadence_f[4].on2max);
break;
case 4:
printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
j->cadence_f[4].off2, j->cadence_f[4].off2min, j->cadence_f[4].off2dot, j->cadence_f[4].off2max);
break;
case 5:
printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max);
break;
case 6:
printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max);
break;
}
}
}
if (j->cadence_f[4].state == 7) {
j->cadence_f[4].state = 0;
j->pstn_ring_stop = jiffies;
j->ex.bits.pstn_ring = 1;
ixj_kill_fasync(j, SIG_PSTN_RING, POLL_IN);
if(ixjdebug & 0x0008) {
printk(KERN_INFO "IXJ Ring int set /dev/phone%d at %ld\n", j->board, jiffies);
}
}
if((j->pstn_ring_int != 0 && time_after(jiffies, j->pstn_ring_int + (hertz * 5)) && !j->flags.pstn_rmr) ||
(j->pstn_ring_stop != 0 && time_after(jiffies, j->pstn_ring_stop + (hertz * 5)))) {
if(ixjdebug & 0x0008) {
printk("IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->board, jiffies);
printk("IXJ DAA pstn ring int /dev/phone%d at %ld\n", j->board, j->pstn_ring_int);
printk("IXJ DAA pstn ring stop /dev/phone%d at %ld\n", j->board, j->pstn_ring_stop);
}
j->pstn_ring_stop = j->pstn_ring_int = 0;
daa_set_mode(j, SOP_PU_SLEEP);
}
outb_p(j->pld_scrw.byte, j->XILINXbase);
if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) {
ixj_daa_cid_read(j);
j->ex.bits.caller_id = 1;
ixj_kill_fasync(j, SIG_CALLER_ID, POLL_IN);
j->pstn_cid_intr = 0;
}
if (daaint.bitreg.Cadence) {
if(ixjdebug & 0x0008) {
printk("IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->board);
}
daa_set_mode(j, SOP_PU_SLEEP);
j->ex.bits.pstn_ring = 0;
}
break;
case SOP_PU_CONVERSATION:
if (daaint.bitreg.VDD_OK) {
if(!daaint.bitreg.SI_0) {
if (!j->pstn_winkstart) {
if(ixjdebug & 0x0008) {
printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies);
}
j->pstn_winkstart = jiffies;
}
} else {
if (j->pstn_winkstart) {
if(ixjdebug & 0x0008) {
printk("IXJ DAA possible wink end /dev/phone%d %ld\n", j->board, jiffies);
}
j->pstn_winkstart = 0;
}
}
}
if (j->pstn_winkstart && time_after(jiffies, j->pstn_winkstart + ((hertz * j->winktime) / 1000))) {
if(ixjdebug & 0x0008) {
printk("IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->board, jiffies);
}
daa_set_mode(j, SOP_PU_SLEEP);
j->pstn_winkstart = 0;
j->ex.bits.pstn_wink = 1;
ixj_kill_fasync(j, SIG_PSTN_WINK, POLL_IN);
}
break;
}
}
static void ixj_timeout(unsigned long ptr)
{
int board;
unsigned long jifon;
IXJ *j = (IXJ *)ptr;
board = j->board;
if (j->DSPbase && atomic_read(&j->DSPWrite) == 0 && test_and_set_bit(board, (void *)&j->busyflags) == 0) {
ixj_perfmon(j->timerchecks);
j->hookstate = ixj_hookstate(j);
if (j->tone_state) {
if (!(j->hookstate)) {
ixj_cpt_stop(j);
if (j->m_hook) {
j->m_hook = 0;
j->ex.bits.hookstate = 1;
ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
}
clear_bit(board, &j->busyflags);
ixj_add_timer(j);
return;
}
if (j->tone_state == 1)
jifon = ((hertz * j->tone_on_time) * 25 / 100000);
else
jifon = ((hertz * j->tone_on_time) * 25 / 100000) + ((hertz * j->tone_off_time) * 25 / 100000);
if (time_before(jiffies, j->tone_start_jif + jifon)) {
if (j->tone_state == 1) {
ixj_play_tone(j, j->tone_index);
if (j->dsp.low == 0x20) {
clear_bit(board, &j->busyflags);
ixj_add_timer(j);
return;
}
} else {
ixj_play_tone(j, 0);
if (j->dsp.low == 0x20) {
clear_bit(board, &j->busyflags);
ixj_add_timer(j);
return;
}
}
} else {
ixj_tone_timeout(j);
if (j->flags.dialtone) {
ixj_dialtone(j);
}
if (j->flags.busytone) {
ixj_busytone(j);
if (j->dsp.low == 0x20) {
clear_bit(board, &j->busyflags);
ixj_add_timer(j);
return;
}
}
if (j->flags.ringback) {
ixj_ringback(j);
if (j->dsp.low == 0x20) {
clear_bit(board, &j->busyflags);
ixj_add_timer(j);
return;
}
}
if (!j->tone_state) {
ixj_cpt_stop(j);
}
}
}
if (!(j->tone_state && j->dsp.low == 0x20)) {
if (IsRxReady(j)) {
ixj_read_frame(j);
}
if (IsTxReady(j)) {
ixj_write_frame(j);
}
}
if (j->flags.cringing) {
if (j->hookstate & 1) {
j->flags.cringing = 0;
ixj_ring_off(j);
} else if(j->cadence_f[5].enable && ((!j->cadence_f[5].en_filter) || (j->cadence_f[5].en_filter && j->flags.firstring))) {
switch(j->cadence_f[5].state) {
case 0:
j->cadence_f[5].on1dot = jiffies + (long)((j->cadence_f[5].on1 * (hertz * 100) / 10000));
if (time_before(jiffies, j->cadence_f[5].on1dot)) {
if(ixjdebug & 0x0004) {
printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
}
ixj_ring_on(j);
}
j->cadence_f[5].state = 1;
break;
case 1:
if (time_after(jiffies, j->cadence_f[5].on1dot)) {
j->cadence_f[5].off1dot = jiffies + (long)((j->cadence_f[5].off1 * (hertz * 100) / 10000));
if(ixjdebug & 0x0004) {
printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
}
ixj_ring_off(j);
j->cadence_f[5].state = 2;
}
break;
case 2:
if (time_after(jiffies, j->cadence_f[5].off1dot)) {
if(ixjdebug & 0x0004) {
printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
}
ixj_ring_on(j);
if (j->cadence_f[5].on2) {
j->cadence_f[5].on2dot = jiffies + (long)((j->cadence_f[5].on2 * (hertz * 100) / 10000));
j->cadence_f[5].state = 3;
} else {
j->cadence_f[5].state = 7;
}
}
break;
case 3:
if (time_after(jiffies, j->cadence_f[5].on2dot)) {
if(ixjdebug & 0x0004) {
printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
}
ixj_ring_off(j);
if (j->cadence_f[5].off2) {
j->cadence_f[5].off2dot = jiffies + (long)((j->cadence_f[5].off2 * (hertz * 100) / 10000));
j->cadence_f[5].state = 4;
} else {
j->cadence_f[5].state = 7;
}
}
break;
case 4:
if (time_after(jiffies, j->cadence_f[5].off2dot)) {
if(ixjdebug & 0x0004) {
printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
}
ixj_ring_on(j);
if (j->cadence_f[5].on3) {
j->cadence_f[5].on3dot = jiffies + (long)((j->cadence_f[5].on3 * (hertz * 100) / 10000));
j->cadence_f[5].state = 5;
} else {
j->cadence_f[5].state = 7;
}
}
break;
case 5:
if (time_after(jiffies, j->cadence_f[5].on3dot)) {
if(ixjdebug & 0x0004) {
printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
}
ixj_ring_off(j);
if (j->cadence_f[5].off3) {
j->cadence_f[5].off3dot = jiffies + (long)((j->cadence_f[5].off3 * (hertz * 100) / 10000));
j->cadence_f[5].state = 6;
} else {
j->cadence_f[5].state = 7;
}
}
break;
case 6:
if (time_after(jiffies, j->cadence_f[5].off3dot)) {
if(ixjdebug & 0x0004) {
printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
}
j->cadence_f[5].state = 7;
}
break;
case 7:
if(ixjdebug & 0x0004) {
printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
}
j->flags.cidring = 1;
j->cadence_f[5].state = 0;
break;
}
if (j->flags.cidring && !j->flags.cidsent) {
j->flags.cidsent = 1;
if(j->fskdcnt) {
SLIC_SetState(PLD_SLIC_STATE_OHT, j);
ixj_pre_cid(j);
}
j->flags.cidring = 0;
}
clear_bit(board, &j->busyflags);
ixj_add_timer(j);
return;
} else {
if (time_after(jiffies, j->ring_cadence_jif + (hertz / 2))) {
if (j->flags.cidring && !j->flags.cidsent) {
j->flags.cidsent = 1;
if(j->fskdcnt) {
SLIC_SetState(PLD_SLIC_STATE_OHT, j);
ixj_pre_cid(j);
}
j->flags.cidring = 0;
}
j->ring_cadence_t--;
if (j->ring_cadence_t == -1)
j->ring_cadence_t = 15;
j->ring_cadence_jif = jiffies;
if (j->ring_cadence & 1 << j->ring_cadence_t) {
if(j->flags.cidsent && j->cadence_f[5].en_filter)
j->flags.firstring = 1;
else
ixj_ring_on(j);
} else {
ixj_ring_off(j);
if(!j->flags.cidsent)
j->flags.cidring = 1;
}
}
clear_bit(board, &j->busyflags);
ixj_add_timer(j);
return;
}
}
if (!j->flags.ringing) {
if (j->hookstate) { /* & 1) { */
if (j->dsp.low != 0x20 &&
SLIC_GetState(j) != PLD_SLIC_STATE_ACTIVE) {
SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
}
LineMonitor(j);
read_filters(j);
ixj_WriteDSPCommand(0x511B, j);
j->proc_load = j->ssr.high << 8 | j->ssr.low;
if (!j->m_hook && (j->hookstate & 1)) {
j->m_hook = j->ex.bits.hookstate = 1;
ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
}
} else {
if (j->ex.bits.dtmf_ready) {
j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0;
}
if (j->m_hook) {
j->m_hook = 0;
j->ex.bits.hookstate = 1;
ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
}
}
}
if (j->cardtype == QTI_LINEJACK && !j->flags.pstncheck && j->flags.pstn_present) {
ixj_pstn_state(j);
}
if (j->ex.bytes) {
wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
}
clear_bit(board, &j->busyflags);
}
ixj_add_timer(j);
}
static int ixj_status_wait(IXJ *j)
{
unsigned long jif;
jif = jiffies + ((60 * hertz) / 100);
while (!IsStatusReady(j)) {
ixj_perfmon(j->statuswait);
if (time_after(jiffies, jif)) {
ixj_perfmon(j->statuswaitfail);
return -1;
}
}
return 0;
}
static int ixj_PCcontrol_wait(IXJ *j)
{
unsigned long jif;
jif = jiffies + ((60 * hertz) / 100);
while (!IsPCControlReady(j)) {
ixj_perfmon(j->pcontrolwait);
if (time_after(jiffies, jif)) {
ixj_perfmon(j->pcontrolwaitfail);
return -1;
}
}
return 0;
}
static int ixj_WriteDSPCommand(unsigned short cmd, IXJ *j)
{
BYTES bytes;
unsigned long jif;
atomic_inc(&j->DSPWrite);
if(atomic_read(&j->DSPWrite) > 1) {
printk("IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->board, cmd);
return -1;
}
bytes.high = (cmd & 0xFF00) >> 8;
bytes.low = cmd & 0x00FF;
jif = jiffies + ((60 * hertz) / 100);
while (!IsControlReady(j)) {
ixj_perfmon(j->iscontrolready);
if (time_after(jiffies, jif)) {
ixj_perfmon(j->iscontrolreadyfail);
atomic_dec(&j->DSPWrite);
if(atomic_read(&j->DSPWrite) > 0) {
printk("IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->board, cmd);
while(atomic_read(&j->DSPWrite) > 0) {
atomic_dec(&j->DSPWrite);
}
}
return -1;
}
}
outb(bytes.low, j->DSPbase + 6);
outb(bytes.high, j->DSPbase + 7);
if (ixj_status_wait(j)) {
j->ssr.low = 0xFF;
j->ssr.high = 0xFF;
atomic_dec(&j->DSPWrite);
if(atomic_read(&j->DSPWrite) > 0) {
printk("IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->board, cmd);
while(atomic_read(&j->DSPWrite) > 0) {
atomic_dec(&j->DSPWrite);
}
}
return -1;
}
/* Read Software Status Register */
j->ssr.low = inb_p(j->DSPbase + 2);
j->ssr.high = inb_p(j->DSPbase + 3);
atomic_dec(&j->DSPWrite);
if(atomic_read(&j->DSPWrite) > 0) {
printk("IXJ %d DSP overlaped command 0x%4.4x\n", j->board, cmd);
while(atomic_read(&j->DSPWrite) > 0) {
atomic_dec(&j->DSPWrite);
}
}
return 0;
}
/***************************************************************************
*
* General Purpose IO Register read routine
*
***************************************************************************/
static inline int ixj_gpio_read(IXJ *j)
{
if (ixj_WriteDSPCommand(0x5143, j))
return -1;
j->gpio.bytes.low = j->ssr.low;
j->gpio.bytes.high = j->ssr.high;
return 0;
}
static inline void LED_SetState(int state, IXJ *j)
{
if (j->cardtype == QTI_LINEJACK) {
j->pld_scrw.bits.led1 = state & 0x1 ? 1 : 0;
j->pld_scrw.bits.led2 = state & 0x2 ? 1 : 0;
j->pld_scrw.bits.led3 = state & 0x4 ? 1 : 0;
j->pld_scrw.bits.led4 = state & 0x8 ? 1 : 0;
outb(j->pld_scrw.byte, j->XILINXbase);
}
}
/*********************************************************************
* GPIO Pins are configured as follows on the Quicknet Internet
* PhoneJACK Telephony Cards
*
* POTS Select GPIO_6=0 GPIO_7=0
* Mic/Speaker Select GPIO_6=0 GPIO_7=1
* Handset Select GPIO_6=1 GPIO_7=0
*
* SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0
* SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0
* SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0
*
* Hook Switch changes reported on GPIO_3
*********************************************************************/
static int ixj_set_port(IXJ *j, int arg)
{
if (j->cardtype == QTI_PHONEJACK_LITE) {
if (arg != PORT_POTS)
return 10;
else
return 0;
}
switch (arg) {
case PORT_POTS:
j->port = PORT_POTS;
switch (j->cardtype) {
case QTI_PHONECARD:
if (j->flags.pcmciasct == 1)
SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
else
return 11;
break;
case QTI_PHONEJACK_PCI:
j->pld_slicw.pcib.mic = 0;
j->pld_slicw.pcib.spk = 0;
outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
break;
case QTI_LINEJACK:
ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
Software Control Register */
return 2;
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb(j->pld_scrw.byte, j->XILINXbase);
j->pld_clock.byte = 0;
outb(j->pld_clock.byte, j->XILINXbase + 0x04);
j->pld_slicw.bits.rly1 = 1;
j->pld_slicw.bits.spken = 0;
outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
ixj_mixer(0x1200, j); /* Turn Off MIC switch on mixer left */
ixj_mixer(0x1401, j); /* Turn On Mono1 switch on mixer left */
ixj_mixer(0x1300, j); /* Turn Off MIC switch on mixer right */
ixj_mixer(0x1501, j); /* Turn On Mono1 switch on mixer right */
ixj_mixer(0x0E80, j); /*Mic mute */
ixj_mixer(0x0F00, j); /* Set mono out (SLIC) to 0dB */
ixj_mixer(0x0080, j); /* Mute Master Left volume */
ixj_mixer(0x0180, j); /* Mute Master Right volume */
SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
/* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
break;
case QTI_PHONEJACK:
j->gpio.bytes.high = 0x0B;
j->gpio.bits.gpio6 = 0;
j->gpio.bits.gpio7 = 0;
ixj_WriteDSPCommand(j->gpio.word, j);
break;
}
break;
case PORT_PSTN:
if (j->cardtype == QTI_LINEJACK) {
ixj_WriteDSPCommand(0xC534, j); /* Write CODEC config to Software Control Register */
j->pld_slicw.bits.rly3 = 0;
j->pld_slicw.bits.rly1 = 1;
j->pld_slicw.bits.spken = 0;
outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
j->port = PORT_PSTN;
} else {
return 4;
}
break;
case PORT_SPEAKER:
j->port = PORT_SPEAKER;
switch (j->cardtype) {
case QTI_PHONECARD:
if (j->flags.pcmciasct) {
SLIC_SetState(PLD_SLIC_STATE_OC, j);
}
break;
case QTI_PHONEJACK_PCI:
j->pld_slicw.pcib.mic = 1;
j->pld_slicw.pcib.spk = 1;
outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
break;
case QTI_LINEJACK:
ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
Software Control Register */
return 2;
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb(j->pld_scrw.byte, j->XILINXbase);
j->pld_clock.byte = 0;
outb(j->pld_clock.byte, j->XILINXbase + 0x04);
j->pld_slicw.bits.rly1 = 1;
j->pld_slicw.bits.spken = 1;
outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
ixj_mixer(0x1201, j); /* Turn On MIC switch on mixer left */
ixj_mixer(0x1400, j); /* Turn Off Mono1 switch on mixer left */
ixj_mixer(0x1301, j); /* Turn On MIC switch on mixer right */
ixj_mixer(0x1500, j); /* Turn Off Mono1 switch on mixer right */
ixj_mixer(0x0E06, j); /*Mic un-mute 0dB */
ixj_mixer(0x0F80, j); /* Mute mono out (SLIC) */
ixj_mixer(0x0000, j); /* Set Master Left volume to 0dB */
ixj_mixer(0x0100, j); /* Set Master Right volume to 0dB */
break;
case QTI_PHONEJACK:
j->gpio.bytes.high = 0x0B;
j->gpio.bits.gpio6 = 0;
j->gpio.bits.gpio7 = 1;
ixj_WriteDSPCommand(j->gpio.word, j);
break;
}
break;
case PORT_HANDSET:
if (j->cardtype != QTI_PHONEJACK) {
return 5;
} else {
j->gpio.bytes.high = 0x0B;
j->gpio.bits.gpio6 = 1;
j->gpio.bits.gpio7 = 0;
ixj_WriteDSPCommand(j->gpio.word, j);
j->port = PORT_HANDSET;
}
break;
default:
return 6;
break;
}
return 0;
}
static int ixj_set_pots(IXJ *j, int arg)
{
if (j->cardtype == QTI_LINEJACK) {
if (arg) {
if (j->port == PORT_PSTN) {
j->pld_slicw.bits.rly1 = 0;
outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
j->flags.pots_pstn = 1;
return 1;
} else {
j->flags.pots_pstn = 0;
return 0;
}
} else {
j->pld_slicw.bits.rly1 = 1;
outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
j->flags.pots_pstn = 0;
return 1;
}
} else {
return 0;
}
}
static void ixj_ring_on(IXJ *j)
{
if (j->dsp.low == 0x20) /* Internet PhoneJACK */
{
if (ixjdebug & 0x0004)
printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
j->gpio.bytes.high = 0x0B;
j->gpio.bytes.low = 0x00;
j->gpio.bits.gpio1 = 1;
j->gpio.bits.gpio2 = 1;
j->gpio.bits.gpio5 = 0;
ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring signal */
} else /* Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI */
{
if (ixjdebug & 0x0004)
printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
SLIC_SetState(PLD_SLIC_STATE_RINGING, j);
}
}
static int ixj_siadc(IXJ *j, int val)
{
if(j->cardtype == QTI_PHONECARD){
if(j->flags.pcmciascp){
if(val == -1)
return j->siadc.bits.rxg;
if(val < 0 || val > 0x1F)
return -1;
j->siadc.bits.hom = 0; /* Handset Out Mute */
j->siadc.bits.lom = 0; /* Line Out Mute */
j->siadc.bits.rxg = val; /*(0xC000 - 0x41C8) / 0x4EF; RX PGA Gain */
j->psccr.bits.addr = 6; /* R/W Smart Cable Register Address */
j->psccr.bits.rw = 0; /* Read / Write flag */
j->psccr.bits.dev = 0;
outb(j->siadc.byte, j->XILINXbase + 0x00);
outb(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
return j->siadc.bits.rxg;
}
}
return -1;
}
static int ixj_sidac(IXJ *j, int val)
{
if(j->cardtype == QTI_PHONECARD){
if(j->flags.pcmciascp){
if(val == -1)
return j->sidac.bits.txg;
if(val < 0 || val > 0x1F)
return -1;
j->sidac.bits.srm = 1; /* Speaker Right Mute */
j->sidac.bits.slm = 1; /* Speaker Left Mute */
j->sidac.bits.txg = val; /* (0xC000 - 0x45E4) / 0x5D3; TX PGA Gain */
j->psccr.bits.addr = 7; /* R/W Smart Cable Register Address */
j->psccr.bits.rw = 0; /* Read / Write flag */
j->psccr.bits.dev = 0;
outb(j->sidac.byte, j->XILINXbase + 0x00);
outb(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
return j->sidac.bits.txg;
}
}
return -1;
}
static int ixj_pcmcia_cable_check(IXJ *j)
{
j->pccr1.byte = inb_p(j->XILINXbase + 0x03);
if (!j->flags.pcmciastate) {
j->pccr2.byte = inb_p(j->XILINXbase + 0x02);
if (j->pccr1.bits.drf || j->pccr2.bits.rstc) {
j->flags.pcmciastate = 4;
return 0;
}
if (j->pccr1.bits.ed) {
j->pccr1.bits.ed = 0;
j->psccr.bits.dev = 3;
j->psccr.bits.rw = 1;
outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
ixj_PCcontrol_wait(j);
j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0;
j->psccr.bits.dev = 3;
j->psccr.bits.rw = 0;
outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
ixj_PCcontrol_wait(j);
return j->pslic.bits.led2 ? 1 : 0;
} else if (j->flags.pcmciasct) {
return j->r_hook;
} else {
return 1;
}
} else if (j->flags.pcmciastate == 4) {
if (!j->pccr1.bits.drf) {
j->flags.pcmciastate = 3;
}
return 0;
} else if (j->flags.pcmciastate == 3) {
j->pccr2.bits.pwr = 0;
j->pccr2.bits.rstc = 1;
outb(j->pccr2.byte, j->XILINXbase + 0x02);
j->checkwait = jiffies + (hertz * 2);
j->flags.incheck = 1;
j->flags.pcmciastate = 2;
return 0;
} else if (j->flags.pcmciastate == 2) {
if (j->flags.incheck) {
if (time_before(jiffies, j->checkwait)) {
return 0;
} else {
j->flags.incheck = 0;
}
}
j->pccr2.bits.pwr = 0;
j->pccr2.bits.rstc = 0;
outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
j->flags.pcmciastate = 1;
return 0;
} else if (j->flags.pcmciastate == 1) {
j->flags.pcmciastate = 0;
if (!j->pccr1.bits.drf) {
j->psccr.bits.dev = 3;
j->psccr.bits.rw = 1;
outb_p(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
j->flags.pcmciascp = 1; /* Set Cable Present Flag */
j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; /* Get Cable Type */
if (j->flags.pcmciasct == 3) {
j->flags.pcmciastate = 4;
return 0;
} else if (j->flags.pcmciasct == 0) {
j->pccr2.bits.pwr = 1;
j->pccr2.bits.rstc = 0;
outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
j->port = PORT_SPEAKER;
} else {
j->port = PORT_POTS;
}
j->sic1.bits.cpd = 0; /* Chip Power Down */
j->sic1.bits.mpd = 0; /* MIC Bias Power Down */
j->sic1.bits.hpd = 0; /* Handset Bias Power Down */
j->sic1.bits.lpd = 0; /* Line Bias Power Down */
j->sic1.bits.spd = 1; /* Speaker Drive Power Down */
j->psccr.bits.addr = 1; /* R/W Smart Cable Register Address */
j->psccr.bits.rw = 0; /* Read / Write flag */
j->psccr.bits.dev = 0;
outb(j->sic1.byte, j->XILINXbase + 0x00);
outb(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
j->sic2.bits.al = 0; /* Analog Loopback DAC analog -> ADC analog */
j->sic2.bits.dl2 = 0; /* Digital Loopback DAC -> ADC one bit */
j->sic2.bits.dl1 = 0; /* Digital Loopback ADC -> DAC one bit */
j->sic2.bits.pll = 0; /* 1 = div 10, 0 = div 5 */
j->sic2.bits.hpd = 0; /* HPF disable */
j->psccr.bits.addr = 2; /* R/W Smart Cable Register Address */
j->psccr.bits.rw = 0; /* Read / Write flag */
j->psccr.bits.dev = 0;
outb(j->sic2.byte, j->XILINXbase + 0x00);
outb(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
j->psccr.bits.addr = 3; /* R/W Smart Cable Register Address */
j->psccr.bits.rw = 0; /* Read / Write flag */
j->psccr.bits.dev = 0;
outb(0x00, j->XILINXbase + 0x00); /* PLL Divide N1 */
outb(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
j->psccr.bits.addr = 4; /* R/W Smart Cable Register Address */
j->psccr.bits.rw = 0; /* Read / Write flag */
j->psccr.bits.dev = 0;
outb(0x09, j->XILINXbase + 0x00); /* PLL Multiply M1 */
outb(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
j->sirxg.bits.lig = 1; /* Line In Gain */
j->sirxg.bits.lim = 1; /* Line In Mute */
j->sirxg.bits.mcg = 0; /* MIC In Gain was 3 */
j->sirxg.bits.mcm = 0; /* MIC In Mute */
j->sirxg.bits.him = 0; /* Handset In Mute */
j->sirxg.bits.iir = 1; /* IIR */
j->psccr.bits.addr = 5; /* R/W Smart Cable Register Address */
j->psccr.bits.rw = 0; /* Read / Write flag */
j->psccr.bits.dev = 0;
outb(j->sirxg.byte, j->XILINXbase + 0x00);
outb(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
ixj_siadc(j, 0x17);
ixj_sidac(j, 0x1D);
j->siaatt.bits.sot = 0;
j->psccr.bits.addr = 9; /* R/W Smart Cable Register Address */
j->psccr.bits.rw = 0; /* Read / Write flag */
j->psccr.bits.dev = 0;
outb(j->siaatt.byte, j->XILINXbase + 0x00);
outb(j->psccr.byte, j->XILINXbase + 0x01);
ixj_PCcontrol_wait(j);
if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) {
j->psccr.byte = j->pslic.byte = 0;
j->pslic.bits.powerdown = 1;
j->psccr.bits.dev = 3;
j->psccr.bits.rw = 0;
outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
ixj_PCcontrol_wait(j);
}
}
return 0;
} else {
j->flags.pcmciascp = 0;
return 0;
}
return 0;
}
static int ixj_hookstate(IXJ *j)
{
unsigned long det;
int fOffHook = 0;
switch (j->cardtype) {
case QTI_PHONEJACK:
ixj_gpio_read(j);
fOffHook = j->gpio.bits.gpio3read ? 1 : 0;
break;
case QTI_LINEJACK:
case QTI_PHONEJACK_LITE:
case QTI_PHONEJACK_PCI:
SLIC_GetState(j);
if(j->cardtype == QTI_LINEJACK && j->flags.pots_pstn == 1 && (j->readers || j->writers)) {
fOffHook = j->pld_slicr.bits.potspstn ? 1 : 0;
if(fOffHook != j->p_hook) {
if(!j->checkwait) {
j->checkwait = jiffies;
}
if(time_before(jiffies, j->checkwait + 2)) {
fOffHook ^= 1;
} else {
j->checkwait = 0;
}
j->p_hook = fOffHook;
printk("IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->board, fOffHook, jiffies);
}
} else {
if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE ||
j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) {
if (j->flags.ringing || j->flags.cringing) {
if (!in_interrupt()) {
det = jiffies + (hertz / 50);
while (time_before(jiffies, det)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
}
SLIC_GetState(j);
if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) {
ixj_ring_on(j);
}
}
if (j->cardtype == QTI_PHONEJACK_PCI) {
j->pld_scrr.byte = inb_p(j->XILINXbase);
fOffHook = j->pld_scrr.pcib.det ? 1 : 0;
} else
fOffHook = j->pld_slicr.bits.det ? 1 : 0;
}
}
break;
case QTI_PHONECARD:
fOffHook = ixj_pcmcia_cable_check(j);
break;
}
if (j->r_hook != fOffHook) {
j->r_hook = fOffHook;
if (j->port == PORT_SPEAKER || j->port == PORT_HANDSET) { // || (j->port == PORT_PSTN && j->flags.pots_pstn == 0)) {
j->ex.bits.hookstate = 1;
ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
} else if (!fOffHook) {
j->flash_end = jiffies + ((60 * hertz) / 100);
}
}
if (fOffHook) {
if(time_before(jiffies, j->flash_end)) {
j->ex.bits.flash = 1;
j->flash_end = 0;
ixj_kill_fasync(j, SIG_FLASH, POLL_IN);
}
} else {
if(time_before(jiffies, j->flash_end)) {
fOffHook = 1;
}
}
if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION)
fOffHook |= 2;
if (j->port == PORT_SPEAKER) {
if(j->cardtype == QTI_PHONECARD) {
if(j->flags.pcmciascp && j->flags.pcmciasct) {
fOffHook |= 2;
}
} else {
fOffHook |= 2;
}
}
if (j->port == PORT_HANDSET)
fOffHook |= 2;
return fOffHook;
}
static void ixj_ring_off(IXJ *j)
{
if (j->dsp.low == 0x20) /* Internet PhoneJACK */
{
if (ixjdebug & 0x0004)
printk(KERN_INFO "IXJ Ring Off\n");
j->gpio.bytes.high = 0x0B;
j->gpio.bytes.low = 0x00;
j->gpio.bits.gpio1 = 0;
j->gpio.bits.gpio2 = 1;
j->gpio.bits.gpio5 = 0;
ixj_WriteDSPCommand(j->gpio.word, j);
} else /* Internet LineJACK */
{
if (ixjdebug & 0x0004)
printk(KERN_INFO "IXJ Ring Off\n");
if(!j->flags.cidplay)
SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
SLIC_GetState(j);
}
}
static void ixj_ring_start(IXJ *j)
{
j->flags.cringing = 1;
if (ixjdebug & 0x0004)
printk(KERN_INFO "IXJ Cadence Ringing Start /dev/phone%d\n", j->board);
if (ixj_hookstate(j) & 1) {
if (j->port == PORT_POTS)
ixj_ring_off(j);
j->flags.cringing = 0;
if (ixjdebug & 0x0004)
printk(KERN_INFO "IXJ Cadence Ringing Stopped /dev/phone%d off hook\n", j->board);
} else if(j->cadence_f[5].enable && (!j->cadence_f[5].en_filter)) {
j->ring_cadence_jif = jiffies;
j->flags.cidsent = j->flags.cidring = 0;
j->cadence_f[5].state = 0;
if(j->cadence_f[5].on1)
ixj_ring_on(j);
} else {
j->ring_cadence_jif = jiffies;
j->ring_cadence_t = 15;
if (j->ring_cadence & 1 << j->ring_cadence_t) {
ixj_ring_on(j);
} else {
ixj_ring_off(j);
}
j->flags.cidsent = j->flags.cidring = j->flags.firstring = 0;
}
}
static int ixj_ring(IXJ *j)
{
char cntr;
unsigned long jif, det;
j->flags.ringing = 1;
if (ixj_hookstate(j) & 1) {
ixj_ring_off(j);
j->flags.ringing = 0;
return 1;
}
det = 0;
for (cntr = 0; cntr < j->maxrings; cntr++) {
jif = jiffies + (1 * hertz);
ixj_ring_on(j);
while (time_before(jiffies, jif)) {
if (ixj_hookstate(j) & 1) {
ixj_ring_off(j);
j->flags.ringing = 0;
return 1;
}
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
if (signal_pending(current))
break;
}
jif = jiffies + (3 * hertz);
ixj_ring_off(j);
while (time_before(jiffies, jif)) {
if (ixj_hookstate(j) & 1) {
det = jiffies + (hertz / 100);
while (time_before(jiffies, det)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
if (signal_pending(current))
break;
}
if (ixj_hookstate(j) & 1) {
j->flags.ringing = 0;
return 1;
}
}
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
if (signal_pending(current))
break;
}
}
ixj_ring_off(j);
j->flags.ringing = 0;
return 0;
}
static int ixj_open(struct phone_device *p, struct file *file_p)
{
IXJ *j = get_ixj(p->board);
file_p->private_data = j;
if (!j->DSPbase)
return -ENODEV;
if (file_p->f_mode & FMODE_READ) {
if(!j->readers) {
j->readers++;
} else {
return -EBUSY;
}
}
if (file_p->f_mode & FMODE_WRITE) {
if(!j->writers) {
j->writers++;
} else {
if (file_p->f_mode & FMODE_READ){
j->readers--;
}
return -EBUSY;
}
}
if (j->cardtype == QTI_PHONECARD) {
j->pslic.bits.powerdown = 0;
j->psccr.bits.dev = 3;
j->psccr.bits.rw = 0;
outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
ixj_PCcontrol_wait(j);
}
j->flags.cidplay = 0;
j->flags.cidcw_ack = 0;
if (ixjdebug & 0x0002)
printk(KERN_INFO "Opening board %d\n", p->board);
j->framesread = j->frameswritten = 0;
return 0;
}
static int ixj_release(struct inode *inode, struct file *file_p)
{
IXJ_TONE ti;
int cnt;
IXJ *j = file_p->private_data;
int board = j->p.board;
/*
* Set up locks to ensure that only one process is talking to the DSP at a time.
* This is necessary to keep the DSP from locking up.
*/
while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
if (ixjdebug & 0x0002)
printk(KERN_INFO "Closing board %d\n", NUM(inode));
if (j->cardtype == QTI_PHONECARD)
ixj_set_port(j, PORT_SPEAKER);
else
ixj_set_port(j, PORT_POTS);
aec_stop(j);
ixj_play_stop(j);
ixj_record_stop(j);
set_play_volume(j, 0x100);
set_rec_volume(j, 0x100);
ixj_ring_off(j);
/* Restore the tone table to default settings. */
ti.tone_index = 10;
ti.gain0 = 1;
ti.freq0 = hz941;
ti.gain1 = 0;
ti.freq1 = hz1209;
ixj_init_tone(j, &ti);
ti.tone_index = 11;
ti.gain0 = 1;
ti.freq0 = hz941;
ti.gain1 = 0;
ti.freq1 = hz1336;
ixj_init_tone(j, &ti);
ti.tone_index = 12;
ti.gain0 = 1;
ti.freq0 = hz941;
ti.gain1 = 0;
ti.freq1 = hz1477;
ixj_init_tone(j, &ti);
ti.tone_index = 13;
ti.gain0 = 1;
ti.freq0 = hz800;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 14;
ti.gain0 = 1;
ti.freq0 = hz1000;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 15;
ti.gain0 = 1;
ti.freq0 = hz1250;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 16;
ti.gain0 = 1;
ti.freq0 = hz950;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 17;
ti.gain0 = 1;
ti.freq0 = hz1100;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 18;
ti.gain0 = 1;
ti.freq0 = hz1400;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 19;
ti.gain0 = 1;
ti.freq0 = hz1500;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 20;
ti.gain0 = 1;
ti.freq0 = hz1600;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 21;
ti.gain0 = 1;
ti.freq0 = hz1800;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 22;
ti.gain0 = 1;
ti.freq0 = hz2100;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 23;
ti.gain0 = 1;
ti.freq0 = hz1300;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 24;
ti.gain0 = 1;
ti.freq0 = hz2450;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ti.tone_index = 25;
ti.gain0 = 1;
ti.freq0 = hz350;
ti.gain1 = 0;
ti.freq1 = hz440;
ixj_init_tone(j, &ti);
ti.tone_index = 26;
ti.gain0 = 1;
ti.freq0 = hz440;
ti.gain1 = 0;
ti.freq1 = hz480;
ixj_init_tone(j, &ti);
ti.tone_index = 27;
ti.gain0 = 1;
ti.freq0 = hz480;
ti.gain1 = 0;
ti.freq1 = hz620;
ixj_init_tone(j, &ti);
set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
j->ex.bits.dtmf_ready = 0;
j->dtmf_state = 0;
j->dtmf_wp = j->dtmf_rp = 0;
j->rec_mode = j->play_mode = -1;
j->flags.ringing = 0;
j->maxrings = MAXRINGS;
j->ring_cadence = USA_RING_CADENCE;
if(j->cadence_f[5].enable) {
j->cadence_f[5].enable = j->cadence_f[5].en_filter = j->cadence_f[5].state = 0;
}
j->drybuffer = 0;
j->winktime = 320;
j->flags.dtmf_oob = 0;
for (cnt = 0; cnt < 4; cnt++)
j->cadence_f[cnt].enable = 0;
idle(j);
if(j->cardtype == QTI_PHONECARD) {
SLIC_SetState(PLD_SLIC_STATE_OC, j);
}
if (file_p->f_mode & FMODE_READ)
j->readers--;
if (file_p->f_mode & FMODE_WRITE)
j->writers--;
if (j->read_buffer && !j->readers) {
kfree(j->read_buffer);
j->read_buffer = NULL;
j->read_buffer_size = 0;
}
if (j->write_buffer && !j->writers) {
kfree(j->write_buffer);
j->write_buffer = NULL;
j->write_buffer_size = 0;
}
j->rec_codec = j->play_codec = 0;
j->rec_frame_size = j->play_frame_size = 0;
j->flags.cidsent = j->flags.cidring = 0;
ixj_fasync(-1, file_p, 0); /* remove from list of async notification */
if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
ixj_set_port(j, PORT_PSTN);
daa_set_mode(j, SOP_PU_SLEEP);
ixj_set_pots(j, 1);
}
ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
/* Set up the default signals for events */
for (cnt = 0; cnt < 35; cnt++)
j->ixj_signals[cnt] = SIGIO;
/* Set the excetion signal enable flags */
j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
j->ex_sig.bits.f3 = j->ex_sig.bits.fc0 = j->ex_sig.bits.fc1 = j->ex_sig.bits.fc2 = j->ex_sig.bits.fc3 = 1;
file_p->private_data = NULL;
clear_bit(board, &j->busyflags);
return 0;
}
static int read_filters(IXJ *j)
{
unsigned short fc, cnt, trg;
int var;
trg = 0;
if (ixj_WriteDSPCommand(0x5144, j)) {
if(ixjdebug & 0x0001) {
printk(KERN_INFO "Read Frame Counter failed!\n");
}
return -1;
}
fc = j->ssr.high << 8 | j->ssr.low;
if (fc == j->frame_count)
return 1;
j->frame_count = fc;
if (j->dtmf_proc)
return 1;
var = 10;
for (cnt = 0; cnt < 4; cnt++) {
if (ixj_WriteDSPCommand(0x5154 + cnt, j)) {
if(ixjdebug & 0x0001) {
printk(KERN_INFO "Select Filter %d failed!\n", cnt);
}
return -1;
}
if (ixj_WriteDSPCommand(0x515C, j)) {
if(ixjdebug & 0x0001) {
printk(KERN_INFO "Read Filter History %d failed!\n", cnt);
}
return -1;
}
j->filter_hist[cnt] = j->ssr.high << 8 | j->ssr.low;
if (j->cadence_f[cnt].enable) {
if (j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) {
if (j->cadence_f[cnt].state == 0) {
j->cadence_f[cnt].state = 1;
j->cadence_f[cnt].on1min = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 - var)) / 10000));
j->cadence_f[cnt].on1dot = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100)) / 10000));
j->cadence_f[cnt].on1max = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 + var)) / 10000));
} else if (j->cadence_f[cnt].state == 2 &&
(time_after(jiffies, j->cadence_f[cnt].off1min) &&
time_before(jiffies, j->cadence_f[cnt].off1max))) {
if (j->cadence_f[cnt].on2) {
j->cadence_f[cnt].state = 3;
j->cadence_f[cnt].on2min = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 - var)) / 10000));
j->cadence_f[cnt].on2dot = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100)) / 10000));
j->cadence_f[cnt].on2max = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[cnt].state = 7;
}
} else if (j->cadence_f[cnt].state == 4 &&
(time_after(jiffies, j->cadence_f[cnt].off2min) &&
time_before(jiffies, j->cadence_f[cnt].off2max))) {
if (j->cadence_f[cnt].on3) {
j->cadence_f[cnt].state = 5;
j->cadence_f[cnt].on3min = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 - var)) / 10000));
j->cadence_f[cnt].on3dot = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100)) / 10000));
j->cadence_f[cnt].on3max = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[cnt].state = 7;
}
} else {
j->cadence_f[cnt].state = 0;
}
} else if (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)) {
if (j->cadence_f[cnt].state == 1) {
if(!j->cadence_f[cnt].on1) {
j->cadence_f[cnt].state = 7;
} else if((time_after(jiffies, j->cadence_f[cnt].on1min) &&
time_before(jiffies, j->cadence_f[cnt].on1max))) {
if(j->cadence_f[cnt].off1) {
j->cadence_f[cnt].state = 2;
j->cadence_f[cnt].off1min = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 - var)) / 10000));
j->cadence_f[cnt].off1dot = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100)) / 10000));
j->cadence_f[cnt].off1max = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[cnt].state = 7;
}
} else {
j->cadence_f[cnt].state = 0;
}
} else if (j->cadence_f[cnt].state == 3) {
if((time_after(jiffies, j->cadence_f[cnt].on2min) &&
time_before(jiffies, j->cadence_f[cnt].on2max))) {
if(j->cadence_f[cnt].off2) {
j->cadence_f[cnt].state = 4;
j->cadence_f[cnt].off2min = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 - var)) / 10000));
j->cadence_f[cnt].off2dot = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100)) / 10000));
j->cadence_f[cnt].off2max = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[cnt].state = 7;
}
} else {
j->cadence_f[cnt].state = 0;
}
} else if (j->cadence_f[cnt].state == 5) {
if ((time_after(jiffies, j->cadence_f[cnt].on3min) &&
time_before(jiffies, j->cadence_f[cnt].on3max))) {
if(j->cadence_f[cnt].off3) {
j->cadence_f[cnt].state = 6;
j->cadence_f[cnt].off3min = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 - var)) / 10000));
j->cadence_f[cnt].off3dot = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100)) / 10000));
j->cadence_f[cnt].off3max = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 + var)) / 10000));
} else {
j->cadence_f[cnt].state = 7;
}
} else {
j->cadence_f[cnt].state = 0;
}
} else {
j->cadence_f[cnt].state = 0;
}
} else {
switch(j->cadence_f[cnt].state) {
case 1:
if(time_after(jiffies, j->cadence_f[cnt].on1dot) &&
!j->cadence_f[cnt].off1 &&
!j->cadence_f[cnt].on2 && !j->cadence_f[cnt].off2 &&
!j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
j->cadence_f[cnt].state = 7;
}
break;
case 3:
if(time_after(jiffies, j->cadence_f[cnt].on2dot) &&
!j->cadence_f[cnt].off2 &&
!j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
j->cadence_f[cnt].state = 7;
}
break;
case 5:
if(time_after(jiffies, j->cadence_f[cnt].on3dot) &&
!j->cadence_f[cnt].off3) {
j->cadence_f[cnt].state = 7;
}
break;
}
}
if (ixjdebug & 0x0040) {
printk(KERN_INFO "IXJ Tone Cadence state = %d /dev/phone%d at %ld\n", j->cadence_f[cnt].state, j->board, jiffies);
switch(j->cadence_f[cnt].state) {
case 0:
printk(KERN_INFO "IXJ /dev/phone%d No Tone detected\n", j->board);
break;
case 1:
printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %u %ld - %ld - %ld\n", j->board,
j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max);
break;
case 2:
printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min,
j->cadence_f[cnt].off1max);
break;
case 3:
printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on2min,
j->cadence_f[cnt].on2max);
break;
case 4:
printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off2min,
j->cadence_f[cnt].off2max);
break;
case 5:
printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min,
j->cadence_f[cnt].on3max);
break;
case 6:
printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min,
j->cadence_f[cnt].off3max);
break;
}
}
}
if (j->cadence_f[cnt].state == 7) {
j->cadence_f[cnt].state = 0;
if (j->cadence_f[cnt].enable == 1)
j->cadence_f[cnt].enable = 0;
switch (cnt) {
case 0:
if(ixjdebug & 0x0020) {
printk(KERN_INFO "Filter Cadence 0 triggered %ld\n", jiffies);
}
j->ex.bits.fc0 = 1;
ixj_kill_fasync(j, SIG_FC0, POLL_IN);
break;
case 1:
if(ixjdebug & 0x0020) {
printk(KERN_INFO "Filter Cadence 1 triggered %ld\n", jiffies);
}
j->ex.bits.fc1 = 1;
ixj_kill_fasync(j, SIG_FC1, POLL_IN);
break;
case 2:
if(ixjdebug & 0x0020) {
printk(KERN_INFO "Filter Cadence 2 triggered %ld\n", jiffies);
}
j->ex.bits.fc2 = 1;
ixj_kill_fasync(j, SIG_FC2, POLL_IN);
break;
case 3:
if(ixjdebug & 0x0020) {
printk(KERN_INFO "Filter Cadence 3 triggered %ld\n", jiffies);
}
j->ex.bits.fc3 = 1;
ixj_kill_fasync(j, SIG_FC3, POLL_IN);
break;
}
}
if (j->filter_en[cnt] && ((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) ||
(j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)))) {
if((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12))) {
trg = 1;
} else if((j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3))) {
trg = 0;
}
switch (cnt) {
case 0:
if(ixjdebug & 0x0020) {
printk(KERN_INFO "Filter 0 triggered %d at %ld\n", trg, jiffies);
}
j->ex.bits.f0 = 1;
ixj_kill_fasync(j, SIG_F0, POLL_IN);
break;
case 1:
if(ixjdebug & 0x0020) {
printk(KERN_INFO "Filter 1 triggered %d at %ld\n", trg, jiffies);
}
j->ex.bits.f1 = 1;
ixj_kill_fasync(j, SIG_F1, POLL_IN);
break;
case 2:
if(ixjdebug & 0x0020) {
printk(KERN_INFO "Filter 2 triggered %d at %ld\n", trg, jiffies);
}
j->ex.bits.f2 = 1;
ixj_kill_fasync(j, SIG_F2, POLL_IN);
break;
case 3:
if(ixjdebug & 0x0020) {
printk(KERN_INFO "Filter 3 triggered %d at %ld\n", trg, jiffies);
}
j->ex.bits.f3 = 1;
ixj_kill_fasync(j, SIG_F3, POLL_IN);
break;
}
}
}
return 0;
}
static int LineMonitor(IXJ *j)
{
if (j->dtmf_proc) {
return -1;
}
j->dtmf_proc = 1;
if (ixj_WriteDSPCommand(0x7000, j)) /* Line Monitor */
return -1;
j->dtmf.bytes.high = j->ssr.high;
j->dtmf.bytes.low = j->ssr.low;
if (!j->dtmf_state && j->dtmf.bits.dtmf_valid) {
j->dtmf_state = 1;
j->dtmf_current = j->dtmf.bits.digit;
}
if (j->dtmf_state && !j->dtmf.bits.dtmf_valid) /* && j->dtmf_wp != j->dtmf_rp) */
{
if(!j->cidcw_wait) {
j->dtmfbuffer[j->dtmf_wp] = j->dtmf_current;
j->dtmf_wp++;
if (j->dtmf_wp == 79)
j->dtmf_wp = 0;
j->ex.bits.dtmf_ready = 1;
if(j->ex_sig.bits.dtmf_ready) {
ixj_kill_fasync(j, SIG_DTMF_READY, POLL_IN);
}
}
else if(j->dtmf_current == 0x00 || j->dtmf_current == 0x0D) {
if(ixjdebug & 0x0020) {
printk("IXJ phone%d saw CIDCW Ack DTMF %d from display at %ld\n", j->board, j->dtmf_current, jiffies);
}
j->flags.cidcw_ack = 1;
}
j->dtmf_state = 0;
}
j->dtmf_proc = 0;
return 0;
}
/************************************************************************
*
* Functions to allow alaw <-> ulaw conversions.
*
************************************************************************/
static void ulaw2alaw(unsigned char *buff, unsigned long len)
{
static unsigned char table_ulaw2alaw[] =
{
0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
};
while (len--)
{
*buff = table_ulaw2alaw[*(unsigned char *)buff];
buff++;
}
}
static void alaw2ulaw(unsigned char *buff, unsigned long len)
{
static unsigned char table_alaw2ulaw[] =
{
0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
};
while (len--)
{
*buff = table_alaw2ulaw[*(unsigned char *)buff];
buff++;
}
}
static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos)
{
unsigned long i = *ppos;
IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode));
DECLARE_WAITQUEUE(wait, current);
if (j->flags.inread)
return -EALREADY;
j->flags.inread = 1;
add_wait_queue(&j->read_q, &wait);
set_current_state(TASK_INTERRUPTIBLE);
mb();
while (!j->read_buffer_ready || (j->dtmf_state && j->flags.dtmf_oob)) {
++j->read_wait;
if (file_p->f_flags & O_NONBLOCK) {
set_current_state(TASK_RUNNING);
remove_wait_queue(&j->read_q, &wait);
j->flags.inread = 0;
return -EAGAIN;
}
if (!ixj_hookstate(j)) {
set_current_state(TASK_RUNNING);
remove_wait_queue(&j->read_q, &wait);
j->flags.inread = 0;
return 0;
}
interruptible_sleep_on(&j->read_q);
if (signal_pending(current)) {
set_current_state(TASK_RUNNING);
remove_wait_queue(&j->read_q, &wait);
j->flags.inread = 0;
return -EINTR;
}
}
remove_wait_queue(&j->read_q, &wait);
set_current_state(TASK_RUNNING);
/* Don't ever copy more than the user asks */
if(j->rec_codec == ALAW)
ulaw2alaw(j->read_buffer, min(length, j->read_buffer_size));
i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size));
j->read_buffer_ready = 0;
if (i) {
j->flags.inread = 0;
return -EFAULT;
} else {
j->flags.inread = 0;
return min(length, j->read_buffer_size);
}
}
static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t length,
loff_t * ppos)
{
int pre_retval;
ssize_t read_retval = 0;
IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
pre_retval = ixj_PreRead(j, 0L);
switch (pre_retval) {
case NORMAL:
read_retval = ixj_read(file_p, buf, length, ppos);
ixj_PostRead(j, 0L);
break;
case NOPOST:
read_retval = ixj_read(file_p, buf, length, ppos);
break;
case POSTONLY:
ixj_PostRead(j, 0L);
break;
default:
read_retval = pre_retval;
}
return read_retval;
}
static ssize_t ixj_write(struct file *file_p, const char __user *buf, size_t count, loff_t * ppos)
{
unsigned long i = *ppos;
IXJ *j = file_p->private_data;
DECLARE_WAITQUEUE(wait, current);
if (j->flags.inwrite)
return -EALREADY;
j->flags.inwrite = 1;
add_wait_queue(&j->write_q, &wait);
set_current_state(TASK_INTERRUPTIBLE);
mb();
while (!j->write_buffers_empty) {
++j->write_wait;
if (file_p->f_flags & O_NONBLOCK) {
set_current_state(TASK_RUNNING);
remove_wait_queue(&j->write_q, &wait);
j->flags.inwrite = 0;
return -EAGAIN;
}
if (!ixj_hookstate(j)) {
set_current_state(TASK_RUNNING);
remove_wait_queue(&j->write_q, &wait);
j->flags.inwrite = 0;
return 0;
}
interruptible_sleep_on(&j->write_q);
if (signal_pending(current)) {
set_current_state(TASK_RUNNING);
remove_wait_queue(&j->write_q, &wait);
j->flags.inwrite = 0;
return -EINTR;
}
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&j->write_q, &wait);
if (j->write_buffer_wp + count >= j->write_buffer_end)
j->write_buffer_wp = j->write_buffer;
i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size));
if (i) {
j->flags.inwrite = 0;
return -EFAULT;
}
if(j->play_codec == ALAW)
alaw2ulaw(j->write_buffer_wp, min(count, j->write_buffer_size));
j->flags.inwrite = 0;
return min(count, j->write_buffer_size);
}
static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf, size_t count, loff_t * ppos)
{
int pre_retval;
ssize_t write_retval = 0;
IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
pre_retval = ixj_PreWrite(j, 0L);
switch (pre_retval) {
case NORMAL:
write_retval = ixj_write(file_p, buf, count, ppos);
if (write_retval > 0) {
ixj_PostWrite(j, 0L);
j->write_buffer_wp += write_retval;
j->write_buffers_empty--;
}
break;
case NOPOST:
write_retval = ixj_write(file_p, buf, count, ppos);
if (write_retval > 0) {
j->write_buffer_wp += write_retval;
j->write_buffers_empty--;
}
break;
case POSTONLY:
ixj_PostWrite(j, 0L);
break;
default:
write_retval = pre_retval;
}
return write_retval;
}
static void ixj_read_frame(IXJ *j)
{
int cnt, dly;
if (j->read_buffer) {
for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
if (!(cnt % 16) && !IsRxReady(j)) {
dly = 0;
while (!IsRxReady(j)) {
if (dly++ > 5) {
dly = 0;
break;
}
udelay(10);
}
}
/* Throw away word 0 of the 8021 compressed format to get standard G.729. */
if (j->rec_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
inb_p(j->DSPbase + 0x0E);
inb_p(j->DSPbase + 0x0F);
}
*(j->read_buffer + cnt) = inb_p(j->DSPbase + 0x0E);
*(j->read_buffer + cnt + 1) = inb_p(j->DSPbase + 0x0F);
}
++j->framesread;
if (j->intercom != -1) {
if (IsTxReady(get_ixj(j->intercom))) {
for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
if (!(cnt % 16) && !IsTxReady(j)) {
dly = 0;
while (!IsTxReady(j)) {
if (dly++ > 5) {
dly = 0;
break;
}
udelay(10);
}
}
outb_p(*(j->read_buffer + cnt), get_ixj(j->intercom)->DSPbase + 0x0C);
outb_p(*(j->read_buffer + cnt + 1), get_ixj(j->intercom)->DSPbase + 0x0D);
}
get_ixj(j->intercom)->frameswritten++;
}
} else {
j->read_buffer_ready = 1;
wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
if(j->ixj_signals[SIG_READ_READY])
ixj_kill_fasync(j, SIG_READ_READY, POLL_OUT);
}
}
}
static short fsk[][6][20] =
{
{
{
0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196,
-16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722
},
{
-28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481,
-32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876
},
{
-28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715,
-16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846
},
{
0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196,
16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722
},
{
28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481,
32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876
},
{
28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715,
16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846
}
},
{
{
0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126,
0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126
},
{
-28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051,
28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051
},
{
-28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925,
28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925
},
{
0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126,
0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126
},
{
28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051,
-28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051
},
{
28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925,
-28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925
}
}
};
static void ixj_write_cid_bit(IXJ *j, int bit)
{
while (j->fskcnt < 20) {
if(j->fskdcnt < (j->fsksize - 1))
j->fskdata[j->fskdcnt++] = fsk[bit][j->fskz][j->fskcnt];
j->fskcnt += 3;
}
j->fskcnt %= 20;
if (!bit)
j->fskz++;
if (j->fskz >= 6)
j->fskz = 0;
}
static void ixj_write_cid_byte(IXJ *j, char byte)
{
IXJ_CBYTE cb;
cb.cbyte = byte;
ixj_write_cid_bit(j, 0);
ixj_write_cid_bit(j, cb.cbits.b0 ? 1 : 0);
ixj_write_cid_bit(j, cb.cbits.b1 ? 1 : 0);
ixj_write_cid_bit(j, cb.cbits.b2 ? 1 : 0);
ixj_write_cid_bit(j, cb.cbits.b3 ? 1 : 0);
ixj_write_cid_bit(j, cb.cbits.b4 ? 1 : 0);
ixj_write_cid_bit(j, cb.cbits.b5 ? 1 : 0);
ixj_write_cid_bit(j, cb.cbits.b6 ? 1 : 0);
ixj_write_cid_bit(j, cb.cbits.b7 ? 1 : 0);
ixj_write_cid_bit(j, 1);
}
static void ixj_write_cid_seize(IXJ *j)
{
int cnt;
for (cnt = 0; cnt < 150; cnt++) {
ixj_write_cid_bit(j, 0);
ixj_write_cid_bit(j, 1);
}
for (cnt = 0; cnt < 180; cnt++) {
ixj_write_cid_bit(j, 1);
}
}
static void ixj_write_cidcw_seize(IXJ *j)
{
int cnt;
for (cnt = 0; cnt < 80; cnt++) {
ixj_write_cid_bit(j, 1);
}
}
static int ixj_write_cid_string(IXJ *j, char *s, int checksum)
{
int cnt;
for (cnt = 0; cnt < strlen(s); cnt++) {
ixj_write_cid_byte(j, s[cnt]);
checksum = (checksum + s[cnt]);
}
return checksum;
}
static void ixj_pad_fsk(IXJ *j, int pad)
{
int cnt;
for (cnt = 0; cnt < pad; cnt++) {
if(j->fskdcnt < (j->fsksize - 1))
j->fskdata[j->fskdcnt++] = 0x0000;
}
for (cnt = 0; cnt < 720; cnt++) {
if(j->fskdcnt < (j->fsksize - 1))
j->fskdata[j->fskdcnt++] = 0x0000;
}
}
static void ixj_pre_cid(IXJ *j)
{
j->cid_play_codec = j->play_codec;
j->cid_play_frame_size = j->play_frame_size;
j->cid_play_volume = get_play_volume(j);
j->cid_play_flag = j->flags.playing;
j->cid_rec_codec = j->rec_codec;
j->cid_rec_volume = get_rec_volume(j);
j->cid_rec_flag = j->flags.recording;
j->cid_play_aec_level = j->aec_level;
switch(j->baseframe.low) {
case 0xA0:
j->cid_base_frame_size = 20;
break;
case 0x50:
j->cid_base_frame_size = 10;
break;
case 0xF0:
j->cid_base_frame_size = 30;
break;
}
ixj_play_stop(j);
ixj_cpt_stop(j);
j->flags.cidplay = 1;
set_base_frame(j, 30);
set_play_codec(j, LINEAR16);
set_play_volume(j, 0x1B);
ixj_play_start(j);
}
static void ixj_post_cid(IXJ *j)
{
ixj_play_stop(j);
if(j->cidsize > 5000) {
SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
}
j->flags.cidplay = 0;
if(ixjdebug & 0x0200) {
printk("IXJ phone%d Finished Playing CallerID data %ld\n", j->board, jiffies);
}
ixj_fsk_free(j);
j->fskdcnt = 0;
set_base_frame(j, j->cid_base_frame_size);
set_play_codec(j, j->cid_play_codec);
ixj_aec_start(j, j->cid_play_aec_level);
set_play_volume(j, j->cid_play_volume);
set_rec_codec(j, j->cid_rec_codec);
set_rec_volume(j, j->cid_rec_volume);
if(j->cid_rec_flag)
ixj_record_start(j);
if(j->cid_play_flag)
ixj_play_start(j);
if(j->cid_play_flag) {
wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
}
}
static void ixj_write_cid(IXJ *j)
{
char sdmf1[50];
char sdmf2[50];
char sdmf3[80];
char mdmflen, len1, len2, len3;
int pad;
int checksum = 0;
if (j->dsp.low == 0x20 || j->flags.cidplay)
return;
j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
j->cidsize = j->cidcnt = 0;
ixj_fsk_alloc(j);
strcpy(sdmf1, j->cid_send.month);
strcat(sdmf1, j->cid_send.day);
strcat(sdmf1, j->cid_send.hour);
strcat(sdmf1, j->cid_send.min);
strcpy(sdmf2, j->cid_send.number);
strcpy(sdmf3, j->cid_send.name);
len1 = strlen(sdmf1);
len2 = strlen(sdmf2);
len3 = strlen(sdmf3);
mdmflen = len1 + len2 + len3 + 6;
while(1){
ixj_write_cid_seize(j);
ixj_write_cid_byte(j, 0x80);
checksum = 0x80;
ixj_write_cid_byte(j, mdmflen);
checksum = checksum + mdmflen;
ixj_write_cid_byte(j, 0x01);
checksum = checksum + 0x01;
ixj_write_cid_byte(j, len1);
checksum = checksum + len1;
checksum = ixj_write_cid_string(j, sdmf1, checksum);
if(ixj_hookstate(j) & 1)
break;
ixj_write_cid_byte(j, 0x02);
checksum = checksum + 0x02;
ixj_write_cid_byte(j, len2);
checksum = checksum + len2;
checksum = ixj_write_cid_string(j, sdmf2, checksum);
if(ixj_hookstate(j) & 1)
break;
ixj_write_cid_byte(j, 0x07);
checksum = checksum + 0x07;
ixj_write_cid_byte(j, len3);
checksum = checksum + len3;
checksum = ixj_write_cid_string(j, sdmf3, checksum);
if(ixj_hookstate(j) & 1)
break;
checksum %= 256;
checksum ^= 0xFF;
checksum += 1;
ixj_write_cid_byte(j, (char) checksum);
pad = j->fskdcnt % 240;
if (pad) {
pad = 240 - pad;
}
ixj_pad_fsk(j, pad);
break;
}
ixj_write_frame(j);
}
static void ixj_write_cidcw(IXJ *j)
{
IXJ_TONE ti;
char sdmf1[50];
char sdmf2[50];
char sdmf3[80];
char mdmflen, len1, len2, len3;
int pad;
int checksum = 0;
if (j->dsp.low == 0x20 || j->flags.cidplay)
return;
j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
j->cidsize = j->cidcnt = 0;
ixj_fsk_alloc(j);
j->flags.cidcw_ack = 0;
ti.tone_index = 23;
ti.gain0 = 1;
ti.freq0 = hz440;
ti.gain1 = 0;
ti.freq1 = 0;
ixj_init_tone(j, &ti);
ixj_set_tone_on(1500, j);
ixj_set_tone_off(32, j);
if(ixjdebug & 0x0200) {
printk("IXJ cidcw phone%d first tone start at %ld\n", j->board, jiffies);
}
ixj_play_tone(j, 23);
clear_bit(j->board, &j->busyflags);
while(j->tone_state) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
if(ixjdebug & 0x0200) {
printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies);
}
ti.tone_index = 24;
ti.gain0 = 1;
ti.freq0 = hz2130;
ti.gain1 = 0;
ti.freq1 = hz2750;
ixj_init_tone(j, &ti);
ixj_set_tone_off(10, j);
ixj_set_tone_on(600, j);
if(ixjdebug & 0x0200) {
printk("IXJ cidcw phone%d second tone start at %ld\n", j->board, jiffies);
}
ixj_play_tone(j, 24);
clear_bit(j->board, &j->busyflags);
while(j->tone_state) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
if(ixjdebug & 0x0200) {
printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies);
}
j->cidcw_wait = jiffies + ((50 * hertz) / 100);
clear_bit(j->board, &j->busyflags);
while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
j->cidcw_wait = 0;
if(!j->flags.cidcw_ack) {
if(ixjdebug & 0x0200) {
printk("IXJ cidcw phone%d did not receive ACK from display %ld\n", j->board, jiffies);
}
ixj_post_cid(j);
if(j->cid_play_flag) {
wake_up_interruptible(&j->write_q); /* Wake any blocked readers */
}
return;
} else {
ixj_pre_cid(j);
}
j->flags.cidcw_ack = 0;
strcpy(sdmf1, j->cid_send.month);
strcat(sdmf1, j->cid_send.day);
strcat(sdmf1, j->cid_send.hour);
strcat(sdmf1, j->cid_send.min);
strcpy(sdmf2, j->cid_send.number);
strcpy(sdmf3, j->cid_send.name);
len1 = strlen(sdmf1);
len2 = strlen(sdmf2);
len3 = strlen(sdmf3);
mdmflen = len1 + len2 + len3 + 6;
ixj_write_cidcw_seize(j);
ixj_write_cid_byte(j, 0x80);
checksum = 0x80;
ixj_write_cid_byte(j, mdmflen);
checksum = checksum + mdmflen;
ixj_write_cid_byte(j, 0x01);
checksum = checksum + 0x01;
ixj_write_cid_byte(j, len1);
checksum = checksum + len1;
checksum = ixj_write_cid_string(j, sdmf1, checksum);
ixj_write_cid_byte(j, 0x02);
checksum = checksum + 0x02;
ixj_write_cid_byte(j, len2);
checksum = checksum + len2;
checksum = ixj_write_cid_string(j, sdmf2, checksum);
ixj_write_cid_byte(j, 0x07);
checksum = checksum + 0x07;
ixj_write_cid_byte(j, len3);
checksum = checksum + len3;
checksum = ixj_write_cid_string(j, sdmf3, checksum);
checksum %= 256;
checksum ^= 0xFF;
checksum += 1;
ixj_write_cid_byte(j, (char) checksum);
pad = j->fskdcnt % 240;
if (pad) {
pad = 240 - pad;
}
ixj_pad_fsk(j, pad);
if(ixjdebug & 0x0200) {
printk("IXJ cidcw phone%d sent FSK data at %ld\n", j->board, jiffies);
}
}
static void ixj_write_vmwi(IXJ *j, int msg)
{
char mdmflen;
int pad;
int checksum = 0;
if (j->dsp.low == 0x20 || j->flags.cidplay)
return;
j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
j->cidsize = j->cidcnt = 0;
ixj_fsk_alloc(j);
mdmflen = 3;
if (j->port == PORT_POTS)
SLIC_SetState(PLD_SLIC_STATE_OHT, j);
ixj_write_cid_seize(j);
ixj_write_cid_byte(j, 0x82);
checksum = 0x82;
ixj_write_cid_byte(j, mdmflen);
checksum = checksum + mdmflen;
ixj_write_cid_byte(j, 0x0B);
checksum = checksum + 0x0B;
ixj_write_cid_byte(j, 1);
checksum = checksum + 1;
if(msg) {
ixj_write_cid_byte(j, 0xFF);
checksum = checksum + 0xFF;
}
else {
ixj_write_cid_byte(j, 0x00);
checksum = checksum + 0x00;
}
checksum %= 256;
checksum ^= 0xFF;
checksum += 1;
ixj_write_cid_byte(j, (char) checksum);
pad = j->fskdcnt % 240;
if (pad) {
pad = 240 - pad;
}
ixj_pad_fsk(j, pad);
}
static void ixj_write_frame(IXJ *j)
{
int cnt, frame_count, dly;
IXJ_WORD dat;
BYTES blankword;
frame_count = 0;
if(j->flags.cidplay) {
for(cnt = 0; cnt < 480; cnt++) {
if (!(cnt % 16) && !IsTxReady(j)) {
dly = 0;
while (!IsTxReady(j)) {
if (dly++ > 5) {
dly = 0;
break;
}
udelay(10);
}
}
dat.word = j->fskdata[j->cidcnt++];
outb_p(dat.bytes.low, j->DSPbase + 0x0C);
outb_p(dat.bytes.high, j->DSPbase + 0x0D);
cnt++;
}
if(j->cidcnt >= j->fskdcnt) {
ixj_post_cid(j);
}
/* This may seem rude, but if we just played one frame of FSK data for CallerID
and there is real audio data in the buffer, we need to throw it away because
we just used it's time slot */
if (j->write_buffer_rp > j->write_buffer_wp) {
j->write_buffer_rp += j->cid_play_frame_size * 2;
if (j->write_buffer_rp >= j->write_buffer_end) {
j->write_buffer_rp = j->write_buffer;
}
j->write_buffers_empty++;
wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
}
} else if (j->write_buffer && j->write_buffers_empty < 1) {
if (j->write_buffer_wp > j->write_buffer_rp) {
frame_count =
(j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2);
}
if (j->write_buffer_rp > j->write_buffer_wp) {
frame_count =
(j->write_buffer_wp - j->write_buffer) / (j->play_frame_size * 2) +
(j->write_buffer_end - j->write_buffer_rp) / (j->play_frame_size * 2);
}
if (frame_count >= 1) {
if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) {
switch (j->play_mode) {
case PLAYBACK_MODE_ULAW:
case PLAYBACK_MODE_ALAW:
blankword.low = blankword.high = 0xFF;
break;
case PLAYBACK_MODE_8LINEAR:
case PLAYBACK_MODE_16LINEAR:
blankword.low = blankword.high = 0x00;
break;
case PLAYBACK_MODE_8LINEAR_WSS:
blankword.low = blankword.high = 0x80;
break;
}
for (cnt = 0; cnt < 16; cnt++) {
if (!(cnt % 16) && !IsTxReady(j)) {
dly = 0;
while (!IsTxReady(j)) {
if (dly++ > 5) {
dly = 0;
break;
}
udelay(10);
}
}
outb_p((blankword.low), j->DSPbase + 0x0C);
outb_p((blankword.high), j->DSPbase + 0x0D);
}
j->flags.play_first_frame = 0;
} else if (j->play_codec == G723_63 && j->flags.play_first_frame) {
for (cnt = 0; cnt < 24; cnt++) {
if(cnt == 12) {
blankword.low = 0x02;
blankword.high = 0x00;
}
else {
blankword.low = blankword.high = 0x00;
}
if (!(cnt % 16) && !IsTxReady(j)) {
dly = 0;
while (!IsTxReady(j)) {
if (dly++ > 5) {
dly = 0;
break;
}
udelay(10);
}
}
outb_p((blankword.low), j->DSPbase + 0x0C);
outb_p((blankword.high), j->DSPbase + 0x0D);
}
j->flags.play_first_frame = 0;
}
for (cnt = 0; cnt < j->play_frame_size * 2; cnt += 2) {
if (!(cnt % 16) && !IsTxReady(j)) {
dly = 0;
while (!IsTxReady(j)) {
if (dly++ > 5) {
dly = 0;
break;
}
udelay(10);
}
}
/* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */
if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
if(j->write_buffer_rp + cnt == 0 && j->write_buffer_rp + cnt + 1 == 0 && j->write_buffer_rp + cnt + 2 == 0 &&
j->write_buffer_rp + cnt + 3 == 0 && j->write_buffer_rp + cnt + 4 == 0 && j->write_buffer_rp + cnt + 5 == 0 &&
j->write_buffer_rp + cnt + 6 == 0 && j->write_buffer_rp + cnt + 7 == 0 && j->write_buffer_rp + cnt + 8 == 0 &&
j->write_buffer_rp + cnt + 9 == 0) {
/* someone is trying to write silence lets make this a type 0 frame. */
outb_p(0x00, j->DSPbase + 0x0C);
outb_p(0x00, j->DSPbase + 0x0D);
} else {
/* so all other frames are type 1. */
outb_p(0x01, j->DSPbase + 0x0C);
outb_p(0x00, j->DSPbase + 0x0D);
}
}
outb_p(*(j->write_buffer_rp + cnt), j->DSPbase + 0x0C);
outb_p(*(j->write_buffer_rp + cnt + 1), j->DSPbase + 0x0D);
*(j->write_buffer_rp + cnt) = 0;
*(j->write_buffer_rp + cnt + 1) = 0;
}
j->write_buffer_rp += j->play_frame_size * 2;
if (j->write_buffer_rp >= j->write_buffer_end) {
j->write_buffer_rp = j->write_buffer;
}
j->write_buffers_empty++;
wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
++j->frameswritten;
}
} else {
j->drybuffer++;
}
if(j->ixj_signals[SIG_WRITE_READY]) {
ixj_kill_fasync(j, SIG_WRITE_READY, POLL_OUT);
}
}
static int idle(IXJ *j)
{
if (ixj_WriteDSPCommand(0x0000, j)) /* DSP Idle */
return 0;
if (j->ssr.high || j->ssr.low) {
return 0;
} else {
j->play_mode = -1;
j->flags.playing = 0;
j->rec_mode = -1;
j->flags.recording = 0;
return 1;
}
}
static int set_base_frame(IXJ *j, int size)
{
unsigned short cmd;
int cnt;
idle(j);
j->cid_play_aec_level = j->aec_level;
aec_stop(j);
for (cnt = 0; cnt < 10; cnt++) {
if (idle(j))
break;
}
if (j->ssr.high || j->ssr.low)
return -1;
if (j->dsp.low != 0x20) {
switch (size) {
case 30:
cmd = 0x07F0;
/* Set Base Frame Size to 240 pg9-10 8021 */
break;
case 20:
cmd = 0x07A0;
/* Set Base Frame Size to 160 pg9-10 8021 */
break;
case 10:
cmd = 0x0750;
/* Set Base Frame Size to 80 pg9-10 8021 */
break;
default:
return -1;
}
} else {
if (size == 30)
return size;
else
return -1;
}
if (ixj_WriteDSPCommand(cmd, j)) {
j->baseframe.high = j->baseframe.low = 0xFF;
return -1;
} else {
j->baseframe.high = j->ssr.high;
j->baseframe.low = j->ssr.low;
/* If the status returned is 0x0000 (pg9-9 8021) the call failed */
if(j->baseframe.high == 0x00 && j->baseframe.low == 0x00) {
return -1;
}
}
ixj_aec_start(j, j->cid_play_aec_level);
return size;
}
static int set_rec_codec(IXJ *j, int rate)
{
int retval = 0;
j->rec_codec = rate;
switch (rate) {
case G723_63:
if (j->ver.low != 0x12 || ixj_convert_loaded) {
j->rec_frame_size = 12;
j->rec_mode = 0;
} else {
retval = 1;
}
break;
case G723_53:
if (j->ver.low != 0x12 || ixj_convert_loaded) {
j->rec_frame_size = 10;
j->rec_mode = 0;
} else {
retval = 1;
}
break;
case TS85:
if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
j->rec_frame_size = 16;
j->rec_mode = 0;
} else {
retval = 1;
}
break;
case TS48:
if (j->ver.low != 0x12 || ixj_convert_loaded) {
j->rec_frame_size = 9;
j->rec_mode = 0;
} else {
retval = 1;
}
break;
case TS41:
if (j->ver.low != 0x12 || ixj_convert_loaded) {
j->rec_frame_size = 8;
j->rec_mode = 0;
} else {
retval = 1;
}
break;
case G728:
if (j->dsp.low != 0x20) {
j->rec_frame_size = 48;
j->rec_mode = 0;
} else {
retval = 1;
}
break;
case G729:
if (j->dsp.low != 0x20) {
if (!j->flags.g729_loaded) {
retval = 1;
break;
}
switch (j->baseframe.low) {
case 0xA0:
j->rec_frame_size = 10;
break;
case 0x50:
j->rec_frame_size = 5;
break;
default:
j->rec_frame_size = 15;
break;
}
j->rec_mode = 0;
} else {
retval = 1;
}
break;
case G729B:
if (j->dsp.low != 0x20) {
if (!j->flags.g729_loaded) {
retval = 1;
break;
}
switch (j->baseframe.low) {
case 0xA0:
j->rec_frame_size = 12;
break;
case 0x50:
j->rec_frame_size = 6;
break;
default:
j->rec_frame_size = 18;
break;
}
j->rec_mode = 0;
} else {
retval = 1;
}
break;
case ULAW:
switch (j->baseframe.low) {
case 0xA0:
j->rec_frame_size = 80;
break;
case 0x50:
j->rec_frame_size = 40;
break;
default:
j->rec_frame_size = 120;
break;
}
j->rec_mode = 4;
break;
case ALAW:
switch (j->baseframe.low) {
case 0xA0:
j->rec_frame_size = 80;
break;
case 0x50:
j->rec_frame_size = 40;
break;
default:
j->rec_frame_size = 120;
break;
}
j->rec_mode = 4;
break;
case LINEAR16:
switch (j->baseframe.low) {
case 0xA0:
j->rec_frame_size = 160;
break;
case 0x50:
j->rec_frame_size = 80;
break;
default:
j->rec_frame_size = 240;
break;
}
j->rec_mode = 5;
break;
case LINEAR8:
switch (j->baseframe.low) {
case 0xA0:
j->rec_frame_size = 80;
break;
case 0x50:
j->rec_frame_size = 40;
break;
default:
j->rec_frame_size = 120;
break;
}
j->rec_mode = 6;
break;
case WSS:
switch (j->baseframe.low) {
case 0xA0:
j->rec_frame_size = 80;
break;
case 0x50:
j->rec_frame_size = 40;
break;
default:
j->rec_frame_size = 120;
break;
}
j->rec_mode = 7;
break;
default:
j->rec_frame_size = 0;
j->rec_mode = -1;
if (j->read_buffer) {
kfree(j->read_buffer);
j->read_buffer = NULL;
j->read_buffer_size = 0;
}
retval = 1;
break;
}
return retval;
}
static int ixj_record_start(IXJ *j)
{
unsigned short cmd = 0x0000;
if (j->read_buffer) {
ixj_record_stop(j);
}
j->flags.recording = 1;
ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
if(ixjdebug & 0x0002)
printk("IXJ %d Starting Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
if (!j->rec_mode) {
switch (j->rec_codec) {
case G723_63:
cmd = 0x5131;
break;
case G723_53:
cmd = 0x5132;
break;
case TS85:
cmd = 0x5130; /* TrueSpeech 8.5 */
break;
case TS48:
cmd = 0x5133; /* TrueSpeech 4.8 */
break;
case TS41:
cmd = 0x5134; /* TrueSpeech 4.1 */
break;
case G728:
cmd = 0x5135;
break;
case G729:
case G729B:
cmd = 0x5136;
break;
default:
return 1;
}
if (ixj_WriteDSPCommand(cmd, j))
return -1;
}
if (!j->read_buffer) {
if (!j->read_buffer)
j->read_buffer = kmalloc(j->rec_frame_size * 2, GFP_ATOMIC);
if (!j->read_buffer) {
printk("Read buffer allocation for ixj board %d failed!\n", j->board);
return -ENOMEM;
}
}
j->read_buffer_size = j->rec_frame_size * 2;
if (ixj_WriteDSPCommand(0x5102, j)) /* Set Poll sync mode */
return -1;
switch (j->rec_mode) {
case 0:
cmd = 0x1C03; /* Record C1 */
break;
case 4:
if (j->ver.low == 0x12) {
cmd = 0x1E03; /* Record C1 */
} else {
cmd = 0x1E01; /* Record C1 */
}
break;
case 5:
if (j->ver.low == 0x12) {
cmd = 0x1E83; /* Record C1 */
} else {
cmd = 0x1E81; /* Record C1 */
}
break;
case 6:
if (j->ver.low == 0x12) {
cmd = 0x1F03; /* Record C1 */
} else {
cmd = 0x1F01; /* Record C1 */
}
break;
case 7:
if (j->ver.low == 0x12) {
cmd = 0x1F83; /* Record C1 */
} else {
cmd = 0x1F81; /* Record C1 */
}
break;
}
if (ixj_WriteDSPCommand(cmd, j))
return -1;
if (j->flags.playing) {
ixj_aec_start(j, j->aec_level);
}
return 0;
}
static void ixj_record_stop(IXJ *j)
{
if(ixjdebug & 0x0002)
printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
if (j->read_buffer) {
kfree(j->read_buffer);
j->read_buffer = NULL;
j->read_buffer_size = 0;
}
if (j->rec_mode > -1) {
ixj_WriteDSPCommand(0x5120, j);
j->rec_mode = -1;
}
j->flags.recording = 0;
}
static void ixj_vad(IXJ *j, int arg)
{
if (arg)
ixj_WriteDSPCommand(0x513F, j);
else
ixj_WriteDSPCommand(0x513E, j);
}
static void set_rec_depth(IXJ *j, int depth)
{
if (depth > 60)
depth = 60;
if (depth < 0)
depth = 0;
ixj_WriteDSPCommand(0x5180 + depth, j);
}
static void set_dtmf_prescale(IXJ *j, int volume)
{
ixj_WriteDSPCommand(0xCF07, j);
ixj_WriteDSPCommand(volume, j);
}
static int get_dtmf_prescale(IXJ *j)
{
ixj_WriteDSPCommand(0xCF05, j);
return j->ssr.high << 8 | j->ssr.low;
}
static void set_rec_volume(IXJ *j, int volume)
{
if(j->aec_level == AEC_AGC) {
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: /dev/phone%d Setting AGC Threshold to 0x%4.4x\n", j->board, volume);
ixj_WriteDSPCommand(0xCF96, j);
ixj_WriteDSPCommand(volume, j);
} else {
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: /dev/phone %d Setting Record Volume to 0x%4.4x\n", j->board, volume);
ixj_WriteDSPCommand(0xCF03, j);
ixj_WriteDSPCommand(volume, j);
}
}
static int set_rec_volume_linear(IXJ *j, int volume)
{
int newvolume, dsprecmax;
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->board, volume);
if(volume > 100 || volume < 0) {
return -1;
}
/* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
switch (j->cardtype) {
case QTI_PHONEJACK:
dsprecmax = 0x440;
break;
case QTI_LINEJACK:
dsprecmax = 0x180;
ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
break;
case QTI_PHONEJACK_LITE:
dsprecmax = 0x4C0;
break;
case QTI_PHONEJACK_PCI:
dsprecmax = 0x100;
break;
case QTI_PHONECARD:
dsprecmax = 0x400;
break;
default:
return -1;
}
newvolume = (dsprecmax * volume) / 100;
set_rec_volume(j, newvolume);
return 0;
}
static int get_rec_volume(IXJ *j)
{
if(j->aec_level == AEC_AGC) {
if (ixjdebug & 0x0002)
printk(KERN_INFO "Getting AGC Threshold\n");
ixj_WriteDSPCommand(0xCF86, j);
if (ixjdebug & 0x0002)
printk(KERN_INFO "AGC Threshold is 0x%2.2x%2.2x\n", j->ssr.high, j->ssr.low);
return j->ssr.high << 8 | j->ssr.low;
} else {
if (ixjdebug & 0x0002)
printk(KERN_INFO "Getting Record Volume\n");
ixj_WriteDSPCommand(0xCF01, j);
return j->ssr.high << 8 | j->ssr.low;
}
}
static int get_rec_volume_linear(IXJ *j)
{
int volume, newvolume, dsprecmax;
switch (j->cardtype) {
case QTI_PHONEJACK:
dsprecmax = 0x440;
break;
case QTI_LINEJACK:
dsprecmax = 0x180;
break;
case QTI_PHONEJACK_LITE:
dsprecmax = 0x4C0;
break;
case QTI_PHONEJACK_PCI:
dsprecmax = 0x100;
break;
case QTI_PHONECARD:
dsprecmax = 0x400;
break;
default:
return -1;
}
volume = get_rec_volume(j);
newvolume = (volume * 100) / dsprecmax;
if(newvolume > 100)
newvolume = 100;
return newvolume;
}
static int get_rec_level(IXJ *j)
{
int retval;
ixj_WriteDSPCommand(0xCF88, j);
retval = j->ssr.high << 8 | j->ssr.low;
retval = (retval * 256) / 240;
return retval;
}
static void ixj_aec_start(IXJ *j, int level)
{
j->aec_level = level;
if (ixjdebug & 0x0002)
printk(KERN_INFO "AGC set = 0x%2.2x\n", j->aec_level);
if (!level) {
aec_stop(j);
} else {
if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer */
ixj_WriteDSPCommand(0x0300, j);
}
ixj_WriteDSPCommand(0xB001, j); /* AEC On */
ixj_WriteDSPCommand(0xE013, j); /* Advanced AEC C1 */
switch (level) {
case AEC_LOW:
ixj_WriteDSPCommand(0x0000, j); /* Advanced AEC C2 = off */
ixj_WriteDSPCommand(0xE011, j);
ixj_WriteDSPCommand(0xFFFF, j);
ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
ixj_WriteDSPCommand(0x0000, j); /* to off */
break;
case AEC_MED:
ixj_WriteDSPCommand(0x0600, j); /* Advanced AEC C2 = on medium */
ixj_WriteDSPCommand(0xE011, j);
ixj_WriteDSPCommand(0x0080, j);
ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
ixj_WriteDSPCommand(0x0000, j); /* to off */
break;
case AEC_HIGH:
ixj_WriteDSPCommand(0x0C00, j); /* Advanced AEC C2 = on high */
ixj_WriteDSPCommand(0xE011, j);
ixj_WriteDSPCommand(0x0080, j);
ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
ixj_WriteDSPCommand(0x0000, j); /* to off */
break;
case AEC_AGC:
/* First we have to put the AEC into advance auto mode so that AGC will not conflict with it */
ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
ixj_WriteDSPCommand(0xE011, j);
ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
ixj_WriteDSPCommand(0x0224, j);
else
ixj_WriteDSPCommand(0x1224, j);
ixj_WriteDSPCommand(0xE014, j);
ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */
ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
/* Now we can set the AGC initial parameters and turn it on */
ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minumum gain */
ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */
ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */
ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */
ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */
ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */
ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */
ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */
ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */
ixj_WriteDSPCommand(0x0005, j); /* to 8ms */
ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */
ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */
ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */
ixj_WriteDSPCommand(0x1200, j); /* to 25% */
ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
ixj_WriteDSPCommand(0x0001, j); /* to on */
break;
case AEC_AUTO:
ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
ixj_WriteDSPCommand(0xE011, j);
ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
ixj_WriteDSPCommand(0x0224, j);
else
ixj_WriteDSPCommand(0x1224, j);
ixj_WriteDSPCommand(0xE014, j);
ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */
ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
break;
}
}
}
static void aec_stop(IXJ *j)
{
j->aec_level = AEC_OFF;
if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer back */
ixj_WriteDSPCommand(0x0700, j);
}
if (j->play_mode != -1 && j->rec_mode != -1)
{
ixj_WriteDSPCommand(0xB002, j); /* AEC Stop */
}
}
static int set_play_codec(IXJ *j, int rate)
{
int retval = 0;
j->play_codec = rate;
switch (rate) {
case G723_63:
if (j->ver.low != 0x12 || ixj_convert_loaded) {
j->play_frame_size = 12;
j->play_mode = 0;
} else {
retval = 1;
}
break;
case G723_53:
if (j->ver.low != 0x12 || ixj_convert_loaded) {
j->play_frame_size = 10;
j->play_mode = 0;
} else {
retval = 1;
}
break;
case TS85:
if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
j->play_frame_size = 16;
j->play_mode = 0;
} else {
retval = 1;
}
break;
case TS48:
if (j->ver.low != 0x12 || ixj_convert_loaded) {
j->play_frame_size = 9;
j->play_mode = 0;
} else {
retval = 1;
}
break;
case TS41:
if (j->ver.low != 0x12 || ixj_convert_loaded) {
j->play_frame_size = 8;
j->play_mode = 0;
} else {
retval = 1;
}
break;
case G728:
if (j->dsp.low != 0x20) {
j->play_frame_size = 48;
j->play_mode = 0;
} else {
retval = 1;
}
break;
case G729:
if (j->dsp.low != 0x20) {
if (!j->flags.g729_loaded) {
retval = 1;
break;
}
switch (j->baseframe.low) {
case 0xA0:
j->play_frame_size = 10;
break;
case 0x50:
j->play_frame_size = 5;
break;
default:
j->play_frame_size = 15;
break;
}
j->play_mode = 0;
} else {
retval = 1;
}
break;
case G729B:
if (j->dsp.low != 0x20) {
if (!j->flags.g729_loaded) {
retval = 1;
break;
}
switch (j->baseframe.low) {
case 0xA0:
j->play_frame_size = 12;
break;
case 0x50:
j->play_frame_size = 6;
break;
default:
j->play_frame_size = 18;
break;
}
j->play_mode = 0;
} else {
retval = 1;
}
break;
case ULAW:
switch (j->baseframe.low) {
case 0xA0:
j->play_frame_size = 80;
break;
case 0x50:
j->play_frame_size = 40;
break;
default:
j->play_frame_size = 120;
break;
}
j->play_mode = 2;
break;
case ALAW:
switch (j->baseframe.low) {
case 0xA0:
j->play_frame_size = 80;
break;
case 0x50:
j->play_frame_size = 40;
break;
default:
j->play_frame_size = 120;
break;
}
j->play_mode = 2;
break;
case LINEAR16:
switch (j->baseframe.low) {
case 0xA0:
j->play_frame_size = 160;
break;
case 0x50:
j->play_frame_size = 80;
break;
default:
j->play_frame_size = 240;
break;
}
j->play_mode = 6;
break;
case LINEAR8:
switch (j->baseframe.low) {
case 0xA0:
j->play_frame_size = 80;
break;
case 0x50:
j->play_frame_size = 40;
break;
default:
j->play_frame_size = 120;
break;
}
j->play_mode = 4;
break;
case WSS:
switch (j->baseframe.low) {
case 0xA0:
j->play_frame_size = 80;
break;
case 0x50:
j->play_frame_size = 40;
break;
default:
j->play_frame_size = 120;
break;
}
j->play_mode = 5;
break;
default:
j->play_frame_size = 0;
j->play_mode = -1;
if (j->write_buffer) {
kfree(j->write_buffer);
j->write_buffer = NULL;
j->write_buffer_size = 0;
}
retval = 1;
break;
}
return retval;
}
static int ixj_play_start(IXJ *j)
{
unsigned short cmd = 0x0000;
if (j->write_buffer) {
ixj_play_stop(j);
}
if(ixjdebug & 0x0002)
printk("IXJ %d Starting Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
j->flags.playing = 1;
ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
j->flags.play_first_frame = 1;
j->drybuffer = 0;
if (!j->play_mode) {
switch (j->play_codec) {
case G723_63:
cmd = 0x5231;
break;
case G723_53:
cmd = 0x5232;
break;
case TS85:
cmd = 0x5230; /* TrueSpeech 8.5 */
break;
case TS48:
cmd = 0x5233; /* TrueSpeech 4.8 */
break;
case TS41:
cmd = 0x5234; /* TrueSpeech 4.1 */
break;
case G728:
cmd = 0x5235;
break;
case G729:
case G729B:
cmd = 0x5236;
break;
default:
return 1;
}
if (ixj_WriteDSPCommand(cmd, j))
return -1;
}
j->write_buffer = kmalloc(j->play_frame_size * 2, GFP_ATOMIC);
if (!j->write_buffer) {
printk("Write buffer allocation for ixj board %d failed!\n", j->board);
return -ENOMEM;
}
/* j->write_buffers_empty = 2; */
j->write_buffers_empty = 1;
j->write_buffer_size = j->play_frame_size * 2;
j->write_buffer_end = j->write_buffer + j->play_frame_size * 2;
j->write_buffer_rp = j->write_buffer_wp = j->write_buffer;
if (ixj_WriteDSPCommand(0x5202, j)) /* Set Poll sync mode */
return -1;
switch (j->play_mode) {
case 0:
cmd = 0x2C03;
break;
case 2:
if (j->ver.low == 0x12) {
cmd = 0x2C23;
} else {
cmd = 0x2C21;
}
break;
case 4:
if (j->ver.low == 0x12) {
cmd = 0x2C43;
} else {
cmd = 0x2C41;
}
break;
case 5:
if (j->ver.low == 0x12) {
cmd = 0x2C53;
} else {
cmd = 0x2C51;
}
break;
case 6:
if (j->ver.low == 0x12) {
cmd = 0x2C63;
} else {
cmd = 0x2C61;
}
break;
}
if (ixj_WriteDSPCommand(cmd, j))
return -1;
if (ixj_WriteDSPCommand(0x2000, j)) /* Playback C2 */
return -1;
if (ixj_WriteDSPCommand(0x2000 + j->play_frame_size, j)) /* Playback C3 */
return -1;
if (j->flags.recording) {
ixj_aec_start(j, j->aec_level);
}
return 0;
}
static void ixj_play_stop(IXJ *j)
{
if(ixjdebug & 0x0002)
printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
if (j->write_buffer) {
kfree(j->write_buffer);
j->write_buffer = NULL;
j->write_buffer_size = 0;
}
if (j->play_mode > -1) {
ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */
j->play_mode = -1;
}
j->flags.playing = 0;
}
static inline int get_play_level(IXJ *j)
{
int retval;
ixj_WriteDSPCommand(0xCF8F, j); /* 8022 Reference page 9-38 */
return j->ssr.high << 8 | j->ssr.low;
retval = j->ssr.high << 8 | j->ssr.low;
retval = (retval * 256) / 240;
return retval;
}
static unsigned int ixj_poll(struct file *file_p, poll_table * wait)
{
unsigned int mask = 0;
IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
poll_wait(file_p, &(j->poll_q), wait);
if (j->read_buffer_ready > 0)
mask |= POLLIN | POLLRDNORM; /* readable */
if (j->write_buffers_empty > 0)
mask |= POLLOUT | POLLWRNORM; /* writable */
if (j->ex.bytes)
mask |= POLLPRI;
return mask;
}
static int ixj_play_tone(IXJ *j, char tone)
{
if (!j->tone_state) {
if(ixjdebug & 0x0002) {
printk("IXJ %d starting tone %d at %ld\n", j->board, tone, jiffies);
}
if (j->dsp.low == 0x20) {
idle(j);
}
j->tone_start_jif = jiffies;
j->tone_state = 1;
}
j->tone_index = tone;
if (ixj_WriteDSPCommand(0x6000 + j->tone_index, j))
return -1;
return 0;
}
static int ixj_set_tone_on(unsigned short arg, IXJ *j)
{
j->tone_on_time = arg;
if (ixj_WriteDSPCommand(0x6E04, j)) /* Set Tone On Period */
return -1;
if (ixj_WriteDSPCommand(arg, j))
return -1;
return 0;
}
static int SCI_WaitHighSCI(IXJ *j)
{
int cnt;
j->pld_scrr.byte = inb_p(j->XILINXbase);
if (!j->pld_scrr.bits.sci) {
for (cnt = 0; cnt < 10; cnt++) {
udelay(32);
j->pld_scrr.byte = inb_p(j->XILINXbase);
if ((j->pld_scrr.bits.sci))
return 1;
}
if (ixjdebug & 0x0001)
printk(KERN_INFO "SCI Wait High failed %x\n", j->pld_scrr.byte);
return 0;
} else
return 1;
}
static int SCI_WaitLowSCI(IXJ *j)
{
int cnt;
j->pld_scrr.byte = inb_p(j->XILINXbase);
if (j->pld_scrr.bits.sci) {
for (cnt = 0; cnt < 10; cnt++) {
udelay(32);
j->pld_scrr.byte = inb_p(j->XILINXbase);
if (!(j->pld_scrr.bits.sci))
return 1;
}
if (ixjdebug & 0x0001)
printk(KERN_INFO "SCI Wait Low failed %x\n", j->pld_scrr.byte);
return 0;
} else
return 1;
}
static int SCI_Control(IXJ *j, int control)
{
switch (control) {
case SCI_End:
j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
j->pld_scrw.bits.c1 = 0; /* to no selection */
break;
case SCI_Enable_DAA:
j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
j->pld_scrw.bits.c1 = 0; /* to write to DAA */
break;
case SCI_Enable_Mixer:
j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
j->pld_scrw.bits.c1 = 1; /* to write to mixer */
break;
case SCI_Enable_EEPROM:
j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
j->pld_scrw.bits.c1 = 1; /* to write to EEPROM */
break;
default:
return 0;
break;
}
outb_p(j->pld_scrw.byte, j->XILINXbase);
switch (control) {
case SCI_End:
return 1;
break;
case SCI_Enable_DAA:
case SCI_Enable_Mixer:
case SCI_Enable_EEPROM:
if (!SCI_WaitHighSCI(j))
return 0;
break;
default:
return 0;
break;
}
return 1;
}
static int SCI_Prepare(IXJ *j)
{
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
return 1;
}
static int ixj_get_mixer(long val, IXJ *j)
{
int reg = (val & 0x1F00) >> 8;
return j->mix.vol[reg];
}
static int ixj_mixer(long val, IXJ *j)
{
BYTES bytes;
bytes.high = (val & 0x1F00) >> 8;
bytes.low = val & 0x00FF;
/* save mixer value so we can get back later on */
j->mix.vol[bytes.high] = bytes.low;
outb_p(bytes.high & 0x1F, j->XILINXbase + 0x03); /* Load Mixer Address */
outb_p(bytes.low, j->XILINXbase + 0x02); /* Load Mixer Data */
SCI_Control(j, SCI_Enable_Mixer);
SCI_Control(j, SCI_End);
return 0;
}
static int daa_load(BYTES * p_bytes, IXJ *j)
{
outb_p(p_bytes->high, j->XILINXbase + 0x03);
outb_p(p_bytes->low, j->XILINXbase + 0x02);
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
else
return 1;
}
static int ixj_daa_cr4(IXJ *j, char reg)
{
BYTES bytes;
switch (j->daa_mode) {
case SOP_PU_SLEEP:
bytes.high = 0x14;
break;
case SOP_PU_RINGING:
bytes.high = 0x54;
break;
case SOP_PU_CONVERSATION:
bytes.high = 0x94;
break;
case SOP_PU_PULSEDIALING:
bytes.high = 0xD4;
break;
}
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = reg;
switch (j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGX) {
case 0:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 0;
break;
case 1:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 2;
break;
case 2:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 1;
break;
case 3:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 3;
break;
}
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Prepare(j))
return 0;
return 1;
}
static char daa_int_read(IXJ *j)
{
BYTES bytes;
if (!SCI_Prepare(j))
return 0;
bytes.high = 0x38;
bytes.low = 0x00;
outb_p(bytes.high, j->XILINXbase + 0x03);
outb_p(bytes.low, j->XILINXbase + 0x02);
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
bytes.high = inb_p(j->XILINXbase + 0x03);
bytes.low = inb_p(j->XILINXbase + 0x02);
if (bytes.low != ALISDAA_ID_BYTE) {
if (ixjdebug & 0x0001)
printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
return 0;
}
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
bytes.high = inb_p(j->XILINXbase + 0x03);
bytes.low = inb_p(j->XILINXbase + 0x02);
j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg = bytes.high;
return 1;
}
static char daa_CR_read(IXJ *j, int cr)
{
IXJ_WORD wdata;
BYTES bytes;
if (!SCI_Prepare(j))
return 0;
switch (j->daa_mode) {
case SOP_PU_SLEEP:
bytes.high = 0x30 + cr;
break;
case SOP_PU_RINGING:
bytes.high = 0x70 + cr;
break;
case SOP_PU_CONVERSATION:
bytes.high = 0xB0 + cr;
break;
case SOP_PU_PULSEDIALING:
bytes.high = 0xF0 + cr;
break;
}
bytes.low = 0x00;
outb_p(bytes.high, j->XILINXbase + 0x03);
outb_p(bytes.low, j->XILINXbase + 0x02);
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
bytes.high = inb_p(j->XILINXbase + 0x03);
bytes.low = inb_p(j->XILINXbase + 0x02);
if (bytes.low != ALISDAA_ID_BYTE) {
if (ixjdebug & 0x0001)
printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
return 0;
}
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
wdata.word = inw_p(j->XILINXbase + 0x02);
switch(cr){
case 5:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = wdata.bytes.high;
break;
case 4:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = wdata.bytes.high;
break;
case 3:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = wdata.bytes.high;
break;
case 2:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = wdata.bytes.high;
break;
case 1:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = wdata.bytes.high;
break;
case 0:
j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = wdata.bytes.high;
break;
default:
return 0;
}
return 1;
}
static int ixj_daa_cid_reset(IXJ *j)
{
int i;
BYTES bytes;
if (ixjdebug & 0x0002)
printk("DAA Clearing CID ram\n");
if (!SCI_Prepare(j))
return 0;
bytes.high = 0x58;
bytes.low = 0x00;
outb_p(bytes.high, j->XILINXbase + 0x03);
outb_p(bytes.low, j->XILINXbase + 0x02);
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
if (!SCI_WaitHighSCI(j))
return 0;
for (i = 0; i < ALISDAA_CALLERID_SIZE - 1; i += 2) {
bytes.high = bytes.low = 0x00;
outb_p(bytes.high, j->XILINXbase + 0x03);
if (i < ALISDAA_CALLERID_SIZE - 1)
outb_p(bytes.low, j->XILINXbase + 0x02);
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
if (!SCI_WaitHighSCI(j))
return 0;
}
if (!SCI_Control(j, SCI_End))
return 0;
if (ixjdebug & 0x0002)
printk("DAA CID ram cleared\n");
return 1;
}
static int ixj_daa_cid_read(IXJ *j)
{
int i;
BYTES bytes;
char CID[ALISDAA_CALLERID_SIZE], mContinue;
char *pIn, *pOut;
if (!SCI_Prepare(j))
return 0;
bytes.high = 0x78;
bytes.low = 0x00;
outb_p(bytes.high, j->XILINXbase + 0x03);
outb_p(bytes.low, j->XILINXbase + 0x02);
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
if (!SCI_WaitHighSCI(j))
return 0;
bytes.high = inb_p(j->XILINXbase + 0x03);
bytes.low = inb_p(j->XILINXbase + 0x02);
if (bytes.low != ALISDAA_ID_BYTE) {
if (ixjdebug & 0x0001)
printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
return 0;
}
for (i = 0; i < ALISDAA_CALLERID_SIZE; i += 2) {
bytes.high = bytes.low = 0x00;
outb_p(bytes.high, j->XILINXbase + 0x03);
outb_p(bytes.low, j->XILINXbase + 0x02);
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
if (!SCI_WaitHighSCI(j))
return 0;
CID[i + 0] = inb_p(j->XILINXbase + 0x03);
CID[i + 1] = inb_p(j->XILINXbase + 0x02);
}
if (!SCI_Control(j, SCI_End))
return 0;
pIn = CID;
pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
mContinue = 1;
while (mContinue) {
if ((pIn[1] & 0x03) == 0x01) {
pOut[0] = pIn[0];
}
if ((pIn[2] & 0x0c) == 0x04) {
pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2);
}
if ((pIn[3] & 0x30) == 0x10) {
pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4);
}
if ((pIn[4] & 0xc0) == 0x40) {
pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6);
} else {
mContinue = FALSE;
}
pIn += 5, pOut += 4;
}
memset(&j->cid, 0, sizeof(PHONE_CID));
pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
pOut += 4;
strncpy(j->cid.month, pOut, 2);
pOut += 2;
strncpy(j->cid.day, pOut, 2);
pOut += 2;
strncpy(j->cid.hour, pOut, 2);
pOut += 2;
strncpy(j->cid.min, pOut, 2);
pOut += 3;
j->cid.numlen = *pOut;
pOut += 1;
strncpy(j->cid.number, pOut, j->cid.numlen);
pOut += j->cid.numlen + 1;
j->cid.namelen = *pOut;
pOut += 1;
strncpy(j->cid.name, pOut, j->cid.namelen);
ixj_daa_cid_reset(j);
return 1;
}
static char daa_get_version(IXJ *j)
{
BYTES bytes;
if (!SCI_Prepare(j))
return 0;
bytes.high = 0x35;
bytes.low = 0x00;
outb_p(bytes.high, j->XILINXbase + 0x03);
outb_p(bytes.low, j->XILINXbase + 0x02);
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
bytes.high = inb_p(j->XILINXbase + 0x03);
bytes.low = inb_p(j->XILINXbase + 0x02);
if (bytes.low != ALISDAA_ID_BYTE) {
if (ixjdebug & 0x0001)
printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
return 0;
}
if (!SCI_Control(j, SCI_Enable_DAA))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
bytes.high = inb_p(j->XILINXbase + 0x03);
bytes.low = inb_p(j->XILINXbase + 0x02);
if (ixjdebug & 0x0002)
printk("DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.high, bytes.low);
j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = bytes.high;
return bytes.high;
}
static int daa_set_mode(IXJ *j, int mode)
{
/* NOTE:
The DAA *MUST* be in the conversation mode if the
PSTN line is to be seized (PSTN line off-hook).
Taking the PSTN line off-hook while the DAA is in
a mode other than conversation mode will cause a
hardware failure of the ALIS-A part.
NOTE:
The DAA can only go to SLEEP, RINGING or PULSEDIALING modes
if the PSTN line is on-hook. Failure to have the PSTN line
in the on-hook state WILL CAUSE A HARDWARE FAILURE OF THE
ALIS-A part.
*/
BYTES bytes;
j->flags.pstn_rmr = 0;
if (!SCI_Prepare(j))
return 0;
switch (mode) {
case SOP_PU_RESET:
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->pld_slicw.bits.rly2 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
bytes.high = 0x10;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
daa_load(&bytes, j);
if (!SCI_Prepare(j))
return 0;
j->daa_mode = SOP_PU_SLEEP;
break;
case SOP_PU_SLEEP:
if(j->daa_mode == SOP_PU_SLEEP)
{
break;
}
if (ixjdebug & 0x0008)
printk(KERN_INFO "phone DAA: SOP_PU_SLEEP at %ld\n", jiffies);
/* if(j->daa_mode == SOP_PU_CONVERSATION) */
{
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->pld_slicw.bits.rly2 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
bytes.high = 0x10;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
daa_load(&bytes, j);
if (!SCI_Prepare(j))
return 0;
}
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->pld_slicw.bits.rly2 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
bytes.high = 0x10;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
daa_load(&bytes, j);
if (!SCI_Prepare(j))
return 0;
j->daa_mode = SOP_PU_SLEEP;
j->flags.pstn_ringing = 0;
j->ex.bits.pstn_ring = 0;
j->pstn_sleeptil = jiffies + (hertz / 4);
wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
break;
case SOP_PU_RINGING:
if (ixjdebug & 0x0008)
printk(KERN_INFO "phone DAA: SOP_PU_RINGING at %ld\n", jiffies);
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->pld_slicw.bits.rly2 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
bytes.high = 0x50;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
daa_load(&bytes, j);
if (!SCI_Prepare(j))
return 0;
j->daa_mode = SOP_PU_RINGING;
break;
case SOP_PU_CONVERSATION:
if (ixjdebug & 0x0008)
printk(KERN_INFO "phone DAA: SOP_PU_CONVERSATION at %ld\n", jiffies);
bytes.high = 0x90;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
daa_load(&bytes, j);
if (!SCI_Prepare(j))
return 0;
j->pld_slicw.bits.rly2 = 1;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
j->pld_scrw.bits.daafsyncen = 1; /* Turn on DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->daa_mode = SOP_PU_CONVERSATION;
j->flags.pstn_ringing = 0;
j->ex.bits.pstn_ring = 0;
j->pstn_sleeptil = jiffies;
j->pstn_ring_start = j->pstn_ring_stop = j->pstn_ring_int = 0;
break;
case SOP_PU_PULSEDIALING:
if (ixjdebug & 0x0008)
printk(KERN_INFO "phone DAA: SOP_PU_PULSEDIALING at %ld\n", jiffies);
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->pld_slicw.bits.rly2 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
bytes.high = 0xD0;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
daa_load(&bytes, j);
if (!SCI_Prepare(j))
return 0;
j->daa_mode = SOP_PU_PULSEDIALING;
break;
default:
break;
}
return 1;
}
static int ixj_daa_write(IXJ *j)
{
BYTES bytes;
j->flags.pstncheck = 1;
daa_set_mode(j, SOP_PU_SLEEP);
if (!SCI_Prepare(j))
return 0;
outb_p(j->pld_scrw.byte, j->XILINXbase);
bytes.high = 0x14;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg;
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg;
bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Prepare(j))
return 0;
bytes.high = 0x1F;
bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg;
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.XOP_xr6_W.reg;
bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg;
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg;
bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg;
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg;
bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg;
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.XOP_xr0_W.reg;
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Prepare(j))
return 0;
bytes.high = 0x00;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x01;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x02;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x03;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x04;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x05;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x06;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x07;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x08;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x09;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x0A;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x0B;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x0C;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x0D;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x0E;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
if (!SCI_Control(j, SCI_End))
return 0;
if (!SCI_WaitLowSCI(j))
return 0;
bytes.high = 0x0F;
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2];
bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1];
if (!daa_load(&bytes, j))
return 0;
bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0];
bytes.low = 0x00;
if (!daa_load(&bytes, j))
return 0;
udelay(32);
j->pld_scrr.byte = inb_p(j->XILINXbase);
if (!SCI_Control(j, SCI_End))
return 0;
outb_p(j->pld_scrw.byte, j->XILINXbase);
if (ixjdebug & 0x0002)
printk("DAA Coefficients Loaded\n");
j->flags.pstncheck = 0;
return 1;
}
int ixj_set_tone_off(unsigned short arg, IXJ *j)
{
j->tone_off_time = arg;
if (ixj_WriteDSPCommand(0x6E05, j)) /* Set Tone Off Period */
return -1;
if (ixj_WriteDSPCommand(arg, j))
return -1;
return 0;
}
static int ixj_get_tone_on(IXJ *j)
{
if (ixj_WriteDSPCommand(0x6E06, j)) /* Get Tone On Period */
return -1;
return 0;
}
static int ixj_get_tone_off(IXJ *j)
{
if (ixj_WriteDSPCommand(0x6E07, j)) /* Get Tone Off Period */
return -1;
return 0;
}
static void ixj_busytone(IXJ *j)
{
j->flags.ringback = 0;
j->flags.dialtone = 0;
j->flags.busytone = 1;
ixj_set_tone_on(0x07D0, j);
ixj_set_tone_off(0x07D0, j);
ixj_play_tone(j, 27);
}
static void ixj_dialtone(IXJ *j)
{
j->flags.ringback = 0;
j->flags.dialtone = 1;
j->flags.busytone = 0;
if (j->dsp.low == 0x20) {
return;
} else {
ixj_set_tone_on(0xFFFF, j);
ixj_set_tone_off(0x0000, j);
ixj_play_tone(j, 25);
}
}
static void ixj_cpt_stop(IXJ *j)
{
if(j->tone_state || j->tone_cadence_state)
{
j->flags.dialtone = 0;
j->flags.busytone = 0;
j->flags.ringback = 0;
ixj_set_tone_on(0x0001, j);
ixj_set_tone_off(0x0000, j);
ixj_play_tone(j, 0);
j->tone_state = j->tone_cadence_state = 0;
if (j->cadence_t) {
if (j->cadence_t->ce) {
kfree(j->cadence_t->ce);
}
kfree(j->cadence_t);
j->cadence_t = NULL;
}
}
if (j->play_mode == -1 && j->rec_mode == -1)
idle(j);
if (j->play_mode != -1 && j->dsp.low == 0x20)
ixj_play_start(j);
if (j->rec_mode != -1 && j->dsp.low == 0x20)
ixj_record_start(j);
}
static void ixj_ringback(IXJ *j)
{
j->flags.busytone = 0;
j->flags.dialtone = 0;
j->flags.ringback = 1;
ixj_set_tone_on(0x0FA0, j);
ixj_set_tone_off(0x2EE0, j);
ixj_play_tone(j, 26);
}
static void ixj_testram(IXJ *j)
{
ixj_WriteDSPCommand(0x3001, j); /* Test External SRAM */
}
static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp)
{
ixj_cadence *lcp;
IXJ_CADENCE_ELEMENT __user *cep;
IXJ_CADENCE_ELEMENT *lcep;
IXJ_TONE ti;
int err;
lcp = kmalloc(sizeof(ixj_cadence), GFP_KERNEL);
if (lcp == NULL)
return -ENOMEM;
err = -EFAULT;
if (copy_from_user(&lcp->elements_used,
&cp->elements_used, sizeof(int)))
goto out;
if (copy_from_user(&lcp->termination,
&cp->termination, sizeof(IXJ_CADENCE_TERM)))
goto out;
if (get_user(cep, &cp->ce))
goto out;
err = -EINVAL;
if ((unsigned)lcp->elements_used >= ~0U/sizeof(IXJ_CADENCE_ELEMENT))
goto out;
err = -ENOMEM;
lcep = kmalloc(sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used, GFP_KERNEL);
if (!lcep)
goto out;
err = -EFAULT;
if (copy_from_user(lcep, cep, sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used))
goto out1;
if (j->cadence_t) {
kfree(j->cadence_t->ce);
kfree(j->cadence_t);
}
lcp->ce = (void *) lcep;
j->cadence_t = lcp;
j->tone_cadence_state = 0;
ixj_set_tone_on(lcp->ce[0].tone_on_time, j);
ixj_set_tone_off(lcp->ce[0].tone_off_time, j);
if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
ixj_init_tone(j, &ti);
}
ixj_play_tone(j, lcp->ce[0].index);
return 1;
out1:
kfree(lcep);
out:
kfree(lcp);
return err;
}
static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp)
{
IXJ_FILTER_CADENCE *lcp;
lcp = kmalloc(sizeof(IXJ_FILTER_CADENCE), GFP_KERNEL);
if (lcp == NULL) {
if(ixjdebug & 0x0001) {
printk(KERN_INFO "Could not allocate memory for cadence\n");
}
return -ENOMEM;
}
if (copy_from_user(lcp, cp, sizeof(IXJ_FILTER_CADENCE))) {
if(ixjdebug & 0x0001) {
printk(KERN_INFO "Could not copy cadence to kernel\n");
}
kfree(lcp);
return -EFAULT;
}
if (lcp->filter > 5) {
if(ixjdebug & 0x0001) {
printk(KERN_INFO "Cadence out of range\n");
}
kfree(lcp);
return -1;
}
j->cadence_f[lcp->filter].state = 0;
j->cadence_f[lcp->filter].enable = lcp->enable;
j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter;
j->cadence_f[lcp->filter].on1 = lcp->on1;
j->cadence_f[lcp->filter].on1min = 0;
j->cadence_f[lcp->filter].on1max = 0;
j->cadence_f[lcp->filter].off1 = lcp->off1;
j->cadence_f[lcp->filter].off1min = 0;
j->cadence_f[lcp->filter].off1max = 0;
j->cadence_f[lcp->filter].on2 = lcp->on2;
j->cadence_f[lcp->filter].on2min = 0;
j->cadence_f[lcp->filter].on2max = 0;
j->cadence_f[lcp->filter].off2 = lcp->off2;
j->cadence_f[lcp->filter].off2min = 0;
j->cadence_f[lcp->filter].off2max = 0;
j->cadence_f[lcp->filter].on3 = lcp->on3;
j->cadence_f[lcp->filter].on3min = 0;
j->cadence_f[lcp->filter].on3max = 0;
j->cadence_f[lcp->filter].off3 = lcp->off3;
j->cadence_f[lcp->filter].off3min = 0;
j->cadence_f[lcp->filter].off3max = 0;
if(ixjdebug & 0x0002) {
printk(KERN_INFO "Cadence %d loaded\n", lcp->filter);
}
kfree(lcp);
return 0;
}
static void add_caps(IXJ *j)
{
j->caps = 0;
j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET;
strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)");
j->caplist[j->caps].captype = vendor;
j->caplist[j->caps].handle = j->caps++;
j->caplist[j->caps].captype = device;
switch (j->cardtype) {
case QTI_PHONEJACK:
strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK");
break;
case QTI_LINEJACK:
strcpy(j->caplist[j->caps].desc, "Quicknet Internet LineJACK");
break;
case QTI_PHONEJACK_LITE:
strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK Lite");
break;
case QTI_PHONEJACK_PCI:
strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK PCI");
break;
case QTI_PHONECARD:
strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneCARD");
break;
}
j->caplist[j->caps].cap = j->cardtype;
j->caplist[j->caps].handle = j->caps++;
strcpy(j->caplist[j->caps].desc, "POTS");
j->caplist[j->caps].captype = port;
j->caplist[j->caps].cap = pots;
j->caplist[j->caps].handle = j->caps++;
/* add devices that can do speaker/mic */
switch (j->cardtype) {
case QTI_PHONEJACK:
case QTI_LINEJACK:
case QTI_PHONEJACK_PCI:
case QTI_PHONECARD:
strcpy(j->caplist[j->caps].desc, "SPEAKER");
j->caplist[j->caps].captype = port;
j->caplist[j->caps].cap = speaker;
j->caplist[j->caps].handle = j->caps++;
default:
break;
}
/* add devices that can do handset */
switch (j->cardtype) {
case QTI_PHONEJACK:
strcpy(j->caplist[j->caps].desc, "HANDSET");
j->caplist[j->caps].captype = port;
j->caplist[j->caps].cap = handset;
j->caplist[j->caps].handle = j->caps++;
break;
default:
break;
}
/* add devices that can do PSTN */
switch (j->cardtype) {
case QTI_LINEJACK:
strcpy(j->caplist[j->caps].desc, "PSTN");
j->caplist[j->caps].captype = port;
j->caplist[j->caps].cap = pstn;
j->caplist[j->caps].handle = j->caps++;
break;
default:
break;
}
/* add codecs - all cards can do uLaw, linear 8/16, and Windows sound system */
strcpy(j->caplist[j->caps].desc, "ULAW");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = ULAW;
j->caplist[j->caps].handle = j->caps++;
strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = LINEAR16;
j->caplist[j->caps].handle = j->caps++;
strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = LINEAR8;
j->caplist[j->caps].handle = j->caps++;
strcpy(j->caplist[j->caps].desc, "Windows Sound System");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = WSS;
j->caplist[j->caps].handle = j->caps++;
/* software ALAW codec, made from ULAW */
strcpy(j->caplist[j->caps].desc, "ALAW");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = ALAW;
j->caplist[j->caps].handle = j->caps++;
/* version 12 of the 8020 does the following codecs in a broken way */
if (j->dsp.low != 0x20 || j->ver.low != 0x12) {
strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = G723_63;
j->caplist[j->caps].handle = j->caps++;
strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = G723_53;
j->caplist[j->caps].handle = j->caps++;
strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = TS48;
j->caplist[j->caps].handle = j->caps++;
strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = TS41;
j->caplist[j->caps].handle = j->caps++;
}
/* 8020 chips can do TS8.5 native, and 8021/8022 can load it */
if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = TS85;
j->caplist[j->caps].handle = j->caps++;
}
/* 8021 chips can do G728 */
if (j->dsp.low == 0x21) {
strcpy(j->caplist[j->caps].desc, "G.728 16kbps");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = G728;
j->caplist[j->caps].handle = j->caps++;
}
/* 8021/8022 chips can do G729 if loaded */
if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
strcpy(j->caplist[j->caps].desc, "G.729A 8kbps");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = G729;
j->caplist[j->caps].handle = j->caps++;
}
if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
strcpy(j->caplist[j->caps].desc, "G.729B 8kbps");
j->caplist[j->caps].captype = codec;
j->caplist[j->caps].cap = G729B;
j->caplist[j->caps].handle = j->caps++;
}
}
static int capabilities_check(IXJ *j, struct phone_capability *pcreq)
{
int cnt;
int retval = 0;
for (cnt = 0; cnt < j->caps; cnt++) {
if (pcreq->captype == j->caplist[cnt].captype
&& pcreq->cap == j->caplist[cnt].cap) {
retval = 1;
break;
}
}
return retval;
}
static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg)
{
IXJ_TONE ti;
IXJ_FILTER jf;
IXJ_FILTER_RAW jfr;
void __user *argp = (void __user *)arg;
unsigned int raise, mant;
unsigned int minor = iminor(inode);
int board = NUM(inode);
IXJ *j = get_ixj(NUM(inode));
int retval = 0;
/*
* Set up locks to ensure that only one process is talking to the DSP at a time.
* This is necessary to keep the DSP from locking up.
*/
while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
if (ixjdebug & 0x0040)
printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
if (minor >= IXJMAX) {
clear_bit(board, &j->busyflags);
return -ENODEV;
}
/*
* Check ioctls only root can use.
*/
if (!capable(CAP_SYS_ADMIN)) {
switch (cmd) {
case IXJCTL_TESTRAM:
case IXJCTL_HZ:
retval = -EPERM;
}
}
switch (cmd) {
case IXJCTL_TESTRAM:
ixj_testram(j);
retval = (j->ssr.high << 8) + j->ssr.low;
break;
case IXJCTL_CARDTYPE:
retval = j->cardtype;
break;
case IXJCTL_SERIAL:
retval = j->serial;
break;
case IXJCTL_VERSION:
{
char arg_str[100];
snprintf(arg_str, sizeof(arg_str),
"\nDriver version %i.%i.%i", IXJ_VER_MAJOR,
IXJ_VER_MINOR, IXJ_BLD_VER);
if (copy_to_user(argp, arg_str, strlen(arg_str)))
retval = -EFAULT;
}
break;
case PHONE_RING_CADENCE:
j->ring_cadence = arg;
break;
case IXJCTL_CIDCW:
if(arg) {
if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
retval = -EFAULT;
break;
}
} else {
memset(&j->cid_send, 0, sizeof(PHONE_CID));
}
ixj_write_cidcw(j);
break;
/* Binary compatbility */
case OLD_PHONE_RING_START:
arg = 0;
/* Fall through */
case PHONE_RING_START:
if(arg) {
if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
retval = -EFAULT;
break;
}
ixj_write_cid(j);
} else {
memset(&j->cid_send, 0, sizeof(PHONE_CID));
}
ixj_ring_start(j);
break;
case PHONE_RING_STOP:
j->flags.cringing = 0;
if(j->cadence_f[5].enable) {
j->cadence_f[5].state = 0;
}
ixj_ring_off(j);
break;
case PHONE_RING:
retval = ixj_ring(j);
break;
case PHONE_EXCEPTION:
retval = j->ex.bytes;
if(j->ex.bits.flash) {
j->flash_end = 0;
j->ex.bits.flash = 0;
}
j->ex.bits.pstn_ring = 0;
j->ex.bits.caller_id = 0;
j->ex.bits.pstn_wink = 0;
j->ex.bits.f0 = 0;
j->ex.bits.f1 = 0;
j->ex.bits.f2 = 0;
j->ex.bits.f3 = 0;
j->ex.bits.fc0 = 0;
j->ex.bits.fc1 = 0;
j->ex.bits.fc2 = 0;
j->ex.bits.fc3 = 0;
j->ex.bits.reserved = 0;
break;
case PHONE_HOOKSTATE:
j->ex.bits.hookstate = 0;
retval = j->hookstate; //j->r_hook;
break;
case IXJCTL_SET_LED:
LED_SetState(arg, j);
break;
case PHONE_FRAME:
retval = set_base_frame(j, arg);
break;
case PHONE_REC_CODEC:
retval = set_rec_codec(j, arg);
break;
case PHONE_VAD:
ixj_vad(j, arg);
break;
case PHONE_REC_START:
ixj_record_start(j);
break;
case PHONE_REC_STOP:
ixj_record_stop(j);
break;
case PHONE_REC_DEPTH:
set_rec_depth(j, arg);
break;
case PHONE_REC_VOLUME:
if(arg == -1) {
retval = get_rec_volume(j);
}
else {
set_rec_volume(j, arg);
retval = arg;
}
break;
case PHONE_REC_VOLUME_LINEAR:
if(arg == -1) {
retval = get_rec_volume_linear(j);
}
else {
set_rec_volume_linear(j, arg);
retval = arg;
}
break;
case IXJCTL_DTMF_PRESCALE:
if(arg == -1) {
retval = get_dtmf_prescale(j);
}
else {
set_dtmf_prescale(j, arg);
retval = arg;
}
break;
case PHONE_REC_LEVEL:
retval = get_rec_level(j);
break;
case IXJCTL_SC_RXG:
retval = ixj_siadc(j, arg);
break;
case IXJCTL_SC_TXG:
retval = ixj_sidac(j, arg);
break;
case IXJCTL_AEC_START:
ixj_aec_start(j, arg);
break;
case IXJCTL_AEC_STOP:
aec_stop(j);
break;
case IXJCTL_AEC_GET_LEVEL:
retval = j->aec_level;
break;
case PHONE_PLAY_CODEC:
retval = set_play_codec(j, arg);
break;
case PHONE_PLAY_START:
retval = ixj_play_start(j);
break;
case PHONE_PLAY_STOP:
ixj_play_stop(j);
break;
case PHONE_PLAY_DEPTH:
set_play_depth(j, arg);
break;
case PHONE_PLAY_VOLUME:
if(arg == -1) {
retval = get_play_volume(j);
}
else {
set_play_volume(j, arg);
retval = arg;
}
break;
case PHONE_PLAY_VOLUME_LINEAR:
if(arg == -1) {
retval = get_play_volume_linear(j);
}
else {
set_play_volume_linear(j, arg);
retval = arg;
}
break;
case PHONE_PLAY_LEVEL:
retval = get_play_level(j);
break;
case IXJCTL_DSP_TYPE:
retval = (j->dsp.high << 8) + j->dsp.low;
break;
case IXJCTL_DSP_VERSION:
retval = (j->ver.high << 8) + j->ver.low;
break;
case IXJCTL_HZ:
hertz = arg;
break;
case IXJCTL_RATE:
if (arg > hertz)
retval = -1;
else
samplerate = arg;
break;
case IXJCTL_DRYBUFFER_READ:
put_user(j->drybuffer, (unsigned long __user *) argp);
break;
case IXJCTL_DRYBUFFER_CLEAR:
j->drybuffer = 0;
break;
case IXJCTL_FRAMES_READ:
put_user(j->framesread, (unsigned long __user *) argp);
break;
case IXJCTL_FRAMES_WRITTEN:
put_user(j->frameswritten, (unsigned long __user *) argp);
break;
case IXJCTL_READ_WAIT:
put_user(j->read_wait, (unsigned long __user *) argp);
break;
case IXJCTL_WRITE_WAIT:
put_user(j->write_wait, (unsigned long __user *) argp);
break;
case PHONE_MAXRINGS:
j->maxrings = arg;
break;
case PHONE_SET_TONE_ON_TIME:
ixj_set_tone_on(arg, j);
break;
case PHONE_SET_TONE_OFF_TIME:
ixj_set_tone_off(arg, j);
break;
case PHONE_GET_TONE_ON_TIME:
if (ixj_get_tone_on(j)) {
retval = -1;
} else {
retval = (j->ssr.high << 8) + j->ssr.low;
}
break;
case PHONE_GET_TONE_OFF_TIME:
if (ixj_get_tone_off(j)) {
retval = -1;
} else {
retval = (j->ssr.high << 8) + j->ssr.low;
}
break;
case PHONE_PLAY_TONE:
if (!j->tone_state)
retval = ixj_play_tone(j, arg);
else
retval = -1;
break;
case PHONE_GET_TONE_STATE:
retval = j->tone_state;
break;
case PHONE_DTMF_READY:
retval = j->ex.bits.dtmf_ready;
break;
case PHONE_GET_DTMF:
if (ixj_hookstate(j)) {
if (j->dtmf_rp != j->dtmf_wp) {
retval = j->dtmfbuffer[j->dtmf_rp];
j->dtmf_rp++;
if (j->dtmf_rp == 79)
j->dtmf_rp = 0;
if (j->dtmf_rp == j->dtmf_wp) {
j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
}
}
}
break;
case PHONE_GET_DTMF_ASCII:
if (ixj_hookstate(j)) {
if (j->dtmf_rp != j->dtmf_wp) {
switch (j->dtmfbuffer[j->dtmf_rp]) {
case 10:
retval = 42; /* '*'; */
break;
case 11:
retval = 48; /*'0'; */
break;
case 12:
retval = 35; /*'#'; */
break;
case 28:
retval = 65; /*'A'; */
break;
case 29:
retval = 66; /*'B'; */
break;
case 30:
retval = 67; /*'C'; */
break;
case 31:
retval = 68; /*'D'; */
break;
default:
retval = 48 + j->dtmfbuffer[j->dtmf_rp];
break;
}
j->dtmf_rp++;
if (j->dtmf_rp == 79)
j->dtmf_rp = 0;
if(j->dtmf_rp == j->dtmf_wp)
{
j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
}
}
}
break;
case PHONE_DTMF_OOB:
j->flags.dtmf_oob = arg;
break;
case PHONE_DIALTONE:
ixj_dialtone(j);
break;
case PHONE_BUSY:
ixj_busytone(j);
break;
case PHONE_RINGBACK:
ixj_ringback(j);
break;
case PHONE_WINK:
if(j->cardtype == QTI_PHONEJACK)
retval = -1;
else
retval = ixj_wink(j);
break;
case PHONE_CPT_STOP:
ixj_cpt_stop(j);
break;
case PHONE_QUERY_CODEC:
{
struct phone_codec_data pd;
int val;
int proto_size[] = {
-1,
12, 10, 16, 9, 8, 48, 5,
40, 40, 80, 40, 40, 6
};
if(copy_from_user(&pd, argp, sizeof(pd))) {
retval = -EFAULT;
break;
}
if(pd.type<1 || pd.type>13) {
retval = -EPROTONOSUPPORT;
break;
}
if(pd.type<G729)
val=proto_size[pd.type];
else switch(j->baseframe.low)
{
case 0xA0:val=2*proto_size[pd.type];break;
case 0x50:val=proto_size[pd.type];break;
default:val=proto_size[pd.type]*3;break;
}
pd.buf_min=pd.buf_max=pd.buf_opt=val;
if(copy_to_user(argp, &pd, sizeof(pd)))
retval = -EFAULT;
break;
}
case IXJCTL_DSP_IDLE:
idle(j);
break;
case IXJCTL_MIXER:
if ((arg & 0xff) == 0xff)
retval = ixj_get_mixer(arg, j);
else
ixj_mixer(arg, j);
break;
case IXJCTL_DAA_COEFF_SET:
switch (arg) {
case DAA_US:
DAA_Coeff_US(j);
retval = ixj_daa_write(j);
break;
case DAA_UK:
DAA_Coeff_UK(j);
retval = ixj_daa_write(j);
break;
case DAA_FRANCE:
DAA_Coeff_France(j);
retval = ixj_daa_write(j);
break;
case DAA_GERMANY:
DAA_Coeff_Germany(j);
retval = ixj_daa_write(j);
break;
case DAA_AUSTRALIA:
DAA_Coeff_Australia(j);
retval = ixj_daa_write(j);
break;
case DAA_JAPAN:
DAA_Coeff_Japan(j);
retval = ixj_daa_write(j);
break;
default:
retval = 1;
break;
}
break;
case IXJCTL_DAA_AGAIN:
ixj_daa_cr4(j, arg | 0x02);
break;
case IXJCTL_PSTN_LINETEST:
retval = ixj_linetest(j);
break;
case IXJCTL_VMWI:
ixj_write_vmwi(j, arg);
break;
case IXJCTL_CID:
if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID)))
retval = -EFAULT;
j->ex.bits.caller_id = 0;
break;
case IXJCTL_WINK_DURATION:
j->winktime = arg;
break;
case IXJCTL_PORT:
if (arg)
retval = ixj_set_port(j, arg);
else
retval = j->port;
break;
case IXJCTL_POTS_PSTN:
retval = ixj_set_pots(j, arg);
break;
case PHONE_CAPABILITIES:
add_caps(j);
retval = j->caps;
break;
case PHONE_CAPABILITIES_LIST:
add_caps(j);
if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps))
retval = -EFAULT;
break;
case PHONE_CAPABILITIES_CHECK:
{
struct phone_capability cap;
if (copy_from_user(&cap, argp, sizeof(cap)))
retval = -EFAULT;
else {
add_caps(j);
retval = capabilities_check(j, &cap);
}
}
break;
case PHONE_PSTN_SET_STATE:
daa_set_mode(j, arg);
break;
case PHONE_PSTN_GET_STATE:
retval = j->daa_mode;
j->ex.bits.pstn_ring = 0;
break;
case IXJCTL_SET_FILTER:
if (copy_from_user(&jf, argp, sizeof(jf)))
retval = -EFAULT;
retval = ixj_init_filter(j, &jf);
break;
case IXJCTL_SET_FILTER_RAW:
if (copy_from_user(&jfr, argp, sizeof(jfr)))
retval = -EFAULT;
else
retval = ixj_init_filter_raw(j, &jfr);
break;
case IXJCTL_GET_FILTER_HIST:
if(arg<0||arg>3)
retval = -EINVAL;
else
retval = j->filter_hist[arg];
break;
case IXJCTL_INIT_TONE:
if (copy_from_user(&ti, argp, sizeof(ti)))
retval = -EFAULT;
else
retval = ixj_init_tone(j, &ti);
break;
case IXJCTL_TONE_CADENCE:
retval = ixj_build_cadence(j, argp);
break;
case IXJCTL_FILTER_CADENCE:
retval = ixj_build_filter_cadence(j, argp);
break;
case IXJCTL_SIGCTL:
if (copy_from_user(&j->sigdef, argp, sizeof(IXJ_SIGDEF))) {
retval = -EFAULT;
break;
}
j->ixj_signals[j->sigdef.event] = j->sigdef.signal;
if(j->sigdef.event < 33) {
raise = 1;
for(mant = 0; mant < j->sigdef.event; mant++){
raise *= 2;
}
if(j->sigdef.signal)
j->ex_sig.bytes |= raise;
else
j->ex_sig.bytes &= (raise^0xffff);
}
break;
case IXJCTL_INTERCOM_STOP:
if(arg < 0 || arg >= IXJMAX)
return -EINVAL;
j->intercom = -1;
ixj_record_stop(j);
ixj_play_stop(j);
idle(j);
get_ixj(arg)->intercom = -1;
ixj_record_stop(get_ixj(arg));
ixj_play_stop(get_ixj(arg));
idle(get_ixj(arg));
break;
case IXJCTL_INTERCOM_START:
if(arg < 0 || arg >= IXJMAX)
return -EINVAL;
j->intercom = arg;
ixj_record_start(j);
ixj_play_start(j);
get_ixj(arg)->intercom = board;
ixj_play_start(get_ixj(arg));
ixj_record_start(get_ixj(arg));
break;
}
if (ixjdebug & 0x0040)
printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
clear_bit(board, &j->busyflags);
return retval;
}
static int ixj_fasync(int fd, struct file *file_p, int mode)
{
IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
return fasync_helper(fd, file_p, mode, &j->async_queue);
}
static struct file_operations ixj_fops =
{
.owner = THIS_MODULE,
.read = ixj_enhanced_read,
.write = ixj_enhanced_write,
.poll = ixj_poll,
.ioctl = ixj_ioctl,
.release = ixj_release,
.fasync = ixj_fasync
};
static int ixj_linetest(IXJ *j)
{
unsigned long jifwait;
j->flags.pstncheck = 1; /* Testing */
j->flags.pstn_present = 0; /* Assume the line is not there */
daa_int_read(j); /*Clear DAA Interrupt flags */
/* */
/* Hold all relays in the normally de-energized position. */
/* */
j->pld_slicw.bits.rly1 = 0;
j->pld_slicw.bits.rly2 = 0;
j->pld_slicw.bits.rly3 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
if (j->pld_slicr.bits.potspstn) {
j->flags.pots_pstn = 1;
j->flags.pots_correct = 0;
LED_SetState(0x4, j);
} else {
j->flags.pots_pstn = 0;
j->pld_slicw.bits.rly1 = 0;
j->pld_slicw.bits.rly2 = 0;
j->pld_slicw.bits.rly3 = 1;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
daa_set_mode(j, SOP_PU_CONVERSATION);
jifwait = jiffies + hertz;
while (time_before(jiffies, jifwait)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
daa_int_read(j);
daa_set_mode(j, SOP_PU_RESET);
if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
j->flags.pots_correct = 0; /* Should not be line voltage on POTS port. */
LED_SetState(0x4, j);
j->pld_slicw.bits.rly3 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
} else {
j->flags.pots_correct = 1;
LED_SetState(0x8, j);
j->pld_slicw.bits.rly1 = 1;
j->pld_slicw.bits.rly2 = 0;
j->pld_slicw.bits.rly3 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
}
}
j->pld_slicw.bits.rly3 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
daa_set_mode(j, SOP_PU_CONVERSATION);
jifwait = jiffies + hertz;
while (time_before(jiffies, jifwait)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
daa_int_read(j);
daa_set_mode(j, SOP_PU_RESET);
if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
j->pstn_sleeptil = jiffies + (hertz / 4);
j->flags.pstn_present = 1;
} else {
j->flags.pstn_present = 0;
}
if (j->flags.pstn_present) {
if (j->flags.pots_correct) {
LED_SetState(0xA, j);
} else {
LED_SetState(0x6, j);
}
} else {
if (j->flags.pots_correct) {
LED_SetState(0x9, j);
} else {
LED_SetState(0x5, j);
}
}
j->flags.pstncheck = 0; /* Testing */
return j->flags.pstn_present;
}
static int ixj_selfprobe(IXJ *j)
{
unsigned short cmd;
unsigned long jif;
int cnt;
BYTES bytes;
init_waitqueue_head(&j->poll_q);
init_waitqueue_head(&j->read_q);
init_waitqueue_head(&j->write_q);
while(atomic_read(&j->DSPWrite) > 0)
atomic_dec(&j->DSPWrite);
if (ixjdebug & 0x0002)
printk(KERN_INFO "Write IDLE to Software Control Register\n");
ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
return -1;
/* The read values of the SSR should be 0x00 for the IDLE command */
if (j->ssr.low || j->ssr.high)
return -1;
if (ixjdebug & 0x0002)
printk(KERN_INFO "Get Device ID Code\n");
if (ixj_WriteDSPCommand(0x3400, j)) /* Get Device ID Code */
return -1;
j->dsp.low = j->ssr.low;
j->dsp.high = j->ssr.high;
if (ixjdebug & 0x0002)
printk(KERN_INFO "Get Device Version Code\n");
if (ixj_WriteDSPCommand(0x3800, j)) /* Get Device Version Code */
return -1;
j->ver.low = j->ssr.low;
j->ver.high = j->ssr.high;
if (!j->cardtype) {
if (j->dsp.low == 0x21) {
bytes.high = bytes.low = inb_p(j->XILINXbase + 0x02);
outb_p(bytes.low ^ 0xFF, j->XILINXbase + 0x02);
/* Test for Internet LineJACK or Internet PhoneJACK Lite */
bytes.low = inb_p(j->XILINXbase + 0x02);
if (bytes.low == bytes.high) /* Register is read only on */
/* Internet PhoneJack Lite */
{
j->cardtype = QTI_PHONEJACK_LITE;
if (!request_region(j->XILINXbase, 4, "ixj control")) {
printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
return -1;
}
j->pld_slicw.pcib.e1 = 1;
outb_p(j->pld_slicw.byte, j->XILINXbase);
} else {
j->cardtype = QTI_LINEJACK;
if (!request_region(j->XILINXbase, 8, "ixj control")) {
printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
return -1;
}
}
} else if (j->dsp.low == 0x22) {
j->cardtype = QTI_PHONEJACK_PCI;
request_region(j->XILINXbase, 4, "ixj control");
j->pld_slicw.pcib.e1 = 1;
outb_p(j->pld_slicw.byte, j->XILINXbase);
} else
j->cardtype = QTI_PHONEJACK;
} else {
switch (j->cardtype) {
case QTI_PHONEJACK:
if (!j->dsp.low != 0x20) {
j->dsp.high = 0x80;
j->dsp.low = 0x20;
ixj_WriteDSPCommand(0x3800, j);
j->ver.low = j->ssr.low;
j->ver.high = j->ssr.high;
}
break;
case QTI_LINEJACK:
if (!request_region(j->XILINXbase, 8, "ixj control")) {
printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
return -1;
}
break;
case QTI_PHONEJACK_LITE:
case QTI_PHONEJACK_PCI:
if (!request_region(j->XILINXbase, 4, "ixj control")) {
printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
return -1;
}
j->pld_slicw.pcib.e1 = 1;
outb_p(j->pld_slicw.byte, j->XILINXbase);
break;
case QTI_PHONECARD:
break;
}
}
if (j->dsp.low == 0x20 || j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
if (ixjdebug & 0x0002)
printk(KERN_INFO "Write CODEC config to Software Control Register\n");
if (ixj_WriteDSPCommand(0xC462, j)) /* Write CODEC config to Software Control Register */
return -1;
if (ixjdebug & 0x0002)
printk(KERN_INFO "Write CODEC timing to Software Control Register\n");
if (j->cardtype == QTI_PHONEJACK) {
cmd = 0x9FF2;
} else {
cmd = 0x9FF5;
}
if (ixj_WriteDSPCommand(cmd, j)) /* Write CODEC timing to Software Control Register */
return -1;
} else {
if (set_base_frame(j, 30) != 30)
return -1;
if (ixjdebug & 0x0002)
printk(KERN_INFO "Write CODEC config to Software Control Register\n");
if (j->cardtype == QTI_PHONECARD) {
if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
return -1;
}
if (j->cardtype == QTI_LINEJACK) {
if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
return -1;
if (ixjdebug & 0x0002)
printk(KERN_INFO "Turn on the PLD Clock at 8Khz\n");
j->pld_clock.byte = 0;
outb_p(j->pld_clock.byte, j->XILINXbase + 0x04);
}
}
if (j->dsp.low == 0x20) {
if (ixjdebug & 0x0002)
printk(KERN_INFO "Configure GPIO pins\n");
j->gpio.bytes.high = 0x09;
/* bytes.low = 0xEF; 0xF7 */
j->gpio.bits.gpio1 = 1;
j->gpio.bits.gpio2 = 1;
j->gpio.bits.gpio3 = 0;
j->gpio.bits.gpio4 = 1;
j->gpio.bits.gpio5 = 1;
j->gpio.bits.gpio6 = 1;
j->gpio.bits.gpio7 = 1;
ixj_WriteDSPCommand(j->gpio.word, j); /* Set GPIO pin directions */
if (ixjdebug & 0x0002)
printk(KERN_INFO "Enable SLIC\n");
j->gpio.bytes.high = 0x0B;
j->gpio.bytes.low = 0x00;
j->gpio.bits.gpio1 = 0;
j->gpio.bits.gpio2 = 1;
j->gpio.bits.gpio5 = 0;
ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring stop signal */
j->port = PORT_POTS;
} else {
if (j->cardtype == QTI_LINEJACK) {
LED_SetState(0x1, j);
jif = jiffies + (hertz / 10);
while (time_before(jiffies, jif)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
LED_SetState(0x2, j);
jif = jiffies + (hertz / 10);
while (time_before(jiffies, jif)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
LED_SetState(0x4, j);
jif = jiffies + (hertz / 10);
while (time_before(jiffies, jif)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
LED_SetState(0x8, j);
jif = jiffies + (hertz / 10);
while (time_before(jiffies, jif)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
LED_SetState(0x0, j);
daa_get_version(j);
if (ixjdebug & 0x0002)
printk("Loading DAA Coefficients\n");
DAA_Coeff_US(j);
if (!ixj_daa_write(j)) {
printk("DAA write failed on board %d\n", j->board);
return -1;
}
if(!ixj_daa_cid_reset(j)) {
printk("DAA CID reset failed on board %d\n", j->board);
return -1;
}
j->flags.pots_correct = 0;
j->flags.pstn_present = 0;
ixj_linetest(j);
if (j->flags.pots_correct) {
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->pld_slicw.bits.rly1 = 1;
j->pld_slicw.bits.spken = 1;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
/* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
j->port = PORT_POTS;
}
ixj_set_port(j, PORT_PSTN);
ixj_set_pots(j, 1);
if (ixjdebug & 0x0002)
printk(KERN_INFO "Enable Mixer\n");
ixj_mixer(0x0000, j); /*Master Volume Left unmute 0db */
ixj_mixer(0x0100, j); /*Master Volume Right unmute 0db */
ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
ixj_mixer(0x0480, j); /*FM Left mute */
ixj_mixer(0x0580, j); /*FM Right mute */
ixj_mixer(0x0680, j); /*CD Left mute */
ixj_mixer(0x0780, j); /*CD Right mute */
ixj_mixer(0x0880, j); /*Line Left mute */
ixj_mixer(0x0980, j); /*Line Right mute */
ixj_mixer(0x0A80, j); /*Aux left mute */
ixj_mixer(0x0B80, j); /*Aux right mute */
ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
ixj_mixer(0x0D80, j); /*Mono2 mute */
ixj_mixer(0x0E80, j); /*Mic mute */
ixj_mixer(0x0F00, j); /*Mono Out Volume unmute 0db */
ixj_mixer(0x1000, j); /*Voice Left and Right out only */
ixj_mixer(0x110C, j);
ixj_mixer(0x1200, j); /*Mono1 switch on mixer left */
ixj_mixer(0x1401, j);
ixj_mixer(0x1300, j); /*Mono1 switch on mixer right */
ixj_mixer(0x1501, j);
ixj_mixer(0x1700, j); /*Clock select */
ixj_mixer(0x1800, j); /*ADC input from mixer */
ixj_mixer(0x1901, j); /*Mic gain 30db */
if (ixjdebug & 0x0002)
printk(KERN_INFO "Setting Default US Ring Cadence Detection\n");
j->cadence_f[4].state = 0;
j->cadence_f[4].on1 = 0; /*Cadence Filter 4 is used for PSTN ring cadence */
j->cadence_f[4].off1 = 0;
j->cadence_f[4].on2 = 0;
j->cadence_f[4].off2 = 0;
j->cadence_f[4].on3 = 0;
j->cadence_f[4].off3 = 0; /* These should represent standard US ring pulse. */
j->pstn_last_rmr = jiffies;
} else {
if (j->cardtype == QTI_PHONECARD) {
ixj_WriteDSPCommand(0xCF07, j);
ixj_WriteDSPCommand(0x00B0, j);
ixj_set_port(j, PORT_SPEAKER);
} else {
ixj_set_port(j, PORT_POTS);
SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
/* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
}
}
}
j->intercom = -1;
j->framesread = j->frameswritten = 0;
j->read_wait = j->write_wait = 0;
j->rxreadycheck = j->txreadycheck = 0;
/* initialise the DTMF prescale to a sensible value */
if (j->cardtype == QTI_LINEJACK) {
set_dtmf_prescale(j, 0x10);
} else {
set_dtmf_prescale(j, 0x40);
}
set_play_volume(j, 0x100);
set_rec_volume(j, 0x100);
if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
return -1;
/* The read values of the SSR should be 0x00 for the IDLE command */
if (j->ssr.low || j->ssr.high)
return -1;
if (ixjdebug & 0x0002)
printk(KERN_INFO "Enable Line Monitor\n");
if (ixjdebug & 0x0002)
printk(KERN_INFO "Set Line Monitor to Asyncronous Mode\n");
if (ixj_WriteDSPCommand(0x7E01, j)) /* Asynchronous Line Monitor */
return -1;
if (ixjdebug & 0x002)
printk(KERN_INFO "Enable DTMF Detectors\n");
if (ixj_WriteDSPCommand(0x5151, j)) /* Enable DTMF detection */
return -1;
if (ixj_WriteDSPCommand(0x6E01, j)) /* Set Asyncronous Tone Generation */
return -1;
set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
j->ex.bits.dtmf_ready = 0;
j->dtmf_state = 0;
j->dtmf_wp = j->dtmf_rp = 0;
j->rec_mode = j->play_mode = -1;
j->flags.ringing = 0;
j->maxrings = MAXRINGS;
j->ring_cadence = USA_RING_CADENCE;
j->drybuffer = 0;
j->winktime = 320;
j->flags.dtmf_oob = 0;
for (cnt = 0; cnt < 4; cnt++)
j->cadence_f[cnt].enable = 0;
/* must be a device on the specified address */
ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
/* Set up the default signals for events */
for (cnt = 0; cnt < 35; cnt++)
j->ixj_signals[cnt] = SIGIO;
/* Set the excetion signal enable flags */
j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
j->ex_sig.bits.f3 = j->ex_sig.bits.fc0 = j->ex_sig.bits.fc1 = j->ex_sig.bits.fc2 = j->ex_sig.bits.fc3 = 1;
#ifdef IXJ_DYN_ALLOC
j->fskdata = NULL;
#endif
j->fskdcnt = 0;
j->cidcw_wait = 0;
/* Register with the Telephony for Linux subsystem */
j->p.f_op = &ixj_fops;
j->p.open = ixj_open;
j->p.board = j->board;
phone_register_device(&j->p, PHONE_UNIT_ANY);
ixj_init_timer(j);
ixj_add_timer(j);
return 0;
}
/*
* Exported service for pcmcia card handling
*/
IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)
{
IXJ *j = ixj_alloc();
j->board = 0;
j->DSPbase = dsp;
j->XILINXbase = xilinx;
j->cardtype = QTI_PHONECARD;
ixj_selfprobe(j);
return j;
}
EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */
static int ixj_get_status_proc(char *buf)
{
int len;
int cnt;
IXJ *j;
len = 0;
len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER);
len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ));
len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS));
len += sprintf(buf + len, "\nUsing old telephony API");
len += sprintf(buf + len, "\nDebug Level %d\n", ixjdebug);
for (cnt = 0; cnt < IXJMAX; cnt++) {
j = get_ixj(cnt);
if(j==NULL)
continue;
if (j->DSPbase) {
len += sprintf(buf + len, "\nCard Num %d", cnt);
len += sprintf(buf + len, "\nDSP Base Address 0x%4.4x", j->DSPbase);
if (j->cardtype != QTI_PHONEJACK)
len += sprintf(buf + len, "\nXILINX Base Address 0x%4.4x", j->XILINXbase);
len += sprintf(buf + len, "\nDSP Type %2.2x%2.2x", j->dsp.high, j->dsp.low);
len += sprintf(buf + len, "\nDSP Version %2.2x.%2.2x", j->ver.high, j->ver.low);
len += sprintf(buf + len, "\nSerial Number %8.8x", j->serial);
switch (j->cardtype) {
case (QTI_PHONEJACK):
len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK");
break;
case (QTI_LINEJACK):
len += sprintf(buf + len, "\nCard Type = Internet LineJACK");
if (j->flags.g729_loaded)
len += sprintf(buf + len, " w/G.729 A/B");
len += sprintf(buf + len, " Country = %d", j->daa_country);
break;
case (QTI_PHONEJACK_LITE):
len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK Lite");
if (j->flags.g729_loaded)
len += sprintf(buf + len, " w/G.729 A/B");
break;
case (QTI_PHONEJACK_PCI):
len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK PCI");
if (j->flags.g729_loaded)
len += sprintf(buf + len, " w/G.729 A/B");
break;
case (QTI_PHONECARD):
len += sprintf(buf + len, "\nCard Type = Internet PhoneCARD");
if (j->flags.g729_loaded)
len += sprintf(buf + len, " w/G.729 A/B");
len += sprintf(buf + len, "\nSmart Cable %spresent", j->pccr1.bits.drf ? "not " : "");
if (!j->pccr1.bits.drf)
len += sprintf(buf + len, "\nSmart Cable type %d", j->flags.pcmciasct);
len += sprintf(buf + len, "\nSmart Cable state %d", j->flags.pcmciastate);
break;
default:
len += sprintf(buf + len, "\nCard Type = %d", j->cardtype);
break;
}
len += sprintf(buf + len, "\nReaders %d", j->readers);
len += sprintf(buf + len, "\nWriters %d", j->writers);
add_caps(j);
len += sprintf(buf + len, "\nCapabilities %d", j->caps);
if (j->dsp.low != 0x20)
len += sprintf(buf + len, "\nDSP Processor load %d", j->proc_load);
if (j->flags.cidsent)
len += sprintf(buf + len, "\nCaller ID data sent");
else
len += sprintf(buf + len, "\nCaller ID data not sent");
len += sprintf(buf + len, "\nPlay CODEC ");
switch (j->play_codec) {
case G723_63:
len += sprintf(buf + len, "G.723.1 6.3");
break;
case G723_53:
len += sprintf(buf + len, "G.723.1 5.3");
break;
case TS85:
len += sprintf(buf + len, "TrueSpeech 8.5");
break;
case TS48:
len += sprintf(buf + len, "TrueSpeech 4.8");
break;
case TS41:
len += sprintf(buf + len, "TrueSpeech 4.1");
break;
case G728:
len += sprintf(buf + len, "G.728");
break;
case G729:
len += sprintf(buf + len, "G.729");
break;
case G729B:
len += sprintf(buf + len, "G.729B");
break;
case ULAW:
len += sprintf(buf + len, "uLaw");
break;
case ALAW:
len += sprintf(buf + len, "aLaw");
break;
case LINEAR16:
len += sprintf(buf + len, "16 bit Linear");
break;
case LINEAR8:
len += sprintf(buf + len, "8 bit Linear");
break;
case WSS:
len += sprintf(buf + len, "Windows Sound System");
break;
default:
len += sprintf(buf + len, "NO CODEC CHOSEN");
break;
}
len += sprintf(buf + len, "\nRecord CODEC ");
switch (j->rec_codec) {
case G723_63:
len += sprintf(buf + len, "G.723.1 6.3");
break;
case G723_53:
len += sprintf(buf + len, "G.723.1 5.3");
break;
case TS85:
len += sprintf(buf + len, "TrueSpeech 8.5");
break;
case TS48:
len += sprintf(buf + len, "TrueSpeech 4.8");
break;
case TS41:
len += sprintf(buf + len, "TrueSpeech 4.1");
break;
case G728:
len += sprintf(buf + len, "G.728");
break;
case G729:
len += sprintf(buf + len, "G.729");
break;
case G729B:
len += sprintf(buf + len, "G.729B");
break;
case ULAW:
len += sprintf(buf + len, "uLaw");
break;
case ALAW:
len += sprintf(buf + len, "aLaw");
break;
case LINEAR16:
len += sprintf(buf + len, "16 bit Linear");
break;
case LINEAR8:
len += sprintf(buf + len, "8 bit Linear");
break;
case WSS:
len += sprintf(buf + len, "Windows Sound System");
break;
default:
len += sprintf(buf + len, "NO CODEC CHOSEN");
break;
}
len += sprintf(buf + len, "\nAEC ");
switch (j->aec_level) {
case AEC_OFF:
len += sprintf(buf + len, "Off");
break;
case AEC_LOW:
len += sprintf(buf + len, "Low");
break;
case AEC_MED:
len += sprintf(buf + len, "Med");
break;
case AEC_HIGH:
len += sprintf(buf + len, "High");
break;
case AEC_AUTO:
len += sprintf(buf + len, "Auto");
break;
case AEC_AGC:
len += sprintf(buf + len, "AEC/AGC");
break;
default:
len += sprintf(buf + len, "unknown(%i)", j->aec_level);
break;
}
len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j));
len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j));
len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j));
len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */
if (j->cardtype == QTI_LINEJACK) {
len += sprintf(buf + len, "\nPOTS Correct %d", j->flags.pots_correct);
len += sprintf(buf + len, "\nPSTN Present %d", j->flags.pstn_present);
len += sprintf(buf + len, "\nPSTN Check %d", j->flags.pstncheck);
len += sprintf(buf + len, "\nPOTS to PSTN %d", j->flags.pots_pstn);
switch (j->daa_mode) {
case SOP_PU_SLEEP:
len += sprintf(buf + len, "\nDAA PSTN On Hook");
break;
case SOP_PU_RINGING:
len += sprintf(buf + len, "\nDAA PSTN Ringing");
len += sprintf(buf + len, "\nRinging state = %d", j->cadence_f[4].state);
break;
case SOP_PU_CONVERSATION:
len += sprintf(buf + len, "\nDAA PSTN Off Hook");
break;
case SOP_PU_PULSEDIALING:
len += sprintf(buf + len, "\nDAA PSTN Pulse Dialing");
break;
}
len += sprintf(buf + len, "\nDAA RMR = %d", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR);
len += sprintf(buf + len, "\nDAA VDD OK = %d", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK);
len += sprintf(buf + len, "\nDAA CR0 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg);
len += sprintf(buf + len, "\nDAA CR1 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg);
len += sprintf(buf + len, "\nDAA CR2 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg);
len += sprintf(buf + len, "\nDAA CR3 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg);
len += sprintf(buf + len, "\nDAA CR4 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg);
len += sprintf(buf + len, "\nDAA CR5 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg);
len += sprintf(buf + len, "\nDAA XR0 = 0x%02x", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg);
len += sprintf(buf + len, "\nDAA ringstop %ld - jiffies %ld", j->pstn_ring_stop, jiffies);
}
switch (j->port) {
case PORT_POTS:
len += sprintf(buf + len, "\nPort POTS");
break;
case PORT_PSTN:
len += sprintf(buf + len, "\nPort PSTN");
break;
case PORT_SPEAKER:
len += sprintf(buf + len, "\nPort SPEAKER/MIC");
break;
case PORT_HANDSET:
len += sprintf(buf + len, "\nPort HANDSET");
break;
}
if (j->dsp.low == 0x21 || j->dsp.low == 0x22) {
len += sprintf(buf + len, "\nSLIC state ");
switch (SLIC_GetState(j)) {
case PLD_SLIC_STATE_OC:
len += sprintf(buf + len, "OC");
break;
case PLD_SLIC_STATE_RINGING:
len += sprintf(buf + len, "RINGING");
break;
case PLD_SLIC_STATE_ACTIVE:
len += sprintf(buf + len, "ACTIVE");
break;
case PLD_SLIC_STATE_OHT: /* On-hook transmit */
len += sprintf(buf + len, "OHT");
break;
case PLD_SLIC_STATE_TIPOPEN:
len += sprintf(buf + len, "TIPOPEN");
break;
case PLD_SLIC_STATE_STANDBY:
len += sprintf(buf + len, "STANDBY");
break;
case PLD_SLIC_STATE_APR: /* Active polarity reversal */
len += sprintf(buf + len, "APR");
break;
case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
len += sprintf(buf + len, "OHTPR");
break;
default:
len += sprintf(buf + len, "%d", SLIC_GetState(j));
break;
}
}
len += sprintf(buf + len, "\nBase Frame %2.2x.%2.2x", j->baseframe.high, j->baseframe.low);
len += sprintf(buf + len, "\nCID Base Frame %2d", j->cid_base_frame_size);
#ifdef PERFMON_STATS
len += sprintf(buf + len, "\nTimer Checks %ld", j->timerchecks);
len += sprintf(buf + len, "\nRX Ready Checks %ld", j->rxreadycheck);
len += sprintf(buf + len, "\nTX Ready Checks %ld", j->txreadycheck);
len += sprintf(buf + len, "\nFrames Read %ld", j->framesread);
len += sprintf(buf + len, "\nFrames Written %ld", j->frameswritten);
len += sprintf(buf + len, "\nDry Buffer %ld", j->drybuffer);
len += sprintf(buf + len, "\nRead Waits %ld", j->read_wait);
len += sprintf(buf + len, "\nWrite Waits %ld", j->write_wait);
len += sprintf(buf + len, "\nStatus Waits %ld", j->statuswait);
len += sprintf(buf + len, "\nStatus Wait Fails %ld", j->statuswaitfail);
len += sprintf(buf + len, "\nPControl Waits %ld", j->pcontrolwait);
len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail);
len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready);
len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail);
#endif
len += sprintf(buf + len, "\n");
}
}
return len;
}
static int ixj_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = ixj_get_status_proc(page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return len;
}
static void cleanup(void)
{
int cnt;
IXJ *j;
for (cnt = 0; cnt < IXJMAX; cnt++) {
j = get_ixj(cnt);
if(j != NULL && j->DSPbase) {
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: Deleting timer for /dev/phone%d\n", cnt);
del_timer(&j->timer);
if (j->cardtype == QTI_LINEJACK) {
j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
outb_p(j->pld_scrw.byte, j->XILINXbase);
j->pld_slicw.bits.rly1 = 0;
j->pld_slicw.bits.rly2 = 0;
j->pld_slicw.bits.rly3 = 0;
outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
LED_SetState(0x0, j);
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
release_region(j->XILINXbase, 8);
} else if (j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
release_region(j->XILINXbase, 4);
}
if (j->read_buffer)
kfree(j->read_buffer);
if (j->write_buffer)
kfree(j->write_buffer);
if (j->dev)
pnp_device_detach(j->dev);
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt);
phone_unregister_device(&j->p);
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt);
release_region(j->DSPbase, 16);
#ifdef IXJ_DYN_ALLOC
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: Freeing memory for /dev/phone%d\n", cnt);
kfree(j);
ixj[cnt] = NULL;
#endif
}
}
if (ixjdebug & 0x0002)
printk(KERN_INFO "IXJ: Removing /proc/ixj\n");
remove_proc_entry ("ixj", NULL);
}
/* Typedefs */
typedef struct {
BYTE length;
DWORD bits;
} DATABLOCK;
static void PCIEE_WriteBit(WORD wEEPROMAddress, BYTE lastLCC, BYTE byData)
{
lastLCC = lastLCC & 0xfb;
lastLCC = lastLCC | (byData ? 4 : 0);
outb(lastLCC, wEEPROMAddress); /*set data out bit as appropriate */
mdelay(1);
lastLCC = lastLCC | 0x01;
outb(lastLCC, wEEPROMAddress); /*SK rising edge */
byData = byData << 1;
lastLCC = lastLCC & 0xfe;
mdelay(1);
outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
}
static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC)
{
mdelay(1);
lastLCC = lastLCC | 0x01;
outb(lastLCC, wEEPROMAddress); /*SK rising edge */
lastLCC = lastLCC & 0xfe;
mdelay(1);
outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
return ((inb(wEEPROMAddress) >> 3) & 1);
}
static BOOL PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult)
{
BYTE lastLCC;
WORD wEEPROMAddress = wAddress + 3;
DWORD i;
BYTE byResult;
*pwResult = 0;
lastLCC = inb(wEEPROMAddress);
lastLCC = lastLCC | 0x02;
lastLCC = lastLCC & 0xfe;
outb(lastLCC, wEEPROMAddress); /* CS hi, SK lo */
mdelay(1); /* delay */
PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0);
for (i = 0; i < 8; i++) {
PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0);
wLoc <<= 1;
}
for (i = 0; i < 16; i++) {
byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC);
*pwResult = (*pwResult << 1) | byResult;
}
mdelay(1); /* another delay */
lastLCC = lastLCC & 0xfd;
outb(lastLCC, wEEPROMAddress); /* negate CS */
return 0;
}
static DWORD PCIEE_GetSerialNumber(WORD wAddress)
{
WORD wLo, wHi;
if (PCIEE_ReadWord(wAddress, 62, &wLo))
return 0;
if (PCIEE_ReadWord(wAddress, 63, &wHi))
return 0;
return (((DWORD) wHi << 16) | wLo);
}
static int dspio[IXJMAX + 1] =
{
0,
};
static int xio[IXJMAX + 1] =
{
0,
};
module_param_array(dspio, int, NULL, 0);
module_param_array(xio, int, NULL, 0);
MODULE_DESCRIPTION("Quicknet VoIP Telephony card module - www.quicknet.net");
MODULE_AUTHOR("Ed Okerson <eokerson@quicknet.net>");
MODULE_LICENSE("GPL");
static void __exit ixj_exit(void)
{
cleanup();
}
static IXJ *new_ixj(unsigned long port)
{
IXJ *res;
if (!request_region(port, 16, "ixj DSP")) {
printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", port);
return NULL;
}
res = ixj_alloc();
if (!res) {
release_region(port, 16);
printk(KERN_INFO "ixj: out of memory\n");
return NULL;
}
res->DSPbase = port;
return res;
}
static int __init ixj_probe_isapnp(int *cnt)
{
int probe = 0;
int func = 0x110;
struct pnp_dev *dev = NULL, *old_dev = NULL;
while (1) {
do {
IXJ *j;
int result;
old_dev = dev;
dev = pnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'),
ISAPNP_FUNCTION(func), old_dev);
if (!dev || !dev->card)
break;
result = pnp_device_attach(dev);
if (result < 0) {
printk("pnp attach failed %d \n", result);
break;
}
if (pnp_activate_dev(dev) < 0) {
printk("pnp activate failed (out of resources?)\n");
pnp_device_detach(dev);
return -ENOMEM;
}
if (!pnp_port_valid(dev, 0)) {
pnp_device_detach(dev);
return -ENODEV;
}
j = new_ixj(pnp_port_start(dev, 0));
if (!j)
break;
if (func != 0x110)
j->XILINXbase = pnp_port_start(dev, 1); /* get real port */
switch (func) {
case (0x110):
j->cardtype = QTI_PHONEJACK;
break;
case (0x310):
j->cardtype = QTI_LINEJACK;
break;
case (0x410):
j->cardtype = QTI_PHONEJACK_LITE;
break;
}
j->board = *cnt;
probe = ixj_selfprobe(j);
if(!probe) {
j->serial = dev->card->serial;
j->dev = dev;
switch (func) {
case 0x110:
printk(KERN_INFO "ixj: found Internet PhoneJACK at 0x%x\n", j->DSPbase);
break;
case 0x310:
printk(KERN_INFO "ixj: found Internet LineJACK at 0x%x\n", j->DSPbase);
break;
case 0x410:
printk(KERN_INFO "ixj: found Internet PhoneJACK Lite at 0x%x\n", j->DSPbase);
break;
}
}
++*cnt;
} while (dev);
if (func == 0x410)
break;
if (func == 0x310)
func = 0x410;
if (func == 0x110)
func = 0x310;
dev = NULL;
}
return probe;
}
static int __init ixj_probe_isa(int *cnt)
{
int i, probe;
/* Use passed parameters for older kernels without PnP */
for (i = 0; i < IXJMAX; i++) {
if (dspio[i]) {
IXJ *j = new_ixj(dspio[i]);
if (!j)
break;
j->XILINXbase = xio[i];
j->cardtype = 0;
j->board = *cnt;
probe = ixj_selfprobe(j);
j->dev = NULL;
++*cnt;
}
}
return 0;
}
static int __init ixj_probe_pci(int *cnt)
{
struct pci_dev *pci = NULL;
int i, probe = 0;
IXJ *j = NULL;
for (i = 0; i < IXJMAX - *cnt; i++) {
pci = pci_find_device(0x15E2, 0x0500, pci);
if (!pci)
break;
if (pci_enable_device(pci))
break;
j = new_ixj(pci_resource_start(pci, 0));
if (!j)
break;
j->serial = (PCIEE_GetSerialNumber)pci_resource_start(pci, 2);
j->XILINXbase = j->DSPbase + 0x10;
j->cardtype = QTI_PHONEJACK_PCI;
j->board = *cnt;
probe = ixj_selfprobe(j);
if (!probe)
printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase);
++*cnt;
}
return probe;
}
static int __init ixj_init(void)
{
int cnt = 0;
int probe = 0;
cnt = 0;
/* These might be no-ops, see above. */
if ((probe = ixj_probe_isapnp(&cnt)) < 0) {
return probe;
}
if ((probe = ixj_probe_isa(&cnt)) < 0) {
return probe;
}
if ((probe = ixj_probe_pci(&cnt)) < 0) {
return probe;
}
printk(KERN_INFO "ixj driver initialized.\n");
create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL);
return probe;
}
module_init(ixj_init);
module_exit(ixj_exit);
static void DAA_Coeff_US(IXJ *j)
{
int i;
j->daa_country = DAA_US;
/*----------------------------------------------- */
/* CAO */
for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
}
/* Bytes for IM-filter part 1 (04): 0E,32,E2,2F,C2,5A,C0,00 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x03;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0x4B;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x5D;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xCD;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x24;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xC5;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
/* Bytes for IM-filter part 2 (05): 72,85,00,0E,2B,3A,D0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x71;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x1A;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
/* Bytes for FRX-filter (08): 03,8F,48,F2,8F,48,70,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x05;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xA3;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x72;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x3F;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x3B;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
/* Bytes for FRR-filter (07): 04,8F,38,7F,9B,EA,B0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x05;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x3E;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
/* Bytes for AX-filter (0A): 16,55,DD,CA */
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x41;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
/* Bytes for AR-filter (09): 52,D3,11,42 */
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
/* Bytes for TH-filter part 1 (00): 00,42,48,81,B3,80,00,98 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA5;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
/* Bytes for TH-filter part 2 (01): 02,F2,33,A0,68,AB,8A,AD */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xA2;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2B;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAB;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xCC;
/* Bytes for TH-filter part 3 (02): 00,88,DA,54,A4,BA,2D,BB */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xD2;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x24;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xA9;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x3B;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xA6;
/* ; (10K, 0.68uF) */
/* */
/* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
/* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
/* Levelmetering Ringing (0D):B2,45,0F,8E */
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
/* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1C; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0xB3; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0xAB; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xAB; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x54; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */
/* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBB; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x2A; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7D; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD4; */
/* */
/* Levelmetering Ringing (0D):B2,45,0F,8E */
/* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; */
/* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x05; */
/* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; */
/* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; */
/* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
/* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
/* */
/* ;CR Registers */
/* Config. Reg. 0 (filters) (cr0):FE ; CLK gen. by crystal */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
/* Config. Reg. 1 (dialing) (cr1):05 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
/* Config. Reg. 2 (caller ID) (cr2):04 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
/* Config. Reg. 3 (testloops) (cr3):03 ; SEL Bit==0, HP-disabled */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
/* Config. Reg. 4 (analog gain) (cr4):02 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
/* Config. Reg. 5 (Version) (cr5):02 */
/* Config. Reg. 6 (Reserved) (cr6):00 */
/* Config. Reg. 7 (Reserved) (cr7):00 */
/* */
/* ;xr Registers */
/* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
/* Ext. Reg. 1 (Interrupt enable) (xr1):3C Cadence, RING, Caller ID, VDD_OK */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x3C;
/* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
/* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off == 1 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x3B; /*0x32; */
/* Ext. Reg. 4 (Cadence) (xr4):00 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
/* Ext. Reg. 5 (Ring timer) (xr5):22 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
/* Ext. Reg. 6 (Power State) (xr6):00 */
j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
/* Ext. Reg. 7 (Vdd) (xr7):40 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
/* */
/* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
/* 12,33,5A,C3 ; 770 Hz */
/* 13,3C,5B,32 ; 852 Hz */
/* 1D,1B,5C,CC ; 941 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
/* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
/* EC,1D,52,22 ; 1336 Hz */
/* AA,AC,51,D2 ; 1477 Hz */
/* 9B,3B,51,25 ; 1633 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
}
static void DAA_Coeff_UK(IXJ *j)
{
int i;
j->daa_country = DAA_UK;
/*----------------------------------------------- */
/* CAO */
for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
}
/* Bytes for IM-filter part 1 (04): 00,C2,BB,A8,CB,81,A0,00 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xC2;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xA8;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xCB;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
/* Bytes for IM-filter part 2 (05): 40,00,00,0A,A4,33,E0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x40;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xA4;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
/* Bytes for FRX-filter (08): 07,9B,ED,24,B2,A2,A0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9B;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xED;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x24;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0xB2;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0xA2;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xA0;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
/* Bytes for FRR-filter (07): 0F,92,F2,B2,87,D2,30,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x92;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF2;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0xB2;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xD2;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x30;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
/* Bytes for AX-filter (0A): 1B,A5,DD,CA */
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x1B;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xA5;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
/* Bytes for AR-filter (09): E2,27,10,D6 */
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x27;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
/* Bytes for TH-filter part 1 (00): 80,2D,38,8B,D0,00,00,98 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x2D;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x38;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x8B;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xD0;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
/* Bytes for TH-filter part 2 (01): 02,5A,53,F0,0B,5F,84,D4 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x5A;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x53;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xF0;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x0B;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5F;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x84;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xD4;
/* Bytes for TH-filter part 3 (02): 00,88,6A,A4,8F,52,F5,32 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x6A;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA4;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x8F;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xF5;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x32;
/* ; idle */
/* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
/* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
/* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V less possible? */
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
/* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
/* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
/* ;CR Registers */
/* Config. Reg. 0 (filters) (cr0):FF */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
/* Config. Reg. 1 (dialing) (cr1):05 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
/* Config. Reg. 2 (caller ID) (cr2):04 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
/* Config. Reg. 3 (testloops) (cr3):00 ; */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
/* Config. Reg. 4 (analog gain) (cr4):02 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
/* Config. Reg. 5 (Version) (cr5):02 */
/* Config. Reg. 6 (Reserved) (cr6):00 */
/* Config. Reg. 7 (Reserved) (cr7):00 */
/* ;xr Registers */
/* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
/* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
/* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
/* Ext. Reg. 3 (DC Char) (xr3):36 ; */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
/* Ext. Reg. 4 (Cadence) (xr4):00 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
/* Ext. Reg. 5 (Ring timer) (xr5):22 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
/* Ext. Reg. 6 (Power State) (xr6):00 */
j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
/* Ext. Reg. 7 (Vdd) (xr7):46 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
/* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
/* 12,33,5A,C3 ; 770 Hz */
/* 13,3C,5B,32 ; 852 Hz */
/* 1D,1B,5C,CC ; 941 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
/* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
/* EC,1D,52,22 ; 1336 Hz */
/* AA,AC,51,D2 ; 1477 Hz */
/* 9B,3B,51,25 ; 1633 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
}
static void DAA_Coeff_France(IXJ *j)
{
int i;
j->daa_country = DAA_FRANCE;
/*----------------------------------------------- */
/* CAO */
for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
}
/* Bytes for IM-filter part 1 (04): 02,A2,43,2C,22,AF,A0,00 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA2;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x43;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2C;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xAF;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
/* Bytes for IM-filter part 2 (05): 67,CE,00,0C,22,33,E0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x67;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xCE;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x2C;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
/* Bytes for FRX-filter (08): 07,9A,28,F6,23,4A,B0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9A;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x28;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0xF6;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x23;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x4A;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xB0;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
/* Bytes for FRR-filter (07): 03,8F,F9,2F,9E,FA,20,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9E;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xFA;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
/* Bytes for AX-filter (0A): 16,B5,DD,CA */
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x16;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
/* Bytes for AR-filter (09): 52,C7,10,D6 */
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
/* Bytes for TH-filter part 1 (00): 00,42,48,81,A6,80,00,98 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA6;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
/* Bytes for TH-filter part 2 (01): 02,AC,2A,30,78,AC,8A,2C */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAC;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x30;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x78;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAC;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x8A;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x2C;
/* Bytes for TH-filter part 3 (02): 00,88,DA,A5,22,BA,2C,45 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA5;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x2C;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x45;
/* ; idle */
/* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
/* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
/* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
/* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
/* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
/* ;CR Registers */
/* Config. Reg. 0 (filters) (cr0):FF */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
/* Config. Reg. 1 (dialing) (cr1):05 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
/* Config. Reg. 2 (caller ID) (cr2):04 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
/* Config. Reg. 3 (testloops) (cr3):00 ; */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
/* Config. Reg. 4 (analog gain) (cr4):02 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
/* Config. Reg. 5 (Version) (cr5):02 */
/* Config. Reg. 6 (Reserved) (cr6):00 */
/* Config. Reg. 7 (Reserved) (cr7):00 */
/* ;xr Registers */
/* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
/* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
/* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
/* Ext. Reg. 3 (DC Char) (xr3):36 ; */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
/* Ext. Reg. 4 (Cadence) (xr4):00 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
/* Ext. Reg. 5 (Ring timer) (xr5):22 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
/* Ext. Reg. 6 (Power State) (xr6):00 */
j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
/* Ext. Reg. 7 (Vdd) (xr7):46 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
/* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
/* 12,33,5A,C3 ; 770 Hz */
/* 13,3C,5B,32 ; 852 Hz */
/* 1D,1B,5C,CC ; 941 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
/* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
/* EC,1D,52,22 ; 1336 Hz */
/* AA,AC,51,D2 ; 1477 Hz */
/* 9B,3B,51,25 ; 1633 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
}
static void DAA_Coeff_Germany(IXJ *j)
{
int i;
j->daa_country = DAA_GERMANY;
/*----------------------------------------------- */
/* CAO */
for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
}
/* Bytes for IM-filter part 1 (04): 00,CE,BB,B8,D2,81,B0,00 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xCE;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xB8;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xD2;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xB0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
/* Bytes for IM-filter part 2 (05): 45,8F,00,0C,D2,3A,D0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x45;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x8F;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0C;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xD2;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x3A;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xD0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
/* Bytes for FRX-filter (08): 07,AA,E2,34,24,89,20,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xAA;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x24;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x89;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x20;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
/* Bytes for FRR-filter (07): 02,87,FA,37,9A,CA,B0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xFA;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x37;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9A;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
/* Bytes for AX-filter (0A): 72,D5,DD,CA */
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x72;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xD5;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
/* Bytes for AR-filter (09): 72,42,13,4B */
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x72;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x42;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x13;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0x4B;
/* Bytes for TH-filter part 1 (00): 80,52,48,81,AD,80,00,98 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAD;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
/* Bytes for TH-filter part 2 (01): 02,42,5A,20,E8,1A,81,27 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x42;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x5A;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x1A;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x27;
/* Bytes for TH-filter part 3 (02): 00,88,63,26,BD,4B,A3,C2 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x63;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x26;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBD;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x4B;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xA3;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xC2;
/* ; (10K, 0.68uF) */
/* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3B;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x9B;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0xD4;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x1C;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xB3;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
/* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x13;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x42;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0xD4;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x73;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
/* Levelmetering Ringing (0D):B2,45,0F,8E */
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xB2;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
/* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
/* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
/* ;CR Registers */
/* Config. Reg. 0 (filters) (cr0):FF ; all Filters enabled, CLK from ext. source */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
/* Config. Reg. 1 (dialing) (cr1):05 ; Manual Ring, Ring metering enabled */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
/* Config. Reg. 2 (caller ID) (cr2):04 ; Analog Gain 0dB, FSC internal */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
/* Config. Reg. 3 (testloops) (cr3):00 ; SEL Bit==0, HP-enabled */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
/* Config. Reg. 4 (analog gain) (cr4):02 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
/* Config. Reg. 5 (Version) (cr5):02 */
/* Config. Reg. 6 (Reserved) (cr6):00 */
/* Config. Reg. 7 (Reserved) (cr7):00 */
/* ;xr Registers */
/* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
/* Ext. Reg. 1 (Interrupt enable) (xr1):1C ; Ring, CID, VDDOK Interrupts enabled */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
/* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
/* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off==1, U0=3.5V, R=200Ohm */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x32;
/* Ext. Reg. 4 (Cadence) (xr4):00 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
/* Ext. Reg. 5 (Ring timer) (xr5):22 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
/* Ext. Reg. 6 (Power State) (xr6):00 */
j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
/* Ext. Reg. 7 (Vdd) (xr7):40 ; VDD=4.25 V */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
/* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
/* 12,33,5A,C3 ; 770 Hz */
/* 13,3C,5B,32 ; 852 Hz */
/* 1D,1B,5C,CC ; 941 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
/* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
/* EC,1D,52,22 ; 1336 Hz */
/* AA,AC,51,D2 ; 1477 Hz */
/* 9B,3B,51,25 ; 1633 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
}
static void DAA_Coeff_Australia(IXJ *j)
{
int i;
j->daa_country = DAA_AUSTRALIA;
/*----------------------------------------------- */
/* CAO */
for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
}
/* Bytes for IM-filter part 1 (04): 00,A3,AA,28,B3,82,D0,00 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA3;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xAA;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x28;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xB3;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x82;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xD0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
/* Bytes for IM-filter part 2 (05): 70,96,00,09,32,6B,C0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x70;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x96;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x09;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x6B;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xC0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
/* Bytes for FRX-filter (08): 07,96,E2,34,32,9B,30,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x96;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x9B;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
/* Bytes for FRR-filter (07): 0F,9A,E9,2F,22,CC,A0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x9A;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xE9;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCC;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xA0;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
/* Bytes for AX-filter (0A): CB,45,DD,CA */
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0xCB;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0x45;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
/* Bytes for AR-filter (09): 1B,67,10,D6 */
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x1B;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x67;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
/* Bytes for TH-filter part 1 (00): 80,52,48,81,AF,80,00,98 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAF;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
/* Bytes for TH-filter part 2 (01): 02,DB,52,B0,38,01,82,AC */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xDB;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x38;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x01;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x82;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xAC;
/* Bytes for TH-filter part 3 (02): 00,88,4A,3E,2C,3B,24,46 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x4A;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x3E;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x2C;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x3B;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x24;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x46;
/* ; idle */
/* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
/* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
/* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
/* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
/* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
/* ;CR Registers */
/* Config. Reg. 0 (filters) (cr0):FF */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
/* Config. Reg. 1 (dialing) (cr1):05 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
/* Config. Reg. 2 (caller ID) (cr2):04 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
/* Config. Reg. 3 (testloops) (cr3):00 ; */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
/* Config. Reg. 4 (analog gain) (cr4):02 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
/* Config. Reg. 5 (Version) (cr5):02 */
/* Config. Reg. 6 (Reserved) (cr6):00 */
/* Config. Reg. 7 (Reserved) (cr7):00 */
/* ;xr Registers */
/* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
/* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
/* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
/* Ext. Reg. 3 (DC Char) (xr3):2B ; */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x2B;
/* Ext. Reg. 4 (Cadence) (xr4):00 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
/* Ext. Reg. 5 (Ring timer) (xr5):22 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
/* Ext. Reg. 6 (Power State) (xr6):00 */
j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
/* Ext. Reg. 7 (Vdd) (xr7):40 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
/* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
/* 12,33,5A,C3 ; 770 Hz */
/* 13,3C,5B,32 ; 852 Hz */
/* 1D,1B,5C,CC ; 941 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
/* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
/* EC,1D,52,22 ; 1336 Hz */
/* AA,AC,51,D2 ; 1477 Hz */
/* 9B,3B,51,25 ; 1633 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
}
static void DAA_Coeff_Japan(IXJ *j)
{
int i;
j->daa_country = DAA_JAPAN;
/*----------------------------------------------- */
/* CAO */
for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
}
/* Bytes for IM-filter part 1 (04): 06,BD,E2,2D,BA,F9,A0,00 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x06;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xBD;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xE2;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2D;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xF9;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
/* Bytes for IM-filter part 2 (05): 6F,F7,00,0E,34,33,E0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x6F;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xF7;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0E;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x34;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
/* Bytes for FRX-filter (08): 02,8F,68,77,9C,58,F0,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x8F;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x68;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x77;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x9C;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x58;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xF0;
j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
/* Bytes for FRR-filter (07): 03,8F,38,73,87,EA,20,08 */
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0x38;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x73;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xEA;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
/* Bytes for AX-filter (0A): 51,C5,DD,CA */
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x51;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xC5;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
/* Bytes for AR-filter (09): 25,A7,10,D6 */
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xA7;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
/* Bytes for TH-filter part 1 (00): 00,42,48,81,AE,80,00,98 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAE;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
/* Bytes for TH-filter part 2 (01): 02,AB,2A,20,99,5B,89,28 */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAB;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5B;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x89;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x28;
/* Bytes for TH-filter part 3 (02): 00,88,DA,25,34,C5,4C,BA */
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x25;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x34;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xC5;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x4C;
j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xBA;
/* ; idle */
/* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
/* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
/* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V ????????? */
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
/* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
/* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
/* ;CR Registers */
/* Config. Reg. 0 (filters) (cr0):FF */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
/* Config. Reg. 1 (dialing) (cr1):05 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
/* Config. Reg. 2 (caller ID) (cr2):04 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
/* Config. Reg. 3 (testloops) (cr3):00 ; */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
/* Config. Reg. 4 (analog gain) (cr4):02 */
j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
/* Config. Reg. 5 (Version) (cr5):02 */
/* Config. Reg. 6 (Reserved) (cr6):00 */
/* Config. Reg. 7 (Reserved) (cr7):00 */
/* ;xr Registers */
/* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
/* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
/* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
/* Ext. Reg. 3 (DC Char) (xr3):22 ; */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x22;
/* Ext. Reg. 4 (Cadence) (xr4):00 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
/* Ext. Reg. 5 (Ring timer) (xr5):22 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
/* Ext. Reg. 6 (Power State) (xr6):00 */
j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
/* Ext. Reg. 7 (Vdd) (xr7):40 */
j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
/* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
/* 12,33,5A,C3 ; 770 Hz */
/* 13,3C,5B,32 ; 852 Hz */
/* 1D,1B,5C,CC ; 941 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
/* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
/* EC,1D,52,22 ; 1336 Hz */
/* AA,AC,51,D2 ; 1477 Hz */
/* 9B,3B,51,25 ; 1633 Hz */
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
}
static s16 tone_table[][19] =
{
{ /* f20_50[] 11 */
32538, /* A1 = 1.985962 */
-32325, /* A2 = -0.986511 */
-343, /* B2 = -0.010493 */
0, /* B1 = 0 */
343, /* B0 = 0.010493 */
32619, /* A1 = 1.990906 */
-32520, /* A2 = -0.992462 */
19179, /* B2 = 0.585327 */
-19178, /* B1 = -1.170593 */
19179, /* B0 = 0.585327 */
32723, /* A1 = 1.997314 */
-32686, /* A2 = -0.997528 */
9973, /* B2 = 0.304352 */
-9955, /* B1 = -0.607605 */
9973, /* B0 = 0.304352 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f133_200[] 12 */
32072, /* A1 = 1.95752 */
-31896, /* A2 = -0.973419 */
-435, /* B2 = -0.013294 */
0, /* B1 = 0 */
435, /* B0 = 0.013294 */
32188, /* A1 = 1.9646 */
-32400, /* A2 = -0.98877 */
15139, /* B2 = 0.462036 */
-14882, /* B1 = -0.908356 */
15139, /* B0 = 0.462036 */
32473, /* A1 = 1.981995 */
-32524, /* A2 = -0.992584 */
23200, /* B2 = 0.708008 */
-23113, /* B1 = -1.410706 */
23200, /* B0 = 0.708008 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f300 13 */
31769, /* A1 = -1.939026 */
-32584, /* A2 = 0.994385 */
-475, /* B2 = -0.014522 */
0, /* B1 = 0.000000 */
475, /* B0 = 0.014522 */
31789, /* A1 = -1.940247 */
-32679, /* A2 = 0.997284 */
17280, /* B2 = 0.527344 */
-16865, /* B1 = -1.029358 */
17280, /* B0 = 0.527344 */
31841, /* A1 = -1.943481 */
-32681, /* A2 = 0.997345 */
543, /* B2 = 0.016579 */
-525, /* B1 = -0.032097 */
543, /* B0 = 0.016579 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f300_420[] 14 */
30750, /* A1 = 1.876892 */
-31212, /* A2 = -0.952515 */
-804, /* B2 = -0.024541 */
0, /* B1 = 0 */
804, /* B0 = 0.024541 */
30686, /* A1 = 1.872925 */
-32145, /* A2 = -0.980988 */
14747, /* B2 = 0.450043 */
-13703, /* B1 = -0.836395 */
14747, /* B0 = 0.450043 */
31651, /* A1 = 1.931824 */
-32321, /* A2 = -0.986389 */
24425, /* B2 = 0.745422 */
-23914, /* B1 = -1.459595 */
24427, /* B0 = 0.745483 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f330 15 */
31613, /* A1 = -1.929565 */
-32646, /* A2 = 0.996277 */
-185, /* B2 = -0.005657 */
0, /* B1 = 0.000000 */
185, /* B0 = 0.005657 */
31620, /* A1 = -1.929932 */
-32713, /* A2 = 0.998352 */
19253, /* B2 = 0.587585 */
-18566, /* B1 = -1.133179 */
19253, /* B0 = 0.587585 */
31674, /* A1 = -1.933228 */
-32715, /* A2 = 0.998413 */
2575, /* B2 = 0.078590 */
-2495, /* B1 = -0.152283 */
2575, /* B0 = 0.078590 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f300_425[] 16 */
30741, /* A1 = 1.876282 */
-31475, /* A2 = -0.960541 */
-703, /* B2 = -0.021484 */
0, /* B1 = 0 */
703, /* B0 = 0.021484 */
30688, /* A1 = 1.873047 */
-32248, /* A2 = -0.984161 */
14542, /* B2 = 0.443787 */
-13523, /* B1 = -0.825439 */
14542, /* B0 = 0.443817 */
31494, /* A1 = 1.922302 */
-32366, /* A2 = -0.987762 */
21577, /* B2 = 0.658508 */
-21013, /* B1 = -1.282532 */
21577, /* B0 = 0.658508 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f330_440[] 17 */
30627, /* A1 = 1.869324 */
-31338, /* A2 = -0.95636 */
-843, /* B2 = -0.025749 */
0, /* B1 = 0 */
843, /* B0 = 0.025749 */
30550, /* A1 = 1.864685 */
-32221, /* A2 = -0.983337 */
13594, /* B2 = 0.414886 */
-12589, /* B1 = -0.768402 */
13594, /* B0 = 0.414886 */
31488, /* A1 = 1.921936 */
-32358, /* A2 = -0.987518 */
24684, /* B2 = 0.753296 */
-24029, /* B1 = -1.466614 */
24684, /* B0 = 0.753296 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f340 18 */
31546, /* A1 = -1.925476 */
-32646, /* A2 = 0.996277 */
-445, /* B2 = -0.013588 */
0, /* B1 = 0.000000 */
445, /* B0 = 0.013588 */
31551, /* A1 = -1.925781 */
-32713, /* A2 = 0.998352 */
23884, /* B2 = 0.728882 */
-22979, /* B1 = -1.402527 */
23884, /* B0 = 0.728882 */
31606, /* A1 = -1.929138 */
-32715, /* A2 = 0.998413 */
863, /* B2 = 0.026367 */
-835, /* B1 = -0.050985 */
863, /* B0 = 0.026367 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f350_400[] 19 */
31006, /* A1 = 1.892517 */
-32029, /* A2 = -0.977448 */
-461, /* B2 = -0.014096 */
0, /* B1 = 0 */
461, /* B0 = 0.014096 */
30999, /* A1 = 1.892029 */
-32487, /* A2 = -0.991455 */
11325, /* B2 = 0.345612 */
-10682, /* B1 = -0.651978 */
11325, /* B0 = 0.345612 */
31441, /* A1 = 1.919067 */
-32526, /* A2 = -0.992615 */
24324, /* B2 = 0.74231 */
-23535, /* B1 = -1.436523 */
24324, /* B0 = 0.74231 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f350_440[] */
30634, /* A1 = 1.869751 */
-31533, /* A2 = -0.962341 */
-680, /* B2 = -0.020782 */
0, /* B1 = 0 */
680, /* B0 = 0.020782 */
30571, /* A1 = 1.865906 */
-32277, /* A2 = -0.985016 */
12894, /* B2 = 0.393524 */
-11945, /* B1 = -0.729065 */
12894, /* B0 = 0.393524 */
31367, /* A1 = 1.91449 */
-32379, /* A2 = -0.988129 */
23820, /* B2 = 0.726929 */
-23104, /* B1 = -1.410217 */
23820, /* B0 = 0.726929 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f350_450[] */
30552, /* A1 = 1.864807 */
-31434, /* A2 = -0.95929 */
-690, /* B2 = -0.021066 */
0, /* B1 = 0 */
690, /* B0 = 0.021066 */
30472, /* A1 = 1.859924 */
-32248, /* A2 = -0.984161 */
13385, /* B2 = 0.408478 */
-12357, /* B1 = -0.754242 */
13385, /* B0 = 0.408478 */
31358, /* A1 = 1.914001 */
-32366, /* A2 = -0.987732 */
26488, /* B2 = 0.80835 */
-25692, /* B1 = -1.568176 */
26490, /* B0 = 0.808411 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f360 */
31397, /* A1 = -1.916321 */
-32623, /* A2 = 0.995605 */
-117, /* B2 = -0.003598 */
0, /* B1 = 0.000000 */
117, /* B0 = 0.003598 */
31403, /* A1 = -1.916687 */
-32700, /* A2 = 0.997925 */
3388, /* B2 = 0.103401 */
-3240, /* B1 = -0.197784 */
3388, /* B0 = 0.103401 */
31463, /* A1 = -1.920410 */
-32702, /* A2 = 0.997986 */
13346, /* B2 = 0.407288 */
-12863, /* B1 = -0.785126 */
13346, /* B0 = 0.407288 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f380_420[] */
30831, /* A1 = 1.881775 */
-32064, /* A2 = -0.978546 */
-367, /* B2 = -0.01122 */
0, /* B1 = 0 */
367, /* B0 = 0.01122 */
30813, /* A1 = 1.880737 */
-32456, /* A2 = -0.990509 */
11068, /* B2 = 0.337769 */
-10338, /* B1 = -0.631042 */
11068, /* B0 = 0.337769 */
31214, /* A1 = 1.905212 */
-32491, /* A2 = -0.991577 */
16374, /* B2 = 0.499695 */
-15781, /* B1 = -0.963196 */
16374, /* B0 = 0.499695 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f392 */
31152, /* A1 = -1.901428 */
-32613, /* A2 = 0.995300 */
-314, /* B2 = -0.009605 */
0, /* B1 = 0.000000 */
314, /* B0 = 0.009605 */
31156, /* A1 = -1.901672 */
-32694, /* A2 = 0.997742 */
28847, /* B2 = 0.880371 */
-2734, /* B1 = -0.166901 */
28847, /* B0 = 0.880371 */
31225, /* A1 = -1.905823 */
-32696, /* A2 = 0.997803 */
462, /* B2 = 0.014108 */
-442, /* B1 = -0.027019 */
462, /* B0 = 0.014108 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f400_425[] */
30836, /* A1 = 1.882141 */
-32296, /* A2 = -0.985596 */
-324, /* B2 = -0.009903 */
0, /* B1 = 0 */
324, /* B0 = 0.009903 */
30825, /* A1 = 1.881409 */
-32570, /* A2 = -0.993958 */
16847, /* B2 = 0.51416 */
-15792, /* B1 = -0.963898 */
16847, /* B0 = 0.51416 */
31106, /* A1 = 1.89856 */
-32584, /* A2 = -0.994415 */
9579, /* B2 = 0.292328 */
-9164, /* B1 = -0.559357 */
9579, /* B0 = 0.292328 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f400_440[] */
30702, /* A1 = 1.873962 */
-32134, /* A2 = -0.980682 */
-517, /* B2 = -0.015793 */
0, /* B1 = 0 */
517, /* B0 = 0.015793 */
30676, /* A1 = 1.872375 */
-32520, /* A2 = -0.992462 */
8144, /* B2 = 0.24855 */
-7596, /* B1 = -0.463684 */
8144, /* B0 = 0.24855 */
31084, /* A1 = 1.897217 */
-32547, /* A2 = -0.993256 */
22713, /* B2 = 0.693176 */
-21734, /* B1 = -1.326599 */
22713, /* B0 = 0.693176 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f400_450[] */
30613, /* A1 = 1.86853 */
-32031, /* A2 = -0.977509 */
-618, /* B2 = -0.018866 */
0, /* B1 = 0 */
618, /* B0 = 0.018866 */
30577, /* A1 = 1.866272 */
-32491, /* A2 = -0.991577 */
9612, /* B2 = 0.293335 */
-8935, /* B1 = -0.54541 */
9612, /* B0 = 0.293335 */
31071, /* A1 = 1.896484 */
-32524, /* A2 = -0.992584 */
21596, /* B2 = 0.659058 */
-20667, /* B1 = -1.261414 */
21596, /* B0 = 0.659058 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f420 */
30914, /* A1 = -1.886841 */
-32584, /* A2 = 0.994385 */
-426, /* B2 = -0.013020 */
0, /* B1 = 0.000000 */
426, /* B0 = 0.013020 */
30914, /* A1 = -1.886841 */
-32679, /* A2 = 0.997314 */
17520, /* B2 = 0.534668 */
-16471, /* B1 = -1.005310 */
17520, /* B0 = 0.534668 */
31004, /* A1 = -1.892334 */
-32683, /* A2 = 0.997406 */
819, /* B2 = 0.025023 */
-780, /* B1 = -0.047619 */
819, /* B0 = 0.025023 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
#if 0
{ /* f425 */
30881, /* A1 = -1.884827 */
-32603, /* A2 = 0.994965 */
-496, /* B2 = -0.015144 */
0, /* B1 = 0.000000 */
496, /* B0 = 0.015144 */
30880, /* A1 = -1.884766 */
-32692, /* A2 = 0.997711 */
24767, /* B2 = 0.755859 */
-23290, /* B1 = -1.421509 */
24767, /* B0 = 0.755859 */
30967, /* A1 = -1.890076 */
-32694, /* A2 = 0.997772 */
728, /* B2 = 0.022232 */
-691, /* B1 = -0.042194 */
728, /* B0 = 0.022232 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
#else
{
30850,
-32534,
-504,
0,
504,
30831,
-32669,
24303,
-22080,
24303,
30994,
-32673,
1905,
-1811,
1905,
5,
129,
17,
0xff5
},
#endif
{ /* f425_450[] */
30646, /* A1 = 1.870544 */
-32327, /* A2 = -0.986572 */
-287, /* B2 = -0.008769 */
0, /* B1 = 0 */
287, /* B0 = 0.008769 */
30627, /* A1 = 1.869324 */
-32607, /* A2 = -0.995087 */
13269, /* B2 = 0.404968 */
-12376, /* B1 = -0.755432 */
13269, /* B0 = 0.404968 */
30924, /* A1 = 1.887512 */
-32619, /* A2 = -0.995453 */
19950, /* B2 = 0.608826 */
-18940, /* B1 = -1.156006 */
19950, /* B0 = 0.608826 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f425_475[] */
30396, /* A1 = 1.855225 */
-32014, /* A2 = -0.97699 */
-395, /* B2 = -0.012055 */
0, /* B1 = 0 */
395, /* B0 = 0.012055 */
30343, /* A1 = 1.85199 */
-32482, /* A2 = -0.991302 */
17823, /* B2 = 0.543945 */
-16431, /* B1 = -1.002869 */
17823, /* B0 = 0.543945 */
30872, /* A1 = 1.884338 */
-32516, /* A2 = -0.99231 */
18124, /* B2 = 0.553101 */
-17246, /* B1 = -1.052673 */
18124, /* B0 = 0.553101 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f435 */
30796, /* A1 = -1.879639 */
-32603, /* A2 = 0.994965 */
-254, /* B2 = -0.007762 */
0, /* B1 = 0.000000 */
254, /* B0 = 0.007762 */
30793, /* A1 = -1.879456 */
-32692, /* A2 = 0.997711 */
18934, /* B2 = 0.577820 */
-17751, /* B1 = -1.083496 */
18934, /* B0 = 0.577820 */
30882, /* A1 = -1.884888 */
-32694, /* A2 = 0.997772 */
1858, /* B2 = 0.056713 */
-1758, /* B1 = -0.107357 */
1858, /* B0 = 0.056713 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f440_450[] */
30641, /* A1 = 1.870239 */
-32458, /* A2 = -0.99057 */
-155, /* B2 = -0.004735 */
0, /* B1 = 0 */
155, /* B0 = 0.004735 */
30631, /* A1 = 1.869568 */
-32630, /* A2 = -0.995789 */
11453, /* B2 = 0.349548 */
-10666, /* B1 = -0.651001 */
11453, /* B0 = 0.349548 */
30810, /* A1 = 1.880554 */
-32634, /* A2 = -0.995941 */
12237, /* B2 = 0.373474 */
-11588, /* B1 = -0.707336 */
12237, /* B0 = 0.373474 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f440_480[] */
30367, /* A1 = 1.853455 */
-32147, /* A2 = -0.981079 */
-495, /* B2 = -0.015113 */
0, /* B1 = 0 */
495, /* B0 = 0.015113 */
30322, /* A1 = 1.850769 */
-32543, /* A2 = -0.993134 */
10031, /* B2 = 0.306152 */
-9252, /* B1 = -0.564728 */
10031, /* B0 = 0.306152 */
30770, /* A1 = 1.878052 */
-32563, /* A2 = -0.993774 */
22674, /* B2 = 0.691956 */
-21465, /* B1 = -1.31012 */
22674, /* B0 = 0.691956 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f445 */
30709, /* A1 = -1.874329 */
-32603, /* A2 = 0.994965 */
-83, /* B2 = -0.002545 */
0, /* B1 = 0.000000 */
83, /* B0 = 0.002545 */
30704, /* A1 = -1.874084 */
-32692, /* A2 = 0.997711 */
10641, /* B2 = 0.324738 */
-9947, /* B1 = -0.607147 */
10641, /* B0 = 0.324738 */
30796, /* A1 = -1.879639 */
-32694, /* A2 = 0.997772 */
10079, /* B2 = 0.307587 */
9513, /* B1 = 0.580688 */
10079, /* B0 = 0.307587 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f450 */
30664, /* A1 = -1.871643 */
-32603, /* A2 = 0.994965 */
-164, /* B2 = -0.005029 */
0, /* B1 = 0.000000 */
164, /* B0 = 0.005029 */
30661, /* A1 = -1.871399 */
-32692, /* A2 = 0.997711 */
15294, /* B2 = 0.466736 */
-14275, /* B1 = -0.871307 */
15294, /* B0 = 0.466736 */
30751, /* A1 = -1.876953 */
-32694, /* A2 = 0.997772 */
3548, /* B2 = 0.108284 */
-3344, /* B1 = -0.204155 */
3548, /* B0 = 0.108284 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f452 */
30653, /* A1 = -1.870911 */
-32615, /* A2 = 0.995361 */
-209, /* B2 = -0.006382 */
0, /* B1 = 0.000000 */
209, /* B0 = 0.006382 */
30647, /* A1 = -1.870605 */
-32702, /* A2 = 0.997986 */
18971, /* B2 = 0.578979 */
-17716, /* B1 = -1.081299 */
18971, /* B0 = 0.578979 */
30738, /* A1 = -1.876099 */
-32702, /* A2 = 0.998016 */
2967, /* B2 = 0.090561 */
-2793, /* B1 = -0.170502 */
2967, /* B0 = 0.090561 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f475 */
30437, /* A1 = -1.857727 */
-32603, /* A2 = 0.994965 */
-264, /* B2 = -0.008062 */
0, /* B1 = 0.000000 */
264, /* B0 = 0.008062 */
30430, /* A1 = -1.857300 */
-32692, /* A2 = 0.997711 */
21681, /* B2 = 0.661682 */
-20082, /* B1 = -1.225708 */
21681, /* B0 = 0.661682 */
30526, /* A1 = -1.863220 */
-32694, /* A2 = 0.997742 */
1559, /* B2 = 0.047600 */
-1459, /* B1 = -0.089096 */
1559, /* B0 = 0.047600 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f480_620[] */
28975, /* A1 = 1.768494 */
-30955, /* A2 = -0.944672 */
-1026, /* B2 = -0.03133 */
0, /* B1 = 0 */
1026, /* B0 = 0.03133 */
28613, /* A1 = 1.746399 */
-32089, /* A2 = -0.979309 */
14214, /* B2 = 0.433807 */
-12202, /* B1 = -0.744812 */
14214, /* B0 = 0.433807 */
30243, /* A1 = 1.845947 */
-32238, /* A2 = -0.983856 */
24825, /* B2 = 0.757629 */
-23402, /* B1 = -1.428345 */
24825, /* B0 = 0.757629 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f494 */
30257, /* A1 = -1.846741 */
-32605, /* A2 = 0.995056 */
-249, /* B2 = -0.007625 */
0, /* B1 = 0.000000 */
249, /* B0 = 0.007625 */
30247, /* A1 = -1.846191 */
-32694, /* A2 = 0.997772 */
18088, /* B2 = 0.552002 */
-16652, /* B1 = -1.016418 */
18088, /* B0 = 0.552002 */
30348, /* A1 = -1.852295 */
-32696, /* A2 = 0.997803 */
2099, /* B2 = 0.064064 */
-1953, /* B1 = -0.119202 */
2099, /* B0 = 0.064064 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f500 */
30202, /* A1 = -1.843431 */
-32624, /* A2 = 0.995622 */
-413, /* B2 = -0.012622 */
0, /* B1 = 0.000000 */
413, /* B0 = 0.012622 */
30191, /* A1 = -1.842721 */
-32714, /* A2 = 0.998364 */
25954, /* B2 = 0.792057 */
-23890, /* B1 = -1.458131 */
25954, /* B0 = 0.792057 */
30296, /* A1 = -1.849172 */
-32715, /* A2 = 0.998397 */
2007, /* B2 = 0.061264 */
-1860, /* B1 = -0.113568 */
2007, /* B0 = 0.061264 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f520 */
30001, /* A1 = -1.831116 */
-32613, /* A2 = 0.995270 */
-155, /* B2 = -0.004750 */
0, /* B1 = 0.000000 */
155, /* B0 = 0.004750 */
29985, /* A1 = -1.830200 */
-32710, /* A2 = 0.998260 */
6584, /* B2 = 0.200928 */
-6018, /* B1 = -0.367355 */
6584, /* B0 = 0.200928 */
30105, /* A1 = -1.837524 */
-32712, /* A2 = 0.998291 */
23812, /* B2 = 0.726685 */
-21936, /* B1 = -1.338928 */
23812, /* B0 = 0.726685 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f523 */
29964, /* A1 = -1.828918 */
-32601, /* A2 = 0.994904 */
-101, /* B2 = -0.003110 */
0, /* B1 = 0.000000 */
101, /* B0 = 0.003110 */
29949, /* A1 = -1.827942 */
-32700, /* A2 = 0.997925 */
11041, /* B2 = 0.336975 */
-10075, /* B1 = -0.614960 */
11041, /* B0 = 0.336975 */
30070, /* A1 = -1.835388 */
-32702, /* A2 = 0.997986 */
16762, /* B2 = 0.511536 */
-15437, /* B1 = -0.942230 */
16762, /* B0 = 0.511536 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f525 */
29936, /* A1 = -1.827209 */
-32584, /* A2 = 0.994415 */
-91, /* B2 = -0.002806 */
0, /* B1 = 0.000000 */
91, /* B0 = 0.002806 */
29921, /* A1 = -1.826233 */
-32688, /* A2 = 0.997559 */
11449, /* B2 = 0.349396 */
-10426, /* B1 = -0.636383 */
11449, /* B0 = 0.349396 */
30045, /* A1 = -1.833862 */
-32688, /* A2 = 0.997589 */
13055, /* B2 = 0.398407 */
-12028, /* B1 = -0.734161 */
13055, /* B0 = 0.398407 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f540_660[] */
28499, /* A1 = 1.739441 */
-31129, /* A2 = -0.949982 */
-849, /* B2 = -0.025922 */
0, /* B1 = 0 */
849, /* B0 = 0.025922 */
28128, /* A1 = 1.716797 */
-32130, /* A2 = -0.98056 */
14556, /* B2 = 0.444214 */
-12251, /* B1 = -0.747772 */
14556, /* B0 = 0.444244 */
29667, /* A1 = 1.81073 */
-32244, /* A2 = -0.984039 */
23038, /* B2 = 0.703064 */
-21358, /* B1 = -1.303589 */
23040, /* B0 = 0.703125 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f587 */
29271, /* A1 = -1.786560 */
-32599, /* A2 = 0.994873 */
-490, /* B2 = -0.014957 */
0, /* B1 = 0.000000 */
490, /* B0 = 0.014957 */
29246, /* A1 = -1.785095 */
-32700, /* A2 = 0.997925 */
28961, /* B2 = 0.883850 */
-25796, /* B1 = -1.574463 */
28961, /* B0 = 0.883850 */
29383, /* A1 = -1.793396 */
-32700, /* A2 = 0.997955 */
1299, /* B2 = 0.039650 */
-1169, /* B1 = -0.071396 */
1299, /* B0 = 0.039650 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f590 */
29230, /* A1 = -1.784058 */
-32584, /* A2 = 0.994415 */
-418, /* B2 = -0.012757 */
0, /* B1 = 0.000000 */
418, /* B0 = 0.012757 */
29206, /* A1 = -1.782593 */
-32688, /* A2 = 0.997559 */
36556, /* B2 = 1.115601 */
-32478, /* B1 = -1.982300 */
36556, /* B0 = 1.115601 */
29345, /* A1 = -1.791077 */
-32688, /* A2 = 0.997589 */
897, /* B2 = 0.027397 */
-808, /* B1 = -0.049334 */
897, /* B0 = 0.027397 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f600 */
29116, /* A1 = -1.777100 */
-32603, /* A2 = 0.994965 */
-165, /* B2 = -0.005039 */
0, /* B1 = 0.000000 */
165, /* B0 = 0.005039 */
29089, /* A1 = -1.775452 */
-32708, /* A2 = 0.998199 */
6963, /* B2 = 0.212494 */
-6172, /* B1 = -0.376770 */
6963, /* B0 = 0.212494 */
29237, /* A1 = -1.784485 */
-32710, /* A2 = 0.998230 */
24197, /* B2 = 0.738464 */
-21657, /* B1 = -1.321899 */
24197, /* B0 = 0.738464 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f660 */
28376, /* A1 = -1.731934 */
-32567, /* A2 = 0.993896 */
-363, /* B2 = -0.011102 */
0, /* B1 = 0.000000 */
363, /* B0 = 0.011102 */
28337, /* A1 = -1.729614 */
-32683, /* A2 = 0.997434 */
21766, /* B2 = 0.664246 */
-18761, /* B1 = -1.145081 */
21766, /* B0 = 0.664246 */
28513, /* A1 = -1.740356 */
-32686, /* A2 = 0.997498 */
2509, /* B2 = 0.076584 */
-2196, /* B1 = -0.134041 */
2509, /* B0 = 0.076584 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f700 */
27844, /* A1 = -1.699463 */
-32563, /* A2 = 0.993744 */
-366, /* B2 = -0.011187 */
0, /* B1 = 0.000000 */
366, /* B0 = 0.011187 */
27797, /* A1 = -1.696655 */
-32686, /* A2 = 0.997498 */
22748, /* B2 = 0.694214 */
-19235, /* B1 = -1.174072 */
22748, /* B0 = 0.694214 */
27995, /* A1 = -1.708740 */
-32688, /* A2 = 0.997559 */
2964, /* B2 = 0.090477 */
-2546, /* B1 = -0.155449 */
2964, /* B0 = 0.090477 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f740 */
27297, /* A1 = -1.666077 */
-32551, /* A2 = 0.993408 */
-345, /* B2 = -0.010540 */
0, /* B1 = 0.000000 */
345, /* B0 = 0.010540 */
27240, /* A1 = -1.662598 */
-32683, /* A2 = 0.997406 */
22560, /* B2 = 0.688477 */
-18688, /* B1 = -1.140625 */
22560, /* B0 = 0.688477 */
27461, /* A1 = -1.676147 */
-32684, /* A2 = 0.997467 */
3541, /* B2 = 0.108086 */
-2985, /* B1 = -0.182220 */
3541, /* B0 = 0.108086 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f750 */
27155, /* A1 = -1.657410 */
-32551, /* A2 = 0.993408 */
-462, /* B2 = -0.014117 */
0, /* B1 = 0.000000 */
462, /* B0 = 0.014117 */
27097, /* A1 = -1.653870 */
-32683, /* A2 = 0.997406 */
32495, /* B2 = 0.991699 */
-26776, /* B1 = -1.634338 */
32495, /* B0 = 0.991699 */
27321, /* A1 = -1.667542 */
-32684, /* A2 = 0.997467 */
1835, /* B2 = 0.056007 */
-1539, /* B1 = -0.093948 */
1835, /* B0 = 0.056007 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f750_1450[] */
19298, /* A1 = 1.177917 */
-24471, /* A2 = -0.746796 */
-4152, /* B2 = -0.126709 */
0, /* B1 = 0 */
4152, /* B0 = 0.126709 */
12902, /* A1 = 0.787476 */
-29091, /* A2 = -0.887817 */
12491, /* B2 = 0.38121 */
-1794, /* B1 = -0.109528 */
12494, /* B0 = 0.381317 */
26291, /* A1 = 1.604736 */
-30470, /* A2 = -0.929901 */
28859, /* B2 = 0.880737 */
-26084, /* B1 = -1.592102 */
28861, /* B0 = 0.880798 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f770 */
26867, /* A1 = -1.639832 */
-32551, /* A2 = 0.993408 */
-123, /* B2 = -0.003755 */
0, /* B1 = 0.000000 */
123, /* B0 = 0.003755 */
26805, /* A1 = -1.636108 */
-32683, /* A2 = 0.997406 */
17297, /* B2 = 0.527863 */
-14096, /* B1 = -0.860382 */
17297, /* B0 = 0.527863 */
27034, /* A1 = -1.650085 */
-32684, /* A2 = 0.997467 */
12958, /* B2 = 0.395477 */
-10756, /* B1 = -0.656525 */
12958, /* B0 = 0.395477 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f800 */
26413, /* A1 = -1.612122 */
-32547, /* A2 = 0.993286 */
-223, /* B2 = -0.006825 */
0, /* B1 = 0.000000 */
223, /* B0 = 0.006825 */
26342, /* A1 = -1.607849 */
-32686, /* A2 = 0.997498 */
6391, /* B2 = 0.195053 */
-5120, /* B1 = -0.312531 */
6391, /* B0 = 0.195053 */
26593, /* A1 = -1.623108 */
-32688, /* A2 = 0.997559 */
23681, /* B2 = 0.722717 */
-19328, /* B1 = -1.179688 */
23681, /* B0 = 0.722717 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f816 */
26168, /* A1 = -1.597209 */
-32528, /* A2 = 0.992706 */
-235, /* B2 = -0.007182 */
0, /* B1 = 0.000000 */
235, /* B0 = 0.007182 */
26092, /* A1 = -1.592590 */
-32675, /* A2 = 0.997192 */
20823, /* B2 = 0.635498 */
-16510, /* B1 = -1.007751 */
20823, /* B0 = 0.635498 */
26363, /* A1 = -1.609070 */
-32677, /* A2 = 0.997253 */
6739, /* B2 = 0.205688 */
-5459, /* B1 = -0.333206 */
6739, /* B0 = 0.205688 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f850 */
25641, /* A1 = -1.565063 */
-32536, /* A2 = 0.992950 */
-121, /* B2 = -0.003707 */
0, /* B1 = 0.000000 */
121, /* B0 = 0.003707 */
25560, /* A1 = -1.560059 */
-32684, /* A2 = 0.997437 */
18341, /* B2 = 0.559753 */
-14252, /* B1 = -0.869904 */
18341, /* B0 = 0.559753 */
25837, /* A1 = -1.577026 */
-32684, /* A2 = 0.997467 */
16679, /* B2 = 0.509003 */
-13232, /* B1 = -0.807648 */
16679, /* B0 = 0.509003 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f857_1645[] */
16415, /* A1 = 1.001953 */
-23669, /* A2 = -0.722321 */
-4549, /* B2 = -0.138847 */
0, /* B1 = 0 */
4549, /* B0 = 0.138847 */
8456, /* A1 = 0.516174 */
-28996, /* A2 = -0.884918 */
13753, /* B2 = 0.419724 */
-12, /* B1 = -0.000763 */
13757, /* B0 = 0.419846 */
24632, /* A1 = 1.503418 */
-30271, /* A2 = -0.923828 */
29070, /* B2 = 0.887146 */
-25265, /* B1 = -1.542114 */
29073, /* B0 = 0.887268 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f900 */
24806, /* A1 = -1.514099 */
-32501, /* A2 = 0.991852 */
-326, /* B2 = -0.009969 */
0, /* B1 = 0.000000 */
326, /* B0 = 0.009969 */
24709, /* A1 = -1.508118 */
-32659, /* A2 = 0.996674 */
20277, /* B2 = 0.618835 */
-15182, /* B1 = -0.926636 */
20277, /* B0 = 0.618835 */
25022, /* A1 = -1.527222 */
-32661, /* A2 = 0.996735 */
4320, /* B2 = 0.131836 */
-3331, /* B1 = -0.203339 */
4320, /* B0 = 0.131836 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f900_1300[] */
19776, /* A1 = 1.207092 */
-27437, /* A2 = -0.837341 */
-2666, /* B2 = -0.081371 */
0, /* B1 = 0 */
2666, /* B0 = 0.081371 */
16302, /* A1 = 0.995026 */
-30354, /* A2 = -0.926361 */
10389, /* B2 = 0.317062 */
-3327, /* B1 = -0.203064 */
10389, /* B0 = 0.317062 */
24299, /* A1 = 1.483154 */
-30930, /* A2 = -0.943909 */
25016, /* B2 = 0.763428 */
-21171, /* B1 = -1.292236 */
25016, /* B0 = 0.763428 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f935_1215[] */
20554, /* A1 = 1.254517 */
-28764, /* A2 = -0.877838 */
-2048, /* B2 = -0.062515 */
0, /* B1 = 0 */
2048, /* B0 = 0.062515 */
18209, /* A1 = 1.11145 */
-30951, /* A2 = -0.94458 */
9390, /* B2 = 0.286575 */
-3955, /* B1 = -0.241455 */
9390, /* B0 = 0.286575 */
23902, /* A1 = 1.458923 */
-31286, /* A2 = -0.954803 */
23252, /* B2 = 0.709595 */
-19132, /* B1 = -1.167725 */
23252, /* B0 = 0.709595 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f941_1477[] */
17543, /* A1 = 1.07074 */
-26220, /* A2 = -0.800201 */
-3298, /* B2 = -0.100647 */
0, /* B1 = 0 */
3298, /* B0 = 0.100647 */
12423, /* A1 = 0.75827 */
-30036, /* A2 = -0.916626 */
12651, /* B2 = 0.386078 */
-2444, /* B1 = -0.14917 */
12653, /* B0 = 0.386154 */
23518, /* A1 = 1.435425 */
-30745, /* A2 = -0.938293 */
27282, /* B2 = 0.832581 */
-22529, /* B1 = -1.375122 */
27286, /* B0 = 0.832703 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f942 */
24104, /* A1 = -1.471252 */
-32507, /* A2 = 0.992065 */
-351, /* B2 = -0.010722 */
0, /* B1 = 0.000000 */
351, /* B0 = 0.010722 */
23996, /* A1 = -1.464600 */
-32671, /* A2 = 0.997040 */
22848, /* B2 = 0.697266 */
-16639, /* B1 = -1.015564 */
22848, /* B0 = 0.697266 */
24332, /* A1 = -1.485168 */
-32673, /* A2 = 0.997101 */
4906, /* B2 = 0.149727 */
-3672, /* B1 = -0.224174 */
4906, /* B0 = 0.149727 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f950 */
23967, /* A1 = -1.462830 */
-32507, /* A2 = 0.992065 */
-518, /* B2 = -0.015821 */
0, /* B1 = 0.000000 */
518, /* B0 = 0.015821 */
23856, /* A1 = -1.456055 */
-32671, /* A2 = 0.997040 */
26287, /* B2 = 0.802246 */
-19031, /* B1 = -1.161560 */
26287, /* B0 = 0.802246 */
24195, /* A1 = -1.476746 */
-32673, /* A2 = 0.997101 */
2890, /* B2 = 0.088196 */
-2151, /* B1 = -0.131317 */
2890, /* B0 = 0.088196 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f950_1400[] */
18294, /* A1 = 1.116638 */
-26962, /* A2 = -0.822845 */
-2914, /* B2 = -0.088936 */
0, /* B1 = 0 */
2914, /* B0 = 0.088936 */
14119, /* A1 = 0.861786 */
-30227, /* A2 = -0.922455 */
11466, /* B2 = 0.349945 */
-2833, /* B1 = -0.172943 */
11466, /* B0 = 0.349945 */
23431, /* A1 = 1.430115 */
-30828, /* A2 = -0.940796 */
25331, /* B2 = 0.773071 */
-20911, /* B1 = -1.276367 */
25331, /* B0 = 0.773071 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f975 */
23521, /* A1 = -1.435608 */
-32489, /* A2 = 0.991516 */
-193, /* B2 = -0.005915 */
0, /* B1 = 0.000000 */
193, /* B0 = 0.005915 */
23404, /* A1 = -1.428467 */
-32655, /* A2 = 0.996582 */
17740, /* B2 = 0.541412 */
-12567, /* B1 = -0.767029 */
17740, /* B0 = 0.541412 */
23753, /* A1 = -1.449829 */
-32657, /* A2 = 0.996613 */
9090, /* B2 = 0.277405 */
-6662, /* B1 = -0.406647 */
9090, /* B0 = 0.277405 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1000 */
23071, /* A1 = -1.408203 */
-32489, /* A2 = 0.991516 */
-293, /* B2 = -0.008965 */
0, /* B1 = 0.000000 */
293, /* B0 = 0.008965 */
22951, /* A1 = -1.400818 */
-32655, /* A2 = 0.996582 */
5689, /* B2 = 0.173645 */
-3951, /* B1 = -0.241150 */
5689, /* B0 = 0.173645 */
23307, /* A1 = -1.422607 */
-32657, /* A2 = 0.996613 */
18692, /* B2 = 0.570435 */
-13447, /* B1 = -0.820770 */
18692, /* B0 = 0.570435 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1020 */
22701, /* A1 = -1.385620 */
-32474, /* A2 = 0.991058 */
-292, /* B2 = -0.008933 */
0, /*163840 , B1 = 10.000000 */
292, /* B0 = 0.008933 */
22564, /* A1 = -1.377258 */
-32655, /* A2 = 0.996552 */
20756, /* B2 = 0.633423 */
-14176, /* B1 = -0.865295 */
20756, /* B0 = 0.633423 */
22960, /* A1 = -1.401428 */
-32657, /* A2 = 0.996613 */
6520, /* B2 = 0.198990 */
-4619, /* B1 = -0.281937 */
6520, /* B0 = 0.198990 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1050 */
22142, /* A1 = -1.351501 */
-32474, /* A2 = 0.991058 */
-147, /* B2 = -0.004493 */
0, /* B1 = 0.000000 */
147, /* B0 = 0.004493 */
22000, /* A1 = -1.342834 */
-32655, /* A2 = 0.996552 */
15379, /* B2 = 0.469360 */
-10237, /* B1 = -0.624847 */
15379, /* B0 = 0.469360 */
22406, /* A1 = -1.367554 */
-32657, /* A2 = 0.996613 */
17491, /* B2 = 0.533783 */
-12096, /* B1 = -0.738312 */
17491, /* B0 = 0.533783 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1100_1750[] */
12973, /* A1 = 0.79184 */
-24916, /* A2 = -0.760376 */
6655, /* B2 = 0.203102 */
367, /* B1 = 0.0224 */
6657, /* B0 = 0.203171 */
5915, /* A1 = 0.361053 */
-29560, /* A2 = -0.90213 */
-7777, /* B2 = -0.23735 */
0, /* B1 = 0 */
7777, /* B0 = 0.23735 */
20510, /* A1 = 1.251892 */
-30260, /* A2 = -0.923462 */
26662, /* B2 = 0.81366 */
-20573, /* B1 = -1.255737 */
26668, /* B0 = 0.813843 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1140 */
20392, /* A1 = -1.244629 */
-32460, /* A2 = 0.990601 */
-270, /* B2 = -0.008240 */
0, /* B1 = 0.000000 */
270, /* B0 = 0.008240 */
20218, /* A1 = -1.234009 */
-32655, /* A2 = 0.996582 */
21337, /* B2 = 0.651154 */
-13044, /* B1 = -0.796143 */
21337, /* B0 = 0.651154 */
20684, /* A1 = -1.262512 */
-32657, /* A2 = 0.996643 */
8572, /* B2 = 0.261612 */
-5476, /* B1 = -0.334244 */
8572, /* B0 = 0.261612 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1200 */
19159, /* A1 = -1.169373 */
-32456, /* A2 = 0.990509 */
-335, /* B2 = -0.010252 */
0, /* B1 = 0.000000 */
335, /* B0 = 0.010252 */
18966, /* A1 = -1.157593 */
-32661, /* A2 = 0.996735 */
6802, /* B2 = 0.207588 */
-3900, /* B1 = -0.238098 */
6802, /* B0 = 0.207588 */
19467, /* A1 = -1.188232 */
-32661, /* A2 = 0.996765 */
25035, /* B2 = 0.764008 */
-15049, /* B1 = -0.918579 */
25035, /* B0 = 0.764008 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1209 */
18976, /* A1 = -1.158264 */
-32439, /* A2 = 0.989990 */
-183, /* B2 = -0.005588 */
0, /* B1 = 0.000000 */
183, /* B0 = 0.005588 */
18774, /* A1 = -1.145874 */
-32650, /* A2 = 0.996429 */
15468, /* B2 = 0.472076 */
-8768, /* B1 = -0.535217 */
15468, /* B0 = 0.472076 */
19300, /* A1 = -1.177979 */
-32652, /* A2 = 0.996490 */
19840, /* B2 = 0.605499 */
-11842, /* B1 = -0.722809 */
19840, /* B0 = 0.605499 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1330 */
16357, /* A1 = -0.998413 */
-32368, /* A2 = 0.987793 */
-217, /* B2 = -0.006652 */
0, /* B1 = 0.000000 */
217, /* B0 = 0.006652 */
16107, /* A1 = -0.983126 */
-32601, /* A2 = 0.994904 */
11602, /* B2 = 0.354065 */
-5555, /* B1 = -0.339111 */
11602, /* B0 = 0.354065 */
16722, /* A1 = -1.020630 */
-32603, /* A2 = 0.994965 */
15574, /* B2 = 0.475311 */
-8176, /* B1 = -0.499069 */
15574, /* B0 = 0.475311 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1336 */
16234, /* A1 = -0.990875 */
32404, /* A2 = -0.988922 */
-193, /* B2 = -0.005908 */
0, /* B1 = 0.000000 */
193, /* B0 = 0.005908 */
15986, /* A1 = -0.975769 */
-32632, /* A2 = 0.995880 */
18051, /* B2 = 0.550903 */
-8658, /* B1 = -0.528473 */
18051, /* B0 = 0.550903 */
16591, /* A1 = -1.012695 */
-32634, /* A2 = 0.995941 */
15736, /* B2 = 0.480240 */
-8125, /* B1 = -0.495926 */
15736, /* B0 = 0.480240 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1366 */
15564, /* A1 = -0.949982 */
-32404, /* A2 = 0.988922 */
-269, /* B2 = -0.008216 */
0, /* B1 = 0.000000 */
269, /* B0 = 0.008216 */
15310, /* A1 = -0.934479 */
-32632, /* A2 = 0.995880 */
10815, /* B2 = 0.330063 */
-4962, /* B1 = -0.302887 */
10815, /* B0 = 0.330063 */
15924, /* A1 = -0.971924 */
-32634, /* A2 = 0.995941 */
18880, /* B2 = 0.576172 */
-9364, /* B1 = -0.571594 */
18880, /* B0 = 0.576172 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1380 */
15247, /* A1 = -0.930603 */
-32397, /* A2 = 0.988708 */
-244, /* B2 = -0.007451 */
0, /* B1 = 0.000000 */
244, /* B0 = 0.007451 */
14989, /* A1 = -0.914886 */
-32627, /* A2 = 0.995697 */
18961, /* B2 = 0.578644 */
-8498, /* B1 = -0.518707 */
18961, /* B0 = 0.578644 */
15608, /* A1 = -0.952667 */
-32628, /* A2 = 0.995758 */
11145, /* B2 = 0.340134 */
-5430, /* B1 = -0.331467 */
11145, /* B0 = 0.340134 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1400 */
14780, /* A1 = -0.902130 */
-32393, /* A2 = 0.988586 */
-396, /* B2 = -0.012086 */
0, /* B1 = 0.000000 */
396, /* B0 = 0.012086 */
14510, /* A1 = -0.885651 */
-32630, /* A2 = 0.995819 */
6326, /* B2 = 0.193069 */
-2747, /* B1 = -0.167671 */
6326, /* B0 = 0.193069 */
15154, /* A1 = -0.924957 */
-32632, /* A2 = 0.995850 */
23235, /* B2 = 0.709076 */
-10983, /* B1 = -0.670380 */
23235, /* B0 = 0.709076 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1477 */
13005, /* A1 = -0.793793 */
-32368, /* A2 = 0.987823 */
-500, /* B2 = -0.015265 */
0, /* B1 = 0.000000 */
500, /* B0 = 0.015265 */
12708, /* A1 = -0.775665 */
-32615, /* A2 = 0.995331 */
11420, /* B2 = 0.348526 */
-4306, /* B1 = -0.262833 */
11420, /* B0 = 0.348526 */
13397, /* A1 = -0.817688 */
-32615, /* A2 = 0.995361 */
9454, /* B2 = 0.288528 */
-3981, /* B1 = -0.243027 */
9454, /* B0 = 0.288528 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1600 */
10046, /* A1 = -0.613190 */
-32331, /* A2 = 0.986694 */
-455, /* B2 = -0.013915 */
0, /* B1 = 0.000000 */
455, /* B0 = 0.013915 */
9694, /* A1 = -0.591705 */
-32601, /* A2 = 0.994934 */
6023, /* B2 = 0.183815 */
-1708, /* B1 = -0.104279 */
6023, /* B0 = 0.183815 */
10478, /* A1 = -0.639587 */
-32603, /* A2 = 0.994965 */
22031, /* B2 = 0.672333 */
-7342, /* B1 = -0.448151 */
22031, /* B0 = 0.672333 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1633_1638[] */
9181, /* A1 = 0.560394 */
-32256, /* A2 = -0.984375 */
-556, /* B2 = -0.016975 */
0, /* B1 = 0 */
556, /* B0 = 0.016975 */
8757, /* A1 = 0.534515 */
-32574, /* A2 = -0.99408 */
8443, /* B2 = 0.25769 */
-2135, /* B1 = -0.130341 */
8443, /* B0 = 0.25769 */
9691, /* A1 = 0.591522 */
-32574, /* A2 = -0.99411 */
15446, /* B2 = 0.471375 */
-4809, /* B1 = -0.293579 */
15446, /* B0 = 0.471375 */
7, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1800 */
5076, /* A1 = -0.309875 */
-32304, /* A2 = 0.985840 */
-508, /* B2 = -0.015503 */
0, /* B1 = 0.000000 */
508, /* B0 = 0.015503 */
4646, /* A1 = -0.283600 */
-32605, /* A2 = 0.995026 */
6742, /* B2 = 0.205780 */
-878, /* B1 = -0.053635 */
6742, /* B0 = 0.205780 */
5552, /* A1 = -0.338928 */
-32605, /* A2 = 0.995056 */
23667, /* B2 = 0.722260 */
-4297, /* B1 = -0.262329 */
23667, /* B0 = 0.722260 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
{ /* f1860 */
3569, /* A1 = -0.217865 */
-32292, /* A2 = 0.985504 */
-239, /* B2 = -0.007322 */
0, /* B1 = 0.000000 */
239, /* B0 = 0.007322 */
3117, /* A1 = -0.190277 */
-32603, /* A2 = 0.994965 */
18658, /* B2 = 0.569427 */
-1557, /* B1 = -0.095032 */
18658, /* B0 = 0.569427 */
4054, /* A1 = -0.247437 */
-32603, /* A2 = 0.994965 */
18886, /* B2 = 0.576385 */
-2566, /* B1 = -0.156647 */
18886, /* B0 = 0.576385 */
5, /* Internal filter scaling */
159, /* Minimum in-band energy threshold */
21, /* 21/32 in-band to broad-band ratio */
0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
},
};
static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf)
{
unsigned short cmd;
int cnt, max;
if (jf->filter > 3) {
return -1;
}
if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) /* Select Filter */
return -1;
if (!jf->enable) {
if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
return -1;
else
return 0;
} else {
if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
return -1;
/* Select the filter (f0 - f3) to use. */
if (ixj_WriteDSPCommand(0x5154 + jf->filter, j))
return -1;
}
if (jf->freq < 12 && jf->freq > 3) {
/* Select the frequency for the selected filter. */
if (ixj_WriteDSPCommand(0x5170 + jf->freq, j))
return -1;
} else if (jf->freq > 11) {
/* We need to load a programmable filter set for undefined */
/* frequencies. So we will point the filter to a programmable set. */
/* Since there are only 4 filters and 4 programmable sets, we will */
/* just point the filter to the same number set and program it for the */
/* frequency we want. */
if (ixj_WriteDSPCommand(0x5170 + jf->filter, j))
return -1;
if (j->ver.low != 0x12) {
cmd = 0x515B;
max = 19;
} else {
cmd = 0x515E;
max = 15;
}
if (ixj_WriteDSPCommand(cmd, j))
return -1;
for (cnt = 0; cnt < max; cnt++) {
if (ixj_WriteDSPCommand(tone_table[jf->freq - 12][cnt], j))
return -1;
}
}
j->filter_en[jf->filter] = jf->enable;
return 0;
}
static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr)
{
unsigned short cmd;
int cnt, max;
if (jfr->filter > 3) {
return -1;
}
if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) /* Select Filter */
return -1;
if (!jfr->enable) {
if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
return -1;
else
return 0;
} else {
if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
return -1;
/* Select the filter (f0 - f3) to use. */
if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j))
return -1;
}
/* We need to load a programmable filter set for undefined */
/* frequencies. So we will point the filter to a programmable set. */
/* Since there are only 4 filters and 4 programmable sets, we will */
/* just point the filter to the same number set and program it for the */
/* frequency we want. */
if (ixj_WriteDSPCommand(0x5170 + jfr->filter, j))
return -1;
if (j->ver.low != 0x12) {
cmd = 0x515B;
max = 19;
} else {
cmd = 0x515E;
max = 15;
}
if (ixj_WriteDSPCommand(cmd, j))
return -1;
for (cnt = 0; cnt < max; cnt++) {
if (ixj_WriteDSPCommand(jfr->coeff[cnt], j))
return -1;
}
j->filter_en[jfr->filter] = jfr->enable;
return 0;
}
static int ixj_init_tone(IXJ *j, IXJ_TONE * ti)
{
int freq0, freq1;
unsigned short data;
if (ti->freq0) {
freq0 = ti->freq0;
} else {
freq0 = 0x7FFF;
}
if (ti->freq1) {
freq1 = ti->freq1;
} else {
freq1 = 0x7FFF;
}
if(ti->tone_index > 12 && ti->tone_index < 28)
{
if (ixj_WriteDSPCommand(0x6800 + ti->tone_index, j))
return -1;
if (ixj_WriteDSPCommand(0x6000 + (ti->gain1 << 4) + ti->gain0, j))
return -1;
data = freq0;
if (ixj_WriteDSPCommand(data, j))
return -1;
data = freq1;
if (ixj_WriteDSPCommand(data, j))
return -1;
}
return freq0;
}
| xtreamerdev/linux-xtr | drivers/telephony/ixj.c | C | gpl-2.0 | 321,287 |
/*
* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (c) 2012, The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
*/
#ifndef __LIM_UTILS_H
#define __LIM_UTILS_H
#include "sirApi.h"
#include "sirDebug.h"
#include "cfgApi.h"
#include "limTypes.h"
#include "limScanResultUtils.h"
#include "limTimerUtils.h"
#include "limTrace.h"
typedef enum
{
ONE_BYTE = 1,
TWO_BYTE = 2
} eSizeOfLenField;
#define LIM_STA_ID_MASK 0x00FF
#define LIM_AID_MASK 0xC000
#define LIM_SPECTRUM_MANAGEMENT_BIT_MASK 0x0100
#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
#define LIM_MAX_REASSOC_RETRY_LIMIT 2
#endif
//
#define LIM_MAKE_CLSID(tsid, dir) (((tsid) & 0x0F) | (((dir) & 0x03) << 4))
#define LIM_SET_STA_BA_STATE(pSta, tid, newVal) \
{\
pSta->baState = ((pSta->baState | (0x3 << tid*2)) & ((newVal << tid*2) | ~(0x3 << tid*2)));\
}
#define LIM_GET_STA_BA_STATE(pSta, tid, pCurVal)\
{\
*pCurVal = (tLimBAState)(((pSta->baState >> tid*2) & 0x3));\
}
typedef struct sAddBaInfo
{
tANI_U16 fBaEnable : 1;
tANI_U16 startingSeqNum: 12;
tANI_U16 reserved : 3;
}tAddBaInfo, *tpAddBaInfo;
typedef struct sAddBaCandidate
{
tSirMacAddr staAddr;
tAddBaInfo baInfo[STACFG_MAX_TC];
}tAddBaCandidate, *tpAddBaCandidate;
//
void limGetBssidFromPkt(tpAniSirGlobal, tANI_U8 *, tANI_U8 *, tANI_U32 *);
char * limMlmStateStr(tLimMlmStates state);
char * limSmeStateStr(tLimSmeStates state);
char * limMsgStr(tANI_U32 msgType);
char * limResultCodeStr(tSirResultCodes resultCode);
char* limDot11ModeStr(tpAniSirGlobal pMac, tANI_U8 dot11Mode);
char* limStaOpRateModeStr(tStaRateMode opRateMode);
void limPrintMlmState(tpAniSirGlobal pMac, tANI_U16 logLevel, tLimMlmStates state);
void limPrintSmeState(tpAniSirGlobal pMac, tANI_U16 logLevel, tLimSmeStates state);
void limPrintMsgName(tpAniSirGlobal pMac, tANI_U16 logLevel, tANI_U32 msgType);
void limPrintMsgInfo(tpAniSirGlobal pMac, tANI_U16 logLevel, tSirMsgQ *msg);
char* limBssTypeStr(tSirBssType bssType);
#if defined FEATURE_WLAN_CCX || defined WLAN_FEATURE_VOWIFI
extern tSirRetStatus limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac,
tPowerdBm txPower,
tpPESession pSessionEntry );
extern tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower);
#endif
tANI_U32 limPostMsgApiNoWait(tpAniSirGlobal, tSirMsgQ *);
tANI_U8 limIsAddrBC(tSirMacAddr);
tANI_U8 limIsGroupAddr(tSirMacAddr);
//
tANI_U8 limActiveScanAllowed(tpAniSirGlobal, tANI_U8);
//
void limInitPeerIdxpool(tpAniSirGlobal,tpPESession);
tANI_U16 limAssignPeerIdx(tpAniSirGlobal,tpPESession);
void limEnableOverlap11gProtection(tpAniSirGlobal pMac, tpUpdateBeaconParams pBeaconParams, tpSirMacMgmtHdr pMh,tpPESession psessionEntry);
void limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams);
void limUpdateShortPreamble(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry);
void limUpdateShortSlotTime(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry);
/*
*/
void limReleasePeerIdx(tpAniSirGlobal, tANI_U16, tpPESession);
void limDecideApProtection(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tpUpdateBeaconParams pBeaconParams,tpPESession);
void
limDecideApProtectionOnDelete(tpAniSirGlobal pMac,
tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry);
extern tSirRetStatus limEnable11aProtection(tpAniSirGlobal pMac, tANI_U8 enable, tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession);
extern tSirRetStatus limEnable11gProtection(tpAniSirGlobal pMac, tANI_U8 enable, tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry);
extern tSirRetStatus limEnableHtProtectionFrom11g(tpAniSirGlobal pMac, tANI_U8 enable, tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry);
extern tSirRetStatus limEnableHT20Protection(tpAniSirGlobal pMac, tANI_U8 enable, tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession sessionEntry);
extern tSirRetStatus limEnableHTNonGfProtection(tpAniSirGlobal pMac, tANI_U8 enable, tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession);
extern tSirRetStatus limEnableHtRifsProtection(tpAniSirGlobal pMac, tANI_U8 enable, tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry);
extern tSirRetStatus limEnableHTLsigTxopProtection(tpAniSirGlobal pMac, tANI_U8 enable, tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession);
extern tSirRetStatus limEnableShortPreamble(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry);
extern tSirRetStatus limEnableHtOBSSProtection (tpAniSirGlobal pMac, tANI_U8 enable, tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams, tpPESession);
void limDecideStaProtection(tpAniSirGlobal pMac, tpSchBeaconStruct pBeaconStruct, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry);
void limDecideStaProtectionOnAssoc(tpAniSirGlobal pMac, tpSchBeaconStruct pBeaconStruct, tpPESession psessionEntry);
void limUpdateStaRunTimeHTSwitchChnlParams(tpAniSirGlobal pMac, tDot11fIEHTInfo * pHTInfo, tANI_U8 bssIdx, tpPESession psessionEntry);
//
void limPrintMacAddr(tpAniSirGlobal, tSirMacAddr, tANI_U8);
//
tANI_U8 limWriteDeferredMsgQ(tpAniSirGlobal pMac, tpSirMsgQ limMsg);
tSirMsgQ* limReadDeferredMsgQ(tpAniSirGlobal pMac);
void limHandleDeferMsgError(tpAniSirGlobal pMac, tpSirMsgQ pLimMsg);
//
void limResetDeferredMsgQ(tpAniSirGlobal pMac);
tSirRetStatus limSysProcessMmhMsgApi(tpAniSirGlobal, tSirMsgQ*, tANI_U8);
void limHandleUpdateOlbcCache(tpAniSirGlobal pMac);
tANI_U8 limIsNullSsid( tSirMacSSid *pSsid );
void limProcessAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param);
//
void limStopTxAndSwitchChannel(tpAniSirGlobal pMac, tANI_U8 sessionId);
void limProcessChannelSwitchTimeout(tpAniSirGlobal);
tSirRetStatus limStartChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry);
void limUpdateChannelSwitch(tpAniSirGlobal, tpSirProbeRespBeacon, tpPESession psessionEntry);
void limProcessQuietTimeout(tpAniSirGlobal);
void limProcessQuietBssTimeout(tpAniSirGlobal);
#if 0
void limProcessWPSOverlapTimeout(tpAniSirGlobal pMac);
#endif
void limStartQuietTimer(tpAniSirGlobal pMac, tANI_U8 sessionId);
void limSwitchPrimaryChannel(tpAniSirGlobal, tANI_U8,tpPESession);
void limSwitchPrimarySecondaryChannel(tpAniSirGlobal, tpPESession, tANI_U8, ePhyChanBondState);
tAniBool limTriggerBackgroundScanDuringQuietBss(tpAniSirGlobal);
void limUpdateStaRunTimeHTSwtichChnlParams(tpAniSirGlobal pMac, tDot11fIEHTInfo *pRcvdHTInfo, tANI_U8 bssIdx);
void limUpdateStaRunTimeHTCapability(tpAniSirGlobal pMac, tDot11fIEHTCaps *pHTCaps);
void limUpdateStaRunTimeHTInfo(struct sAniSirGlobal *pMac, tDot11fIEHTInfo *pRcvdHTInfo, tpPESession psessionEntry);
void limCancelDot11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry);
void limCancelDot11hQuiet(tpAniSirGlobal pMac, tpPESession psessionEntry);
tAniBool limIsChannelValidForChannelSwitch(tpAniSirGlobal pMac, tANI_U8 channel);
void limFrameTransmissionControl(tpAniSirGlobal pMac, tLimQuietTxMode type, tLimControlTx mode);
tSirRetStatus limRestorePreChannelSwitchState(tpAniSirGlobal pMac, tpPESession psessionEntry);
tSirRetStatus limRestorePreQuietState(tpAniSirGlobal pMac, tpPESession psessionEntry);
void limPrepareFor11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry);
void limSwitchChannelCback(tpAniSirGlobal pMac, eHalStatus status,
tANI_U32 *data, tpPESession psessionEntry);
static inline tSirRFBand limGetRFBand(tANI_U8 channel)
{
if ((channel >= SIR_11A_CHANNEL_BEGIN) &&
(channel <= SIR_11A_CHANNEL_END))
return SIR_BAND_5_GHZ;
if ((channel >= SIR_11B_CHANNEL_BEGIN) &&
(channel <= SIR_11B_CHANNEL_END))
return SIR_BAND_2_4_GHZ;
return SIR_BAND_UNKNOWN;
}
static inline tSirRetStatus
limGetMgmtStaid(tpAniSirGlobal pMac, tANI_U16 *staid, tpPESession psessionEntry)
{
if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
*staid = 1;
else if (psessionEntry->limSystemRole == eLIM_STA_ROLE)
*staid = 0;
else
return eSIR_FAILURE;
return eSIR_SUCCESS;
}
static inline tANI_U8
limIsSystemInSetMimopsState(tpAniSirGlobal pMac)
{
if (pMac->lim.gLimMlmState == eLIM_MLM_WT_SET_MIMOPS_STATE)
return true;
return false;
}
static inline tANI_U8
isEnteringMimoPS(tSirMacHTMIMOPowerSaveState curState, tSirMacHTMIMOPowerSaveState newState)
{
if (curState == eSIR_HT_MIMO_PS_NO_LIMIT &&
(newState == eSIR_HT_MIMO_PS_DYNAMIC ||newState == eSIR_HT_MIMO_PS_STATIC))
return TRUE;
return FALSE;
}
//
void limUtilCountStaAdd(tpAniSirGlobal pMac, tpDphHashNode pSta, tpPESession psessionEntry);
void limUtilCountStaDel(tpAniSirGlobal pMac, tpDphHashNode pSta, tpPESession psessionEntry);
tANI_U8 limGetHTCapability( tpAniSirGlobal, tANI_U32, tpPESession);
void limTxComplete( tHalHandle hHal, void *pData );
/* */
//
//
void limProcessDelTsInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg);
tSirRetStatus limProcessHalIndMessages(tpAniSirGlobal pMac, tANI_U32 mesgId, void *mesgParam );
tSirRetStatus limValidateDeltsReq(tpAniSirGlobal pMac, tpSirDeltsReq pDeltsReq, tSirMacAddr peerMacAddr,tpPESession psessionEntry);
/* */
//
void limRegisterHalIndCallBack(tpAniSirGlobal pMac);
void limPktFree (
tpAniSirGlobal pMac,
eFrameType frmType,
tANI_U8 *pBD,
void *body);
void limGetBDfromRxPacket(tpAniSirGlobal pMac, void *body, tANI_U32 **pBD);
/*
*/
static inline tANI_U32 utilsPowerXY( tANI_U16 base, tANI_U16 power )
{
tANI_U32 result = 1, i;
for( i = 0; i < power; i++ )
result *= base;
return result;
}
tSirRetStatus limPostMlmAddBAReq( tpAniSirGlobal pMac,
tpDphHashNode pStaDs,
tANI_U8 tid, tANI_U16 startingSeqNum,tpPESession psessionEntry);
tSirRetStatus limPostMlmAddBARsp( tpAniSirGlobal pMac,
tSirMacAddr peerMacAddr,
tSirMacStatusCodes baStatusCode,
tANI_U8 baDialogToken,
tANI_U8 baTID,
tANI_U8 baPolicy,
tANI_U16 baBufferSize,
tANI_U16 baTimeout,
tpPESession psessionEntry);
tSirRetStatus limPostMlmDelBAReq( tpAniSirGlobal pMac,
tpDphHashNode pSta,
tANI_U8 baDirection,
tANI_U8 baTID,
tSirMacReasonCodes baReasonCode ,
tpPESession psessionEntry);
tSirRetStatus limPostMsgAddBAReq( tpAniSirGlobal pMac,
tpDphHashNode pSta,
tANI_U8 baDialogToken,
tANI_U8 baTID,
tANI_U8 baPolicy,
tANI_U16 baBufferSize,
tANI_U16 baTimeout,
tANI_U16 baSSN,
tANI_U8 baDirection,
tpPESession psessionEntry);
tSirRetStatus limPostMsgDelBAInd( tpAniSirGlobal pMac,
tpDphHashNode pSta,
tANI_U8 baTID,
tANI_U8 baDirection,
tpPESession psessionEntry);
tSirRetStatus limPostSMStateUpdate(tpAniSirGlobal pMac,
tANI_U16 StaIdx,
tSirMacHTMIMOPowerSaveState MIMOPSState);
void limDeleteStaContext(tpAniSirGlobal pMac, tpSirMsgQ limMsg);
void limProcessAddBaInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg);
void limDeleteBASessions(tpAniSirGlobal pMac, tpPESession pSessionEntry, tANI_U32 baDirection);
void limDelAllBASessionsBtc(tpAniSirGlobal pMac);
void limDelAllBASessions(tpAniSirGlobal pMac);
void limDeleteDialogueTokenList(tpAniSirGlobal pMac);
tSirRetStatus limSearchAndDeleteDialogueToken(tpAniSirGlobal pMac, tANI_U8 token, tANI_U16 assocId, tANI_U16 tid);
void limRessetScanChannelInfo(tpAniSirGlobal pMac);
void limAddScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 channelId);
tANI_U8 limGetChannelFromBeacon(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon);
tSirNwType limGetNwType(tpAniSirGlobal pMac, tANI_U8 channelNum, tANI_U32 type, tpSchBeaconStruct pBeacon);
void limSetTspecUapsdMask(tpAniSirGlobal pMac, tSirMacTSInfo *pTsInfo, tANI_U32 action);
void limHandleHeartBeatTimeout(tpAniSirGlobal pMac);
void limHandleHeartBeatTimeoutForSession(tpAniSirGlobal pMac, tpPESession psessionEntry);
//
void limProcessAddStaRsp(tpAniSirGlobal pMac,tpSirMsgQ pMsgQ);
void limUpdateBeacon(tpAniSirGlobal pMac);
void limProcessBtAmpApMlmAddStaRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ, tpPESession psessionEntry);
void limProcessBtAmpApMlmDelBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry);
void limProcessBtAmpApMlmDelStaRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ,tpPESession psessionEntry);
tpPESession limIsIBSSSessionActive(tpAniSirGlobal pMac);
tpPESession limIsApSessionActive(tpAniSirGlobal pMac);
void limHandleHeartBeatFailureTimeout(tpAniSirGlobal pMac);
void limProcessDelStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ);
void limProcessAddStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ);
v_U8_t* limGetIEPtr(tpAniSirGlobal pMac, v_U8_t *pIes, int length, v_U8_t eid,eSizeOfLenField size_of_len_field);
tANI_U8 limUnmapChannel(tANI_U8 mapChannel);
#define limGetWscIEPtr(pMac, ie, ie_len) \
limGetVendorIEOuiPtr(pMac, SIR_MAC_WSC_OUI, SIR_MAC_WSC_OUI_SIZE, ie, ie_len)
#define limGetP2pIEPtr(pMac, ie, ie_len) \
limGetVendorIEOuiPtr(pMac, SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE, ie, ie_len)
v_U8_t limGetNoaAttrStreamInMultP2pIes(tpAniSirGlobal pMac,v_U8_t* noaStream,v_U8_t noaLen,v_U8_t overFlowLen);
v_U8_t limGetNoaAttrStream(tpAniSirGlobal pMac, v_U8_t*pNoaStream,tpPESession psessionEntry);
v_U8_t limBuildP2pIe(tpAniSirGlobal pMac, tANI_U8 *ie, tANI_U8 *data, tANI_U8 ie_len);
tANI_BOOLEAN limIsNOAInsertReqd(tpAniSirGlobal pMac);
v_U8_t* limGetVendorIEOuiPtr(tpAniSirGlobal pMac, tANI_U8 *oui, tANI_U8 oui_size, tANI_U8 *ie, tANI_U16 ie_len);
tANI_BOOLEAN limIsconnectedOnDFSChannel(tANI_U8 currentChannel);
tANI_U8 limGetCurrentOperatingChannel(tpAniSirGlobal pMac);
#ifdef WLAN_FEATURE_11AC
tANI_BOOLEAN limCheckVHTOpModeChange( tpAniSirGlobal pMac,
tpPESession psessionEntry, tANI_U8 chanWidth, tANI_U8 staId);
#endif
#ifdef FEATURE_WLAN_DIAG_SUPPORT
typedef enum
{
WLAN_PE_DIAG_SCAN_REQ_EVENT = 0,
WLAN_PE_DIAG_SCAN_ABORT_IND_EVENT,
WLAN_PE_DIAG_SCAN_RSP_EVENT,
WLAN_PE_DIAG_JOIN_REQ_EVENT,
WLAN_PE_DIAG_JOIN_RSP_EVENT,
WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
WLAN_PE_DIAG_REASSOC_REQ_EVENT,
WLAN_PE_DIAG_REASSOC_RSP_EVENT,
WLAN_PE_DIAG_AUTH_REQ_EVENT,
WLAN_PE_DIAG_AUTH_RSP_EVENT,
WLAN_PE_DIAG_DISASSOC_REQ_EVENT,
WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
WLAN_PE_DIAG_DISASSOC_IND_EVENT,
WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
WLAN_PE_DIAG_DEAUTH_IND_EVENT,
WLAN_PE_DIAG_START_BSS_REQ_EVENT,
WLAN_PE_DIAG_START_BSS_RSP_EVENT,
WLAN_PE_DIAG_AUTH_IND_EVENT,
WLAN_PE_DIAG_ASSOC_IND_EVENT,
WLAN_PE_DIAG_ASSOC_CNF_EVENT,
WLAN_PE_DIAG_REASSOC_IND_EVENT,
WLAN_PE_DIAG_SWITCH_CHL_REQ_EVENT,
WLAN_PE_DIAG_SWITCH_CHL_RSP_EVENT,
WLAN_PE_DIAG_STOP_BSS_REQ_EVENT,
WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
WLAN_PE_DIAG_ADDTS_REQ_EVENT,
WLAN_PE_DIAG_ADDTS_RSP_EVENT,
WLAN_PE_DIAG_DELTS_REQ_EVENT,
WLAN_PE_DIAG_DELTS_RSP_EVENT,
WLAN_PE_DIAG_DELTS_IND_EVENT,
WLAN_PE_DIAG_ENTER_BMPS_REQ_EVENT,
WLAN_PE_DIAG_ENTER_BMPS_RSP_EVENT,
WLAN_PE_DIAG_EXIT_BMPS_REQ_EVENT,
WLAN_PE_DIAG_EXIT_BMPS_RSP_EVENT,
WLAN_PE_DIAG_EXIT_BMPS_IND_EVENT,
WLAN_PE_DIAG_ENTER_IMPS_REQ_EVENT,
WLAN_PE_DIAG_ENTER_IMPS_RSP_EVENT,
WLAN_PE_DIAG_EXIT_IMPS_REQ_EVENT,
WLAN_PE_DIAG_EXIT_IMPS_RSP_EVENT,
WLAN_PE_DIAG_ENTER_UAPSD_REQ_EVENT,
WLAN_PE_DIAG_ENTER_UAPSD_RSP_EVENT,
WLAN_PE_DIAG_EXIT_UAPSD_REQ_EVENT,
WLAN_PE_DIAG_EXIT_UAPSD_RSP_EVENT,
WLAN_PE_DIAG_WOWL_ADD_BCAST_PTRN_EVENT,
WLAN_PE_DIAG_WOWL_DEL_BCAST_PTRN_EVENT,
WLAN_PE_DIAG_ENTER_WOWL_REQ_EVENT,
WLAN_PE_DIAG_ENTER_WOWL_RSP_EVENT,
WLAN_PE_DIAG_EXIT_WOWL_REQ_EVENT,
WLAN_PE_DIAG_EXIT_WOWL_RSP_EVENT,
WLAN_PE_DIAG_HAL_ADDBA_REQ_EVENT,
WLAN_PE_DIAG_HAL_ADDBA_RSP_EVENT,
WLAN_PE_DIAG_HAL_DELBA_IND_EVENT,
}WLAN_PE_DIAG_EVENT_TYPE;
void limDiagEventReport(tpAniSirGlobal pMac, tANI_U16 eventType, tpPESession pSessionEntry, tANI_U16 status, tANI_U16 reasonCode);
#endif /* */
void peSetResumeChannel(tpAniSirGlobal pMac, tANI_U16 channel, ePhyChanBondState cbState);
/*
*/
void peGetResumeChannel(tpAniSirGlobal pMac, tANI_U8* resumeChannel, ePhyChanBondState* resumePhyCbState);
#ifdef FEATURE_WLAN_TDLS_INTERNAL
tANI_U8 limTdlsFindLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac, tLimTdlsLinkSetupPeer **setupPeer);
void limTdlsDelLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac);
void limStartTdlsTimer(tpAniSirGlobal pMac, tANI_U8 sessionId, TX_TIMER *timer, tANI_U32 timerId,
tANI_U16 timerType, tANI_U32 timerMsg);
#endif
tANI_U8 limGetShortSlotFromPhyMode(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U32 phyMode);
void limCleanUpDisassocDeauthReq(tpAniSirGlobal pMac, tANI_U8 *staMac, tANI_BOOLEAN cleanRxPath);
tANI_BOOLEAN limCheckDisassocDeauthAckPending(tpAniSirGlobal pMac, tANI_U8 *staMac);
#endif /* */
| aicjofs/android_kernel_lge_v500 | drivers/staging/prima_kk_2_7/CORE/MAC/src/pe/lim/limUtils.h | C | gpl-2.0 | 21,027 |
/*
* This file is part of the CMaNGOS Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "WaypointMovementGenerator.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "Creature.h"
#include "CreatureAI.h"
#include "WaypointManager.h"
#include "ScriptMgr.h"
#include "movement/MoveSplineInit.h"
#include "movement/MoveSpline.h"
#include <cassert>
//-----------------------------------------------//
void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature, int32 pathId, WaypointPathOrigin wpOrigin, uint32 overwriteEntry)
{
DETAIL_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "LoadPath: loading waypoint path for %s", creature.GetGuidStr().c_str());
if (!overwriteEntry)
overwriteEntry = creature.GetEntry();
if (wpOrigin == PATH_NO_PATH && pathId == 0)
i_path = sWaypointMgr.GetDefaultPath(overwriteEntry, creature.GetGUIDLow(), &m_PathOrigin);
else
{
m_PathOrigin = wpOrigin == PATH_NO_PATH ? PATH_FROM_ENTRY : wpOrigin;
i_path = sWaypointMgr.GetPathFromOrigin(overwriteEntry, creature.GetGUIDLow(), pathId, m_PathOrigin);
}
m_pathId = pathId;
// No movement found for entry nor guid
if (!i_path)
{
if (m_PathOrigin == PATH_FROM_EXTERNAL)
sLog.outErrorScriptLib("WaypointMovementGenerator::LoadPath: %s doesn't have waypoint path %i", creature.GetGuidStr().c_str(), pathId);
else
sLog.outErrorDb("WaypointMovementGenerator::LoadPath: %s doesn't have waypoint path %i", creature.GetGuidStr().c_str(), pathId);
return;
}
if (i_path->empty())
return;
// Initialize the i_currentNode to point to the first node
i_currentNode = i_path->begin()->first;
m_lastReachedWaypoint = 0;
}
void WaypointMovementGenerator<Creature>::Initialize(Creature& creature)
{
creature.addUnitState(UNIT_STAT_ROAMING);
creature.clearUnitState(UNIT_STAT_WAYPOINT_PAUSED);
}
void WaypointMovementGenerator<Creature>::InitializeWaypointPath(Creature& u, int32 id, WaypointPathOrigin wpSource, uint32 initialDelay, uint32 overwriteEntry)
{
LoadPath(u, id, wpSource, overwriteEntry);
i_nextMoveTime.Reset(initialDelay);
// Start moving if possible
StartMove(u);
}
void WaypointMovementGenerator<Creature>::Finalize(Creature& creature)
{
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false);
}
void WaypointMovementGenerator<Creature>::Interrupt(Creature& creature)
{
creature.InterruptMoving();
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false);
}
void WaypointMovementGenerator<Creature>::Reset(Creature& creature)
{
creature.addUnitState(UNIT_STAT_ROAMING);
StartMove(creature);
}
void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
{
if (!i_path || i_path->empty())
return;
m_lastReachedWaypoint = i_currentNode;
if (m_isArrivalDone)
return;
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
m_isArrivalDone = true;
WaypointPath::const_iterator currPoint = i_path->find(i_currentNode);
MANGOS_ASSERT(currPoint != i_path->end());
WaypointNode const& node = currPoint->second;
if (node.script_id)
{
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature movement start script %u at point %u for %s.", node.script_id, i_currentNode, creature.GetGuidStr().c_str());
creature.GetMap()->ScriptsStart(sCreatureMovementScripts, node.script_id, &creature, &creature);
}
// We have reached the destination and can process behavior
if (WaypointBehavior* behavior = node.behavior)
{
if (behavior->emote != 0)
creature.HandleEmote(behavior->emote);
if (behavior->spell != 0)
creature.CastSpell(&creature, behavior->spell, false);
if (behavior->model1 != 0)
creature.SetDisplayId(behavior->model1);
if (behavior->textid[0])
{
int32 textId = behavior->textid[0];
// Not only one text is set
if (behavior->textid[1])
{
// Select one from max 5 texts (0 and 1 already checked)
int i = 2;
for (; i < MAX_WAYPOINT_TEXT; ++i)
{
if (!behavior->textid[i])
break;
}
textId = behavior->textid[urand(0, i - 1)];
}
if (MangosStringLocale const* textData = sObjectMgr.GetMangosStringLocale(textId))
creature.MonsterText(textData, nullptr);
else
sLog.outErrorDb("%s reached waypoint %u, attempted to do text %i, but required text-data could not be found", creature.GetGuidStr().c_str(), i_currentNode, textId);
}
}
// Inform script
if (creature.AI())
{
uint32 type = WAYPOINT_MOTION_TYPE;
if (m_PathOrigin == PATH_FROM_EXTERNAL && m_pathId > 0)
type = EXTERNAL_WAYPOINT_MOVE + m_pathId;
creature.AI()->MovementInform(type, i_currentNode);
}
// Wait delay ms
Stop(node.delay);
}
void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
{
if (!i_path || i_path->empty())
return;
if (Stopped(creature))
return;
if (!creature.isAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
return;
WaypointPath::const_iterator currPoint = i_path->find(i_currentNode);
MANGOS_ASSERT(currPoint != i_path->end());
if (WaypointBehavior* behavior = currPoint->second.behavior)
{
if (behavior->model2 != 0)
creature.SetDisplayId(behavior->model2);
creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
}
if (m_isArrivalDone)
{
bool reachedLast = false;
++currPoint;
if (currPoint == i_path->end())
{
reachedLast = true;
currPoint = i_path->begin();
}
// Inform AI
if (creature.AI() && m_PathOrigin == PATH_FROM_EXTERNAL && m_pathId > 0)
{
if (!reachedLast)
creature.AI()->MovementInform(EXTERNAL_WAYPOINT_MOVE_START + m_pathId, currPoint->first);
else
creature.AI()->MovementInform(EXTERNAL_WAYPOINT_FINISHED_LAST + m_pathId, currPoint->first);
if (creature.isDead() || !creature.IsInWorld()) // Might have happened with above calls
return;
}
i_currentNode = currPoint->first;
}
m_isArrivalDone = false;
creature.addUnitState(UNIT_STAT_ROAMING_MOVE);
WaypointNode const& nextNode = currPoint->second;;
Movement::MoveSplineInit init(creature);
init.MoveTo(nextNode.x, nextNode.y, nextNode.z, true);
if (nextNode.orientation != 100 && nextNode.delay != 0)
init.SetFacing(nextNode.orientation);
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE) && !creature.IsLevitating(), false);
init.Launch();
}
bool WaypointMovementGenerator<Creature>::Update(Creature& creature, const uint32& diff)
{
// Waypoint movement can be switched on/off
// This is quite handy for escort quests and other stuff
if (creature.hasUnitState(UNIT_STAT_NOT_MOVE))
{
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
return true;
}
// prevent a crash at empty waypoint path.
if (!i_path || i_path->empty())
{
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
return true;
}
if (Stopped(creature))
{
if (CanMove(diff, creature))
StartMove(creature);
}
else
{
if (creature.IsStopped())
Stop(STOP_TIME_FOR_PLAYER);
else if (creature.movespline->Finalized())
{
OnArrived(creature);
StartMove(creature);
}
}
return true;
}
bool WaypointMovementGenerator<Creature>::Stopped(Creature& u)
{
return !i_nextMoveTime.Passed() || u.hasUnitState(UNIT_STAT_WAYPOINT_PAUSED);
}
bool WaypointMovementGenerator<Creature>::CanMove(int32 diff, Creature& u)
{
i_nextMoveTime.Update(diff);
if (i_nextMoveTime.Passed() && u.hasUnitState(UNIT_STAT_WAYPOINT_PAUSED))
i_nextMoveTime.Reset(1);
return i_nextMoveTime.Passed() && !u.hasUnitState(UNIT_STAT_WAYPOINT_PAUSED);
}
bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x, float& y, float& z, float& o) const
{
// prevent a crash at empty waypoint path.
if (!i_path || i_path->empty())
return false;
WaypointPath::const_iterator lastPoint = i_path->find(m_lastReachedWaypoint);
// Special case: Before the first waypoint is reached, m_lastReachedWaypoint is set to 0 (which may not be contained in i_path)
if (!m_lastReachedWaypoint && lastPoint == i_path->end())
return false;
MANGOS_ASSERT(lastPoint != i_path->end());
WaypointNode const* curWP = &(lastPoint->second);
x = curWP->x;
y = curWP->y;
z = curWP->z;
if (curWP->orientation != 100)
o = curWP->orientation;
else // Calculate the resulting angle based on positions between previous and current waypoint
{
WaypointNode const* prevWP;
if (lastPoint != i_path->begin()) // Not the first waypoint
{
--lastPoint;
prevWP = &(lastPoint->second);
}
else // Take the last waypoint (crbegin()) as previous
prevWP = &(i_path->rbegin()->second);
float dx = x - prevWP->x;
float dy = y - prevWP->y;
o = atan2(dy, dx); // returns value between -Pi..Pi
o = (o >= 0) ? o : 2 * M_PI_F + o;
}
return true;
}
void WaypointMovementGenerator<Creature>::GetPathInformation(std::ostringstream& oss) const
{
oss << "WaypointMovement: Last Reached WP: " << m_lastReachedWaypoint << " ";
oss << "(Loaded path " << m_pathId << " from " << WaypointManager::GetOriginString(m_PathOrigin) << ")\n";
}
void WaypointMovementGenerator<Creature>::AddToWaypointPauseTime(int32 waitTimeDiff)
{
if (!i_nextMoveTime.Passed())
{
// Prevent <= 0, the code in Update requires to catch the change from moving to not moving
int32 newWaitTime = i_nextMoveTime.GetExpiry() + waitTimeDiff;
i_nextMoveTime.Reset(newWaitTime > 0 ? newWaitTime : 1);
}
}
bool WaypointMovementGenerator<Creature>::SetNextWaypoint(uint32 pointId)
{
if (!i_path || i_path->empty())
return false;
WaypointPath::const_iterator currPoint = i_path->find(pointId);
if (currPoint == i_path->end())
return false;
// Allow Moving with next tick
// Handle allow movement this way to not interact with PAUSED state.
// If this function is called while PAUSED, it will move properly when unpaused.
i_nextMoveTime.Reset(1);
m_isArrivalDone = false;
// Set the point
i_currentNode = pointId;
return true;
}
//----------------------------------------------------//
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
{
if (i_currentNode >= i_path->size())
return i_path->size();
uint32 curMapId = (*i_path)[i_currentNode].mapid;
for (uint32 i = i_currentNode; i < i_path->size(); ++i)
{
if ((*i_path)[i].mapid != curMapId)
return i;
}
return i_path->size();
}
void FlightPathMovementGenerator::Initialize(Player& player)
{
Reset(player);
}
void FlightPathMovementGenerator::Finalize(Player& player)
{
// remove flag to prevent send object build movement packets for flight state and crash (movement generator already not at top of stack)
player.clearUnitState(UNIT_STAT_TAXI_FLIGHT);
player.Unmount();
player.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
if (player.m_taxi.empty())
{
player.getHostileRefManager().setOnlineOfflineState(true);
if (player.pvpInfo.inHostileArea)
player.CastSpell(&player, 2479, true);
// update z position to ground and orientation for landing point
// this prevent cheating with landing point at lags
// when client side flight end early in comparison server side
player.StopMoving(true);
}
}
void FlightPathMovementGenerator::Interrupt(Player& player)
{
player.clearUnitState(UNIT_STAT_TAXI_FLIGHT);
}
#define PLAYER_FLIGHT_SPEED 32.0f
void FlightPathMovementGenerator::Reset(Player& player)
{
player.getHostileRefManager().setOnlineOfflineState(false);
player.addUnitState(UNIT_STAT_TAXI_FLIGHT);
player.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
Movement::MoveSplineInit init(player);
uint32 end = GetPathAtMapEnd();
for (uint32 i = GetCurrentNode(); i != end; ++i)
{
G3D::Vector3 vertice((*i_path)[i].x, (*i_path)[i].y, (*i_path)[i].z);
init.Path().push_back(vertice);
}
init.SetFirstPointId(GetCurrentNode());
init.SetFly();
init.SetVelocity(PLAYER_FLIGHT_SPEED);
init.Launch();
}
bool FlightPathMovementGenerator::Update(Player& player, const uint32& /*diff*/)
{
uint32 pointId = (uint32)player.movespline->currentPathIdx();
if (pointId > i_currentNode)
{
bool departureEvent = true;
do
{
DoEventIfAny(player, (*i_path)[i_currentNode], departureEvent);
if (pointId == i_currentNode)
break;
i_currentNode += (uint32)departureEvent;
departureEvent = !departureEvent;
}
while (true);
}
return i_currentNode < (i_path->size() - 1);
}
void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
{
if (i_path->empty())
return;
uint32 map0 = (*i_path)[0].mapid;
for (size_t i = 1; i < i_path->size(); ++i)
{
if ((*i_path)[i].mapid != map0)
{
i_currentNode = i;
return;
}
}
}
void FlightPathMovementGenerator::DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure)
{
if (uint32 eventid = departure ? node.departureEventID : node.arrivalEventID)
{
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player.GetName());
StartEvents_Event(player.GetMap(), eventid, &player, &player, departure);
}
}
bool FlightPathMovementGenerator::GetResetPosition(Player&, float& x, float& y, float& z, float& o) const
{
const TaxiPathNodeEntry& node = (*i_path)[i_currentNode];
x = node.x;
y = node.y;
z = node.z;
return true;
}
| Leadballoon2000/mangos-tbc | src/game/WaypointMovementGenerator.cpp | C++ | gpl-2.0 | 15,674 |
/* Copyright_License {
XCSoar Glide Computer - http://www.xcsoar.org/
Copyright (C) 2000-2014 The XCSoar Project
A detailed list of copyright holders can be found in the file "AUTHORS".
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.
}
*/
#ifndef AATISOLINESEGMENT_HPP
#define AATISOLINESEGMENT_HPP
#include "AATIsoline.hpp"
/**
* Specialisation of AATIsoline such that the segment of
* the isoline within the task point's observation zone is
* determined. This allows for parametric representation
* of all points along the isoline within the OZ.
*
* End-points of segments are searched for and so this
* class is slow to instantiate.
*/
class AATIsolineSegment: public AATIsoline
{
fixed t_up;
fixed t_down;
public:
/**
* Constructor. This performs the search for the isoline
* segment and so is slow.
*
* @param ap The AAT point for which the isoline is sought
*
* @return Initialised object
*/
AATIsolineSegment(const AATPoint &ap, const TaskProjection &projection);
/**
* Test whether segment is valid (nonzero length)
*
* @return True if segment is valid
*/
bool IsValid() const;
/**
* Parametric representation of points on the isoline segment.
*
* @param t Parameter (0,1)
*
* @return Location of point on isoline segment
*/
GeoPoint Parametric(const fixed t) const;
};
#endif
| CnZoom/XcSoarWork | src/Engine/Task/Ordered/AATIsolineSegment.hpp | C++ | gpl-2.0 | 2,037 |
<?php
/**
* @version $Id$
* @package WR PageBuilder
* @author WooRockets Team <support@www.woorockets.com>
* @copyright Copyright (C) 2012 www.woorockets.com. All Rights Reserved.
* @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
*
* Websites: http://www.www.woorockets.com
* Technical Support: Feedback - http://www.www.woorockets.com
*/
class WR_Pb_Helper_Html_Button_Group extends WR_Pb_Helper_Html {
/**
* Button group
* @param type $element
* @return string
*/
static function render( $element ) {
$element = parent::get_extra_info( $element );
$label = parent::get_label( $element );
$output = "<div class='btn-group'>
<a class='btn btn-default dropdown-toggle wr-dropdown-toggle' href='#'>
".__( 'Convert to', WR_PBL )."...
<span class='caret'></span>
</a>
<ul class='dropdown-menu'>";
foreach ( $element['actions'] as $action ) {
$output .= "<li><a href='#' data-action = '{$action["action"]}' data-action-type = '{$action["action_type"]}'>{$action['std']}</a></li>";
}
$output .= '</ul></div>';
return parent::final_element( $element, $output, $label );
}
} | SayenkoDesign/playground | wp-content/plugins/wr-pagebuilder/core/helper/html/button-group.php | PHP | gpl-2.0 | 1,161 |
/*
* Freeplane - mind map editor
* Copyright (C) 2008 Joerg Mueller, Daniel Polansky, Christian Foltin, Dimitry Polivaev
*
* This file is modified by Dimitry Polivaev in 2008.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
package org.freeplane.view.swing.map.cloud;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Stroke;
import java.util.LinkedList;
import java.util.Random;
import java.util.Vector;
import org.freeplane.features.cloud.CloudController;
import org.freeplane.features.cloud.CloudModel;
import org.freeplane.features.map.NodeModel;
import org.freeplane.view.swing.map.MapView;
import org.freeplane.view.swing.map.NodeView;
/**
* This class represents a Cloud around a node.
*/
abstract public class CloudView {
static final Stroke DEF_STROKE = new BasicStroke(1);
/** the layout functions can get the additional height of the clouded node .
* @param cloud */
static public int getAdditionalHeigth(CloudModel cloud, final NodeView source) {
final CloudView heightCalculator = new CloudViewFactory().createCloudView(cloud, source);
return (int) (2.2 * heightCalculator.getDistanceToConvexHull());
}
protected CloudModel cloudModel;
protected NodeView source;
private final int iterativeLevel;
private Random random;
CloudView(final CloudModel cloudModel, final NodeView source) {
this.cloudModel = cloudModel;
this.source = source;
iterativeLevel = getCloudIterativeLevel();
}
private int getCloudIterativeLevel() {
int iterativeLevel = 0;
for (NodeView parentNode = source.getParentView(); parentNode != null; parentNode = parentNode.getParentView()) {
if (null != parentNode.getCloudModel()) {
iterativeLevel++;
}
}
return iterativeLevel;
}
public Color getColor() {
return source.getCloudColor();
}
protected double getDistanceToConvexHull() {
return 20 / (getIterativeLevel() + 1) * getZoom();
}
public Color getExteriorColor(final Color color) {
return color.darker();
}
/**
* getIterativeLevel() describes the n-th nested cloud that is to be
* painted.
*/
protected int getIterativeLevel() {
return iterativeLevel;
}
protected MapView getMap() {
return source.getMap();
}
protected CloudModel getModel() {
return cloudModel;
}
/**
* Get the width in pixels rather than in width constant (like -1)
*/
public int getRealWidth() {
final int width = getWidth();
return (width < 1) ? 1 : width;
}
public Stroke getStroke() {
final int width = getWidth();
if (width < 1) {
return CloudView.DEF_STROKE;
}
return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
}
public int getWidth() {
final NodeModel node = source.getModel();
return CloudController.getController(source.getMap().getModeController()).getWidth(node);
}
protected double getZoom() {
return getMap().getZoom();
}
public void paint(final Graphics graphics) {
random = new Random(0);
final Graphics2D g = (Graphics2D) graphics.create();
final Graphics2D gstroke = (Graphics2D) g.create();
final Color color = getColor();
g.setColor(color);
/* set a bigger stroke to prevent not filled areas. */
g.setStroke(getStroke());
/* now bold */
gstroke.setColor(getExteriorColor(color));
gstroke.setStroke(getStroke());
/*
* calculate the distances between two points on the convex hull
* depending on the getIterativeLevel().
*/
/** get coordinates */
final LinkedList<Point> coordinates = new LinkedList<Point>();
source.getCoordinates(coordinates);
final ConvexHull hull = new ConvexHull();
final Vector<Point> res = hull.calculateHull(coordinates);
final Polygon p = new Polygon();
Point lastPt = null;
for (int i = 0; i < res.size(); ++i) {
final Point pt = (Point) res.get(i);
if(!pt.equals(lastPt)){
p.addPoint(pt.x, pt.y);
lastPt = pt;
}
}
final Point pt = (Point) res.get(0);
p.addPoint(pt.x, pt.y);
paintDecoration(p, g, gstroke);
g.dispose();
}
protected void paintDecoration(final Polygon p, Graphics2D g, Graphics2D gstroke){
fillPolygon(p, g);
double middleDistanceBetweenPoints = calcDistanceBetweenPoints();
final int[] xpoints = p.xpoints;
final int[] ypoints = p.ypoints;
final Point lastPoint = new Point(xpoints[0], ypoints[0]);
double x0, y0;
x0 = lastPoint.x;
y0 = lastPoint.y;
/* close the path: */
double x2, y2; /* the drawing start points. */
x2 = x0;
y2 = y0;
for (int i = p.npoints - 2; i >= 0; --i) {
final Point nextPoint = new Point(xpoints[i], ypoints[i]);
double x1, y1, x3, y3, dx, dy, dxn, dyn;
x1 = nextPoint.x;
y1 = nextPoint.y;
dx = x1 - x0; /* direction of p0 -> p1 */
dy = y1 - y0;
final double length = Math.sqrt(dx * dx + dy * dy);
dxn = dx / length; /* normalized direction of p0 -> p1 */
dyn = dy / length;
for (int j = 0;;) {
double distanceBetweenPoints = middleDistanceBetweenPoints * random(0.7);
if (j + 2* distanceBetweenPoints < length) {
j += distanceBetweenPoints;
x3 = x0 + j * dxn;
/* the drawing end point.*/
y3 = y0 + j * dyn;
}
else {
/* last point */
break;
}
paintDecoration(g, gstroke, x2, y2, x3, y3);
x2 = x3;
y2 = y3;
}
paintDecoration(g, gstroke, x2, y2, x1, y1);
x2 = x1;
y2 = y1;
x0 = x1;
y0 = y1;
}
}
protected void fillPolygon(final Polygon p, Graphics2D g) {
g.fillPolygon(p);
g.drawPolygon(p);
}
protected void paintDecoration(Graphics2D g, Graphics2D gstroke, double x0, double y0, double x1, double y1) {
double dx, dy;
dx = x1 - x0;
dy = y1 - y0;
final double length = Math.sqrt(dx * dx + dy * dy);
double dxn, dyn;
dxn = dx / length;
dyn = dy / length;
paintDecoration(g, gstroke, x0, y0, x1, y1, dx, dy, dxn, dyn);
}
abstract protected void paintDecoration(Graphics2D g, Graphics2D gstroke, double x0, double y0, double x1, double y1,
double dx, double dy, double dxn, double dyn);
protected double calcDistanceBetweenPoints() {
final double distanceBetweenPoints = getDistanceToConvexHull();
return distanceBetweenPoints;
}
protected double random(double min) {
return (min + (1-min) * random.nextDouble());
}
}
| fnatter/freeplane-debian-dev | freeplane/src/main/java/org/freeplane/view/swing/map/cloud/CloudView.java | Java | gpl-2.0 | 6,981 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script src="../../lib/prototype.js" type="text/javascript"></script>
<script src="../../src/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
Position.includeScrollOffsets = true;
Draggables.clear = function (event) {
while (Draggables.drags.length) {
var d = Draggables.drags.pop();
var e = d.element;
d.stopScrolling();
d.destroy();
d.element = null;
if (e.parentNode) {e.parentNode.removeChild(e)};
}
}
function cleanup() { //try to remove circular references
lis = document.getElementsByTagName("li");
for (i = 0; i < lis.length; i++) {
if (lis[i].longListItem) {lis[i].longListItem.destroy();}
else if (lis[i].container) {lis[i].container.destroy();}
}
Draggables.clear();
}
window.onload = function() {
var li = $("masterList").getElementsByTagName('LI');
for (var i = 0; i < li.length; i++) {
//var d = new LongListItem(li[i]);
//li[i].onmousedown = d.onMouseDown.bindAsEventListener(d);
var d = new Draggable(li[i],
{revert: true,
ghosting: false,
scroll: "rightContainers"
});
}
var divs = $("rightContainers").getElementsByTagName("div");
for (i = 0; i < divs.length; i++) {
if (divs[i].className && Element.hasClassName(divs[i], "container")) {
Droppables.add(divs[i].id, {hoverclass: "hover", scrollingParent: "rightContainers"});
}
}
Event.observe(window, 'unload', cleanup, false);
}
//]]>
</script>
<style type="text/css">
html, body {
margin:0; padding: 0;
height: 100% !important;
}
body {
position:relative;
color: black;
background-color: white;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: small;
}
h1 {font-size:115%;}
h2 {font-size: 110%;}
h3 {font-size: 105%;}
div, p, li, td {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: small;
}
p {margin: 0 0 .7em 0; padding:0;}
ul {
position:relative;
list-style: none;
margin:0; padding:0;
overflow: visible;
}
li {position:relative;}
.instructions {font-style:italic;}
#leftDiv {
position: absolute;
top: 0; left: 0; bottom: 0;
width: 30%;
margin: 0; padding: 7px;
border-right: 2px solid #bb9;
background-color: #eed;
}
#leftDiv li, #rightContainers div.container li {
margin: 3px 0; padding: 3px 3em 3px 10px;
border: 2px solid #456;
background-color: #cde;
cursor: move;
}
#rightContainers {
padding: .5em;
position: absolute;
top: 0; bottom: 0; right: 0; left: 35%;
overflow:auto;
}
#rightContainers div.container{
background-color: #bb9;
margin: 0 0 40px 0; padding: 0 0 1px 0;
border: 2px solid #775;
}
#rightContainers div.container h2{
margin:0; padding: 2px 1em 0 1em;
text-align:center;
}
#rightContainers div.container ul {
margin: 5px; padding: 0 3px;
background-color: white;
border: 1px solid black;
}
#rightContainers div.container ul.empty {
padding: 3px 0;
}
#rightContainers div.hover {
background-color: #eed;
}
</style>
<!--[if IE]><style type="text/css">
#leftDiv {
height: expression((document.body.clientHeight - 44) + "px");
}
#leftDiv ul{width:93%;}
#leftDiv li div.count {
right:4px;
top:4px;
}
#rightContainers li a.remove {
display:block;
float:none;
position:absolute;
top: 4px;
right: 1.6em;
margin:0; padding:0 .2em;
}
</style><![endif]-->
</head>
<body>
<div id="leftDiv" class="">
<form id="frmContinue" action="#" method="post">
<p class="instructions">Shrink your window until the right-hand pane is scrollable.</p>
<p class="instructions">Drag from the list on left to groups on the right, force the right-hand pane to scroll.</p>
<input name="data" type="hidden" value=" ">
</form>
<ul id="masterList">
<li id="drag1">One</li>
<li id="drag2">Two</li>
<li id="drag3">Three</li>
<li id="drag4">Four</li>
<li id="drag5">Five</li>
<li id="drag6">Six</li>
<li id="drag7">Seven</li>
<li id="drag8">Eight</li>
</ul>
</div>
<div id="rightContainers" class="">
</form>
<div id="grp1" class="container">
<h2><span id="grp1_name">Group 1</span></h2>
<ul id="grp1ul" class="empty"></ul>
</div>
<div id="grp2" class="container">
<h2><span id="grp2_name">Group 2</span></h2>
<ul id="grp2ul" class="empty"></ul>
</div>
<div id="grp3" class="container">
<h2><span id="grp3_name">Group 3</span></h2>
<ul id="grp3ul" class="empty"></ul>
</div>
<div id="grp4" class="container">
<h2><span id="grp4_name">Group 4</span></h2>
<ul id="grp4ul" class="empty"></ul>
</div>
<div id="grp5" class="container">
<h2><span id="grp5_name">Group 5</span></h2>
<ul id="grp5ul" class="empty"></ul>
</div>
<div id="grp6" class="container">
<h2><span id="grp6_name">Group 6</span></h2>
<ul id="grp6ul" class="empty"></ul>
</div>
<div id="grp7" class="container">
<h2><span id="grp7_name">Group 7</span></h2>
<ul id="grp7ul" class="empty"></ul>
</div>
<div id="grp8" class="container">
<h2><span id="grp8_name">Group 8</span></h2>
<ul id="grp8ul" class="empty"></ul>
</div>
<div id="grp9" class="container">
<h2><span id="grp9_name">Group 9</span></h2>
<ul id="grp9ul" class="empty"></ul>
</div>
</div>
</body>
</html> | nikhilsharma869/bio-pharma-dev | scriptaculous/test/functional/dragdrop7_test.html | HTML | gpl-2.0 | 5,404 |
#ifndef UNCALI_ACCHUB_H
#define UNCALI_ACCHUB_H
#include <linux/ioctl.h>
#endif
| Alberto96/android_kernel_ulefone_k11ta_a | drivers/misc/mediatek/uncali_acc/uncali_acchub/uncali_acchub.h | C | gpl-2.0 | 82 |
#ifndef __INPUT_FORMATTER_LOCAL_H_INCLUDED__
#define __INPUT_FORMATTER_LOCAL_H_INCLUDED__
#include "input_formatter_global.h"
#include "isp.h" /* ISP_VEC_ALIGN */
typedef struct input_formatter_state_s input_formatter_state_t;
#define HIVE_IF_FSM_SYNC_STATUS 0x100
#define HIVE_IF_FSM_SYNC_COUNTER 0x104
#define HIVE_IF_FSM_CROP_STATUS 0x108
#define HIVE_IF_FSM_CROP_LINE_COUNTER 0x10C
#define HIVE_IF_FSM_CROP_PIXEL_COUNTER 0x110
#define HIVE_IF_FSM_DEINTERLEAVING_IDX 0x114
#define HIVE_IF_FSM_DECIMATION_H_COUNTER 0x118
#define HIVE_IF_FSM_DECIMATION_V_COUNTER 0x11C
#define HIVE_IF_FSM_DECIMATION_BLOCK_V_COUNTER 0x120
#define HIVE_IF_FSM_PADDING_STATUS 0x124
#define HIVE_IF_FSM_PADDING_ELEMENT_COUNTER 0x128
#define HIVE_IF_FSM_VECTOR_SUPPORT_ERROR 0x12C
#define HIVE_IF_FSM_VECTOR_SUPPORT_BUFF_FULL 0x130
#define HIVE_IF_FSM_VECTOR_SUPPORT 0x134
#define HIVE_IF_FIFO_SENSOR_STATUS 0x138
struct input_formatter_state_s {
/* int reset; */
int start_line;
int start_column;
int cropped_height;
int cropped_width;
int ver_decimation;
int hor_decimation;
int deinterleaving;
int left_padding;
int eol_offset;
int vmem_start_address;
int vmem_end_address;
int vmem_increment;
int is_yuv420;
int vsync_active_low;
int hsync_active_low;
int allow_fifo_overflow;
int fsm_sync_status;
int fsm_sync_counter;
int fsm_crop_status;
int fsm_crop_line_counter;
int fsm_crop_pixel_counter;
int fsm_deinterleaving_index;
int fsm_dec_h_counter;
int fsm_dec_v_counter;
int fsm_dec_block_v_counter;
int fsm_padding_status;
int fsm_padding_elem_counter;
int fsm_vector_support_error;
int fsm_vector_buffer_full;
int vector_support;
int sensor_data_lost;
};
static const unsigned int input_formatter_alignment[N_INPUT_FORMATTER_ID] = {
ISP_VEC_ALIGN, ISP_VEC_ALIGN, HIVE_ISP_CTRL_DATA_BYTES};
#endif /* __INPUT_FORMATTER_LOCAL_H_INCLUDED__ */
| nels83/android_kernel_samsung_santos10 | drivers/media/video/atomisp2/css2400/hive_isp_css_2400_system/host/input_formatter_local.h | C | gpl-2.0 | 2,011 |
<?php
/**
* @package com.jpexs.image.bmp
*
* JPEXS ICO Image functions
* @version 2.1
* @author JPEXS
* @copyright (c) JPEXS 2004-2009
*
* Webpage: http://www.jpexs.com
* Email: jpexs@jpexs.com
*
* If you like my script, you can donate... visit my webpages or email me for more info.
*
* Version changes:
* v2.1 - redesigned sourcecode, phpdoc included, all internal functions and global variables have prefix "jpexs_"
* v2.0 - For icons with Alpha channel now you can set background color
* - ImageCreateFromExeIco added
* - Fixed ICO_MAX_SIZE and ICO_MAX_COLOR values
*
* TODO list:
* - better error handling
* - class encapsulation
* License:
* - you can freely use it
* - you can freely distribute sourcecode
* - you can freely modify it as long as you leave my copyright/author info in source code
* - if you developing closesource application, you should add my name at least to "about" page of your web application
* - if you create an amazing modification, please contact me... I can publish link to your webpage if you're interested...
* - if you want to use my script in commercial application for earning money, you should make a donation to me first
*/
/** TrueColor images constant */
define("ICO_TRUE_COLOR", 0x1000000);
/** XPColor images constant (Alpha channel) */
define("ICO_XP_COLOR", 4294967296);
/** Image with maximum colors */
define("ICO_MAX_COLOR", -2);
/** Image with maximal size */
define("ICO_MAX_SIZE", -2);
/** TrueColor images constant
* @deprecated Deprecated since version 2.1, please use ICO_ constants
*/
define("TRUE_COLOR", 0x1000000);
/** XPColor images constant (Alpha channel)
* @deprecated Deprecated since version 2.1, please use ICO_ constants
*/
define("XP_COLOR", 4294967296);
/** Image with maximum colors
* @deprecated Deprecated since version 2.1, please use ICO_ constants
*/
define("MAX_COLOR", -2);
/** Image with maximal size
* @deprecated Deprecated since version 2.1, please use ICO_ constants
*/
define("MAX_SIZE", -2);
/**
* Reads image from a ICO file
*
* @param string $filename Target ico file to load
* @param int $icoColorCount Icon color count (For multiple icons ico file) - 2,16,256, ICO_TRUE_COLOR, ICO_XP_COLOR or ICO_MAX_COLOR
* @param int $icoSize Icon width (For multiple icons ico file) or ICO_MAX_SIZE
* @param int $alphaBgR Background color R value for alpha-channel images (Default is White)
* @param int $alphaBgG Background color G value for alpha-channel images (Default is White)
* @param int $alphaBgB Background color B value for alpha-channel images (Default is White)
* @return resource Image resource
*/
function imageCreateFromIco($filename,$icoColorCount=16,$icoSize=16,$alphaBgR=255,$alphaBgG=255,$alphaBgB=255)
{
$Ikona=jpexs_GetIconsInfo($filename);
$IconID=-1;
$ColMax=-1;
$SizeMax=-1;
for($p=0;$p<count($Ikona);$p++)
{
$Ikona[$p]["NumberOfColors"]=pow(2,$Ikona[$p]["Info"]["BitsPerPixel"]);
};
for($p=0;$p<count($Ikona);$p++)
{
if(($ColMax==-1)or($Ikona[$p]["NumberOfColors"]>=$Ikona[$ColMax]["NumberOfColors"]))
if(($icoSize==$Ikona[$p]["Width"])or($icoSize==ICO_MAX_SIZE))
{
$ColMax=$p;
};
if(($SizeMax==-1)or($Ikona[$p]["Width"]>=$Ikona[$SizeMax]["Width"]))
if(($icoColorCount==$Ikona[$p]["NumberOfColors"])or($icoColorCount==ICO_MAX_COLOR))
{
$SizeMax=$p;
};
if($Ikona[$p]["NumberOfColors"]==$icoColorCount)
if($Ikona[$p]["Width"]==$icoSize)
{
$IconID=$p;
};
};
if($icoColorCount==ICO_MAX_COLOR) $IconID=$ColMax;
if($icoSize==ICO_MAX_SIZE) $IconID=$SizeMax;
$ColName=$icoColorCount;
if($icoSize==ICO_MAX_SIZE) $icoSize="Max";
if($ColName==ICO_TRUE_COLOR) $ColName="True";
if($ColName==ICO_XP_COLOR) $ColName="XP";
if($ColName==ICO_MAX_COLOR) $ColName="Max";
if($IconID==-1) die("Icon with $ColName colors and $icoSize x $icoSize size doesn't exist in this file!");
jpexs_readIcon($filename,$IconID,$Ikona);
$biBitCount=$Ikona[$IconID]["Info"]["BitsPerPixel"];
if($Ikona[$IconID]["Info"]["BitsPerPixel"]==0)
{
$Ikona[$IconID]["Info"]["BitsPerPixel"]=24;
};
$biBitCount=$Ikona[$IconID]["Info"]["BitsPerPixel"];
if($biBitCount==0) $biBitCount=1;
$Ikona[$IconID]["BitCount"]=$Ikona[$IconID]["Info"]["BitsPerPixel"];
if($Ikona[$IconID]["BitCount"]>=24)
{
$img=imagecreatetruecolor($Ikona[$IconID]["Width"],$Ikona[$IconID]["Height"]);
if($Ikona[$IconID]["BitCount"]==32):
$backcolor=imagecolorallocate($img,$alphaBgR,$alphaBgG,$alphaBgB);
imagefilledrectangle($img,0,0,$Ikona[$IconID]["Width"]-1,$Ikona[$IconID]["Height"]-1,$backcolor);
endif;
for($y=0;$y<$Ikona[$IconID]["Height"];$y++)
for($x=0;$x<$Ikona[$IconID]["Width"];$x++)
{
$R=$Ikona[$IconID]["Data"][$x][$y]["r"];
$G=$Ikona[$IconID]["Data"][$x][$y]["g"];
$B=$Ikona[$IconID]["Data"][$x][$y]["b"];
if($Ikona[$IconID]["BitCount"]==32)
{
$Alpha=127-round($Ikona[$IconID]["Data"][$x][$y]["alpha"]*127/255);
if($Ikona[$IconID]["Maska"][$x][$y]==1) $Alpha=127;
$color=imagecolorexactalpha($img,$R,$G,$B,$Alpha);
if($color==-1) $color=imagecolorallocatealpha($img,$R,$G,$B,$Alpha);
}
else
{
$color=imagecolorexact($img,$R,$G,$B);
if($color==-1) $color=imagecolorallocate($img,$R,$G,$B);
};
imagesetpixel($img,$x,$y,$color);
};
}
else
{
$img=imagecreate($Ikona[$IconID]["Width"],$Ikona[$IconID]["Height"]);
for($p=0;$p<count($Ikona[$IconID]["Paleta"]);$p++)
$Paleta[$p]=imagecolorallocate($img,$Ikona[$IconID]["Paleta"][$p]["r"],$Ikona[$IconID]["Paleta"][$p]["g"],$Ikona[$IconID]["Paleta"][$p]["b"]);
for($y=0;$y<$Ikona[$IconID]["Height"];$y++)
for($x=0;$x<$Ikona[$IconID]["Width"];$x++)
{
imagesetpixel($img,$x,$y,$Paleta[$Ikona[$IconID]["Data"][$x][$y]]);
};
};
$IsTransparent=false;
for($y=0;$y<$Ikona[$IconID]["Height"];$y++)
for($x=0;$x<$Ikona[$IconID]["Width"];$x++)
if($Ikona[$IconID]["Maska"][$x][$y]==1)
{
$IsTransparent=true;
break;
};
if($Ikona[$IconID]["BitCount"]==32)
{
imagealphablending($img, false);
if(function_exists("imagesavealpha"))
imagesavealpha($img,true);
};
if($IsTransparent)
{
if(($Ikona[$IconID]["BitCount"]>=24)or(imagecolorstotal($img)>=256))
{
$img2=imagecreatetruecolor(imagesx($img),imagesy($img));
imagecopy($img2,$img,0,0,0,0,imagesx($img),imagesy($img));
imagedestroy($img);
$img=$img2;
imagetruecolortopalette($img,true,255);
};
$Pruhledna=imagecolorallocate($img,0,0,0);
for($y=0;$y<$Ikona[$IconID]["Height"];$y++)
for($x=0;$x<$Ikona[$IconID]["Width"];$x++)
if($Ikona[$IconID]["Maska"][$x][$y]==1)
{
imagesetpixel($img,$x,$y,$Pruhledna);
};
imagecolortransparent($img,$Pruhledna);
};
return $img;
};
function jpexs_readIcon($filename,$id,&$Ikona)
{
global $jpexs_currentBit;
$f=fopen($filename,"rb");
fseek($f,6+$id*16);
$Width=jpexs_freadbyte($f);
$Height=jpexs_freadbyte($f);
fseek($f,6+$id*16+12);
$OffSet=jpexs_freaddword($f);
fseek($f,$OffSet);
$p=$id;
$Ikona[$p]["Info"]["HeaderSize"]=jpexs_freadlngint($f);
$Ikona[$p]["Info"]["ImageWidth"]=jpexs_freadlngint($f);
$Ikona[$p]["Info"]["ImageHeight"]=jpexs_freadlngint($f);
$Ikona[$p]["Info"]["NumberOfImagePlanes"]=jpexs_freadword($f);
$Ikona[$p]["Info"]["BitsPerPixel"]=jpexs_freadword($f);
$Ikona[$p]["Info"]["CompressionMethod"]=jpexs_freadlngint($f);
$Ikona[$p]["Info"]["SizeOfBitmap"]=jpexs_freadlngint($f);
$Ikona[$p]["Info"]["HorzResolution"]=jpexs_freadlngint($f);
$Ikona[$p]["Info"]["VertResolution"]=jpexs_freadlngint($f);
$Ikona[$p]["Info"]["NumColorUsed"]=jpexs_freadlngint($f);
$Ikona[$p]["Info"]["NumSignificantColors"]=jpexs_freadlngint($f);
$biBitCount=$Ikona[$p]["Info"]["BitsPerPixel"];
if($Ikona[$p]["Info"]["BitsPerPixel"]<=8)
{
$barev=pow(2,$biBitCount);
for($b=0;$b<$barev;$b++)
{
$Ikona[$p]["Paleta"][$b]["b"]=jpexs_freadbyte($f);
$Ikona[$p]["Paleta"][$b]["g"]=jpexs_freadbyte($f);
$Ikona[$p]["Paleta"][$b]["r"]=jpexs_freadbyte($f);
jpexs_freadbyte($f);
};
$Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4;
for($y=$Height-1;$y>=0;$y--)
{
$jpexs_currentBit=0;
for($x=0;$x<$Width;$x++)
{
$C=jpexs_freadbits($f,$biBitCount);
$Ikona[$p]["Data"][$x][$y]=$C;
};
if($jpexs_currentBit!=0) {jpexs_freadbyte($f);};
for($g=0;$g<$Zbytek;$g++)
jpexs_freadbyte($f);
};
}
elseif($biBitCount==24)
{
$Zbytek=$Width%4;
for($y=$Height-1;$y>=0;$y--)
{
for($x=0;$x<$Width;$x++)
{
$B=jpexs_freadbyte($f);
$G=jpexs_freadbyte($f);
$R=jpexs_freadbyte($f);
$Ikona[$p]["Data"][$x][$y]["r"]=$R;
$Ikona[$p]["Data"][$x][$y]["g"]=$G;
$Ikona[$p]["Data"][$x][$y]["b"]=$B;
}
for($z=0;$z<$Zbytek;$z++)
jpexs_freadbyte($f);
};
}
elseif($biBitCount==32)
{
$Zbytek=$Width%4;
for($y=$Height-1;$y>=0;$y--)
{
for($x=0;$x<$Width;$x++)
{
$B=jpexs_freadbyte($f);
$G=jpexs_freadbyte($f);
$R=jpexs_freadbyte($f);
$Alpha=jpexs_freadbyte($f);
$Ikona[$p]["Data"][$x][$y]["r"]=$R;
$Ikona[$p]["Data"][$x][$y]["g"]=$G;
$Ikona[$p]["Data"][$x][$y]["b"]=$B;
$Ikona[$p]["Data"][$x][$y]["alpha"]=$Alpha;
}
for($z=0;$z<$Zbytek;$z++)
jpexs_freadbyte($f);
};
};
//Maska
$Zbytek=(4-ceil(($Width/(8)))%4)%4;
for($y=$Height-1;$y>=0;$y--)
{
$jpexs_currentBit=0;
for($x=0;$x<$Width;$x++)
{
$C=jpexs_freadbits($f,1);
$Ikona[$p]["Maska"][$x][$y]=$C;
};
if($jpexs_currentBit!=0) {jpexs_freadbyte($f);};
for($g=0;$g<$Zbytek;$g++)
jpexs_freadbyte($f);
};
//--------------
fclose($f);
};
function jpexs_GetIconsInfo($filename)
{
global $jpexs_currentBit;
$f=fopen($filename,"rb");
$Reserved=jpexs_freadword($f);
$Type=jpexs_freadword($f);
$Count=jpexs_freadword($f);
for($p=0;$p<$Count;$p++)
{
$Ikona[$p]["Width"]=jpexs_freadbyte($f);
$Ikona[$p]["Height"]=jpexs_freadbyte($f);
$Ikona[$p]["ColorCount"]=jpexs_freadword($f);
if($Ikona[$p]["ColorCount"]==0) $Ikona[$p]["ColorCount"]=256;
$Ikona[$p]["Planes"]=jpexs_freadword($f);
$Ikona[$p]["BitCount"]=jpexs_freadword($f);
$Ikona[$p]["BytesInRes"]=jpexs_freaddword($f);
$Ikona[$p]["ImageOffset"]=jpexs_freaddword($f);
};
if(!feof($f)):
for($p=0;$p<$Count;$p++)
{
fseek($f,$Ikona[$p]["ImageOffset"]+14);
$Ikona[$p]["Info"]["BitsPerPixel"]=jpexs_freadword($f);
};
endif;
fclose($f);
return $Ikona;
};
/**
* Reads image from a icon in exe file
* @param string $filename Target exefile
* @param int $icoIndex Index of the icon in exefile
* @param int $icoColorCount Icon color count (For multiple icons ico file) - 2,16,256, ICO_TRUE_COLOR, ICO_XP_COLOR or ICO_MAX_COLOR
* @param int $icoSize Icon width (For multiple icons ico file) or ICO_MAX_SIZE
* @param int $alphaBgR Background color R value for alpha-channel images (Default is White)
* @param int $alphaBgG Background color G value for alpha-channel images (Default is White)
* @param int $alphaBgB Background color B value for alpha-channel images (Default is White)
* @return resource Image resource or false on error
*/
function imageCreateFromExeIco($filename,$icoIndex,$icoColorCount=16,$icoSize=16,$alphaBgR=255,$alphaBgG=255,$alphaBgB=255)
{
$ok=saveExeIcon($filename,"icotemp.dat",$icoIndex);
if(!$ok):
$im=false;
else:
$im=imageCreateFromIco("icotemp.dat",$icoColorCount,$icoSize,$alphaBgR,$alphaBgG,$alphaBgB);
unlink("icotemp.dat");
endif;
return $im;
};
/**
* Saves icon(s) from the exe file
* @global int $jpexs_StartOfRsrc Internal reserved variable
* @global int $jpexs_ImageBase Internal reserved variable
* @global int $jpexs_ResVirtualAddress Internal reserved variable
* @param string $filename Target exefile
* @param string $icoFileNameOrPath Filename to save ico or path (Default "") Path if you want more than 1 icon. If "", the filename is "$icoIndex.ico"
* @param int|array $iconIndex Index(es) of the icon in exefile (Default -1) If -1, all icons are saved, Can be an array of indexes.
* @return boolean True on successful save
*/
function saveExeIcon($filename,$icoFileNameOrPath="",$iconIndex=-1) /*-1 for all,or can be array*/
{
global $jpexs_f,$jpexs_StartOfRsrc,$jpexs_ImageBase,$jpexs_ResVirtualAddress;
$jpexs_f=fopen($filename,"r");
$MZ=fread($jpexs_f,2);
if($MZ!="MZ") NotValidExe();
fseek($jpexs_f,60);
$OffsetToNewHeader=jpexs_freaddword($jpexs_f);
fseek($jpexs_f,$OffsetToNewHeader);
$PE=fread($jpexs_f,2);
if($PE!="PE") NotValidExe();
fread($jpexs_f,4);
$NumberOfSections=jpexs_freadword($jpexs_f);
fseek($jpexs_f,ftell($jpexs_f)+12);
$SizeOfOptionalHeader=jpexs_freadword($jpexs_f);
$PosMagic=ftell($jpexs_f)+2;
fseek($jpexs_f,$PosMagic+$SizeOfOptionalHeader);
for($p=0;$p<$NumberOfSections;$p++):
$SectionName[$p]=trim(fread($jpexs_f,8));
$VirtualSize[$p]=jpexs_freaddword($jpexs_f);
$VirtualAddress[$p]=jpexs_freaddword($jpexs_f);
$PhysicalSize[$p]=jpexs_freaddword($jpexs_f);
$PhysicalOffset[$p]=jpexs_freaddword($jpexs_f);
fread($jpexs_f,16);
if($SectionName[$p]==".rsrc"):
$jpexs_ResVirtualAddress=$VirtualAddress[$p];
fseek($jpexs_f,$PhysicalOffset[$p]);
$jpexs_StartOfRsrc=$PhysicalOffset[$p];
jpexs_readResDirectoryEntry($R,$PhysicalOffset[$p]);
$IconCount=null;
$Ikona=null;
while (list ($key, $val) = each ($R["Subdir"])):
if($key==14):
$r=0;
while (list ($key2, $val2) = each ($R["Subdir"][$key]["Subdir"])):
while (list ($key3, $val3) = each ($R["Subdir"][$key]["Subdir"][$key2]["Subdir"])):
fseek($jpexs_f,$val3["DataOffset"]);
$Reserved=jpexs_freadword($jpexs_f);
$Type=jpexs_freadword($jpexs_f);
$ic=jpexs_freadword($jpexs_f);
$IconCount[]=$ic;
for($s=0;$s<$ic;$s++)
{
$Ikona[$r][$s]["Width"]=jpexs_freadbyte($jpexs_f);
$Ikona[$r][$s]["Height"]=jpexs_freadbyte($jpexs_f);
$Ikona[$r][$s]["ColorCount"]=jpexs_freadword($jpexs_f);
$Ikona[$r][$s]["Planes"]=jpexs_freadword($jpexs_f);
$Ikona[$r][$s]["BitCount"]=jpexs_freadword($jpexs_f);
$Ikona[$r][$s]["BytesInRes"]=jpexs_freaddword($jpexs_f);
$Ikona[$r][$s]["IconId"]=jpexs_freadword($jpexs_f);
};
fseek($jpexs_f,$val3["DataOffset"]);
$r++;
endwhile;
endwhile;
endif;
endwhile;
reset ($R["Subdir"]);
while (list ($key, $val) = each ($R["Subdir"])):
if($key==3):
while (list ($key2, $val2) = each ($R["Subdir"][$key]["Subdir"])):
for($r=0;$r<count($Ikona);$r++):
for($s=0;$s<count($Ikona[$r]);$s++):
while (list ($key3, $val3) = each ($R["Subdir"][$key]["Subdir"][$Ikona[$r][$s]["IconId"]]["Subdir"])):
if(($iconIndex==$r)or($iconIndex==-1)or((is_array($iconIndex))and(in_array($r,$iconIndex)))):
fseek($jpexs_f,$val3["DataOffset"]);
$Ikona[$r][$s]["Data"]=fread($jpexs_f,$val3["DataSize"]);
$Ikona[$r][$s]["DataSize"]=$val3["DataSize"];
endif;
endwhile;
endfor;
endfor;
endwhile;
endif;
endwhile;
$ok=false;
for($r=0;$r<count($Ikona);$r++):
if(($iconIndex==$r)or($iconIndex==-1)or((is_array($iconIndex))and(in_array($r,$iconIndex)))):
$savefile=$icoFileNameOrPath;
if($icoFileNameOrPath=="")
{
$savefile="$r.ico";
}
else
{
if(($iconIndex==-1)or(is_array($iconIndex)))
$savefile=$icoFileNameOrPath."$r.ico";
};
$f2=fopen($savefile,"w");
fwrite($f2,jpexs_inttoword(0));
fwrite($f2,jpexs_inttoword(1));
fwrite($f2,jpexs_inttoword(count($Ikona[$r])));
$Offset=6+16*count($Ikona[$r]);
for($s=0;$s<count($Ikona[$r]);$s++):
fwrite($f2,jpexs_inttobyte($Ikona[$r][$s]["Width"]));
fwrite($f2,jpexs_inttobyte($Ikona[$r][$s]["Height"]));
fwrite($f2,jpexs_inttoword($Ikona[$r][$s]["ColorCount"]));
fwrite($f2,jpexs_inttoword($Ikona[$r][$s]["Planes"]));
fwrite($f2,jpexs_inttoword($Ikona[$r][$s]["BitCount"]));
fwrite($f2,jpexs_inttodword($Ikona[$r][$s]["BytesInRes"]));
fwrite($f2,jpexs_inttodword($Offset));
$Offset+=$Ikona[$r][$s]["DataSize"];
endfor;
for($s=0;$s<count($Ikona[$r]);$s++):
fwrite($f2,$Ikona[$r][$s]["Data"]);
endfor;
fclose($f2);
$ok=true;
endif;
endfor;
return $ok;
endif;
endfor;
fclose($jpexs_f);
};
/**
* Internal function for reading exe icons
*/
function jpexs_readResDirectoryEntry(&$parentRes,$offset)
{
global $jpexs_f,$jpexs_StartOfRsrc,$jpexs_ImageBase,$jpexs_ResVirtualAddress;
$lastPos=ftell($jpexs_f);
$Res=null;
fseek($jpexs_f,$offset);
//IMAGE_RESOURCE_DIRECTORY
$Characteristics=jpexs_freaddword($jpexs_f);
$TimeDateStamp=jpexs_freaddword($jpexs_f);
$MajorVersion=jpexs_freadword($jpexs_f);
$MinorVersion=jpexs_freadword($jpexs_f);
$NumberOfNamedEntries=jpexs_freadword($jpexs_f);
$NumberOfIdEntries=jpexs_freadword($jpexs_f);
for($q=0;$q<$NumberOfNamedEntries+$NumberOfIdEntries;$q++):
//IMAGE_RESOURCE_DIRECTORY_ENTRY
$ResName=jpexs_freaddword($jpexs_f);
$lastPos2=ftell($jpexs_f);
if($ResName>=0x80000000):
//String Name
$ResNameOffset=$ResName-0x80000000;
fseek($jpexs_f,$jpexs_StartOfRsrc+$ResNameOffset);
$StringLength=jpexs_freadword($jpexs_f);
$Identificator=(fread($jpexs_f,$StringLength*2));
fseek($jpexs_f,$lastPos2);
else:
//Integer Id
$Identificator=$ResName;
endif;
$ResOffsetToData=jpexs_freaddword($jpexs_f);
if($ResOffsetToData>=0x80000000):
$SubResOffset=$ResOffsetToData-0x80000000;
jpexs_readResDirectoryEntry($Res["$Identificator"],$jpexs_StartOfRsrc+$SubResOffset);
else:
$RawDataOffset=$ResOffsetToData;
$lastPos2=ftell($jpexs_f);
fseek($jpexs_f,$jpexs_StartOfRsrc+$RawDataOffset);
//IMAGE_RESOURCE_DATA_ENTRY
$OffsetToData=jpexs_freaddword($jpexs_f);
$Res["$Identificator"]["DataOffset"]=$jpexs_StartOfRsrc-$jpexs_ResVirtualAddress+$OffsetToData;
$Res["$Identificator"]["DataSize"]=jpexs_freaddword($jpexs_f);
$CodePage=jpexs_freaddword($jpexs_f);
$Reserved=jpexs_freaddword($jpexs_f);
fseek($jpexs_f,$lastPos2);
endif;
endfor;
fseek($jpexs_f,$lastPos);
$parentRes["Subdir"]=$Res;
};
/**
* Creates ico file from image resource(s)
* @param resource|array $images Target Image resource (Can be array of image resources)
* @param string $filename Target ico file to save icon to, If ommited or "", image is written to snadard output - use header("Content-type: image/x-icon"); */
function imageIco($images,$filename="")
{
if(is_array($images))
{
$ImageCount=count($images);
$Image=$images;
}
else
{
$Image[0]=$images;
$ImageCount=1;
};
$WriteToFile=false;
if($filename!="")
{
$WriteToFile=true;
};
$ret="";
$ret.=jpexs_inttoword(0); //PASSWORD
$ret.=jpexs_inttoword(1); //SOURCE
$ret.=jpexs_inttoword($ImageCount); //ICONCOUNT
for($q=0;$q<$ImageCount;$q++)
{
$img=$Image[$q];
$Width=imagesx($img);
$Height=imagesy($img);
$ColorCount=imagecolorstotal($img);
$Transparent=imagecolortransparent($img);
$IsTransparent=$Transparent!=-1;
if($IsTransparent) $ColorCount--;
if($ColorCount==0) {$ColorCount=0; $BitCount=24;};
if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;};
if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;};
if(($ColorCount>16)and($ColorCount<=256)) { $ColorCount=0; $BitCount=8;};
//ICONINFO:
$ret.=jpexs_inttobyte($Width);//
$ret.=jpexs_inttobyte($Height);//
$ret.=jpexs_inttobyte($ColorCount);//
$ret.=jpexs_inttobyte(0);//RESERVED
$Planes=0;
if($BitCount>=8) $Planes=1;
$ret.=jpexs_inttoword($f,$Planes);//PLANES
if($BitCount>=8) $WBitCount=$BitCount;
if($BitCount==4) $WBitCount=0;
if($BitCount==1) $WBitCount=0;
$ret.=jpexs_inttoword($WBitCount);//BITS
$Zbytek=(4-($Width/(8/$BitCount))%4)%4;
$ZbytekMask=(4-($Width/8)%4)%4;
$PalSize=0;
$Size=40+($Width/(8/$BitCount)+$Zbytek)*$Height+(($Width/8+$ZbytekMask) * $Height);
if($BitCount<24)
$Size+=pow(2,$BitCount)*4;
$IconId=1;
$ret.=jpexs_inttodword($Size); //SIZE
$OffSet=6+16*$ImageCount+$FullSize;
$ret.=jpexs_inttodword(6+16*$ImageCount+$FullSize);//OFFSET
$FullSize+=$Size;
//-------------
};
for($q=0;$q<$ImageCount;$q++)
{
$img=$Image[$q];
$Width=imagesx($img);
$Height=imagesy($img);
$ColorCount=imagecolorstotal($img);
$Transparent=imagecolortransparent($img);
$IsTransparent=$Transparent!=-1;
if($IsTransparent) $ColorCount--;
if($ColorCount==0) {$ColorCount=0; $BitCount=24;};
if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;};
if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;};
if(($ColorCount>16)and($ColorCount<=256)) { $ColorCount=0; $BitCount=8;};
//ICONS
$ret.=jpexs_inttodword(40);//HEADSIZE
$ret.=jpexs_inttodword($Width);//
$ret.=jpexs_inttodword(2*$Height);//
$ret.=jpexs_inttoword(1); //PLANES
$ret.=jpexs_inttoword($BitCount); //
$ret.=jpexs_inttodword(0);//Compress method
$ZbytekMask=($Width/8)%4;
$Zbytek=($Width/(8/$BitCount))%4;
$Size=($Width/(8/$BitCount)+$Zbytek)*$Height+(($Width/8+$ZbytekMask) * $Height);
$ret.=jpexs_inttodword($Size);//SIZE
$ret.=jpexs_inttodword(0);//HPIXEL_M
$ret.=jpexs_inttodword(0);//V_PIXEL_M
$ret.=jpexs_inttodword($ColorCount); //UCOLORS
$ret.=jpexs_inttodword(0); //DCOLORS
//---------------
$CC=$ColorCount;
if($CC==0) $CC=256;
if($BitCount<24)
{
$ColorTotal=imagecolorstotal($img);
if($IsTransparent) $ColorTotal--;
for($p=0;$p<$ColorTotal;$p++)
{
$color=imagecolorsforindex($img,$p);
$ret.=jpexs_inttobyte($color["blue"]);
$ret.=jpexs_inttobyte($color["green"]);
$ret.=jpexs_inttobyte($color["red"]);
$ret.=jpexs_inttobyte(0); //RESERVED
};
$CT=$ColorTotal;
for($p=$ColorTotal;$p<$CC;$p++)
{
$ret.=jpexs_inttobyte(0);
$ret.=jpexs_inttobyte(0);
$ret.=jpexs_inttobyte(0);
$ret.=jpexs_inttobyte(0); //RESERVED
};
};
if($BitCount<=8)
{
for($y=$Height-1;$y>=0;$y--)
{
$bWrite="";
for($x=0;$x<$Width;$x++)
{
$color=imagecolorat($img,$x,$y);
if($color==$Transparent)
$color=imagecolorexact($img,0,0,0);
if($color==-1) $color=0;
if($color>pow(2,$BitCount)-1) $color=0;
$bWrite.=jpexs_decbinx($color,$BitCount);
if(strlen($bWrite)==8)
{
$ret.=jpexs_inttobyte(bindec($bWrite));
$bWrite="";
};
};
if((strlen($bWrite)<8)and(strlen($bWrite)!=0))
{
$sl=strlen($bWrite);
for($t=0;$t<8-$sl;$t++)
$sl.="0";
$ret.=jpexs_inttobyte(bindec($bWrite));
};
for($z=0;$z<$Zbytek;$z++)
$ret.=jpexs_inttobyte(0);
};
};
if($BitCount>=24)
{
for($y=$Height-1;$y>=0;$y--)
{
for($x=0;$x<$Width;$x++)
{
$color=imagecolorsforindex($img,imagecolorat($img,$x,$y));
$ret.=jpexs_inttobyte($color["blue"]);
$ret.=jpexs_inttobyte($color["green"]);
$ret.=jpexs_inttobyte($color["red"]);
if($BitCount==32)
$ret.=jpexs_inttobyte(0);//Alpha for ICO_XP_COLORS
};
for($z=0;$z<$Zbytek;$z++)
$ret.=jpexs_inttobyte(0);
};
};
//MASK
for($y=$Height-1;$y>=0;$y--)
{
$byteCount=0;
$bOut="";
for($x=0;$x<$Width;$x++)
{
if(($Transparent!=-1)and(imagecolorat($img,$x,$y)==$Transparent))
{
$bOut.="1";
}
else
{
$bOut.="0";
};
};
for($p=0;$p<strlen($bOut);$p+=8)
{
$byte=bindec(substr($bOut,$p,8));
$byteCount++;
$ret.=jpexs_inttobyte($byte);
};
$Zbytek=$byteCount%4;
for($z=0;$z<$Zbytek;$z++)
{
$ret.=jpexs_inttobyte(0xff);
};
};
//------------------
};//q
if($WriteToFile)
{
$f=fopen($filename,"w");
fwrite($f,$ret);
fclose($f);
}
else
{
echo $ret;
};
};
/*
* Internal functions:
*-------------------------
* jpexs_inttobyte($n) - returns chr(n)
* jpexs_inttodword($n) - returns dword (n)
* jpexs_inttoword($n) - returns word(n)
* jpexs_freadbyte($file) - reads 1 byte from $file
* jpexs_freadword($file) - reads 2 bytes (1 word) from $file
* jpexs_freaddword($file) - reads 4 bytes (1 dword) from $file
* jpexs_freadlngint($file) - same as freaddword($file)
* jpexs_decbin8($d) - returns binary string of d zero filled to 8
* jpexs_RetBits($byte,$start,$len) - returns bits $start->$start+$len from $byte
* jpexs_freadbits($file,$count) - reads next $count bits from $file
*/
function jpexs_decbin8($d)
{
return jpexs_decbinx($d,8);
};
function jpexs_decbinx($d,$n)
{
$bin=decbin($d);
$sbin=strlen($bin);
for($j=0;$j<$n-$sbin;$j++)
$bin="0$bin";
return $bin;
};
function jpexs_retBits($byte,$start,$len)
{
$bin=jpexs_decbin8($byte);
$r=bindec(substr($bin,$start,$len));
return $r;
};
$jpexs_currentBit=0;
function jpexs_freadbits($f,$count)
{
global $jpexs_currentBit,$jpexs_SMode;
$Byte=jpexs_freadbyte($f);
$LastCBit=$jpexs_currentBit;
$jpexs_currentBit+=$count;
if($jpexs_currentBit==8)
{
$jpexs_currentBit=0;
}
else
{
fseek($f,ftell($f)-1);
};
return jpexs_retBits($Byte,$LastCBit,$count);
};
function jpexs_freadbyte($f)
{
return ord(fread($f,1));
};
function jpexs_freadword($f)
{
$b1=jpexs_freadbyte($f);
$b2=jpexs_freadbyte($f);
return $b2*256+$b1;
};
function jpexs_freadlngint($f)
{
return jpexs_freaddword($f);
};
function jpexs_freaddword($f)
{
$b1=jpexs_freadword($f);
$b2=jpexs_freadword($f);
return $b2*65536+$b1;
};
function jpexs_inttobyte($n)
{
return chr($n);
};
function jpexs_inttodword($n)
{
return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255);
};
function jpexs_inttoword($n)
{
return chr($n & 255).chr(($n >> 8) & 255);
};
?> | jegelstaff/formulize | libraries/wideimage/lib/vendor/JPEXS/ico.php | PHP | gpl-2.0 | 27,177 |
using System;
class Foo<T>
{
public enum TestEnum { One, Two, Three }
public TestEnum Test;
public Foo (TestEnum test)
{
this.Test = test;
}
}
class X
{
public static void Main ()
{
Foo<int>.TestEnum e = Foo<int>.TestEnum.One;
Console.WriteLine (e);
Foo<int> foo = new Foo<int> (e);
foo.Test = e;
}
}
| xen2/mcs | tests/gtest-313.cs | C# | gpl-2.0 | 324 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using UtilityExtensions;
using Intuit.Ipp.Core;
using Intuit.Ipp.Security;
using Intuit.Ipp.Data.Qbo;
namespace CmsData.Classes.QuickBooks
{
public class QBOHelper : QuickBooksHelper
{
public List<Account> ListAllAccounts() // Max per page from QuickBooks is 100
{
int iX;
List<Account> lTemp;
List<Account> lReturn = new List<Account>();
lTemp = getDataService().FindAll(new Account(), 1, 100).ToList<Account>();
for (iX = 0; true; iX++)
{
if (lTemp.Count() != 100) break;
lReturn.InsertRange(iX * 100, lTemp);
lTemp = getDataService().FindAll(new Account(), iX + 1, 100).ToList<Account>();
}
lReturn.InsertRange(iX * 100, lTemp);
return lReturn;
}
public Account GetAccountByID(string sAccountID)
{
Account acct = new Account();
acct.Id = new IdType { Value = sAccountID };
return getDataService().FindById<Account>(acct) as Account;
}
public JournalEntryLine TranslateJournalEntry(QBJournalEntryLine qbjel, bool bCredit)
{
JournalEntryLine jel = new JournalEntryLine();
jel.Desc = qbjel.sDescrition;
jel.Amount = qbjel.dAmount;
jel.AmountSpecified = true;
jel.AccountId = new IdType() { Value = qbjel.sAccountID };
if (bCredit) jel.PostingType = PostingTypeEnum.Credit;
else jel.PostingType = PostingTypeEnum.Debit;
jel.PostingTypeSpecified = true;
return jel;
}
public new int CommitJournalEntries(string sDescription, List<QBJournalEntryLine> jelEntries)
{
if (jelEntries == null) return 0;
if (jelEntries.Count() == 0) return 0;
JournalEntryLine[] entries = new JournalEntryLine[jelEntries.Count()];
for (int iX = 0; iX < jelEntries.Count(); iX++)
{
entries[iX] = TranslateJournalEntry(jelEntries[iX], jelEntries[iX].bCredit);
}
JournalEntry jeNew = new JournalEntry();
JournalEntryHeader jeh = new JournalEntryHeader();
jeh.Note = sDescription;
jeNew.Header = jeh;
jeNew.Line = entries;
JournalEntry jeMade = getDataService().Add(jeNew) as JournalEntry;
if (jeMade.Id.Value.ToInt() > 0 && jeMade.SyncToken.ToInt() > -1) return jeMade.Id.Value.ToInt();
else return 0;
}
}
}
| RGray1959/MyParish | CmsData/Classes/QuickBooks/QBOHelper.cs | C# | gpl-2.0 | 2,727 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.3.1
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Unit Testing Class
*
* Simple testing class
*
* @package CodeIgniter
* @subpackage Libraries
* @category UnitTesting
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/uri.html
*/
class CI_Unit_test {
var $active = TRUE;
var $results = array();
var $strict = FALSE;
var $_template = NULL;
var $_template_rows = NULL;
function CI_Unit_test()
{
log_message('debug', "Unit Testing Class Initialized");
}
// --------------------------------------------------------------------
/**
* Run the tests
*
* Runs the supplied tests
*
* @access public
* @param mixed
* @param mixed
* @param string
* @return string
*/
function run($test, $expected = TRUE, $test_name = 'undefined')
{
if ($this->active == FALSE)
{
return FALSE;
}
if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
{
$expected = str_replace('is_float', 'is_double', $expected);
$result = ($expected($test)) ? TRUE : FALSE;
$extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
}
else
{
if ($this->strict == TRUE)
$result = ($test === $expected) ? TRUE : FALSE;
else
$result = ($test == $expected) ? TRUE : FALSE;
$extype = gettype($expected);
}
$back = $this->_backtrace();
$report[] = array (
'test_name' => $test_name,
'test_datatype' => gettype($test),
'res_datatype' => $extype,
'result' => ($result === TRUE) ? 'passed' : 'failed',
'file' => $back['file'],
'line' => $back['line']
);
$this->results[] = $report;
return($this->report($this->result($report)));
}
// --------------------------------------------------------------------
/**
* Generate a report
*
* Displays a table with the test data
*
* @access public
* @return string
*/
function report($result = array())
{
if (count($result) == 0)
{
$result = $this->result();
}
$CI =& get_instance();
$CI->load->language('unit_test');
$this->_parse_template();
$r = '';
foreach ($result as $res)
{
$table = '';
foreach ($res as $key => $val)
{
if ($key == $CI->lang->line('ut_result'))
{
if ($val == $CI->lang->line('ut_passed'))
{
$val = '<span style="color: #0C0;">'.$val.'</span>';
}
elseif ($val == $CI->lang->line('ut_failed'))
{
$val = '<span style="color: #C00;">'.$val.'</span>';
}
}
$temp = $this->_template_rows;
$temp = str_replace('{item}', $key, $temp);
$temp = str_replace('{result}', $val, $temp);
$table .= $temp;
}
$r .= str_replace('{rows}', $table, $this->_template);
}
return $r;
}
// --------------------------------------------------------------------
/**
* Use strict comparison
*
* Causes the evaluation to use === rather then ==
*
* @access public
* @param bool
* @return null
*/
function use_strict($state = TRUE)
{
$this->strict = ($state == FALSE) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
/**
* Make Unit testing active
*
* Enables/disables unit testing
*
* @access public
* @param bool
* @return null
*/
function active($state = TRUE)
{
$this->active = ($state == FALSE) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
/**
* Result Array
*
* Returns the raw result data
*
* @access public
* @return array
*/
function result($results = array())
{
$CI =& get_instance();
$CI->load->language('unit_test');
if (count($results) == 0)
{
$results = $this->results;
}
$retval = array();
foreach ($results as $result)
{
$temp = array();
foreach ($result as $key => $val)
{
if (is_array($val))
{
foreach ($val as $k => $v)
{
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
{
$v = $line;
}
$temp[$CI->lang->line('ut_'.$k)] = $v;
}
}
else
{
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val))))
{
$val = $line;
}
$temp[$CI->lang->line('ut_'.$key)] = $val;
}
}
$retval[] = $temp;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Set the template
*
* This lets us set the template to be used to display results
*
* @access public
* @param string
* @return void
*/
function set_template($template)
{
$this->_template = $template;
}
// --------------------------------------------------------------------
/**
* Generate a backtrace
*
* This lets us show file names and line numbers
*
* @access private
* @return array
*/
function _backtrace()
{
if (function_exists('debug_backtrace'))
{
$back = debug_backtrace();
$file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
$line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
return array('file' => $file, 'line' => $line);
}
return array('file' => 'Unknown', 'line' => 'Unknown');
}
// --------------------------------------------------------------------
/**
* Get Default Template
*
* @access private
* @return string
*/
function _default_template()
{
$this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">';
$this->_template .= '{rows}';
$this->_template .= "\n".'</table>';
$this->_template_rows = "\n\t".'<tr>';
$this->_template_rows .= "\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>';
$this->_template_rows .= "\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>';
$this->_template_rows .= "\n\t".'</tr>';
}
// --------------------------------------------------------------------
/**
* Parse Template
*
* Harvests the data within the template {pseudo-variables}
*
* @access private
* @return void
*/
function _parse_template()
{
if ( ! is_null($this->_template_rows))
{
return;
}
if (is_null($this->_template))
{
$this->_default_template();
return;
}
if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
{
$this->_default_template();
return;
}
$this->_template_rows = $match['1'];
$this->_template = str_replace($match['0'], '{rows}', $this->_template);
}
}
// END Unit_test Class
/**
* Helper functions to test boolean true/false
*
*
* @access private
* @return bool
*/
function is_true($test)
{
return (is_bool($test) AND $test === TRUE) ? TRUE : FALSE;
}
function is_false($test)
{
return (is_bool($test) AND $test === FALSE) ? TRUE : FALSE;
}
/* End of file Unit_test.php */
/* Location: ./system/libraries/Unit_test.php */ | Calico90/codeigniter-version-scanner | CodeIgniter_1.6.3/CodeIgniter_1.6.3/system/libraries/Unit_test.php | PHP | gpl-2.0 | 7,526 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.