answer
stringlengths
15
1.25M
#!/usr/bin/env python3 import sys import os sys.path.append(os.path.realpath(".")) import unittest import cleanstream import tagger import pretransfer import transfer import interchunk import postchunk import adaptdocx if __name__ == "__main__": os.chdir(os.path.dirname(__file__)) failures = 0 for module in [tagger, pretransfer, transfer, interchunk, postchunk, adaptdocx, cleanstream]: suite = unittest.TestLoader().loadTestsFromModule(module) res = unittest.TextTestRunner(verbosity=2).run(suite) if(not(res.wasSuccessful())): failures += 1 sys.exit(min(failures, 255))
/** * @file * VP8 decoder support via libvpx */ #define <API key> 1 #include <vpx/vpx_decoder.h> #include <vpx/vp8dx.h> #include "libavutil/common.h" #include "libavutil/imgutils.h" #include "avcodec.h" #include "internal.h" typedef struct VP8DecoderContext { struct vpx_codec_ctx decoder; } VP8Context; static av_cold int vpx_init(AVCodecContext *avctx, const struct vpx_codec_iface *iface) { VP8Context *ctx = avctx->priv_data; struct vpx_codec_dec_cfg deccfg = { /* token partitions+1 would be a decent choice */ .threads = FFMIN(avctx->thread_count, 16) }; av_log(avctx, AV_LOG_INFO, "%s\n", <API key>()); av_log(avctx, AV_LOG_VERBOSE, "%s\n", <API key>()); if (vpx_codec_dec_init(&ctx->decoder, iface, &deccfg, 0) != VPX_CODEC_OK) { const char *error = vpx_codec_error(&ctx->decoder); av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder: %s\n", error); return AVERROR(EINVAL); } avctx->pix_fmt = AV_PIX_FMT_YUV420P; return 0; } static int vp8_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { VP8Context *ctx = avctx->priv_data; AVFrame *picture = data; const void *iter = NULL; struct vpx_image *img; int ret; if (vpx_codec_decode(&ctx->decoder, avpkt->data, avpkt->size, NULL, 0) != VPX_CODEC_OK) { const char *error = vpx_codec_error(&ctx->decoder); const char *detail = <API key>(&ctx->decoder); av_log(avctx, AV_LOG_ERROR, "Failed to decode frame: %s\n", error); if (detail) av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail); return AVERROR_INVALIDDATA; } if ((img = vpx_codec_get_frame(&ctx->decoder, &iter))) { if (img->fmt != VPX_IMG_FMT_I420) { av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d)\n", img->fmt); return AVERROR_INVALIDDATA; } if ((int) img->d_w != avctx->width || (int) img->d_h != avctx->height) { av_log(avctx, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n", avctx->width, avctx->height, img->d_w, img->d_h); if (av_image_check_size(img->d_w, img->d_h, 0, avctx)) return AVERROR_INVALIDDATA; <API key>(avctx, img->d_w, img->d_h); } if ((ret = ff_get_buffer(avctx, picture, 0)) < 0) return ret; av_image_copy(picture->data, picture->linesize, img->planes, img->stride, avctx->pix_fmt, img->d_w, img->d_h); *got_frame = 1; } return avpkt->size; } static av_cold int vp8_free(AVCodecContext *avctx) { VP8Context *ctx = avctx->priv_data; vpx_codec_destroy(&ctx->decoder); return 0; } #if <API key> static av_cold int vp8_init(AVCodecContext *avctx) { return vpx_init(avctx, &<API key>); } AVCodec <API key> = { .name = "libvpx", .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP8, .priv_data_size = sizeof(VP8Context), .init = vp8_init, .close = vp8_free, .decode = vp8_decode, .capabilities = <API key> | CODEC_CAP_DR1, .long_name = <API key>("libvpx VP8"), }; #endif /* <API key> */ #if <API key> static av_cold int vp9_init(AVCodecContext *avctx) { return vpx_init(avctx, &<API key>); } AVCodec <API key> = { .name = "libvpx-vp9", .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP9, .priv_data_size = sizeof(VP8Context), .init = vp9_init, .close = vp8_free, .decode = vp8_decode, .capabilities = <API key> | <API key>, .long_name = <API key>("libvpx VP9"), }; #endif /* <API key> */
// ReadEntityBodyMode.cs // 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, // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // included in all copies or substantial portions of the Software. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // 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. namespace System.Web { public enum ReadEntityBodyMode { None, Classic, Bufferless, Buffered, } }
#!/usr/bin/python3 # This program is free software; you can redistribute it and/or modify # (at your option) any later version. # This program is distributed in the hope that it will be useful, # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import logging import random from . import ipc_test_pb2 from . import ipc_test logger = logging.getLogger(__name__) class IPCPerfTest(ipc_test.IPCPerfTestBase): async def test_small_messages(self): request = ipc_test_pb2.TestRequest() request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 5000) async def test_large_messages(self): request = ipc_test_pb2.TestRequest() for _ in range(10000): request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 100)
VERSION = 1.0.1 all: smistrip -d MIB src-mib/nagios*.mib test: smilint -p ./MIB/NAGIOS-ROOT-MIB ./MIB/NAGIOS-NOTIFY-MIB tarball:
#ifndef INC_FMTLexer_hpp_ #define INC_FMTLexer_hpp_ #include <antlr/config.hpp> /* $ANTLR 2.7.7 (20130428): "format.g" -> "FMTLexer.hpp"$ */ #include <antlr/CommonToken.hpp> #include <antlr/InputBuffer.hpp> #include <antlr/BitSet.hpp> #include "FMTTokenTypes.hpp" #include <antlr/CharScanner.hpp> #include <fstream> #include <sstream> #include "fmtnode.hpp" #include "CFMTLexer.hpp" #include <antlr/TokenStreamSelector.hpp> //using namespace antlr; class CUSTOM_API FMTLexer : public antlr::CharScanner, public FMTTokenTypes { private: antlr::TokenStreamSelector* selector; CFMTLexer* cLexer; public: void SetSelector( antlr::TokenStreamSelector& s) { selector = &s; } void SetCLexer( CFMTLexer& l) { cLexer = &l; } private: void initLiterals(); public: bool <API key>() const { return false; } public: FMTLexer(std::istream& in); FMTLexer(antlr::InputBuffer& ib); FMTLexer(const antlr::<API key>& state); antlr::RefToken nextToken(); public: void mSTRING(bool _createToken); public: void mCSTRING(bool _createToken); public: void mLBRACE(bool _createToken); public: void mRBRACE(bool _createToken); public: void mSLASH(bool _createToken); public: void mCOMMA(bool _createToken); public: void mA(bool _createToken); public: void mTERM(bool _createToken); public: void mNONL(bool _createToken); public: void mF(bool _createToken); public: void mD(bool _createToken); public: void mE(bool _createToken); public: void mG(bool _createToken); public: void mI(bool _createToken); public: void mO(bool _createToken); public: void mB(bool _createToken); public: void mZ(bool _createToken); public: void mZZ(bool _createToken); public: void mQ(bool _createToken); public: void mH(bool _createToken); public: void mT(bool _createToken); public: void mL(bool _createToken); public: void mR(bool _createToken); public: void mX(bool _createToken); public: void mC(bool _createToken); public: void mCMOA(bool _createToken); public: void mCMoA(bool _createToken); public: void mCmoA(bool _createToken); public: void mCMOI(bool _createToken); public: void mCDI(bool _createToken); public: void mCMI(bool _createToken); public: void mCYI(bool _createToken); public: void mCSI(bool _createToken); public: void mCSF(bool _createToken); public: void mCHI(bool _createToken); public: void mChI(bool _createToken); public: void mCDWA(bool _createToken); public: void mCDwA(bool _createToken); public: void mCdwA(bool _createToken); public: void mCAPA(bool _createToken); public: void mCApA(bool _createToken); public: void mCapA(bool _createToken); public: void mPERCENT(bool _createToken); public: void mDOT(bool _createToken); public: void mPM(bool _createToken); public: void mMP(bool _createToken); protected: void mW(bool _createToken); public: void mWHITESPACE(bool _createToken); protected: void mDIGITS(bool _createToken); protected: void mCHAR(bool _createToken); public: void mNUMBER(bool _createToken); private: static const unsigned long _tokenSet_0_data_[]; static const antlr::BitSet _tokenSet_0; static const unsigned long _tokenSet_1_data_[]; static const antlr::BitSet _tokenSet_1; static const unsigned long _tokenSet_2_data_[]; static const antlr::BitSet _tokenSet_2; }; #endif /*INC_FMTLexer_hpp_*/
#include "db/db.h" Database::Database() { this->records_tree_ = nullptr; } void Database::Read(DatabaseReader &reader) { this->records_tree_ = reader.ReadIndex(); } Record *Database::GetRecordsTree() const { return this->records_tree_; } void Database::SetRecordsTree(Record *records_tree) { this->records_tree_ = records_tree; }
import glob import fnmatch import itertools import logging import os import re import six import sys import yaml from .dockerfile import Dockerfile from .image import ImageBuilder from .config import Config class Builder(object) : def __init__(self, config=None, **kwds) : self.logger = logging.getLogger(type(self).__name__) self.kwds = kwds self.images = {} if config is None: config = Config() config.update(dict( images= [ { 'path': 'docker/*', } ], )) self.patterns = [] for image in config['images']: # When path is provided and globbed, Dockerfile refers to its location # When path is provided but not globbed, Dockerfile refers to the current path # When Dockerfile is provided and globbed, path must not be globbed, both # refers to the current directory path = image.get('path', None) dockerfile = image.get('Dockerfile', 'Dockerfile') name = image.get('name', None) if path is None: path = '.' if '*' in path: if '*' in dockerfile: raise ValueError('Ambiguity in your configuration for %r, globbing can' 'be done either in "Dockerfile" or "path" key but not both at the' 'same time' % image) dockerfile = os.path.join(path, dockerfile) path = re.compile(re.sub('^.*/([^*]*)$', r'(?P<path>.*)/\1', dockerfile)) if name is None: name = dockerfile if '*' in name: start = re.sub('^([^*]*/|).*', r'^\1(?P<name>.*)', dockerfile) end = re.sub('^.*\*(?:|[^/]*)(/.*)$', r'\1$', dockerfile) name = re.compile(start + end) pattern = { 'name': name, 'path': path, 'Dockerfile': dockerfile, } self.patterns.append(pattern) self.config = config def <API key>(self, pattern, name, path): pattern = pattern[name] if isinstance(pattern, six.string_types): return pattern else: match = pattern.match(path) if match: return match.group(name) return None def getImage(self, image_name): try: return self.images[image_name] except KeyError: self.logger.debug('image builder cache miss, try to find it') for img_cfg in self.patterns: for path in glob.glob(img_cfg['Dockerfile']): found_image_name = self.<API key>(img_cfg, 'name', path) context_path = self.<API key>(img_cfg, 'path', path) if found_image_name == image_name: image = ImageBuilder(image_name, contextPath=context_path, dockerfile=path, tagResolver=self, **self.kwds ) self.images[image_name] = image return image raise KeyError("Cannot find image %s" % image_name) def imageTag(self, imgName) : imgBuilder = self.images.get(imgName, None) if imgBuilder : return imgBuilder.buildTag() return None def build(self, client, names=None, child_images=[]) : if isinstance(names, six.string_types): names = [names] def iter_buildable_deps(name): """ instanciates a builder for each image dependency does nothing when the image cannot be build """ for dep_name, _ in self.getImage(name).imageDeps(): try: self.getImage(dep_name) yield dep_name except KeyError: continue for name in names: if name in child_images: raise RuntimeError("dependency loop detected, %s some how depends on itself %s" % (name, ' -> '.join(child_images + [name])) ) for dep_name in iter_buildable_deps(name): self.build(client, dep_name, child_images=child_images+[name]) for name in names: self.getImage(name).build(client) def tag(self, client, tags, images, **kwds): if tags is None: tags = ['latest'] for image in images: self.getImage(image).tag(client, tags, **kwds) COMMAND_NAME='build' def add_options(parser): from . import addCommonOptions, commonSetUp from .dockerfile import <API key> from .image import addImageOptions try: add = parser.add_argument except AttributeError: add = parser.add_option add("image", nargs="*", help="images to build") add("-t", "--tag", dest="tag", default=None, action='append', help="tag(s) to be applied to the resulting image in case of success") add("--registry", dest="registry", default=[], action='append', help="Registry on which the image should tagged (<registry>/<name>:<tag>)") addCommonOptions(parser) <API key>(parser) addImageOptions(parser) def main(argv=sys.argv, args=None) : """ Builds a list of images """ from . import commonSetUp if not args: import argparse parser = argparse.ArgumentParser() add_options(parser) args = parser.parse_args(argv[1:]) import sys, os import yaml from docker import Client from . import commonSetUp commonSetUp(args) builder = Builder() builder.build(Client.from_env(), args.image) builder.tag(Client.from_env(), args.tag, args.image, registries=args.registry) if __name__ == "__main__" : main()
<?php global $lang; global $languages; $<API key>="Najczęściej {$languages[$lang]} odwiedzane strony"; $l_page="Strona"; $l_last_update="ostatnio aktualizowane"; $l_last_visited="ostatnio odwiedzane"; $<API key>="średnio dziennych wizyt"; $<API key>="Całkowite statystyki serwisu"; $l_served_pages="Ten serwer serwuje średnio %.02f stron dziennie dystrybuowanych w wielu językach jak ten (wyniki w tabeli wykluczając strony main.html)&nbsp;:"; $l_language="język"; $l_percentage="procentowo"; $l_stat_graphics="Te wykresy pokazują średnią odwiedzających www.kdevelop.org"; $l_day_graphic= "Wykres dzienny"; $l_week_graphic= "Wykres tygodniowy"; $l_month_graphic="Wykres miesięczny"; $l_year_grahic= "Wykres roczny"; return include("inc/stats.php"); ?>
<?php require_once __DIR__ . '/../../../mainfile.php'; $op = \Xmf\Request::getCmd('op', ''); switch ($op) { case 'load': loadSampleData(); break; } // XMF TableLoad for SAMPLE data function loadSampleData() { // $moduleDirName = basename(dirname(__DIR__)); xoops_loadLanguage('comment'); $items = \Xmf\Yaml::readWrapped('quotes_data.yml'); \Xmf\Database\TableLoad::truncateTable('randomquote_quotes'); \Xmf\Database\TableLoad::loadTableFromArray('randomquote_quotes', $items); redirect_header('../admin/index.php', 1, _CM_ACTIVE); }
#ifndef <API key> #define <API key> #include <mshtml.h> #include <shdeprecated.h> class __declspec(uuid("<API key>")) <API key> : public IUnknown { public: STDMETHOD(<API key>)(VARIANT_BOOL* cancel) = 0; STDMETHOD(<API key>)(VOID) = 0; STDMETHOD(<API key>)(VOID) = 0; STDMETHOD(<API key>)(VOID) = 0; STDMETHOD(<API key>)(VOID) = 0; }; class __declspec(uuid("{<API key>}")) <API key> : public IUnknown { public: STDMETHOD(GetUrlForEvents)(BSTR* url) = 0; }; class __declspec(uuid("{<API key>}")) IWebBrowserPriv : public IUnknown { public: STDMETHOD(NavigateWithBindCtx)(VARIANT* uri, VARIANT* flags, VARIANT* target_frame, VARIANT* post_data, VARIANT* headers, IBindCtx* bind_ctx, LPOLESTR url_fragment); STDMETHOD(OnClose)(); }; class <API key> : public IUnknown { public: STDMETHOD(<API key>)(IUri* uri, VARIANT* flags, VARIANT* target_frame, VARIANT* post_data, VARIANT* headers, IBindCtx* bind_ctx, LPOLESTR url_fragment); }; class <API key> : public IUnknown { public: STDMETHOD(<API key>)(IUri* uri, VARIANT* flags, VARIANT* target_frame, VARIANT* post_data, VARIANT* headers, IBindCtx* bind_ctx, LPOLESTR url_fragment, DWORD unused1); }; interface __declspec(uuid("<API key>")) IDocObjectService : public IUnknown { STDMETHOD(FireBeforeNavigate2)(IDispatch* dispatch, LPCTSTR url, DWORD flags, LPCTSTR frame_name, BYTE* post_data, DWORD post_data_len, LPCTSTR headers, BOOL play_nav_sound, BOOL* cancel) = 0; STDMETHOD(<API key>)(IHTMLWindow2* html_window2, DWORD flags) = 0; STDMETHOD(FireDownloadBegin)() = 0; STDMETHOD(<API key>)() = 0; STDMETHOD(<API key>)(IHTMLWindow2* html_window2, DWORD flags) = 0; STDMETHOD(<API key>)(IHTMLWindow2* html_window2) = 0; STDMETHOD(GetPendingUrl)(BSTR* pending_url) = 0; STDMETHOD(<API key>)(IHTMLElement* html_element) = 0; STDMETHOD(<API key>)(BSTR* search) = 0; STDMETHOD(IsErrorUrl)(LPCTSTR url, BOOL* is_error) = 0; }; interface __declspec(uuid("<API key>")) ITridentService2 : public IUnknown { STDMETHOD(FireBeforeNavigate2)(IDispatch* dispatch, LPCTSTR url, DWORD flags, LPCTSTR frame_name, BYTE* post_data, DWORD post_data_len, LPCTSTR headers, BOOL play_nav_sound, BOOL* cancel) = 0; STDMETHOD(<API key>)(IHTMLWindow2*, uint32); STDMETHOD(FireDownloadBegin)(VOID); STDMETHOD(<API key>)(VOID); STDMETHOD(<API key>)(IHTMLWindow2*, uint32); STDMETHOD(<API key>)(IHTMLWindow2*); STDMETHOD(GetPendingUrl)(uint16**); STDMETHOD(<API key>)(IHTMLElement*); STDMETHOD(<API key>)(uint16**); STDMETHOD(IsErrorUrl)(uint16 const*, int32*); STDMETHOD(AttachMyPics)(VOID *, VOID**); STDMETHOD(ReleaseMyPics)(VOID*); STDMETHOD(IsGalleryMeta)(int32, VOID*); STDMETHOD(EmailPicture)(uint16*); STDMETHOD(FireNavigateError)(IHTMLWindow2*, uint16*, uint16*, uint32, int*); STDMETHOD(<API key>)(IHTMLWindow2*, int32); STDMETHOD(<API key>)(IHTMLWindow2*, uint32, int32); STDMETHOD(<API key>)(int32 privacy_violated); STDMETHOD(InitAutoImageResize)(VOID); STDMETHOD(<API key>)(VOID); }; #define <API key> (0x01) #define TLEF_RELATIVE_BACK (0x10) #define TLEF_RELATIVE_FORE (0x20) #endif
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>-</title> <link href="../css/style.css" rel="stylesheet" type="text/css"> <script src="../js/jQuery.js" type="text/javascript"></script> <script src="../js/common.js" type="text/javascript"></script> <script src="../js/model/WdatePicker/WdatePicker.js" type="text/javascript"></script> <script src="../js/utils.js" type="text/javascript"></script> <script src="../js/model/highcharts/highcharts.js"></script> </head> <body> <div class="layout_header"> <div class="header"> <div class="h_logo"><a href="#" title="101"><img src="../images/qaup_logo.png" width="130" height="40" alt=""/></a></div> <div class="h_nav"> <span class="hi"><img src="../images/head_default.jpg" alt="id"/> </span><span class="link"><a href="#"><i class="icon16 icon16-setting"></i> </a><a href="#"><i class="icon16 icon16-power"></i> </a></span> </div> <div class="clear"></div> </div> </div> <div class="layout_leftnav"> <div class="inner"> <div class="nav-vertical"> <ul class="accordion"> <li><a href="#"><i class="icon20 icon20_index"></i><span></span></a> <ul class="sub-menu"> <li><a href="/mySchool/web/courseList.html"></a></li> <li><a href="/mySchool/web/teacherList.html"></a></li> <li><a href="/mySchool/web/studentList.html"></a></li> <li><a href="/mySchool/web/financeList.html" class="active"></a></li> </ul> </li> </ul> </div> </div> </div> <div class="layout_rightmain"> <div class="inner"> <div class="pd10x20"> <div class="page-title mb20"> <i class="i_icon"></i><label id="teacher_name">Male</label> </div> <div class="panel"> <div class="panel-tab pd10"> <ul> <li class="active" id="a1" onclick="setTab('a', 1, 3)"></li> <li id="a2" onclick="setTab('a', 2, 3)"></li> <li id="a3" onclick="setTab('a', 3, 3)"></li> <div class="clear"></div> </ul> </div> <div class="panel-main pd10"> <div id="con_a_1" style="width: 1000px;" class="hover" > <div class="panel-header"> <div><a href="#" class="btn btn-primary" onclick="downloadCourse()"></a></div> </div> <table class="table table-striped"> <thead> <tr> <th ></th> <th ></th> <th ></th> <th ></th> <th ></th> <th ></th> </tr> </thead> <tbody id = "couse_list_tbody"> </tbody> </table> </div> <div id="con_a_2" style="display:none; width: 1000px;" ></div> <div id="con_a_3" style="display:none; width: 1000px;" > <table class="table table-striped"> <thead> <tr> <th ></th> <th >/</th> </tr> </thead> <tbody id = "cost_list_tbody"> </tbody> </table> </div> </div> </div> </div> </div> </div> </body> <script type="text/javascript"> var teacherId = ''; var startTimeStr = ''; var endTimeStr = ''; var gradeSet = new Array(); var gradeNameArray = new Array(); var gradeIdNum = new Array(); window.onload = function() { teacherId = getQuery("teacherId"); startTimeStr = getQuery("startTimeStr"); endTimeStr = getQuery("endTimeStr"); initGradeSet(); var teacherUrl = "/mySchool/office/getTeacherById.action"; var params = "teacherId=" + teacherId; var teacherJson = ajaxQuery(teacherUrl, params); this.document.getElementById("teacher_name").innerHTML = teacherJson.data.teacherList[0].name; fillCourseTable(teacherId, startTimeStr, endTimeStr); drawGradeImg(); initFinanceList(); } function initGradeSet() { var gradeUrl = "/mySchool/office/getGradeList.action"; var gradeListJson = ajaxQuery(gradeUrl, null); var row_length = gradeListJson.data.size; for (var i = 0; i < row_length; i++) { gradeSet[gradeListJson.data.gradeList[i].gradeId] = gradeListJson.data.gradeList[i].gradeName; gradeNameArray[i] = gradeListJson.data.gradeList[i].gradeName; gradeIdNum[i] = 0; } gradeIdNum[row_length] = 0; } function fillCourseTable(teacherId, startTimeStr, endTimeStr){ var courseUrl = "/mySchool/office/getCourseList.action"; var params = "startTimeStr=" + startTimeStr + "&" + "endTimeStr=" + endTimeStr + "&" + "teacherId=" + teacherId + "&courseStatus=1"; var courseListJson = ajaxQuery(courseUrl, params); if(courseListJson.data.size == 0){ return; } var data = courseListJson.data; var row_length = data.size; var task_tbody = document.getElementById("couse_list_tbody"); for(var i = 0; i < row_length; i++){ var tr = document.createElement("tr"); var studentName = document.createElement("td"); studentName.innerHTML = data.course_list[i].studentName; tr.appendChild(studentName); var grade = document.createElement("td"); grade.innerHTML = gradeSet[data.course_list[i].gradeId]; tr.appendChild(grade); var subjectName = document.createElement("td"); subjectName.innerHTML = data.course_list[i].subjectName; tr.appendChild(subjectName); var courseTime = document.createElement("td"); courseTime.innerHTML = data.course_list[i].courseTime; tr.appendChild(courseTime); var time = document.createElement("td"); time.innerHTML = (new Date(data.course_list[i].time)).Format("yyyy-MM-dd hh:mm:ss"); tr.appendChild(time); var classroom = document.createElement("td"); classroom.innerHTML = data.course_list[i].classroom; tr.appendChild(classroom); gradeIdNum[data.course_list[i].gradeId] += 1; task_tbody.appendChild(tr); } } function drawGradeImg() { $(function() { $('#con_a_2').highcharts({ title: { text: '', x: -20 //center }, xAxis: { categories: gradeNameArray }, yAxis: { title: { text: '' }, plotLines: [{ value: 0, width: 1, color: '#808080' }] }, tooltip: { valueSuffix: '' }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, series: [{ name: '', data: gradeIdNum.slice(1) }] }); }); } function initFinanceList() { var teacherGradeCostUrl = "/mySchool/finance/<API key>.action"; var params = "teacherId=" + teacherId; var teacherJson = ajaxQuery(teacherGradeCostUrl, params); var task_tbody = document.getElementById("cost_list_tbody"); var data = teacherJson.data; var row_length = data.size; for (var i = 0; i < row_length; i++) { var tr = document.createElement("tr"); var grade = document.createElement("td"); grade.innerHTML = gradeSet[data.teacherList[i].gradeId]; tr.appendChild(grade); var cost = document.createElement("td"); cost.innerHTML = data.teacherList[i].cost; tr.appendChild(cost); task_tbody.appendChild(tr); } } function downloadCourse(){ var params = ""; params += "startTimeStr=" + startTimeStr + "&"; params += "endTimeStr=" + endTimeStr + "&"; params += "teacherId=" + teacherId; window.location.href = "/mySchool/office/downloadCourse.action?"+params; } </script> </html>
<?php class wpsociallikes { const OPTION_NAME_MAIN = 'sociallikes'; const <API key> = '<API key>'; const <API key> = '<API key>'; const <API key> = '<API key>'; const <API key> = '<API key>'; var $lang; var $options; var $buttons = array( 'vk_btn', 'facebook_btn', 'twitter_btn', 'google_btn', 'pinterest_btn', 'lj_btn', 'linkedin_btn', 'odn_btn', 'mm_btn', 'email_btn' ); function wpsociallikes() { add_option(self::<API key>, ''); add_option(self::<API key>, 'after'); add_option(self::<API key>, 'disabled'); add_option(self::<API key>, 'disabled'); add_action('init', array(&$this, 'ap_action_init')); add_action('wp_head', array(&$this, 'header_content')); add_action('wp_enqueue_scripts', array(&$this, 'header_scripts')); add_action('admin_menu', array(&$this, 'wpsociallikes_menu')); add_action('save_post', array(&$this, 'save_post_meta')); add_action('<API key>', array(&$this, '<API key>')); add_filter('the_content', array(&$this, 'add_social_likes')); add_filter('the_excerpt_rss', array(&$this, '<API key>')); add_filter('the_content_feed', array(&$this, '<API key>')); add_filter('plugin_action_links', array(&$this, 'add_action_links'), 10, 2); add_shortcode('wp-social-likes', array(&$this, 'shortcode_content')); } function ap_action_init() { $this->load_options(); $custom_locale = $this->options['customLocale']; if ($custom_locale) { load_textdomain('wp-social-likes', plugin_dir_path( __FILE__ ).'/languages/wp-social-likes-'.$custom_locale.'.mo'); } else { <API key>('wp-social-likes', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/'); } $this->title_vkontakte = __('Share link on VK', 'wp-social-likes'); $this->title_facebook = __('Share link on Facebook', 'wp-social-likes'); $this->title_twitter = __('Share link on Twitter', 'wp-social-likes'); $this->title_plusone = __('Share link on Google+', 'wp-social-likes'); $this->title_pinterest = __('Share image on Pinterest', 'wp-social-likes'); $this->title_livejournal = __('Share link on LiveJournal', 'wp-social-likes'); $this->title_linkedin = __('Share link on LinkedIn', 'wp-social-likes'); $this->title_odnoklassniki = __('Share link on Odnoklassniki', 'wp-social-likes'); $this->title_mailru = __('Share link on Mail.ru', 'wp-social-likes'); $this->title_email = __('Share link by E-mail', 'wp-social-likes'); $this->label_vkontakte = __('VK', 'wp-social-likes'); $this->label_facebook = __('Facebook', 'wp-social-likes'); $this->label_twitter = __('Twitter', 'wp-social-likes'); $this->label_plusone = __('Google+', 'wp-social-likes'); $this->label_pinterest = __('Pinterest', 'wp-social-likes'); $this->label_livejournal = __('LiveJournal', 'wp-social-likes'); $this->label_linkedin = __('LinkedIn', 'wp-social-likes'); $this->label_odnoklassniki = __('Odnoklassniki', 'wp-social-likes'); $this->label_mailru = __('Mail.ru', 'wp-social-likes'); $this->label_email = __('E-mail', 'wp-social-likes'); $this->label_share = __('Share', 'wp-social-likes'); } function header_content() { $skin = str_replace('light', '', $this->options['skin']); if (($skin != 'classic') && ($skin != 'flat') && ($skin != 'birman')) { $skin = 'classic'; } ?> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/social-likes_<?php echo $skin ?>.css"> <?php if ($this->button_is_active('lj_btn')) { ?> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/livejournal.css"> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/livejournal_<?php echo $skin ?>.css"> <?php } if ($this->button_is_active('linkedin_btn')) { ?> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/linkedin.css"> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/linkedin_<?php echo $skin ?>.css"> <?php } if ($this->button_is_active('email_btn')) { ?> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/email.css"> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/email_<?php echo $skin ?>.css"> <?php } ?> <script src="<?php echo plugin_dir_url(__FILE__) ?>js/social-likes.min.js"></script> <?php if ($this-><API key>()) { ?> <script src="<?php echo plugin_dir_url(__FILE__) ?>js/custom-buttons.js"></script> <?php } } function header_scripts() { wp_enqueue_script('jquery'); } function <API key>() { wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-sortable'); } function wpsociallikes_menu() { $post_opt = $this->options['post']; $page_opt = $this->options['page']; add_meta_box('wpsociallikes', 'Social Likes', array(&$this, 'wpsociallikes_meta'), 'post', 'normal', 'default', array('default'=>$post_opt)); add_meta_box('wpsociallikes', 'Social Likes', array(&$this, 'wpsociallikes_meta'), 'page', 'normal', 'default', array('default'=>$page_opt)); $args = array( 'public' => true, '_builtin' => false ); $post_types = get_post_types($args, 'names', 'and'); foreach ($post_types as $post_type ) { add_meta_box('wpsociallikes', 'Social Likes', array(&$this, 'wpsociallikes_meta'), $post_type, 'normal', 'default', array('default'=>$post_opt)); } $plugin_page = add_options_page('Social Likes', 'Social Likes', 'administrator', basename(__FILE__), array (&$this, 'display_admin_form')); add_action('admin_head-' . $plugin_page, array(&$this, 'admin_menu_head')); } function wpsociallikes_meta($post, $metabox) { if (!strstr($_SERVER['REQUEST_URI'], '-new.php')) { $checked = get_post_meta($post->ID, 'sociallikes', true); } else { $checked = $metabox['args']['default']; } if ($checked) { $img_url = get_post_meta($post->ID, 'sociallikes_img_url', true); if ($img_url == '' && $this->options['pinterestImg']) { $img_url = $this->get_post_first_img($post); } } else { $img_url = ''; } ?> <div id="social-likes"> <input type="hidden" name="<API key>" value="true" /> <div style="padding: 5px 0"> <input type="checkbox" name="<API key>" id="<API key>" <?php if ($checked) echo 'checked class="checked"' ?> title="<?php echo get_permalink($post->ID); ?>" /> <label for="<API key>"><?php _e('Add social buttons', 'wp-social-likes') ?></label> </div> <table> <tr> <td><label for="<API key>" style="padding-right:5px"><?php _e('Image&nbspURL:', 'wp-social-likes') ?></label></td> <td style="width:100%"> <input name="<API key>" id="<API key>" value="<?php echo $img_url ?>" <?php if (!$checked) echo 'disabled' ?> type="text" placeholder="<?php _e('Image URL (required for Pinterest)', 'wp-social-likes') ?>" style="width:100%" /> </td> </tr> </table> </div> <script> (function($) { var savedImageUrlValue = ''; $('input#<API key>').change(function () { var $this = $(this); $this.toggleClass('checked'); var socialLikesEnabled = $this.hasClass('checked'); var imageUrlField = $('#<API key>'); if (socialLikesEnabled) { imageUrlField .removeAttr('disabled') .val(savedImageUrlValue); } else { savedImageUrlValue = imageUrlField.val(); imageUrlField .attr('disabled', 'disabled') .val(''); } }); })( jQuery ); </script> <?php } function get_post_first_img($post) { $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); return $matches [1] [0]; } function save_post_meta($post_id) { if (!isset($_POST['<API key>']) || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) { return; } if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return; } } else { if (!current_user_can('edit_post', $post_id)) { return; } } update_post_meta($post_id, 'sociallikes', isset($_POST['<API key>'])); $img_url_sent = isset($_POST['<API key>']); $img_url = $img_url_sent ? $_POST['<API key>'] : ''; if ($img_url_sent && $img_url == '' && $this->options['pinterestImg']) { $post = get_post($post_id); $img_url = $this->get_post_first_img($post); } update_post_meta($post_id, 'sociallikes_img_url', $img_url); } function add_social_likes($content = '') { global $post; if (in_the_loop() && get_post_meta($post->ID, 'sociallikes', true) && (is_page() || is_single() || $this->options['excerpts'] || !$this-><API key>())) { $this->lang = get_bloginfo('language'); $buttons = $this->build_buttons($post); $placement = $this->options['placement']; if ($placement != 'none') { if ($placement == 'before') { $content = $buttons . $content; } else if ($placement == 'before-after') { $content = $buttons . $content . $buttons; } else { $content .= $buttons; } } } return $content; } function <API key>() { global $page, $pages; $post_content = $pages[$page - 1]; return preg_match('/<!--more(.*?)?-->/', $post_content); } function build_buttons($post) { $twitter_via = $this->options['twitterVia']; //$twitter_rel = $this->options['twitterRel']; $look = $this->options['look']; $skin = $this->options['skin']; $light = false; if (strpos($skin, 'light')) { $light = true; $skin = str_replace('light', '', $skin); } $iconsOnly = $this->options['iconsOnly']; $label_vkontakte = $iconsOnly ? '' : $this->label_vkontakte; $label_facebook = $iconsOnly ? '' : $this->label_facebook; $label_twitter = $iconsOnly ? '' : $this->label_twitter; $label_plusone = $iconsOnly ? '' : $this->label_plusone; $label_pinterest = $iconsOnly ? '' : $this->label_pinterest; $label_livejournal = $iconsOnly ? '' : $this->label_livejournal; $label_linkedin = $iconsOnly ? '' : $this->label_linkedin; $label_odnoklassniki = $iconsOnly ? '' : $this->label_odnoklassniki; $label_mailru = $iconsOnly ? '' : $this->label_mailru; $label_email = $iconsOnly ? '' : $this->label_email; $socialButton['vk_btn'] = '<div class="vkontakte" title="'.$this->title_vkontakte.'">'.$label_vkontakte.'</div>'; $socialButton['facebook_btn'] = '<div class="facebook" title="'.$this->title_facebook.'">'.$label_facebook.'</div>'; $socialButton['twitter_btn'] = '<div class="twitter" '; if ($twitter_via != '') { $socialButton['twitter_btn'] .= 'data-via="' . $twitter_via . '" '; } /*if ($twitter_rel != '') { $socialButton['twitter_btn'] .= 'data-related="' . $twitter_rel . '" '; }*/ $socialButton['twitter_btn'] .= 'title="'.$this->title_twitter.'">'.$label_twitter.'</div>'; $socialButton['google_btn'] = '<div class="plusone" title="'.$this->title_plusone.'">'.$label_plusone.'</div>'; $img_url = get_post_meta($post->ID, 'sociallikes_img_url', true); $socialButton['pinterest_btn'] = '<div class="pinterest" title="' . $this->title_pinterest . '"'; if ($img_url != '') { $socialButton['pinterest_btn'] .= ' data-media="' . $img_url . '"'; } if ($img_url == '' && $this->options['pinterestImg']) { $socialButton['pinterest_btn'] .= ' data-media="' . $this->get_post_first_img($post) . '"'; } $socialButton['pinterest_btn'] .= '>' . $label_pinterest . '</div>'; $socialButton['lj_btn'] = '<div class="livejournal" title="' .$this->title_livejournal .'" data-html="&lt;a href=\'{url}\'&gt;{title}&lt;/a&gt;">' .$label_livejournal.'</div>'; $socialButton['linkedin_btn'] = '<div class="linkedin" title="'.$this->title_linkedin.'">'.$label_linkedin.'</div>'; $socialButton['odn_btn'] = '<div class="odnoklassniki" title="'.$this->title_odnoklassniki.'">'.$label_odnoklassniki.'</div>'; $socialButton['mm_btn'] = '<div class="mailru" title="'.$this->title_mailru.'">'.$label_mailru.'</div>'; $socialButton['email_btn'] = '<div class="email" title="'.$this->title_email.'">'.$label_email.'</div>'; $main_div = '<div class="social-likes'; $classAppend = ''; if ($iconsOnly) { $classAppend .= ' social-likes_notext'; } if (($skin == 'flat') && $light) { $classAppend .= ' social-likes_light'; } if ($look == 'h') { $main_div .= $classAppend.'"'; } elseif ($look == 'v') { $main_div .= ' <API key>'.$classAppend.'"'; } else { $main_div .= ' social-likes_single'.$classAppend.'" data-single-title="'.$this->label_share.'"'; } $main_div .= ' data-title="' . $post->post_title . '"'; $main_div .= ' data-url="' . get_permalink( $post->ID ) . '"'; $main_div .= $this->options['counters'] ? ' data-counters="yes"' : ' data-counters="no"'; $main_div .= $this->options['zeroes'] ? ' data-zeroes="yes"' : ''; $main_div .= '>'; foreach ($this->options['buttons'] as $btn) { if (in_array($btn, $this->buttons)) { $main_div .= $socialButton[$btn]; } } $main_div .= '</div><form style="display: none;" class="<API key>"></form>'; return $main_div; } function admin_menu_head() { ?> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/<API key>.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/social-likes_flat.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/social-likes_birman.css"> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/livejournal.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/livejournal_classic.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/livejournal_flat.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/livejournal_birman.css"> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/linkedin.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/linkedin_classic.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/linkedin_flat.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/linkedin_birman.css"> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/email.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/email_classic.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/email_flat.css"> <link rel="stylesheet" id="<API key>" href="<?php echo plugin_dir_url(__FILE__) ?>css/email_birman.css"> <link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__) ?>css/admin-page.css"> <script src="<?php echo plugin_dir_url(__FILE__) ?>js/social-likes.min.js"></script> <script src="<?php echo plugin_dir_url(__FILE__) ?>js/preview.js"></script> <?php } function display_admin_form() { if (isset($_POST['submit']) || isset($_POST['apply_to_posts']) || isset($_POST['apply_to_pages'])) { $this->submit_admin_form(); } if (isset($_POST['apply_to_posts'])) { $args = array('numberposts' => -1, 'post_type' => 'post', 'post_status' => 'any'); $result = get_posts($args); foreach ($result as $post) { update_post_meta($post->ID, 'sociallikes', isset($_POST['post_chb'])); } } if (isset($_POST['apply_to_pages'])) { $args = array('post_type' => 'page'); $result = get_pages($args); foreach ($result as $post) { update_post_meta($post->ID, 'sociallikes', isset($_POST['page_chb'])); } } $this->load_options(); $look = $this->options['look']; $counters = $this->options['counters']; $post = $this->options['post']; $page = $this->options['page']; $skin = $this->options['skin']; $light = false; if (strpos($skin, 'light')) { $light = true; } if (($skin != 'classic') && ($skin != 'flat') && ($skin != 'flatlight') && ($skin != 'birman')) { $skin = 'classic'; } $zeroes = $this->options['zeroes']; $iconsOnly = $this->options['iconsOnly']; $label["vk_btn"] = __("VK", 'wp-social-likes'); $label["facebook_btn"] = __("Facebook", 'wp-social-likes'); $label["twitter_btn"] = __("Twitter", 'wp-social-likes'); $label["google_btn"] = __("Google+", 'wp-social-likes'); $label["pinterest_btn"] = __("Pinterest", 'wp-social-likes'); $label["lj_btn"] = __("LiveJournal", 'wp-social-likes'); $label["linkedin_btn"] = __("LinkedIn", 'wp-social-likes'); $label["odn_btn"] = __("Odnoklassniki", 'wp-social-likes'); $label["mm_btn"] = __("Mail.ru", 'wp-social-likes'); $label["email_btn"] = __("E-mail", 'wp-social-likes'); $this->lang = get_bloginfo('language'); ?> <div class="wrap"> <h2><?php _e('Social Likes Settings', 'wp-social-likes') ?></h2> <form name="wpsociallikes" method="post" action="?page=wp-social-likes.php&amp;updated=true"> <?php wp_nonce_field('update-options'); ?> <input id="title_vkontakte" type="hidden" value="<?php echo $this->title_vkontakte ?>"> <input id="title_facebook" type="hidden" value="<?php echo $this->title_facebook ?>"> <input id="title_twitter" type="hidden" value="<?php echo $this->title_twitter ?>"> <input id="title_plusone" type="hidden" value="<?php echo $this->title_plusone ?>"> <input id="title_pinterest" type="hidden" value="<?php echo $this->title_pinterest ?>"> <input id="title_livejournal" type="hidden" value="<?php echo $this->title_livejournal ?>"> <input id="title_linkedin" type="hidden" value="<?php echo $this->title_linkedin ?>"> <input id="title_odnoklassniki" type="hidden" value="<?php echo $this->title_odnoklassniki ?>"> <input id="title_mailru" type="hidden" value="<?php echo $this->title_mailru ?>"> <input id="title_email" type="hidden" value="<?php echo $this->title_email ?>"> <input id="label_vkontakte" type="hidden" value="<?php echo $this->label_vkontakte ?>"> <input id="label_facebook" type="hidden" value="<?php echo $this->label_facebook ?>"> <input id="label_twitter" type="hidden" value="<?php echo $this->label_twitter ?>"> <input id="label_plusone" type="hidden" value="<?php echo $this->label_plusone ?>"> <input id="label_pinterest" type="hidden" value="<?php echo $this->label_pinterest ?>"> <input id="label_livejournal" type="hidden" value="<?php echo $this->label_livejournal ?>"> <input id="label_linkedin" type="hidden" value="<?php echo $this->label_linkedin ?>"> <input id="label_odnoklassniki" type="hidden" value="<?php echo $this->label_odnoklassniki ?>"> <input id="label_mailru" type="hidden" value="<?php echo $this->label_mailru ?>"> <input id="label_email" type="hidden" value="<?php echo $this->label_email ?>"> <input id="label_share" type="hidden" value="<?php echo $this->label_share ?>"> <input id="<API key>" type="hidden" value="<?php _e('You have unsaved changes on this page. Do you want to leave this page and discard your changes?', 'wp-social-likes') ?>"> <table class="plugin-setup"> <tr valign="top"> <th scope="row"><?php _e('Skin', 'wp-social-likes') ?></th> <td class="switch-button-row"> <div style="float: left;"> <input type="radio" name="skin" id="skin_classic" class="view-state<?php if ($skin == 'classic') echo ' checked' ?>" value="classic" <?php if ($skin == 'classic') echo 'checked' ?> /> <label class="switch-button" for="skin_classic"><?php _e('Classic', 'wp-social-likes') ?></label> <input type="radio" name="skin" id="skin_flat" class="view-state<?php if ($skin == 'flat') echo ' checked' ?>" value="flat" <?php if ($skin == 'flat') echo ' checked' ?> /> <label class="switch-button" for="skin_flat"><?php _e('Flat', 'wp-social-likes') ?></label> <input type="radio" name="skin" id="skin_flatlight" class="view-state<?php if ($skin == 'flat') echo ' checked' ?>" value="flatlight" <?php if ($skin == 'flatlight') echo ' checked' ?> /> <label class="switch-button" for="skin_flatlight"><?php _e('Flat Light', 'wp-social-likes') ?></label> <input type="radio" name="skin" id="skin_birman" class="view-state<?php if ($skin == 'birman') echo ' checked' ?>" value="birman" <?php if ($skin == 'birman') echo ' checked' ?> /> <label class="switch-button" for="skin_birman"><?php _e('Birman', 'wp-social-likes') ?></label> </div> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Look', 'wp-social-likes') ?></th> <td class="switch-button-row"> <div style="float: left;"> <input type="radio" name="look" id="h_look" class="view-state<?php if ($look == 'h') echo ' checked' ?>" value="h" <?php if ($look == 'h') echo 'checked' ?> /> <label class="switch-button" for="h_look"<!--class="wpsl-label-->"><?php _e('Horizontal', 'wp-social-likes') ?></label> <input type="radio" name="look" id="v_look" class="view-state<?php if ($look == 'v') echo ' checked' ?>" value="v" <?php if ($look == 'v') echo ' checked' ?> /> <label class="switch-button" for="v_look"><?php _e('Vertical', 'wp-social-likes') ?></label> <input type="radio" name="look" id="s_look" class="view-state<?php if ($look == 's') echo ' checked' ?>" value="s" <?php if ($look == 's') echo ' checked' ?> /> <label class="switch-button" for="s_look"><?php _e('Single button', 'wp-social-likes') ?></label> </div> </td> </tr> <tr valign="top"> <th scope="row"></th> <td scope="row" class="without-bottom"> <div class="option-checkboxes"> <input type="checkbox" name="counters" id="counters" <?php if ($counters) echo 'checked' ?> /> <label for="counters" class="wpsl-label"><?php _e('Show counters', 'wp-social-likes') ?></label> </div> <div class="option-checkboxes" id="zeroes-container"> <input type="checkbox" name="zeroes" id="zeroes" <?php if ($zeroes) echo 'checked' ?> /> <label for="zeroes" class="wpsl-label"><?php _e('With zeroes', 'wp-social-likes') ?></label> </div> <div class="option-checkboxes" id="icons-container"> <input type="checkbox" name="icons" id="icons" <?php if ($iconsOnly) echo 'checked' ?> /> <label for="icons" class="wpsl-label"><?php _e('Icons only', 'wp-social-likes') ?></label> </div> </td> </tr> <tr valign="top"> <th class="valign-top" scope="row"><?php _e('Websites', 'wp-social-likes') ?></th> <td class="without-bottom"> <ul class="sortable-container"> <?php $remainingButtons = $this->buttons; for ($i = 1; $i <= count($label); $i++) { $btn = null; $checked = false; if ($i <= count($this->options['buttons'])) { $btn = $this->options['buttons'][$i - 1]; $index = array_search($btn, $remainingButtons, true); if ($index !== false) { array_splice($remainingButtons, $index, 1); $checked = true; } } if ($btn == null) { $btn = array_shift($remainingButtons); } $hidden = ($this->lang != 'ru-RU') && !$checked && ($btn == 'odn_btn' || $btn == 'mm_btn'); ?> <li class="sortable-item<?php if ($hidden) echo ' hidden' ?>"> <input type="checkbox" name="site[]" id="<?php echo $btn ?>" value="<?php echo $btn ?>" <?php if ($checked) echo 'checked' ?> /> <label for="<?php echo $btn ?>" class="wpsl-label"><?php echo $label[$btn] ?></label> </li> <?php } ?> </ul> <?php if ($this->lang != 'ru-RU' && !($this->button_is_active('odn_btn') && $this->button_is_active('mm_btn'))) { ?><span class="more-websites"><?php _e('More websites', 'wp-social-likes') ?></span><?php } ?> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Twitter Via', 'wp-social-likes') ?></th> <td> <input type="text" name="twitter_via" placeholder="<?php _e('Username', 'wp-social-likes') ?>" class="wpsl-field" value="<?php echo $this->options['twitterVia']; ?>" /> </td> </tr> <!--tr valign="top"> <th scope="row">Twitter Related</th> <td> <input type="text" name="twitter_rel" placeholder="Username:Description" class="wpsl-field" value="<?php echo $this->options['twitterRel']; ?>"/> </td> </tr <tr valign="top"> <th scope="row"></th> <td scope="row" class="without-bottom"> <input type="checkbox" name="pinterest_img" id="pinterest_img" <?php if ($this->options['pinterestImg']) echo 'checked' ?> /> <label for="pinterest_img" class="wpsl-label"><?php _e('Automatically place first image in the post/page to the Image URL field', 'wp-social-likes') ?></label> </td> </tr> <tr valign="top"> <th scope="row"></th> <td class="without-bottom"> <input type="checkbox" name="post_chb" id="post_chb" <?php if ($post) echo 'checked' ?> /> <label for="post_chb" class="wpsl-label"><?php _e('Add by default for new posts', 'wp-social-likes') ?></label> <input type="submit" name="apply_to_posts" id="apply_to_posts" value="<?php _e('Apply to existing posts', 'wp-social-likes') ?>" class="button-secondary"/> </td> </tr> <tr valign="top"> <th scope="row"></th> <td> <input type="checkbox" name="page_chb" id="page_chb" <?php if ($page) echo 'checked' ?> /> <label for="page_chb" class="wpsl-label"><?php _e('Add by default for new pages', 'wp-social-likes') ?></label> <input type="submit" name="apply_to_pages" id="apply_to_pages" value="<?php _e('Apply to existing pages', 'wp-social-likes') ?>" class="button-secondary" /> </td> </tr> </table> <div class="row"> <div id="preview" class="shadow-border" <?php if ($this->lang == 'ru-RU') echo 'language="ru"' ?> ></div> </div> <?php submit_button(); ?> </form> </div> <?php } function submit_admin_form() { $options = array( 'skin' => $_POST['skin'], 'look' => $_POST['look'], 'post' => isset($_POST['post_chb']), 'page' => isset($_POST['page_chb']), 'pinterestImg' => isset($_POST['pinterest_img']), 'twitterVia' => $_POST['twitter_via'], //'twitterRel' => $_POST['twitter_rel'], 'iconsOnly' => isset($_POST['icons']), 'counters' => isset($_POST['counters']), 'zeroes' => isset($_POST['zeroes']), 'buttons' => array() ); if (isset($_POST['site'])) { foreach ($_POST['site'] as $btn) { if (in_array($btn, $this->buttons)) { array_push($options['buttons'], $btn); } } } update_option(self::OPTION_NAME_MAIN, $options); $this-><API key>(); } function <API key>($content) { global $post; if (get_post_meta($post->ID, 'sociallikes', true)) { $index = strripos($content, ' '); $content = substr_replace($content, '', $index); } return $content; } function <API key>($content) { if (is_feed()) { $content = preg_replace("/<div.*(class)=(\"|')social-likes(\"|').*>.*<\/div>/smUi", '', $content); } return $content; } function shortcode_content() { global $post; if ($this->options['shortcode']) { return $this->build_buttons($post); } return ''; } function add_action_links($all_links, $current_file) { if (basename(__FILE__) == basename($current_file)) { $<API key> = explode('/', plugin_basename(__FILE__)); $plugin_file_name = $<API key>[count($<API key>) - 1]; $settings_link = '<a href="' . admin_url('options-general.php?page=' . $plugin_file_name) . '">' . __('Settings', 'wp-social-likes') . '</a>'; array_unshift($all_links, $settings_link); } return $all_links; } function <API key>() { return $this->button_is_active('lj_btn') || $this->button_is_active('linkedin_btn') || $this->button_is_active('email_btn'); } function button_is_active($name) { return in_array($name, $this->options['buttons']); } function load_options() { $options = $this-><API key>(); if (!$options) { $options = get_option(self::OPTION_NAME_MAIN); if (!$options || !is_array($options)) { $options = array( 'counters' => true, 'look' => 'h', 'post' => true, 'skin' => 'classic' ); } if (!$options['buttons'] || !is_array($options['buttons'])) { $options['buttons'] = array(); for ($i = 0; $i < 4; $i++) { array_push($options['buttons'], $this->buttons[$i]); } } } $options['customLocale'] = get_option(self::<API key>); $options['placement'] = get_option(self::<API key>); $options['shortcode'] = get_option(self::<API key>) == 'enabled'; $options['excerpts'] = get_option(self::<API key>) == 'enabled'; $defaultValues = array( 'look' => 'h', 'skin' => 'classic', 'twitterVia' => '', 'twitterRel' => '' ); foreach ($defaultValues as $key => $value) { if (!isset($options[$key]) || !$options[$key]) { $options[$key] = $value; } } $this->options = $options; } function <API key>() { if (!get_option('sociallikes_skin') || !get_option('sociallikes_look')) { return null; } $options = array( 'skin' => get_option('sociallikes_skin'), 'look' => get_option('sociallikes_look'), 'post' => get_option('sociallikes_post'), 'page' => get_option('sociallikes_page'), 'pinterestImg' => get_option('<API key>'), 'twitterVia' => get_option('<API key>'), 'twitterRel' => get_option('<API key>'), 'iconsOnly' => get_option('sociallikes_icons'), 'counters' => get_option('<API key>'), 'zeroes' => get_option('sociallikes_zeroes'), 'buttons' => array() ); for ($i = 1; $i <= 8; $i++) { $option = 'pos' . $i; $btn = get_option($option); if (get_option($btn)) { array_push($options['buttons'], $btn); } } return $options; } function <API key>() { delete_option('<API key>'); delete_option('sociallikes_look'); delete_option('<API key>'); delete_option('<API key>'); delete_option('<API key>'); delete_option('sociallikes_post'); delete_option('sociallikes_page'); delete_option('sociallikes_skin'); delete_option('sociallikes_icons'); delete_option('sociallikes_zeroes'); delete_option('vk_btn'); delete_option('facebook_btn'); delete_option('twitter_btn'); delete_option('google_btn'); delete_option('pinterest_btn'); delete_option('lj_btn'); delete_option('odn_btn'); delete_option('mm_btn'); delete_option('pos1'); delete_option('pos2'); delete_option('pos3'); delete_option('pos4'); delete_option('pos5'); delete_option('pos6'); delete_option('pos7'); delete_option('pos8'); } } $wpsociallikes = new wpsociallikes(); function social_likes($postId = null) { echo get_social_likes($postId); } function get_social_likes($postId = null) { $post = get_post($postId); global $wpsociallikes; return $post != null ? $wpsociallikes->build_buttons($post) : ''; } ?>
// <API key>.h // VKMessenger #import "<API key>.h" @interface <API key> : <API key> <<API key>> @property (weak, nonatomic) IBOutlet UIImageView *image; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *<API key>; @end
<?php namespace VuFind\Statistics; class Record extends AbstractBase { /** * Saves the record view to wherever the config [Statistics] says so * * @param \VuFind\Search\Base\Results $data Results from Search controller * @param <API key> $request Request data * * @return void */ public function log($data, $request) { $this->save( array( 'recordId' => $data->getUniqueId(), 'recordSource' => $data->getResourceSource() ), $request ); } /** * Returns a set of basic statistics including total records * and most commonly viewed records. * * @param integer $listLength How long the top list is * @param bool $bySource Sort record views by source? * * @return array */ public function getStatsSummary($listLength = 5, $bySource = false) { foreach ($this->getDrivers() as $driver) { $summary = $driver->getFullList('recordId'); if (!empty($summary)) { $sources = $driver->getFullList('recordSource'); $hashes = array(); // Generate hashes (faster than grouping by looping) for ($i=0;$i<count($summary);$i++) { $source = $sources[$i]['recordSource']; $id = $summary[$i]['recordId']; $hashes[$source][$id] = isset($hashes[$source][$id]) ? $hashes[$source][$id] + 1 : 1; } $top = array(); // For each source foreach ($hashes as $source=>$records) { // Using a reference to consolidate code dramatically $reference =& $top; if ($bySource) { $top[$source] = array(); $reference =& $top[$source]; } // For each record foreach ($records as $id=>$count) { $newRecord = array( 'value' => $id, 'count' => $count, 'source' => $source ); // Insert sort (limit to listLength) for ($i=0;$i<$listLength-1 && $i<count($reference);$i++) { if ($count > $reference[$i]['count']) { // Insert in order array_splice($reference, $i, 0, array($newRecord)); continue 2; // Skip the append after this loop } } if (count($reference) < $listLength) { $reference[] = $newRecord; } } $reference = array_slice($reference, 0, $listLength); } return array( 'top' => $top, 'total' => count($summary) ); } } return array(); } }
<?php namespace eZ\Publish\Core\Base\Container\Compiler\Search\Legacy; use Symfony\Component\DependencyInjection\Compiler\<API key>; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Definition; /** * This compiler pass will register Legacy Search Engine criterion handlers. */ class <API key> implements <API key> { /** * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container */ public function process(ContainerBuilder $container) { if ( !$container->hasDefinition('ezpublish.search.legacy.gateway.criteria_converter.content') && !$container->hasDefinition('ezpublish.search.legacy.gateway.criteria_converter.location') && !$container->hasDefinition('ezplatform.trash.search.legacy.gateway.criteria_converter') && !$container->hasDefinition('ezpublish.spi.persistence.legacy.url.criterion_converter') ) { return; } if ($container->hasDefinition('ezpublish.search.legacy.gateway.criteria_converter.content')) { $<API key> = $container->getDefinition('ezpublish.search.legacy.gateway.criteria_converter.content'); $contentHandlers = $container-><API key>('ezpublish.search.legacy.gateway.criterion_handler.content'); $this->addHandlers($<API key>, $contentHandlers); } if ($container->hasDefinition('ezpublish.search.legacy.gateway.criteria_converter.location')) { $<API key> = $container->getDefinition('ezpublish.search.legacy.gateway.criteria_converter.location'); $locationHandlers = $container-><API key>('ezpublish.search.legacy.gateway.criterion_handler.location'); $this->addHandlers($<API key>, $locationHandlers); } if ($container->hasDefinition('ezplatform.trash.search.legacy.gateway.criteria_converter')) { $<API key> = $container->getDefinition('ezplatform.trash.search.legacy.gateway.criteria_converter'); $<API key> = $container-><API key>('ezplatform.trash.search.legacy.gateway.criterion_handler'); $this->addHandlers($<API key>, $<API key>); } if ($container->hasDefinition('ezpublish.spi.persistence.legacy.url.criterion_converter')) { $<API key> = $container->getDefinition('ezpublish.spi.persistence.legacy.url.criterion_converter'); $urlCriteriaHandlers = $container-><API key>('ezpublish.persistence.legacy.url.criterion_handler'); $this->addHandlers($<API key>, $urlCriteriaHandlers); } } protected function addHandlers(Definition $definition, $handlers) { foreach ($handlers as $id => $attributes) { $definition->addMethodCall('addHandler', [new Reference($id)]); } } }
#ifndef UI_UNDOVIEW_H #define UI_UNDOVIEW_H #include <QtWidgets/QUndoView> namespace ui { class UndoView : public QUndoView { Q_OBJECT public: explicit UndoView(QWidget *parent = 0); signals: public slots: }; } // namespace ui #endif // UI_UNDOVIEW_H
<?php global $post; if( tie_get_option( 'archives_socail' ) ):?> <div class="mini-share-post"> <ul> <li><a href="https://twitter.com/share" class="<TwitterConsumerkey>" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-via="<?php echo tie_get_option( '<API key>' ) ?>" data-lang="en">tweet</a> <script>!function(d,s,id){var js,fjs=d.<API key>(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></li> <li> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.<API key>(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="<?php the_permalink(); ?>" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div> </li> <li><div class="g-plusone" data-size="medium" data-href="<?php the_permalink(); ?>"></div> <script type='text/javascript'> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.<API key>('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> </li> <li><script type="text/javascript" src="http: </ul> </div> <!-- .share-post --> <?php endif; ?>
#define RTC_VERSION "1.09b" #include <linux/bcd.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/smp_lock.h> #include <linux/types.h> #include <linux/miscdevice.h> #include <linux/ioport.h> #include <linux/fcntl.h> #include <linux/rtc.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/proc_fs.h> #include <asm/m48t35.h> #include <asm/sn/ioc3.h> #include <asm/io.h> #include <asm/uaccess.h> #include <asm/system.h> #include <asm/sn/klconfig.h> #include <asm/sn/sn0/ip27.h> #include <asm/sn/sn0/hub.h> #include <asm/sn/sn_private.h> static long rtc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data); static void get_rtc_time(struct rtc_time *rtc_tm); /* * Bits in rtc_status. (6 bits of room for future expansion) */ #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ #define RTC_TIMER_ON 0x02 /* missed irq timer active */ static unsigned char rtc_status; /* bitmapped status byte. */ static unsigned long rtc_freq; /* Current periodic IRQ rate */ static struct m48t35_rtc *rtc; /* * If this driver ever becomes modularised, it will be really nice * to make the epoch retain its value across module reload... */ static unsigned long epoch = 1970; /* year corresponding to 0x00 */ static const unsigned char days_in_mo[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; static long rtc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct rtc_time wtime; switch (cmd) { case RTC_RD_TIME: /* Read the time/date from RTC */ { get_rtc_time(&wtime); break; } case RTC_SET_TIME: /* Set the RTC */ { struct rtc_time rtc_tm; unsigned char mon, day, hrs, min, sec, leap_yr; unsigned int yrs; if (!capable(CAP_SYS_TIME)) return -EACCES; if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, sizeof(struct rtc_time))) return -EFAULT; yrs = rtc_tm.tm_year + 1900; mon = rtc_tm.tm_mon + 1; /* tm_mon starts at zero */ day = rtc_tm.tm_mday; hrs = rtc_tm.tm_hour; min = rtc_tm.tm_min; sec = rtc_tm.tm_sec; if (yrs < 1970) return -EINVAL; leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400)); if ((mon > 12) || (day == 0)) return -EINVAL; if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr))) return -EINVAL; if ((hrs >= 24) || (min >= 60) || (sec >= 60)) return -EINVAL; if ((yrs -= epoch) > 255) /* They are unsigned */ return -EINVAL; if (yrs > 169) return -EINVAL; if (yrs >= 100) yrs -= 100; sec = bin2bcd(sec); min = bin2bcd(min); hrs = bin2bcd(hrs); day = bin2bcd(day); mon = bin2bcd(mon); yrs = bin2bcd(yrs); spin_lock_irq(&rtc_lock); rtc->control |= M48T35_RTC_SET; rtc->year = yrs; rtc->month = mon; rtc->date = day; rtc->hour = hrs; rtc->min = min; rtc->sec = sec; rtc->control &= ~M48T35_RTC_SET; spin_unlock_irq(&rtc_lock); return 0; } default: return -EINVAL; } return copy_to_user((void *)arg, &wtime, sizeof wtime) ? -EFAULT : 0; } /* * We enforce only one user at a time here with the open/close. * Also clear the previous interrupt data on an open, and clean * up things on a close. */ static int rtc_open(struct inode *inode, struct file *file) { lock_kernel(); spin_lock_irq(&rtc_lock); if (rtc_status & RTC_IS_OPEN) { spin_unlock_irq(&rtc_lock); unlock_kernel(); return -EBUSY; } rtc_status |= RTC_IS_OPEN; spin_unlock_irq(&rtc_lock); unlock_kernel(); return 0; } static int rtc_release(struct inode *inode, struct file *file) { /* * Turn off all interrupts once the device is no longer * in use, and clear the data. */ spin_lock_irq(&rtc_lock); rtc_status &= ~RTC_IS_OPEN; spin_unlock_irq(&rtc_lock); return 0; } /* * The various file operations we support. */ static const struct file_operations rtc_fops = { .owner = THIS_MODULE, .unlocked_ioctl = rtc_ioctl, .open = rtc_open, .release = rtc_release, }; static struct miscdevice rtc_dev= { RTC_MINOR, "rtc", &rtc_fops }; static int __init rtc_init(void) { rtc = (struct m48t35_rtc *) (<API key>(master_nasid)->memory_base + IOC3_BYTEBUS_DEV0); printk(KERN_INFO "Real Time Clock Driver v%s\n", RTC_VERSION); if (misc_register(&rtc_dev)) { printk(KERN_ERR "rtc: cannot register misc device.\n"); return -ENODEV; } if (!<API key>("driver/rtc", 0, NULL, rtc_read_proc, NULL)) { printk(KERN_ERR "rtc: cannot create /proc/rtc.\n"); misc_deregister(&rtc_dev); return -ENOENT; } rtc_freq = 1024; return 0; } static void __exit rtc_exit (void) { /* interrupts and timer disabled at this point by rtc_release */ remove_proc_entry ("rtc", NULL); misc_deregister(&rtc_dev); } module_init(rtc_init); module_exit(rtc_exit); /* * Info exported via "/proc/rtc". */ static int rtc_get_status(char *buf) { char *p; struct rtc_time tm; /* * Just emulate the standard /proc/rtc */ p = buf; get_rtc_time(&tm); /* * There is no way to tell if the luser has the RTC set for local * time or for Universal Standard Time (GMT). Probably local though. */ p += sprintf(p, "rtc_time\t: %02d:%02d:%02d\n" "rtc_date\t: %04d-%02d-%02d\n" "rtc_epoch\t: %04lu\n" "24hr\t\t: yes\n", tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, epoch); return p - buf; } static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { int len = rtc_get_status(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 get_rtc_time(struct rtc_time *rtc_tm) { /* * Do we need to wait for the last update to finish? */ /* * Only the values that we read from the RTC are set. We leave * tm_wday, tm_yday and tm_isdst untouched. Even though the * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated * by the RTC when initially set to a non-zero value. */ spin_lock_irq(&rtc_lock); rtc->control |= M48T35_RTC_READ; rtc_tm->tm_sec = rtc->sec; rtc_tm->tm_min = rtc->min; rtc_tm->tm_hour = rtc->hour; rtc_tm->tm_mday = rtc->date; rtc_tm->tm_mon = rtc->month; rtc_tm->tm_year = rtc->year; rtc->control &= ~M48T35_RTC_READ; spin_unlock_irq(&rtc_lock); rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); /* * Account for differences between how the RTC uses the values * and how they are defined in a struct rtc_time; */ if ((rtc_tm->tm_year += (epoch - 1900)) <= 69) rtc_tm->tm_year += 100; rtc_tm->tm_mon }
<!DOCTYPE html> <html> <head> <title>Asterisk Project : Asterisk Standard Channel Variables</title> <link rel="stylesheet" href="styles/site.css" type="text/css" /> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body class="theme-default aui-theme-default"> <div id="page"> <div id="main" class="aui-page-panel"> <div id="main-header"> <div id="breadcrumb-section"> <ol id="breadcrumbs"> <li class="first"> <span><a href="index.html">Asterisk Project</a></span> </li> <li> <span><a href="<API key>.html">Configuration and Operation</a></span> </li> <li> <span><a href="<API key>.html">Channel Variables</a></span> </li> </ol> </div> <h1 id="title-heading" class="pagetitle"> <span id="title-text"> Asterisk Project : Asterisk Standard Channel Variables </span> </h1> </div> <div id="content" class="view"> <div class="page-metadata"> Added by mdavenport , edited by mjordan on Aug 11, 2012 </div> <div id="main-content" class="wiki-content group"> <p>There are a number of variables that are defined or read by Asterisk. Here is a listing of them. More information is available in each application's help text. All these variables are in UPPER CASE only.</p> <p>Variables marked with a * are builtin functions and can't be set, only read in the dialplan. Writes to such variables are silently ignored.</p> <h3 id="<API key>.8andforward%3A">Variables present in Asterisk 1.8 and forward:</h3> <ul> <li>${CDR(accountcode)} * - Account code (if specified)</li> <li>${BLINDTRANSFER} - The name of the channel on the other side of a blind transfer</li> <li>${BRIDGEPEER} - Bridged peer</li> <li>${BRIDGEPVTCALLID} - Bridged peer PVT call ID (SIP Call ID if a SIP call)</li> <li>${CALLERID(ani)} * - Caller ANI (PRI channels)</li> <li>${CALLERID(ani2)} * - ANI2 (Info digits) also called Originating line information or OLI</li> <li>${CALLERID(all)} * - Caller ID</li> <li>${CALLERID(dnid)} * - Dialed Number Identifier</li> <li>${CALLERID(name)} * - Caller ID Name only</li> <li>${CALLERID(num)} * - Caller ID Number only</li> <li>${CALLERID(rdnis)} * - Redirected Dial Number ID Service</li> <li>${CALLINGANI2} * - Caller ANI2 (PRI channels)</li> <li>${CALLINGPRES} * - Caller ID presentation for incoming calls (PRI channels)</li> <li>${CALLINGTNS} * - Transit Network Selector (PRI channels)</li> <li>${CALLINGTON} * - Caller Type of Number (PRI channels)</li> <li>${CHANNEL} * - Current channel name</li> <li>${CONTEXT} * - Current context</li> <li>${DATETIME} * - Current date time in the format: DDMMYYYY-HH:MM:SS (Deprecated; use ${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)})</li> <li>${DB_RESULT} - Result value of DB_EXISTS() dial plan function</li> <li>${EPOCH} * - Current unix style epoch</li> <li>${EXTEN} * - Current extension</li> <li>${ENV(VAR)} - Environmental variable VAR</li> <li>${GOTO_ON_BLINDXFR} - Transfer to the specified context/extension/priority after a blind transfer (use ^ characters in place of | to separate context/extension/priority when setting this variable from the dialplan)</li> <li>${HANGUPCAUSE} * - Asterisk cause of hangup (inbound/outbound)</li> <li>${HINT} * - Channel hints for this extension</li> <li>${HINTNAME} * - Suggested Caller*ID name for this extension</li> <li>${INVALID_EXTEN} - The invalid called extension (used in the &quot;i&quot; extension)</li> <li>${LANGUAGE} * - Current language (Deprecated; use ${LANGUAGE()})</li> <li>${LEN(VAR)} - String length of VAR (integer)</li> <li>${PRIORITY} * - Current priority in the dialplan</li> <li>${PRIREDIRECTREASON} - Reason for redirect on PRI, if a call was directed</li> <li>${TIMESTAMP} * - Current date time in the format: YYYYMMDD-HHMMSS (Deprecated; use ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})</li> <li>${TRANSFER_CONTEXT} - Context for transferred calls</li> <li>${FORWARD_CONTEXT} - Context for forwarded calls</li> <li>${DYNAMIC_PEERNAME} - The name of the channel on the other side when a dynamic feature is used.</li> <li>${DYNAMIC_FEATURENAME} The name of the last triggered dynamic feature.</li> <li>${UNIQUEID} * - Current call unique identifier</li> <li>${SYSTEMNAME} * - value of the systemname option of asterisk.conf</li> <li>${ENTITYID} * - Global Entity ID set automatically, or from asterisk.conf</li> </ul> <h3 id="<API key>%3A">Variables present in Asterisk 11 and forward:</h3> <ul> <li>${AGIEXITONHANGUP} - set to <code>1</code> to force the behavior of a call to AGI to behave as it did in 1.4, where the AGI script would exit immediately on detecting a channel hangup</li> <li>${CALENDAR_SUCCESS} * - Status of the <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+<API key>">CALENDAR_WRITE</a> function. Set to <code>1</code> if the function completed successfully; <code>0</code> otherwise.</li> <li>${SIP_RECVADDR} * - the address a SIP MESSAGE request was received from</li> <li>${<API key>} * - Status of the <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+<API key>">VoiceMailPlayMsg</a> application. <code>SUCCESS</code> if the voicemail was played back successfully, {{FAILED} otherwise</li> </ul> </div> </div> </div> <div id="footer"> <section class="footer-body"> <p>Document generated by Confluence on Dec 20, 2013 14:18</p> </section> </div> </div> </body> </html>
<?php class Miscinfo_b extends Lxaclass { static $__desc_realname = array("", "", "real_name"); static $__desc_paddress = array("", "", "personal_address"); static $__desc_padd_city = array("", "", "city"); static $__desc_padd_country = array( "", "", "Country", "Country of the Client"); static $__desc_ptelephone = array("", "", "telephone_no"); static $__desc_caddress = array("", "", "company_address"); static $__desc_cadd_country = array("", "", "country" ); static $__desc_cadd_city = array("", "", "city"); static $__desc_ctelephone = array("", "", "telephone"); static $__desc_cfax = array("", "", "fax"); static $__desc_text_comment = array("t", "", "comments"); } class sp_Miscinfo extends LxSpecialClass { static $__desc = array("","", "miscinfo"); static $__desc_nname = array("", "", "name"); static $__desc_miscinfo_b = array("", "", "<API key>"); static $<API key> = array("","", "details"); function updateform($subaction, $param) { $vlist['nname']= array('M', $this->getSpecialname()); $vlist['<API key>']= ""; $vlist['<API key>']= ""; $vlist['<API key>']= ""; $vlist['<API key>']= ""; $vlist['<API key>']= ""; $vlist['<API key>']= ""; $vlist['<API key>']= ""; $vlist['<API key>']= ""; $vlist['<API key>']= ""; $vlist['miscinfo_b_s_cfax']= ""; return $vlist; } }
<?php defined( '_JEXEC' ) or die; $after_html = '<span class="switch notice">'.JText::_( '<API key>' ).JText::_( '<API key>' ).'</span>'; $object = 'joomla_user_group'; echo JCckDev::renderForm( 'core_form', '', $config, array( 'label'=>'Content Type2', 'selectlabel'=>'None', 'options'=>'Linked to Content Type=optgroup', 'options2'=>'{"query":"","table":"#__cck_core_types","name":"title","where":"published=1 AND storage_location=\"'.$object.'\"","value":"name","orderby":"title","orderby_direction":"ASC","limit":"","language_detection":"joomla","language_codes":"EN,GB,US,FR","language_default":"EN"}', 'bool4'=>1, 'required'=>'', 'css'=>'storage-cck-more', 'attributes'=>'disabled="disabled"', 'storage_field'=>'storage_cck' ), array( 'after'=>$after_html ), 'w100' ); ?>
/* $Id: leo.h,v 1.4 2005-07-07 11:55:42 fzago-guest Exp $ */ /* Commands supported by the scanner. */ #define <API key> 0x00 #define SCSI_INQUIRY 0x12 #define SCSI_SCAN 0x1b #define SCSI_SET_WINDOW 0x24 #define SCSI_READ_10 0x28 #define SCSI_SEND_10 0x2a #define SCSI_REQUEST_SENSE 0x03 #define <API key> 0x34 typedef struct { unsigned char data[16]; int len; } CDB; /* Set a specific bit depending on a boolean. * MKSCSI_BIT(TRUE, 3) will generate 0x08. */ #define MKSCSI_BIT(bit, pos) ((bit)? 1<<(pos): 0) /* Set a value in a range of bits. * MKSCSI_I2B(5, 3, 5) will generate 0x28 */ #define MKSCSI_I2B(bits, pos_b, pos_e) ((bits) << (pos_b) & ((1<<((pos_e)-(pos_b)+1))-1)) /* Store an integer in 2, 3 or 4 byte in an array. */ #define Ito16(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 0) & 0xff; \ } #define Ito24(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 16) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[2] = ((val) >> 0) & 0xff; \ } #define Ito32(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 24) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 16) & 0xff; \ ((unsigned char *)buf)[2] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[3] = ((val) >> 0) & 0xff; \ } #define <API key>(cdb, wait, buflen) \ cdb.data[0] = <API key>; \ cdb.data[1] = MKSCSI_BIT(wait, 0); \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.data[6] = 0; \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_INQUIRY(cdb, buflen) \ cdb.data[0] = SCSI_INQUIRY; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = buflen; \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_SCAN(cdb) \ cdb.data[0] = SCSI_SCAN; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_SEND_10(cdb, dtc, dtq, buflen) \ cdb.data[0] = SCSI_SEND_10; \ cdb.data[1] = 0; \ cdb.data[2] = (dtc); \ cdb.data[3] = 0; \ cdb.data[4] = (((dtq) >> 8) & 0xff); \ cdb.data[5] = (((dtq) >> 0) & 0xff); \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_SET_WINDOW(cdb, buflen) \ cdb.data[0] = SCSI_SET_WINDOW; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_READ_10(cdb, dtc, dtq, buflen) \ cdb.data[0] = SCSI_READ_10; \ cdb.data[1] = 0; \ cdb.data[2] = (dtc); \ cdb.data[3] = 0; \ cdb.data[4] = (((dtq) >> 8) & 0xff); \ cdb.data[5] = (((dtq) >> 0) & 0xff); \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define <API key>(cdb, buflen) \ cdb.data[0] = SCSI_REQUEST_SENSE; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = (buflen); \ cdb.data[5] = 0; \ cdb.len = 6; #define <API key>(cdb) \ cdb.data[0] = <API key>; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.len = 6; static int getbitfield(unsigned char *pageaddr, int mask, int shift) { return ((*pageaddr >> shift) & mask); } /* defines for request sense return block */ #define <API key>(b) getbitfield(b + 0x00, 1, 7) #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0) #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7) #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6) #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5) #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0) #define get_RS_information(b) getnbyte(b+0x03, 4) #define <API key>(b) b[0x07] #define get_RS_ASC(b) b[0x0c] #define get_RS_ASCQ(b) b[0x0d] #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) #define mmToIlu(mm) (((mm) * dev->x_resolution) / SANE_MM_PER_INCH) #define iluToMm(ilu) (((ilu) * SANE_MM_PER_INCH) / dev->x_resolution) #define GAMMA_LENGTH 0x100 /* number of value per color */ enum Leo_Option { /* Must come first */ OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, /* scanner modes */ OPT_RESOLUTION, /* X and Y resolution */ OPT_GEOMETRY_GROUP, OPT_TL_X, /* upper left X */ OPT_TL_Y, /* upper left Y */ OPT_BR_X, /* bottom right X */ OPT_BR_Y, /* bottom right Y */ <API key>, OPT_CUSTOM_GAMMA, /* Use the custom gamma tables */ OPT_GAMMA_VECTOR_R, /* Custom Red gamma table */ OPT_GAMMA_VECTOR_G, /* Custom Green Gamma table */ OPT_GAMMA_VECTOR_B, /* Custom Blue Gamma table */ <API key>, /* Custom Gray Gamma table */ <API key>, /* Halftone pattern */ OPT_PREVIEW, /* preview mode */ /* must come last: */ OPT_NUM_OPTIONS }; /* * Scanner supported by this backend. */ struct scanners_supported { int scsi_type; char scsi_vendor[9]; char scsi_product[17]; const char *real_vendor; const char *real_product; }; #define BLACK_WHITE_STR SANE_I18N("Black & White") #define GRAY_STR SANE_I18N("Grayscale") #define COLOR_STR SANE_I18N("Color") /* Define a scanner occurence. */ typedef struct Leo_Scanner { struct Leo_Scanner *next; SANE_Device sane; char *devicename; int sfd; /* device handle */ /* Infos from inquiry. */ char scsi_type; char scsi_vendor[9]; char scsi_product[17]; char scsi_version[5]; SANE_Range res_range; int x_resolution_max; /* maximum X dpi */ int y_resolution_max; /* maximum Y dpi */ /* SCSI handling */ size_t buffer_size; /* size of the buffer */ SANE_Byte *buffer; /* for SCSI transfer. */ /* Scanner infos. */ const struct scanners_supported *def; /* default options for that scanner */ /* Scanning handling. */ int scanning; /* TRUE if a scan is running. */ int x_resolution; /* X resolution in DPI */ int y_resolution; /* Y resolution in DPI */ int x_tl; /* X top left */ int y_tl; /* Y top left */ int x_br; /* X bottom right */ int y_br; /* Y bottom right */ int width; /* width of the scan area in mm */ int length; /* length of the scan area in mm */ int pass; /* current pass number */ enum { LEO_BW, LEO_HALFTONE, LEO_GRAYSCALE, LEO_COLOR } scan_mode; int depth; /* depth per color */ size_t bytes_left; /* number of bytes left to give to the backend */ size_t real_bytes_left; /* number of bytes left the scanner will return. */ SANE_Byte *image; /* keep the raw image here */ size_t image_size; /* allocated size of image */ size_t image_begin; /* first significant byte in image */ size_t image_end; /* first free byte in image */ SANE_Parameters params; /* Options */ <API key> opt[OPT_NUM_OPTIONS]; Option_Value val[OPT_NUM_OPTIONS]; /* Gamma table. 1 array per colour. */ SANE_Word gamma_R[GAMMA_LENGTH]; SANE_Word gamma_G[GAMMA_LENGTH]; SANE_Word gamma_B[GAMMA_LENGTH]; SANE_Word gamma_GRAY[GAMMA_LENGTH]; } Leo_Scanner; /* Debug levels. * Should be common to all backends. */ #define DBG_error0 0 #define DBG_error 1 #define DBG_sense 2 #define DBG_warning 3 #define DBG_inquiry 4 #define DBG_info 5 #define DBG_info2 6 #define DBG_proc 7 #define DBG_read 8 #define DBG_sane_init 10 #define DBG_sane_proc 11 #define DBG_sane_info 12 #define DBG_sane_option 13 /* 32 bits from an array to an integer (eg ntohl). */ #define B32TOI(buf) \ ((((unsigned char *)buf)[0] << 24) | \ (((unsigned char *)buf)[1] << 16) | \ (((unsigned char *)buf)[2] << 8) | \ (((unsigned char *)buf)[3] << 0)) #define B24TOI(buf) \ ((((unsigned char *)buf)[0] << 16) | \ (((unsigned char *)buf)[1] << 8) | \ (((unsigned char *)buf)[2] << 0)) #define B16TOI(buf) \ ((((unsigned char *)buf)[0] << 8) | \ (((unsigned char *)buf)[1] << 0)) /* Downloadable halftone patterns */ typedef unsigned char halftone_pattern_t[256]; static const halftone_pattern_t <API key> = { 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0 }; static const halftone_pattern_t <API key> = { 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xC6, 0x96, 0x76, 0x4E, 0x46, 0x6E, 0x9E, 0xCE, 0xC6, 0x96, 0x76, 0x4E, 0x46, 0x6E, 0x9E, 0xCE, 0x2A, 0x62, 0x82, 0xA2, 0xAA, 0x8A, 0x7A, 0x22, 0x2A, 0x62, 0x82, 0xA2, 0xAA, 0x8A, 0x7A, 0x22, 0x0A, 0x32, 0xDA, 0xF2, 0xFE, 0xB2, 0x5A, 0x02, 0x0A, 0x32, 0xDA, 0xF2, 0xFE, 0xB2, 0x5A, 0x02, 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xC6, 0x96, 0x76, 0x4E, 0x46, 0x6E, 0x9E, 0xCE, 0xC6, 0x96, 0x76, 0x4E, 0x46, 0x6E, 0x9E, 0xCE, 0x2A, 0x62, 0x82, 0xA2, 0xAA, 0x8A, 0x7A, 0x22, 0x2A, 0x62, 0x82, 0xA2, 0xAA, 0x8A, 0x7A, 0x22, 0x0A, 0x32, 0xDA, 0xF2, 0xFE, 0xB2, 0x5A, 0x02, 0x0A, 0x32, 0xDA, 0xF2, 0xFE, 0xB2, 0x5A, 0x02 }; static const halftone_pattern_t <API key> = { 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76, 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76, 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76, 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76 }; static const halftone_pattern_t <API key> = { 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0x46, 0xD6, 0xC6, 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0x46, 0xD6, 0xC6, 0xBE, 0x0E, 0x1E, 0x5E, 0xB6, 0x06, 0x16, 0x56, 0xBE, 0x0E, 0x1E, 0x5E, 0xB6, 0x06, 0x16, 0x56, 0x7E, 0x3E, 0x2E, 0x9E, 0x76, 0x36, 0x26, 0x96, 0x7E, 0x3E, 0x2E, 0x9E, 0x76, 0x36, 0x26, 0x96, 0xEE, 0xAE, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6, 0xEE, 0xAE, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6, 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0x46, 0xD6, 0xC6, 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0x46, 0xD6, 0xC6, 0xBE, 0x0E, 0x1E, 0x5E, 0xB6, 0x06, 0x16, 0x56, 0xBE, 0x0E, 0x1E, 0x5E, 0xB6, 0x06, 0x16, 0x56, 0x7E, 0x3E, 0x2E, 0x9E, 0x76, 0x36, 0x26, 0x96, 0x7E, 0x3E, 0x2E, 0x9E, 0x76, 0x36, 0x26, 0x96, 0xEE, 0xAE, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6, 0xEE, 0xAE, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6 }; static const halftone_pattern_t <API key> = { 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6, 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6, 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6, 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6 };
#include "<API key>.hpp" #include "<API key>.hpp" using namespace adaptative::logic; using namespace adaptative::playlist; <API key>::<API key>(): <API key>() { } BaseRepresentation *<API key>::<API key>(BaseAdaptationSet *adaptSet) const { <API key> selector; return selector.select(adaptSet, 0); }
package com.oa.bean; public class FeedBackInfo { private Long id; private String feedbackinfo; private String userid; private String date; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getFeedbackinfo() { return feedbackinfo; } public void setFeedbackinfo(String feedbackinfo) { this.feedbackinfo = feedbackinfo; } public String getUserid() { return userid; } public void setUserid(String userid) { this.userid = userid; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } }
<?php include('../../../operaciones.php'); conectar(); apruebadeintrusos(); if($_SESSION['cargo_user']!="Bodeguero"){ header('Location: ../../../login.php'); } ?> <html lang="en"> <head> <title>PNKS Inventario - Estadística de Productos</title> <!-- BEGIN META --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="keywords" content="your,keywords"> <meta name="description" content="Short explanation about this website"> <!-- END META --> <!-- BEGIN STYLESHEETS --> <link href='http://fonts.googleapis.com/css?family=Roboto:300italic,400italic,300,400,500,700,900' rel='stylesheet' type='text/css'/> <link type="text/css" rel="stylesheet" href="../../../css/bootstrap.css" /> <link type="text/css" rel="stylesheet" href="../../../css/materialadmin.css" /> <link type="text/css" rel="stylesheet" href="../../../css/font-awesome.min.css" /> <link type="text/css" rel="stylesheet" href="../../../css/<API key>.min.css" /> <link type="text/css" rel="stylesheet" href="../../../css/libs/DataTables/jquery.dataTables.css" /> <link type="text/css" rel="stylesheet" href="../../../css/libs/DataTables/extensions/dataTables.colVis.css" /> <link type="text/css" rel="stylesheet" href="../../../css/libs/DataTables/extensions/dataTables.tableTools.css" /> <!-- END STYLESHEETS --> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script type="text/javascript" src="js/libs/utils/html5shiv.js?1403934957"></script> <script type="text/javascript" src="js/libs/utils/respond.min.js?1403934956"></script> <![endif] </head> <body class="menubar-hoverable header-fixed menubar-first menubar-visible menubar-pin"> <!-- BEGIN HEADER--> <header id="header" > <div class="headerbar"> <!-- Brand and toggle get grouped for better mobile display --> <div class="headerbar-left"> <ul class="header-nav header-nav-options"> <li class="header-nav-brand" > <div class="brand-holder"> <a href=""> <span class="text-lg text-bold text-primary">PNKS LTDA</span> </a> </div> </li> <li> <a class="btn btn-icon-toggle menubar-toggle" data-toggle="menubar" href="javascript:void(0);"> <i class="fa fa-bars"></i> </a> </li> </ul> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="headerbar-right"> <ul class="header-nav header-nav-profile"> <li class="dropdown"> <a href="javascript:void(0);" class="dropdown-toggle ink-reaction" data-toggle="dropdown"> <?php if(file_exists('../../../img/usuarios/'.$_SESSION['foto_user'])){ ?> <img src="../../../img/usuarios/<?php echo $_SESSION['foto_user']; ?>" alt="" /> <?php } else { ?> <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNzEiIGhlaWdodD0iMTgwIj48cmVjdCB3aWR0aD0iMTcxIiBoZWlnaHQ9IjE4MCIgZmlsbD0iI2VlZSI+PC9yZWN0Pjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9Ijg1LjUiIHk9IjkwIiBzdHlsZT0iZmlsbDojYWFhO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjEycHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+<API key>="/> <?php } ?> <span class="profile-info"> <?php echo $_SESSION['usuario_session']; ?> <small><?php echo $_SESSION['cargo_user']; ?></small> </span> </a> <ul class="dropdown-menu animation-dock"> <li class="dropdown-header">Opciones de Cuenta</li> <li><a href="../../opcion/cambiarclave.php">Cambiar Clave</a></li> <li><a href="../../opcion/cambiarficha.php">Cambiar Datos Personales</a></li> <li><a href="../../opcion/cambiarfoto.php">Cambiar Foto de Perfil</a></li> <li class="divider"></li> <li><a href="../../../login.php" onClick=""><i class="fa fa-fw fa-power-off text-danger"></i> Salir</a></li> </ul><!--end .dropdown-menu </li><!--end .dropdown </ul><!--end .header-nav-profile </div><!--end #<API key> --> </div> </header> <!-- END HEADER--> <!-- BEGIN BASE--> <div id="base"> <!-- BEGIN OFFCANVAS LEFT --> <div class="offcanvas"> </div><!--end .offcanvas <!-- END OFFCANVAS LEFT --> <!-- BEGIN CONTENT--> <div id="content"> <section> <div class="section-body"> <div class="row"> </div><!--end .row </div><!--end .section-body </section> </div><!--end #content--> <!-- END CONTENT --> <div id="menubar" class="menubar-first"> <div class="menubar-fixed-panel"> <div> <a class="btn btn-icon-toggle btn-default menubar-toggle" data-toggle="menubar" href="javascript:void(0);"> <i class="fa fa-bars"></i> </a> </div> <div class="expanded"> <a href=""> <span class="text-lg text-bold text-primary ">PNKS&nbsp;LTDA</span> </a> </div> </div> <div class="<API key>"> <!-- BEGIN MAIN MENU --> <ul id="main-menu" class="gui-controls"> <!-- BEGIN DASHBOARD --> <li> <a href="../index.php"> <div class="gui-icon"><i class="md md-home"></i></div> <span class="title">Inicio</span> </a> </li> <li> <a href="../producto.php"> <div class="gui-icon"><i class="md md-web"></i></div> <span class="title">Ficha Producto</span> </a> </li><!--end /menu-li <!-- END DASHBOARD --> <!-- BEGIN EMAIL --> <li> <a href="../etiqueta.php"> <div class="gui-icon"><i class="md md-chat"></i></div> <span class="title">Emisión de Etiqueta</span> </a> </li><!--end /menu-li <!-- END EMAIL --> <!-- BEGIN EMAIL --> <li> <li> <a href="../bodega.php"> <div class="gui-icon"><i class="glyphicon glyphicon-list-alt"></i></div> <span class="title">Administración de Bodega</span> </a> </li><!--end /menu-li <!-- END EMAIL --> <!-- BEGIN EMAIL --> <li> <li> <a href="../reserva.php"> <div class="gui-icon"><i class="md md-view-list"></i></div> <span class="title">Control de Reservas</span> </a> </li><!--end /menu-li <!-- END EMAIL --> <!-- BEGIN EMAIL --> <li> <a href="../inventario.php"> <div class="gui-icon"><i class="fa fa-table"></i></div> <span class="title">Inventario</span> </a> </li><!--end /menu-li <!-- END EMAIL --> <!-- BEGIN EMAIL --> <li> <a href="../stock.php"> <div class="gui-icon"><i class="md <API key>"></i></div> <span class="title">Control de Stock</span> </a> </li><!--end /menu-li <!-- END EMAIL --> <!-- BEGIN EMAIL --> <li> <a href="../precio.php"> <div class="gui-icon"><i class="md md-assignment"></i></div> <span class="title">Lista de Precio</span> </a> </li><!--end /menu-li <!-- END EMAIL --> <!-- BEGIN EMAIL --> <li> <a href="../cliente.php"> <div class="gui-icon"><i class="md md-description"></i></div> <span class="title">Ficha Cliente</span> </a> </li><!--end /menu-li <!-- END EMAIL --> <!-- BEGIN EMAIL --> <li class="gui-folder"> <a> <div class="gui-icon"><i class="md md-assessment"></i></div> <span class="title">Informes</span> </a> <!--start submenu <ul> <li><a href="stockbodega.php"><span class="title">Stock por Bodega</span></a></li> <li><a href="guia.php"><span class="title">Entrada y Salida</span></a></li> <li><a href="stock.php"><span class="title">Control de Stock</span></a></li> <li><a href="consumo.php"><span class="title">Consumo Interno</span></a></li> <li><a href="consignacion.php"><span class="title">Consignaciones</span></a></li> <li><a href="estadistica.php" class="active"><span class="title">Estadística de Producto</span></a></li> <li><a href="serie.php"><span class="title">Control de Serie</span></a></li> <li><a href="vencimiento.php" ><span class="title">Vencimiento de Producto</span></a></li> <li><a href="rotacion.php"><span class="title">Rotación de Inventario</span></a></li> <li><a href="toma.php"><span class="title">Toma de Inventario</span></a></li> </ul><!--end /submenu </li><!--end /menu-li <!-- END EMAIL --> </ul><!--end .main-menu <!-- END MAIN MENU --> <div class="menubar-foot-panel"> <small class="no-linebreak hidden-folded"> <span class="opacity-75">&copy; 2015</span> <strong>GH Soluciones Informáticas</strong> </small> </div> </div><!--end .<API key> </div><!--end #menubar--> <!-- END MENUBAR --> </div><!--end #base--> <!-- END BASE --> <!-- BEGIN JAVASCRIPT --> <script src="../../../js/libs/jquery/jquery-1.11.2.min.js"></script> <script src="../../../js/libs/jquery/jquery-migrate-1.2.1.min.js"></script> <script src="../../../js/libs/bootstrap/bootstrap.min.js"></script> <script src="../../../js/libs/spin.js/spin.min.js"></script> <script src="../../../js/libs/autosize/jquery.autosize.min.js"></script> <script src="../../../js/libs/DataTables/jquery.dataTables.min.js"></script> <script src="../../../js/libs/DataTables/extensions/ColVis/js/dataTables.colVis.min.js"></script> <script src="../../../js/libs/DataTables/extensions/TableTools/js/dataTables.tableTools.min.js"></script> <script src="../../../js/libs/nanoscroller/jquery.nanoscroller.min.js"></script> <script src="../../../js/core/source/App.js"></script> <script src="../../../js/core/source/AppNavigation.js"></script> <script src="../../../js/core/source/AppOffcanvas.js"></script> <script src="../../../js/core/source/AppCard.js"></script> <script src="../../../js/core/source/AppForm.js"></script> <script src="../../../js/core/source/AppVendor.js"></script> <!-- END JAVASCRIPT --> </body> </html>
package org.owasp.benchmark.testcode; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/BenchmarkTest17998") public class BenchmarkTest17998 extends HttpServlet { private static final long serialVersionUID = 1L; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = ""; java.util.Enumeration<String> names = request.getParameterNames(); if (names.hasMoreElements()) { param = names.nextElement(); // just grab first element } String bar = doSomething(param); java.io.FileOutputStream fos = new java.io.FileOutputStream(new java.io.File(org.owasp.benchmark.helpers.Utils.testfileDir + bar),false); } // end doPost private static String doSomething(String param) throws ServletException, IOException { String bar = "safe!"; java.util.HashMap<String,Object> map37923 = new java.util.HashMap<String,Object>(); map37923.put("keyA-37923", "a_Value"); // put some stuff in the collection map37923.put("keyB-37923", param.toString()); // put it in a collection map37923.put("keyC", "another_Value"); // put some stuff in the collection bar = (String)map37923.get("keyB-37923"); // get it back out bar = (String)map37923.get("keyA-37923"); // get safe value back out return bar; } }
package Classes::Sentry4; our @ISA = qw(Classes::Device); sub init { my $self = shift; if ($self->mode =~ /device::hardware::health/) { $self-><API key>('Classes::Sentry4::Components::<API key>'); } elsif ($self->mode =~ /device::power::health/) { $self-><API key>('Classes::Sentry4::Components::PowerSubsystem'); } else { $self->no_such_mode(); } if (! $self->check_messages()) { $self->add_ok('hardware working fine'); } }
using System.Windows.Controls; namespace HomeControl { <summary> Interaction logic for UserControl1.xaml </summary> public partial class HomeCtrl : UserControl { public HomeCtrl() { InitializeComponent(); // doug's change... } } }
package adamros.mods.transducers.item; import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import adamros.mods.transducers.Transducers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; public class ItemElectricEngine extends ItemBlock { public ItemElectricEngine(int par1) { super(par1); setHasSubtypes(true); setMaxDamage(0); setUnlocalizedName("itemElectricEngine"); setCreativeTab(Transducers.tabTransducers); } @Override public int getMetadata(int meta) { return meta; } @Override public String getUnlocalizedName(ItemStack is) { String suffix; switch (is.getItemDamage()) { case 0: suffix = "lv"; break; case 1: suffix = "mv"; break; case 2: suffix = "hv"; break; case 3: suffix = "ev"; break; default: suffix = "lv"; break; } return getUnlocalizedName() + "." + suffix; } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); String type; switch (par1ItemStack.getItemDamage()) { case 0: type = "lv"; break; case 1: type = "mv"; break; case 2: type = "hv"; break; case 3: type = "ev"; break; default: type = "lv"; break; } par3List.add(StatCollector.translateToLocal("tip.electricEngine." + type).trim()); } }
<?php /** * @file * Opigno Learning Record Store stats - Course content - Course contexts statistics template file * * @param array $<API key> */ ?> <div class="lrs-stats-widget" id="<API key>"> <h2><?php print t('Course context statistics'); ?></h2> <?php print theme('<API key>', compact('<API key>')); ?> </div>
showWord(["v. ","vin jòn.<br>"])
## see AUTHORS ## This software may be freely redistributed under the terms of the GNU ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import inspect from func import logger from func.config import read_config, BaseConfig from func.commonconfig import FuncdConfig from func.minion.func_arg import * #the arg getter stuff class FuncModule(object): # the version is meant to version = "0.0.0" api_version = "0.0.0" description = "No Description provided" class Config(BaseConfig): pass def __init__(self): config_file = '/etc/func/minion.conf' self.config = read_config(config_file, FuncdConfig) self.__init_log() self.__base_methods = { # __'s so we don't clobber useful names "module_version" : self.__module_version, "module_api_version" : self.<API key>, "module_description" : self.<API key>, "list_methods" : self.__list_methods, "get_method_args" : self.__get_method_args, } self.__init_options() def __init_log(self): log = logger.Logger() self.logger = log.logger def __init_options(self): options_file = '/etc/func/modules/'+self.__class__.__name__+'.conf' self.options = read_config(options_file, self.Config) return def register_rpc(self, handlers, module_name): # add the internal methods, note that this means they # can get clobbbered by subclass versions for meth in self.__base_methods: handlers["%s.%s" % (module_name, meth)] = self.__base_methods[meth] # register our module's handlers for name, handler in self.__list_handlers().items(): handlers["%s.%s" % (module_name, name)] = handler def __list_handlers(self): """ Return a dict of { handler_name, method, ... }. All methods that do not being with an underscore will be exposed. We also make sure to not expose our register_rpc method. """ handlers = {} for attr in dir(self): if self.<API key>(attr): handlers[attr] = getattr(self, attr) return handlers def __list_methods(self): return self.__list_handlers().keys() + self.__base_methods.keys() def __module_version(self): return self.version def <API key>(self): return self.api_version def <API key>(self): return self.description def <API key>(self,attr): if inspect.ismethod(getattr(self, attr)) and attr[0] != '_' and\ attr != 'register_rpc' and attr!='<API key>': return True return False def __get_method_args(self): """ Gets arguments with their formats according to ArgCompatibility class' rules. @return : dict with args or Raise Exception if something wrong happens """ tmp_arg_dict = self.<API key>() #if it is not implemeted then return empty stuff if not tmp_arg_dict: return {} #see if user tried to register an not implemented method :) for method in tmp_arg_dict.iterkeys(): if not hasattr(self,method): raise <API key>("%s is not in %s "%(method,self.__class__.__name__)) #create argument validation instance self.arg_comp = ArgCompatibility(tmp_arg_dict) #see if all registered arguments are there for method in tmp_arg_dict.iterkeys(): self.arg_comp.<API key>(self,method,tmp_arg_dict[method]['args']) #see if the options that were used are OK.. self.arg_comp.validate_all() return tmp_arg_dict def <API key>(self): """ That is the method where users should override in their modules according to be able to send their method arguments to the Overlord. If they dont have it nothing breaks just that one in the base class is called @return : empty {} """ # to know they didnt implement it return {}
package lambda; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; public class Esempio extends JFrame { public Esempio() { init(); } private void init() { BorderLayout b=new BorderLayout(); this.setLayout(b); JButton button=new JButton("Ok"); this.add(button,BorderLayout.SOUTH); this.setSize(400, 300); this.setVisible(true); ActionListener l=new Azione(); button.addActionListener(( e) -> System.out.println("ciao")); } public static void main(String[] args) { Esempio e=new Esempio(); } }
#include <dwt/widgets/ProgressBar.h> namespace dwt { const TCHAR ProgressBar::windowClass[] = PROGRESS_CLASS; ProgressBar::Seed::Seed() : BaseType::Seed(WS_CHILD | PBS_SMOOTH) { } }
<?php require "tableinitiateclass.php"; require "../queryinitiateclass.php"; $tbl = new AddTable; ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Table index</title> </head> <style> table { width:100%; } </style> <body> <?php // just the headers $arrayheaders = array("head1","head2","head3"); // just the rows $arrayrows = array(array("row1-1","row1-2","row1-3"), array("row2-1","row2-2","row2-3"), array("row3-1","row3-2","row3-3"), array("row4-1","row4-2","row4-3"), array("row5-1","row5-2","row5-3")); $query = new AddSql("root","","map_directory_uphrm","localhost"); $arraycolumns = $query->getallColumn("rooms_uphrm"); $arrayfields = $query->getallascolQuery("rooms_uphrm"); // display table styling still unfinished echo $tbl->settblQuery(sizeof($arrayfields),sizeof($arraycolumns),$arraycolumns,$arrayfields); // display search for row and column numbers echo $tbl->gettableData(2,1); // set search query $tbl->searchRows("-3"); // display search query echo $tbl->getsearchResults(); // reset table $tbl->resetAll(); // get query string $getquery = 'current'; // next page $nextpage = $tbl->checkSet($getquery) + 1; // back page $backpage = $tbl->checkSet($getquery) - 1; // display table with restriction of 2 echo $tbl->settblrestrictQuery(sizeof($arrayfields),sizeof($arraycolumns), $arraycolumns,$arrayfields,5, $tbl->checkSet($getquery)); // display back button $totaldist = sizeof($arrayfields) / 5; echo $tbl->toBack($backpage,$getquery); // display next button echo $tbl->toNext($nextpage,$getquery); ?> <button onclick = "ajaxNav()" > Next </button> <button onclick = "ajaxNavb()" > Back </button> <div id = "tableDiv" > </div> <?php echo $tbl->popupDelete(); ?> <script> var count = 1; function ajaxNav() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("tableDiv").innerHTML=xmlhttp.responseText; } } if(count<<?php echo $totaldist; ?>); count++; xmlhttp.open("GET","ajaxnav.php?<?php echo $getquery; ?>="+ count,true); xmlhttp.send(); } function ajaxNavb() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("tableDiv").innerHTML=xmlhttp.responseText; } } if(count>0); count xmlhttp.open("GET","ajaxnav.php?<?php echo $getquery; ?>="+ count,true); xmlhttp.send(); } </script> </body> </html>
package slash.carcosts; import slash.gui.model.AbstractModel; /** * An CurrencyModel holds a Currency and provides get and set * methods for it. * * @author Christian Pesch */ public class CurrencyModel extends AbstractModel { /** * Construct a new CurrencyModel. */ public CurrencyModel() { this(Currency.getCurrency("DM")); } /** * Construct a new CurrencyModel. */ public CurrencyModel(Currency value) { setValue(value); } /** * Get the Currency value that is holded by the model. */ public Currency getValue() { return value; } /** * Set the Currency value to hold. */ public void setValue(Currency newValue) { if (value != newValue) { this.value = newValue; fireStateChanged(); } } public String toString() { return "CurrencyModel(" + value + ")"; } private Currency value; }
/* c) The receipt screen */ .point-of-sale .<API key> { font-size: 10pt; } .point-of-sale .pos-sale-ticket { text-align: left; /* width: 76mm; */ width: 255px; /* background-color: white; */ margin: 0mm,0mm,0mm,0mm; /* padding: 1px; */ /* padding-bottom:1px; */ display: inline-block; font-family: "Tahoma","Inconsolata","Lucida Console", "monospace"; /* font-family: "Inconsolata"; */ /* border-radius: 2px; */ /* box-shadow: 0px 1px 0px white, 0px 3px 0px #C1B9D6, 0px 8px 16px rgba(0, 0, 0, 0.3);*/ } .point-of-sale .pos-sale-ticket .emph{ font-size: 12pt; margin:5px; font-weight: bolder; } .point-of-sale .pos-sale-ticket .ticket{ font-size: 16pt; font-weight: bolder; } .point-of-sale .pos-sale-ticket .titulo{ font-size: 16pt; font-weight: bolder; text-align: center; } .point-of-sale .pos-sale-ticket table { width: 100%; border: 0; table-layout: fixed; border-spacing: 1px 1px; border-collapse: collapse; } .point-of-sale .pos-sale-ticket p { font-size: 9pt; margin: 0px !important; padding: 0 !important; padding-bottom:0px !important; } .point-of-sale .pos-sale-ticket table td { font-size: 9pt; border: 0; margin: 0px !important; word-wrap: break-word; } @media print { .point-of-sale #topheader, .point-of-sale #leftpane { display: none !important; } .point-of-sale #content { top: 0px !important; } .point-of-sale #rightpane { left: 0px !important; background-color: white; } #receipt-screen header { display: none !important; } #receipt-screen { text-align: left; } .pos-actionbar { display: none !important; } .pos-sale-ticket { margin: 0px !important; } .debug-widget{ display: none !important; } .point-of-sale *{ text-shadow: none !important; box-shadow: none !important; background: transparent !important; } .point-of-sale .pos-sale-ticket{ margin-left: 0px !important; margin-right: 0px !important; border: none !important; } }
package org.deneblingvo.booleans.core;
#ifndef __LINUX_USB_H #define __LINUX_USB_H #include <linux/mod_devicetable.h> #include <linux/usb/ch9.h> #define USB_MAJOR 180 #define USB_DEVICE_MAJOR 189 #ifdef __KERNEL__ #include <linux/errno.h> /* for -ENODEV */ #include <linux/delay.h> /* for mdelay() */ #include <linux/interrupt.h> /* for in_interrupt() */ #include <linux/list.h> /* for struct list_head */ #include <linux/kref.h> /* for struct kref */ #include <linux/device.h> /* for struct device */ #include <linux/fs.h> /* for struct file_operations */ #include <linux/completion.h> /* for struct completion */ #include <linux/sched.h> /* for current && schedule_timeout */ #include <linux/mutex.h> /* for struct mutex */ #include <linux/pm_runtime.h> /* for runtime PM */ struct usb_device; struct usb_driver; struct wusb_dev; /* * Host-side wrappers for standard USB descriptors ... these are parsed * from the data provided by devices. Parsing turns them from a flat * sequence of descriptors into a hierarchy: * * - devices have one (usually) or more configs; * - configs have one (often) or more interfaces; * - interfaces have one (usually) or more settings; * - each interface setting has zero or (usually) more endpoints. * - a SuperSpeed endpoint has a companion descriptor * * And there might be other descriptors mixed in with those. * * Devices may also have class-specific or vendor-specific descriptors. */ struct ep_device; /** * struct usb_host_endpoint - host-side endpoint descriptor and queue * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder * @ss_ep_comp: SuperSpeed companion descriptor for this endpoint * @urb_list: urbs queued to this endpoint; maintained by usbcore * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH) * with one or more transfer descriptors (TDs) per urb * @ep_dev: ep_device for sysfs info * @extra: descriptors following this endpoint in the configuration * @extralen: how many bytes of "extra" are valid * @enabled: URBs may be submitted to this endpoint * * USB requests are always queued to a given endpoint, identified by a * descriptor within an active interface in a given USB configuration. */ struct usb_host_endpoint { struct <API key> desc; struct <API key> ss_ep_comp; struct list_head urb_list; void *hcpriv; struct ep_device *ep_dev; /* For sysfs info */ unsigned char *extra; /* Extra descriptors */ int extralen; int enabled; }; /* host-side wrapper for one interface setting's parsed descriptors */ struct usb_host_interface { struct <API key> desc; /* array of desc.bNumEndpoint endpoints associated with this * interface setting. these will be in no particular order. */ struct usb_host_endpoint *endpoint; char *string; /* iInterface string, if present */ unsigned char *extra; /* Extra descriptors */ int extralen; }; enum <API key> { <API key> = 0, <API key>, USB_INTERFACE_BOUND, <API key>, }; /** * struct usb_interface - what usb device drivers talk to * @altsetting: array of interface structures, one for each alternate * setting that may be selected. Each one includes a set of * endpoint configurations. They will be in no particular order. * @cur_altsetting: the current altsetting. * @num_altsetting: number of altsettings defined. * @intf_assoc: interface association descriptor * @minor: the minor number assigned to this interface, if this * interface is bound to a driver that uses the USB major number. * If this interface does not use the USB major, this field should * be unused. The driver should set this value in the probe() * function of the driver, after it has been assigned a minor * number from the USB core by calling usb_register_dev(). * @condition: binding state of the interface: not bound, binding * (in probe()), bound to a driver, or unbinding (in disconnect()) * @sysfs_files_created: sysfs attributes exist * @ep_devs_created: endpoint child pseudo-devices exist * @unregistering: flag set when the interface is being unregistered * @needs_remote_wakeup: flag set when the driver requires remote-wakeup * capability during autosuspend. * @needs_altsetting0: flag set when a set-interface request for altsetting 0 * has been deferred. * @needs_binding: flag set when the driver should be re-probed or unbound * following a reset or suspend operation it doesn't support. * @dev: driver model's view of this device * @usb_dev: if an interface is bound to the USB major, this will point * to the sysfs representation for that device. * @pm_usage_cnt: PM usage counter for this interface * @reset_ws: Used for scheduling resets from atomic context. * @reset_running: set to 1 if the interface is currently running a * queued reset so that <API key>() doesn't try to * remove from the workqueue when running inside the worker * thread. See <API key>(). * @resetting_device: USB core reset the device, so use alt setting 0 as * current; needs bandwidth alloc after reset. * * USB device drivers attach to interfaces on a physical device. Each * interface encapsulates a single high level function, such as feeding * an audio stream to a speaker or reporting a change in a volume control. * Many USB devices only have one interface. The protocol used to talk to * an interface's endpoints can be defined in a usb "class" specification, * or by a product's vendor. The (default) control endpoint is part of * every interface, but is never listed among the interface's descriptors. * * The driver that is bound to the interface can use standard driver model * calls such as dev_get_drvdata() on the dev member of this structure. * * Each interface may have alternate settings. The initial configuration * of a device sets altsetting 0, but the device driver can change * that setting using usb_set_interface(). Alternate settings are often * used to control the use of periodic endpoints, such as by having * different endpoints use different amounts of reserved USB bandwidth. * All <API key> USB devices that use isochronous endpoints * will use them in non-default settings. * * The USB specification says that alternate setting numbers must run from * 0 to one less than the total number of alternate settings. But some * devices manage to mess this up, and the structures aren't necessarily * stored in numerical order anyhow. Use <API key>() to * look up an alternate setting in the altsetting array based on its number. */ struct usb_interface { /* array of alternate settings for this interface, * stored in no particular order */ struct usb_host_interface *altsetting; struct usb_host_interface *cur_altsetting; /* the currently * active alternate setting */ unsigned num_altsetting; /* number of alternate settings */ /* If there is an interface association descriptor then it will list * the associated interfaces */ struct <API key> *intf_assoc; int minor; /* minor number this interface is * bound to */ enum <API key> condition; /* state of binding */ unsigned sysfs_files_created:1; /* the sysfs attributes exist */ unsigned ep_devs_created:1; /* endpoint "devices" exist */ unsigned unregistering:1; /* unregistration is in progress */ unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ unsigned needs_binding:1; /* needs delayed unbind/rebind */ unsigned reset_running:1; unsigned resetting_device:1; /* true: bandwidth alloc after reset */ struct device dev; /* interface specific device info */ struct device *usb_dev; atomic_t pm_usage_cnt; /* usage counter for autosuspend */ struct work_struct reset_ws; /* for resets in atomic context */ }; #define to_usb_interface(d) container_of(d, struct usb_interface, dev) static inline void *usb_get_intfdata(struct usb_interface *intf) { return dev_get_drvdata(&intf->dev); } static inline void usb_set_intfdata(struct usb_interface *intf, void *data) { dev_set_drvdata(&intf->dev, data); } struct usb_interface *usb_get_intf(struct usb_interface *intf); void usb_put_intf(struct usb_interface *intf); /* this maximum is arbitrary */ #define USB_MAXINTERFACES 32 #define USB_MAXIADS (USB_MAXINTERFACES/2) /** * struct usb_interface_cache - long-term representation of a device interface * @num_altsetting: number of altsettings defined. * @ref: reference counter. * @altsetting: variable-length array of interface structures, one for * each alternate setting that may be selected. Each one includes a * set of endpoint configurations. They will be in no particular order. * * These structures persist for the lifetime of a usb_device, unlike * struct usb_interface (which persists only as long as its configuration * is installed). The altsetting arrays can be accessed through these * structures at any time, permitting comparison of configurations and * providing support for the /proc/bus/usb/devices pseudo-file. */ struct usb_interface_cache { unsigned num_altsetting; /* number of alternate settings */ struct kref ref; /* reference counter */ /* variable-length array of alternate settings for this interface, * stored in no particular order */ struct usb_host_interface altsetting[0]; }; #define <API key>(r) \ container_of(r, struct usb_interface_cache, ref) #define <API key>(a) \ container_of(a, struct usb_interface_cache, altsetting[0]) /** * struct usb_host_config - representation of a device's configuration * @desc: the device's configuration descriptor. * @string: pointer to the cached version of the iConfiguration string, if * present for this configuration. * @intf_assoc: list of any interface association descriptors in this config * @interface: array of pointers to usb_interface structures, one for each * interface in the configuration. The number of interfaces is stored * in desc.bNumInterfaces. These pointers are valid only while the * the configuration is active. * @intf_cache: array of pointers to usb_interface_cache structures, one * for each interface in the configuration. These structures exist * for the entire life of the device. * @extra: pointer to buffer containing all extra descriptors associated * with this configuration (those preceding the first interface * descriptor). * @extralen: length of the extra descriptors buffer. * * USB devices may have multiple configurations, but only one can be active * at any time. Each encapsulates a different operational environment; * for example, a dual-speed device would have separate configurations for * full-speed and high-speed operation. The number of configurations * available is stored in the device descriptor as bNumConfigurations. * * A configuration can contain multiple interfaces. Each corresponds to * a different function of the USB device, and all are available whenever * the configuration is active. The USB standard says that interfaces * are supposed to be numbered from 0 to desc.bNumInterfaces-1, but a lot * of devices get this wrong. In addition, the interface array is not * guaranteed to be sorted in numerical order. Use usb_ifnum_to_if() to * look up an interface entry based on its number. * * Device drivers should not attempt to activate configurations. The choice * of which configuration to install is a policy decision based on such * considerations as available power, functionality provided, and the user's * desires (expressed through userspace tools). However, drivers can call * <API key>() to reinitialize the current configuration and * all its interfaces. */ struct usb_host_config { struct <API key> desc; char *string; /* iConfiguration string, if present */ /* List of any Interface Association Descriptors in this * configuration. */ struct <API key> *intf_assoc[USB_MAXIADS]; /* the interfaces associated with this configuration, * stored in no particular order */ struct usb_interface *interface[USB_MAXINTERFACES]; /* Interface information available even when this is not the * active configuration */ struct usb_interface_cache *intf_cache[USB_MAXINTERFACES]; unsigned char *extra; /* Extra descriptors */ int extralen; }; int <API key>(char *buffer, unsigned size, unsigned char type, void **ptr); #define <API key>(ifpoint, type, ptr) \ <API key>((ifpoint)->extra, \ (ifpoint)->extralen, \ type, (void **)ptr) /* USB device number allocation bitmap */ struct usb_devmap { unsigned long devicemap[128 / (8*sizeof(unsigned long))]; }; /* * Allocated per bus (tree of devices) we have: */ struct usb_bus { struct device *controller; /* host/master side hardware */ int busnum; /* Bus number (in order of reg) */ const char *bus_name; /* stable id (PCI slot_name etc) */ u8 uses_dma; /* Does the host controller use DMA? */ u8 <API key>; /* * Does the host controller use PIO * for control transfers? */ u8 otg_port; /* 0, or number of OTG/HNP port */ unsigned is_b_host:1; /* true during some HNP roleswitches */ unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ unsigned sg_tablesize; /* 0 or largest number of sg list entries */ int devnum_next; /* Next open device number in * round-robin allocation */ struct usb_devmap devmap; /* device address allocation map */ struct usb_device *root_hub; /* Root hub */ struct usb_bus *hs_companion; /* Companion EHCI bus, if any */ struct list_head bus_list; /* list of busses */ int bandwidth_allocated; /* on this bus: how much of the time * reserved for periodic (intr/iso) * requests is used, on average? * Units: microseconds/frame. * Limits: Full/low speed reserve 90%, * while high speed reserves 80%. */ int bandwidth_int_reqs; /* number of Interrupt requests */ int bandwidth_isoc_reqs; /* number of Isoc. requests */ #ifdef CONFIG_USB_DEVICEFS struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ #endif #if defined(CONFIG_USB_MON) || defined(<API key>) struct mon_bus *mon_bus; /* non-null when associated */ int monitored; /* non-zero when monitored */ #endif }; /* This is arbitrary. * From USB 2.0 spec Table 11-13, offset 7, a hub can * have up to 255 ports. The most yet reported is 10. * * Current Wireless USB host hardware (Intel i1480 for example) allows * up to 22 devices to connect. Upcoming hardware might raise that * limit. Because the arrays need to add a bit for hub status data, we * do 31, so plus one evens out to four bytes. */ #define USB_MAXCHILDREN (31) struct usb_tt; /** * struct usb_device - kernel's representation of a USB device * @devnum: device number; address on a USB bus * @devpath: device ID string for use in messages (e.g., /port/...) * @route: tree topology hex string for use with xHCI * @state: device state: configured, not attached, etc. * @speed: device speed: high/full/low (or error) * @tt: Transaction Translator info; used with low/full speed dev, highspeed hub * @ttport: device port on that tt hub * @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints * @parent: our hub, unless we're the root * @bus: bus we're part of * @ep0: endpoint 0 data (default control pipe) * @dev: generic device interface * @descriptor: USB device descriptor * @config: all of the device's configs * @actconfig: the active configuration * @ep_in: array of IN endpoints * @ep_out: array of OUT endpoints * @rawdescriptors: raw descriptors for each config * @bus_mA: Current available from the bus * @portnum: parent port number (origin 1) * @level: number of USB hub ancestors * @can_submit: URBs may be submitted * @persist_enabled: USB_PERSIST enabled for this device * @have_langid: whether string_langid is valid * @authorized: policy has said we can use it; * (user space) policy determines if we authorize this device to be * used or not. By default, wired USB devices are authorized. * WUSB devices are not, until we authorize them from user space. * FIXME -- complete doc * @authenticated: Crypto authentication passed * @wusb: device is Wireless USB * @string_langid: language ID for strings * @product: iProduct string, if present (static) * @manufacturer: iManufacturer string, if present (static) * @serial: iSerialNumber string, if present (static) * @filelist: usbfs files that are open to this device * @usb_classdev: USB class device that was created for usbfs device * access from userspace * @usbfs_dentry: usbfs dentry entry for the device * @maxchild: number of ports if hub * @children: child devices - USB devices that are attached to this hub * @quirks: quirks of the whole device * @urbnum: number of URBs submitted for the whole device * @active_duration: total time device is not suspended * @connect_time: time device was first connected * @do_remote_wakeup: remote wakeup should be enabled * @reset_resume: needs reset instead of resume * @wusb_dev: if this is a Wireless USB device, link to the WUSB * specific data for the device. * @slot_id: Slot ID assigned by xHCI * * Notes: * Usbcore drivers should not set usbdev->state directly. Instead use * <API key>(). */ struct usb_device { int devnum; char devpath[16]; u32 route; enum usb_device_state state; enum usb_device_speed speed; struct usb_tt *tt; int ttport; unsigned int toggle[2]; struct usb_device *parent; struct usb_bus *bus; struct usb_host_endpoint ep0; struct device dev; struct <API key> descriptor; struct usb_host_config *config; struct usb_host_config *actconfig; struct usb_host_endpoint *ep_in[16]; struct usb_host_endpoint *ep_out[16]; char **rawdescriptors; unsigned short bus_mA; u8 portnum; u8 level; unsigned can_submit:1; unsigned persist_enabled:1; unsigned have_langid:1; unsigned authorized:1; unsigned authenticated:1; unsigned wusb:1; int string_langid; /* static strings from the device */ char *product; char *manufacturer; char *serial; struct list_head filelist; #ifdef <API key> struct device *usb_classdev; #endif #ifdef CONFIG_USB_DEVICEFS struct dentry *usbfs_dentry; #endif int maxchild; struct usb_device *children[USB_MAXCHILDREN]; u32 quirks; atomic_t urbnum; unsigned long active_duration; #ifdef CONFIG_PM unsigned long connect_time; unsigned do_remote_wakeup:1; unsigned reset_resume:1; #endif struct wusb_dev *wusb_dev; int slot_id; }; #define to_usb_device(d) container_of(d, struct usb_device, dev) static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf) { return to_usb_device(intf->dev.parent); } extern struct usb_device *usb_get_dev(struct usb_device *dev); extern void usb_put_dev(struct usb_device *dev); /* USB device locking */ #define usb_lock_device(udev) device_lock(&(udev)->dev) #define usb_unlock_device(udev) device_unlock(&(udev)->dev) #define usb_trylock_device(udev) device_trylock(&(udev)->dev) extern int <API key>(struct usb_device *udev, const struct usb_interface *iface); /* USB port reset for device reinitialization */ extern int usb_reset_device(struct usb_device *dev); extern void <API key>(struct usb_interface *dev); /* USB autosuspend and autoresume */ #ifdef CONFIG_USB_SUSPEND extern void <API key>(struct usb_device *udev); extern void <API key>(struct usb_device *udev); extern int <API key>(struct usb_interface *intf); extern void <API key>(struct usb_interface *intf); extern int <API key>(struct usb_interface *intf); extern void <API key>(struct usb_interface *intf); extern void <API key>(struct usb_interface *intf); extern void <API key>(struct usb_interface *intf); static inline void usb_mark_last_busy(struct usb_device *udev) { <API key>(&udev->dev); } #else static inline int <API key>(struct usb_device *udev) { return 0; } static inline int <API key>(struct usb_device *udev) { return 0; } static inline int <API key>(struct usb_interface *intf) { return 0; } static inline int <API key>(struct usb_interface *intf) { return 0; } static inline void <API key>(struct usb_interface *intf) { } static inline void <API key>(struct usb_interface *intf) { } static inline void <API key>( struct usb_interface *intf) { } static inline void <API key>( struct usb_interface *intf) { } static inline void usb_mark_last_busy(struct usb_device *udev) { } #endif /* for drivers using iso endpoints */ extern int <API key>(struct usb_device *usb_dev); /* Sets up a group of bulk endpoints to support multiple stream IDs. */ extern int usb_alloc_streams(struct usb_interface *interface, struct usb_host_endpoint **eps, unsigned int num_eps, unsigned int num_streams, gfp_t mem_flags); /* Reverts a group of bulk endpoints back to not using stream IDs. */ extern void usb_free_streams(struct usb_interface *interface, struct usb_host_endpoint **eps, unsigned int num_eps, gfp_t mem_flags); /* used these for multi-interface device registration */ extern int <API key>(struct usb_driver *driver, struct usb_interface *iface, void *priv); /** * <API key> - returns true iff an interface is claimed * @iface: the interface being checked * * Returns true (nonzero) iff the interface is claimed, else false (zero). * Callers must own the driver model's usb bus readlock. So driver * probe() entries don't need extra locking, but other call contexts * may need to explicitly claim that lock. * */ static inline int <API key>(struct usb_interface *iface) { return (iface->dev.driver != NULL); } extern void <API key>(struct usb_driver *driver, struct usb_interface *iface); const struct usb_device_id *usb_match_id(struct usb_interface *interface, const struct usb_device_id *id); extern int usb_match_one_id(struct usb_interface *interface, const struct usb_device_id *id); extern struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor); extern struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev, unsigned ifnum); extern struct usb_host_interface *<API key>( const struct usb_interface *intf, unsigned int altnum); extern struct usb_host_interface *<API key>( struct usb_host_config *config, unsigned int iface_num, unsigned int alt_num); /** * usb_make_path - returns stable device path in the usb tree * @dev: the device whose path is being constructed * @buf: where to put the string * @size: how big is "buf"? * * Returns length of the string (> 0) or negative if size was too small. * * This identifier is intended to be "stable", reflecting physical paths in * hardware such as physical bus addresses for host controllers or ports on * USB hubs. That makes it stay the same until systems are physically * reconfigured, by re-cabling a tree of USB devices or by moving USB host * controllers. Adding and removing devices, including virtual root hubs * in host controller driver modules, does not change these path identifiers; * neither does rebooting or re-enumerating. These are more useful identifiers * than changeable ("unstable") ones like bus numbers or device addresses. * * With a partial exception for devices connected to USB 2.0 root hubs, these * identifiers are also predictable. So long as the device tree isn't changed, * plugging any USB device into a given hub port always gives it the same path. * Because of the use of "companion" controllers, devices connected to ports on * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are * high speed, and a different one if they are full or low speed. */ static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size) { int actual; actual = snprintf(buf, size, "usb-%s-%s", dev->bus->bus_name, dev->devpath); return (actual >= (int)size) ? -1 : actual; } #define <API key> \ (<API key> | <API key>) #define <API key> \ (<API key> | <API key>) #define <API key> \ (<API key> | <API key>) #define <API key> \ (<API key> | \ <API key> | \ <API key>) #define <API key> \ (<API key> | \ <API key> | \ <API key>) /** * USB_DEVICE - macro used to describe a specific usb device * @vend: the 16 bit USB Vendor ID * @prod: the 16 bit USB Product ID * * This macro is used to create a struct usb_device_id that matches a * specific device. */ #define USB_DEVICE(vend, prod) \ .match_flags = <API key>, \ .idVendor = (vend), \ .idProduct = (prod) /** * USB_DEVICE_VER - describe a specific usb device with a version range * @vend: the 16 bit USB Vendor ID * @prod: the 16 bit USB Product ID * @lo: the bcdDevice_lo value * @hi: the bcdDevice_hi value * * This macro is used to create a struct usb_device_id that matches a * specific device, with a version range. */ #define USB_DEVICE_VER(vend, prod, lo, hi) \ .match_flags = <API key>, \ .idVendor = (vend), \ .idProduct = (prod), \ .bcdDevice_lo = (lo), \ .bcdDevice_hi = (hi) /** * <API key> - describe a usb device with a specific interface protocol * @vend: the 16 bit USB Vendor ID * @prod: the 16 bit USB Product ID * @pr: bInterfaceProtocol value * * This macro is used to create a struct usb_device_id that matches a * specific interface protocol of devices. */ #define <API key>(vend, prod, pr) \ .match_flags = <API key> | \ <API key>, \ .idVendor = (vend), \ .idProduct = (prod), \ .bInterfaceProtocol = (pr) /** * USB_DEVICE_INFO - macro used to describe a class of usb devices * @cl: bDeviceClass value * @sc: bDeviceSubClass value * @pr: bDeviceProtocol value * * This macro is used to create a struct usb_device_id that matches a * specific class of devices. */ #define USB_DEVICE_INFO(cl, sc, pr) \ .match_flags = <API key>, \ .bDeviceClass = (cl), \ .bDeviceSubClass = (sc), \ .bDeviceProtocol = (pr) /** * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces * @cl: bInterfaceClass value * @sc: bInterfaceSubClass value * @pr: bInterfaceProtocol value * * This macro is used to create a struct usb_device_id that matches a * specific class of interfaces. */ #define USB_INTERFACE_INFO(cl, sc, pr) \ .match_flags = <API key>, \ .bInterfaceClass = (cl), \ .bInterfaceSubClass = (sc), \ .bInterfaceProtocol = (pr) /** * <API key> - describe a specific usb device with a class of usb interfaces * @vend: the 16 bit USB Vendor ID * @prod: the 16 bit USB Product ID * @cl: bInterfaceClass value * @sc: bInterfaceSubClass value * @pr: bInterfaceProtocol value * * This macro is used to create a struct usb_device_id that matches a * specific device with a specific class of interfaces. * * This is especially useful when explicitly matching devices that have * vendor specific bDeviceClass values, but standards-compliant interfaces. */ #define <API key>(vend, prod, cl, sc, pr) \ .match_flags = <API key> \ | <API key>, \ .idVendor = (vend), \ .idProduct = (prod), \ .bInterfaceClass = (cl), \ .bInterfaceSubClass = (sc), \ .bInterfaceProtocol = (pr) /* Stuff for dynamic usb ids */ struct usb_dynids { spinlock_t lock; struct list_head list; }; struct usb_dynid { struct list_head node; struct usb_device_id id; }; extern ssize_t usb_store_new_id(struct usb_dynids *dynids, struct device_driver *driver, const char *buf, size_t count); /** * struct usbdrv_wrap - wrapper for driver-model structure * @driver: The driver-model core driver structure. * @for_devices: Non-zero for device drivers, 0 for interface drivers. */ struct usbdrv_wrap { struct device_driver driver; int for_devices; }; /** * struct usb_driver - identifies USB interface driver to usbcore * @name: The driver name should be unique among USB drivers, * and should normally be the same as the module name. * @probe: Called to see if the driver is willing to manage a particular * interface on a device. If it is, probe returns zero and uses * usb_set_intfdata() to associate driver-specific data with the * interface. It may also use usb_set_interface() to specify the * appropriate altsetting. If unwilling to manage the interface, * return -ENODEV, if genuine IO errors occurred, an appropriate * negative errno value. * @disconnect: Called when the interface is no longer accessible, usually * because its device has been (or is being) disconnected or the * driver module is being unloaded. * @unlocked_ioctl: Used for drivers that want to talk to userspace through * the "usbfs" filesystem. This lets devices provide ways to * expose information to user space regardless of where they * do (or don't) show up otherwise in the filesystem. * @suspend: Called when the device is going to be suspended by the system. * @resume: Called when the device is being resumed by the system. * @reset_resume: Called when the suspended device has been reset instead * of being resumed. * @pre_reset: Called by usb_reset_device() when the device is about to be * reset. This routine must not return until the driver has no active * URBs for the device, and no more URBs may be submitted until the * post_reset method is called. * @post_reset: Called by usb_reset_device() after the device * has been reset * @id_table: USB drivers use ID table to support hotplugging. * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set * or your driver's probe function will never get called. * @dynids: used internally to hold the list of dynamically added device * ids for this driver. * @drvwrap: Driver-model core structure wrapper. * @no_dynamic_id: if set to 1, the USB core will not allow dynamic ids to be * added to this driver by preventing the sysfs file from being created. * @<API key>: if set to 0, the USB core will not allow autosuspend * for interfaces bound to this driver. * @soft_unbind: if set to 1, the USB core will not kill URBs and disable * endpoints before calling the driver's disconnect method. * * USB interface drivers must provide a name, probe() and disconnect() * methods, and an id_table. Other driver fields are optional. * * The id_table is used in hotplugging. It holds a set of descriptors, * and specialized data may be associated with each entry. That table * is used by both user and kernel mode hotplugging support. * * The probe() and disconnect() methods are called in a context where * they can sleep, but they should avoid abusing the privilege. Most * work to connect to a device should be done when the device is opened, * and undone at the last close. The disconnect code needs to address * concurrency issues with respect to open() and close() methods, as * well as forcing all pending I/O requests to complete (by unlinking * them as necessary, and blocking until the unlinks complete). */ struct usb_driver { const char *name; int (*probe) (struct usb_interface *intf, const struct usb_device_id *id); void (*disconnect) (struct usb_interface *intf); int (*unlocked_ioctl) (struct usb_interface *intf, unsigned int code, void *buf); int (*suspend) (struct usb_interface *intf, pm_message_t message); int (*resume) (struct usb_interface *intf); int (*reset_resume)(struct usb_interface *intf); int (*pre_reset)(struct usb_interface *intf); int (*post_reset)(struct usb_interface *intf); const struct usb_device_id *id_table; struct usb_dynids dynids; struct usbdrv_wrap drvwrap; unsigned int no_dynamic_id:1; unsigned int <API key>:1; unsigned int soft_unbind:1; }; #define to_usb_driver(d) container_of(d, struct usb_driver, drvwrap.driver) /** * struct usb_device_driver - identifies USB device driver to usbcore * @name: The driver name should be unique among USB drivers, * and should normally be the same as the module name. * @probe: Called to see if the driver is willing to manage a particular * device. If it is, probe returns zero and uses dev_set_drvdata() * to associate driver-specific data with the device. If unwilling * to manage the device, return a negative errno value. * @disconnect: Called when the device is no longer accessible, usually * because it has been (or is being) disconnected or the driver's * module is being unloaded. * @suspend: Called when the device is going to be suspended by the system. * @resume: Called when the device is being resumed by the system. * @drvwrap: Driver-model core structure wrapper. * @<API key>: if set to 0, the USB core will not allow autosuspend * for devices bound to this driver. * * USB drivers must provide all the fields listed above except drvwrap. */ struct usb_device_driver { const char *name; int (*probe) (struct usb_device *udev); void (*disconnect) (struct usb_device *udev); int (*suspend) (struct usb_device *udev, pm_message_t message); int (*resume) (struct usb_device *udev, pm_message_t message); struct usbdrv_wrap drvwrap; unsigned int <API key>:1; }; #define <API key>(d) container_of(d, struct usb_device_driver, \ drvwrap.driver) extern struct bus_type usb_bus_type; /** * struct usb_class_driver - identifies a USB driver that wants to use the USB major number * @name: the usb class device name for this driver. Will show up in sysfs. * @devnode: Callback to provide a naming hint for a possible * device node to create. * @fops: pointer to the struct file_operations of this driver. * @minor_base: the start of the minor range for this driver. * * This structure is used for the usb_register_dev() and * usb_unregister_dev() functions, to consolidate a number of the * parameters used for them. */ struct usb_class_driver { char *name; char *(*devnode)(struct device *dev, umode_t *mode); const struct file_operations *fops; int minor_base; }; /* * use these in module_init()/module_exit() * and don't forget MODULE_DEVICE_TABLE(usb, ...) */ extern int usb_register_driver(struct usb_driver *, struct module *, const char *); /* use a define to avoid include chaining to get THIS_MODULE & friends */ #define usb_register(driver) \ usb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) extern void usb_deregister(struct usb_driver *); extern int <API key>(struct usb_device_driver *, struct module *); extern void <API key>(struct usb_device_driver *); extern int usb_register_dev(struct usb_interface *intf, struct usb_class_driver *class_driver); extern void usb_deregister_dev(struct usb_interface *intf, struct usb_class_driver *class_driver); extern int usb_disabled(void); /* * URB support, for asynchronous request completions */ /* * urb->transfer_flags: * * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb(). */ #define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */ #define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame * ignored */ #define <API key> 0x0004 /* urb->transfer_dma valid on submit */ #define URB_NO_FSBR 0x0020 /* UHCI-specific */ #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt * needed */ #define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ /* The following flags are used internally by usbcore and HCDs */ #define URB_DIR_IN 0x0200 /* Transfer from device to host */ #define URB_DIR_OUT 0 #define URB_DIR_MASK URB_DIR_IN #define URB_DMA_MAP_SINGLE 0x00010000 /* Non-scatter-gather mapping */ #define URB_DMA_MAP_PAGE 0x00020000 /* HCD-unsupported S-G */ #define URB_DMA_MAP_SG 0x00040000 /* HCD-supported S-G */ #define URB_MAP_LOCAL 0x00080000 /* HCD-local-memory mapping */ #define <API key> 0x00100000 /* Setup packet DMA mapped */ #define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */ #define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */ #define <API key> 0x00800000 /* Temp buffer was alloc'd */ struct <API key> { unsigned int offset; unsigned int length; /* expected length */ unsigned int actual_length; int status; }; struct urb; struct usb_anchor { struct list_head urb_list; wait_queue_head_t wait; spinlock_t lock; unsigned int poisoned:1; }; static inline void init_usb_anchor(struct usb_anchor *anchor) { INIT_LIST_HEAD(&anchor->urb_list); init_waitqueue_head(&anchor->wait); spin_lock_init(&anchor->lock); } typedef void (*usb_complete_t)(struct urb *); /** * struct urb - USB Request Block * @urb_list: For use by current owner of the URB. * @anchor_list: membership in the list of an anchor * @anchor: to anchor URBs to a common mooring * @ep: Points to the endpoint's data structure. Will eventually * replace @pipe. * @pipe: Holds endpoint number, direction, type, and more. * Create these values with the eight macros available; * usb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is "ctrl" * (control), "bulk", "int" (interrupt), or "iso" (isochronous). * For example usb_sndbulkpipe() or usb_rcvintpipe(). Endpoint * numbers range from zero to fifteen. Note that "in" endpoint two * is a different endpoint (and pipe) from "out" endpoint two. * The current configuration controls the existence, type, and * maximum packet size of any given endpoint. * @stream_id: the endpoint's stream ID for bulk streams * @dev: Identifies the USB device to perform the request. * @status: This is read in non-iso completion functions to get the * status of the particular request. ISO requests only use it * to tell whether the URB was unlinked; detailed status for * each frame is in the fields of the iso_frame-desc. * @transfer_flags: A variety of flags may be used to affect how URB * submission, unlinking, or operation are handled. Different * kinds of URB can use different flags. * @transfer_buffer: This identifies the buffer to (or from) which the I/O * request will be performed unless <API key> is set * (however, do not leave garbage in transfer_buffer even then). * This buffer must be suitable for DMA; allocate it with * kmalloc() or equivalent. For transfers to "in" endpoints, contents * of this buffer will be modified. This buffer is used for the data * stage of control transfers. * @transfer_dma: When transfer_flags includes <API key>, * the device driver is saying that it provided this DMA address, * which the host controller driver should use in preference to the * transfer_buffer. * @sg: scatter gather buffer list * @num_sgs: number of entries in the sg list * @<API key>: How big is transfer_buffer. The transfer may * be broken up into chunks according to the current maximum packet * size for the endpoint, which is a function of the configuration * and is encoded in the pipe. When the length is zero, neither * transfer_buffer nor transfer_dma is used. * @actual_length: This is read in non-iso completion functions, and * it tells how many bytes (out of <API key>) were * transferred. It will normally be the same as requested, unless * either an error was reported or a short read was performed. * The URB_SHORT_NOT_OK transfer flag may be used to make such * short reads be reported as errors. * @setup_packet: Only used for control transfers, this points to eight bytes * of setup data. Control transfers always start by sending this data * to the device. Then transfer_buffer is read or written, if needed. * @setup_dma: DMA pointer for the setup packet. The caller must not use * this field; setup_packet must point to a valid buffer. * @start_frame: Returns the initial frame for isochronous transfers. * @number_of_packets: Lists the number of ISO transfer buffers. * @interval: Specifies the polling interval for interrupt or isochronous * transfers. The units are frames (milliseconds) for full and low * speed devices, and microframes (1/8 millisecond) for highspeed * and SuperSpeed devices. * @error_count: Returns the number of ISO transfers that reported errors. * @context: For use in completion functions. This normally points to * request-specific driver context. * @complete: Completion handler. This URB is passed as the parameter to the * completion function. The completion function may then do what * it likes with the URB, including resubmitting or freeing it. * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to * collect the transfer status for each buffer. * * This structure identifies USB transfer requests. URBs must be allocated by * calling usb_alloc_urb() and freed with a call to usb_free_urb(). * Initialization may be done using various usb_fill_*_urb() functions. URBs * are submitted using usb_submit_urb(), and pending requests may be canceled * using usb_unlink_urb() or usb_kill_urb(). * * Data Transfer Buffers: * * Normally drivers provide I/O buffers allocated with kmalloc() or otherwise * taken from the general page pool. That is provided by transfer_buffer * (control requests also use setup_packet), and host controller drivers * perform a dma mapping (and unmapping) for each buffer transferred. Those * mapping operations can be expensive on some platforms (perhaps using a dma * bounce buffer or talking to an IOMMU), * although they're cheap on commodity x86 and ppc hardware. * * Alternatively, drivers may pass the <API key> transfer flag, * which tells the host controller driver that no such mapping is needed for * the transfer_buffer since * the device driver is DMA-aware. For example, a device driver might * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map(). * When this transfer flag is provided, host controller drivers will * attempt to use the dma address found in the transfer_dma * field rather than determining a dma address themselves. * * Note that transfer_buffer must still be set if the controller * does not support DMA (as indicated by bus.uses_dma) and when talking * to root hub. If you have to trasfer between highmem zone and the device * on such controller, create a bounce buffer or bail out with an error. * If transfer_buffer cannot be set (is in highmem) and the controller is DMA * capable, assign NULL to it, so that usbmon knows not to use the value. * The setup_packet must always be set, so it cannot be located in highmem. * * Initialization: * * All URBs submitted must initialize the dev, pipe, transfer_flags (may be * zero), and complete fields. All URBs must also initialize * transfer_buffer and <API key>. They may provide the * URB_SHORT_NOT_OK transfer flag, indicating that short reads are * to be treated as errors; that flag is invalid for write requests. * * Bulk URBs may * use the URB_ZERO_PACKET transfer flag, indicating that bulk OUT transfers * should always terminate with a short packet, even if it means adding an * extra zero length packet. * * Control URBs must provide a valid pointer in the setup_packet field. * Unlike the transfer_buffer, the setup_packet may not be mapped for DMA * beforehand. * * Interrupt URBs must provide an interval, saying how often (in milliseconds * or, for highspeed devices, 125 microsecond units) * to poll for transfers. After the URB has been submitted, the interval * field reflects how the transfer was actually scheduled. * The polling interval may be more frequent than requested. * For example, some controllers have a maximum interval of 32 milliseconds, * while others support intervals of up to 1024 milliseconds. * Isochronous URBs also have transfer intervals. (Note that for isochronous * endpoints, as well as high speed interrupt endpoints, the encoding of * the transfer interval in the endpoint descriptor is logarithmic. * Device drivers must convert that value to linear units themselves.) * * Isochronous URBs normally use the URB_ISO_ASAP transfer flag, telling * the host controller to schedule the transfer as soon as bandwidth * utilization allows, and then set start_frame to reflect the actual frame * selected during submission. Otherwise drivers must specify the start_frame * and handle the case where the transfer can't begin then. However, drivers * won't know how bandwidth is currently allocated, and while they can * find the current frame using <API key> () they can't * know the range for that frame number. (Ranges for frame counter values * are HC-specific, and can go from 256 to 65536 frames from "now".) * * Isochronous URBs have a different data transfer model, in part because * the quality of service is only "best effort". Callers provide specially * allocated URBs, with number_of_packets worth of iso_frame_desc structures * at the end. Each such packet is an individual ISO transfer. Isochronous * URBs are normally queued, submitted by drivers to arrange that * transfers are at least double buffered, and then explicitly resubmitted * in completion handlers, so * that data (such as audio or video) streams at as constant a rate as the * host controller scheduler can support. * * Completion Callbacks: * * The completion callback is made in_interrupt(), and one of the first * things that a completion handler should do is check the status field. * The status field is provided for all URBs. It is used to report * unlinked URBs, and status for all non-ISO transfers. It should not * be examined before the URB is returned to the completion handler. * * The context field is normally used to link URBs back to the relevant * driver or request state. * * When the completion callback is invoked for non-isochronous URBs, the * actual_length field tells how many bytes were transferred. This field * is updated even when the URB terminated with an error or was unlinked. * * ISO transfer status is reported in the status and actual_length fields * of the iso_frame_desc array, and the number of errors is reported in * error_count. Completion callbacks for ISO transfers will normally * (re)submit URBs to ensure a constant transfer rate. * * Note that even fields marked "public" should not be touched by the driver * when the urb is owned by the hcd, that is, since the call to * usb_submit_urb() till the entry into the completion routine. */ struct urb { /* private: usb core and host controller only fields in the urb */ struct kref kref; /* reference count of the URB */ void *hcpriv; /* private data for host controller */ atomic_t use_count; /* concurrent submissions counter */ atomic_t reject; /* submissions will fail */ int unlinked; /* unlink error code */ /* public: documented fields in the urb that can be used by drivers */ struct list_head urb_list; /* list head for use by the urb's * current owner */ struct list_head anchor_list; /* the URB may be anchored */ struct usb_anchor *anchor; struct usb_device *dev; /* (in) pointer to associated device */ struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */ unsigned int pipe; /* (in) pipe information */ unsigned int stream_id; /* (in) stream ID */ int status; /* (return) non-ISO status */ unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ void *transfer_buffer; /* (in) associated data buffer */ dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ struct scatterlist *sg; /* (in) scatter gather buffer list */ int num_mapped_sgs; /* (internal) mapped sg entries */ int num_sgs; /* (in) number of entries in the sg list */ u32 <API key>; /* (in) data buffer length */ u32 actual_length; /* (return) actual transfer length */ unsigned char *setup_packet; /* (in) setup packet (control only) */ dma_addr_t setup_dma; /* (in) dma addr for setup_packet */ int start_frame; /* (modify) start frame (ISO) */ int number_of_packets; /* (in) number of ISO packets */ int interval; /* (modify) transfer interval * (INT/ISO) */ int error_count; /* (return) number of ISO errors */ void *context; /* (in) context for completion */ usb_complete_t complete; /* (in) completion routine */ struct <API key> iso_frame_desc[0]; /* (in) ISO ONLY */ }; /** * <API key> - initializes a control urb * @urb: pointer to the urb to initialize. * @dev: pointer to the struct usb_device for this urb. * @pipe: the endpoint pipe * @setup_packet: pointer to the setup_packet buffer * @transfer_buffer: pointer to the transfer buffer * @buffer_length: length of the transfer buffer * @complete_fn: pointer to the usb_complete_t function * @context: what to set the urb context to. * * Initializes a control urb with the proper information needed to submit * it to a device. */ static inline void <API key>(struct urb *urb, struct usb_device *dev, unsigned int pipe, unsigned char *setup_packet, void *transfer_buffer, int buffer_length, usb_complete_t complete_fn, void *context) { urb->dev = dev; urb->pipe = pipe; urb->setup_packet = setup_packet; urb->transfer_buffer = transfer_buffer; urb-><API key> = buffer_length; urb->complete = complete_fn; urb->context = context; } /** * usb_fill_bulk_urb - macro to help initialize a bulk urb * @urb: pointer to the urb to initialize. * @dev: pointer to the struct usb_device for this urb. * @pipe: the endpoint pipe * @transfer_buffer: pointer to the transfer buffer * @buffer_length: length of the transfer buffer * @complete_fn: pointer to the usb_complete_t function * @context: what to set the urb context to. * * Initializes a bulk urb with the proper information needed to submit it * to a device. */ static inline void usb_fill_bulk_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, void *transfer_buffer, int buffer_length, usb_complete_t complete_fn, void *context) { urb->dev = dev; urb->pipe = pipe; urb->transfer_buffer = transfer_buffer; urb-><API key> = buffer_length; urb->complete = complete_fn; urb->context = context; } /** * usb_fill_int_urb - macro to help initialize a interrupt urb * @urb: pointer to the urb to initialize. * @dev: pointer to the struct usb_device for this urb. * @pipe: the endpoint pipe * @transfer_buffer: pointer to the transfer buffer * @buffer_length: length of the transfer buffer * @complete_fn: pointer to the usb_complete_t function * @context: what to set the urb context to. * @interval: what to set the urb interval to, encoded like * the endpoint descriptor's bInterval value. * * Initializes a interrupt urb with the proper information needed to submit * it to a device. * * Note that High Speed and SuperSpeed interrupt endpoints use a logarithmic * encoding of the endpoint interval, and express polling intervals in * microframes (eight per millisecond) rather than in frames (one per * millisecond). * * Wireless USB also uses the logarithmic encoding, but specifies it in units of * 128us instead of 125us. For Wireless USB devices, the interval is passed * through to the host controller, rather than being translated into microframe * units. */ static inline void usb_fill_int_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, void *transfer_buffer, int buffer_length, usb_complete_t complete_fn, void *context, int interval) { urb->dev = dev; urb->pipe = pipe; urb->transfer_buffer = transfer_buffer; urb-><API key> = buffer_length; urb->complete = complete_fn; urb->context = context; if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER) urb->interval = 1 << (interval - 1); else urb->interval = interval; urb->start_frame = -1; } extern void usb_init_urb(struct urb *urb); extern struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags); extern void usb_free_urb(struct urb *urb); #define usb_put_urb usb_free_urb extern struct urb *usb_get_urb(struct urb *urb); extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); extern int usb_unlink_urb(struct urb *urb); extern void usb_kill_urb(struct urb *urb); extern void usb_poison_urb(struct urb *urb); extern void usb_unpoison_urb(struct urb *urb); extern void <API key>(struct usb_anchor *anchor); extern void <API key>(struct usb_anchor *anchor); extern void <API key>(struct usb_anchor *anchor); extern void <API key>(struct usb_anchor *anchor); extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); extern void usb_unanchor_urb(struct urb *urb); extern int <API key>(struct usb_anchor *anchor, unsigned int timeout); extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); extern void <API key>(struct usb_anchor *anchor); extern int usb_anchor_empty(struct usb_anchor *anchor); /** * usb_urb_dir_in - check if an URB describes an IN transfer * @urb: URB to be checked * * Returns 1 if @urb describes an IN transfer (device-to-host), * otherwise 0. */ static inline int usb_urb_dir_in(struct urb *urb) { return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_IN; } /** * usb_urb_dir_out - check if an URB describes an OUT transfer * @urb: URB to be checked * * Returns 1 if @urb describes an OUT transfer (host-to-device), * otherwise 0. */ static inline int usb_urb_dir_out(struct urb *urb) { return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; } void *usb_alloc_coherent(struct usb_device *dev, size_t size, gfp_t mem_flags, dma_addr_t *dma); void usb_free_coherent(struct usb_device *dev, size_t size, void *addr, dma_addr_t dma); #if 0 struct urb *usb_buffer_map(struct urb *urb); void usb_buffer_dmasync(struct urb *urb); void usb_buffer_unmap(struct urb *urb); #endif struct scatterlist; int usb_buffer_map_sg(const struct usb_device *dev, int is_in, struct scatterlist *sg, int nents); #if 0 void <API key>(const struct usb_device *dev, int is_in, struct scatterlist *sg, int n_hw_ents); #endif void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in, struct scatterlist *sg, int n_hw_ents); extern int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout); extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout); extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout); /* wrappers around usb_control_msg() for the most common standard requests */ extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, unsigned char descindex, void *buf, int size); extern int usb_get_status(struct usb_device *dev, int type, int target, void *data); extern int usb_string(struct usb_device *dev, int index, char *buf, size_t size); /* wrappers that also update important state inside usbcore */ extern int usb_clear_halt(struct usb_device *dev, int pipe); extern int <API key>(struct usb_device *dev); extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr); /* this request isn't really synchronous, but it belongs with the others */ extern int <API key>(struct usb_device *udev, int config); /* * timeouts, in milliseconds, used for sending/receiving control messages * they typically complete within a few frames (msec) after they're issued * USB identifies 5 second timeouts, maybe more in a few cases, and a few * slow devices (like some MGE Ellipse UPSes) actually push that limit. */ #define <API key> 5000 #define <API key> 5000 /** * struct usb_sg_request - support for scatter/gather I/O * @status: zero indicates success, else negative errno * @bytes: counts bytes transferred. * * These requests are initialized using usb_sg_init(), and then are used * as request handles passed to usb_sg_wait() or usb_sg_cancel(). Most * members of the request object aren't for driver access. * * The status and bytecount values are valid only after usb_sg_wait() * returns. If the status is zero, then the bytecount matches the total * from the request. * * After an error completion, drivers may need to clear a halt condition * on the endpoint. */ struct usb_sg_request { int status; size_t bytes; /* private: * members below are private to usbcore, * and are not provided for driver access! */ spinlock_t lock; struct usb_device *dev; int pipe; int entries; struct urb **urbs; int count; struct completion complete; }; int usb_sg_init( struct usb_sg_request *io, struct usb_device *dev, unsigned pipe, unsigned period, struct scatterlist *sg, int nents, size_t length, gfp_t mem_flags ); void usb_sg_cancel(struct usb_sg_request *io); void usb_sg_wait(struct usb_sg_request *io); /* * For various legacy reasons, Linux has a small cookie that's paired with * a struct usb_device to identify an endpoint queue. Queue characteristics * are defined by the endpoint's descriptor. This cookie is called a "pipe", * an unsigned int encoded as: * * - direction: bit 7 (0 = Host-to-Device [Out], * 1 = Device-to-Host [In] ... * like endpoint bEndpointAddress) * - device address: bits 8-14 ... bit positions known to uhci-hcd * - endpoint: bits 15-18 ... bit positions known to uhci-hcd * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, * 10 = control, 11 = bulk) * * Given the device address and endpoint descriptor, pipes are redundant. */ /* NOTE: these are not the standard USB_ENDPOINT_XFER_* values!! */ /* (yet ... they're the values used by usbfs) */ #define PIPE_ISOCHRONOUS 0 #define PIPE_INTERRUPT 1 #define PIPE_CONTROL 2 #define PIPE_BULK 3 #define usb_pipein(pipe) ((pipe) & USB_DIR_IN) #define usb_pipeout(pipe) (!usb_pipein(pipe)) #define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f) #define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf) #define usb_pipetype(pipe) (((pipe) >> 30) & 3) #define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS) #define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT) #define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL) #define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK) static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint) { return (dev->devnum << 8) | (endpoint << 15); } /* Create various pipes... */ #define usb_sndctrlpipe(dev, endpoint) \ ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint)) #define usb_rcvctrlpipe(dev, endpoint) \ ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) #define usb_sndisocpipe(dev, endpoint) \ ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint)) #define usb_rcvisocpipe(dev, endpoint) \ ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) #define usb_sndbulkpipe(dev, endpoint) \ ((PIPE_BULK << 30) | __create_pipe(dev, endpoint)) #define usb_rcvbulkpipe(dev, endpoint) \ ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) #define usb_sndintpipe(dev, endpoint) \ ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint)) #define usb_rcvintpipe(dev, endpoint) \ ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) static inline struct usb_host_endpoint * usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) { struct usb_host_endpoint **eps; eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out; return eps[usb_pipeendpoint(pipe)]; } static inline __u16 usb_maxpacket(struct usb_device *udev, int pipe, int is_out) { struct usb_host_endpoint *ep; unsigned epnum = usb_pipeendpoint(pipe); if (is_out) { WARN_ON(usb_pipein(pipe)); ep = udev->ep_out[epnum]; } else { WARN_ON(usb_pipeout(pipe)); ep = udev->ep_in[epnum]; } if (!ep) return 0; /* NOTE: only 0x07ff bits are for packet size... */ return le16_to_cpu(ep->desc.wMaxPacketSize); } /* Events from the usb core */ #define USB_DEVICE_ADD 0x0001 #define USB_DEVICE_REMOVE 0x0002 #define USB_BUS_ADD 0x0003 #define USB_BUS_REMOVE 0x0004 extern void usb_register_notify(struct notifier_block *nb); extern void <API key>(struct notifier_block *nb); #ifdef DEBUG #define dbg(format, arg...) \ printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg) #else #define dbg(format, arg...) \ do { \ if (0) \ printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ } while (0) #endif #define err(format, arg...) \ printk(KERN_ERR KBUILD_MODNAME ": " format "\n", ##arg) /* debugfs stuff */ extern struct dentry *usb_debug_root; #endif /* __KERNEL__ */ #endif
#ifndef <API key> #define <API key> #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32_WCE void <API key>(PNDIS_WAN_PACKET wan_pkt); Boolean <API key>(SshNdisIMAdapter adapter, PNDIS_WAN_PACKET packet, <API key> *protocol); void <API key>(SshNdisIMAdapter adapter, PNDIS_WAN_PACKET packet, PNDIS_STATUS status); Boolean <API key>(SshNdisIMAdapter adapter, PUCHAR *packet, ULONG *packet_size, <API key> *protocol); void <API key>(SshNdisIMAdapter adapter, PUCHAR packet, ULONG packet_size, PNDIS_STATUS status); Boolean <API key>(SshNdisIMAdapter adapter, SshNdisPacket packet, <API key> protocol); Boolean <API key>(SshNdisIMAdapter adapter, SshNdisPacket packet, <API key> protocol); #endif /* _WIN32_WCE */ #ifdef __cplusplus } #endif #endif /* <API key> */
package de.superioz.moo.network.client; import de.superioz.moo.network.server.NetworkServer; import lombok.Getter; import de.superioz.moo.api.collection.UnmodifiableList; import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /** * The hub for storing the client connections * * @see MooClient */ public final class ClientManager { /** * It is only necessary to only have one ClientHub instance so this is the static access for this * class after it has been initialised by the network server */ @Getter private static ClientManager instance; /** * The connected {@link MooClient}'s by the type of them */ private ConcurrentMap<ClientType, Map<InetSocketAddress, MooClient>> clientsByType = new ConcurrentHashMap<>(); /** * The ram usage of every daemon (as socketaddress) as percent */ @Getter private Map<InetSocketAddress, Integer> daemonRamUsage = new HashMap<>(); /** * The netty server the clients are connected to */ private NetworkServer netServer; public ClientManager(NetworkServer netServer) { instance = this; this.netServer = netServer; for(ClientType clientType : ClientType.values()) { clientsByType.put(clientType, new HashMap<>()); } } /** * Updates the ramUsage of a daemon * * @param address The address of the daemon/server * @param ramUsage The ramUsage in per cent */ public void updateRamUsage(InetSocketAddress address, int ramUsage) { Map<InetSocketAddress, MooClient> daemonClients = clientsByType.get(ClientType.DAEMON); if(!daemonClients.containsKey(address)) return; daemonRamUsage.put(address, ramUsage); } /** * Gets the best available daemon where the ram usage is the lowest * * @return The client */ public MooClient getBestDaemon() { Map<InetSocketAddress, MooClient> daemonClients = clientsByType.get(ClientType.DAEMON); if(daemonClients.isEmpty()) return null; int lowesRamUsage = -1; MooClient <API key> = null; for(InetSocketAddress address : daemonClients.keySet()) { if(!daemonRamUsage.containsKey(address)) continue; MooClient client = daemonClients.get(address); int ramUsage = daemonRamUsage.get(address); if((lowesRamUsage == -1 || lowesRamUsage > ramUsage) && !((lowesRamUsage = ramUsage) >= (Integer) netServer.getConfig().get("slots-ram-usage"))) { <API key> = client; } } return <API key>; } /** * Adds a client to the hub * * @param cl The client * @return The size of the map */ public int add(MooClient cl) { Map<InetSocketAddress, MooClient> map = clientsByType.get(cl.getType()); map.put(cl.getAddress(), cl); if(cl.getType() == ClientType.DAEMON) { daemonRamUsage.put(cl.getAddress(), 0); } return map.size(); } /** * Removes a client from the hub * * @param address The address (the key) * @return This */ public ClientManager remove(InetSocketAddress address) { for(Map<InetSocketAddress, MooClient> m : clientsByType.values()) { m.entrySet().removeIf(entry -> entry.getKey().equals(address)); } return this; } public ClientManager remove(MooClient cl) { return remove(cl.getAddress()); } /** * Gets a client from address * * @param address The address * @return The client */ public MooClient get(InetSocketAddress address) { MooClient client = null; for(Map.Entry<ClientType, Map<InetSocketAddress, MooClient>> entry : clientsByType.entrySet()) { if(entry.getValue().containsKey(address)) { client = entry.getValue().get(address); } } return client; } public boolean contains(InetSocketAddress address) { return get(address) != null; } /** * Get clients (from type) * * @param type The type * @return The list of clients (unmodifiable) */ public UnmodifiableList<MooClient> getClients(ClientType type) { Map<InetSocketAddress, MooClient> map = clientsByType.get(type); return new UnmodifiableList<>(map.values()); } /** * Get all clients inside one list * * @return The list of clients */ public List<MooClient> getAll() { List<MooClient> clients = new ArrayList<>(); for(ClientType clientType : ClientType.values()) { clients.addAll(getClients(clientType)); } return clients; } public UnmodifiableList<MooClient> getMinecraftClients() { List<MooClient> clients = new ArrayList<>(); clients.addAll(getClients(ClientType.PROXY)); clients.addAll(getClients(ClientType.SERVER)); return new UnmodifiableList<>(clients); } public UnmodifiableList<MooClient> getServerClients() { return getClients(ClientType.SERVER); } public UnmodifiableList<MooClient> getProxyClients() { return getClients(ClientType.PROXY); } public UnmodifiableList<MooClient> getCustomClients() { return getClients(ClientType.CUSTOM); } public UnmodifiableList<MooClient> getDaemonClients() { return getClients(ClientType.DAEMON); } }
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int f1(int limite); int f2(int limite) { int i; for (i = 1; i < limite; i ++) f1(i); } int f1(int limite) { int i; for (i = 1; i < limite; i ++) f2(i); } int main(void) { f1(25); }
package models.planners import java.awt.Color import java.awt.image.BufferedImage import utils._ import models.{Yarn, Needle} import models.units.Stitches object Helper { /** First/last needle for the knitting with the given width when center alignment. */ def center(width: Stitches): (Needle, Needle) = { (Needle.middle - (width / 2).approx, Needle.middle + (width / 2).approx) } /** Convert two color image into a yarn pattern. */ def monochromeToPattern(img: BufferedImage, yarnWhite: Yarn, yarnBlack: Yarn): Matrix[Yarn] = { val rgbs = IndexedSeq.tabulate(img.getHeight, img.getWidth)((y, x) => new Color(img.getRGB(x, y))) val colors = rgbs.flatten.toSet.toSeq require(colors.size <= 2, s"not monochrome: ${colors.toList}") val white = if (colors.size > 1 && colors(0).getRGB > colors(1).getRGB) colors(1) else colors(0) rgbs.matrixMap(c => if (c == white) yarnWhite else yarnBlack) } /** Convert the image into a pattern, yarns are take from colors. */ def imageToPattern(img: BufferedImage): Matrix[Yarn] = { val rgbs = IndexedSeq.tabulate(img.getHeight, img.getWidth)((y, x) => new Color(img.getRGB(x, y))) val yarns = colorsToYarns(rgbs.flatten.toSet) val pattern = rgbs.matrixMap(yarns).reverseBoth pattern } def colorsToYarns(colors: Set[Color]) = { colors.zipWithIndex.map { case (c@Color.white, i) => c -> Yarn(s"White", new Color(0xf4f4f4)) case (c@Color.black, i) => c -> Yarn(s"Black", c) case (c@Color.yellow, i) => c -> Yarn(s"Yellow", c) case (c@Color.red, i) => c -> Yarn(s"Red", c) case (c@Color.green, i) => c -> Yarn(s"Green", c) case (c@Color.blue, i) => c -> Yarn(s"Blue", c) case (color, i) => color -> Yarn(s"Yarn $i", color) }.toMap } }
#include "dnsmasq.h" #ifdef HAVE_LOOP static ssize_t loop_make_probe(u32 uid); void loop_send_probes() { struct server *serv; if (!option_bool(OPT_LOOP_DETECT)) return; /* Loop through all upstream servers not for particular domains, and send a query to that server which is identifiable, via the uid. If we see that query back again, then the server is looping, and we should not use it. */ for (serv = daemon->servers; serv; serv = serv->next) if (!(serv->flags & (<API key> | SERV_NO_ADDR | SERV_USE_RESOLV | SERV_NO_REBIND | SERV_HAS_DOMAIN | SERV_FOR_NODOTS | SERV_LOOP))) { ssize_t len = loop_make_probe(serv->uid); int fd; struct randfd *rfd = NULL; if (serv->sfd) fd = serv->sfd->fd; else { if (!(rfd = allocate_rfd(serv->addr.sa.sa_family))) continue; fd = rfd->fd; } while (retry_send(sendto(fd, daemon->packet, len, 0, &serv->addr.sa, sa_len(&serv->addr)))); free_rfd(rfd); } } static ssize_t loop_make_probe(u32 uid) { struct dns_header *header = (struct dns_header *)daemon->packet; unsigned char *p = (unsigned char *)(header+1); /* packet buffer overwritten */ daemon->srv_save = NULL; header->id = rand16(); header->ancount = header->nscount = header->arcount = htons(0); header->qdcount = htons(1); header->hb3 = HB3_RD; header->hb4 = 0; SET_OPCODE(header, QUERY); *p++ = 8; sprintf((char *)p, "%.8x", uid); p += 8; *p++ = strlen(LOOP_TEST_DOMAIN); strcpy((char *)p, LOOP_TEST_DOMAIN); /* Add terminating zero */ p += strlen(LOOP_TEST_DOMAIN) + 1; PUTSHORT(LOOP_TEST_TYPE, p); PUTSHORT(C_IN, p); return p - (unsigned char *)header; } int detect_loop(char *query, int type) { int i; u32 uid; struct server *serv; if (!option_bool(OPT_LOOP_DETECT)) return 0; if (type != LOOP_TEST_TYPE || strlen(LOOP_TEST_DOMAIN) + 9 != strlen(query) || strstr(query, LOOP_TEST_DOMAIN) != query + 9) return 0; for (i = 0; i < 8; i++) if (!isxdigit(query[i])) return 0; uid = strtol(query, NULL, 16); for (serv = daemon->servers; serv; serv = serv->next) if (!(serv->flags & (<API key> | SERV_NO_ADDR | SERV_USE_RESOLV | SERV_NO_REBIND | SERV_HAS_DOMAIN | SERV_FOR_NODOTS | SERV_LOOP)) && uid == serv->uid) { serv->flags |= SERV_LOOP; check_servers(); /* log new state */ return 1; } return 0; } #endif
import math as mth import numpy as np # J Matthews, 21/02 # This is a file containing useful constants for python coding # Units in CGS unless stated #H=6.62606957E-27 HEV=4.13620e-15 #C=29979245800.0 #BOLTZMANN=1.3806488E-16 VERY_BIG=1e50 H=6.6262e-27 HC=1.98587e-16 HEV=4.13620e-15 # Planck's constant in eV HRYD=3.04005e-16 # NSH 1204 Planck's constant in Rydberg C =2.997925e10 G=6.670e-8 BOLTZMANN =1.38062e-16 WIEN= 5.879e10 # NSH 1208 Wien Disp Const in frequency units H_OVER_K=4.799437e-11 STEFAN_BOLTZMANN =5.6696e-5 THOMPSON=0.66524e-24 PI = 3.1415927 MELEC = 9.10956e-28 E= 4.8035e-10 # Electric charge in esu MPROT = 1.672661e-24 MSOL = 1.989e33 PC= 3.08e18 YR = 3.1556925e7 PI_E2_OVER_MC=0.02655103 # Classical cross-section PI_E2_OVER_M =7.96e8 ALPHA= 7.297351e-3 # Fine structure constant BOHR= 0.529175e-8 # Bohr radius CR= 3.288051e15 #Rydberg frequency for H != Ryd freq for infinite mass ANGSTROM = 1.e-8 #Definition of an Angstrom in units of this code, e.g. cm EV2ERGS =1.602192e-12 RADIAN= 57.29578 RYD2ERGS =2.1798741e-11 PARSEC=3.086E18
using System; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; namespace WeifenLuo.WinFormsUI.Docking { #region DockPanelSkin classes <summary> The skin to use when displaying the DockPanel. The skin allows custom gradient color schemes to be used when drawing the DockStrips and Tabs. </summary> [TypeConverter(typeof(<API key>))] public class DockPanelSkin { private AutoHideStripSkin m_autoHideStripSkin; private DockPaneStripSkin m_dockPaneStripSkin; public DockPanelSkin() { m_autoHideStripSkin = new AutoHideStripSkin(); m_dockPaneStripSkin = new DockPaneStripSkin(); } <summary> The skin used to display the auto hide strips and tabs. </summary> public AutoHideStripSkin AutoHideStripSkin { get { return m_autoHideStripSkin; } set { m_autoHideStripSkin = value; } } <summary> The skin used to display the Document and ToolWindow style DockStrips and Tabs. </summary> public DockPaneStripSkin DockPaneStripSkin { get { return m_dockPaneStripSkin; } set { m_dockPaneStripSkin = value; } } } <summary> The skin used to display the auto hide strip and tabs. </summary> [TypeConverter(typeof(<API key>))] public class AutoHideStripSkin { private DockPanelGradient m_dockStripGradient; private TabGradient m_TabGradient; public AutoHideStripSkin() { m_dockStripGradient = new DockPanelGradient(); m_dockStripGradient.StartColor = SystemColors.ControlLight; m_dockStripGradient.EndColor = SystemColors.ControlLight; m_TabGradient = new TabGradient(); m_TabGradient.TextColor = SystemColors.ControlDarkDark; } <summary> The gradient color skin for the DockStrips. </summary> public DockPanelGradient DockStripGradient { get { return m_dockStripGradient; } set { m_dockStripGradient = value; } } <summary> The gradient color skin for the Tabs. </summary> public TabGradient TabGradient { get { return m_TabGradient; } set { m_TabGradient = value; } } } <summary> The skin used to display the document and tool strips and tabs. </summary> [TypeConverter(typeof(<API key>))] public class DockPaneStripSkin { private <API key> m_DocumentGradient; private <API key> <API key>; public DockPaneStripSkin() { m_DocumentGradient = new <API key>(); m_DocumentGradient.DockStripGradient.StartColor = SystemColors.Control; m_DocumentGradient.DockStripGradient.EndColor = SystemColors.Control; m_DocumentGradient.ActiveTabGradient.StartColor = SystemColors.ControlLightLight; m_DocumentGradient.ActiveTabGradient.EndColor = SystemColors.ControlLightLight; m_DocumentGradient.InactiveTabGradient.StartColor = SystemColors.ControlLight; m_DocumentGradient.InactiveTabGradient.EndColor = SystemColors.ControlLight; <API key> = new <API key>(); <API key>.DockStripGradient.StartColor = SystemColors.ControlLight; <API key>.DockStripGradient.EndColor = SystemColors.ControlLight; <API key>.ActiveTabGradient.StartColor = SystemColors.Control; <API key>.ActiveTabGradient.EndColor = SystemColors.Control; <API key>.InactiveTabGradient.StartColor = Color.Transparent; <API key>.InactiveTabGradient.EndColor = Color.Transparent; <API key>.InactiveTabGradient.TextColor = SystemColors.ControlDarkDark; <API key>.<API key>.StartColor = SystemColors.<API key>; <API key>.<API key>.EndColor = SystemColors.ActiveCaption; <API key>.<API key>.LinearGradientMode = LinearGradientMode.Vertical; <API key>.<API key>.TextColor = SystemColors.ActiveCaptionText; <API key>.<API key>.StartColor = SystemColors.<API key>; <API key>.<API key>.EndColor = SystemColors.<API key>; <API key>.<API key>.LinearGradientMode = LinearGradientMode.Vertical; <API key>.<API key>.TextColor = SystemColors.ControlText; } <summary> The skin used to display the Document style DockPane strip and tab. </summary> public <API key> DocumentGradient { get { return m_DocumentGradient; } set { m_DocumentGradient = value; } } <summary> The skin used to display the ToolWindow style DockPane strip and tab. </summary> public <API key> ToolWindowGradient { get { return <API key>; } set { <API key> = value; } } } <summary> The skin used to display the DockPane ToolWindow strip and tab. </summary> [TypeConverter(typeof(<API key>))] public class <API key> : <API key> { private TabGradient <API key>; private TabGradient <API key>; public <API key>() { <API key> = new TabGradient(); <API key> = new TabGradient(); } <summary> The skin used to display the active ToolWindow caption. </summary> public TabGradient <API key> { get { return <API key>; } set { <API key> = value; } } <summary> The skin used to display the inactive ToolWindow caption. </summary> public TabGradient <API key> { get { return <API key>; } set { <API key> = value; } } } <summary> The skin used to display the DockPane strip and tab. </summary> [TypeConverter(typeof(<API key>))] public class <API key> { private DockPanelGradient m_dockStripGradient; private TabGradient m_activeTabGradient; private TabGradient <API key>; public <API key>() { m_dockStripGradient = new DockPanelGradient(); m_activeTabGradient = new TabGradient(); <API key> = new TabGradient(); } <summary> The gradient color skin for the DockStrip. </summary> public DockPanelGradient DockStripGradient { get { return m_dockStripGradient; } set { m_dockStripGradient = value; } } <summary> The skin used to display the active DockPane tabs. </summary> public TabGradient ActiveTabGradient { get { return m_activeTabGradient; } set { m_activeTabGradient = value; } } <summary> The skin used to display the inactive DockPane tabs. </summary> public TabGradient InactiveTabGradient { get { return <API key>; } set { <API key> = value; } } } <summary> The skin used to display the dock pane tab </summary> [TypeConverter(typeof(<API key>))] public class TabGradient : DockPanelGradient { private Color m_textColor; public TabGradient() { m_textColor = SystemColors.ControlText; } <summary> The text color. </summary> [DefaultValue(typeof(SystemColors), "ControlText")] public Color TextColor { get { return m_textColor; } set { m_textColor = value; } } } <summary> The gradient color skin. </summary> [TypeConverter(typeof(<API key>))] public class DockPanelGradient { private Color m_startColor; private Color m_endColor; private LinearGradientMode <API key>; public DockPanelGradient() { m_startColor = SystemColors.Control; m_endColor = SystemColors.Control; <API key> = LinearGradientMode.Horizontal; } <summary> The beginning gradient color. </summary> [DefaultValue(typeof(SystemColors), "Control")] public Color StartColor { get { return m_startColor; } set { m_startColor = value; } } <summary> The ending gradient color. </summary> [DefaultValue(typeof(SystemColors), "Control")] public Color EndColor { get { return m_endColor; } set { m_endColor = value; } } <summary> The gradient mode to display the colors. </summary> [DefaultValue(LinearGradientMode.Horizontal)] public LinearGradientMode LinearGradientMode { get { return <API key>; } set { <API key> = value; } } } #endregion DockPanelSkin classes #region Converters public class <API key> : <API key> { public override bool CanConvertTo(<API key> context, Type destinationType) { if (destinationType == typeof(DockPanelSkin)) return true; return base.CanConvertTo(context, destinationType); } public override object ConvertTo(<API key> context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(String) && value is DockPanelSkin) { return "DockPanelSkin"; } return base.ConvertTo(context, culture, value, destinationType); } } public class <API key> : <API key> { public override bool CanConvertTo(<API key> context, Type destinationType) { if (destinationType == typeof(DockPanelGradient)) return true; return base.CanConvertTo(context, destinationType); } public override object ConvertTo(<API key> context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(String) && value is DockPanelGradient) { return "DockPanelGradient"; } return base.ConvertTo(context, culture, value, destinationType); } } public class <API key> : <API key> { public override bool CanConvertTo(<API key> context, Type destinationType) { if (destinationType == typeof(AutoHideStripSkin)) return true; return base.CanConvertTo(context, destinationType); } public override object ConvertTo(<API key> context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(String) && value is AutoHideStripSkin) { return "AutoHideStripSkin"; } return base.ConvertTo(context, culture, value, destinationType); } } public class <API key> : <API key> { public override bool CanConvertTo(<API key> context, Type destinationType) { if (destinationType == typeof(DockPaneStripSkin)) return true; return base.CanConvertTo(context, destinationType); } public override object ConvertTo(<API key> context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(String) && value is DockPaneStripSkin) { return "DockPaneStripSkin"; } return base.ConvertTo(context, culture, value, destinationType); } } public class <API key> : <API key> { public override bool CanConvertTo(<API key> context, Type destinationType) { if (destinationType == typeof(<API key>)) return true; return base.CanConvertTo(context, destinationType); } public override object ConvertTo(<API key> context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(String) && value is <API key>) { return "<API key>"; } return base.ConvertTo(context, culture, value, destinationType); } } public class <API key> : <API key> { public override bool CanConvertTo(<API key> context, Type destinationType) { if (destinationType == typeof(TabGradient)) return true; return base.CanConvertTo(context, destinationType); } public override object ConvertTo(<API key> context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(String) && value is TabGradient) { return "DockPaneTabGradient"; } return base.ConvertTo(context, culture, value, destinationType); } } #endregion Converters }
/* * General control styling */ .control-table .table-container { border: 1px solid #e0e0e0; -<API key>: 4px; -moz-border-radius: 4px; border-radius: 4px; overflow: hidden; margin-bottom: 15px; } .control-table .table-container:last-child { margin-bottom: 0; } .control-table.active .table-container { border-color: #808c8d; } .control-table table { width: 100%; border-collapse: collapse; table-layout: fixed; } .control-table table td, .control-table table th { padding: 0; font-size: 13px; color: #555555; } .control-table table [data-view-container] { padding: 5px 10px; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 28px; } .control-table table.headers:after { content: ' '; display: block; position: absolute; left: 1px; right: 1px; margin-top: -1px; border-bottom: 1px solid #e0e0e0; } .control-table table.headers th { padding: 7px 10px; font-size: 13px; text-transform: uppercase; font-weight: 600; color: #333333; background: white; border-right: 1px solid #ecf0f1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .control-table table.headers th [data-view-container] { padding-bottom: 6px; } .control-table table.headers th:last-child { border-right: none; } .control-table.active table.headers:after { border-bottom-color: #808c8d; } .control-table table.data td { border: 1px solid #ecf0f1; } .control-table table.data td .content-container { position: relative; padding: 1px; } .control-table table.data td.active { border-color: #5fb6f5 !important; } .control-table table.data td.active .content-container { padding: 0; border: 1px solid #5fb6f5; } .control-table table.data td.active .content-container:before, .control-table table.data td.active .content-container:after { content: ' '; background: #5fb6f5; position: absolute; left: -2px; top: -2px; } .control-table table.data td.active .content-container:before { width: 1px; bottom: -2px; } .control-table table.data td.active .content-container:after { right: -2px; height: 1px; } .control-table table.data tr { background-color: white; } .control-table table.data tr.error { background-color: #fbecec!important; } .control-table table.data tr.error td.active.error { border-color: #ec0000!important; } .control-table table.data tr.error td.active.error .content-container { border-color: #ec0000!important; } .control-table table.data tr.error td.active.error .content-container:before, .control-table table.data tr.error td.active.error .content-container:after { background-color: #ec0000!important; } .control-table table.data tr:nth-child(2n) { background-color: #fbfbfb; } .control-table table.data tr:first-child td { border-top: none; } .control-table table.data tr:last-child td { border-bottom: none; } .control-table table.data td:first-child { border-left: none; } .control-table table.data td:last-child { border-right: none; } .control-table .control-scrollbar > div { <API key>: 4px; <API key>: 4px; overflow: hidden; } .control-table .control-scrollbar table.data tr:last-child td { border-bottom: 1px solid #ecf0f1; } .control-table .toolbar { background: white; border-bottom: 1px solid #e0e0e0; } .control-table .toolbar a.btn { color: #323e50; padding: 10px; opacity: 0.5; filter: alpha(opacity=50); } .control-table .toolbar a.btn:hover { opacity: 1; filter: alpha(opacity=100); } .control-table .toolbar a.table-icon:before { display: inline-block; content: ' '; width: 16px; height: 16px; margin-right: 8px; position: relative; top: 3px; background: transparent url(../images/table-icons.gif) no-repeat; background-position: 0 0; background-size: 32px auto; } .control-table .toolbar a.table-icon.add-table-row-above:before { background-position: 0 -56px; } .control-table .toolbar a.table-icon.delete-table-row:before { background-position: 0 -113px; } .control-table.active .toolbar { border-bottom-color: #808c8d; } .control-table .pagination ul { padding: 0; margin-bottom: 15px; } .control-table .pagination ul li { list-style: none; padding: 4px 6px; -<API key>: 2px; -moz-border-radius: 2px; border-radius: 2px; display: inline-block; margin-right: 5px; font-size: 12px; background: #ecf0f1; line-height: 100%; } .control-table .pagination ul li a { text-decoration: none; color: #95a5a6; } .control-table .pagination ul li.active { background: #5fb6f5; } .control-table .pagination ul li.active a { color: #ffffff; } @media only screen and (-<API key>: 1.5), only screen and (-<API key>: 3/2), only screen and (-<API key>: 1.5), only screen and (<API key>: 1.5), only screen and (min-resolution: 1.5dppx) { .control-table .toolbar a:before { background-position: 0px -9px; background-size: 16px auto; } .control-table .toolbar a.add-table-row-above:before { background-position: 0 -39px; } .control-table .toolbar a.delete-table-row:before { background-position: 0 -66px; } } /* * String editor */ .control-table td[data-column-type=string] input[type=text] { width: 100%; height: 100%; display: block; outline: none; border: none; padding: 5px 10px; } /* * Checkbox editor */ .control-table td[data-column-type=checkbox] div[<API key>] { width: 16px; height: 16px; border-radius: 2px; background-color: #FFFFFF; border: 1px solid #999999; margin: 5px 5px 5px 10px; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .control-table td[data-column-type=checkbox] div[<API key>]:hover { border-color: #808080; color: #4d4d4d; } .control-table td[data-column-type=checkbox] div[<API key>].checked { border-width: 2px; } .control-table td[data-column-type=checkbox] div[<API key>].checked:before { font-family: FontAwesome; font-weight: normal; font-style: normal; text-decoration: inherit; -<API key>: antialiased; *margin-right: .3em; content: "\f00c"; font-size: 10px; position: relative; left: 1px; top: -4px; } .control-table td[data-column-type=checkbox] div[<API key>]:focus { border-color: #5fb6f5; outline: none; } /* * Dropdown editor */ .control-table td[data-column-type=dropdown] { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .control-table td[data-column-type=dropdown] [data-view-container] { padding-right: 20px; position: relative; cursor: pointer; } .control-table td[data-column-type=dropdown] [data-view-container]:after { font-family: FontAwesome; font-weight: normal; font-style: normal; text-decoration: inherit; -<API key>: antialiased; *margin-right: .3em; content: "\f107"; font-size: 13px; line-height: 100%; color: #95a5a6; position: absolute; top: 8px; right: 10px; } .control-table td[data-column-type=dropdown] [data-view-container]:hover:after { color: #0181b9; } .control-table td[data-column-type=dropdown] [data-dropdown-open=true] { background: white; } .control-table td[data-column-type=dropdown] [data-dropdown-open=true] [data-view-container]:after { font-family: FontAwesome; font-weight: normal; font-style: normal; text-decoration: inherit; -<API key>: antialiased; *margin-right: .3em; content: "\f106"; } .control-table td[data-column-type=dropdown] .content-container { outline: none; } /* Frameless control styles start */ .widget-field.frameless .control-table .table-container { border-top: none; border-left: none; border-right: none; -<API key>: 0; -moz-border-radius: 0; border-radius: 0; } .widget-field.frameless .control-table .toolbar { background: transparent; } /* Frameless control styles end */ html.cssanimations .control-table td[data-column-type=dropdown] [data-view-container].loading:after { background-image: url('../../../../../../modules/system/assets/ui/images/loader-transparent.svg'); background-size: 15px 15px; background-position: 50% 50%; position: absolute; width: 15px; height: 15px; top: 6px; right: 5px; content: ' '; -webkit-animation: spin 1s linear infinite; animation: spin 1s linear infinite; } .<API key> { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; position: absolute; background: white; border: 1px solid #808c8d; border-top: none; padding-top: 1px; overflow: hidden; z-index: 1000; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; <API key>: 4px; <API key>: 4px; } .<API key> ul { border-top: 1px solid #ecf0f1; padding: 0; margin: 0; max-height: 200px; overflow: auto; } .<API key> li { list-style: none; font-size: 13px; color: #555555; padding: 5px 10px; cursor: pointer; outline: none; } .<API key> li:hover, .<API key> li:focus, .<API key> li.selected { background: #5fb6f5; color: white; }
def format_path( str ): while( str.find( ' str = str.replace( ' return str
/* page layout styles */ *{ margin:0; padding:0; } body { background-color:#eee; color:#fff; font:14px/1.3 Arial,sans-serif; } header { background-color:#212121; box-shadow: 0 -1px 2px #111111; display:block; height:70px; position:relative; width:100%; z-index:100; } header h2{ font-size:22px; font-weight:normal; left:50%; margin-left:-400px; padding:22px 0; position:absolute; width:540px; } header a.stuts,a.stuts:visited{ border:none; text-decoration:none; color:#fcfcfc; font-size:14px; left:50%; line-height:31px; margin:23px 0 0 110px; position:absolute; top:0; } header .stuts span { font-size:22px; font-weight:bold; margin-left:5px; } .container { color: #000; margin: 20px auto; overflow: hidden; position: relative; width: 600px; height: 400px; } .controls { border: 1px dashed gray; color: #000; margin: 20px auto; padding: 25px; position: relative; width: 550px; } .controls p { margin-bottom: 10px; } .controls input { margin-left: 10px; }
#!/usr/bin/env bash # Usage example: # PLot the chirp signal and its frequency domain presentation: # (while true; do echo line; sleep 0.01; done)| \ # awk 'BEGIN{PI=atan2(0,-1);t=0;f0=1;f1=32;T=256;k=(f1-f0)/T;}{print sin(2*PI*(t*f0+k/2*t*t));t+=0.1;fflush()}'| \ # tee >(bin/dsp/fft.sh 64 "w1;0.5;0.5"|bin/dsp/fftabs.sh 64| \ # bin/gp/gnuplotblock.sh '-0.5:31.5;0:0.5' 'Chirp signal spectrum;1')| \ # bin/gp/gnuplotwindow.sh 128 "-1:1" "Chirp signal;2" N=${1:-64} # number of samples, default 64 wd=${2:-w0} # window function description, w0-rectangular window (default), w1-hanning window col=${3:-1} # input stream column to calculate fft for awk -v N="$N" -v col="$col" -v win_desc="$wd" ' function compl_add(a, b, ara,arb) { split(a, ara);split(b, arb); return ara[1]+arb[1]" "ara[2]+arb[2]; } function compl_sub(a, b, ara,arb) { split(a, ara);split(b, arb); return ara[1]-arb[1]" "ara[2]-arb[2]; } function compl_mul(a, b, ara,arb) { split(a, ara);split(b, arb); return ara[1]*arb[1]-ara[2]*arb[2]" "ara[1]*arb[2]+ara[2]*arb[1]; } function init_hanning_window(N,a,b, i) { for(i=0;i<N;++i) { w[i] = a - b*cos(2*PI*i/(N-1)); } } function init_window(N,win_desc, i,wa,a,b,win_type) { split(win_desc, wa, ";"); switch(wa[1]) { case "w1": # hanning window win_type = 1; if (2 in wa) a = wa[2]; else a = 0.5; if (3 in wa) b = wa[3]; else b = 0.5; init_hanning_window(N,a,b); break; case "w0": default: win_type = 0; break; } return win_type; } function apply_window(N, i) { for(i=0;i<N;++i) { c[i]*=w[i]; } } function calc_pow2(N, pow) { pow = 0; while(N = rshift(N,1)) { ++pow; }; return pow; } function bit_reverse(n,pow, i,r) { r = 0; pow-=1; for(i=pow;i>=0;--i) { r = or(r,lshift(and(rshift(n,i),1), pow-i)); } return r; } function binary_inversion(N,pow, tmp,i,j) { # pow = calc_pow2(N); for(i=0;i<N;++i) { j = bit_reverse(i,pow); if (i<j) { tmp = c[i]; c[i] = c[j]; c[j] = tmp; } } } function fft(start,end,e, N,N2,k,t,et) { N = end - start; if (N<2) return; N2 = N/2; et = e; for (k=0;k<N2;++k) { t = c[start+k]; c[start+k] = compl_add(t,c[start+k+N2]); c[start+k+N2] = compl_sub(t,c[start+k+N2]); if (k>0) { c[start+k+N2] = compl_mul(et,c[start+k+N2]); et = compl_mul(et,e); } } et = compl_mul(e,e); fft(start, start+N2, et); fft(start+N2, end, et); } function print_fft(N, N2,i) { N2 = N/2; for(i=1;i<=N2;++i) { print c[i]; } } BEGIN { if (and(N,N-1)!=0) { print "Error: Signal width shall be power of two!" > "/dev/stderr"; exit(1); } start=0;end=0; for(i=0;i<N;++i) a[i]=0; PI = atan2(0,-1); expN = cos(2*PI/N) " " (-sin(2*PI/N)); N2 = N/2; pow = calc_pow2(N); # win_type = 0; # rectangular window by default # win_type = 1; # hanning window win_type = init_window(N, win_desc); } { if (match($0,/^.+$/)) { a[end] = $col; ++end; if (end>start+N) { delete a[start]; start++; } for (i=start;i<N+start;++i) { (i<end)?c[i-start] = a[i]:c[i-start] = 0; } if (win_type!=0) { apply_window(N); } fft(0,N,expN); binary_inversion(N,pow); # N = 2^pow; print_fft(N); printf("\n"); fflush(); } } ' -
document.addEventListener("DOMContentLoaded", function (event) { 'use strict'; var paragraph, url, proxy; paragraph = document.querySelectorAll('p.error_text'); chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) { url = tabs[0].url; if (url.indexOf('chrome: paragraph[0].innerHTML = 'Sorry, you can\'t activate Browse Google Cache on a page with a "chrome://" URL.'; } else if (url.indexOf('https://chrome.google.com/webstore') == 0) { paragraph[0].innerHTML = 'Sorry, you can\'t activate Browse Google Cache on the Chrome Web Store.'; } else { chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) { chrome.runtime.sendMessage({ action : '<API key>', 'tab': tabs[0] }); window.close(); }); } }); });
using Deployer.Services.Config; using Deployer.Services.Config.Interfaces; using Moq; using NUnit.Framework; using System.Collections; namespace Deployer.Tests.Config { [TestFixture] public class <API key> { private Mock<IJsonPersistence> _jsonPersist; private Mock<ISlugCreator> _slugCreator; private <API key> _sut; [SetUp] public void BeforeEachTest() { _jsonPersist = new Mock<IJsonPersistence>(); _slugCreator = new Mock<ISlugCreator>(); _sut = new <API key>(@"\root\", _jsonPersist.Object, _slugCreator.Object); } [Test] public void Empty_build_params() { _jsonPersist.Setup(x => x.Read(@"\root\config\slug-1.json")).Returns(new Hashtable()); var hash = _sut.GetBuildParams("slug-1"); Assert.IsNotNull(hash); Assert.AreEqual(0, hash.Count); _jsonPersist.Verify(x => x.Read(It.IsAny<string>()), Times.Once); _jsonPersist.Verify(x => x.Read(@"\root\config\slug-1.json"), Times.Once); } [Test] public void Read_params() { var mockHash = new Hashtable { {"key1", "value1"}, {"key2", "value2"} }; _jsonPersist.Setup(x => x.Read(@"\root\config\slug-1.json")).Returns(mockHash); var actualHash = _sut.GetBuildParams("slug-1"); Assert.IsNotNull(actualHash); Assert.AreEqual(2, actualHash.Count); Assert.AreEqual("value1", actualHash["key1"]); Assert.AreEqual("value2", actualHash["key2"]); _jsonPersist.Verify(x => x.Read(It.IsAny<string>()), Times.Once); _jsonPersist.Verify(x => x.Read(@"\root\config\slug-1.json"), Times.Once); } [Test] public void Write_params() { var mockHash = new Hashtable { {"key1", "value1"}, {"key2", "value2"} }; _jsonPersist.Setup(x => x.Write(@"\root\config\slug-1.json", It.IsAny<Hashtable>())) .Callback((string path, Hashtable hash) => { Assert.AreEqual(2, hash.Count); Assert.AreEqual("value1", hash["key1"]); Assert.AreEqual("value2", hash["key2"]); }); _sut.SaveBuildParams("slug-1", mockHash); _jsonPersist.Verify(x => x.Write(@"\root\config\slug-1.json", It.IsAny<Hashtable>()), Times.Once); } } }
package ch.hgdev.toposuite.utils; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Useful static method for manipulating String. * * @author HGdev */ public class StringUtils { public static final String UTF8_BOM = "\uFEFF"; /** * This method assumes that the String contains a number. * * @param str A String. * @return The String incremented by 1. * @throws <API key> Thrown if the input String does not end with a suitable * number. */ public static String incrementAsNumber(String str) throws <API key> { if (str == null) { throw new <API key>("The input String must not be null!"); } Pattern p = Pattern.compile("([0-9]+)$"); Matcher m = p.matcher(str); if (!m.find()) { throw new <API key>( "Invalid input argument! The input String must end with a valid number"); } String number = m.group(1); String prefix = str.substring(0, str.length() - number.length()); return prefix + String.valueOf(Integer.valueOf(number) + 1); } }
package org.currconv.services.impl; import java.util.List; import org.currconv.dao.UserDao; import org.currconv.entities.user.User; import org.currconv.services.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service("userService") @Transactional public class UserServiceImpl implements UserService { @Autowired private UserDao dao; public void saveUser(User user) { dao.saveUser(user); } public List<User> findAllUsers(){ return dao.findAllUsers(); } public User findByUserName(String name){ return dao.findByUserName(name); } }
package com.debugtoday.htmldecoder.output; import java.io.File; import java.io.<API key>; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.<API key>; import java.util.List; import java.util.regex.Matcher; import org.slf4j.Logger; import com.debugtoday.htmldecoder.decoder.GeneralDecoder; import com.debugtoday.htmldecoder.exception.GeneralException; import com.debugtoday.htmldecoder.log.CommonLog; import com.debugtoday.htmldecoder.output.object.FileOutputArg; import com.debugtoday.htmldecoder.output.object.PaginationOutputArg; import com.debugtoday.htmldecoder.output.object.TagFileOutputArg; import com.debugtoday.htmldecoder.output.object.TagOutputArg; import com.debugtoday.htmldecoder.output.object.TagWrapper; import com.debugtoday.htmldecoder.output.object.<API key>; /** * base class for output relative to file output, i.g. article/article page/tag page/category page * @author zydecx * */ public class AbstractFileOutput implements Output { private static final Logger logger = CommonLog.getLogger(); @Override public String export(Object object) throws GeneralException { // TODO Auto-generated method stub return DONE; } /** * @param file * @param template * @param arg * @throws GeneralException */ public void writeToFile(File file, <API key> template, FileOutputArg arg) throws GeneralException { File parentFile = file.getParentFile(); if (!parentFile.exists()) { parentFile.mkdirs(); } if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { throw new GeneralException("fail to create file[" + file.getAbsolutePath() + "]", e); } } try ( PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); ) { String formattedHead = ""; if (arg.getPageTitle() != null) { formattedHead += "<title>" + arg.getPageTitle() + "</title>"; } if (arg.getHead() != null) { formattedHead += "\n" + arg.getHead(); } String templateFullText = template.getFullText() .replace(GeneralDecoder.<API key>("head"), formattedHead); if (arg.getBodyTitle() != null) { templateFullText = templateFullText .replace(GeneralDecoder.<API key>("body_title"), arg.getBodyTitle()); } if (arg.getBody() != null) { templateFullText = templateFullText .replace(GeneralDecoder.<API key>("body"), arg.getBody()); } if (arg.getPagination() != null) { templateFullText = templateFullText .replace(GeneralDecoder.<API key>("pagination"), arg.getPagination()); } pw.write(templateFullText); } catch (<API key> | <API key> e) { throw new GeneralException("fail to write to file[" + file.getAbsolutePath() + "]", e); } } /** * used for tag page/category page output * @param <API key> * @param arg * @throws GeneralException */ public void exportTagPage(<API key> <API key>, TagFileOutputArg arg) throws GeneralException { List<TagWrapper> itemList = arg.getTagList(); int itemSize = itemList.size(); int pagination = arg.getPagination(); int pageSize = (int) Math.ceil(itemSize * 1.0 / pagination); Output tagOutput = arg.getTagOutput(); Output paginationOutput = arg.getPaginationOutput(); for (int i = 1; i <= pageSize; i++) { List<TagWrapper> subList = itemList.subList((i - 1) * pagination, Math.min(itemSize, i * pagination)); StringBuilder sb = new StringBuilder(); for (TagWrapper item : subList) { String itemName = item.getName(); TagOutputArg tagArg = new TagOutputArg(itemName, arg.getRootUrl() + "/" + item.getName(), item.getArticleList().size()); sb.append(tagOutput.export(tagArg)); } File file = new File(formatPageFilePath(arg.getRootFile().getAbsolutePath(), i)); FileOutputArg fileOutputArg = new FileOutputArg(); fileOutputArg.setBodyTitle(arg.getBodyTitle()); fileOutputArg.setBody(sb.toString()); fileOutputArg.setPageTitle(arg.getBodyTitle()); fileOutputArg.setPagination(paginationOutput.export(new PaginationOutputArg(arg.getRootUrl(), pageSize, i))); writeToFile(file, <API key>, fileOutputArg); } } protected String formatPageUrl(String rootUrl, int index) { return PaginationOutput.formatPaginationUrl(rootUrl, index); } protected String formatPageFilePath(String rootPath, int index) { return PaginationOutput.<API key>(rootPath, index); } }
void dflu_pack_fin(DFluPack *p) { UC(dmap_fin(NFRAGS, &p->map)); UC(comm_bags_fin(PINNED, NONE, &p->hpp, &p->dpp)); if (p->opt.ids) UC(comm_bags_fin(PINNED, NONE, &p->hii, &p->dii)); if (p->opt.colors) UC(comm_bags_fin(PINNED, NONE, &p->hcc, &p->dcc)); EFREE(p); } void dflu_comm_fin(DFluComm *c) { UC(comm_fin(c->pp)); if (c->opt.ids) UC(comm_fin(c->ii)); if (c->opt.colors) UC(comm_fin(c->cc)); EFREE(c); } void dflu_unpack_fin(DFluUnpack *u) { UC(comm_bags_fin(HST_ONLY, NONE, &u->hpp, NULL)); if (u->opt.ids) UC(comm_bags_fin(HST_ONLY, NONE, &u->hii, NULL)); if (u->opt.colors) UC(comm_bags_fin(HST_ONLY, NONE, &u->hcc, NULL)); CC(d::Free(u->ppre)); if (u->opt.ids) CC(d::Free(u->iire)); if (u->opt.colors) CC(d::Free(u->ccre)); EFREE(u); }
#include "Aria.h" #include "ArExport.h" #include "<API key>.h" #include "<API key>.h" AREXPORT <API key>::<API key>( ArServerBase *server, ArRobot *robot, bool <API key>, bool useComputerJoystick, bool useRobotJoystick, bool useServerCommands, const char *name, bool <API key>) : ArServerMode(robot, server, name), myRatioDriveGroup(robot), myJoyUserTaskCB(this, &<API key>::joyUserTask), <API key>(this, &<API key>::serverSetSafeDrive), <API key>(this, &<API key>::serverGetSafeDrive), <API key>(this, &<API key>::serverRatioDrive), myRatioFireCB(this, &<API key>::ratioFireCallback), <API key>(this, &<API key>::<API key>), <API key>(this, &<API key>::<API key>) { myHandlerCommands = NULL; myDriveSafely = true; <API key> = <API key>; <API key> = useComputerJoystick; myUseRobotJoystick = useRobotJoystick; myUseServerCommands = useServerCommands; <API key> = true; <API key> = <API key>; myTimeout = 2; myGotServerCommand = true; myLastTimedOut = false; // SEEKUR mySentRecenter = false; // add the actions, put the ratio input on top, then have the // limiters since the ratio doesn't touch decel except lightly // whereas the limiter will touch it strongly myRatioAction = new ArActionRatioInput; myRatioDriveGroup.addAction(myRatioAction, 50); myLimiterForward = new <API key>( "<API key>", <API key>::FORWARDS); myRatioDriveGroup.addAction(myLimiterForward, 40); myLimiterBackward = new <API key>( "<API key>", <API key>::BACKWARDS); myRatioDriveGroup.addAction(myLimiterBackward, 39); <API key> = NULL; <API key> = NULL; if (myRobot->hasLatVel()) { <API key> = new <API key>( "<API key>", <API key>::LATERAL_LEFT); myRatioDriveGroup.addAction(<API key>, 38); <API key> = new <API key>( "<API key>", <API key>::LATERAL_RIGHT); myRatioDriveGroup.addAction(<API key>, 37); } <API key> = new <API key>("<API key>", false); myRatioDriveGroup.addAction(<API key>, 1); myRatioFireCB.setName("<API key>"); myRatioAction->addFireCallback(30, &myRatioFireCB); <API key> = true; if (myServer != NULL && myUseServerCommands) { addModeData("ratioDrive", "drives the robot as with a joystick", &<API key>, "double: transRatio; double: rotRatio; double: throttleRatio ", "none", "Movement", "RETURN_NONE"); myServer->addData("setSafeDrive", "sets whether we drive the robot safely or not", &<API key>, "byte: 1 == drive safely, 0 == drive unsafely", "none", "UnsafeMovement", "RETURN_NONE"); myServer->addData("getSafeDrive", "gets whether we drive the robot safely or not", &<API key>, "none", "byte: 1 == driving safely, 0 == driving unsafely", "Movement", "RETURN_SINGLE"); } if (<API key>) { myJoydrive = new <API key>(robot, myRatioAction); if ((myJoyHandler = Aria::getJoyHandler()) == NULL) { myJoyHandler = new ArJoyHandler; myJoyHandler->init(); Aria::setJoyHandler(myJoyHandler); } } if (myUseRobotJoystick) { myRobotJoydrive = new <API key>(robot, myRatioAction); if ((myRobotJoyHandler = Aria::getRobotJoyHandler()) == NULL) { myRobotJoyHandler = new ArRobotJoyHandler(robot); Aria::setRobotJoyHandler(myRobotJoyHandler); } } if (myUseRobotJoystick || <API key>) { std::string taskName = name; taskName += "::joyUserTask"; myRobot->addUserTask(taskName.c_str(), 75, &myJoyUserTaskCB); } myPrinting = false; } AREXPORT <API key>::~<API key>() { } AREXPORT void <API key>::addToConfig(ArConfig *config, const char *section) { config->addParam( ArConfigArg( "Timeout", &myTimeout, "If there are no commands for this period of time, then the robot will stop. 0 Disables. This is a double so you can do like .1 seconds if you want.", 0), section, ArPriority::ADVANCED); myRatioAction->addToConfig(config, section); myLimiterForward->addToConfig(config, section, "Forward"); myLimiterBackward->addToConfig(config, section, "Backward"); if (<API key> != NULL) <API key>->addToConfig(config, section, "Lateral"); if (<API key> != NULL) <API key>->addToConfig(config, section, "Lateral"); <API key>->addToConfig(config, section, "Teleop"); } AREXPORT void <API key>::activate(void) { //if (!baseActivate()) { // return; ratioDrive(0, 0, 100, true); } AREXPORT void <API key>::deactivate(void) { myRatioDriveGroup.deactivate(); baseDeactivate(); } AREXPORT void <API key>::setSafeDriving(bool safe, bool internal) { if (!internal) myRobot->lock(); // if this is a change then print it if (safe != myDriveSafely) { if (safe) { ArLog::log(ArLog::Normal, "%s: Driving safely again", myName.c_str()); } else { ArLog::log(ArLog::Normal, "%s: Driving UNSAFELY", myName.c_str()); } myNewDriveSafely = true; } myDriveSafely = safe; // ratioDrive is only called if this mode is already active if (isActive()) ratioDrive(myRatioAction->getTransRatio(), myRatioAction->getRotRatio(), myRatioAction->getThrottleRatio()); if (!internal) myRobot->unlock(); } AREXPORT bool <API key>::getSafeDriving(void) { return myDriveSafely; } AREXPORT void <API key>::<API key>(void) { setSafeDriving(true); } AREXPORT void <API key>::<API key>(void) { setSafeDriving(false); } AREXPORT void <API key>::addControlCommands(<API key> *handlerCommands) { if (!myUseServerCommands) { ArLog::log(ArLog::Normal, "<API key>::addControlCommands: Tried to add control commands to a ratio drive not using the server"); return; } myHandlerCommands = handlerCommands; myHandlerCommands->addCommand( "<API key>", "Enables safe driving with ratioDrive, which will attempt to prevent collisions (default)", &<API key>, "UnsafeMovement"); myHandlerCommands->addCommand( "<API key>", "Disables safe driving with ratioDrive, this is UNSAFE and will let you drive your robot into things or down stairs, use at your own risk", &<API key>, "UnsafeMovement"); } /** * @param isActivating a bool set to true only if this method is called from the activate() * method, otherwise false * @param transRatio Amount of forward velocity to request * @param rotRatio Amount of rotational velocity to request * @param throttleRatio Amount of speed to request * @param latRatio amount of lateral velocity to request (if robot supports it) **/ AREXPORT void <API key>::ratioDrive( double transRatio, double rotRatio, double throttleRatio, bool isActivating, double latRatio) { bool wasActive; wasActive = isActive(); myTransRatio = transRatio; myRotRatio = rotRatio; myThrottleRatio = throttleRatio; myLatRatio = latRatio; // KMC: Changed the following test to include isActivating. // if (!wasActive && !baseActivate()) // return; // The baseActivate() method should only be called in the context of the activate() // method. if (isActivating && !wasActive) { if (!baseActivate()) { return; } } // end if activating and wasn't previously active // This is to handle the case where ratioDrive is called outside the // activate() method, and the activation was not successful. if (!isActive()) { return; } if (!wasActive || myNewDriveSafely) { myRobot->clearDirectMotion(); if (myDriveSafely) { myRatioDriveGroup.activateExclusive(); myMode = "Drive"; ArLog::log(ArLog::Normal, "%s: Driving safely", myName.c_str()); } else { myRobot->deactivateActions(); myRatioAction->activate(); myMode = "UNSAFE Drive"; ArLog::log(ArLog::Normal, "%s: Driving unsafely", myName.c_str()); } if (myDriveSafely) <API key>.invoke(); else <API key>.invoke(); } myNewDriveSafely = false; // MPL why is this here twice? myTransRatio = transRatio; myRotRatio = rotRatio; myThrottleRatio = throttleRatio; myLatRatio = latRatio; <API key>(); // SEEKUR mySentRecenter = false; if (myPrinting) printf("cmd %.0f %.0f %.0f %.0f\n", transRatio, rotRatio, throttleRatio, latRatio); if (myTransRatio < -0.1) <API key>.invoke(); //myRatioAction.setRatios(transRatio, rotRatio, throttleRatio); } AREXPORT void <API key>::serverRatioDrive(ArServerClient *client, ArNetPacket *packet) { double transRatio = packet->bufToDouble(); double rotRatio = packet->bufToDouble(); double throttleRatio = packet->bufToDouble(); double lateralRatio = packet->bufToDouble(); myGotServerCommand = true; if (!myDriveSafely && !client->hasGroupAccess("UnsafeMovement")) <API key>(); myRobot->lock(); // Activate if necessary. Note that this is done before the ratioDrive // call because we want the new ratio values to be applied after the // default ones. if (!isActive()) { activate(); } /* ArLog::log(ArLog::Normal, "RatioDrive trans %.0f rot %.0f lat %.0f ratio %.0f", transRatio, rotRatio, lateralRatio, throttleRatio); */ ratioDrive(transRatio, rotRatio, throttleRatio, false, lateralRatio); myRobot->unlock(); } AREXPORT void <API key>::serverSetSafeDrive( ArServerClient *client, ArNetPacket *packet) { if (packet->bufToUByte() == 0) setSafeDriving(false); else setSafeDriving(true); } AREXPORT void <API key>::serverGetSafeDrive( ArServerClient *client, ArNetPacket *packet) { ArNetPacket sendPacket; if (getSafeDriving()) sendPacket.uByteToBuf(1); else sendPacket.uByteToBuf(0); client->sendPacketTcp(&sendPacket); } AREXPORT void <API key>::joyUserTask(void) { // if we're not active but we should be if (<API key> && !isActive() && ((<API key> && myJoyHandler->haveJoystick() && myJoyHandler->getButton(1)) || (myUseRobotJoystick && myRobotJoyHandler->gotData() && myRobotJoyHandler->getButton1()))) { if (ArServerMode::getActiveMode() != NULL) ArLog::log(ArLog::Normal, "%s: Activating instead of %s because of local joystick", ArServerMode::getActiveMode()->getName(), myName.c_str()); else ArLog::log(ArLog::Normal, "%s: Activating because of local joystick", myName.c_str()); // if we're locked and are overriding that lock for the robot // joystick and it was the robot joystick that caused it to happen if (myUseRobotJoystick && myRobotJoyHandler->gotData() && myRobotJoyHandler->getButton1() && <API key> && ArServerMode::ourActiveModeLocked) { ArLog::log(ArLog::Terse, "Robot joystick is overriding locked mode %s", ourActiveMode->getName()); ourActiveMode->forceUnlock(); myRobot->enableMotors(); } activate(); } bool unsafeRobotDrive; if (myUseRobotJoystick && myRobotJoyHandler->gotData() && ((unsafeRobotDrive = (bool)(myRobot->getFaultFlags() & ArUtil::BIT15)) != !<API key>)) { <API key> = !unsafeRobotDrive; setSafeDriving(<API key>, true); } } AREXPORT void <API key>::userTask(void) { // Sets the robot so that we always think we're trying to move in // this mode myRobot->forceTryingToMove(); // if the joystick is pushed then set that we're active, server // commands'll go into ratioDrive and set it there too if ((<API key> && myJoyHandler->haveJoystick() && myJoyHandler->getButton(1)) || (myUseRobotJoystick && myRobotJoyHandler->gotData() && myRobotJoyHandler->getButton1()) || (myUseServerCommands && myGotServerCommand)) { <API key>(); } myGotServerCommand = false; bool timedOut = false; // if we're moving, and there is a timeout, and the activity time is // greater than the timeout, then stop the robot if ((fabs(myRobot->getVel()) > 0 || fabs(myRobot->getRotVel()) > 0 || fabs(myRobot->getLatVel()) > 0) && myTimeout > .0000001 && getActivityTime().mSecSince()/1000.0 >= myTimeout) { if (!myLastTimedOut) { ArLog::log(ArLog::Normal, "Stopping the robot since teleop timed out"); myRobot->stop(); myRobot->clearDirectMotion(); ratioDrive(0, 0, 0, 0); } timedOut = true; } myLastTimedOut = timedOut; // SEEKUR (needed for prototype versions) /* if (myRobot->hasLatVel() && !mySentRecenter && getActivityTime().secSince() >= 10) { mySentRecenter = true; myRobot->com(120); } */ if (!<API key>) { if (myRobot->isLeftMotorStalled() || myRobot->isRightMotorStalled()) myStatus = "Stalled"; // this works because if the motors stalled above caught it, if // not and more values it means a stall else if (myRobot->getStallValue()) myStatus = "Bumped"; else if (ArMath::fabs(myRobot->getVel()) < 2 && ArMath::fabs(myRobot->getRotVel()) < 2 && (!myRobot->hasLatVel() || ArMath::fabs(myRobot->getLatVel()) < 2)) myStatus = "Stopped"; else myStatus = "Driving"; } <API key> = false; } // end method userTask AREXPORT void <API key>::ratioFireCallback(void) { if (myPrinting) ArLog::log(ArLog::Normal, "<API key>: TransRatio=%.0f RotRatio=%.0f ThrottleRatio=%.0f LatRatio=%.0f", myTransRatio, myRotRatio, myThrottleRatio, myLatRatio); myRatioAction->setRatios(myTransRatio, myRotRatio, myThrottleRatio, myLatRatio); } AREXPORT void <API key>::<API key>( bool <API key>, bool internal) { if (!internal) myRobot->lock(); // if this is a change then print it if (<API key> != <API key>) { if (<API key>) { ArLog::log(ArLog::Normal, "%s: Using location dependent range devices", myName.c_str()); } else { ArLog::log(ArLog::Normal, "%s: Not using location dependent range devices", myName.c_str()); } <API key> = <API key>; myLimiterForward-><API key>( <API key>); myLimiterBackward-><API key>( <API key>); if (<API key> != NULL) <API key>-><API key>( <API key>); if (<API key> != NULL) <API key>-><API key>( <API key>); } if (!internal) myRobot->unlock(); } AREXPORT bool <API key>::<API key>(void) { return <API key>; }
package com.networkprofiles.widget; /** Service to refresh the widget **/ import android.app.Service; import android.appwidget.AppWidgetManager; import android.content.Intent; import android.graphics.Color; import android.os.IBinder; import android.provider.Settings; import android.widget.RemoteViews; import com.networkprofiles.R; import com.networkprofiles.utils.MyNetControll; public class NPWidgetService extends Service { private Boolean mobile; private Boolean cell; private Boolean gps; private Boolean display; private Boolean sound; private int [] widgetIds; private RemoteViews rv; private AppWidgetManager wm; private MyNetControll myController; public void onCreate() { wm = AppWidgetManager.getInstance(NPWidgetService.this);//this.<API key>() myController = new MyNetControll(NPWidgetService.this); myController.myStart(); //rv = new RemoteViews(getPackageName(), R.layout.npwidgetwifi); } public int onStartCommand(Intent intent, int flags, int startId) { // /** Check the state of the network devices and set the text for the text fields **/ // //set the TextView for 3G data // if(telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED || telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTING) { // rv.setTextViewText(R.id.textMobile, "3G data is ON"); // if(telephonyManager.getDataState() == TelephonyManager.DATA_DISCONNECTED) { // rv.setTextViewText(R.id.textMobile, "3G data is OFF"); // //set the TextView for WiFi // if(wifim.getWifiState() == WifiManager.WIFI_STATE_ENABLED || wifim.getWifiState() == WifiManager.WIFI_STATE_ENABLING) { // rv.setTextViewText(R.id.textWifi, "Wifi is ON"); // if(wifim.getWifiState() == WifiManager.WIFI_STATE_DISABLED || wifim.getWifiState() == WifiManager.<API key>) { // rv.setTextViewText(R.id.textWifi, "Wifi is OFF"); // //set the TextView for Bluetooth // if(myBluetooth.getState() == BluetoothAdapter.STATE_ON || myBluetooth.getState() == BluetoothAdapter.STATE_TURNING_ON) { // rv.setTextViewText(R.id.textBluetooth, "Bluetooth is ON"); // if(myBluetooth.getState() == BluetoothAdapter.STATE_OFF || myBluetooth.getState() == BluetoothAdapter.STATE_TURNING_OFF) { // rv.setTextViewText(R.id.textBluetooth, "Bluetooth is Off"); // //set the TextView for Cell voice // if(Settings.System.getInt(NPWidgetService.this.getContentResolver(), // Settings.System.AIRPLANE_MODE_ON, 0) == 0) { // rv.setTextViewText(R.id.textCell, "Cell is ON"); // } else { // rv.setTextViewText(R.id.textCell, "Cell is OFF"); // //set the TextView for GPS // locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.<API key>); // if(locationProviders.contains("gps")) { // rv.setTextViewText(R.id.textGps, "GPS is ON"); // } else { // rv.setTextViewText(R.id.textGps, "GPS is OFF"); /** Check which textView was clicked and switch the state of the corresponding device **/ widgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); mobile = intent.getBooleanExtra("mobile", false); cell = intent.getBooleanExtra("cell", false); gps = intent.getBooleanExtra("gps", false); display = intent.getBooleanExtra("display", false); sound = intent.getBooleanExtra("sound", false); if(widgetIds.length > 0) { if(mobile) { rv = new RemoteViews(getPackageName(), R.layout.npwidgetmobiledata); rv.setTextColor(R.id.<API key>, Color.GREEN); updateWidgets(); rv.setTextColor(R.id.<API key>, Color.WHITE); myController.mobileOnOff(); } if(cell) { rv = new RemoteViews(getPackageName(), R.layout.npwidgetcell); rv.setTextColor(R.id.textWidgetCell, Color.GREEN); if(Settings.System.getInt(NPWidgetService.this.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 0) { myController.cellOff(); } else { myController.cellOn(); } if(Settings.System.getInt(NPWidgetService.this.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 0) { rv.setTextViewText(R.id.textWidgetCell, "Cell ON"); } else { rv.setTextViewText(R.id.textWidgetCell, "Cell OFF"); } updateWidgets(); rv.setTextColor(R.id.textWidgetCell, Color.WHITE); } if(gps) { rv = new RemoteViews(getPackageName(), R.layout.npwidgetgps); rv.setTextColor(R.id.textWidgetGps, Color.GREEN); updateWidgets(); rv.setTextColor(R.id.textWidgetGps, Color.WHITE); myController.gpsOnOff(); } if(display) { rv = new RemoteViews(getPackageName(), R.layout.npwidgetdisplay); rv.setTextColor(R.id.textWidgetDisplay, Color.GREEN); updateWidgets(); rv.setTextColor(R.id.textWidgetDisplay, Color.WHITE); myController.displayOnOff(); } if(sound) { rv = new RemoteViews(getPackageName(), R.layout.npwidgetsound); rv.setTextColor(R.id.textViewWidgetSound, Color.GREEN); updateWidgets(); rv.setTextColor(R.id.textViewWidgetSound, Color.WHITE); myController.soundSettings(); } } updateWidgets(); stopSelf(); return 1; } public void onStart(Intent intent, int startId) { } public IBinder onBind(Intent arg0) { return null; } private void updateWidgets() { for(int id : widgetIds) { wm.updateAppWidget(id, rv); } } }//close class NPWidgetService
#!/usr/bin/env python3 # This program or module is free software: you can redistribute it and/or # provided for educational purposes and is distributed in the hope that """Provides the Item example classes. """ class Item(object): def __init__(self, artist, title, year=None): self.__artist = artist self.__title = title self.__year = year def artist(self): return self.__artist def setArtist(self, artist): self.__artist = artist def title(self): return self.__title def setTitle(self, title): self.__title = title def year(self): return self.__year def setYear(self, year): self.__year = year def __str__(self): year = "" if self.__year is not None: year = " in {0}".format(self.__year) return "{0} by {1}{2}".format(self.__title, self.__artist, year) class Painting(Item): def __init__(self, artist, title, year=None): super(Painting, self).__init__(artist, title, year) class Sculpture(Item): def __init__(self, artist, title, year=None, material=None): super(Sculpture, self).__init__(artist, title, year) self.__material = material def material(self): return self.__material def setMaterial(self, material): self.__material = material def __str__(self): materialString = "" if self.__material is not None: materialString = " ({0})".format(self.__material) return "{0}{1}".format(super(Sculpture, self).__str__(), materialString) class Dimension(object): def __init__(self, width, height, depth=None): self.__width = width self.__height = height self.__depth = depth def width(self): return self.__width def setWidth(self, width): self.__width = width def height(self): return self.__height def setHeight(self, height): self.__height = height def depth(self): return self.__depth def setDepth(self, depth): self.__depth = depth def area(self): raise NotImplemented def volume(self): raise NotImplemented if __name__ == "__main__": items = [] items.append(Painting("Cecil Collins", "The Poet", 1941)) items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943)) items.append(Painting("Edvard Munch", "The Scream", 1893)) items.append(Painting("Edvard Munch", "The Sick Child", 1896)) items.append(Painting("Edvard Munch", "The Dance of Life", 1900)) items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917, "plaster")) items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917, "plaster")) items.append(Sculpture("Auguste Rodin", "The Secret", 1925, "bronze")) uniquematerials = set() for item in items: print(item) if hasattr(item, "material"): uniquematerials.add(item.material()) print("Sculptures use {0} unique materials".format( len(uniquematerials)))
<?php /** * The template for displaying all posts having layout like: sidebar/content/sidebar. * * @package Sage Theme */ ?> <?php get_sidebar('second'); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'single' ); ?> <?php // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || get_comments_number() ) : comments_template(); endif; ?> <?php endwhile; // end of the loop. ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); ?>
#define _FILE_OFFSET_BITS 64 #include <algorithm> #include <cctype> #include <cerrno> #include <climits> #include <cstdio> #include <cstdlib> #include <ctime> #include <string> #include <vector> #include <stdint.h> #include <termios.h> #include <unistd.h> #include "block.h" #include "mapbook.h" namespace { void input_pos_error( const long long pos, const long long insize ) { char buf[128]; snprintf( buf, sizeof buf, "Can't start reading at pos %s.\n" " Input file is only %s bytes long.", format_num3( pos ), format_num3( insize ) ); show_error( buf ); } } // end namespace bool Mapbook::save_mapfile( const char * const name ) { std::remove( name ); FILE * const f = std::fopen( name, "w" ); if( f && write_mapfile( f, true, true ) && std::fclose( f ) == 0 ) { char buf[80]; snprintf( buf, sizeof buf, "Mapfile saved in '%s'\n", name ); final_msg( buf ); return true; } return false; } bool Mapbook::emergency_save() { static bool first_time = true; static std::string home_name; const std::string dead_name( "ddrescue.map" ); if( filename() != dead_name && save_mapfile( dead_name.c_str() ) ) return true; if( first_time ) { first_time = false; const char * const p = std::getenv( "HOME" ); if( p ) { home_name = p; home_name += '/'; home_name += dead_name; } } if( home_name.size() && filename() != home_name && save_mapfile( home_name.c_str() ) ) return true; show_error( "Emergency save failed." ); return false; } Mapbook::Mapbook( const long long offset, const long long insize, Domain & dom, const Mb_options & mb_opts, const char * const mapname, const int cluster, const int hardbs, const bool complete_only, const bool rescue ) : Mapfile( mapname ), Mb_options( mb_opts ), offset_( offset ), mapfile_insize_( 0 ), domain_( dom ), hardbs_( hardbs ), softbs_( cluster * hardbs_ ), iobuf_size_( softbs_ + hardbs_ ), // +hardbs for direct unaligned reads final_errno_( 0 ), um_t1( 0 ), um_t1s( 0 ), um_prev_mf_sync( false ), mapfile_exists_( false ) { long alignment = sysconf( _SC_PAGESIZE ); if( alignment < hardbs_ || alignment % hardbs_ ) alignment = hardbs_; if( alignment < 2 ) alignment = 0; iobuf_ = iobuf_base = new uint8_t[ alignment + iobuf_size_ + hardbs_ ]; if( alignment > 1 ) // align iobuf for direct disc access { const int disp = alignment - ( reinterpret_cast<unsigned long long> (iobuf_) % alignment ); if( disp > 0 && disp < alignment ) iobuf_ += disp; } if( insize > 0 ) { if( domain_.pos() >= insize ) { input_pos_error( domain_.pos(), insize ); std::exit( 1 ); } domain_.crop_by_file_size( insize ); } if( filename() ) { mapfile_exists_ = read_mapfile( 0, false ); if( mapfile_exists_ ) mapfile_insize_ = extent().end(); } if( !complete_only ) <API key>( insize ); else domain_.crop( extent() ); // limit domain to blocks read from mapfile <API key>(); if( rescue ) join_subsectors( hardbs_ ); <API key>( domain_ ); if( sblocks() == 0 ) domain_.clear(); } // Writes periodically the mapfile to disc. // Returns false only if update is attempted and fails. bool Mapbook::update_mapfile( const int odes, const bool force ) { if( !filename() ) return true; const int interval = ( <API key> >= 0 ) ? <API key> : 30 + std::min( 270L, sblocks() / 38 ); // auto, 30s to 5m const long t2 = std::time( 0 ); if( um_t1 == 0 || um_t1 > t2 ) um_t1 = um_t1s = t2; // initialize if( !force && t2 - um_t1 < interval ) return true; const bool mf_sync = ( force || t2 - um_t1s >= <API key> ); if( odes >= 0 ) fsync( odes ); if( um_prev_mf_sync ) { std::string mapname_bak( filename() ); mapname_bak += ".bak"; std::remove( mapname_bak.c_str() ); // break possible hard link std::rename( filename(), mapname_bak.c_str() ); } um_prev_mf_sync = mf_sync; while( true ) { errno = 0; if( write_mapfile( 0, true, mf_sync ) ) // update times here to exclude writing time from intervals { um_t1 = std::time( 0 ); if( mf_sync ) um_t1s = um_t1; return true; } if( verbosity < 0 ) return false; const int saved_errno = errno; std::fputc( '\n', stderr ); char buf[80]; snprintf( buf, sizeof buf, "Error writing mapfile '%s'", filename() ); show_error( buf, saved_errno ); std::fputs( "Fix the problem and press ENTER to retry,\n" " or E+ENTER for an emergency save and exit,\n" " or Q+ENTER to abort.\n", stderr ); std::fflush( stderr ); while( true ) { tcflush( STDIN_FILENO, TCIFLUSH ); const int c = std::tolower( std::fgetc( stdin ) ); int tmp = c; while( tmp != '\n' && tmp != EOF ) tmp = std::fgetc( stdin ); if( c == '\r' || c == '\n' || c == 'e' || c == 'q' ) { if( c == 'q' || ( c == 'e' && emergency_save() ) ) { if( !force ) std::fputs( "\n\n\n\n", stdout ); return false; } break; } } } }
#include "../include/config.h" #include "csum.hh" CLICK_DECLS /* Returns the IP checksum of the 'n' bytes in 'data'. */ uint16_t csum(const void *data, size_t n) { return csum_finish(csum_continue(0, data, n)); } /* Adds the 16 bits in 'new' to the partial IP checksum 'partial' and returns * the updated checksum. (To start a new checksum, pass 0 for 'partial'. To * obtain the finished checksum, pass the return value to csum_finish().) */ uint32_t csum_add16(uint32_t partial, uint16_t New) { return partial + New; } /* Adds the 32 bits in 'new' to the partial IP checksum 'partial' and returns * the updated checksum. (To start a new checksum, pass 0 for 'partial'. To * obtain the finished checksum, pass the return value to csum_finish().) */ uint32_t csum_add32(uint32_t partial, uint32_t New) { return partial + (New >> 16) + (New & 0xffff); } /* Adds the 'n' bytes in 'data' to the partial IP checksum 'partial' and * returns the updated checksum. (To start a new checksum, pass 0 for * 'partial'. To obtain the finished checksum, pass the return value to * csum_finish().) */ uint32_t csum_continue(uint32_t partial, const void *data_, size_t n) { const uint16_t *data = (const uint16_t*)data_; for (; n > 1; n -= 2) { partial = csum_add16(partial, *data++); } if (n) { partial += *(uint8_t *) data; } return partial; } /* Returns the IP checksum corresponding to 'partial', which is a value updated * by some combination of csum_add16(), csum_add32(), and csum_continue(). */ uint16_t csum_finish(uint32_t partial) { return ~((partial & 0xffff) + (partial >> 16)); } /* Returns the new checksum for a packet in which the checksum field previously * contained 'old_csum' and in which a field that contained 'old_u16' was * changed to contain 'new_u16'. */ uint16_t recalc_csum16(uint16_t old_csum, uint16_t old_u16, uint16_t new_u16) { /* Ones-complement arithmetic is endian-independent, so this code does not * use htons() or ntohs(). * * See RFC 1624 for formula and explanation. */ uint16_t hc_complement = ~old_csum; uint16_t m_complement = ~old_u16; uint16_t m_prime = new_u16; uint32_t sum = hc_complement + m_complement + m_prime; uint16_t hc_prime_complement = sum + (sum >> 16); return ~hc_prime_complement; } /* Returns the new checksum for a packet in which the checksum field previously * contained 'old_csum' and in which a field that contained 'old_u32' was * changed to contain 'new_u32'. */ uint16_t recalc_csum32(uint16_t old_csum, uint32_t old_u32, uint32_t new_u32) { return recalc_csum16(recalc_csum16(old_csum, old_u32, new_u32), old_u32 >> 16, new_u32 >> 16); } CLICK_ENDDECLS ELEMENT_PROVIDES(Of_Csum)
#!/usr/bin/env python # -*- coding:utf-8 -*- from django import forms from app01 import models class ImportFrom(forms.Form): HOST_TYPE=((1,"001"),(2,"002")) host_type = forms.IntegerField( widget=forms.Select(choices=HOST_TYPE) ) hostname = forms.CharField() def __init__(self,*args,**kwargs): super(ImportFrom,self).__init__(*args,**kwargs) HOST_TYPE=((1,"001"),(2,"002")) self.fields['host_type'].widget.choices = models.userInfo.objects.all().values_list("id","name") models.userInfo.objects.get() models.userInfo.objects.filter()
package net.<API key>.path.launcher; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class FileStoreUtils { private String version; public FileStoreUtils(String versionFile) throws IOException{ BufferedReader br = new BufferedReader(new FileReader(new File(getDataFilePath(versionFile)))); version = br.readLine(); br.close(); } public String getVersionedFile(String filename, String type){ return String.format("%s-%s.%s", filename, version, type); } public boolean fileNeedsUpdating(String filename, String type) { return(new File(getVersionedFile(filename, type)).exists()); } public String <API key>(String filename, String type){ return getDataFilePath(getVersionedFile(filename, type)); } public static String getDataFolderPath(){ String os = System.getProperty("os.name").toLowerCase(); boolean windows = os.contains("windows"); boolean mac = os.contains("macosx"); if(windows){ return System.getenv("APPDATA") + "\\MRTPath2"; }else{ String home = System.getProperty("user.home"); if(mac){ return home + "/Library/Application Support/MRTPath2"; }else{ // Linux return home + "/.mrtpath2"; } } } public static String getDataFilePath(String file){ return getDataFolderPath() + File.separator + file.replace('/', File.separatorChar); } }
#include "livestatus/endpointstable.hpp" #include "icinga/host.hpp" #include "icinga/service.hpp" #include "icinga/icingaapplication.hpp" #include "remote/endpoint.hpp" #include "remote/zone.hpp" #include "base/configtype.hpp" #include "base/objectlock.hpp" #include "base/convert.hpp" #include "base/utility.hpp" #include <boost/algorithm/string/classification.hpp> #include <boost/tuple/tuple.hpp> #include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/split.hpp> using namespace icinga; EndpointsTable::EndpointsTable(void) { AddColumns(this); } void EndpointsTable::AddColumns(Table *table, const String& prefix, const Column::ObjectAccessor& objectAccessor) { table->AddColumn(prefix + "name", Column(&EndpointsTable::NameAccessor, objectAccessor)); table->AddColumn(prefix + "identity", Column(&EndpointsTable::IdentityAccessor, objectAccessor)); table->AddColumn(prefix + "node", Column(&EndpointsTable::NodeAccessor, objectAccessor)); table->AddColumn(prefix + "is_connected", Column(&EndpointsTable::IsConnectedAccessor, objectAccessor)); table->AddColumn(prefix + "zone", Column(&EndpointsTable::ZoneAccessor, objectAccessor)); } String EndpointsTable::GetName(void) const { return "endpoints"; } String EndpointsTable::GetPrefix(void) const { return "endpoint"; } void EndpointsTable::FetchRows(const AddRowFunction& addRowFn) { for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType<Endpoint>()) { if (!addRowFn(endpoint, <API key>, Empty)) return; } } Value EndpointsTable::NameAccessor(const Value& row) { Endpoint::Ptr endpoint = static_cast<Endpoint::Ptr>(row); if (!endpoint) return Empty; return endpoint->GetName(); } Value EndpointsTable::IdentityAccessor(const Value& row) { Endpoint::Ptr endpoint = static_cast<Endpoint::Ptr>(row); if (!endpoint) return Empty; return endpoint->GetName(); } Value EndpointsTable::NodeAccessor(const Value& row) { Endpoint::Ptr endpoint = static_cast<Endpoint::Ptr>(row); if (!endpoint) return Empty; return IcingaApplication::GetInstance()->GetNodeName(); } Value EndpointsTable::IsConnectedAccessor(const Value& row) { Endpoint::Ptr endpoint = static_cast<Endpoint::Ptr>(row); if (!endpoint) return Empty; unsigned int is_connected = endpoint->GetConnected() ? 1 : 0; /* if identity is equal to node, fake is_connected */ if (endpoint->GetName() == IcingaApplication::GetInstance()->GetNodeName()) is_connected = 1; return is_connected; } Value EndpointsTable::ZoneAccessor(const Value& row) { Endpoint::Ptr endpoint = static_cast<Endpoint::Ptr>(row); if (!endpoint) return Empty; Zone::Ptr zone = endpoint->GetZone(); if (!zone) return Empty; return zone->GetName(); }
<?php /** * @file * Banana class. */ namespace Drupal\oop_example_12\BusinessLogic\Fruit; /** * Banana class. */ class Banana extends Fruit { /** * Returns color of the object. */ public function getColor() { return t('yellow'); } }
#ifndef <API key> #define <API key> #include <mach/picoxcell_soc.h> #endif
#include "logging.hpp" #include <fstream> #include <boost/log/sinks/text_file_backend.hpp> #include <boost/log/utility/setup/file.hpp> #include <boost/log/utility/setup/common_attributes.hpp> #include <boost/log/sinks.hpp> namespace p2l { namespace common { void _init_logging() { boost::log::<API key>(); boost::log::core::get()->set_filter ( boost::log::trivial::severity >= boost::log::trivial::trace ); typedef boost::log::sinks::synchronous_sink< boost::log::sinks::<API key> > text_sink; // the file sink for hte default logger boost::shared_ptr< text_sink > default_sink = boost::make_shared< text_sink >(); default_sink->locked_backend()->add_stream ( boost::make_shared< std::ofstream >( "default_log.log" ) ); boost::log::core::get()->add_sink( default_sink ); // the file sink for hte stat logger boost::shared_ptr< text_sink > stat_sink = boost::make_shared< text_sink >(); stat_sink->locked_backend()->add_stream ( boost::make_shared< std::ofstream >( "stat_log.log" ) ); boost::log::core::get()->add_sink( stat_sink ); } } }
package org.hibernate.dialect.unique; import org.hibernate.boot.Metadata; import org.hibernate.dialect.Dialect; import org.hibernate.mapping.UniqueKey; /** * Informix requires the constraint name to come last on the alter table. * * @author Brett Meyer */ public class <API key> extends <API key> { public <API key>( Dialect dialect ) { super( dialect ); } // legacy model ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @Override public String <API key>(UniqueKey uniqueKey, Metadata metadata) { // Do this here, rather than allowing UniqueKey/Constraint to do it. // We need full, simplified control over whether or not it happens. final String tableName = metadata.getDatabase().getJdbcEnvironment().<API key>().format( uniqueKey.getTable().<API key>(), metadata.getDatabase().getJdbcEnvironment().getDialect() ); final String constraintName = dialect.quote( uniqueKey.getName() ); return dialect.getAlterTableString( tableName ) + " add constraint " + uniqueConstraintSql( uniqueKey ) + " constraint " + constraintName; } }
/** * DOC: Wireless regulatory infrastructure * * The usual implementation is for a driver to read a device EEPROM to * determine which regulatory domain it should be operating under, then * looking up the allowable channels in a driver-local table and finally * registering those channels in the wiphy structure. * * Another set of compliance enforcement is for drivers to use their * own compliance limits which can be stored on the EEPROM. The host * driver or firmware may ensure these are used. * * In addition to all this we provide an extra layer of regulatory * conformance. For drivers which do not have any regulatory * information CRDA provides the complete regulatory solution. * For others it provides a community effort on further restrictions * to enhance compliance. * * Note: When number of rules --> infinity we will not be able to * index on alpha2 any more, instead we'll probably have to * rely on some SHA1 checksum of the regdomain for example. * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/kernel.h> #include <linux/slab.h> #include <linux/list.h> #include <linux/random.h> #include <linux/ctype.h> #include <linux/nl80211.h> #include <linux/platform_device.h> #include <net/cfg80211.h> #include "core.h" #include "reg.h" #include "regdb.h" #include "nl80211.h" #ifdef <API key> #define REG_DBG_PRINT(format, args...) \ do { \ printk(KERN_DEBUG pr_fmt(format), ##args); \ } while (0) #else #define REG_DBG_PRINT(args...) #endif /* Receipt of information from last regulatory request */ static struct regulatory_request *last_request; /* To trigger userspace events */ static struct platform_device *reg_pdev; static struct device_type reg_device_type = { .uevent = reg_device_uevent, }; /* * Central wireless core regulatory domains, we only need two, * the current one and a world regulatory domain in case we have no * information to give us an alpha2 */ const struct ieee80211_regdomain *cfg80211_regdomain; /* * Protects static reg.c components: * - <API key> * - cfg80211_regdom * - last_request */ static DEFINE_MUTEX(reg_mutex); static inline void assert_reg_lock(void) { lockdep_assert_held(&reg_mutex); } /* Used to queue up regulatory hints */ static LIST_HEAD(reg_requests_list); static spinlock_t reg_requests_lock; /* Used to queue up beacon hints for review */ static LIST_HEAD(reg_pending_beacons); static spinlock_t <API key>; /* Used to keep track of processed beacon hints */ static LIST_HEAD(reg_beacon_list); struct reg_beacon { struct list_head list; struct ieee80211_channel chan; }; static void reg_todo(struct work_struct *work); static DECLARE_WORK(reg_work, reg_todo); static void reg_timeout_work(struct work_struct *work); static <API key>(reg_timeout, reg_timeout_work); /* We keep a static world regulatory domain in case of the absence of CRDA */ static const struct ieee80211_regdomain world_regdom = { .n_reg_rules = 5, .alpha2 = "00", .reg_rules = { /* IEEE 802.11b/g, channels 1..11 */ REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), /* IEEE 802.11b/g, channels 12..13. No HT40 * channel fits here. */ REG_RULE(2467-10, 2472+10, 20, 6, 20, <API key> | NL80211_RRF_NO_IBSS), /* IEEE 802.11 channel 14 - Only JP enables * this and for 802.11b only */ REG_RULE(2484-10, 2484+10, 20, 6, 20, <API key> | NL80211_RRF_NO_IBSS | NL80211_RRF_NO_OFDM), /* IEEE 802.11a, channel 36..48 */ REG_RULE(5180-10, 5240+10, 40, 6, 20, <API key> | NL80211_RRF_NO_IBSS), /* NB: 5260 MHz - 5700 MHz requies DFS */ /* IEEE 802.11a, channel 149..165 */ REG_RULE(5745-10, 5825+10, 40, 6, 20, <API key> | NL80211_RRF_NO_IBSS), } }; static const struct ieee80211_regdomain *<API key> = &world_regdom; static char *ieee80211_regdom = "00"; static char user_alpha2[2]; module_param(ieee80211_regdom, charp, 0444); MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); static void reset_regdomains(void) { /* avoid freeing static information or freeing something twice */ if (cfg80211_regdomain == <API key>) cfg80211_regdomain = NULL; if (<API key> == &world_regdom) <API key> = NULL; if (cfg80211_regdomain == &world_regdom) cfg80211_regdomain = NULL; kfree(cfg80211_regdomain); kfree(<API key>); <API key> = &world_regdom; cfg80211_regdomain = NULL; } /* * Dynamic world regulatory domain requested by the wireless * core upon initialization */ static void <API key>(const struct ieee80211_regdomain *rd) { BUG_ON(!last_request); reset_regdomains(); <API key> = rd; cfg80211_regdomain = rd; } bool is_world_regdom(const char *alpha2) { if (!alpha2) return false; if (alpha2[0] == '0' && alpha2[1] == '0') return true; return false; } static bool is_alpha2_set(const char *alpha2) { if (!alpha2) return false; if (alpha2[0] != 0 && alpha2[1] != 0) return true; return false; } static bool is_unknown_alpha2(const char *alpha2) { if (!alpha2) return false; /* * Special case where regulatory domain was built by driver * but a specific alpha2 cannot be determined */ if (alpha2[0] == '9' && alpha2[1] == '9') return true; return false; } static bool <API key>(const char *alpha2) { if (!alpha2) return false; /* * Special case where regulatory domain is the * result of an intersection between two regulatory domain * structures */ if (alpha2[0] == '9' && alpha2[1] == '8') return true; return false; } static bool is_an_alpha2(const char *alpha2) { if (!alpha2) return false; if (isalpha(alpha2[0]) && isalpha(alpha2[1])) return true; return false; } static bool alpha2_equal(const char *alpha2_x, const char *alpha2_y) { if (!alpha2_x || !alpha2_y) return false; if (alpha2_x[0] == alpha2_y[0] && alpha2_x[1] == alpha2_y[1]) return true; return false; } static bool regdom_changes(const char *alpha2) { <API key>(); if (!cfg80211_regdomain) return true; if (alpha2_equal(cfg80211_regdomain->alpha2, alpha2)) return false; return true; } /* * The <API key> regdom alpha2 is cached, this lets * you know if a valid regulatory hint with <API key> * has ever been issued. */ static bool <API key>(void) { if (user_alpha2[0] == '9' && user_alpha2[1] == '7') return false; /* This would indicate a mistake on the design */ if (WARN((!is_world_regdom(user_alpha2) && !is_an_alpha2(user_alpha2)), "Unexpected user alpha2: %c%c\n", user_alpha2[0], user_alpha2[1])) return false; return true; } static int reg_copy_regd(const struct ieee80211_regdomain **dst_regd, const struct ieee80211_regdomain *src_regd) { struct ieee80211_regdomain *regd; int size_of_regd = 0; unsigned int i; size_of_regd = sizeof(struct ieee80211_regdomain) + ((src_regd->n_reg_rules + 1) * sizeof(struct ieee80211_reg_rule)); regd = kzalloc(size_of_regd, GFP_KERNEL); if (!regd) return -ENOMEM; memcpy(regd, src_regd, sizeof(struct ieee80211_regdomain)); for (i = 0; i < src_regd->n_reg_rules; i++) memcpy(&regd->reg_rules[i], &src_regd->reg_rules[i], sizeof(struct ieee80211_reg_rule)); *dst_regd = regd; return 0; } #ifdef <API key> struct <API key> { char alpha2[2]; struct list_head list; }; static LIST_HEAD(<API key>); static DEFINE_MUTEX(<API key>); static void reg_regdb_search(struct work_struct *work) { struct <API key> *request; const struct ieee80211_regdomain *curdom, *regdom; int i, r; mutex_lock(&<API key>); while (!list_empty(&<API key>)) { request = list_first_entry(&<API key>, struct <API key>, list); list_del(&request->list); for (i=0; i<reg_regdb_size; i++) { curdom = reg_regdb[i]; if (!memcmp(request->alpha2, curdom->alpha2, 2)) { r = reg_copy_regd(&regdom, curdom); if (r) break; mutex_lock(&cfg80211_mutex); set_regdom(regdom); mutex_unlock(&cfg80211_mutex); break; } } kfree(request); } mutex_unlock(&<API key>); } static DECLARE_WORK(reg_regdb_work, reg_regdb_search); static void reg_regdb_query(const char *alpha2) { struct <API key> *request; if (!alpha2) return; request = kzalloc(sizeof(struct <API key>), GFP_KERNEL); if (!request) return; memcpy(request->alpha2, alpha2, 2); mutex_lock(&<API key>); list_add_tail(&request->list, &<API key>); mutex_unlock(&<API key>); schedule_work(&reg_regdb_work); } #else static inline void reg_regdb_query(const char *alpha2) {} #endif /* <API key> */ /* * This lets us keep regulatory code which is updated on a regulatory * basis in userspace. Country information is filled in by * reg_device_uevent */ static int call_crda(const char *alpha2) { if (!is_world_regdom((char *) alpha2)) pr_info("Calling CRDA for country: %c%c\n", alpha2[0], alpha2[1]); else pr_info("Calling CRDA to update world regulatory domain\n"); /* query internal regulatory database (if it exists) */ reg_regdb_query(alpha2); return kobject_uevent(&reg_pdev->dev.kobj, KOBJ_CHANGE); } /* Used by nl80211 before kmalloc'ing our regulatory domain */ bool <API key>(const char *alpha2) { <API key>(); if (!last_request) return false; return alpha2_equal(last_request->alpha2, alpha2); } /* Sanity check on a regulatory rule */ static bool is_valid_reg_rule(const struct ieee80211_reg_rule *rule) { const struct <API key> *freq_range = &rule->freq_range; u32 freq_diff; if (freq_range->start_freq_khz <= 0 || freq_range->end_freq_khz <= 0) return false; if (freq_range->start_freq_khz > freq_range->end_freq_khz) return false; freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; if (freq_range->end_freq_khz <= freq_range->start_freq_khz || freq_range->max_bandwidth_khz > freq_diff) return false; return true; } static bool is_valid_rd(const struct ieee80211_regdomain *rd) { const struct ieee80211_reg_rule *reg_rule = NULL; unsigned int i; if (!rd->n_reg_rules) return false; if (WARN_ON(rd->n_reg_rules > <API key>)) return false; for (i = 0; i < rd->n_reg_rules; i++) { reg_rule = &rd->reg_rules[i]; if (!is_valid_reg_rule(reg_rule)) return false; } return true; } static bool reg_does_bw_fit(const struct <API key> *freq_range, u32 center_freq_khz, u32 bw_khz) { u32 start_freq_khz, end_freq_khz; start_freq_khz = center_freq_khz - (bw_khz/2); end_freq_khz = center_freq_khz + (bw_khz/2); if (start_freq_khz >= freq_range->start_freq_khz && end_freq_khz <= freq_range->end_freq_khz) return true; return false; } /** * freq_in_rule_band - tells us if a frequency is in a frequency band * @freq_range: frequency rule we want to query * @freq_khz: frequency we are inquiring about * * This lets us know if a specific frequency rule is or is not relevant to * a specific frequency's band. Bands are device specific and artificial * definitions (the "2.4 GHz band" and the "5 GHz band"), however it is * safe for now to assume that a frequency rule should not be part of a * frequency's band if the start freq or end freq are off by more than 2 GHz. * This resolution can be lowered and should be considered as we add * regulatory rule support for other "bands". **/ static bool freq_in_rule_band(const struct <API key> *freq_range, u32 freq_khz) { #define ONE_GHZ_IN_KHZ 1000000 if (abs(freq_khz - freq_range->start_freq_khz) <= (2 * ONE_GHZ_IN_KHZ)) return true; if (abs(freq_khz - freq_range->end_freq_khz) <= (2 * ONE_GHZ_IN_KHZ)) return true; return false; #undef ONE_GHZ_IN_KHZ } /* * Helper for regdom_intersect(), this does the real * mathematical intersection fun */ static int reg_rules_intersect( const struct ieee80211_reg_rule *rule1, const struct ieee80211_reg_rule *rule2, struct ieee80211_reg_rule *intersected_rule) { const struct <API key> *freq_range1, *freq_range2; struct <API key> *freq_range; const struct <API key> *power_rule1, *power_rule2; struct <API key> *power_rule; u32 freq_diff; freq_range1 = &rule1->freq_range; freq_range2 = &rule2->freq_range; freq_range = &intersected_rule->freq_range; power_rule1 = &rule1->power_rule; power_rule2 = &rule2->power_rule; power_rule = &intersected_rule->power_rule; freq_range->start_freq_khz = max(freq_range1->start_freq_khz, freq_range2->start_freq_khz); freq_range->end_freq_khz = min(freq_range1->end_freq_khz, freq_range2->end_freq_khz); freq_range->max_bandwidth_khz = min(freq_range1->max_bandwidth_khz, freq_range2->max_bandwidth_khz); freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; if (freq_range->max_bandwidth_khz > freq_diff) freq_range->max_bandwidth_khz = freq_diff; power_rule->max_eirp = min(power_rule1->max_eirp, power_rule2->max_eirp); power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain, power_rule2->max_antenna_gain); intersected_rule->flags = (rule1->flags | rule2->flags); if (!is_valid_reg_rule(intersected_rule)) return -EINVAL; return 0; } /** * regdom_intersect - do the intersection between two regulatory domains * @rd1: first regulatory domain * @rd2: second regulatory domain * * Use this function to get the intersection between two regulatory domains. * Once completed we will mark the alpha2 for the rd as intersected, "98", * as no one single alpha2 can represent this regulatory domain. * * Returns a pointer to the regulatory domain structure which will hold the * resulting intersection of rules between rd1 and rd2. We will * kzalloc() this structure for you. */ static struct ieee80211_regdomain *regdom_intersect( const struct ieee80211_regdomain *rd1, const struct ieee80211_regdomain *rd2) { int r, size_of_regd; unsigned int x, y; unsigned int num_rules = 0, rule_idx = 0; const struct ieee80211_reg_rule *rule1, *rule2; struct ieee80211_reg_rule *intersected_rule; struct ieee80211_regdomain *rd; /* This is just a dummy holder to help us count */ struct ieee80211_reg_rule irule; /* Uses the stack temporarily for counter arithmetic */ intersected_rule = &irule; memset(intersected_rule, 0, sizeof(struct ieee80211_reg_rule)); if (!rd1 || !rd2) return NULL; /* * First we get a count of the rules we'll need, then we actually * build them. This is to so we can malloc() and free() a * regdomain once. The reason we use reg_rules_intersect() here * is it will return -EINVAL if the rule computed makes no sense. * All rules that do check out OK are valid. */ for (x = 0; x < rd1->n_reg_rules; x++) { rule1 = &rd1->reg_rules[x]; for (y = 0; y < rd2->n_reg_rules; y++) { rule2 = &rd2->reg_rules[y]; if (!reg_rules_intersect(rule1, rule2, intersected_rule)) num_rules++; memset(intersected_rule, 0, sizeof(struct ieee80211_reg_rule)); } } if (!num_rules) return NULL; size_of_regd = sizeof(struct ieee80211_regdomain) + ((num_rules + 1) * sizeof(struct ieee80211_reg_rule)); rd = kzalloc(size_of_regd, GFP_KERNEL); if (!rd) return NULL; for (x = 0; x < rd1->n_reg_rules; x++) { rule1 = &rd1->reg_rules[x]; for (y = 0; y < rd2->n_reg_rules; y++) { rule2 = &rd2->reg_rules[y]; /* * This time around instead of using the stack lets * write to the target rule directly saving ourselves * a memcpy() */ intersected_rule = &rd->reg_rules[rule_idx]; r = reg_rules_intersect(rule1, rule2, intersected_rule); /* * No need to memset here the intersected rule here as * we're not using the stack anymore */ if (r) continue; rule_idx++; } } if (rule_idx != num_rules) { kfree(rd); return NULL; } rd->n_reg_rules = num_rules; rd->alpha2[0] = '9'; rd->alpha2[1] = '8'; return rd; } /* * XXX: add support for the rest of enum <API key>, we may * want to just have the channel structure use these */ static u32 map_regdom_flags(u32 rd_flags) { u32 channel_flags = 0; if (rd_flags & <API key>) channel_flags |= <API key>; if (rd_flags & NL80211_RRF_NO_IBSS) channel_flags |= <API key>; if (rd_flags & NL80211_RRF_DFS) channel_flags |= <API key>; return channel_flags; } static int freq_reg_info_regd(struct wiphy *wiphy, u32 center_freq, u32 desired_bw_khz, const struct ieee80211_reg_rule **reg_rule, const struct ieee80211_regdomain *custom_regd) { int i; bool band_rule_found = false; const struct ieee80211_regdomain *regd; bool bw_fits = false; if (!desired_bw_khz) desired_bw_khz = MHZ_TO_KHZ(20); regd = custom_regd ? custom_regd : cfg80211_regdomain; /* * Follow the driver's regulatory domain, if present, unless a country * IE has been processed or a user wants to help complaince further */ if (!custom_regd && last_request->initiator != <API key> && last_request->initiator != <API key> && wiphy->regd) regd = wiphy->regd; if (!regd) return -EINVAL; for (i = 0; i < regd->n_reg_rules; i++) { const struct ieee80211_reg_rule *rr; const struct <API key> *fr = NULL; rr = &regd->reg_rules[i]; fr = &rr->freq_range; /* * We only need to know if one frequency rule was * was in center_freq's band, that's enough, so lets * not overwrite it once found */ if (!band_rule_found) band_rule_found = freq_in_rule_band(fr, center_freq); bw_fits = reg_does_bw_fit(fr, center_freq, desired_bw_khz); if (band_rule_found && bw_fits) { *reg_rule = rr; return 0; } } if (!band_rule_found) return -ERANGE; return -EINVAL; } int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 desired_bw_khz, const struct ieee80211_reg_rule **reg_rule) { <API key>(); return freq_reg_info_regd(wiphy, center_freq, desired_bw_khz, reg_rule, NULL); } EXPORT_SYMBOL(freq_reg_info); #ifdef <API key> static const char *reg_initiator_name(enum <API key> initiator) { switch (initiator) { case <API key>: return "Set by core"; case <API key>: return "Set by user"; case <API key>: return "Set by driver"; case <API key>: return "Set by country IE"; default: WARN_ON(1); return "Set by bug"; } } static void <API key>(struct ieee80211_channel *chan, u32 desired_bw_khz, const struct ieee80211_reg_rule *reg_rule) { const struct <API key> *power_rule; const struct <API key> *freq_range; char max_antenna_gain[32]; power_rule = &reg_rule->power_rule; freq_range = &reg_rule->freq_range; if (!power_rule->max_antenna_gain) snprintf(max_antenna_gain, 32, "N/A"); else snprintf(max_antenna_gain, 32, "%d", power_rule->max_antenna_gain); REG_DBG_PRINT("Updating information on frequency %d MHz " "for a %d MHz width channel with regulatory rule:\n", chan->center_freq, KHZ_TO_MHZ(desired_bw_khz)); REG_DBG_PRINT("%d KHz - %d KHz @ KHz), (%s mBi, %d mBm)\n", freq_range->start_freq_khz, freq_range->end_freq_khz, max_antenna_gain, power_rule->max_eirp); } #else static void <API key>(struct ieee80211_channel *chan, u32 desired_bw_khz, const struct ieee80211_reg_rule *reg_rule) { return; } #endif /* * Note that right now we assume the desired channel bandwidth * is always 20 MHz for each individual channel (HT40 uses 20 MHz * per channel, the primary and the extension channel). To support * smaller custom bandwidths such as 5 MHz or 10 MHz we'll need a * new ieee80211_channel.target_bw and re run the regulatory check * on the wiphy with the target_bw specified. Then we can simply use * that below for the desired_bw_khz below. */ static void handle_channel(struct wiphy *wiphy, enum <API key> initiator, enum ieee80211_band band, unsigned int chan_idx) { int r; u32 flags, bw_flags = 0; u32 desired_bw_khz = MHZ_TO_KHZ(20); const struct ieee80211_reg_rule *reg_rule = NULL; const struct <API key> *power_rule = NULL; const struct <API key> *freq_range = NULL; struct <API key> *sband; struct ieee80211_channel *chan; struct wiphy *request_wiphy = NULL; <API key>(); request_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); sband = wiphy->bands[band]; BUG_ON(chan_idx >= sband->n_channels); chan = &sband->channels[chan_idx]; flags = chan->orig_flags; r = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq), desired_bw_khz, &reg_rule); if (r) { /* * We will disable all channels that do not match our * received regulatory rule unless the hint is coming * from a Country IE and the Country IE had no information * about a band. The IEEE 802.11 spec allows for an AP * to send only a subset of the regulatory rules allowed, * so an AP in the US that only supports 2.4 GHz may only send * a country IE with information for the 2.4 GHz band * while 5 GHz is still supported. */ if (initiator == <API key> && r == -ERANGE) return; REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq); chan->flags = <API key>; return; } <API key>(chan, desired_bw_khz, reg_rule); power_rule = &reg_rule->power_rule; freq_range = &reg_rule->freq_range; if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(40)) bw_flags = <API key>; if (last_request->initiator == <API key> && request_wiphy && request_wiphy == wiphy && request_wiphy->flags & <API key>) { /* * This guarantees the driver's requested regulatory domain * will always be used as a base for further regulatory * settings */ chan->flags = chan->orig_flags = map_regdom_flags(reg_rule->flags) | bw_flags; chan->max_antenna_gain = chan->orig_mag = (int) MBI_TO_DBI(power_rule->max_antenna_gain); chan->max_power = chan->orig_mpwr = (int) MBM_TO_DBM(power_rule->max_eirp); return; } chan->beacon_found = false; chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); chan->max_antenna_gain = min(chan->orig_mag, (int) MBI_TO_DBI(power_rule->max_antenna_gain)); if (chan->orig_mpwr) { /* * Devices that have their own custom regulatory domain * but also use <API key> will follow the * passed country IE power settings. */ if (initiator == <API key> && wiphy->flags & <API key> && wiphy->flags & <API key>) { chan->max_power = MBM_TO_DBM(power_rule->max_eirp); } else { chan->max_power = min(chan->orig_mpwr, (int) MBM_TO_DBM(power_rule->max_eirp)); } } else chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp); } static void handle_band(struct wiphy *wiphy, enum ieee80211_band band, enum <API key> initiator) { unsigned int i; struct <API key> *sband; BUG_ON(!wiphy->bands[band]); sband = wiphy->bands[band]; for (i = 0; i < sband->n_channels; i++) handle_channel(wiphy, initiator, band, i); } static bool ignore_reg_update(struct wiphy *wiphy, enum <API key> initiator) { if (!last_request) { REG_DBG_PRINT("Ignoring regulatory request %s since " "last_request is not set\n", reg_initiator_name(initiator)); return true; } if (initiator == <API key> && wiphy->flags & <API key>) { REG_DBG_PRINT("Ignoring regulatory request %s " "since the driver uses its own custom " "regulatory domain ", reg_initiator_name(initiator)); return true; } /* * wiphy->regd will be set once the device has its own * desired regulatory domain set */ if (wiphy->flags & <API key> && !wiphy->regd && initiator != <API key> && !is_world_regdom(last_request->alpha2)) { REG_DBG_PRINT("Ignoring regulatory request %s " "since the driver requires its own regulaotry " "domain to be set first", reg_initiator_name(initiator)); return true; } return false; } static void <API key>(enum <API key> initiator) { struct <API key> *rdev; struct wiphy *wiphy; list_for_each_entry(rdev, &cfg80211_rdev_list, list) { wiphy = &rdev->wiphy; <API key>(wiphy, initiator); /* * Regulatory updates set by CORE are ignored for custom * regulatory cards. Let us notify the changes to the driver, * as some drivers used this to restore its orig_* reg domain. */ if (initiator == <API key> && wiphy->flags & <API key> && wiphy->reg_notifier) wiphy->reg_notifier(wiphy, last_request); } } static void handle_reg_beacon(struct wiphy *wiphy, unsigned int chan_idx, struct reg_beacon *reg_beacon) { struct <API key> *sband; struct ieee80211_channel *chan; bool channel_changed = false; struct ieee80211_channel chan_before; <API key>(); sband = wiphy->bands[reg_beacon->chan.band]; chan = &sband->channels[chan_idx]; if (likely(chan->center_freq != reg_beacon->chan.center_freq)) return; if (chan->beacon_found) return; chan->beacon_found = true; if (wiphy->flags & <API key>) return; chan_before.center_freq = chan->center_freq; chan_before.flags = chan->flags; if (chan->flags & <API key>) { chan->flags &= ~<API key>; channel_changed = true; } if (chan->flags & <API key>) { chan->flags &= ~<API key>; channel_changed = true; } if (channel_changed) <API key>(wiphy, &chan_before, chan); } /* * Called when a scan on a wiphy finds a beacon on * new channel */ static void <API key>(struct wiphy *wiphy, struct reg_beacon *reg_beacon) { unsigned int i; struct <API key> *sband; <API key>(); if (!wiphy->bands[reg_beacon->chan.band]) return; sband = wiphy->bands[reg_beacon->chan.band]; for (i = 0; i < sband->n_channels; i++) handle_reg_beacon(wiphy, i, reg_beacon); } /* * Called upon reg changes or a new wiphy is added */ static void <API key>(struct wiphy *wiphy) { unsigned int i; struct <API key> *sband; struct reg_beacon *reg_beacon; <API key>(); if (list_empty(&reg_beacon_list)) return; list_for_each_entry(reg_beacon, &reg_beacon_list, list) { if (!wiphy->bands[reg_beacon->chan.band]) continue; sband = wiphy->bands[reg_beacon->chan.band]; for (i = 0; i < sband->n_channels; i++) handle_reg_beacon(wiphy, i, reg_beacon); } } static bool <API key>(struct wiphy *wiphy) { if (is_world_regdom(cfg80211_regdomain->alpha2) || (wiphy->regd && is_world_regdom(wiphy->regd->alpha2))) return true; if (last_request && last_request->initiator != <API key> && wiphy->flags & <API key>) return true; return false; } /* Reap the advantages of previously found beacons */ static void reg_process_beacons(struct wiphy *wiphy) { /* * Means we are just firing up cfg80211, so no beacons would * have been processed yet. */ if (!last_request) return; if (!<API key>(wiphy)) return; <API key>(wiphy); } static bool is_ht40_not_allowed(struct ieee80211_channel *chan) { if (!chan) return true; if (chan->flags & <API key>) return true; /* This would happen when regulatory rules disallow HT40 completely */ if (<API key> == (chan->flags & (<API key>))) return true; return false; } static void <API key>(struct wiphy *wiphy, enum ieee80211_band band, unsigned int chan_idx) { struct <API key> *sband; struct ieee80211_channel *channel; struct ieee80211_channel *channel_before = NULL, *channel_after = NULL; unsigned int i; <API key>(); sband = wiphy->bands[band]; BUG_ON(chan_idx >= sband->n_channels); channel = &sband->channels[chan_idx]; if (is_ht40_not_allowed(channel)) { channel->flags |= <API key>; return; } /* * We need to ensure the extension channels exist to * be able to use HT40- or HT40+, this finds them (or not) */ for (i = 0; i < sband->n_channels; i++) { struct ieee80211_channel *c = &sband->channels[i]; if (c->center_freq == (channel->center_freq - 20)) channel_before = c; if (c->center_freq == (channel->center_freq + 20)) channel_after = c; } /* * Please note that this assumes target bandwidth is 20 MHz, * if that ever changes we also need to change the below logic * to include that as well. */ if (is_ht40_not_allowed(channel_before)) channel->flags |= <API key>; else channel->flags &= ~<API key>; if (is_ht40_not_allowed(channel_after)) channel->flags |= <API key>; else channel->flags &= ~<API key>; } static void <API key>(struct wiphy *wiphy, enum ieee80211_band band) { unsigned int i; struct <API key> *sband; BUG_ON(!wiphy->bands[band]); sband = wiphy->bands[band]; for (i = 0; i < sband->n_channels; i++) <API key>(wiphy, band, i); } static void <API key>(struct wiphy *wiphy) { enum ieee80211_band band; if (!wiphy) return; for (band = 0; band < IEEE80211_NUM_BANDS; band++) { if (wiphy->bands[band]) <API key>(wiphy, band); } } void <API key>(struct wiphy *wiphy, enum <API key> initiator) { enum ieee80211_band band; if (ignore_reg_update(wiphy, initiator)) return; for (band = 0; band < IEEE80211_NUM_BANDS; band++) { if (wiphy->bands[band]) handle_band(wiphy, band, initiator); } reg_process_beacons(wiphy); <API key>(wiphy); if (wiphy->reg_notifier) wiphy->reg_notifier(wiphy, last_request); } static void <API key>(struct wiphy *wiphy, enum ieee80211_band band, unsigned int chan_idx, const struct ieee80211_regdomain *regd) { int r; u32 desired_bw_khz = MHZ_TO_KHZ(20); u32 bw_flags = 0; const struct ieee80211_reg_rule *reg_rule = NULL; const struct <API key> *power_rule = NULL; const struct <API key> *freq_range = NULL; struct <API key> *sband; struct ieee80211_channel *chan; assert_reg_lock(); sband = wiphy->bands[band]; BUG_ON(chan_idx >= sband->n_channels); chan = &sband->channels[chan_idx]; r = freq_reg_info_regd(wiphy, MHZ_TO_KHZ(chan->center_freq), desired_bw_khz, &reg_rule, regd); if (r) { REG_DBG_PRINT("Disabling freq %d MHz as custom " "regd has no rule that fits a %d MHz " "wide channel\n", chan->center_freq, KHZ_TO_MHZ(desired_bw_khz)); chan->flags = <API key>; return; } <API key>(chan, desired_bw_khz, reg_rule); power_rule = &reg_rule->power_rule; freq_range = &reg_rule->freq_range; if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(40)) bw_flags = <API key>; chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp); } static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band, const struct ieee80211_regdomain *regd) { unsigned int i; struct <API key> *sband; BUG_ON(!wiphy->bands[band]); sband = wiphy->bands[band]; for (i = 0; i < sband->n_channels; i++) <API key>(wiphy, band, i, regd); } /* Used by drivers prior to wiphy registration */ void <API key>(struct wiphy *wiphy, const struct ieee80211_regdomain *regd) { enum ieee80211_band band; unsigned int bands_set = 0; mutex_lock(&reg_mutex); for (band = 0; band < IEEE80211_NUM_BANDS; band++) { if (!wiphy->bands[band]) continue; handle_band_custom(wiphy, band, regd); bands_set++; } mutex_unlock(&reg_mutex); /* * no point in calling this if it won't have any effect * on your device's supportd bands. */ WARN_ON(!bands_set); } EXPORT_SYMBOL(<API key>); /* * Return value which can be used by ignore_request() to indicate * it has been determined we should intersect two regulatory domains */ #define REG_INTERSECT 1 /* This has the logic which determines when a new request * should be ignored. */ static int ignore_request(struct wiphy *wiphy, struct regulatory_request *pending_request) { struct wiphy *last_wiphy = NULL; <API key>(); /* All initial requests are respected */ if (!last_request) return 0; switch (pending_request->initiator) { case <API key>: return 0; case <API key>: last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); if (unlikely(!is_an_alpha2(pending_request->alpha2))) return -EINVAL; if (last_request->initiator == <API key>) { if (last_wiphy != wiphy) { /* * Two cards with two APs claiming different * Country IE alpha2s. We could * intersect them, but that seems unlikely * to be correct. Reject second one for now. */ if (regdom_changes(pending_request->alpha2)) return -EOPNOTSUPP; return -EALREADY; } /* * Two consecutive Country IE hints on the same wiphy. * This should be picked up early by the driver/stack */ if (WARN_ON(regdom_changes(pending_request->alpha2))) return 0; return -EALREADY; } return 0; case <API key>: if (last_request->initiator == <API key>) { if (regdom_changes(pending_request->alpha2)) return 0; return -EALREADY; } /* * This would happen if you unplug and plug your card * back in or if you add a new device for which the previously * loaded card also agrees on the regulatory domain. */ if (last_request->initiator == <API key> && !regdom_changes(pending_request->alpha2)) return -EALREADY; return REG_INTERSECT; case <API key>: if (last_request->initiator == <API key>) return REG_INTERSECT; /* * If the user knows better the user should set the regdom * to their country before the IE is picked up */ if (last_request->initiator == <API key> && last_request->intersect) return -EOPNOTSUPP; /* * Process user requests only after previous user/driver/core * requests have been processed */ if (last_request->initiator == <API key> || last_request->initiator == <API key> || last_request->initiator == <API key>) { if (regdom_changes(last_request->alpha2)) return -EAGAIN; } if (!regdom_changes(pending_request->alpha2)) return -EALREADY; return 0; } return -EINVAL; } static void <API key>(void) { bool <API key> = false; last_request->processed = true; spin_lock(&reg_requests_lock); if (!list_empty(&reg_requests_list)) <API key> = true; spin_unlock(&reg_requests_lock); if (last_request->initiator == <API key>) <API key>(&reg_timeout); if (<API key>) schedule_work(&reg_work); } /** * __regulatory_hint - hint to the wireless core a regulatory domain * @wiphy: if the hint comes from country information from an AP, this * is required to be set to the wiphy that received the information * @pending_request: the regulatory request currently being processed * * The Wireless subsystem can use this function to hint to the wireless core * what it believes should be the current regulatory domain. * * Returns zero if all went fine, %-EALREADY if a regulatory domain had * already been set or other standard error codes. * * Caller must hold &cfg80211_mutex and &reg_mutex */ static int __regulatory_hint(struct wiphy *wiphy, struct regulatory_request *pending_request) { bool intersect = false; int r = 0; <API key>(); r = ignore_request(wiphy, pending_request); if (r == REG_INTERSECT) { if (pending_request->initiator == <API key>) { r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); if (r) { kfree(pending_request); return r; } } intersect = true; } else if (r) { /* * If the regulatory domain being requested by the * driver has already been set just copy it to the * wiphy */ if (r == -EALREADY && pending_request->initiator == <API key>) { r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); if (r) { kfree(pending_request); return r; } r = -EALREADY; goto new_request; } kfree(pending_request); return r; } new_request: kfree(last_request); last_request = pending_request; last_request->intersect = intersect; pending_request = NULL; if (last_request->initiator == <API key>) { user_alpha2[0] = last_request->alpha2[0]; user_alpha2[1] = last_request->alpha2[1]; } /* When r == REG_INTERSECT we do need to call CRDA */ if (r < 0) { /* * Since CRDA will not be called in this case as we already * have applied the requested regulatory domain before we just * inform userspace we have processed the request */ if (r == -EALREADY) { <API key>(last_request); <API key>(); } return r; } return call_crda(last_request->alpha2); } /* This processes *all* regulatory hints */ static void reg_process_hint(struct regulatory_request *reg_request) { int r = 0; struct wiphy *wiphy = NULL; enum <API key> initiator = reg_request->initiator; BUG_ON(!reg_request->alpha2); if (wiphy_idx_valid(reg_request->wiphy_idx)) wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); if (reg_request->initiator == <API key> && !wiphy) { kfree(reg_request); return; } r = __regulatory_hint(wiphy, reg_request); /* This is required so that the orig_* parameters are saved */ if (r == -EALREADY && wiphy && wiphy->flags & <API key>) { <API key>(wiphy, initiator); return; } /* * We only time out user hints, given that they should be the only * source of bogus requests. */ if (r != -EALREADY && reg_request->initiator == <API key>) <API key>(&reg_timeout, msecs_to_jiffies(3142)); } /* * Processes regulatory hints, this is all the <API key>* * Regulatory hints come on a first come first serve basis and we * must process each one atomically. */ static void <API key>(void) { struct regulatory_request *reg_request; mutex_lock(&cfg80211_mutex); mutex_lock(&reg_mutex); /* When last_request->processed becomes true this will be rescheduled */ if (last_request && !last_request->processed) { REG_DBG_PRINT("Pending regulatory request, waiting " "for it to be processed..."); goto out; } spin_lock(&reg_requests_lock); if (list_empty(&reg_requests_list)) { spin_unlock(&reg_requests_lock); goto out; } reg_request = list_first_entry(&reg_requests_list, struct regulatory_request, list); list_del_init(&reg_request->list); spin_unlock(&reg_requests_lock); reg_process_hint(reg_request); out: mutex_unlock(&reg_mutex); mutex_unlock(&cfg80211_mutex); } /* Processes beacon hints -- this has nothing to do with country IEs */ static void <API key>(void) { struct <API key> *rdev; struct reg_beacon *pending_beacon, *tmp; /* * No need to hold the reg_mutex here as we just touch wiphys * and do not read or access regulatory variables. */ mutex_lock(&cfg80211_mutex); /* This goes through the _pending_ beacon list */ spin_lock_bh(&<API key>); if (list_empty(&reg_pending_beacons)) { spin_unlock_bh(&<API key>); goto out; } <API key>(pending_beacon, tmp, &reg_pending_beacons, list) { list_del_init(&pending_beacon->list); /* Applies the beacon hint to current wiphys */ list_for_each_entry(rdev, &cfg80211_rdev_list, list) <API key>(&rdev->wiphy, pending_beacon); /* Remembers the beacon hint for new wiphys or reg changes */ list_add_tail(&pending_beacon->list, &reg_beacon_list); } spin_unlock_bh(&<API key>); out: mutex_unlock(&cfg80211_mutex); } static void reg_todo(struct work_struct *work) { <API key>(); <API key>(); } static void <API key>(struct regulatory_request *request) { if (isalpha(request->alpha2[0])) request->alpha2[0] = toupper(request->alpha2[0]); if (isalpha(request->alpha2[1])) request->alpha2[1] = toupper(request->alpha2[1]); spin_lock(&reg_requests_lock); list_add_tail(&request->list, &reg_requests_list); spin_unlock(&reg_requests_lock); schedule_work(&reg_work); } /* * Core regulatory hint -- happens during cfg80211_init() * and when we restore regulatory settings. */ static int <API key>(const char *alpha2) { struct regulatory_request *request; kfree(last_request); last_request = NULL; request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); if (!request) return -ENOMEM; request->alpha2[0] = alpha2[0]; request->alpha2[1] = alpha2[1]; request->initiator = <API key>; <API key>(request); return 0; } /* User hints */ int <API key>(const char *alpha2) { struct regulatory_request *request; BUG_ON(!alpha2); request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); if (!request) return -ENOMEM; request->wiphy_idx = WIPHY_IDX_STALE; request->alpha2[0] = alpha2[0]; request->alpha2[1] = alpha2[1]; request->initiator = <API key>; <API key>(request); return 0; } /* Driver hints */ int regulatory_hint(struct wiphy *wiphy, const char *alpha2) { struct regulatory_request *request; BUG_ON(!alpha2); BUG_ON(!wiphy); request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); if (!request) return -ENOMEM; request->wiphy_idx = get_wiphy_idx(wiphy); /* Must have registered wiphy first */ BUG_ON(!wiphy_idx_valid(request->wiphy_idx)); request->alpha2[0] = alpha2[0]; request->alpha2[1] = alpha2[1]; request->initiator = <API key>; <API key>(request); return 0; } EXPORT_SYMBOL(regulatory_hint); /* * We hold wdev_lock() here so we cannot hold cfg80211_mutex() and * therefore cannot iterate over the rdev list here. */ void regulatory_hint_11d(struct wiphy *wiphy, enum ieee80211_band band, u8 *country_ie, u8 country_ie_len) { char alpha2[2]; enum environment_cap env = ENVIRON_ANY; struct regulatory_request *request; mutex_lock(&reg_mutex); if (unlikely(!last_request)) goto out; /* IE len must be evenly divisible by 2 */ if (country_ie_len & 0x01) goto out; if (country_ie_len < <API key>) goto out; alpha2[0] = country_ie[0]; alpha2[1] = country_ie[1]; if (country_ie[2] == 'I') env = ENVIRON_INDOOR; else if (country_ie[2] == 'O') env = ENVIRON_OUTDOOR; /* * We will run this only upon a successful connection on cfg80211. * We leave conflict resolution to the workqueue, where can hold * cfg80211_mutex. */ if (likely(last_request->initiator == <API key> && wiphy_idx_valid(last_request->wiphy_idx))) goto out; request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); if (!request) goto out; request->wiphy_idx = get_wiphy_idx(wiphy); request->alpha2[0] = alpha2[0]; request->alpha2[1] = alpha2[1]; request->initiator = <API key>; request->country_ie_env = env; mutex_unlock(&reg_mutex); <API key>(request); return; out: mutex_unlock(&reg_mutex); } static void restore_alpha2(char *alpha2, bool reset_user) { /* indicates there is no alpha2 to consider for restoration */ alpha2[0] = '9'; alpha2[1] = '7'; /* The user setting has precedence over the module parameter */ if (<API key>()) { /* Unless we're asked to ignore it and reset it */ if (reset_user) { REG_DBG_PRINT("Restoring regulatory settings " "including user preference\n"); user_alpha2[0] = '9'; user_alpha2[1] = '7'; /* * If we're ignoring user settings, we still need to * check the module parameter to ensure we put things * back as they were for a full restore. */ if (!is_world_regdom(ieee80211_regdom)) { REG_DBG_PRINT("Keeping preference on " "module parameter ieee80211_regdom: %c%c\n", ieee80211_regdom[0], ieee80211_regdom[1]); alpha2[0] = ieee80211_regdom[0]; alpha2[1] = ieee80211_regdom[1]; } } else { REG_DBG_PRINT("Restoring regulatory settings " "while preserving user preference for: %c%c\n", user_alpha2[0], user_alpha2[1]); alpha2[0] = user_alpha2[0]; alpha2[1] = user_alpha2[1]; } } else if (!is_world_regdom(ieee80211_regdom)) { REG_DBG_PRINT("Keeping preference on " "module parameter ieee80211_regdom: %c%c\n", ieee80211_regdom[0], ieee80211_regdom[1]); alpha2[0] = ieee80211_regdom[0]; alpha2[1] = ieee80211_regdom[1]; } else REG_DBG_PRINT("Restoring regulatory settings\n"); } static void <API key>(struct wiphy *wiphy) { struct <API key> *sband; enum ieee80211_band band; struct ieee80211_channel *chan; int i; for (band = 0; band < IEEE80211_NUM_BANDS; band++) { sband = wiphy->bands[band]; if (!sband) continue; for (i = 0; i < sband->n_channels; i++) { chan = &sband->channels[i]; chan->flags = chan->orig_flags; chan->max_antenna_gain = chan->orig_mag; chan->max_power = chan->orig_mpwr; } } } /* * Restoring regulatory settings involves ingoring any * possibly stale country IE information and user regulatory * settings if so desired, this includes any beacon hints * learned as we could have traveled outside to another country * after disconnection. To restore regulatory settings we do * exactly what we did at bootup: * * - send a core regulatory hint * - send a user regulatory hint if applicable * * Device drivers that send a regulatory hint for a specific country * keep their own regulatory domain on wiphy->regd so that does does * not need to be remembered. */ static void <API key>(bool reset_user) { char alpha2[2]; struct reg_beacon *reg_beacon, *btmp; struct regulatory_request *reg_request, *tmp; LIST_HEAD(tmp_reg_req_list); struct <API key> *rdev; mutex_lock(&cfg80211_mutex); mutex_lock(&reg_mutex); reset_regdomains(); restore_alpha2(alpha2, reset_user); /* * If there's any pending requests we simply * stash them to a temporary pending queue and * add then after we've restored regulatory * settings. */ spin_lock(&reg_requests_lock); if (!list_empty(&reg_requests_list)) { <API key>(reg_request, tmp, &reg_requests_list, list) { if (reg_request->initiator != <API key>) continue; list_del(&reg_request->list); list_add_tail(&reg_request->list, &tmp_reg_req_list); } } spin_unlock(&reg_requests_lock); /* Clear beacon hints */ spin_lock_bh(&<API key>); if (!list_empty(&reg_pending_beacons)) { <API key>(reg_beacon, btmp, &reg_pending_beacons, list) { list_del(&reg_beacon->list); kfree(reg_beacon); } } spin_unlock_bh(&<API key>); if (!list_empty(&reg_beacon_list)) { <API key>(reg_beacon, btmp, &reg_beacon_list, list) { list_del(&reg_beacon->list); kfree(reg_beacon); } } /* First restore to the basic regulatory settings */ cfg80211_regdomain = <API key>; list_for_each_entry(rdev, &cfg80211_rdev_list, list) { if (rdev->wiphy.flags & <API key>) <API key>(&rdev->wiphy); } mutex_unlock(&reg_mutex); mutex_unlock(&cfg80211_mutex); <API key>(cfg80211_regdomain->alpha2); /* * This restores the ieee80211_regdom module parameter * preference or the last user requested regulatory * settings, user regulatory settings takes precedence. */ if (is_an_alpha2(alpha2)) <API key>(user_alpha2); if (list_empty(&tmp_reg_req_list)) return; mutex_lock(&cfg80211_mutex); mutex_lock(&reg_mutex); spin_lock(&reg_requests_lock); <API key>(reg_request, tmp, &tmp_reg_req_list, list) { REG_DBG_PRINT("Adding request for country %c%c back " "into the queue\n", reg_request->alpha2[0], reg_request->alpha2[1]); list_del(&reg_request->list); list_add_tail(&reg_request->list, &reg_requests_list); } spin_unlock(&reg_requests_lock); mutex_unlock(&reg_mutex); mutex_unlock(&cfg80211_mutex); REG_DBG_PRINT("Kicking the queue\n"); schedule_work(&reg_work); } void <API key>(void) { REG_DBG_PRINT("All devices are disconnected, going to " "restore regulatory settings\n"); <API key>(false); } static bool <API key>(u16 freq) { if (freq == <API key>(12, IEEE80211_BAND_2GHZ) || freq == <API key>(13, IEEE80211_BAND_2GHZ) || freq == <API key>(14, IEEE80211_BAND_2GHZ)) return true; return false; } int <API key>(struct wiphy *wiphy, struct ieee80211_channel *beacon_chan, gfp_t gfp) { struct reg_beacon *reg_beacon; if (likely((beacon_chan->beacon_found || (beacon_chan->flags & <API key>) || (beacon_chan->band == IEEE80211_BAND_2GHZ && !<API key>(beacon_chan->center_freq))))) return 0; reg_beacon = kzalloc(sizeof(struct reg_beacon), gfp); if (!reg_beacon) return -ENOMEM; REG_DBG_PRINT("Found new beacon on " "frequency: %d MHz (Ch %d) on %s\n", beacon_chan->center_freq, <API key>(beacon_chan->center_freq), wiphy_name(wiphy)); memcpy(&reg_beacon->chan, beacon_chan, sizeof(struct ieee80211_channel)); /* * Since we can be called from BH or and non-BH context * we must use spin_lock_bh() */ spin_lock_bh(&<API key>); list_add_tail(&reg_beacon->list, &reg_pending_beacons); spin_unlock_bh(&<API key>); schedule_work(&reg_work); return 0; } static void print_rd_rules(const struct ieee80211_regdomain *rd) { unsigned int i; const struct ieee80211_reg_rule *reg_rule = NULL; const struct <API key> *freq_range = NULL; const struct <API key> *power_rule = NULL; pr_info(" (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)\n"); for (i = 0; i < rd->n_reg_rules; i++) { reg_rule = &rd->reg_rules[i]; freq_range = &reg_rule->freq_range; power_rule = &reg_rule->power_rule; /* * There may not be documentation for max antenna gain * in certain regions */ if (power_rule->max_antenna_gain) pr_info(" (%d KHz - %d KHz @ %d KHz), (%d mBi, %d mBm)\n", freq_range->start_freq_khz, freq_range->end_freq_khz, freq_range->max_bandwidth_khz, power_rule->max_antenna_gain, power_rule->max_eirp); else pr_info(" (%d KHz - %d KHz @ %d KHz), (N/A, %d mBm)\n", freq_range->start_freq_khz, freq_range->end_freq_khz, freq_range->max_bandwidth_khz, power_rule->max_eirp); } } static void print_regdomain(const struct ieee80211_regdomain *rd) { if (<API key>(rd->alpha2)) { if (last_request->initiator == <API key>) { struct <API key> *rdev; rdev = <API key>( last_request->wiphy_idx); if (rdev) { pr_info("Current regulatory domain updated by AP to: %c%c\n", rdev->country_ie_alpha2[0], rdev->country_ie_alpha2[1]); } else pr_info("Current regulatory domain intersected:\n"); } else pr_info("Current regulatory domain intersected:\n"); } else if (is_world_regdom(rd->alpha2)) pr_info("World regulatory domain updated:\n"); else { if (is_unknown_alpha2(rd->alpha2)) pr_info("Regulatory domain changed to driver built-in settings (unknown country)\n"); else pr_info("Regulatory domain changed to country: %c%c\n", rd->alpha2[0], rd->alpha2[1]); } print_rd_rules(rd); } static void <API key>(const struct ieee80211_regdomain *rd) { pr_info("Regulatory domain: %c%c\n", rd->alpha2[0], rd->alpha2[1]); print_rd_rules(rd); } /* Takes ownership of rd only if it doesn't fail */ static int __set_regdom(const struct ieee80211_regdomain *rd) { const struct ieee80211_regdomain *intersected_rd = NULL; struct <API key> *rdev = NULL; struct wiphy *request_wiphy; /* Some basic sanity checks first */ if (is_world_regdom(rd->alpha2)) { if (WARN_ON(!<API key>(rd->alpha2))) return -EINVAL; <API key>(rd); return 0; } if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) && !is_unknown_alpha2(rd->alpha2)) return -EINVAL; if (!last_request) return -EINVAL; /* * Lets only bother proceeding on the same alpha2 if the current * rd is non static (it means CRDA was present and was used last) * and the pending request came in from a country IE */ if (last_request->initiator != <API key>) { /* * If someone else asked us to change the rd lets only bother * checking if the alpha2 changes if CRDA was already called */ if (!regdom_changes(rd->alpha2)) return -EINVAL; } /* * Now lets set the regulatory domain, update all driver channels * and finally inform them of what we have done, in case they want * to review or adjust their own settings based on their own * internal EEPROM data */ if (WARN_ON(!<API key>(rd->alpha2))) return -EINVAL; if (!is_valid_rd(rd)) { pr_err("Invalid regulatory domain detected:\n"); <API key>(rd); return -EINVAL; } request_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); if (!last_request->intersect) { int r; if (last_request->initiator != <API key>) { reset_regdomains(); cfg80211_regdomain = rd; return 0; } /* * For a driver hint, lets copy the regulatory domain the * driver wanted to the wiphy to deal with conflicts */ /* * Userspace could have sent two replies with only * one kernel request. */ if (request_wiphy->regd) return -EALREADY; r = reg_copy_regd(&request_wiphy->regd, rd); if (r) return r; reset_regdomains(); cfg80211_regdomain = rd; return 0; } /* Intersection requires a bit more work */ if (last_request->initiator != <API key>) { intersected_rd = regdom_intersect(rd, cfg80211_regdomain); if (!intersected_rd) return -EINVAL; /* * We can trash what CRDA provided now. * However if a driver requested this specific regulatory * domain we keep it for its private use */ if (last_request->initiator == <API key>) request_wiphy->regd = rd; else kfree(rd); rd = NULL; reset_regdomains(); cfg80211_regdomain = intersected_rd; return 0; } if (!intersected_rd) return -EINVAL; rdev = wiphy_to_dev(request_wiphy); rdev->country_ie_alpha2[0] = rd->alpha2[0]; rdev->country_ie_alpha2[1] = rd->alpha2[1]; rdev->env = last_request->country_ie_env; BUG_ON(intersected_rd == rd); kfree(rd); rd = NULL; reset_regdomains(); cfg80211_regdomain = intersected_rd; return 0; } /* * Use this call to set the current regulatory domain. Conflicts with * multiple drivers can be ironed out later. Caller must've already * kmalloc'd the rd structure. Caller must hold cfg80211_mutex */ int set_regdom(const struct ieee80211_regdomain *rd) { int r; <API key>(); mutex_lock(&reg_mutex); /* Note that this doesn't update the wiphys, this is done below */ r = __set_regdom(rd); if (r) { kfree(rd); mutex_unlock(&reg_mutex); return r; } /* This would make this whole thing pointless */ if (!last_request->intersect) BUG_ON(rd != cfg80211_regdomain); /* update all wiphys now with the new established regulatory domain */ <API key>(last_request->initiator); print_regdomain(cfg80211_regdomain); <API key>(last_request); <API key>(); mutex_unlock(&reg_mutex); return r; } #ifdef CONFIG_HOTPLUG int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) { if (last_request && !last_request->processed) { if (add_uevent_var(env, "COUNTRY=%c%c", last_request->alpha2[0], last_request->alpha2[1])) return -ENOMEM; } return 0; } #else int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) { return -ENODEV; } #endif /* CONFIG_HOTPLUG */ /* Caller must hold cfg80211_mutex */ void reg_device_remove(struct wiphy *wiphy) { struct wiphy *request_wiphy = NULL; <API key>(); mutex_lock(&reg_mutex); kfree(wiphy->regd); if (last_request) request_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); if (!request_wiphy || request_wiphy != wiphy) goto out; last_request->wiphy_idx = WIPHY_IDX_STALE; last_request->country_ie_env = ENVIRON_ANY; out: mutex_unlock(&reg_mutex); } static void reg_timeout_work(struct work_struct *work) { REG_DBG_PRINT("Timeout while waiting for CRDA to reply, " "restoring regulatory settings"); <API key>(true); } int __init regulatory_init(void) { int err = 0; reg_pdev = <API key>("regulatory", 0, NULL, 0); if (IS_ERR(reg_pdev)) return PTR_ERR(reg_pdev); reg_pdev->dev.type = &reg_device_type; spin_lock_init(&reg_requests_lock); spin_lock_init(&<API key>); cfg80211_regdomain = <API key>; user_alpha2[0] = '9'; user_alpha2[1] = '7'; /* We always try to get an update for the static regdomain */ err = <API key>(cfg80211_regdomain->alpha2); if (err) { if (err == -ENOMEM) return err; /* * N.B. kobject_uevent_env() can fail mainly for when we're out * memory which is handled and propagated appropriately above * but it can also fail during a netlink_broadcast() or during * early boot for call_usermodehelper(). For now treat these * errors as non-fatal. */ pr_err("kobject_uevent_env() was unable to call CRDA during init\n"); #ifdef <API key> /* We want to find out exactly why when debugging */ WARN_ON(err); #endif } /* * Finally, if the user set the module parameter treat it * as a user hint. */ if (!is_world_regdom(ieee80211_regdom)) <API key>(ieee80211_regdom); return 0; } void /* __init_or_exit */ regulatory_exit(void) { struct regulatory_request *reg_request, *tmp; struct reg_beacon *reg_beacon, *btmp; cancel_work_sync(&reg_work); <API key>(&reg_timeout); mutex_lock(&cfg80211_mutex); mutex_lock(&reg_mutex); reset_regdomains(); kfree(last_request); <API key>(reg_pdev); spin_lock_bh(&<API key>); if (!list_empty(&reg_pending_beacons)) { <API key>(reg_beacon, btmp, &reg_pending_beacons, list) { list_del(&reg_beacon->list); kfree(reg_beacon); } } spin_unlock_bh(&<API key>); if (!list_empty(&reg_beacon_list)) { <API key>(reg_beacon, btmp, &reg_beacon_list, list) { list_del(&reg_beacon->list); kfree(reg_beacon); } } spin_lock(&reg_requests_lock); if (!list_empty(&reg_requests_list)) { <API key>(reg_request, tmp, &reg_requests_list, list) { list_del(&reg_request->list); kfree(reg_request); } } spin_unlock(&reg_requests_lock); mutex_unlock(&reg_mutex); mutex_unlock(&cfg80211_mutex); }
using Db4objects.Db4o.Query; using Db4objects.Db4o.Tests.Common.Soda.Util; using Sharpen; namespace Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed { public class <API key> : SodaBaseTestCase { public int[][][] intArr; public <API key>() { } public <API key>(int[][][] arr) { intArr = arr; } public override object[] CreateData() { Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key>[] arr = new Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key>[5]; arr[0] = new Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> (); int[][][] content = new int[][][] { }; arr[1] = new Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> (content); content = new int[][][] { new int[][] { new int[3], new int[3] } }; content[0][0][1] = 0; content[0][1][0] = 0; arr[2] = new Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> (content); content = new int[][][] { new int[][] { new int[3], new int[3] } }; content[0][0][0] = 1; content[0][1][0] = 17; content[0][1][1] = int.MaxValue - 1; arr[3] = new Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> (content); content = new int[][][] { new int[][] { new int[2], new int[2] } }; content[0][0][0] = 3; content[0][0][1] = 17; content[0][1][0] = 25; content[0][1][1] = int.MaxValue - 2; arr[4] = new Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> (content); object[] ret = new object[arr.Length]; System.Array.Copy(arr, 0, ret, 0, arr.Length); return ret; } public virtual void <API key>() { IQuery q = NewQuery(); int[][][] content = new int[][][] { new int[][] { new int[1] } }; content[0][0][0] = 17; q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> (content)); Expect(q, new int[] { 3, 4 }); } public virtual void <API key>() { IQuery q = NewQuery(); int[][][] content = new int[][][] { new int[][] { new int[1] }, new int[][] { new int[1] } }; content[0][0][0] = 17; content[1][0][0] = 25; q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> (content)); Expect(q, new int[] { 4 }); } public virtual void TestDescendOne() { IQuery q = NewQuery(); q.Constrain(typeof(Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> )); q.Descend("intArr").Constrain(17); Expect(q, new int[] { 3, 4 }); } public virtual void TestDescendTwo() { IQuery q = NewQuery(); q.Constrain(typeof(Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> )); IQuery qElements = q.Descend("intArr"); qElements.Constrain(17); qElements.Constrain(25); Expect(q, new int[] { 4 }); } public virtual void TestDescendSmaller() { IQuery q = NewQuery(); q.Constrain(typeof(Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> )); IQuery qElements = q.Descend("intArr"); qElements.Constrain(3).Smaller(); Expect(q, new int[] { 2, 3 }); } public virtual void <API key>() { IQuery q = NewQuery(); q.Constrain(typeof(Db4objects.Db4o.Tests.Common.Soda.Arrays.Typed.<API key> )); IQuery qElements = q.Descend("intArr"); qElements.Constrain(3).Smaller(); Expect(q, new int[] { 2, 3 }); } } }
#include "steadystatetest.hh" #include <models/REmodel.hh> #include <models/LNAmodel.hh> #include <models/IOSmodel.hh> #include <models/sseinterpreter.hh> #include <models/steadystateanalysis.hh> #include <eval/jit/engine.hh> #include <parser/sbml/sbml.hh> using namespace iNA; SteadyStateTest::~SteadyStateTest() { // pass... } void SteadyStateTest::<API key>() { // Read doc and check for errors: Ast::Model sbml_model; Parser::Sbml::importModel(sbml_model, "test/regression-tests/extended_goodwin.xml"); // Construct RE model to integrate Models::REmodel model(sbml_model); // Perform analysis: Eigen::VectorXd state(model.getDimension()); Models::SteadyStateAnalysis<Models::REmodel> analysis(model); analysis.setMaxIterations(1000); analysis.calcSteadyState(state); } void SteadyStateTest::<API key>() { // Read doc and check for errors: Ast::Model sbml_model; Parser::Sbml::importModel(sbml_model, "test/regression-tests/extended_goodwin.xml"); // Construct LNA model to integrate Models::LNAmodel model(sbml_model); // Perform analysis: Eigen::VectorXd state(model.getDimension()); Models::SteadyStateAnalysis<Models::LNAmodel> analysis(model); analysis.setMaxIterations(1000); analysis.calcSteadyState(state); } void SteadyStateTest::<API key>() { // Read doc and check for errors: Ast::Model sbml_model; Parser::Sbml::importModel(sbml_model, "test/regression-tests/extended_goodwin.xml"); // Construct model to integrate Models::IOSmodel model(sbml_model); // Perform analysis: Eigen::VectorXd state(model.getDimension()); Models::SteadyStateAnalysis<Models::IOSmodel> analysis(model); analysis.setMaxIterations(1000); analysis.calcSteadyState(state); } UnitTest::TestSuite * SteadyStateTest::suite() { UnitTest::TestSuite *s = new UnitTest::TestSuite("Steady State Tests"); s->addTest(new UnitTest::TestCaller<SteadyStateTest>( "EnzymeKinetics Model (RE)", &SteadyStateTest::<API key>)); s->addTest(new UnitTest::TestCaller<SteadyStateTest>( "EnzymeKinetics Model (LNA)", &SteadyStateTest::<API key>)); s->addTest(new UnitTest::TestCaller<SteadyStateTest>( "EnzymeKinetics Model (IOS)", &SteadyStateTest::<API key>)); return s; }
-- 17/03/2011 9h3min12s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,1120054,0,'lbr_TaxStatusPIS',TO_TIMESTAMP('2011-03-17 09:03:10','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (PIS)','LBRA','Defines the Tax Status (PIS)','Y','Tax Status (PIS)','Tax Status (PIS)',TO_TIMESTAMP('2011-03-17 09:03:10','YYYY-MM-DD HH24:MI:SS'),100) ; -- 17/03/2011 9h3min12s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=1120054 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) ; -- 17/03/2011 9h3min43s BRT -- I forgot to set the <API key> System Configurator UPDATE AD_Element_Trl SET IsTranslated='Y',Name='Situação Tributária (PIS)',PrintName='Situação Tributária (PIS)',Description='Defines a Situação Tributária (PIS)',Help='Defines a Situação Tributária (PIS)',Updated=TO_TIMESTAMP('2011-03-17 09:03:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=1120054 AND AD_Language='pt_BR' ; -- 17/03/2011 9h4min44s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Reference (AD_Client_ID,AD_Org_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,IsOrderByValue,Name,Updated,UpdatedBy,ValidationType) VALUES (0,0,1120023,TO_TIMESTAMP('2011-03-17 09:04:43','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','N','<API key>',TO_TIMESTAMP('2011-03-17 09:04:43','YYYY-MM-DD HH24:MI:SS'),100,'L') ; -- 17/03/2011 9h4min44s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Reference_Trl (AD_Language,AD_Reference_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Reference_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Reference t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Reference_ID=1120023 AND NOT EXISTS (SELECT * FROM AD_Reference_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Reference_ID=t.AD_Reference_ID) ; -- 17/03/2011 9h5min17s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120096,1120023,TO_TIMESTAMP('2011-03-17 09:05:17','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','01 - Operação Tributável com Alíquota Básica',TO_TIMESTAMP('2011-03-17 09:05:17','YYYY-MM-DD HH24:MI:SS'),100,'01') ; -- 17/03/2011 9h5min17s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120096 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h5min32s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120097,1120023,TO_TIMESTAMP('2011-03-17 09:05:32','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','02 - Operação Tributável com Alíquota Diferenciada',TO_TIMESTAMP('2011-03-17 09:05:32','YYYY-MM-DD HH24:MI:SS'),100,'02') ; -- 17/03/2011 9h5min32s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120097 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h5min47s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120098,1120023,TO_TIMESTAMP('2011-03-17 09:05:46','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','03 - Operação Tributável com Alíquota por Unidade de Medida de Produto',TO_TIMESTAMP('2011-03-17 09:05:46','YYYY-MM-DD HH24:MI:SS'),100,'03') ; -- 17/03/2011 9h5min47s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120098 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h6min4s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120099,1120023,TO_TIMESTAMP('2011-03-17 09:06:04','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','04 - Operação Tributável Monofásica - Revenda a Alíquota Zero',TO_TIMESTAMP('2011-03-17 09:06:04','YYYY-MM-DD HH24:MI:SS'),100,'04') ; -- 17/03/2011 9h6min4s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120099 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h6min25s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120100,1120023,TO_TIMESTAMP('2011-03-17 09:06:24','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','05 - Operação Tributável por Substituição Tributária',TO_TIMESTAMP('2011-03-17 09:06:24','YYYY-MM-DD HH24:MI:SS'),100,'05') ; -- 17/03/2011 9h6min25s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120100 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h6min58s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120101,1120023,TO_TIMESTAMP('2011-03-17 09:06:57','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','06 - Operação Tributável a Alíquota Zero',TO_TIMESTAMP('2011-03-17 09:06:57','YYYY-MM-DD HH24:MI:SS'),100,'06') ; -- 17/03/2011 9h6min58s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120101 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h7min12s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120102,1120023,TO_TIMESTAMP('2011-03-17 09:07:12','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','07 - Operação Isenta da Contribuição',TO_TIMESTAMP('2011-03-17 09:07:12','YYYY-MM-DD HH24:MI:SS'),100,'07') ; -- 17/03/2011 9h7min12s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120102 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h9min1s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120103,1120023,TO_TIMESTAMP('2011-03-17 09:09:00','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','08 - Operação sem Incidência da Contribuição',TO_TIMESTAMP('2011-03-17 09:09:00','YYYY-MM-DD HH24:MI:SS'),100,'08') ; -- 17/03/2011 9h9min1s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120103 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h9min15s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120104,1120023,TO_TIMESTAMP('2011-03-17 09:09:14','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','09 - Operação com Suspensão da Contribuição',TO_TIMESTAMP('2011-03-17 09:09:14','YYYY-MM-DD HH24:MI:SS'),100,'09') ; -- 17/03/2011 9h9min15s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120104 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h9min31s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120105,1120023,TO_TIMESTAMP('2011-03-17 09:09:31','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','49 - Outras Operações de Saída',TO_TIMESTAMP('2011-03-17 09:09:31','YYYY-MM-DD HH24:MI:SS'),100,'49') ; -- 17/03/2011 9h9min31s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120105 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h9min49s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120106,1120023,TO_TIMESTAMP('2011-03-17 09:09:48','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','50 - Operação com Direito a Crédito - Vinculada Exclusivamente a Receita Tributada no Mercado Interno',TO_TIMESTAMP('2011-03-17 09:09:48','YYYY-MM-DD HH24:MI:SS'),100,'50') ; -- 17/03/2011 9h9min49s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120106 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h10min8s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120107,1120023,TO_TIMESTAMP('2011-03-17 09:10:07','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','51 - Operação com Direito a Crédito – Vinculada Exclusivamente a Receita Não Tributada no Mercado Interno',TO_TIMESTAMP('2011-03-17 09:10:07','YYYY-MM-DD HH24:MI:SS'),100,'51') ; -- 17/03/2011 9h10min8s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120107 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h10min24s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120108,1120023,TO_TIMESTAMP('2011-03-17 09:10:24','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','52 - Operação com Direito a Crédito - Vinculada Exclusivamente a Receita de Exportação',TO_TIMESTAMP('2011-03-17 09:10:24','YYYY-MM-DD HH24:MI:SS'),100,'52') ; -- 17/03/2011 9h10min24s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120108 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h10min38s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120109,1120023,TO_TIMESTAMP('2011-03-17 09:10:37','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','53 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno',TO_TIMESTAMP('2011-03-17 09:10:37','YYYY-MM-DD HH24:MI:SS'),100,'53') ; -- 17/03/2011 9h10min38s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120109 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h11min0s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120110,1120023,TO_TIMESTAMP('2011-03-17 09:11:00','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','54 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas no Mercado Interno e de Exportação',TO_TIMESTAMP('2011-03-17 09:11:00','YYYY-MM-DD HH24:MI:SS'),100,'54') ; -- 17/03/2011 9h11min0s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120110 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 9h11min20s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120111,1120023,TO_TIMESTAMP('2011-03-17 09:11:20','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','55 - Operação com Direito a Crédito - Vinculada a Receitas Não-Tributadas no Mercado Interno e de Exportação',TO_TIMESTAMP('2011-03-17 09:11:20','YYYY-MM-DD HH24:MI:SS'),100,'55') ; -- 17/03/2011 9h11min20s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120111 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h6min3s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120112,1120023,TO_TIMESTAMP('2011-03-17 10:06:02','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','56 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno, e de Exportação',TO_TIMESTAMP('2011-03-17 10:06:02','YYYY-MM-DD HH24:MI:SS'),100,'56') ; -- 17/03/2011 10h6min3s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120112 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h6min21s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120113,1120023,TO_TIMESTAMP('2011-03-17 10:06:20','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','60 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita Tributada no Mercado Interno',TO_TIMESTAMP('2011-03-17 10:06:20','YYYY-MM-DD HH24:MI:SS'),100,'60') ; -- 17/03/2011 10h6min21s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120113 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h6min44s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120114,1120023,TO_TIMESTAMP('2011-03-17 10:06:43','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','61 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita Não-Tributada no Mercado Interno',TO_TIMESTAMP('2011-03-17 10:06:43','YYYY-MM-DD HH24:MI:SS'),100,'61') ; -- 17/03/2011 10h6min44s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120114 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h7min13s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120115,1120023,TO_TIMESTAMP('2011-03-17 10:07:13','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','62 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita de Exportação',TO_TIMESTAMP('2011-03-17 10:07:13','YYYY-MM-DD HH24:MI:SS'),100,'62') ; -- 17/03/2011 10h7min13s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120115 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h7min28s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120116,1120023,TO_TIMESTAMP('2011-03-17 10:07:27','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','63 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno',TO_TIMESTAMP('2011-03-17 10:07:27','YYYY-MM-DD HH24:MI:SS'),100,'63') ; -- 17/03/2011 10h7min28s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120116 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h7min44s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120117,1120023,TO_TIMESTAMP('2011-03-17 10:07:43','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','64 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas no Mercado Interno e de Exportação',TO_TIMESTAMP('2011-03-17 10:07:43','YYYY-MM-DD HH24:MI:SS'),100,'64') ; -- 17/03/2011 10h7min44s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120117 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h8min0s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120118,1120023,TO_TIMESTAMP('2011-03-17 10:07:59','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','65 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Não-Tributadas no Mercado Interno e de Exportação',TO_TIMESTAMP('2011-03-17 10:07:59','YYYY-MM-DD HH24:MI:SS'),100,'65') ; -- 17/03/2011 10h8min0s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120118 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h8min28s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120119,1120023,TO_TIMESTAMP('2011-03-17 10:08:27','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','66 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno e Exp.',TO_TIMESTAMP('2011-03-17 10:08:27','YYYY-MM-DD HH24:MI:SS'),100,'66') ; -- 17/03/2011 10h8min28s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120119 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h8min45s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120120,1120023,TO_TIMESTAMP('2011-03-17 10:08:44','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','67 - Crédito Presumido - Outras Operações',TO_TIMESTAMP('2011-03-17 10:08:44','YYYY-MM-DD HH24:MI:SS'),100,'67') ; -- 17/03/2011 10h8min45s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120120 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h9min11s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120121,1120023,TO_TIMESTAMP('2011-03-17 10:09:11','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','70 - Operação de Aquisição sem Direito a Crédito',TO_TIMESTAMP('2011-03-17 10:09:11','YYYY-MM-DD HH24:MI:SS'),100,'70') ; -- 17/03/2011 10h9min11s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120121 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h10min31s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120122,1120023,TO_TIMESTAMP('2011-03-17 10:10:30','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','71 - Operação de Aquisição com Isenção',TO_TIMESTAMP('2011-03-17 10:10:30','YYYY-MM-DD HH24:MI:SS'),100,'71') ; -- 17/03/2011 10h10min31s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120122 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h10min55s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120123,1120023,TO_TIMESTAMP('2011-03-17 10:10:54','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','72 - Operação de Aquisição com Suspensão',TO_TIMESTAMP('2011-03-17 10:10:54','YYYY-MM-DD HH24:MI:SS'),100,'72') ; -- 17/03/2011 10h10min55s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120123 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h16min20s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120124,1120023,TO_TIMESTAMP('2011-03-17 10:16:19','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','73 - Operação de Aquisição a Alíquota Zero',TO_TIMESTAMP('2011-03-17 10:16:19','YYYY-MM-DD HH24:MI:SS'),100,'73') ; -- 17/03/2011 10h16min20s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120124 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h16min35s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120125,1120023,TO_TIMESTAMP('2011-03-17 10:16:35','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','74 - Operação de Aquisição sem Incidência da Contribuição',TO_TIMESTAMP('2011-03-17 10:16:35','YYYY-MM-DD HH24:MI:SS'),100,'74') ; -- 17/03/2011 10h16min35s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120125 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h16min52s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120126,1120023,TO_TIMESTAMP('2011-03-17 10:16:52','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','75 - Operação de Aquisição por Substituição Tributária',TO_TIMESTAMP('2011-03-17 10:16:52','YYYY-MM-DD HH24:MI:SS'),100,'75') ; -- 17/03/2011 10h16min52s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120126 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h17min8s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120127,1120023,TO_TIMESTAMP('2011-03-17 10:17:07','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','98 - Outras Operações de Entrada',TO_TIMESTAMP('2011-03-17 10:17:07','YYYY-MM-DD HH24:MI:SS'),100,'98') ; -- 17/03/2011 10h17min8s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120127 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h17min20s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,1120128,1120023,TO_TIMESTAMP('2011-03-17 10:17:19','YYYY-MM-DD HH24:MI:SS'),100,'LBRA','Y','99 - Outras Operações',TO_TIMESTAMP('2011-03-17 10:17:19','YYYY-MM-DD HH24:MI:SS'),100,'99') ; -- 17/03/2011 10h17min20s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=1120128 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) ; -- 17/03/2011 10h17min50s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,<API key>,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,1120265,1120054,0,17,1120023,333,'lbr_TaxStatusPIS',TO_TIMESTAMP('2011-03-17 10:17:49','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (PIS)','LBRA',2,'Defines the Tax Status (PIS)','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Tax Status (PIS)',0,TO_TIMESTAMP('2011-03-17 10:17:49','YYYY-MM-DD HH24:MI:SS'),100,0) ; -- 17/03/2011 10h17min50s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=1120265 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID) ; -- 17/03/2011 10h17min52s BRT -- I forgot to set the <API key> System Configurator ALTER TABLE C_InvoiceLine ADD COLUMN lbr_TaxStatusPIS VARCHAR(2) DEFAULT NULL ; -- 17/03/2011 10h26min38s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,1120055,0,'lbr_TaxStatusCOFINS',TO_TIMESTAMP('2011-03-17 10:26:37','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (COFINS)','LBRA','Defines the Tax Status (COFINS)','Y','Tax Status (COFINS)','Tax Status (COFINS)',TO_TIMESTAMP('2011-03-17 10:26:37','YYYY-MM-DD HH24:MI:SS'),100) ; -- 17/03/2011 10h26min38s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=1120055 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) ; -- 17/03/2011 10h27min16s BRT -- I forgot to set the <API key> System Configurator UPDATE AD_Element_Trl SET IsTranslated='Y',Name='Situação Tributária (COFINS)',PrintName='Situação Tributária (COFINS)',Description='Defines a Situação Tributária (COFINS)',Help='Defines a Situação Tributária (COFINS)',Updated=TO_TIMESTAMP('2011-03-17 10:27:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=1120055 AND AD_Language='pt_BR' ; -- 17/03/2011 10h27min29s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,<API key>,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,1120266,1120055,0,17,1120023,333,'lbr_TaxStatusCOFINS',TO_TIMESTAMP('2011-03-17 10:27:28','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (COFINS)','LBRA',2,'Defines the Tax Status (COFINS)','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Tax Status (COFINS)',0,TO_TIMESTAMP('2011-03-17 10:27:28','YYYY-MM-DD HH24:MI:SS'),100,0) ; -- 17/03/2011 10h27min29s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=1120266 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID) ; -- 17/03/2011 10h27min30s BRT -- I forgot to set the <API key> System Configurator ALTER TABLE C_InvoiceLine ADD COLUMN lbr_TaxStatusCOFINS VARCHAR(2) DEFAULT NULL ; -- 17/03/2011 11h40min3s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,<API key>,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,1120267,1120054,0,17,1120023,1000028,'lbr_TaxStatusPIS',TO_TIMESTAMP('2011-03-17 11:40:01','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (PIS)','LBRA',2,'Defines the Tax Status (PIS)','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Tax Status (PIS)',0,TO_TIMESTAMP('2011-03-17 11:40:01','YYYY-MM-DD HH24:MI:SS'),100,0) ; -- 17/03/2011 11h40min3s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=1120267 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID) ; -- 17/03/2011 11h41min24s BRT -- I forgot to set the <API key> System Configurator ALTER TABLE LBR_NotaFiscalLine ADD COLUMN lbr_TaxStatusPIS VARCHAR(2) DEFAULT NULL ; -- 17/03/2011 11h41min47s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,<API key>,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,1120268,1120055,0,17,1120023,1000028,'lbr_TaxStatusCOFINS',TO_TIMESTAMP('2011-03-17 11:41:47','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (COFINS)','LBRA',2,'Defines the Tax Status (COFINS)','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Tax Status (COFINS)',0,TO_TIMESTAMP('2011-03-17 11:41:47','YYYY-MM-DD HH24:MI:SS'),100,0) ; -- 17/03/2011 11h41min47s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=1120268 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID) ; -- 17/03/2011 11h41min49s BRT -- I forgot to set the <API key> System Configurator ALTER TABLE LBR_NotaFiscalLine ADD COLUMN lbr_TaxStatusCOFINS VARCHAR(2) DEFAULT NULL ; -- 17/03/2011 11h42min48s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,<API key>,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,Updated,UpdatedBy) VALUES (0,1120267,1120196,0,1000021,TO_TIMESTAMP('2011-03-17 11:42:47','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (PIS)',2,'LBRA','Defines the Tax Status (PIS)','Y','Y','Y','N','N','N','N','N','Tax Status (PIS)',201,TO_TIMESTAMP('2011-03-17 11:42:47','YYYY-MM-DD HH24:MI:SS'),100) ; -- 17/03/2011 11h42min48s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=1120196 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID) ; -- 17/03/2011 11h43min16s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,<API key>,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,Updated,UpdatedBy) VALUES (0,1120268,1120197,0,1000021,TO_TIMESTAMP('2011-03-17 11:43:15','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (COFINS)',2,'LBRA','Defines the Tax Status (COFINS)','Y','Y','Y','N','N','N','N','Y','Tax Status (COFINS)',202,TO_TIMESTAMP('2011-03-17 11:43:15','YYYY-MM-DD HH24:MI:SS'),100) ; -- 17/03/2011 11h43min16s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=1120197 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID) ; -- 17/03/2011 11h44min9s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,<API key>,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,Updated,UpdatedBy) VALUES (0,1120267,1120198,0,1000030,TO_TIMESTAMP('2011-03-17 11:44:08','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (PIS)',2,'LBRA','Defines the Tax Status (PIS)','Y','Y','Y','N','N','N','N','N','Tax Status (PIS)',251,TO_TIMESTAMP('2011-03-17 11:44:08','YYYY-MM-DD HH24:MI:SS'),100) ; -- 17/03/2011 11h44min9s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=1120198 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID) ; -- 17/03/2011 11h44min32s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,<API key>,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,Updated,UpdatedBy) VALUES (0,1120268,1120199,0,1000030,TO_TIMESTAMP('2011-03-17 11:44:31','YYYY-MM-DD HH24:MI:SS'),100,'Defines the Tax Status (COFINS)',2,'LBRA','Defines the Tax Status (COFINS)','Y','Y','Y','N','N','N','N','Y','Tax Status (COFINS)',252,TO_TIMESTAMP('2011-03-17 11:44:31','YYYY-MM-DD HH24:MI:SS'),100) ; -- 17/03/2011 11h44min32s BRT -- I forgot to set the <API key> System Configurator INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=1120199 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID) ; UPDATE AD_SysConfig SET Value='360-trunk/040-FR_3220195.sql' WHERE AD_SysConfig_ID=1100006;
#include <mach/debug_audio_mm.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/miscdevice.h> #include <linux/uaccess.h> #include <linux/sched.h> #include <linux/wait.h> #include <linux/dma-mapping.h> #include <linux/msm_audio.h> #include <asm/atomic.h> #include <asm/ioctls.h> #include <mach/msm_adsp.h> #include <mach/qdsp5v2/qdsp5audreccmdi.h> #include <mach/qdsp5v2/qdsp5audrecmsg.h> #include <mach/qdsp5v2/audpreproc.h> #include <mach/qdsp5v2/audio_dev_ctl.h> /* FRAME_NUM must be a power of two */ #define FRAME_NUM (8) #define FRAME_SIZE (2052 * 2) #define MONO_DATA_SIZE (2048) #define STEREO_DATA_SIZE (MONO_DATA_SIZE * 2) #define DMASZ (FRAME_SIZE * FRAME_NUM) struct buffer { void *data; uint32_t size; uint32_t read; uint32_t addr; }; struct audio_in { struct buffer in[FRAME_NUM]; spinlock_t dsp_lock; atomic_t in_bytes; atomic_t in_samples; struct mutex lock; struct mutex read_lock; wait_queue_head_t wait; wait_queue_head_t wait_enable; struct msm_adsp_module *audrec; /* configuration to use on next enable */ uint32_t samp_rate; uint32_t channel_mode; uint32_t buffer_size; /* 2048 for mono, 4096 for stereo */ uint32_t enc_type; uint32_t dsp_cnt; uint32_t in_head; /* next buffer dsp will write */ uint32_t in_tail; /* next buffer read() will read */ uint32_t in_count; /* number of buffers available to read() */ const char *module_name; unsigned queue_ids; uint16_t enc_id; /* Session Id */ uint16_t source; /* Encoding source bit mask */ uint32_t device_events; /* device events interested in */ uint32_t dev_cnt; spinlock_t dev_lock; /* data allocated for various buffers */ char *data; dma_addr_t phys; int opened; int enabled; int running; int stopped; /* set when stopped, cleared on flush */ int abort; /* set when error, like sample rate mismatch */ }; static struct audio_in the_audio_in; struct audio_frame { uint16_t frame_count_lsw; uint16_t frame_count_msw; uint16_t frame_length; uint16_t erased_pcm; unsigned char raw_bitstream[]; /* samples */ } __attribute__((packed)); /* Audrec Queue command sent macro's */ #define <API key>(audio, cmd, len) \ msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\ cmd, len) #define <API key>(audio, cmd, len) \ msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\ cmd, len) /* DSP command send functions */ static int <API key>(struct audio_in *audio, int enable); static int <API key>(struct audio_in *audio); static int <API key>(struct audio_in *audio); static int <API key>(struct audio_in *audio, int enable); static int <API key>(struct audio_in *audio, uint32_t read_cnt); static void <API key>(struct audio_in *audio); static void audpcm_in_flush(struct audio_in *audio); static void pcm_in_listener(u32 evt_id, union auddev_evt_data *evt_payload, void *private_data) { struct audio_in *audio = (struct audio_in *) private_data; unsigned long flags; MM_DBG("evt_id = 0x%8x\n", evt_id); switch (evt_id) { case AUDDEV_EVT_DEV_RDY: { MM_DBG("AUDDEV_EVT_DEV_RDY\n"); spin_lock_irqsave(&audio->dev_lock, flags); audio->dev_cnt++; audio->source |= (0x1 << evt_payload->routing_id); <API key>(&audio->dev_lock, flags); if ((audio->running == 1) && (audio->enabled == 1)) <API key>(audio, 1); break; } case AUDDEV_EVT_DEV_RLS: { MM_DBG("AUDDEV_EVT_DEV_RLS\n"); spin_lock_irqsave(&audio->dev_lock, flags); audio->dev_cnt audio->source &= ~(0x1 << evt_payload->routing_id); <API key>(&audio->dev_lock, flags); if (!audio->running || !audio->enabled) break; /* Turn of as per source */ if (audio->source) <API key>(audio, 1); else /* Turn off all */ <API key>(audio, 0); break; } case AUDDEV_EVT_FREQ_CHG: { MM_DBG("Encoder Driver got sample rate change event\n"); MM_DBG("sample rate %d\n", evt_payload->freq_info.sample_rate); MM_DBG("dev_type %d\n", evt_payload->freq_info.dev_type); MM_DBG("acdb_dev_id %d\n", evt_payload->freq_info.acdb_dev_id); if (audio->running == 1) { /* Stop Recording sample rate does not match with device sample rate */ if (evt_payload->freq_info.sample_rate != audio->samp_rate) { <API key>(audio, 0); audio->abort = 1; wake_up(&audio->wait); } } break; } default: MM_ERR("wrong event %d\n", evt_id); break; } } static void <API key>(void *data, unsigned id, void *msg) { struct audio_in *audio = data; switch (id) { case <API key>: { struct audpreproc_err_msg *err_msg = msg; MM_ERR("ERROR_MSG: stream id %d err idx %d\n", err_msg->stream_id, err_msg->aud_preproc_err_idx); /* Error case */ wake_up(&audio->wait_enable); break; } case <API key>: { MM_DBG("CMD_CFG_DONE_MSG \n"); break; } case <API key>: { struct <API key> *enc_cfg_msg = msg; MM_DBG("<API key>: stream id %d enc type \ 0x%8x\n", enc_cfg_msg->stream_id, enc_cfg_msg->rec_enc_type); /* Encoder enable success */ if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE) <API key>(audio); else { /* Encoder disable success */ audio->running = 0; <API key>(audio, 0); } break; } case <API key>: { MM_DBG("<API key> \n"); <API key>(audio); break; } case <API key>: { MM_DBG("<API key> \n"); wake_up(&audio->wait_enable); break; } default: MM_ERR("Unknown Event id %d\n", id); } } static void audrec_dsp_event(void *data, unsigned id, size_t len, void (*getevent)(void *ptr, size_t len)) { struct audio_in *audio = data; switch (id) { case <API key>: { MM_DBG("CMD_MEM_CFG_DONE MSG DONE\n"); audio->running = 1; if (audio->dev_cnt > 0) <API key>(audio, 1); break; } case <API key>: { struct <API key> fatal_err_msg; getevent(&fatal_err_msg, <API key>); MM_ERR("FATAL_ERR_MSG: err id %d\n", fatal_err_msg.audrec_err_id); /* Error stop the encoder */ audio->stopped = 1; wake_up(&audio->wait); break; } case <API key>: { struct <API key> pkt_ready_msg; getevent(&pkt_ready_msg, <API key>); MM_DBG("UP_PACKET_READY_MSG: write cnt lsw %d \ write cnt msw %d read cnt lsw %d read cnt msw %d \n",\ pkt_ready_msg.<API key>, \ pkt_ready_msg.<API key>, \ pkt_ready_msg.<API key>, \ pkt_ready_msg.<API key>); <API key>(audio); break; } default: MM_ERR("Unknown Event id %d\n", id); } } static void <API key>(struct audio_in *audio) { struct audio_frame *frame; uint32_t index; unsigned long flags; index = audio->in_head; frame = (void *) (((char *)audio->in[index].data) - \ sizeof(*frame)); spin_lock_irqsave(&audio->dsp_lock, flags); audio->in[index].size = frame->frame_length; /* statistics of read */ atomic_add(audio->in[index].size, &audio->in_bytes); atomic_add(1, &audio->in_samples); audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1); /* If overflow, move the tail index foward. */ if (audio->in_head == audio->in_tail) audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1); else audio->in_count++; <API key>(audio, audio->dsp_cnt++); <API key>(&audio->dsp_lock, flags); wake_up(&audio->wait); } struct msm_adsp_ops audrec_adsp_ops = { .event = audrec_dsp_event, }; static int <API key>(struct audio_in *audio, int enable) { struct <API key> cmd; memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = <API key>; cmd.stream_id = audio->enc_id; if (enable) cmd.audrec_enc_type = audio->enc_type | ENCODE_ENABLE; else cmd.audrec_enc_type &= ~(ENCODE_ENABLE); return <API key>(&cmd, sizeof(cmd)); } static int <API key>(struct audio_in *audio) { struct <API key> cmd; memset(&cmd, 0, sizeof(cmd)); cmd.common.cmd_id = <API key>; cmd.common.stream_id = audio->enc_id; cmd.<API key> = audio->samp_rate; cmd.aud_rec_stereo_mode = audio->channel_mode; return <API key>(&cmd, sizeof(cmd)); } /* To Do: <API key>(audio->enc_id); */ static int <API key>(struct audio_in *audio, int enable) { struct <API key> cmd; memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = <API key>; cmd.stream_id = audio->enc_id; if (enable) cmd.<API key> = <API key>; else cmd.<API key> = <API key>; cmd.source_mix_mask = audio->source; return <API key>(&cmd, sizeof(cmd)); } static int <API key>(struct audio_in *audio) { struct <API key> cmd; uint16_t *data = (void *) audio->data; int n; memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = <API key>; cmd.<API key> = 1; cmd.<API key> = audio->phys >> 16; cmd.<API key> = audio->phys; cmd.<API key> = FRAME_NUM; /* prepare buffer pointers: * Mono: 1024 samples + 4 halfword header * Stereo: 2048 samples + 4 halfword header */ for (n = 0; n < FRAME_NUM; n++) { audio->in[n].data = data + 4; data += (4 + (audio->channel_mode ? 2048 : 1024)); MM_DBG("0x%8x\n", (int)(audio->in[n].data - 8)); } return <API key>(audio, &cmd, sizeof(cmd)); } static int <API key>(struct audio_in *audio, uint32_t read_cnt) { struct <API key> cmd; memset(&cmd, 0, sizeof(cmd)); cmd.cmd_id = <API key>; cmd.<API key> = read_cnt >> 16; cmd.<API key> = read_cnt; return <API key>(audio, &cmd, sizeof(cmd)); } /* must be called with audio->lock held */ static int audpcm_in_enable(struct audio_in *audio) { if (audio->enabled) return 0; if (audpreproc_enable(audio->enc_id, &<API key>, audio)) { MM_ERR("msm_adsp_enable(audpreproc) failed\n"); return -ENODEV; } if (msm_adsp_enable(audio->audrec)) { MM_ERR("msm_adsp_enable(audrec) failed\n"); audpreproc_disable(audio->enc_id, audio); return -ENODEV; } audio->enabled = 1; <API key>(audio, 1); return 0; } /* must be called with audio->lock held */ static int audpcm_in_disable(struct audio_in *audio) { if (audio->enabled) { audio->enabled = 0; <API key>(audio, 0); wake_up(&audio->wait); <API key>(audio->wait_enable, audio->running == 0, 1*HZ); msm_adsp_disable(audio->audrec); audpreproc_disable(audio->enc_id, audio); } return 0; } static void audpcm_in_flush(struct audio_in *audio) { int i; audio->dsp_cnt = 0; audio->in_head = 0; audio->in_tail = 0; audio->in_count = 0; for (i = 0; i < FRAME_NUM; i++) { audio->in[i].size = 0; audio->in[i].read = 0; } MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes)); MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples)); atomic_set(&audio->in_bytes, 0); atomic_set(&audio->in_samples, 0); } static long audpcm_in_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct audio_in *audio = file->private_data; int rc = 0; if (cmd == AUDIO_GET_STATS) { struct msm_audio_stats stats; stats.byte_count = atomic_read(&audio->in_bytes); stats.sample_count = atomic_read(&audio->in_samples); if (copy_to_user((void *) arg, &stats, sizeof(stats))) return -EFAULT; return rc; } mutex_lock(&audio->lock); switch (cmd) { case AUDIO_START: { uint32_t freq; /* Poll at 48KHz always */ freq = 48000; MM_DBG("AUDIO_START\n"); rc = <API key>(&freq, audio->enc_id, SNDDEV_CAP_TX, AUDDEV_CLNT_ENC); MM_DBG("sample rate configured %d sample rate requested %d\n", freq, audio->samp_rate); if (rc < 0) { MM_DBG("sample rate can not be set, return code %d\n",\ rc); <API key>(audio->enc_id, SNDDEV_CAP_TX, AUDDEV_CLNT_ENC); MM_DBG("<API key>\n"); break; } rc = audpcm_in_enable(audio); if (!rc) { rc = <API key>(audio->wait_enable, audio->running != 0, 1*HZ); MM_DBG("state %d rc = %d\n", audio->running, rc); if (audio->running == 0) rc = -ENODEV; else rc = 0; } break; } case AUDIO_STOP: { rc = audpcm_in_disable(audio); rc = <API key>(audio->enc_id, SNDDEV_CAP_TX, AUDDEV_CLNT_ENC); MM_DBG("<API key>\n"); audio->stopped = 1; audio->abort = 0; break; } case AUDIO_FLUSH: { if (audio->stopped) { /* Make sure we're stopped and we wake any threads * that might be blocked holding the read_lock. * While audio->stopped read threads will always * exit immediately. */ wake_up(&audio->wait); mutex_lock(&audio->read_lock); audpcm_in_flush(audio); mutex_unlock(&audio->read_lock); } break; } case AUDIO_SET_CONFIG: { struct msm_audio_config cfg; if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) { rc = -EFAULT; break; } if (cfg.channel_count == 1) { cfg.channel_count = <API key>; } else if (cfg.channel_count == 2) { cfg.channel_count = <API key>; } else { rc = -EINVAL; break; } audio->samp_rate = cfg.sample_rate; audio->channel_mode = cfg.channel_count; audio->buffer_size = audio->channel_mode ? STEREO_DATA_SIZE : \ MONO_DATA_SIZE; break; } case AUDIO_GET_CONFIG: { struct msm_audio_config cfg; memset(&cfg, 0, sizeof(cfg)); cfg.buffer_size = audio->buffer_size; cfg.buffer_count = FRAME_NUM; cfg.sample_rate = audio->samp_rate; if (audio->channel_mode == <API key>) cfg.channel_count = 1; else cfg.channel_count = 2; if (copy_to_user((void *) arg, &cfg, sizeof(cfg))) rc = -EFAULT; break; } case <API key>: { if (copy_to_user((void *) arg, &audio->enc_id, sizeof(unsigned short))) { rc = -EFAULT; } break; } default: rc = -EINVAL; } mutex_unlock(&audio->lock); return rc; } static ssize_t audpcm_in_read(struct file *file, char __user *buf, size_t count, loff_t *pos) { struct audio_in *audio = file->private_data; unsigned long flags; const char __user *start = buf; void *data; uint32_t index; uint32_t size; int rc = 0; mutex_lock(&audio->read_lock); while (count > 0) { rc = <API key>( audio->wait, (audio->in_count > 0) || audio->stopped || audio->abort); if (rc < 0) break; if (audio->stopped && !audio->in_count) { MM_DBG("Driver in stop state, No more buffer to read"); rc = 0;/* End of File */ break; } if (audio->abort) { rc = -EPERM; /* Not permitted due to abort */ break; } index = audio->in_tail; data = (uint8_t *) audio->in[index].data; size = audio->in[index].size; if (count >= size) { if (copy_to_user(buf, data, size)) { rc = -EFAULT; break; } spin_lock_irqsave(&audio->dsp_lock, flags); if (index != audio->in_tail) { /* overrun -- data is * invalid and we need to retry */ <API key>(&audio->dsp_lock, flags); continue; } audio->in[index].size = 0; audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1); audio->in_count <API key>(&audio->dsp_lock, flags); count -= size; buf += size; } else { MM_ERR("short read\n"); break; } } mutex_unlock(&audio->read_lock); if (buf > start) return buf - start; return rc; } static ssize_t audpcm_in_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { return -EINVAL; } static int audpcm_in_release(struct inode *inode, struct file *file) { struct audio_in *audio = file->private_data; mutex_lock(&audio->lock); /* with draw frequency for session incase not stopped the driver */ <API key>(audio->enc_id, SNDDEV_CAP_TX, AUDDEV_CLNT_ENC); <API key>(AUDDEV_CLNT_ENC, audio->enc_id); audpcm_in_disable(audio); audpcm_in_flush(audio); msm_adsp_put(audio->audrec); <API key>(audio->enc_id); audio->audrec = NULL; audio->opened = 0; mutex_unlock(&audio->lock); return 0; } static int audpcm_in_open(struct inode *inode, struct file *file) { struct audio_in *audio = &the_audio_in; int rc; int encid; mutex_lock(&audio->lock); if (audio->opened) { rc = -EBUSY; goto done; } /* Settings will be re-config at AUDIO_SET_CONFIG, * but at least we need to have initial config */ audio->channel_mode = <API key>; audio->buffer_size = MONO_DATA_SIZE; audio->samp_rate = 8000; audio->enc_type = ENC_TYPE_WAV; audio->source = <API key>; encid = <API key>(audio->enc_type, &audio->module_name, &audio->queue_ids); if (encid < 0) { MM_ERR("No free encoder available\n"); rc = -ENODEV; goto done; } audio->enc_id = encid; rc = msm_adsp_get(audio->module_name, &audio->audrec, &audrec_adsp_ops, audio); if (rc) { <API key>(audio->enc_id); goto done; } audio->stopped = 0; audio->source = 0; audio->abort = 0; audpcm_in_flush(audio); audio->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS | AUDDEV_EVT_FREQ_CHG; rc = <API key>(audio->device_events, AUDDEV_CLNT_ENC, audio->enc_id, pcm_in_listener, (void *) audio); if (rc) { MM_ERR("failed to register device event listener\n"); goto evt_error; } file->private_data = audio; audio->opened = 1; rc = 0; done: mutex_unlock(&audio->lock); return rc; evt_error: msm_adsp_put(audio->audrec); <API key>(audio->enc_id); mutex_unlock(&audio->lock); return rc; } static const struct file_operations audio_in_fops = { .owner = THIS_MODULE, .open = audpcm_in_open, .release = audpcm_in_release, .read = audpcm_in_read, .write = audpcm_in_write, .unlocked_ioctl = audpcm_in_ioctl, }; struct miscdevice audio_in_misc = { .minor = MISC_DYNAMIC_MINOR, .name = "msm_pcm_in", .fops = &audio_in_fops, }; static int __init audpcm_in_init(void) { the_audio_in.data = dma_alloc_coherent(NULL, DMASZ, &the_audio_in.phys, GFP_KERNEL); MM_DBG("Memory addr = 0x%8x phy addr = 0x%8x (int) the_audio_in.data, (int) the_audio_in.phys); if (!the_audio_in.data) { MM_ERR("Unable to allocate DMA buffer\n"); return -ENOMEM; } mutex_init(&the_audio_in.lock); mutex_init(&the_audio_in.read_lock); spin_lock_init(&the_audio_in.dsp_lock); spin_lock_init(&the_audio_in.dev_lock); init_waitqueue_head(&the_audio_in.wait); init_waitqueue_head(&the_audio_in.wait_enable); return misc_register(&audio_in_misc); } device_initcall(audpcm_in_init);
table, th, td {border: 1px solid black; border-collapse: collapse} .right {text-align: right} tr.even {background-color: #FFEEEE} td.right {text-align: right} a {color: #880000; text-decoration: none} a:hover {background-color:#FFCCCC} tr.click:hover {background-color:#FFCCCC} img.right {float: right} div.bar {background-color: #EEEEEE; width: 100%; padding: 10px; border: 1px solid black}
(function () { "use strict"; /* * Utility functions */ function floatEqual (f1, f2) { return (Math.abs(f1 - f2) < 0.000001); } /* * Create the model in a self-contained class where map-specific logic is * done. This model will be used in the directive. */ var MapModel = (function () { var _defaults = { zoom: 8, draggable: false, container: null }; function PrivateMapModel(opts) { var _instance = null, _markers = [], // caches the instances of google.maps.Marker _handlers = [], // event handlers _windows = [], // InfoWindow objects o = angular.extend({}, _defaults, opts), that = this, currentInfoWindow = null; this.center = opts.center; this.zoom = o.zoom; this.draggable = o.draggable; this.dragging = false; this.selector = o.container; this.markers = []; this.options = o.options; this.draw = function () { if (that.center == null) { // TODO log error return; } if (_instance == null) { // Create a new map instance _instance = new google.maps.Map(that.selector, angular.extend(that.options, { center: that.center, zoom: that.zoom, draggable: that.draggable, mapTypeId : google.maps.MapTypeId.ROADMAP })); google.maps.event.addListener(_instance, "dragstart", function () { that.dragging = true; } ); google.maps.event.addListener(_instance, "idle", function () { that.dragging = false; } ); google.maps.event.addListener(_instance, "drag", function () { that.dragging = true; } ); google.maps.event.addListener(_instance, "zoom_changed", function () { that.zoom = _instance.getZoom(); that.center = _instance.getCenter(); } ); google.maps.event.addListener(_instance, "center_changed", function () { that.center = _instance.getCenter(); } ); // Attach additional event listeners if needed if (_handlers.length) { angular.forEach(_handlers, function (h, i) { google.maps.event.addListener(_instance, h.on, h.handler); }); } } else { // Refresh the existing instance google.maps.event.trigger(_instance, "resize"); var instanceCenter = _instance.getCenter(); if (!floatEqual(instanceCenter.lat(), that.center.lat()) || !floatEqual(instanceCenter.lng(), that.center.lng())) { _instance.setCenter(that.center); } if (_instance.getZoom() != that.zoom) { _instance.setZoom(that.zoom); } } }; this.fit = function () { if (_instance && _markers.length) { var bounds = new google.maps.LatLngBounds(); angular.forEach(_markers, function (m, i) { bounds.extend(m.getPosition()); }); _instance.fitBounds(bounds); } }; this.on = function(event, handler) { _handlers.push({ "on": event, "handler": handler }); }; this.addMarker = function (lat, lng, icon, infoWindowContent, label, url, thumbnail) { if (that.findMarker(lat, lng) != null) { return; } var marker = new google.maps.Marker({ position: new google.maps.LatLng(lat, lng), map: _instance, icon: icon }); if (label) { } if (url) { } if (infoWindowContent != null) { var infoWindow = new google.maps.InfoWindow({ content: infoWindowContent }); google.maps.event.addListener(marker, 'click', function() { if (currentInfoWindow != null) { currentInfoWindow.close(); } infoWindow.open(_instance, marker); currentInfoWindow = infoWindow; }); } // Cache marker _markers.unshift(marker); // Cache instance of our marker for scope purposes that.markers.unshift({ "lat": lat, "lng": lng, "draggable": false, "icon": icon, "infoWindowContent": infoWindowContent, "label": label, "url": url, "thumbnail": thumbnail }); // Return marker instance return marker; }; this.findMarker = function (lat, lng) { for (var i = 0; i < _markers.length; i++) { var pos = _markers[i].getPosition(); if (floatEqual(pos.lat(), lat) && floatEqual(pos.lng(), lng)) { return _markers[i]; } } return null; }; this.findMarkerIndex = function (lat, lng) { for (var i = 0; i < _markers.length; i++) { var pos = _markers[i].getPosition(); if (floatEqual(pos.lat(), lat) && floatEqual(pos.lng(), lng)) { return i; } } return -1; }; this.addInfoWindow = function (lat, lng, html) { var win = new google.maps.InfoWindow({ content: html, position: new google.maps.LatLng(lat, lng) }); _windows.push(win); return win; }; this.hasMarker = function (lat, lng) { return that.findMarker(lat, lng) !== null; }; this.getMarkerInstances = function () { return _markers; }; this.removeMarkers = function (markerInstances) { var s = this; angular.forEach(markerInstances, function (v, i) { var pos = v.getPosition(), lat = pos.lat(), lng = pos.lng(), index = s.findMarkerIndex(lat, lng); // Remove from local arrays _markers.splice(index, 1); s.markers.splice(index, 1); // Remove from map v.setMap(null); }); }; } // Done return PrivateMapModel; }()); // End model // Start Angular directive var googleMapsModule = angular.module("google-maps", []); /** * Map directive */ googleMapsModule.directive("googleMap", ["$log", "$timeout", "$filter", function ($log, $timeout, $filter) { var controller = function ($scope, $element) { var _m = $scope.map; self.addInfoWindow = function (lat, lng, content) { _m.addInfoWindow(lat, lng, content); }; }; controller.$inject = ['$scope', '$element']; return { restrict: "EC", priority: 100, transclude: true, template: "<div class='angular-google-map' ng-transclude></div>", replace: false, scope: { center: "=center", // required markers: "=markers", // optional latitude: "=latitude", // required longitude: "=longitude", // required zoom: "=zoom", // required refresh: "&refresh", // optional windows: "=windows" // optional" }, controller: controller, link: function (scope, element, attrs, ctrl) { // Center property must be specified and provide lat & // lng properties if (!angular.isDefined(scope.center) || (!angular.isDefined(scope.center.lat) || !angular.isDefined(scope.center.lng))) { $log.error("angular-google-maps: ould not find a valid center property"); return; } if (!angular.isDefined(scope.zoom)) { $log.error("angular-google-maps: map zoom property not set"); return; } angular.element(element).addClass("angular-google-map"); // Parse options var opts = {options: {}}; if (attrs.options) { opts.options = angular.fromJson(attrs.options); } // Create our model var _m = new MapModel(angular.extend(opts, { container: element[0], center: new google.maps.LatLng(scope.center.lat, scope.center.lng), draggable: attrs.draggable == "true", zoom: scope.zoom })); _m.on("drag", function () { var c = _m.center; $timeout(function () { scope.$apply(function (s) { scope.center.lat = c.lat(); scope.center.lng = c.lng(); }); }); }); _m.on("zoom_changed", function () { if (scope.zoom != _m.zoom) { $timeout(function () { scope.$apply(function (s) { scope.zoom = _m.zoom; }); }); } }); _m.on("center_changed", function () { var c = _m.center; $timeout(function () { scope.$apply(function (s) { if (!_m.dragging) { scope.center.lat = c.lat(); scope.center.lng = c.lng(); } }); }); }); if (attrs.markClick == "true") { (function () { var cm = null; _m.on("click", function (e) { if (cm == null) { cm = { latitude: e.latLng.lat(), longitude: e.latLng.lng() }; scope.markers.push(cm); } else { cm.latitude = e.latLng.lat(); cm.longitude = e.latLng.lng(); } $timeout(function () { scope.latitude = cm.latitude; scope.longitude = cm.longitude; scope.$apply(); }); }); }()); } // Put the map into the scope scope.map = _m; // Check if we need to refresh the map if (angular.isUndefined(scope.refresh())) { // No refresh property given; draw the map immediately _m.draw(); } else { scope.$watch("refresh()", function (newValue, oldValue) { if (newValue && !oldValue) { _m.draw(); } }); } // Markers scope.$watch("markers", function (newValue, oldValue) { $timeout(function () { angular.forEach(newValue, function (v, i) { if (!_m.hasMarker(v.latitude, v.longitude)) { _m.addMarker(v.latitude, v.longitude, v.icon, v.infoWindow); } }); // Clear orphaned markers var orphaned = []; angular.forEach(_m.getMarkerInstances(), function (v, i) { // Check our scope if a marker with equal latitude and longitude. // If not found, then that marker has been removed form the scope. var pos = v.getPosition(), lat = pos.lat(), lng = pos.lng(), found = false; // Test against each marker in the scope for (var si = 0; si < scope.markers.length; si++) { var sm = scope.markers[si]; if (floatEqual(sm.latitude, lat) && floatEqual(sm.longitude, lng)) { // Map marker is present in scope too, don't remove found = true; } } // Marker in map has not been found in scope. Remove. if (!found) { orphaned.push(v); } }); orphaned.length && _m.removeMarkers(orphaned); // Fit map when there are more than one marker. // This will change the map center coordinates if (attrs.fit == "true" && newValue.length > 1) { _m.fit(); } }); }, true); // Update map when center coordinates change scope.$watch("center", function (newValue, oldValue) { if (newValue === oldValue) { return; } if (!_m.dragging) { _m.center = new google.maps.LatLng(newValue.lat, newValue.lng); _m.draw(); } }, true); scope.$watch("zoom", function (newValue, oldValue) { if (newValue === oldValue) { return; } _m.zoom = newValue; _m.draw(); }); } }; }]); }());
<?php die("Access Denied"); ?>#x#s:4516:" 1448241693 <!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <script type="text/javascript"> var siteurl='/'; var tmplurl='/templates/ja_mendozite/'; var isRTL = false; </script> <base href="http: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="generator" content="" /> <title> | </title> <link href="http: <link rel="stylesheet" href="/t3-assets/css_9ce88.css" type="text/css" /> <link rel="stylesheet" href="/t3-assets/css_31cec.css" type="text/css" /> <script src="/en/?jat3action=gzip&amp;jat3type=js&amp;jat3file=t3-assets%2Fjs_7f13c.js" type="text/javascript"></script> <script type="text/javascript"> function keepAlive() { var myAjax = new Request({method: "get", url: "index.php"}).send();} window.addEvent("domready", function(){ keepAlive.periodical(840000); }); </script> <script type="text/javascript"> var akoption = { "colorTable" : true , "opacityEffect" : true , "foldContent" : true , "fixingElement" : true , "smoothScroll" : false } ; var akconfig = new Object(); akconfig.root = 'http: akconfig.host = 'http://'+location.host+'/' ; AsikartEasySet.init( akoption , akconfig ); </script> <link href="/plugins/system/jat3/jat3/base-themes/default/images/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <script> (function(i,s,o,g,r,a,m){i['<API key>']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.<API key>(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script',' ga('create', 'UA-60602086-1', 'auto'); ga('send', 'pageview'); </script> <link rel="stylesheet" href="http: <link rel="stylesheet" href="http: </head> <body id="bd" class="fs3 com_mailto contentpane"> <div id="<API key>"> <div id="system-message"> </div> </div> <script type="text/javascript"> Joomla.submitbutton = function(pressbutton) { var form = document.getElementById('mailtoForm'); // do field validation if (form.mailto.value == "" || form.from.value == "") { alert(''); return false; } form.submit(); } </script> <div id="mailto-window"> <h2> </h2> <div class="mailto-close"> <a href="javascript: void window.close()" title=""> <span> </span></a> </div> <form action="http: <div class="formelm"> <label for="mailto_field"></label> <input type="text" id="mailto_field" name="mailto" class="inputbox" size="25" value=""/> </div> <div class="formelm"> <label for="sender_field"> </label> <input type="text" id="sender_field" name="sender" class="inputbox" value="" size="25" /> </div> <div class="formelm"> <label for="from_field"> </label> <input type="text" id="from_field" name="from" class="inputbox" value="" size="25" /> </div> <div class="formelm"> <label for="subject_field"> </label> <input type="text" id="subject_field" name="subject" class="inputbox" value="" size="25" /> </div> <p> <button class="button" onclick="return Joomla.submitbutton('send');"> </button> <button class="button" onclick="window.close();return false;"> </button> </p> <input type="hidden" name="layout" value="default" /> <input type="hidden" name="option" value="com_mailto" /> <input type="hidden" name="task" value="send" /> <input type="hidden" name="tmpl" value="component" /> <input type="hidden" name="link" value="<SHA1-like>" /> <input type="hidden" name="<API key>" value="1" /> </form> </div> </body> </html>";
<?php foreach ($content as $key => $value): ?> <div class="product-item-viewed product-node-id-<?php print $key; ?>"> <?php print l($value['title'], $value['path']); ?> <?php if (isset($value['image'])): ?> <div class='image-viewed'><img src='<?php print $value['image']; ?>' /></div> <?php endif; ?> </div> <?php endforeach; ?>
package kieranvs.avatar.bending.earth; import java.util.Arrays; import java.util.concurrent.ConcurrentHashMap; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import kieranvs.avatar.Protection; import kieranvs.avatar.bending.Ability; import kieranvs.avatar.bending.AsynchronousAbility; import kieranvs.avatar.bukkit.BlockBukkit; import kieranvs.avatar.bukkit.Location; import kieranvs.avatar.bukkit.Vector; import kieranvs.avatar.util.AvatarDamageSource; import kieranvs.avatar.util.BendingUtils; public class EarthStream extends AsynchronousAbility { private long interval = 200L; private long risetime = 600L; private ConcurrentHashMap<BlockBukkit, Long> movedBlocks = new ConcurrentHashMap<BlockBukkit, Long>(); private Location origin; private Location location; private Vector direction; private int range; private long time; private boolean finished = false; public EarthStream(EntityLivingBase user, Location location, Vector direction, int range) { super(user, 2000); this.time = System.currentTimeMillis(); this.range = range; this.origin = location.clone(); this.location = location.clone(); this.direction = direction.clone(); this.direction.setY(0); this.direction.normalize(); this.location.add(this.direction); } @Override public void update() { for (BlockBukkit block : movedBlocks.keySet()) { long time = movedBlocks.get(block).longValue(); if (System.currentTimeMillis() > time + risetime) { Protection.trySetBlock(user.worldObj, Blocks.air, block.getRelative(BlockBukkit.UP).getX(), block.getRelative(BlockBukkit.UP).getY(), block.getRelative(BlockBukkit.UP).getZ()); movedBlocks.remove(block); } } if (finished) { if (movedBlocks.isEmpty()) { destroy(); } else { return; } } if (System.currentTimeMillis() - time >= interval) { time = System.currentTimeMillis(); location.add(direction); if (location.distance(origin) > range) { finished = true; return; } BlockBukkit block = this.location.getBlock(); if (isMoveable(block)) { moveBlock(block); } if (isMoveable(block.getRelative(BlockBukkit.DOWN))) { moveBlock(block.getRelative(BlockBukkit.DOWN)); location = block.getRelative(BlockBukkit.DOWN).getLocation(); return; } if (isMoveable(block.getRelative(BlockBukkit.UP))) { moveBlock(block.getRelative(BlockBukkit.UP)); location = block.getRelative(BlockBukkit.UP).getLocation(); return; } else { finished = true; } return; } } public void moveBlock(BlockBukkit block) { // block.getRelative(Block.UP).breakNaturally(); //block.getRelative(Block.UP).setType(block.getType()); //movedBlocks.put(block, System.currentTimeMillis()); //damageEntities(block.getLocation()); //BendingUtils.damageEntities(block.getLocation(), 3.5F, AvatarDamageSource.earthbending, 3); Protection.trySetBlock(user.worldObj, Blocks.dirt, block.getRelative(BlockBukkit.UP).getX(), block.getRelative(BlockBukkit.UP).getY(), block.getRelative(BlockBukkit.UP).getZ()); movedBlocks.put(block, System.currentTimeMillis()); } public void damageEntities(Location loc) { for (Object o : loc.getWorld().getLoadedEntityList()) { if (o instanceof EntityLivingBase) { EntityLivingBase e = (EntityLivingBase) o; if (loc.distance(e) < 3.5) { e.attackEntityFrom(AvatarDamageSource.earthbending, 3); } } } } public static boolean isMoveable(BlockBukkit block) { Block[] overwriteable = { Blocks.air, Blocks.sapling, Blocks.tallgrass, Blocks.deadbush, Blocks.yellow_flower, Blocks.red_flower, Blocks.brown_mushroom, Blocks.red_mushroom, Blocks.fire, Blocks.snow, Blocks.torch, Blocks.leaves, Blocks.cactus, Blocks.reeds, Blocks.web, Blocks.waterlily, Blocks.vine }; if (!Arrays.asList(overwriteable).contains(block.getRelative(BlockBukkit.UP).getType())) { return false; } Block[] moveable = { Blocks.brick_block, Blocks.clay, Blocks.coal_ore, Blocks.cobblestone, Blocks.dirt, Blocks.grass, Blocks.gravel, Blocks.mossy_cobblestone, Blocks.mycelium, Blocks.nether_brick, Blocks.netherrack, Blocks.obsidian, Blocks.sand, Blocks.sandstone, Blocks.farmland, Blocks.soul_sand, Blocks.stone }; if (Arrays.asList(moveable).contains(block.getType())) { return true; } return false; } }
#include <iostream> #include <stdint.h> #include <map> #include <set> #include "macros.h" #include <assert.h> using namespace std; #include <fstream> struct defsetcmp { bool operator() (const pair<uint64_t, uint64_t> &l, const pair<uint64_t, uint64_t> &r) { return (l.first < r.first || l.second < r.second); } }; int main(int argc, char *argv[]) { if (argc != 2) { cerr << "Usage: ./parse file" << endl; return(1); } ifstream inFile(argv[1]); map<uint64_t, uint64_t> latestWrite; typedef map<pair<uint64_t, uint64_t>, set<uint64_t>, defsetcmp> defsett; defsett defset; map<uint64_t, bool> localread; map<uint64_t, bool> nonlocalread; map<uint64_t, uint64_t> ins2tid; map<uint64_t, map<uint64_t, bool> > has_read; map<uint64_t, bool> follower; while (inFile.good()) { uint64_t ins, tid, rw, addr; inFile >> ins >> tid >> rw >> addr; if (ins == END && addr == END) { latestWrite.clear(); ins2tid.clear(); has_read.clear(); } else if (rw == READ) { ins2tid[ins] = tid; //if there are no writes to current variable yet then continue if (latestWrite.find(addr) == latestWrite.end()) { continue; } uint64_t latestWriteIns = latestWrite[addr]; //defset defset[make_pair(addr,ins)].insert(latestWriteIns); //local non-local bool isLocal = (tid == ins2tid[latestWriteIns]); if (localread.find(ins) == localread.end()) { localread[ins] = isLocal; nonlocalread[ins] = !isLocal; } else { localread[ins] = localread[ins] && isLocal; nonlocalread[ins] = nonlocalread[ins] && !isLocal; } //follower if (has_read.find(addr) != has_read.end() && has_read[addr].find(tid) != has_read[addr].end()) { if (follower.find(ins) != follower.end()) { follower[ins] = follower[ins] && has_read[addr][tid]; } else { follower[ins] = has_read[addr][tid]; } } has_read[addr][tid] = true; } else { assert(rw == WRITE); ins2tid[ins] = tid; latestWrite[addr] = ins; if(has_read.find(addr) != has_read.end()) { for(map<uint64_t, bool>::iterator titr = has_read[addr].begin(); titr != has_read[addr].end(); ++titr) { titr->second = false; } } } } inFile.close(); //print defset //variable read_ins_addr #writes write_ins_add0 ... for (defsett::const_iterator defsetitr = defset.begin(); defsetitr != defset.end(); ++defsetitr) { cout << defsetitr->first.first << " " << defsetitr->first.second << " "; cout << (defsetitr->second).size() << " "; for (set<uint64_t>::const_iterator witr = (defsetitr->second).begin(); witr != (defsetitr->second).end(); ++witr) { cout << *witr << " "; } cout << endl; } //print local and non local cout << "#local: " << endl; for(map<uint64_t, bool>::const_iterator litr = localread.begin(); litr != localread.end(); ++litr) { if (litr->second) { cout << litr->first << endl; } } cout << "#nonlocal: " << endl; for(map<uint64_t, bool>::const_iterator nlitr = nonlocalread.begin(); nlitr != nonlocalread.end(); ++nlitr) { if (nlitr->second) { cout << nlitr->first << endl; } } //print follower cout << "#follower: " << endl; for(map<uint64_t, bool>::const_iterator fitr = follower.begin(); fitr != follower.end(); ++fitr) { if (fitr->second) { cout << fitr->first << endl; } } return 0; }
#include <qdragobject.h> #include <qstring.h> #include <qstringlist.h> #include <kglobal.h> #include <kiconloader.h> #include <kmimetype.h> #include <klocale.h> #include <kdesktopfile.h> #include <kglobalsettings.h> #include <kapplication.h> #include <kurldrag.h> #include <krecentdocument.h> #include "recentdocsmenu.h" <API key>(recentdocs, RecentDocsMenu) RecentDocsMenu::RecentDocsMenu(QWidget *parent, const char *name, const QStringList &/*args*/) : KPanelMenu(KRecentDocument::<API key>(), parent, name) { } RecentDocsMenu::~RecentDocsMenu() { } void RecentDocsMenu::initialize() { if (initialized()) clear(); insertItem(SmallIconSet("history_clear"), i18n("Clear History"), this, SLOT(slotClearHistory())); insertSeparator(); _fileList = KRecentDocument::recentDocuments(); if (_fileList.isEmpty()) { insertItem(i18n("No Entries"), 0); setItemEnabled(0, false); return; } int id = 0; char <API key>; QStringList previousEntries; for (QStringList::ConstIterator it = _fileList.begin(); it != _fileList.end(); ++it) { KDesktopFile f(*it, true /* read only */); // Make sure this entry is not already present in the menu <API key> = 0; for ( QStringList::Iterator previt = previousEntries.begin(); previt != previousEntries.end(); ++previt ) { if (QString::localeAwareCompare(*previt, f.readName().replace('&', QString::fromAscii("&&") )) == 0) { <API key> = 1; } } if (<API key> == 0) { // Add item to menu insertItem(SmallIconSet(f.readIcon()), f.readName().replace('&', QString::fromAscii("&&") ), id++); // Append to duplicate checking list previousEntries.append(f.readName().replace('&', QString::fromAscii("&&") )); } } setInitialized(true); } void RecentDocsMenu::slotClearHistory() { KRecentDocument::clear(); reinitialize(); } void RecentDocsMenu::slotExec(int id) { if (id >= 0) { kapp-><API key>(); KURL u; u.setPath(_fileList[id]); KDEDesktopMimeType::run(u, true); } } void RecentDocsMenu::mousePressEvent(QMouseEvent* e) { _mouseDown = e->pos(); QPopupMenu::mousePressEvent(e); } void RecentDocsMenu::mouseMoveEvent(QMouseEvent* e) { KPanelMenu::mouseMoveEvent(e); if (!(e->state() & LeftButton)) return; if (!rect().contains(_mouseDown)) return; int dragLength = (e->pos() - _mouseDown).manhattanLength(); if (dragLength <= KGlobalSettings::dndEventDelay()) return; // ignore it int id = idAt(_mouseDown); // Don't drag 'manual' items. if (id < 0) return; KDesktopFile f(_fileList[id], true /* read only */); KURL url ( f.readURL() ); if (url.isEmpty()) // What are we to do ? return; KURL::List lst; lst.append(url); KURLDrag* d = new KURLDrag(lst, this); d->setPixmap(SmallIcon(f.readIcon())); d->dragCopy(); close(); } void RecentDocsMenu::slotAboutToShow() { reinitialize(); KPanelMenu::slotAboutToShow(); } #include "recentdocsmenu.moc"
import numpy as np from OpenGL.GL import * from OpenGL.GLU import * import time import freenect import calibkinect import pykinectwindow as wxwindow # I probably need more help with these! try: TEXTURE_TARGET = <API key> except: TEXTURE_TARGET = <API key> if not 'win' in globals(): win = wxwindow.Window(size=(640, 480)) def refresh(): win.Refresh() print type(win) if not 'rotangles' in globals(): rotangles = [0,0] if not 'zoomdist' in globals(): zoomdist = 1 if not 'projpts' in globals(): projpts = (None, None) if not 'rgb' in globals(): rgb = None def create_texture(): global rgbtex rgbtex = glGenTextures(1) glBindTexture(TEXTURE_TARGET, rgbtex) glTexImage2D(TEXTURE_TARGET,0,GL_RGB,640,480,0,GL_RGB,GL_UNSIGNED_BYTE,None) if not '_mpos' in globals(): _mpos = None @win.eventx def EVT_LEFT_DOWN(event): global _mpos _mpos = event.Position @win.eventx def EVT_LEFT_UP(event): global _mpos _mpos = None @win.eventx def EVT_MOTION(event): global _mpos if event.LeftIsDown(): if _mpos: (x,y),(mx,my) = event.Position,_mpos rotangles[0] += y-my rotangles[1] += x-mx refresh() _mpos = event.Position @win.eventx def EVT_MOUSEWHEEL(event): global zoomdist dy = event.WheelRotation zoomdist *= np.power(0.95, -dy) refresh() clearcolor = [0,0,0,0] @win.event def on_draw(): if not 'rgbtex' in globals(): create_texture() xyz, uv = projpts if xyz is None: return if not rgb is None: rgb_ = (rgb.astype(np.float32) * 4 + 70).clip(0,255).astype(np.uint8) glBindTexture(TEXTURE_TARGET, rgbtex) glTexSubImage2D(TEXTURE_TARGET, 0, 0, 0, 640, 480, GL_RGB, GL_UNSIGNED_BYTE, rgb_); glClearColor(*clearcolor) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glEnable(GL_DEPTH_TEST) # flush that stack in case it's broken from earlier glPushMatrix() glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60, 4/3., 0.3, 200) glMatrixMode(GL_MODELVIEW) glLoadIdentity() def mouse_rotate(xAngle, yAngle, zAngle): glRotatef(xAngle, 1.0, 0.0, 0.0); glRotatef(yAngle, 0.0, 1.0, 0.0); glRotatef(zAngle, 0.0, 0.0, 1.0); glScale(zoomdist,zoomdist,1) glTranslate(0, 0,-3.5) mouse_rotate(rotangles[0], rotangles[1], 0); glTranslate(0,0,1.5) #glTranslate(0, 0,-1) # Draw some axes if 0: glBegin(GL_LINES) glColor3f(1,0,0); glVertex3f(0,0,0); glVertex3f(1,0,0) glColor3f(0,1,0); glVertex3f(0,0,0); glVertex3f(0,1,0) glColor3f(0,0,1); glVertex3f(0,0,0); glVertex3f(0,0,1) glEnd() # We can either project the points ourselves, or embed it in the opengl matrix if 0: dec = 4 v,u = mgrid[:480,:640].astype(np.uint16) points = np.vstack((u[::dec,::dec].flatten(), v[::dec,::dec].flatten(), depth[::dec,::dec].flatten())).transpose() points = points[points[:,2]<2047,:] glMatrixMode(GL_TEXTURE) glLoadIdentity() glMultMatrixf(calibkinect.uv_matrix().transpose()) glMultMatrixf(calibkinect.xyz_matrix().transpose()) glTexCoordPointers(np.array(points)) glMatrixMode(GL_MODELVIEW) glPushMatrix() glMultMatrixf(calibkinect.xyz_matrix().transpose()) glVertexPointers(np.array(points)) else: glMatrixMode(GL_TEXTURE) glLoadIdentity() glMatrixMode(GL_MODELVIEW) glPushMatrix() glVertexPointerf(xyz) glTexCoordPointerf(uv) # Draw the points glPointSize(2) glEnableClientState(GL_VERTEX_ARRAY) glEnableClientState(<API key>) glEnable(TEXTURE_TARGET) glColor3f(1,1,1) glDrawElementsui(GL_POINTS, np.array(range(xyz.shape[0]))) <API key>(GL_VERTEX_ARRAY) <API key>(<API key>) glDisable(TEXTURE_TARGET) glPopMatrix() if 0: inds = np.nonzero(xyz[:,2]>-0.55) glPointSize(10) glColor3f(0,1,1) glEnableClientState(GL_VERTEX_ARRAY) glDrawElementsui(GL_POINTS, np.array(inds)) <API key>(GL_VERTEX_ARRAY) if 0: # Draw only the points in the near plane glBlendFunc(GL_SRC_ALPHA,<API key>) glEnable(GL_BLEND) glColor(0.9,0.9,1.0,0.8) glPushMatrix() glTranslate(0,0,-0.55) glScale(0.6,0.6,1) glBegin(GL_QUADS) glVertex3f(-1,-1,0); glVertex3f( 1,-1,0); glVertex3f( 1, 1,0); glVertex3f(-1, 1,0); glEnd() glPopMatrix() glDisable(GL_BLEND) glPopMatrix() # A silly loop that shows you can busy the ipython thread while opengl runs def playcolors(): while 1: global clearcolor clearcolor = [np.random.random(),0,0,0] time.sleep(0.1) refresh() # Update the point cloud from the shell or from a background thread! def update(dt=0): global projpts, rgb, depth depth,_ = freenect.sync_get_depth() rgb,_ = freenect.sync_get_video() q = depth X,Y = np.meshgrid(range(640),range(480)) # YOU CAN CHANGE THIS AND RERUN THE PROGRAM! # Point cloud downsampling d = 4 projpts = calibkinect.depth2xyzuv(q[::d,::d],X[::d,::d],Y[::d,::d]) refresh() def update_join(): update_on() try: _thread.join() except: update_off() def update_on(): global _updating if not '_updating' in globals(): _updating = False if _updating: return _updating = True from threading import Thread global _thread def _run(): while _updating: update() _thread = Thread(target=_run) _thread.start() def update_off(): global _updating _updating = False # Get frames in a loop and display with opencv def loopcv(): import cv while 1: cv.ShowImage('hi',get_depth().astype(np.uint8)) cv.WaitKey(10) update() #update_on()
/* 480*/ /* #programList .weak, #programList #found{ display: none !important; } */ .list > li .content{ padding:10px; height: 116px; /*border: 1px solid rgba(0, 0, 0, 0.05);*/ } @media (max-width: 480px) { .list > li{ width:100%; margin-right:0px; } .catagories{ margin-left: -8px; } } .avatar { max-width: 150px; } img { max-width: 100%; } h3 { font-size: 16px; margin:0 0 0.3rem; font-weight: normal; font-weight:bold; } p { margin:0; } input { border:solid 1px #ccc; border-radius: 5px; padding:7px 14px; margin-bottom:10px } input:focus { outline:none; border-color:#aaa; } .sort { padding:8px 30px; border-radius: 6px; border:none; display:inline-block; color:#fff; text-decoration: none; background-color: #DDE028; height:30px; } .sort:hover { text-decoration: none; background-color:#1b8aba; } .sort:focus { outline:none; } .sort:after { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 5px solid transparent; content:""; position: relative; top:-10px; right:-5px; } .sort.asc:after { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 5px solid #fff; content:""; position: relative; top:13px; right:-5px; } .sort.desc:after { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 5px solid #fff; content:""; position: relative; top:-10px; right:-5px; } #question{ text-align: center; min-height: 50vh; } #programs{ display: none; } #change{ color:#DDE028; text-decoration: underline; } /*MULTI SELECT STUFF*/ .list { font-family:sans-serif; margin:0; /*padding:20px 0 0;*/ } .list > li { display:block; background-color: #eee; /*padding:10px;*/ box-shadow: inset 0 1px 0 #fff; } .avatar { max-width: 150px; } img { max-width: 100%; } h3 { font-size: 16px; margin:0 0 0.3rem; font-weight: normal; font-weight:bold; } p { margin:0; } input { border:solid 1px #ccc; border-radius: 5px; padding:7px 14px; margin-bottom:10px } input:focus { outline:none; border-color:#aaa; } .sort { padding:8px 30px; border-radius: 6px; border:none; display:inline-block; color:#fff; text-decoration: none; background-color: #DDE028; height:30px; } .sort:hover { text-decoration: none; background-color:#E0D228; } .sort:focus { outline:none; } .sort:after { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 5px solid transparent; content:""; position: relative; top:-10px; right:-5px; } .sort.asc:after { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 5px solid #fff; content:""; position: relative; top:13px; right:-5px; } .sort.desc:after { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 5px solid #fff; content:""; position: relative; top:-10px; right:-5px; } #catagories, .search{ float:left !important; /*margin-top:1rem;*/ } .search{ margin-right:2rem; } #programList{ display: none; } #programList .content{ padding: .5rem 0rem .5rem 1rem !important; } #programList .content *{ display: inline-block; } #programList ul.list{ padding-left: 0rem !important; } #programList thead td{ padding: 0px 0px 0px 0px; } #programList td .sort{ border-radius: 0; width: 100%; box-sizing: border-box; padding-left: .75rem; border: 0PX; FONT-WEIGHT: 700; TEXT-TRANSFORM: UPPERCASE } #catagories{ margin-right:0px !important; } .ms-choice{ width: 307px; } .ms-drop.bottom ul{ width: 307px; box-sizing:border-box; padding-left:1rem; }
using GitHubWin8Phone.Resources; namespace GitHubWin8Phone { <summary> Provides access to string resources. </summary> public class LocalizedStrings { private static AppResources _localizedResources = new AppResources(); public AppResources LocalizedResources { get { return _localizedResources; } } } }
#include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/io.h> #include <linux/delay.h> #include <linux/mutex.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/cpufreq.h> #include <linux/cpu.h> #include <linux/console.h> #include <linux/regulator/consumer.h> #include <asm/mach-types.h> #include <asm/cpu.h> #include <mach/board.h> #include <mach/msm_iomap.h> #include <mach/socinfo.h> #include <mach/<API key>.h> #include <mach/rpm-regulator.h> #include <mach/rpm-regulator-smd.h> #include <mach/msm_bus.h> #include <mach/msm_dcvs.h> #include "acpuclock.h" #include "acpuclock-krait.h" #include "avs.h" #ifdef <API key> #include <mach/sec_debug.h> #endif /* MUX source selects. */ #define PRI_SRC_SEL_SEC_SRC 0 #define PRI_SRC_SEL_HFPLL 1 #define <API key> 2 #define SECCLKAGD BIT(4) #ifdef <API key> int boost_uv; int speed_bin; int pvs_bin; #endif static DEFINE_MUTEX(driver_lock); static DEFINE_SPINLOCK(l2_lock); static struct drv_data { struct acpu_level *acpu_freq_tbl; const struct l2_level *l2_freq_tbl; struct scalable *scalable; struct hfpll_data *hfpll_data; u32 bus_perf_client; struct msm_bus_scale_pdata *bus_scale; int boost_uv; struct device *dev; } drv; static unsigned long <API key>(int cpu) { return drv.scalable[cpu].cur_speed->khz; } /* Select a source on the primary MUX. */ static void set_pri_clk_src(struct scalable *sc, u32 pri_src_sel) { u32 regval; regval = get_l2_indirect_reg(sc->l2cpmr_iaddr); regval &= ~0x3; regval |= (pri_src_sel & 0x3); set_l2_indirect_reg(sc->l2cpmr_iaddr, regval); /* Wait for switch to complete. */ mb(); udelay(1); } /* Select a source on the secondary MUX. */ static void __cpuinit set_sec_clk_src(struct scalable *sc, u32 sec_src_sel) { u32 regval; /* 8064 Errata: disable sec_src clock gating during switch. */ regval = get_l2_indirect_reg(sc->l2cpmr_iaddr); regval |= SECCLKAGD; set_l2_indirect_reg(sc->l2cpmr_iaddr, regval); /* Program the MUX */ regval &= ~(0x3 << 2); regval |= ((sec_src_sel & 0x3) << 2); set_l2_indirect_reg(sc->l2cpmr_iaddr, regval); /* 8064 Errata: re-enabled sec_src clock gating. */ regval &= ~SECCLKAGD; set_l2_indirect_reg(sc->l2cpmr_iaddr, regval); /* Wait for switch to complete. */ mb(); udelay(1); } static int enable_rpm_vreg(struct vreg *vreg) { int ret = 0; if (vreg->rpm_reg) { ret = <API key>(vreg->rpm_reg); if (ret) dev_err(drv.dev, "%s regulator enable failed (%d)\n", vreg->name, ret); } return ret; } static void disable_rpm_vreg(struct vreg *vreg) { int rc; if (vreg->rpm_reg) { rc = <API key>(vreg->rpm_reg); if (rc) dev_err(drv.dev, "%s regulator disable failed (%d)\n", vreg->name, rc); } } /* Enable an already-configured HFPLL. */ static void hfpll_enable(struct scalable *sc, bool skip_regulators) { if (!skip_regulators) { /* Enable regulators required by the HFPLL. */ enable_rpm_vreg(&sc->vreg[VREG_HFPLL_A]); enable_rpm_vreg(&sc->vreg[VREG_HFPLL_B]); } /* Disable PLL bypass mode. */ writel_relaxed(0x2, sc->hfpll_base + drv.hfpll_data->mode_offset); /* * H/W requires a 5us delay between disabling the bypass and * de-asserting the reset. Delay 10us just to be safe. */ mb(); udelay(10); /* De-assert active-low PLL reset. */ writel_relaxed(0x6, sc->hfpll_base + drv.hfpll_data->mode_offset); /* Wait for PLL to lock. */ mb(); udelay(60); /* Enable PLL output. */ writel_relaxed(0x7, sc->hfpll_base + drv.hfpll_data->mode_offset); } /* Disable a HFPLL for power-savings or while it's being reprogrammed. */ static void hfpll_disable(struct scalable *sc, bool skip_regulators) { /* * Disable the PLL output, disable test mode, enable the bypass mode, * and assert the reset. */ writel_relaxed(0, sc->hfpll_base + drv.hfpll_data->mode_offset); if (!skip_regulators) { /* Remove voltage votes required by the HFPLL. */ disable_rpm_vreg(&sc->vreg[VREG_HFPLL_B]); disable_rpm_vreg(&sc->vreg[VREG_HFPLL_A]); } } /* Program the HFPLL rate. Assumes HFPLL is already disabled. */ static void hfpll_set_rate(struct scalable *sc, const struct core_speed *tgt_s) { void __iomem *base = sc->hfpll_base; u32 regval; writel_relaxed(tgt_s->pll_l_val, base + drv.hfpll_data->l_offset); if (drv.hfpll_data->has_user_reg) { regval = readl_relaxed(base + drv.hfpll_data->user_offset); if (tgt_s->pll_l_val <= drv.hfpll_data->low_vco_l_max) regval &= ~drv.hfpll_data->user_vco_mask; else regval |= drv.hfpll_data->user_vco_mask; writel_relaxed(regval, base + drv.hfpll_data->user_offset); } } /* Return the L2 speed that should be applied. */ static unsigned int compute_l2_level(struct scalable *sc, unsigned int vote_l) { unsigned int new_l = 0; int cpu; /* Find max L2 speed vote. */ sc->l2_vote = vote_l; <API key>(cpu) new_l = max(new_l, drv.scalable[cpu].l2_vote); return new_l; } /* Update the bus bandwidth request. */ static void set_bus_bw(unsigned int bw) { int ret; /* Update bandwidth if request has changed. This may sleep. */ ret = <API key>(drv.bus_perf_client, bw); if (ret) dev_err(drv.dev, "bandwidth request failed (%d)\n", ret); } /* Set the CPU or L2 clock speed. */ static void set_speed(struct scalable *sc, const struct core_speed *tgt_s, bool skip_regulators) { const struct core_speed *strt_s = sc->cur_speed; if (strt_s == tgt_s) return; if (strt_s->src == HFPLL && tgt_s->src == HFPLL) { /* * Move to an always-on source running at a frequency * that does not require an elevated CPU voltage. */ set_pri_clk_src(sc, PRI_SRC_SEL_SEC_SRC); /* Re-program HFPLL. */ hfpll_disable(sc, true); hfpll_set_rate(sc, tgt_s); hfpll_enable(sc, true); /* Move to HFPLL. */ set_pri_clk_src(sc, tgt_s->pri_src_sel); } else if (strt_s->src == HFPLL && tgt_s->src != HFPLL) { set_pri_clk_src(sc, tgt_s->pri_src_sel); hfpll_disable(sc, skip_regulators); } else if (strt_s->src != HFPLL && tgt_s->src == HFPLL) { hfpll_set_rate(sc, tgt_s); hfpll_enable(sc, skip_regulators); set_pri_clk_src(sc, tgt_s->pri_src_sel); } sc->cur_speed = tgt_s; } struct vdd_data { int vdd_mem; int vdd_dig; int vdd_core; int ua_core; }; /* Apply any per-cpu voltage increases. */ static int increase_vdd(int cpu, struct vdd_data *data, enum setrate_reason reason) { struct scalable *sc = &drv.scalable[cpu]; int rc; /* * Increase vdd_mem active-set before vdd_dig. * vdd_mem should be >= vdd_dig. */ if (data->vdd_mem > sc->vreg[VREG_MEM].cur_vdd) { rc = <API key>(sc->vreg[VREG_MEM].rpm_reg, data->vdd_mem, sc->vreg[VREG_MEM].max_vdd); if (rc) { dev_err(drv.dev, "vdd_mem (cpu%d) increase failed (%d)\n", cpu, rc); return rc; } sc->vreg[VREG_MEM].cur_vdd = data->vdd_mem; } /* Increase vdd_dig active-set vote. */ if (data->vdd_dig > sc->vreg[VREG_DIG].cur_vdd) { rc = <API key>(sc->vreg[VREG_DIG].rpm_reg, data->vdd_dig, sc->vreg[VREG_DIG].max_vdd); if (rc) { dev_err(drv.dev, "vdd_dig (cpu%d) increase failed (%d)\n", cpu, rc); return rc; } sc->vreg[VREG_DIG].cur_vdd = data->vdd_dig; } /* Increase current request. */ if (data->ua_core > sc->vreg[VREG_CORE].cur_ua) { rc = <API key>(sc->vreg[VREG_CORE].reg, data->ua_core); if (rc < 0) { dev_err(drv.dev, "<API key>(%s) failed (%d)\n", sc->vreg[VREG_CORE].name, rc); return rc; } sc->vreg[VREG_CORE].cur_ua = data->ua_core; } /* * Update per-CPU core voltage. Don't do this for the hotplug path for * which it should already be correct. Attempting to set it is bad * because we don't know what CPU we are running on at this point, but * the CPU regulator API requires we call it from the affected CPU. */ if (data->vdd_core > sc->vreg[VREG_CORE].cur_vdd && reason != SETRATE_HOTPLUG) { rc = <API key>(sc->vreg[VREG_CORE].reg, data->vdd_core, sc->vreg[VREG_CORE].max_vdd); if (rc) { dev_err(drv.dev, "vdd_core (cpu%d) increase failed (%d)\n", cpu, rc); return rc; } sc->vreg[VREG_CORE].cur_vdd = data->vdd_core; } return 0; } /* Apply any per-cpu voltage decreases. */ static void decrease_vdd(int cpu, struct vdd_data *data, enum setrate_reason reason) { struct scalable *sc = &drv.scalable[cpu]; int ret; /* * Update per-CPU core voltage. This must be called on the CPU * that's being affected. Don't do this in the hotplug remove path, * where the rail is off and we're executing on the other CPU. */ if (data->vdd_core < sc->vreg[VREG_CORE].cur_vdd && reason != SETRATE_HOTPLUG) { ret = <API key>(sc->vreg[VREG_CORE].reg, data->vdd_core, sc->vreg[VREG_CORE].max_vdd); if (ret) { dev_err(drv.dev, "vdd_core (cpu%d) decrease failed (%d)\n", cpu, ret); return; } sc->vreg[VREG_CORE].cur_vdd = data->vdd_core; } /* Decrease current request. */ if (data->ua_core < sc->vreg[VREG_CORE].cur_ua) { ret = <API key>(sc->vreg[VREG_CORE].reg, data->ua_core); if (ret < 0) { dev_err(drv.dev, "<API key>(%s) failed (%d)\n", sc->vreg[VREG_CORE].name, ret); return; } sc->vreg[VREG_CORE].cur_ua = data->ua_core; } /* Decrease vdd_dig active-set vote. */ if (data->vdd_dig < sc->vreg[VREG_DIG].cur_vdd) { ret = <API key>(sc->vreg[VREG_DIG].rpm_reg, data->vdd_dig, sc->vreg[VREG_DIG].max_vdd); if (ret) { dev_err(drv.dev, "vdd_dig (cpu%d) decrease failed (%d)\n", cpu, ret); return; } sc->vreg[VREG_DIG].cur_vdd = data->vdd_dig; } /* * Decrease vdd_mem active-set after vdd_dig. * vdd_mem should be >= vdd_dig. */ if (data->vdd_mem < sc->vreg[VREG_MEM].cur_vdd) { ret = <API key>(sc->vreg[VREG_MEM].rpm_reg, data->vdd_mem, sc->vreg[VREG_MEM].max_vdd); if (ret) { dev_err(drv.dev, "vdd_mem (cpu%d) decrease failed (%d)\n", cpu, ret); return; } sc->vreg[VREG_MEM].cur_vdd = data->vdd_mem; } } static int calculate_vdd_mem(const struct acpu_level *tgt) { return drv.l2_freq_tbl[tgt->l2_level].vdd_mem; } static int get_src_dig(const struct core_speed *s) { const int *hfpll_vdd = drv.hfpll_data->vdd; const u32 low_vdd_l_max = drv.hfpll_data->low_vdd_l_max; const u32 nom_vdd_l_max = drv.hfpll_data->nom_vdd_l_max; if (s->src != HFPLL) return hfpll_vdd[HFPLL_VDD_NONE]; else if (s->pll_l_val > nom_vdd_l_max) return hfpll_vdd[HFPLL_VDD_HIGH]; else if (s->pll_l_val > low_vdd_l_max) return hfpll_vdd[HFPLL_VDD_NOM]; else return hfpll_vdd[HFPLL_VDD_LOW]; } static int calculate_vdd_dig(const struct acpu_level *tgt) { int l2_pll_vdd_dig, cpu_pll_vdd_dig; l2_pll_vdd_dig = get_src_dig(&drv.l2_freq_tbl[tgt->l2_level].speed); cpu_pll_vdd_dig = get_src_dig(&tgt->speed); return max(drv.l2_freq_tbl[tgt->l2_level].vdd_dig, max(l2_pll_vdd_dig, cpu_pll_vdd_dig)); } static bool enable_boost = true; module_param_named(boost, enable_boost, bool, S_IRUGO | S_IWUSR); static int calculate_vdd_core(const struct acpu_level *tgt) { return tgt->vdd_core + (enable_boost ? drv.boost_uv : 0); } static DEFINE_MUTEX(l2_regulator_lock); static int l2_vreg_count; static int <API key>(void) { int ret = 0; mutex_lock(&l2_regulator_lock); if (l2_vreg_count == 0) { ret = enable_rpm_vreg(&drv.scalable[L2].vreg[VREG_HFPLL_A]); if (ret) goto out; ret = enable_rpm_vreg(&drv.scalable[L2].vreg[VREG_HFPLL_B]); if (ret) { disable_rpm_vreg(&drv.scalable[L2].vreg[VREG_HFPLL_A]); goto out; } } l2_vreg_count++; out: mutex_unlock(&l2_regulator_lock); return ret; } static void <API key>(void) { mutex_lock(&l2_regulator_lock); if (WARN(!l2_vreg_count, "L2 regulator votes are unbalanced!")) goto out; if (l2_vreg_count == 1) { disable_rpm_vreg(&drv.scalable[L2].vreg[VREG_HFPLL_B]); disable_rpm_vreg(&drv.scalable[L2].vreg[VREG_HFPLL_A]); } l2_vreg_count out: mutex_unlock(&l2_regulator_lock); } static int minus_vc; module_param_named( mclk, minus_vc, int, S_IRUGO | S_IWUSR | S_IWGRP ); /* Set the CPU's clock rate and adjust the L2 rate, voltage and BW requests. */ static int <API key>(int cpu, unsigned long rate, enum setrate_reason reason) { const struct core_speed *strt_acpu_s, *tgt_acpu_s; const struct acpu_level *tgt; int tgt_l2_l; enum src_id prev_l2_src = NUM_SRC_ID; struct vdd_data vdd_data; bool skip_regulators; int rc = 0; if (cpu > num_possible_cpus()) return -EINVAL; if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG) mutex_lock(&driver_lock); strt_acpu_s = drv.scalable[cpu].cur_speed; /* Return early if rate didn't change. */ if (rate == strt_acpu_s->khz) goto out; /* Find target frequency. */ for (tgt = drv.acpu_freq_tbl; tgt->speed.khz != 0; tgt++) { if (tgt->speed.khz == rate) { tgt_acpu_s = &tgt->speed; break; } } if (tgt->speed.khz == 0) { rc = -EINVAL; goto out; } /* Calculate voltage requirements for the current CPU. */ vdd_data.vdd_mem = calculate_vdd_mem(tgt); vdd_data.vdd_dig = calculate_vdd_dig(tgt); vdd_data.vdd_core = calculate_vdd_core(tgt) + minus_vc; vdd_data.ua_core = tgt->ua_core; /* Disable AVS before voltage switch */ if (reason == SETRATE_CPUFREQ && drv.scalable[cpu].avs_enabled) { AVS_DISABLE(cpu); drv.scalable[cpu].avs_enabled = false; } /* Increase VDD levels if needed. */ if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG) { rc = increase_vdd(cpu, &vdd_data, reason); if (rc) goto out; prev_l2_src = drv.l2_freq_tbl[drv.scalable[cpu].l2_vote].speed.src; /* Vote for the L2 regulators here if necessary. */ if (drv.l2_freq_tbl[tgt->l2_level].speed.src == HFPLL) { rc = <API key>(); if (rc) goto out; } } dev_dbg(drv.dev, "Switching from ACPU%d rate %lu KHz -> %lu KHz\n", cpu, strt_acpu_s->khz, tgt_acpu_s->khz); /* * If we are setting the rate as part of power collapse or in the resume * path after power collapse, skip the vote for the HFPLL regulators, * which are active-set-only votes that will be removed when apps enters * its sleep set. This is needed to avoid voting for regulators with * sleeping APIs from an atomic context. */ skip_regulators = (reason == SETRATE_PC); #ifdef <API key> sec_debug_dcvs_log(cpu, strt_acpu_s->khz, tgt_acpu_s->khz); #endif /* Set the new CPU speed. */ set_speed(&drv.scalable[cpu], tgt_acpu_s, skip_regulators); /* * Update the L2 vote and apply the rate change. A spinlock is * necessary to ensure L2 rate is calculated and set atomically * with the CPU frequency, even if <API key>() is * called from an atomic context and the driver_lock mutex is not * acquired. */ spin_lock(&l2_lock); tgt_l2_l = compute_l2_level(&drv.scalable[cpu], tgt->l2_level); set_speed(&drv.scalable[L2], &drv.l2_freq_tbl[tgt_l2_l].speed, true); spin_unlock(&l2_lock); /* Nothing else to do for power collapse or SWFI. */ if (reason == SETRATE_PC || reason == SETRATE_SWFI) goto out; /* * Remove the vote for the L2 HFPLL regulators only if the L2 * was already on an HFPLL source. */ if (prev_l2_src == HFPLL) <API key>(); /* Update bus bandwith request. */ set_bus_bw(drv.l2_freq_tbl[tgt_l2_l].bw_level); /* Drop VDD levels if we can. */ decrease_vdd(cpu, &vdd_data, reason); /* Re-enable AVS */ if (reason == SETRATE_CPUFREQ && tgt->avsdscr_setting) { AVS_ENABLE(cpu, tgt->avsdscr_setting); drv.scalable[cpu].avs_enabled = true; } dev_dbg(drv.dev, "ACPU%d speed change complete\n", cpu); out: if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG) mutex_unlock(&driver_lock); return rc; } static struct acpuclk_data acpuclk_krait_data = { .set_rate = <API key>, .get_rate = <API key>, }; /* Initialize a HFPLL at a given rate and enable it. */ static void __cpuinit hfpll_init(struct scalable *sc, const struct core_speed *tgt_s) { dev_dbg(drv.dev, "Initializing HFPLL%d\n", sc - drv.scalable); /* Disable the PLL for re-programming. */ hfpll_disable(sc, true); /* Configure PLL parameters for integer mode. */ writel_relaxed(drv.hfpll_data->config_val, sc->hfpll_base + drv.hfpll_data->config_offset); writel_relaxed(0, sc->hfpll_base + drv.hfpll_data->m_offset); writel_relaxed(1, sc->hfpll_base + drv.hfpll_data->n_offset); if (drv.hfpll_data->has_user_reg) writel_relaxed(drv.hfpll_data->user_val, sc->hfpll_base + drv.hfpll_data->user_offset); /* Program droop controller, if supported */ if (drv.hfpll_data->has_droop_ctl) writel_relaxed(drv.hfpll_data->droop_val, sc->hfpll_base + drv.hfpll_data->droop_offset); /* Set an initial PLL rate. */ hfpll_set_rate(sc, tgt_s); } static int __cpuinit rpm_regulator_init(struct scalable *sc, enum vregs vreg, int vdd, bool enable) { int ret; if (!sc->vreg[vreg].name) return 0; sc->vreg[vreg].rpm_reg = rpm_regulator_get(drv.dev, sc->vreg[vreg].name); if (IS_ERR(sc->vreg[vreg].rpm_reg)) { ret = PTR_ERR(sc->vreg[vreg].rpm_reg); dev_err(drv.dev, "rpm_regulator_get(%s) failed (%d)\n", sc->vreg[vreg].name, ret); goto err_get; } ret = <API key>(sc->vreg[vreg].rpm_reg, vdd, sc->vreg[vreg].max_vdd); if (ret) { dev_err(drv.dev, "%s initialization failed (%d)\n", sc->vreg[vreg].name, ret); goto err_conf; } sc->vreg[vreg].cur_vdd = vdd; if (enable) { ret = enable_rpm_vreg(&sc->vreg[vreg]); if (ret) goto err_conf; } return 0; err_conf: rpm_regulator_put(sc->vreg[vreg].rpm_reg); err_get: return ret; } static void __cpuinit <API key>(struct scalable *sc, enum vregs vreg) { if (!sc->vreg[vreg].rpm_reg) return; disable_rpm_vreg(&sc->vreg[vreg]); rpm_regulator_put(sc->vreg[vreg].rpm_reg); } /* Voltage regulator initialization. */ static int __cpuinit regulator_init(struct scalable *sc, const struct acpu_level *acpu_level) { int ret, vdd_mem, vdd_dig, vdd_core; vdd_mem = calculate_vdd_mem(acpu_level); ret = rpm_regulator_init(sc, VREG_MEM, vdd_mem, true); if (ret) goto err_mem; vdd_dig = calculate_vdd_dig(acpu_level); ret = rpm_regulator_init(sc, VREG_DIG, vdd_dig, true); if (ret) goto err_dig; ret = rpm_regulator_init(sc, VREG_HFPLL_A, sc->vreg[VREG_HFPLL_A].max_vdd, false); if (ret) goto err_hfpll_a; ret = rpm_regulator_init(sc, VREG_HFPLL_B, sc->vreg[VREG_HFPLL_B].max_vdd, false); if (ret) goto err_hfpll_b; /* Setup Krait CPU regulators and initial core voltage. */ sc->vreg[VREG_CORE].reg = regulator_get(drv.dev, sc->vreg[VREG_CORE].name); if (IS_ERR(sc->vreg[VREG_CORE].reg)) { ret = PTR_ERR(sc->vreg[VREG_CORE].reg); dev_err(drv.dev, "regulator_get(%s) failed (%d)\n", sc->vreg[VREG_CORE].name, ret); goto err_core_get; } ret = <API key>(sc->vreg[VREG_CORE].reg, acpu_level->ua_core); if (ret < 0) { dev_err(drv.dev, "<API key>(%s) failed (%d)\n", sc->vreg[VREG_CORE].name, ret); goto err_core_conf; } sc->vreg[VREG_CORE].cur_ua = acpu_level->ua_core; vdd_core = calculate_vdd_core(acpu_level); ret = <API key>(sc->vreg[VREG_CORE].reg, vdd_core, sc->vreg[VREG_CORE].max_vdd); if (ret) { dev_err(drv.dev, "<API key>(%s) (%d)\n", sc->vreg[VREG_CORE].name, ret); goto err_core_conf; } sc->vreg[VREG_CORE].cur_vdd = vdd_core; ret = regulator_enable(sc->vreg[VREG_CORE].reg); if (ret) { dev_err(drv.dev, "regulator_enable(%s) failed (%d)\n", sc->vreg[VREG_CORE].name, ret); goto err_core_conf; } /* * Increment the L2 HFPLL regulator refcount if _this_ CPU's frequency * requires a corresponding target L2 frequency that needs the L2 to * run off of an HFPLL. */ if (drv.l2_freq_tbl[acpu_level->l2_level].speed.src == HFPLL) l2_vreg_count++; return 0; err_core_conf: regulator_put(sc->vreg[VREG_CORE].reg); err_core_get: <API key>(sc, VREG_HFPLL_B); err_hfpll_b: <API key>(sc, VREG_HFPLL_A); err_hfpll_a: <API key>(sc, VREG_DIG); err_dig: <API key>(sc, VREG_MEM); err_mem: return ret; } static void __cpuinit regulator_cleanup(struct scalable *sc) { regulator_disable(sc->vreg[VREG_CORE].reg); regulator_put(sc->vreg[VREG_CORE].reg); <API key>(sc, VREG_HFPLL_B); <API key>(sc, VREG_HFPLL_A); <API key>(sc, VREG_DIG); <API key>(sc, VREG_MEM); } /* Set initial rate for a given core. */ static int __cpuinit init_clock_sources(struct scalable *sc, const struct core_speed *tgt_s) { u32 regval; void __iomem *aux_reg; /* Program AUX source input to the secondary MUX. */ if (sc->aux_clk_sel_phys) { aux_reg = ioremap(sc->aux_clk_sel_phys, 4); if (!aux_reg) return -ENOMEM; writel_relaxed(sc->aux_clk_sel, aux_reg); iounmap(aux_reg); } /* Switch away from the HFPLL while it's re-initialized. */ set_sec_clk_src(sc, sc->sec_clk_sel); set_pri_clk_src(sc, PRI_SRC_SEL_SEC_SRC); hfpll_init(sc, tgt_s); /* Set <API key> divider to div-2. */ regval = get_l2_indirect_reg(sc->l2cpmr_iaddr); regval &= ~(0x3 << 6); set_l2_indirect_reg(sc->l2cpmr_iaddr, regval); /* Enable and switch to the target clock source. */ if (tgt_s->src == HFPLL) hfpll_enable(sc, false); set_pri_clk_src(sc, tgt_s->pri_src_sel); sc->cur_speed = tgt_s; return 0; } static void __cpuinit fill_cur_core_speed(struct core_speed *s, struct scalable *sc) { s->pri_src_sel = get_l2_indirect_reg(sc->l2cpmr_iaddr) & 0x3; s->pll_l_val = readl_relaxed(sc->hfpll_base + drv.hfpll_data->l_offset); } static bool __cpuinit speed_equal(const struct core_speed *s1, const struct core_speed *s2) { return (s1->pri_src_sel == s2->pri_src_sel && s1->pll_l_val == s2->pll_l_val); } static const struct acpu_level __cpuinit *find_cur_acpu_level(int cpu) { struct scalable *sc = &drv.scalable[cpu]; const struct acpu_level *l; struct core_speed cur_speed; fill_cur_core_speed(&cur_speed, sc); for (l = drv.acpu_freq_tbl; l->speed.khz != 0; l++) if (speed_equal(&l->speed, &cur_speed)) return l; return NULL; } static const struct l2_level __init *find_cur_l2_level(void) { struct scalable *sc = &drv.scalable[L2]; const struct l2_level *l; struct core_speed cur_speed; fill_cur_core_speed(&cur_speed, sc); for (l = drv.l2_freq_tbl; l->speed.khz != 0; l++) if (speed_equal(&l->speed, &cur_speed)) return l; return NULL; } static const struct acpu_level __cpuinit *find_min_acpu_level(void) { struct acpu_level *l; for (l = drv.acpu_freq_tbl; l->speed.khz != 0; l++) if (l->use_for_scaling) return l; return NULL; } static int __cpuinit per_cpu_init(int cpu) { struct scalable *sc = &drv.scalable[cpu]; const struct acpu_level *acpu_level; int ret; sc->hfpll_base = ioremap(sc->hfpll_phys_base, SZ_32); if (!sc->hfpll_base) { ret = -ENOMEM; goto err_ioremap; } acpu_level = find_cur_acpu_level(cpu); if (!acpu_level) { acpu_level = find_min_acpu_level(); if (!acpu_level) { ret = -ENODEV; goto err_table; } dev_dbg(drv.dev, "CPU%d is running at an unknown rate. Defaulting to %lu KHz.\n", cpu, acpu_level->speed.khz); } else { dev_dbg(drv.dev, "CPU%d is running at %lu KHz\n", cpu, acpu_level->speed.khz); } ret = regulator_init(sc, acpu_level); if (ret) goto err_regulators; ret = init_clock_sources(sc, &acpu_level->speed); if (ret) goto err_clocks; sc->l2_vote = acpu_level->l2_level; sc->initialized = true; return 0; err_clocks: regulator_cleanup(sc); err_regulators: err_table: iounmap(sc->hfpll_base); err_ioremap: return ret; } /* Register with bus driver. */ static void __init bus_init(const struct l2_level *l2_level) { int ret; drv.bus_perf_client = <API key>(drv.bus_scale); if (!drv.bus_perf_client) { dev_err(drv.dev, "unable to register bus client\n"); BUG(); } ret = <API key>(drv.bus_perf_client, l2_level->bw_level); if (ret) dev_err(drv.dev, "initial bandwidth req failed (%d)\n", ret); } #ifdef CONFIG_CPU_FREQ_MSM static struct <API key> freq_table[NR_CPUS][35]; extern int console_batt_stat; static void __init cpufreq_table_init(void) { int cpu; <API key>(cpu) { int i, freq_cnt = 0; /* Construct the freq_table tables from acpu_freq_tbl. */ for (i = 0; drv.acpu_freq_tbl[i].speed.khz != 0 && freq_cnt < ARRAY_SIZE(*freq_table); i++) { if (drv.acpu_freq_tbl[i].use_for_scaling) { #ifdef CONFIG_SEC_FACTORY // if factory_condition, set the core freq limit. //QMCK if (<API key> && drv.acpu_freq_tbl[i].speed.khz > 1000000) { if(console_batt_stat == 1) { continue; } } //QMCK #endif freq_table[cpu][freq_cnt].index = freq_cnt; freq_table[cpu][freq_cnt].frequency = drv.acpu_freq_tbl[i].speed.khz; freq_cnt++; } } /* freq_table not big enough to store all usable freqs. */ BUG_ON(drv.acpu_freq_tbl[i].speed.khz != 0); freq_table[cpu][freq_cnt].index = freq_cnt; freq_table[cpu][freq_cnt].frequency = CPUFREQ_TABLE_END; dev_info(drv.dev, "CPU%d: %d frequencies supported\n", cpu, freq_cnt); /* Register table with CPUFreq. */ <API key>(freq_table[cpu], cpu); } } #else static void __init cpufreq_table_init(void) {} #endif static void __init dcvs_freq_init(void) { int i; for (i = 0; drv.acpu_freq_tbl[i].speed.khz != 0; i++) if (drv.acpu_freq_tbl[i].use_for_scaling) <API key>( drv.acpu_freq_tbl[i].speed.khz, drv.acpu_freq_tbl[i].vdd_core / 1000); } static int __cpuinit <API key>(struct notifier_block *nfb, unsigned long action, void *hcpu) { static int prev_khz[NR_CPUS]; int rc, cpu = (int)hcpu; struct scalable *sc = &drv.scalable[cpu]; unsigned long hot_unplug_khz = acpuclk_krait_data.power_collapse_khz; switch (action & ~CPU_TASKS_FROZEN) { case CPU_DEAD: prev_khz[cpu] = <API key>(cpu); /* Fall through. */ case CPU_UP_CANCELED: <API key>(cpu, hot_unplug_khz, SETRATE_HOTPLUG); <API key>(sc->vreg[VREG_CORE].reg, 0); break; case CPU_UP_PREPARE: if (!sc->initialized) { rc = per_cpu_init(cpu); if (rc) return NOTIFY_BAD; break; } if (WARN_ON(!prev_khz[cpu])) return NOTIFY_BAD; rc = <API key>(sc->vreg[VREG_CORE].reg, sc->vreg[VREG_CORE].cur_ua); if (rc < 0) return NOTIFY_BAD; <API key>(cpu, prev_khz[cpu], SETRATE_HOTPLUG); break; default: break; } return NOTIFY_OK; } static struct notifier_block __cpuinitdata <API key> = { .notifier_call = <API key>, }; static const int krait_needs_vmin(void) { switch (read_cpuid_id()) { case 0x511F04D0: /* KR28M2A20 */ case 0x511F04D1: /* KR28M2A21 */ case 0x510F06F0: /* KR28M4A10 */ return 1; default: return 0; }; } static void krait_apply_vmin(struct acpu_level *tbl) { for (; tbl->speed.khz != 0; tbl++) { if (tbl->vdd_core < 1150000) tbl->vdd_core = 1150000; tbl->avsdscr_setting = 0; } } static int __init get_speed_bin(u32 pte_efuse) { uint32_t speed_bin; speed_bin = pte_efuse & 0xF; if (speed_bin == 0xF) speed_bin = (pte_efuse >> 4) & 0xF; if (speed_bin == 0xF) { speed_bin = 0; dev_warn(drv.dev, "SPEED BIN: Defaulting to %d\n", speed_bin); } else { dev_info(drv.dev, "SPEED BIN: %d\n", speed_bin); } return speed_bin; } static int __init get_pvs_bin(u32 pte_efuse) { uint32_t pvs_bin; pvs_bin = (pte_efuse >> 10) & 0x7; if (pvs_bin == 0x7) pvs_bin = (pte_efuse >> 13) & 0x7; if (pvs_bin == 0x7) { pvs_bin = 0; dev_warn(drv.dev, "ACPU PVS: Defaulting to %d\n", pvs_bin); } else { dev_info(drv.dev, "ACPU PVS: %d\n", pvs_bin); } return pvs_bin; } static struct pvs_table * __init select_freq_plan(u32 pte_efuse_phys, struct pvs_table (*pvs_tables)[NUM_PVS]) { void __iomem *pte_efuse; u32 pte_efuse_val, tbl_idx, bin_idx; pte_efuse = ioremap(pte_efuse_phys, 4); if (!pte_efuse) { dev_err(drv.dev, "Unable to map QFPROM base\n"); return NULL; } pte_efuse_val = readl_relaxed(pte_efuse); iounmap(pte_efuse); /* Select frequency tables. */ bin_idx = get_speed_bin(pte_efuse_val); tbl_idx = get_pvs_bin(pte_efuse_val); #ifdef <API key> speed_bin = bin_idx; pvs_bin = tbl_idx; #endif return &pvs_tables[bin_idx][tbl_idx]; } static void __init drv_data_init(struct device *dev, const struct <API key> *params) { struct pvs_table *pvs; drv.dev = dev; drv.scalable = kmemdup(params->scalable, params->scalable_size, GFP_KERNEL); BUG_ON(!drv.scalable); drv.hfpll_data = kmemdup(params->hfpll_data, sizeof(*drv.hfpll_data), GFP_KERNEL); BUG_ON(!drv.hfpll_data); drv.l2_freq_tbl = kmemdup(params->l2_freq_tbl, params->l2_freq_tbl_size, GFP_KERNEL); BUG_ON(!drv.l2_freq_tbl); drv.bus_scale = kmemdup(params->bus_scale, sizeof(*drv.bus_scale), GFP_KERNEL); BUG_ON(!drv.bus_scale); drv.bus_scale->usecase = kmemdup(drv.bus_scale->usecase, drv.bus_scale->num_usecases * sizeof(*drv.bus_scale->usecase), GFP_KERNEL); BUG_ON(!drv.bus_scale->usecase); pvs = select_freq_plan(params->pte_efuse_phys, params->pvs_tables); BUG_ON(!pvs->table); drv.acpu_freq_tbl = kmemdup(pvs->table, pvs->size, GFP_KERNEL); BUG_ON(!drv.acpu_freq_tbl); drv.boost_uv = pvs->boost_uv; #ifdef <API key> boost_uv = drv.boost_uv; #endif acpuclk_krait_data.power_collapse_khz = params->stby_khz; acpuclk_krait_data.wait_for_irq_khz = params->stby_khz; } static void __init hw_init(void) { struct scalable *l2 = &drv.scalable[L2]; const struct l2_level *l2_level; int cpu, rc; if (krait_needs_vmin()) krait_apply_vmin(drv.acpu_freq_tbl); l2->hfpll_base = ioremap(l2->hfpll_phys_base, SZ_32); BUG_ON(!l2->hfpll_base); rc = rpm_regulator_init(l2, VREG_HFPLL_A, l2->vreg[VREG_HFPLL_A].max_vdd, false); BUG_ON(rc); rc = rpm_regulator_init(l2, VREG_HFPLL_B, l2->vreg[VREG_HFPLL_B].max_vdd, false); BUG_ON(rc); l2_level = find_cur_l2_level(); if (!l2_level) { l2_level = drv.l2_freq_tbl; dev_dbg(drv.dev, "L2 is running at an unknown rate. Defaulting to %lu KHz.\n", l2_level->speed.khz); } else { dev_dbg(drv.dev, "L2 is running at %lu KHz\n", l2_level->speed.khz); } rc = init_clock_sources(l2, &l2_level->speed); BUG_ON(rc); for_each_online_cpu(cpu) { rc = per_cpu_init(cpu); BUG_ON(rc); } bus_init(l2_level); } int __init acpuclk_krait_init(struct device *dev, const struct <API key> *params) { drv_data_init(dev, params); hw_init(); cpufreq_table_init(); dcvs_freq_init(); acpuclk_register(&acpuclk_krait_data); <API key>(&<API key>); return 0; }
package org.erc.qmm.mq; import java.util.EventListener; /** * The listener interface for receiving messageReaded events. * The class that is interested in processing a messageReaded * event implements this interface, and the object created * with that class is registered with a component using the * component's <code><API key><code> method. When * the messageReaded event occurs, that object's appropriate * method is invoked. * * @see MessageReadedEvent */ public interface <API key> extends EventListener { /** * Message readed. * * @param message the message */ void messageReaded(JMQMessage message); }
import re p = re.compile(r'(\w+) (\w+)(?P<sign>.*)', re.DOTALL) print re.DOTALL print "p.pattern:", p.pattern print "p.flags:", p.flags print "p.groups:", p.groups print "p.groupindex:", p.groupindex
#include <linux/slab.h> #include <linux/wait.h> #include <linux/sched.h> #include <linux/jiffies.h> #include <linux/uaccess.h> #include <linux/atomic.h> #include <linux/wait.h> #include <sound/apr_audio-v2.h> #include <linux/qdsp6v2/apr.h> #include <sound/q6adm-v2.h> #include <sound/q6audio-v2.h> #include <sound/q6afe-v2.h> #include <sound/hw_audio_log.h> #include "audio_acdb.h" #define TIMEOUT_MS 1000 #define RESET_COPP_ID 99 #define INVALID_COPP_ID 0xFF /* Used for inband payload copy, max size is 4k */ /* 2 is to account for module & param ID in payload */ #define <API key> (4096 - APR_HDR_SIZE - 2 * sizeof(uint32_t)) #define <API key> 48000 enum { ADM_RX_AUDPROC_CAL, ADM_TX_AUDPROC_CAL, ADM_RX_AUDVOL_CAL, ADM_TX_AUDVOL_CAL, ADM_CUSTOM_TOP_CAL, ADM_RTAC, ADM_MAX_CAL_TYPES }; struct adm_ctl { void *apr; atomic_t copp_id[AFE_MAX_PORTS]; atomic_t copp_cnt[AFE_MAX_PORTS]; atomic_t copp_low_latency_id[AFE_MAX_PORTS]; atomic_t <API key>[AFE_MAX_PORTS]; atomic_t copp_perf_mode[AFE_MAX_PORTS]; atomic_t copp_stat[AFE_MAX_PORTS]; wait_queue_head_t wait[AFE_MAX_PORTS]; struct acdb_cal_block mem_addr_audproc[MAX_AUDPROC_TYPES]; struct acdb_cal_block mem_addr_audvol[MAX_AUDPROC_TYPES]; atomic_t mem_map_cal_handles[ADM_MAX_CAL_TYPES]; atomic_t mem_map_cal_index; int set_custom_topology; int ec_ref_rx; }; static struct adm_ctl this_adm; struct adm_multi_ch_map { bool set_channel_map; char channel_mapping[<API key>]; }; static struct adm_multi_ch_map multi_ch_map = { false, {0, 0, 0, 0, 0, 0, 0, 0} }; static int adm_get_parameters[<API key>]; int srs_trumedia_open(int port_id, int srs_tech_id, void *srs_params) { struct <API key> *adm_params = NULL; int ret = 0, sz = 0; int index; ad_logd("SRS - %s", __func__); switch (srs_tech_id) { case SRS_ID_GLOBAL: { struct <API key> *glb_params = NULL; sz = sizeof(struct <API key>) + sizeof(struct <API key>); adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed\n", __func__); return -ENOMEM; } adm_params->payload_size = sizeof(struct <API key>) + sizeof(struct adm_param_data_v5); adm_params->params.param_id = SRS_TRUMEDIA_PARAMS; adm_params->params.param_size = sizeof(struct <API key>); glb_params = (struct <API key> *) ((u8 *)adm_params + sizeof(struct <API key>)); memcpy(glb_params, srs_params, sizeof(struct <API key>)); ad_logd("SRS - %s: Global params - 1 = %x, 2 = %x, 3 = %x, 4 = %x, 5 = %x, 6 = %x, 7 = %x, 8 = %x\n", __func__, (int)glb_params->v1, (int)glb_params->v2, (int)glb_params->v3, (int)glb_params->v4, (int)glb_params->v5, (int)glb_params->v6, (int)glb_params->v7, (int)glb_params->v8); break; } case SRS_ID_WOWHD: { struct <API key> *whd_params = NULL; sz = sizeof(struct <API key>) + sizeof(struct <API key>); adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed\n", __func__); return -ENOMEM; } adm_params->payload_size = sizeof(struct <API key>) + sizeof(struct adm_param_data_v5); adm_params->params.param_id = <API key>; adm_params->params.param_size = sizeof(struct <API key>); whd_params = (struct <API key> *) ((u8 *)adm_params + sizeof(struct <API key>)); memcpy(whd_params, srs_params, sizeof(struct <API key>)); ad_logd("SRS - %s: WOWHD params - 1 = %x, 2 = %x, 3 = %x, 4 = %x, 5 = %x, 6 = %x, 7 = %x, 8 = %x, 9 = %x, 10 = %x, 11 = %x\n", __func__, (int)whd_params->v1, (int)whd_params->v2, (int)whd_params->v3, (int)whd_params->v4, (int)whd_params->v5, (int)whd_params->v6, (int)whd_params->v7, (int)whd_params->v8, (int)whd_params->v9, (int)whd_params->v10, (int)whd_params->v11); break; } case SRS_ID_CSHP: { struct <API key> *chp_params = NULL; sz = sizeof(struct <API key>) + sizeof(struct <API key>); adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed\n", __func__); return -ENOMEM; } adm_params->payload_size = sizeof(struct <API key>) + sizeof(struct adm_param_data_v5); adm_params->params.param_id = <API key>; adm_params->params.param_size = sizeof(struct <API key>); chp_params = (struct <API key> *) ((u8 *)adm_params + sizeof(struct <API key>)); memcpy(chp_params, srs_params, sizeof(struct <API key>)); ad_logd("SRS - %s: CSHP params - 1 = %x, 2 = %x, 3 = %x, 4 = %x, 5 = %x, 6 = %x, 7 = %x, 8 = %x, 9 = %x\n", __func__, (int)chp_params->v1, (int)chp_params->v2, (int)chp_params->v3, (int)chp_params->v4, (int)chp_params->v5, (int)chp_params->v6, (int)chp_params->v7, (int)chp_params->v8, (int)chp_params->v9); break; } case SRS_ID_HPF: { struct <API key> *hpf_params = NULL; sz = sizeof(struct <API key>) + sizeof(struct <API key>); adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed\n", __func__); return -ENOMEM; } adm_params->payload_size = sizeof(struct <API key>) + sizeof(struct adm_param_data_v5); adm_params->params.param_id = <API key>; adm_params->params.param_size = sizeof(struct <API key>); hpf_params = (struct <API key> *) ((u8 *)adm_params + sizeof(struct <API key>)); memcpy(hpf_params, srs_params, sizeof(struct <API key>)); ad_logd("SRS - %s: HPF params - 1 = %x\n", __func__, (int)hpf_params->v1); break; } case SRS_ID_PEQ: { struct <API key> *peq_params = NULL; sz = sizeof(struct <API key>) + sizeof(struct <API key>); adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed\n", __func__); return -ENOMEM; } adm_params->payload_size = sizeof(struct <API key>) + sizeof(struct adm_param_data_v5); adm_params->params.param_id = <API key>; adm_params->params.param_size = sizeof(struct <API key>); peq_params = (struct <API key> *) ((u8 *)adm_params + sizeof(struct <API key>)); memcpy(peq_params, srs_params, sizeof(struct <API key>)); ad_logd("SRS - %s: PEQ params - 1 = %x 2 = %x, 3 = %x, 4 = %x\n", __func__, (int)peq_params->v1, (int)peq_params->v2, (int)peq_params->v3, (int)peq_params->v4); break; } case SRS_ID_HL: { struct <API key> *hl_params = NULL; sz = sizeof(struct <API key>) + sizeof(struct <API key>); adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed\n", __func__); return -ENOMEM; } adm_params->payload_size = sizeof(struct <API key>) + sizeof(struct adm_param_data_v5); adm_params->params.param_id = <API key>; adm_params->params.param_size = sizeof(struct <API key>); hl_params = (struct <API key> *) ((u8 *)adm_params + sizeof(struct <API key>)); memcpy(hl_params, srs_params, sizeof(struct <API key>)); ad_logd("SRS - %s: HL params - 1 = %x, 2 = %x, 3 = %x, 4 = %x, 5 = %x, 6 = %x, 7 = %x\n", __func__, (int)hl_params->v1, (int)hl_params->v2, (int)hl_params->v3, (int)hl_params->v4, (int)hl_params->v5, (int)hl_params->v6, (int)hl_params->v7); break; } default: goto fail_cmd; } adm_params->hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); adm_params->hdr.pkt_size = sz; adm_params->hdr.src_svc = APR_SVC_ADM; adm_params->hdr.src_domain = APR_DOMAIN_APPS; adm_params->hdr.src_port = port_id; adm_params->hdr.dest_svc = APR_SVC_ADM; adm_params->hdr.dest_domain = APR_DOMAIN_ADSP; index = afe_get_port_index(port_id); if (index < 0 || index >= AFE_MAX_PORTS) { ad_loge("%s: invalid port idx %d portid % __func__, index, port_id); ret = -EINVAL; goto fail_cmd; } adm_params->hdr.dest_port = atomic_read(&this_adm.copp_id[index]); adm_params->hdr.token = port_id; adm_params->hdr.opcode = <API key>; adm_params->payload_addr_lsw = 0; adm_params->payload_addr_msw = 0; adm_params->mem_map_handle = 0; adm_params->params.module_id = <API key>; adm_params->params.reserved = 0; ad_logd("SRS - %s: Command was sent now check Q6 - port id = %d, size %d, module id %x, param id %x.\n", __func__, adm_params->hdr.dest_port, adm_params->payload_size, adm_params->params.module_id, adm_params->params.param_id); ret = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params); if (ret < 0) { ad_loge("SRS - %s: ADM enable for port %d failed\n", __func__, port_id); ret = -EINVAL; goto fail_cmd; } /* Wait for the callback with copp id */ ret = wait_event_timeout(this_adm.wait[index], 1, msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { ad_loge("%s: SRS set params timed out port = %d\n", __func__, port_id); ret = -EINVAL; goto fail_cmd; } fail_cmd: kfree(adm_params); return ret; } int <API key>(int port_id, unsigned int session_id, char *params, uint32_t params_length) { struct <API key> *adm_params = NULL; int sz, rc = 0, index = afe_get_port_index(port_id); ad_logd("%s\n", __func__); if (index < 0 || index >= AFE_MAX_PORTS) { ad_loge("%s: invalid port idx %d port_id %#x\n", __func__, index, port_id); return -EINVAL; } sz = sizeof(struct <API key>) + params_length; adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed\n", __func__); return -ENOMEM; } memcpy(((u8 *)adm_params + sizeof(struct <API key>)), params, params_length); adm_params->hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); adm_params->hdr.pkt_size = sz; adm_params->hdr.src_svc = APR_SVC_ADM; adm_params->hdr.src_domain = APR_DOMAIN_APPS; adm_params->hdr.src_port = port_id; adm_params->hdr.dest_svc = APR_SVC_ADM; adm_params->hdr.dest_domain = APR_DOMAIN_ADSP; adm_params->hdr.dest_port = atomic_read(&this_adm.copp_id[index]); adm_params->hdr.token = port_id; adm_params->hdr.opcode = <API key>; adm_params->payload_addr_lsw = 0; adm_params->payload_addr_msw = 0; adm_params->mem_map_handle = 0; adm_params->payload_size = params_length; /* direction RX as 0 */ adm_params->direction = 0; /* session id for this cmd to be applied on */ adm_params->sessionid = session_id; /* valid COPP id for LPCM */ adm_params->deviceid = atomic_read(&this_adm.copp_id[index]); adm_params->reserved = 0; ad_logd("%s: deviceid %d, session_id %d, src_port %d, dest_port %d\n", __func__, adm_params->deviceid, adm_params->sessionid, adm_params->hdr.src_port, adm_params->hdr.dest_port); atomic_set(&this_adm.copp_stat[index], 0); rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params); if (rc < 0) { ad_loge("%s: Set params failed port = % __func__, port_id); rc = -EINVAL; goto <API key>; } /* Wait for the callback */ rc = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!rc) { ad_loge("%s: Set params timed out port = %#x\n", __func__, port_id); rc = -EINVAL; goto <API key>; } rc = 0; <API key>: kfree(adm_params); return rc; } int <API key>(int port_id, char *params, uint32_t params_length) { struct <API key> *adm_params = NULL; int sz, rc = 0, index = afe_get_port_index(port_id); ad_logd("%s\n", __func__); if (index < 0 || index >= AFE_MAX_PORTS) { ad_loge("%s: invalid port idx %d portid % __func__, index, port_id); return -EINVAL; } sz = sizeof(struct <API key>) + params_length; adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed", __func__); return -ENOMEM; } memcpy(((u8 *)adm_params + sizeof(struct <API key>)), params, params_length); adm_params->hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); adm_params->hdr.pkt_size = sz; adm_params->hdr.src_svc = APR_SVC_ADM; adm_params->hdr.src_domain = APR_DOMAIN_APPS; adm_params->hdr.src_port = port_id; adm_params->hdr.dest_svc = APR_SVC_ADM; adm_params->hdr.dest_domain = APR_DOMAIN_ADSP; adm_params->hdr.dest_port = atomic_read(&this_adm.copp_id[index]); adm_params->hdr.token = port_id; adm_params->hdr.opcode = <API key>; adm_params->payload_addr_lsw = 0; adm_params->payload_addr_msw = 0; adm_params->mem_map_handle = 0; adm_params->payload_size = params_length; atomic_set(&this_adm.copp_stat[index], 0); rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params); if (rc < 0) { ad_loge("%s: Set params failed port = % __func__, port_id); rc = -EINVAL; goto <API key>; } /* Wait for the callback */ rc = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!rc) { ad_loge("%s: Set params timed out port = % __func__, port_id); rc = -EINVAL; goto <API key>; } rc = 0; <API key>: kfree(adm_params); return rc; } int adm_get_params(int port_id, uint32_t module_id, uint32_t param_id, uint32_t params_length, char *params) { struct <API key> *adm_params = NULL; int sz, rc = 0, i = 0, index = afe_get_port_index(port_id); int *params_data = (int *)params; if (index < 0 || index >= AFE_MAX_PORTS) { ad_loge("%s: invalid port idx %d portid % __func__, index, port_id); return -EINVAL; } sz = sizeof(struct <API key>) + params_length; adm_params = kzalloc(sz, GFP_KERNEL); if (!adm_params) { ad_loge("%s, adm params memory alloc failed", __func__); return -ENOMEM; } memcpy(((u8 *)adm_params + sizeof(struct <API key>)), params, params_length); adm_params->hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); adm_params->hdr.pkt_size = sz; adm_params->hdr.src_svc = APR_SVC_ADM; adm_params->hdr.src_domain = APR_DOMAIN_APPS; adm_params->hdr.src_port = port_id; adm_params->hdr.dest_svc = APR_SVC_ADM; adm_params->hdr.dest_domain = APR_DOMAIN_ADSP; adm_params->hdr.dest_port = atomic_read(&this_adm.copp_id[index]); adm_params->hdr.token = port_id; adm_params->hdr.opcode = <API key>; adm_params-><API key> = 0; adm_params-><API key> = 0; adm_params->mem_map_handle = 0; adm_params->module_id = module_id; adm_params->param_id = param_id; adm_params->param_max_size = params_length; adm_params->reserved = 0; atomic_set(&this_adm.copp_stat[index], 0); rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params); if (rc < 0) { ad_loge("%s: Failed to Get Params on port %d\n", __func__, port_id); rc = -EINVAL; goto <API key>; } /* Wait for the callback with copp id */ rc = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!rc) { ad_loge("%s: get params timed out port = %d\n", __func__, port_id); rc = -EINVAL; goto <API key>; } if ((params_data) && (ARRAY_SIZE(adm_get_parameters) >= (1+adm_get_parameters[0])) && (params_length/sizeof(int) >= adm_get_parameters[0])) { for (i = 0; i < adm_get_parameters[0]; i++) params_data[i] = adm_get_parameters[1+i]; } else { pr_err("%s: Get param data not copied! get_param array size %zd, index %d, params array size %zd, index %d\n", __func__, ARRAY_SIZE(adm_get_parameters), (1+adm_get_parameters[0]), params_length/sizeof(int), adm_get_parameters[0]); } rc = 0; <API key>: kfree(adm_params); return rc; } static void <API key>(struct apr_client_data *data) { uint32_t *payload; payload = data->payload; if (data->payload_size >= 8) ad_logd("%s: code = 0x%x PL#0[%x], PL#1[%x], size = %d\n", __func__, data->opcode, payload[0], payload[1], data->payload_size); else if (data->payload_size >= 4) ad_logd("%s: code = 0x%x PL#0[%x], size = %d\n", __func__, data->opcode, payload[0], data->payload_size); else ad_logd("%s: code = 0x%x, size = %d\n", __func__, data->opcode, data->payload_size); } void <API key>(char *channel_map) { memcpy(multi_ch_map.channel_mapping, channel_map, <API key>); multi_ch_map.set_channel_map = true; } void <API key>(char *channel_map) { if (multi_ch_map.set_channel_map) { memcpy(channel_map, multi_ch_map.channel_mapping, <API key>); } } static int32_t adm_callback(struct apr_client_data *data, void *priv) { uint32_t *payload; int i, index; if (data == NULL) { ad_loge("%s: data paramter is null\n", __func__); return -EINVAL; } payload = data->payload; if (data->opcode == RESET_EVENTS) { ad_logd("adm_callback: Reset event is received: %d %d apr[%p]\n", data->reset_event, data->reset_proc, this_adm.apr); if (this_adm.apr) { apr_reset(this_adm.apr); for (i = 0; i < AFE_MAX_PORTS; i++) { atomic_set(&this_adm.copp_id[i], RESET_COPP_ID); atomic_set(&this_adm.copp_low_latency_id[i], RESET_COPP_ID); atomic_set(&this_adm.copp_cnt[i], 0); atomic_set(&this_adm.<API key>[i], 0); atomic_set(&this_adm.copp_perf_mode[i], 0); atomic_set(&this_adm.copp_stat[i], 0); } this_adm.apr = NULL; <API key>(); this_adm.set_custom_topology = 1; for (i = 0; i < ADM_MAX_CAL_TYPES; i++) atomic_set(&this_adm.mem_map_cal_handles[i], 0); rtac_clear_mapping(ADM_RTAC_CAL); } ad_logd("Resetting calibration blocks"); for (i = 0; i < MAX_AUDPROC_TYPES; i++) { /* Device calibration */ this_adm.mem_addr_audproc[i].cal_size = 0; this_adm.mem_addr_audproc[i].cal_kvaddr = 0; this_adm.mem_addr_audproc[i].cal_paddr = 0; /* Volume calibration */ this_adm.mem_addr_audvol[i].cal_size = 0; this_adm.mem_addr_audvol[i].cal_kvaddr = 0; this_adm.mem_addr_audvol[i].cal_paddr = 0; } return 0; } <API key>(data); if (data->payload_size) { index = <API key>(data->token); if (index < 0 || index >= AFE_MAX_PORTS) { ad_loge("%s: invalid port idx %d token %d\n", __func__, index, data->token); return 0; } if (data->opcode == <API key>) { ad_logd("<API key> id %x\n", payload[0]); if (payload[1] != 0) { ad_loge("%s: cmd = 0x%x returned error = 0x%x\n", __func__, payload[0], payload[1]); } switch (payload[0]) { case <API key>: ad_logd("%s: <API key>\n", __func__); if (<API key>( payload, data->payload_size)) { break; } case <API key>: case <API key>: case <API key>: case <API key>: ad_logd("%s: Basic callback received, wake up.\n", __func__); atomic_set(&this_adm.copp_stat[index], 1); wake_up(&this_adm.wait[index]); break; case <API key>: ad_logd("%s: <API key>\n", __func__); /* Should only come here if there is an APR */ /* error or malformed APR packet. Otherwise */ /* response will be returned as */ if (payload[1] != 0) { ad_loge("%s: ADM map error, resuming\n", __func__); atomic_set(&this_adm.copp_stat[index], 1); wake_up(&this_adm.wait[index]); } break; case <API key>: ad_logd("%s: <API key>\n", __func__); /* Should only come here if there is an APR */ /* error or malformed APR packet. Otherwise */ /* response will be returned as */ /* <API key> */ if (payload[1] != 0) { ad_loge("%s: ADM get param error = %d, resuming\n", __func__, payload[1]); <API key>(payload, data->payload_size); } break; case <API key>: ad_logd("%s:<API key>\n", __func__); atomic_set(&this_adm.copp_stat[index], 1); wake_up(&this_adm.wait[index]); break; default: ad_loge("%s: Unknown Cmd: 0x%x\n", __func__, payload[0]); break; } return 0; } switch (data->opcode) { case <API key>: { struct <API key> *open = (struct <API key> *)data->payload; if (open->copp_id == INVALID_COPP_ID) { ad_loge("%s: invalid coppid rxed %d\n", __func__, open->copp_id); atomic_set(&this_adm.copp_stat[index], 1); wake_up(&this_adm.wait[index]); break; } if (atomic_read(&this_adm.copp_perf_mode[index])) { atomic_set(&this_adm.copp_low_latency_id[index], open->copp_id); } else { atomic_set(&this_adm.copp_id[index], open->copp_id); } atomic_set(&this_adm.copp_stat[index], 1); ad_logd("%s: coppid rxed=%d\n", __func__, open->copp_id); wake_up(&this_adm.wait[index]); } break; case <API key>: ad_logd("%s: <API key>\n", __func__); if (payload[0] != 0) ad_loge("%s: <API key> returned error = 0x%x\n", __func__, payload[0]); if (<API key>(payload, data->payload_size)) break; if ((payload[0] == 0) && (data->payload_size > (4 * sizeof(*payload))) && (data->payload_size/sizeof(*payload)-4 >= payload[3]) && (ARRAY_SIZE(adm_get_parameters)-1 >= payload[3])) { adm_get_parameters[0] = payload[3]; pr_debug("%s: GET_PP PARAM:received parameter length: 0x%x\n", __func__, adm_get_parameters[0]); /* storing param size then params */ for (i = 0; i < payload[3]; i++) adm_get_parameters[1+i] = payload[4+i]; } else { adm_get_parameters[0] = -1; pr_err("%s: GET_PP_PARAMS failed, setting size to %d\n", __func__, adm_get_parameters[0]); } atomic_set(&this_adm.copp_stat[index], 1); wake_up(&this_adm.wait[index]); break; case <API key>: ad_logd("%s: <API key>\n", __func__); atomic_set(&this_adm.mem_map_cal_handles[ atomic_read(&this_adm.mem_map_cal_index)], *payload); atomic_set(&this_adm.copp_stat[index], 1); wake_up(&this_adm.wait[index]); break; default: ad_loge("%s: Unknown cmd:0x%x\n", __func__, data->opcode); break; } } return 0; } void <API key>(int port_id) { struct acdb_cal_block cal_block; struct cmd_set_topologies adm_top; int index; int result; int size = 4096; <API key>(&cal_block); if (cal_block.cal_size == 0) { ad_logd("%s: no cal to send addr= 0x%pa\n", __func__, &cal_block.cal_paddr); goto done; } index = afe_get_port_index(port_id); if (index < 0 || index >= AFE_MAX_PORTS) { ad_loge("%s: invalid port idx %d portid % __func__, index, port_id); goto done; } if (this_adm.set_custom_topology) { /* specific index 4 for adm topology memory */ atomic_set(&this_adm.mem_map_cal_index, ADM_CUSTOM_TOP_CAL); /* Only call this once */ this_adm.set_custom_topology = 0; result = <API key>(port_id, &cal_block.cal_paddr, 0, &size, 1); if (result < 0) { ad_loge("%s: mmap did not work! addr = 0x%pa, size = %zd\n", __func__, &cal_block.cal_paddr, cal_block.cal_size); goto done; } } adm_top.hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(20), APR_PKT_VER); adm_top.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, sizeof(adm_top)); adm_top.hdr.src_svc = APR_SVC_ADM; adm_top.hdr.src_domain = APR_DOMAIN_APPS; adm_top.hdr.src_port = port_id; adm_top.hdr.dest_svc = APR_SVC_ADM; adm_top.hdr.dest_domain = APR_DOMAIN_ADSP; adm_top.hdr.dest_port = atomic_read(&this_adm.copp_id[index]); adm_top.hdr.token = port_id; adm_top.hdr.opcode = <API key>; adm_top.payload_addr_lsw = lower_32_bits(cal_block.cal_paddr); adm_top.payload_addr_msw = upper_32_bits(cal_block.cal_paddr); adm_top.mem_map_handle = atomic_read(&this_adm.mem_map_cal_handles[ADM_CUSTOM_TOP_CAL]); adm_top.payload_size = cal_block.cal_size; atomic_set(&this_adm.copp_stat[index], 0); ad_logd("%s: Sending <API key> payload = 0x%x, size = %d\n", __func__, adm_top.payload_addr_lsw, adm_top.payload_size); result = apr_send_pkt(this_adm.apr, (uint32_t *)&adm_top); if (result < 0) { ad_loge("%s: Set topologies failed port = 0x%x payload = 0x%pa\n", __func__, port_id, &cal_block.cal_paddr); goto done; } /* Wait for the callback */ result = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!result) { ad_loge("%s: Set topologies timed out port = 0x%x, payload = 0x%pa\n", __func__, port_id, &cal_block.cal_paddr); goto done; } done: return; } static int send_adm_cal_block(int port_id, struct acdb_cal_block *aud_cal, int perf_mode) { s32 result = 0; struct <API key> adm_params; int index = afe_get_port_index(port_id); if (index < 0 || index >= AFE_MAX_PORTS) { ad_loge("%s: invalid port idx %d portid % __func__, index, port_id); return 0; } ad_logd("%s: Port id %#x, index %d\n", __func__, port_id, index); if (!aud_cal || aud_cal->cal_size == 0) { ad_logd("%s: No ADM cal to send for port_id = % __func__, port_id); result = -EINVAL; goto done; } adm_params.hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(20), APR_PKT_VER); adm_params.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, sizeof(adm_params)); adm_params.hdr.src_svc = APR_SVC_ADM; adm_params.hdr.src_domain = APR_DOMAIN_APPS; adm_params.hdr.src_port = port_id; adm_params.hdr.dest_svc = APR_SVC_ADM; adm_params.hdr.dest_domain = APR_DOMAIN_ADSP; if (perf_mode == LEGACY_PCM_MODE) adm_params.hdr.dest_port = atomic_read(&this_adm.copp_id[index]); else adm_params.hdr.dest_port = atomic_read(&this_adm.copp_low_latency_id[index]); adm_params.hdr.token = port_id; adm_params.hdr.opcode = <API key>; adm_params.payload_addr_lsw = lower_32_bits(aud_cal->cal_paddr); adm_params.payload_addr_msw = upper_32_bits(aud_cal->cal_paddr); adm_params.mem_map_handle = atomic_read(&this_adm.mem_map_cal_handles[ atomic_read(&this_adm.mem_map_cal_index)]); adm_params.payload_size = aud_cal->cal_size; atomic_set(&this_adm.copp_stat[index], 0); ad_logd("%s: Sending SET_PARAMS payload = 0x%x, size = %d\n", __func__, adm_params.payload_addr_lsw, adm_params.payload_size); result = apr_send_pkt(this_adm.apr, (uint32_t *)&adm_params); if (result < 0) { ad_loge("%s: Set params failed port = %#x payload = 0x%pa\n", __func__, port_id, &aud_cal->cal_paddr); result = -EINVAL; goto done; } /* Wait for the callback */ result = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!result) { ad_loge("%s: Set params timed out port = %#x, payload = 0x%pa\n", __func__, port_id, &aud_cal->cal_paddr); result = -EINVAL; goto done; } result = 0; done: return result; } static void send_adm_cal(int port_id, int path, int perf_mode) { int result = 0; s32 acdb_path; struct acdb_cal_block aud_cal; int size; ad_logd("%s\n", __func__); /* Maps audio_dev_ctrl path definition to ACDB definition */ acdb_path = path - 1; if (acdb_path == TX_CAL) size = 4096 * 4; else size = 4096; ad_logd("%s: Sending audproc cal\n", __func__); get_audproc_cal(acdb_path, &aud_cal); /* map & cache buffers used */ atomic_set(&this_adm.mem_map_cal_index, acdb_path); if (((this_adm.mem_addr_audproc[acdb_path].cal_paddr != aud_cal.cal_paddr) && (aud_cal.cal_size > 0)) || (aud_cal.cal_size > this_adm.mem_addr_audproc[acdb_path].cal_size)) { if (this_adm.mem_addr_audproc[acdb_path].cal_paddr != 0) <API key>(port_id); result = <API key>(port_id, &aud_cal.cal_paddr, 0, &size, 1); if (result < 0) { ad_loge("ADM audproc mmap did not work! path = %d, addr = 0x%pa, size = %zd\n", acdb_path, &aud_cal.cal_paddr, aud_cal.cal_size); } else { this_adm.mem_addr_audproc[acdb_path].cal_paddr = aud_cal.cal_paddr; this_adm.mem_addr_audproc[acdb_path].cal_size = size; } } if (!send_adm_cal_block(port_id, &aud_cal, perf_mode)) ad_logd("%s: Audproc cal sent for port id: %#x, path %d\n", __func__, port_id, acdb_path); else ad_logd("%s: Audproc cal not sent for port id: %#x, path %d\n", __func__, port_id, acdb_path); ad_logd("%s: Sending audvol cal\n", __func__); get_audvol_cal(acdb_path, &aud_cal); /* map & cache buffers used */ atomic_set(&this_adm.mem_map_cal_index, (acdb_path + MAX_AUDPROC_TYPES)); if (((this_adm.mem_addr_audvol[acdb_path].cal_paddr != aud_cal.cal_paddr) && (aud_cal.cal_size > 0)) || (aud_cal.cal_size > this_adm.mem_addr_audvol[acdb_path].cal_size)) { if (this_adm.mem_addr_audvol[acdb_path].cal_paddr != 0) <API key>(port_id); result = <API key>(port_id, &aud_cal.cal_paddr, 0, &size, 1); if (result < 0) { ad_loge("ADM audvol mmap did not work! path = %d, addr = 0x%pa, size = %zd\n", acdb_path, &aud_cal.cal_paddr, aud_cal.cal_size); } else { this_adm.mem_addr_audvol[acdb_path].cal_paddr = aud_cal.cal_paddr; this_adm.mem_addr_audvol[acdb_path].cal_size = size; } } if (!send_adm_cal_block(port_id, &aud_cal, perf_mode)) ad_logd("%s: Audvol cal sent for port id: %#x, path %d\n", __func__, port_id, acdb_path); else ad_logd("%s: Audvol cal not sent for port id: %#x, path %d\n", __func__, port_id, acdb_path); } int adm_map_rtac_block(struct rtac_cal_block_data *cal_block) { int result = 0; ad_logd("%s\n", __func__); if (cal_block == NULL) { ad_loge("%s: cal_block is NULL!\n", __func__); result = -EINVAL; goto done; } if (cal_block->cal_data.paddr == 0) { ad_logd("%s: No address to map!\n", __func__); result = -EINVAL; goto done; } if (cal_block->map_data.map_size == 0) { ad_logd("%s: map size is 0!\n", __func__); result = -EINVAL; goto done; } /* valid port ID needed for callback use primary I2S */ atomic_set(&this_adm.mem_map_cal_index, ADM_RTAC); result = <API key>(PRIMARY_I2S_RX, &cal_block->cal_data.paddr, 0, &cal_block->map_data.map_size, 1); if (result < 0) { ad_loge("%s: RTAC mmap did not work! addr = 0x%pa, size = %d\n", __func__, &cal_block->cal_data.paddr, cal_block->map_data.map_size); goto done; } cal_block->map_data.map_handle = atomic_read( &this_adm.mem_map_cal_handles[ADM_RTAC]); done: return result; } int <API key>(uint32_t *mem_map_handle) { int result = 0; ad_logd("%s\n", __func__); if (mem_map_handle == NULL) { ad_logd("%s: Map handle is NULL, nothing to unmap\n", __func__); goto done; } if (*mem_map_handle == 0) { ad_logd("%s: Map handle is 0, nothing to unmap\n", __func__); goto done; } if (*mem_map_handle != atomic_read( &this_adm.mem_map_cal_handles[ADM_RTAC])) { ad_loge("%s: Map handles do not match! Unmapping RTAC, RTAC map 0x%x, ADM map 0x%x\n", __func__, *mem_map_handle, atomic_read( &this_adm.mem_map_cal_handles[ADM_RTAC])); /* if mismatch use handle passed in to unmap */ atomic_set(&this_adm.mem_map_cal_handles[ADM_RTAC], *mem_map_handle); } /* valid port ID needed for callback use primary I2S */ atomic_set(&this_adm.mem_map_cal_index, ADM_RTAC); result = <API key>(PRIMARY_I2S_RX); if (result < 0) { ad_logd("%s: <API key> failed, error %d\n", __func__, result); } else { atomic_set(&this_adm.mem_map_cal_handles[ADM_RTAC], 0); *mem_map_handle = 0; } done: return result; } int <API key>(void) { int i; int result = 0; int result2 = 0; for (i = 0; i < ADM_MAX_CAL_TYPES; i++) { if (atomic_read(&this_adm.mem_map_cal_handles[i]) != 0) { if (i <= ADM_TX_AUDPROC_CAL) { this_adm.mem_addr_audproc[i].cal_paddr = 0; this_adm.mem_addr_audproc[i].cal_size = 0; } else if (i <= ADM_TX_AUDVOL_CAL) { this_adm.mem_addr_audvol [(i - ADM_RX_AUDVOL_CAL)].cal_paddr = 0; this_adm.mem_addr_audvol [(i - ADM_RX_AUDVOL_CAL)].cal_size = 0; } else if (i == ADM_CUSTOM_TOP_CAL) { this_adm.set_custom_topology = 1; } else { continue; } /* valid port ID needed for callback use primary I2S */ atomic_set(&this_adm.mem_map_cal_index, i); result2 = <API key>(PRIMARY_I2S_RX); if (result2 < 0) { ad_loge("%s: <API key> failed, err %d\n", __func__, result2); result = result2; } else { atomic_set(&this_adm.mem_map_cal_handles[i], 0); } } } return result; } int <API key>(int mode, int session_id, int port_id) { struct <API key> cmd; int ret = 0; int index; ad_logd("%s: port %d session id:%d mode:%d\n", __func__, port_id, session_id, mode); port_id = <API key>(port_id); if (afe_validate_port(port_id) < 0) { ad_loge("%s port idi[%d] is invalid\n", __func__, port_id); return -ENODEV; } if (this_adm.apr == NULL) { this_adm.apr = apr_register("ADSP", "ADM", adm_callback, 0xFFFFFFFF, &this_adm); if (this_adm.apr == NULL) { ad_loge("%s: Unable to register ADM\n", __func__); ret = -ENODEV; return ret; } rtac_set_adm_handle(this_adm.apr); } index = afe_get_port_index(port_id); ad_logd("%s: Port ID %#x, index %d\n", __func__, port_id, index); cmd.hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); cmd.hdr.pkt_size = sizeof(cmd); cmd.hdr.src_svc = APR_SVC_ADM; cmd.hdr.src_domain = APR_DOMAIN_APPS; cmd.hdr.src_port = port_id; cmd.hdr.dest_svc = APR_SVC_ADM; cmd.hdr.dest_domain = APR_DOMAIN_ADSP; cmd.hdr.dest_port = port_id; cmd.hdr.token = port_id; cmd.hdr.opcode = <API key>; cmd.mode = mode; cmd.session_id = session_id; cmd.afe_port_id = port_id; atomic_set(&this_adm.copp_stat[index], 0); ret = apr_send_pkt(this_adm.apr, (uint32_t *)&cmd); if (ret < 0) { ad_loge("%s:ADM enable for port %#x failed\n", __func__, port_id); ret = -EINVAL; goto fail_cmd; } /* Wait for the callback with copp id */ ret = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { ad_loge("%s ADM connect AFE failed for port %#x\n", __func__, port_id); ret = -EINVAL; goto fail_cmd; } atomic_inc(&this_adm.copp_cnt[index]); return 0; fail_cmd: return ret; } int adm_open(int port_id, int path, int rate, int channel_mode, int topology, int perf_mode, uint16_t bits_per_sample) { struct <API key> open; int ret = 0; int index; int tmp_port = q6audio_get_port_id(port_id); ad_logd("%s: port %#x path:%d rate:%d mode:%d perf_mode:%d\n", __func__, port_id, path, rate, channel_mode, perf_mode); port_id = <API key>(port_id); if (<API key>(port_id) < 0) { ad_loge("%s port idi[%#x] is invalid\n", __func__, port_id); return -ENODEV; } index = <API key>(port_id); ad_logd("%s: Port ID %#x, index %d\n", __func__, port_id, index); if (this_adm.apr == NULL) { this_adm.apr = apr_register("ADSP", "ADM", adm_callback, 0xFFFFFFFF, &this_adm); if (this_adm.apr == NULL) { ad_loge("%s: Unable to register ADM\n", __func__); ret = -ENODEV; return ret; } rtac_set_adm_handle(this_adm.apr); } if (perf_mode == LEGACY_PCM_MODE) { atomic_set(&this_adm.copp_perf_mode[index], 0); <API key>(port_id); } else { atomic_set(&this_adm.copp_perf_mode[index], 1); } /* Create a COPP if port id are not enabled */ if ((perf_mode == LEGACY_PCM_MODE && (atomic_read(&this_adm.copp_cnt[index]) == 0)) || (perf_mode != LEGACY_PCM_MODE && (atomic_read(&this_adm.<API key>[index]) == 0))) { ad_logd("%s:opening ADM: perf_mode: %d\n", __func__, perf_mode); open.hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); open.hdr.pkt_size = sizeof(open); open.hdr.src_svc = APR_SVC_ADM; open.hdr.src_domain = APR_DOMAIN_APPS; open.hdr.src_port = tmp_port; open.hdr.dest_svc = APR_SVC_ADM; open.hdr.dest_domain = APR_DOMAIN_ADSP; open.hdr.dest_port = tmp_port; open.hdr.token = port_id; open.hdr.opcode = <API key>; if (perf_mode == <API key>) open.flags = <API key>; else if (perf_mode == <API key>) open.flags = <API key>; else open.flags = <API key>; open.mode_of_operation = path; open.endpoint_id_1 = tmp_port; if (this_adm.ec_ref_rx == -1) { open.endpoint_id_2 = 0xFFFF; } else if (this_adm.ec_ref_rx && (path != 1)) { open.endpoint_id_2 = this_adm.ec_ref_rx; this_adm.ec_ref_rx = -1; } open.topology_id = topology; if ((open.topology_id == <API key>) || (open.topology_id == <API key>) || (open.topology_id == <API key>)) rate = 16000; if (perf_mode == <API key>) { open.topology_id = NULL_COPP_TOPOLOGY; rate = <API key>; } else if (perf_mode == <API key>) { if ((open.topology_id == <API key>) || (open.topology_id == <API key>)) open.topology_id = <API key>; } open.dev_num_channel = channel_mode & 0x00FF; open.bit_width = bits_per_sample; WARN_ON(perf_mode == <API key> && (rate != 48000)); open.sample_rate = rate; memset(open.dev_channel_mapping, 0, 8); if (channel_mode == 1) { open.dev_channel_mapping[0] = PCM_CHANNEL_FC; } else if (channel_mode == 2) { open.dev_channel_mapping[0] = PCM_CHANNEL_FL; open.dev_channel_mapping[1] = PCM_CHANNEL_FR; } else if (channel_mode == 3) { open.dev_channel_mapping[0] = PCM_CHANNEL_FL; open.dev_channel_mapping[1] = PCM_CHANNEL_FR; open.dev_channel_mapping[2] = PCM_CHANNEL_FC; } else if (channel_mode == 4) { open.dev_channel_mapping[0] = PCM_CHANNEL_FL; open.dev_channel_mapping[1] = PCM_CHANNEL_FR; open.dev_channel_mapping[2] = PCM_CHANNEL_RB; open.dev_channel_mapping[3] = PCM_CHANNEL_LB; } else if (channel_mode == 5) { open.dev_channel_mapping[0] = PCM_CHANNEL_FL; open.dev_channel_mapping[1] = PCM_CHANNEL_FR; open.dev_channel_mapping[2] = PCM_CHANNEL_FC; open.dev_channel_mapping[3] = PCM_CHANNEL_LB; open.dev_channel_mapping[4] = PCM_CHANNEL_RB; } else if (channel_mode == 6) { open.dev_channel_mapping[0] = PCM_CHANNEL_FL; open.dev_channel_mapping[1] = PCM_CHANNEL_FR; open.dev_channel_mapping[2] = PCM_CHANNEL_LFE; open.dev_channel_mapping[3] = PCM_CHANNEL_FC; open.dev_channel_mapping[4] = PCM_CHANNEL_LS; open.dev_channel_mapping[5] = PCM_CHANNEL_RS; } else if (channel_mode == 8) { open.dev_channel_mapping[0] = PCM_CHANNEL_FL; open.dev_channel_mapping[1] = PCM_CHANNEL_FR; open.dev_channel_mapping[2] = PCM_CHANNEL_LFE; open.dev_channel_mapping[3] = PCM_CHANNEL_FC; open.dev_channel_mapping[4] = PCM_CHANNEL_LB; open.dev_channel_mapping[5] = PCM_CHANNEL_RB; open.dev_channel_mapping[6] = PCM_CHANNEL_FLC; open.dev_channel_mapping[7] = PCM_CHANNEL_FRC; } else { ad_loge("%s invalid num_chan %d\n", __func__, channel_mode); return -EINVAL; } if ((open.dev_num_channel > 2) && multi_ch_map.set_channel_map) memcpy(open.dev_channel_mapping, multi_ch_map.channel_mapping, <API key>); ad_logd("%s: port_id=%#x rate=%d topology_id=0x%X\n", __func__, open.endpoint_id_1, open.sample_rate, open.topology_id); atomic_set(&this_adm.copp_stat[index], 0); ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open); if (ret < 0) { ad_loge("%s:ADM enable for port %#x for[%d] failed\n", __func__, tmp_port, port_id); ret = -EINVAL; goto fail_cmd; } /* Wait for the callback with copp id */ ret = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { ad_loge("%s ADM open failed for port %#x for [%d]\n", __func__, tmp_port, port_id); ret = -EINVAL; goto fail_cmd; } } if (perf_mode == <API key> || perf_mode == <API key>) { atomic_inc(&this_adm.<API key>[index]); ad_logd("%s: index: %d coppid: %d", __func__, index, atomic_read(&this_adm.copp_low_latency_id[index])); } else { atomic_inc(&this_adm.copp_cnt[index]); ad_logd("%s: index: %d coppid: %d", __func__, index, atomic_read(&this_adm.copp_id[index])); } return 0; fail_cmd: return ret; } int <API key>(int port_id, int path, int rate, int channel_mode, int topology, int perf_mode, uint16_t bits_per_sample) { int ret = 0; ret = adm_open(port_id, path, rate, channel_mode, topology, perf_mode, bits_per_sample); return ret; } int adm_matrix_map(int session_id, int path, int num_copps, unsigned int *port_id, int copp_id, int perf_mode) { struct <API key> *route; struct <API key> *node; uint16_t *copps_list; int cmd_size = 0; int ret = 0, i = 0; void *payload = NULL; void *matrix_map = NULL; /* Assumes port_ids have already been validated during adm_open */ int index = <API key>(copp_id); if (index < 0 || index >= AFE_MAX_PORTS) { ad_loge("%s: invalid port idx %d token %d\n", __func__, index, copp_id); return 0; } cmd_size = (sizeof(struct <API key>) + sizeof(struct <API key>) + (sizeof(uint32_t) * num_copps)); matrix_map = kzalloc(cmd_size, GFP_KERNEL); if (matrix_map == NULL) { ad_loge("%s: Mem alloc failed\n", __func__); ret = -EINVAL; return ret; } route = (struct <API key> *)matrix_map; ad_logd("%s: session 0x%x path:%d num_copps:%d port_id[0]:%#x coppid[%d]\n", __func__, session_id, path, num_copps, port_id[0], copp_id); route->hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); route->hdr.pkt_size = cmd_size; route->hdr.src_svc = 0; route->hdr.src_domain = APR_DOMAIN_APPS; route->hdr.src_port = copp_id; route->hdr.dest_svc = APR_SVC_ADM; route->hdr.dest_domain = APR_DOMAIN_ADSP; if (perf_mode == <API key> || perf_mode == <API key>) { route->hdr.dest_port = atomic_read(&this_adm.copp_low_latency_id[index]); } else { route->hdr.dest_port = atomic_read(&this_adm.copp_id[index]); } route->hdr.token = copp_id; route->hdr.opcode = <API key>; route->num_sessions = 1; switch (path) { case 0x1: route->matrix_id = <API key>; break; case 0x2: case 0x3: route->matrix_id = <API key>; break; default: ad_loge("%s: Wrong path set[%d]\n", __func__, path); break; } payload = ((u8 *)matrix_map + sizeof(struct <API key>)); node = (struct <API key> *)payload; node->session_id = session_id; node->num_copps = num_copps; payload = (u8 *)node + sizeof(struct <API key>); copps_list = (uint16_t *)payload; for (i = 0; i < num_copps; i++) { int tmp; port_id[i] = <API key>(port_id[i]); tmp = <API key>(port_id[i]); if (tmp >= 0 && tmp < AFE_MAX_PORTS) { if (perf_mode == <API key> || perf_mode == <API key>) copps_list[i] = atomic_read(&this_adm.copp_low_latency_id[tmp]); else copps_list[i] = atomic_read(&this_adm.copp_id[tmp]); } else continue; ad_logd("%s: port_id[%#x]: %d, index: %d act coppid[0x%x]\n", __func__, i, port_id[i], tmp, copps_list[i]); } atomic_set(&this_adm.copp_stat[index], 0); ret = apr_send_pkt(this_adm.apr, (uint32_t *)matrix_map); if (ret < 0) { ad_loge("%s: ADM routing for port %#x failed\n", __func__, port_id[0]); ret = -EINVAL; goto fail_cmd; } ret = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { ad_loge("%s: ADM cmd Route failed for port % __func__, port_id[0]); ret = -EINVAL; goto fail_cmd; } if (perf_mode != <API key>) { for (i = 0; i < num_copps; i++) send_adm_cal(port_id[i], path, perf_mode); for (i = 0; i < num_copps; i++) { int tmp, copp_id; tmp = afe_get_port_index(port_id[i]); if (tmp >= 0 && tmp < AFE_MAX_PORTS) { if (perf_mode == LEGACY_PCM_MODE) copp_id = atomic_read( &this_adm.copp_id[tmp]); else copp_id = atomic_read( &this_adm.copp_low_latency_id[tmp]); rtac_add_adm_device(port_id[i], copp_id, path, session_id); ad_logd("%s, copp_id: %d\n", __func__, copp_id); } else ad_logd("%s: Invalid port index %d", __func__, tmp); } } fail_cmd: kfree(matrix_map); return ret; } int <API key>(int port_id, phys_addr_t *buf_add, uint32_t mempool_id, uint32_t *bufsz, uint32_t bufcnt) { struct <API key> *mmap_regions = NULL; struct <API key> *mregions = NULL; void *mmap_region_cmd = NULL; void *payload = NULL; int ret = 0; int i = 0; int cmd_size = 0; int index = 0; ad_logd("%s\n", __func__); if (this_adm.apr == NULL) { this_adm.apr = apr_register("ADSP", "ADM", adm_callback, 0xFFFFFFFF, &this_adm); if (this_adm.apr == NULL) { ad_loge("%s: Unable to register ADM\n", __func__); ret = -ENODEV; return ret; } rtac_set_adm_handle(this_adm.apr); } port_id = <API key>(port_id); if (<API key>(port_id) < 0) { ad_loge("%s port id[%#x] is invalid\n", __func__, port_id); return -ENODEV; } index = <API key>(port_id); cmd_size = sizeof(struct <API key>) + sizeof(struct <API key>) * bufcnt; mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL); if (!mmap_region_cmd) { ad_loge("%s: allocate mmap_region_cmd failed\n", __func__); return -ENOMEM; } mmap_regions = (struct <API key> *)mmap_region_cmd; mmap_regions->hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); mmap_regions->hdr.pkt_size = cmd_size; mmap_regions->hdr.src_port = 0; mmap_regions->hdr.dest_port = atomic_read(&this_adm.copp_id[index]); mmap_regions->hdr.token = port_id; mmap_regions->hdr.opcode = <API key>; mmap_regions->mem_pool_id = <API key> & 0x00ff; mmap_regions->num_regions = bufcnt & 0x00ff; mmap_regions->property_flag = 0x00; ad_logd("%s: map_regions->num_regions = %d\n", __func__, mmap_regions->num_regions); payload = ((u8 *) mmap_region_cmd + sizeof(struct <API key>)); mregions = (struct <API key> *)payload; for (i = 0; i < bufcnt; i++) { mregions->shm_addr_lsw = lower_32_bits(buf_add[i]); mregions->shm_addr_msw = upper_32_bits(buf_add[i]); mregions->mem_size_bytes = bufsz[i]; ++mregions; } atomic_set(&this_adm.copp_stat[index], 0); ret = apr_send_pkt(this_adm.apr, (uint32_t *) mmap_region_cmd); if (ret < 0) { ad_loge("%s: mmap_regions op[0x%x]rc[%d]\n", __func__, mmap_regions->hdr.opcode, ret); ret = -EINVAL; goto fail_cmd; } ret = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), 5 * HZ); if (!ret) { ad_loge("%s: timeout. waited for memory_map\n", __func__); ret = -EINVAL; goto fail_cmd; } fail_cmd: kfree(mmap_region_cmd); return ret; } int <API key>(int32_t port_id) { struct <API key> unmap_regions; int ret = 0; int index = 0; ad_logd("%s\n", __func__); if (this_adm.apr == NULL) { ad_loge("%s APR handle NULL\n", __func__); return -EINVAL; } port_id = <API key>(port_id); if (<API key>(port_id) < 0) { ad_loge("%s port idi[%d] is invalid\n", __func__, port_id); return -ENODEV; } index = <API key>(port_id); unmap_regions.hdr.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); unmap_regions.hdr.pkt_size = sizeof(unmap_regions); unmap_regions.hdr.src_port = 0; unmap_regions.hdr.dest_port = atomic_read(&this_adm.copp_id[index]); unmap_regions.hdr.token = port_id; unmap_regions.hdr.opcode = <API key>; unmap_regions.mem_map_handle = atomic_read(&this_adm. mem_map_cal_handles[atomic_read(&this_adm.mem_map_cal_index)]); atomic_set(&this_adm.copp_stat[index], 0); ret = apr_send_pkt(this_adm.apr, (uint32_t *) &unmap_regions); if (ret < 0) { ad_loge("%s: mmap_regions op[0x%x]rc[%d]\n", __func__, unmap_regions.hdr.opcode, ret); ret = -EINVAL; goto fail_cmd; } ret = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), 5 * HZ); if (!ret) { ad_loge("%s: timeout. waited for memory_unmap index %d\n", __func__, index); ret = -EINVAL; goto fail_cmd; } else { ad_logd("%s: Unmap handle 0x%x succeeded\n", __func__, unmap_regions.mem_map_handle); } fail_cmd: return ret; } #ifdef CONFIG_RTAC int adm_get_copp_id(int port_index) { int copp_id; ad_logd("%s\n", __func__); if (port_index < 0) { ad_loge("%s: invalid port_id = %d\n", __func__, port_index); return -EINVAL; } copp_id = atomic_read(&this_adm.copp_id[port_index]); if (copp_id == RESET_COPP_ID) copp_id = atomic_read( &this_adm.copp_low_latency_id[port_index]); return copp_id; } int <API key>(int port_index) { ad_logd("%s\n", __func__); if (port_index < 0) { ad_loge("%s: invalid port_id = %d\n", __func__, port_index); return -EINVAL; } return atomic_read(&this_adm.copp_low_latency_id[port_index]); } #else int adm_get_copp_id(int port_index) { return -EINVAL; } int <API key>(int port_index) { return -EINVAL; } #endif /* #ifdef CONFIG_RTAC */ void adm_ec_ref_rx_id(int port_id) { this_adm.ec_ref_rx = port_id; ad_logd("%s ec_ref_rx:%d", __func__, this_adm.ec_ref_rx); } int adm_close(int port_id, int perf_mode) { struct apr_hdr close; int ret = 0; int index = 0; int copp_id = RESET_COPP_ID; port_id = <API key>(port_id); index = <API key>(port_id); if (<API key>(port_id) < 0) return -EINVAL; ad_logd("%s port_id=%#x index %d perf_mode: %d\n", __func__, port_id, index, perf_mode); if (perf_mode == <API key> || perf_mode == <API key>) { if (!(atomic_read(&this_adm.<API key>[index]))) { ad_loge("%s: copp count for port[%#x]is 0\n", __func__, port_id); goto fail_cmd; } atomic_dec(&this_adm.<API key>[index]); } else { if (!(atomic_read(&this_adm.copp_cnt[index]))) { ad_loge("%s: copp count for port[%#x]is 0\n", __func__, port_id); goto fail_cmd; } atomic_dec(&this_adm.copp_cnt[index]); } if ((perf_mode == LEGACY_PCM_MODE && !(atomic_read(&this_adm.copp_cnt[index]))) || ((perf_mode != LEGACY_PCM_MODE) && !(atomic_read(&this_adm.<API key>[index])))) { ad_logd("%s:Closing ADM: perf_mode: %d\n", __func__, perf_mode); close.hdr_field = APR_HDR_FIELD(<API key>, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); close.pkt_size = sizeof(close); close.src_svc = APR_SVC_ADM; close.src_domain = APR_DOMAIN_APPS; close.src_port = port_id; close.dest_svc = APR_SVC_ADM; close.dest_domain = APR_DOMAIN_ADSP; if (perf_mode == <API key> || perf_mode == <API key>) close.dest_port = atomic_read(&this_adm.copp_low_latency_id[index]); else close.dest_port = atomic_read(&this_adm.copp_id[index]); close.token = port_id; close.opcode = <API key>; atomic_set(&this_adm.copp_stat[index], 0); if (perf_mode == <API key> || perf_mode == <API key>) { copp_id = atomic_read( &this_adm.copp_low_latency_id[index]); ad_logd("%s:coppid %d portid=%#x index=%d coppcnt=%d\n", __func__, copp_id, port_id, index, atomic_read( &this_adm.<API key>[index])); atomic_set(&this_adm.copp_low_latency_id[index], RESET_COPP_ID); } else { copp_id = atomic_read(&this_adm.copp_id[index]); ad_logd("%s:coppid %d portid=%#x index=%d coppcnt=%d\n", __func__, copp_id, port_id, index, atomic_read(&this_adm.copp_cnt[index])); atomic_set(&this_adm.copp_id[index], RESET_COPP_ID); } ret = apr_send_pkt(this_adm.apr, (uint32_t *)&close); if (ret < 0) { ad_loge("%s ADM close failed\n", __func__); ret = -EINVAL; goto fail_cmd; } ret = wait_event_timeout(this_adm.wait[index], atomic_read(&this_adm.copp_stat[index]), msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { ad_loge("%s: ADM cmd Route failed for port % __func__, port_id); ret = -EINVAL; goto fail_cmd; } } if (perf_mode != <API key>) { ad_logd("%s: remove adm device from rtac\n", __func__); <API key>(port_id, copp_id); } fail_cmd: return ret; } static int __init adm_init(void) { int i = 0; this_adm.apr = NULL; this_adm.set_custom_topology = 1; this_adm.ec_ref_rx = -1; for (i = 0; i < AFE_MAX_PORTS; i++) { atomic_set(&this_adm.copp_id[i], RESET_COPP_ID); atomic_set(&this_adm.copp_low_latency_id[i], RESET_COPP_ID); atomic_set(&this_adm.copp_cnt[i], 0); atomic_set(&this_adm.<API key>[i], 0); atomic_set(&this_adm.copp_stat[i], 0); atomic_set(&this_adm.copp_perf_mode[i], 0); init_waitqueue_head(&this_adm.wait[i]); } return 0; } device_initcall(adm_init);
#include "i8042prt.h" #include <debug.h> /* This is all pretty confusing. There's more than one way to * disable/enable the keyboard. You can send KBD_ENABLE to the * keyboard, and it will start scanning keys. Sending KBD_DISABLE * will disable the key scanning but also reset the parameters to * defaults. * * You can also send 0xAE to the controller for enabling the * keyboard clock line and 0xAD for disabling it. Then it'll * automatically get turned on at the next command. The last * way is by modifying the bit that drives the clock line in the * 'command byte' of the controller. This is almost, but not quite, * the same as the AE/AD thing. The difference can be used to detect * some really old broken keyboard controllers which I hope won't be * necessary. * * We change the command byte, sending KBD_ENABLE/DISABLE seems to confuse * some kvm switches. */ BOOLEAN i8042ChangeMode( IN <API key> DeviceExtension, IN UCHAR FlagsToDisable, IN UCHAR FlagsToEnable) { UCHAR Value; NTSTATUS Status; if (!i8042Write(DeviceExtension, DeviceExtension->ControlPort, KBD_READ_MODE)) { WARN_(I8042PRT, "Can't read i8042 mode\n"); return FALSE; } Status = i8042ReadDataWait(DeviceExtension, &Value); if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "No response after read i8042 mode\n"); return FALSE; } Value &= ~FlagsToDisable; Value |= FlagsToEnable; if (!i8042Write(DeviceExtension, DeviceExtension->ControlPort, KBD_WRITE_MODE)) { WARN_(I8042PRT, "Can't set i8042 mode\n"); return FALSE; } if (!i8042Write(DeviceExtension, DeviceExtension->DataPort, Value)) { WARN_(I8042PRT, "Can't send i8042 mode\n"); return FALSE; } return TRUE; } static NTSTATUS i8042BasicDetect( IN <API key> DeviceExtension) { NTSTATUS Status; ULONG ResendIterations; UCHAR Value = 0; /* Don't enable keyboard and mouse interrupts, disable keyboard/mouse */ i8042Flush(DeviceExtension); if (!i8042ChangeMode(DeviceExtension, CCB_KBD_INT_ENAB | CCB_MOUSE_INT_ENAB, CCB_KBD_DISAB | CCB_MOUSE_DISAB)) return <API key>; i8042Flush(DeviceExtension); /* Issue a CTRL_SELF_TEST command to check if this is really an i8042 controller */ ResendIterations = DeviceExtension->Settings.ResendIterations + 1; while (ResendIterations { if (!i8042Write(DeviceExtension, DeviceExtension->ControlPort, CTRL_SELF_TEST)) { WARN_(I8042PRT, "Writing CTRL_SELF_TEST command failed\n"); return STATUS_IO_TIMEOUT; } Status = i8042ReadDataWait(DeviceExtension, &Value); if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "Failed to read CTRL_SELF_TEST response, status 0x%08lx\n", Status); return Status; } if (Value == KBD_SELF_TEST_OK) { INFO_(I8042PRT, "CTRL_SELF_TEST completed successfully!\n"); break; } else if (Value == KBD_RESEND) { TRACE_(I8042PRT, "Resending...\n"); <API key>(50); } else { WARN_(I8042PRT, "Got 0x%02x instead of 0x55\n", Value); return <API key>; } } return STATUS_SUCCESS; } static VOID i8042DetectKeyboard( IN <API key> DeviceExtension) { NTSTATUS Status; /* Set LEDs (that is not fatal if some error occurs) */ Status = i8042SynchWritePort(DeviceExtension, 0, KBD_CMD_SET_LEDS, TRUE); if (NT_SUCCESS(Status)) { Status = i8042SynchWritePort(DeviceExtension, 0, 0, TRUE); if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "Can't finish SET_LEDS (0x%08lx)\n", Status); return; } } else { WARN_(I8042PRT, "Warning: can't write SET_LEDS (0x%08lx)\n", Status); } /* Turn on translation and SF (Some machines don't reboot if SF is not set, see ReactOS bug CORE-1713) */ if (!i8042ChangeMode(DeviceExtension, 0, CCB_TRANSLATE | CCB_SYSTEM_FLAG)) return; /* * We used to send a KBD_LINE_TEST (0xAB) command, but on at least HP * Pavilion notebooks the response to that command was incorrect. * So now we just assume that a keyboard is attached. */ DeviceExtension->Flags |= KEYBOARD_PRESENT; INFO_(I8042PRT, "Keyboard detected\n"); } static VOID i8042DetectMouse( IN <API key> DeviceExtension) { NTSTATUS Status; UCHAR Value; UCHAR ExpectedReply[] = { MOUSE_ACK, 0xAA }; UCHAR ReplyByte; /* First do a mouse line test */ if (i8042Write(DeviceExtension, DeviceExtension->ControlPort, MOUSE_LINE_TEST)) { Status = i8042ReadDataWait(DeviceExtension, &Value); if (!NT_SUCCESS(Status) || Value != 0) { WARN_(I8042PRT, "Mouse line test failed\n"); goto failure; } } /* Now reset the mouse */ i8042Flush(DeviceExtension); if(!i8042IsrWritePort(DeviceExtension, MOU_CMD_RESET, CTRL_WRITE_MOUSE)) { WARN_(I8042PRT, "Failed to write reset command to mouse\n"); goto failure; } /* The implementation of the "Mouse Reset" command differs much from chip to chip. By default, the first byte is an ACK, when the mouse is plugged in and working and NACK when it's not. On success, the next bytes are 0xAA and 0x00. But on some systems (like ECS K7S5A Pro, SiS 735 chipset), we always get an ACK and 0xAA. Only the last byte indicates, whether a mouse is plugged in. It is either sent or not, so there is no byte, which indicates a failure here. After the Mouse Reset command was issued, it usually takes some time until we get a response. So get the first two bytes in a loop. */ for (ReplyByte = 0; ReplyByte < sizeof(ExpectedReply) / sizeof(ExpectedReply[0]); ReplyByte++) { ULONG Counter = 500; do { Status = i8042ReadDataWait(DeviceExtension, &Value); if(!NT_SUCCESS(Status)) { /* Wait some time before trying again */ <API key>(50); } } while (Status == STATUS_IO_TIMEOUT && Counter if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "No ACK after mouse reset, status 0x%08lx\n", Status); goto failure; } else if (Value != ExpectedReply[ReplyByte]) { WARN_(I8042PRT, "Unexpected reply: 0x%02x (expected 0x%02x)\n", Value, ExpectedReply[ReplyByte]); goto failure; } } /* Finally get the third byte, but only try it one time (see above). Otherwise this takes around 45 seconds on a K7S5A Pro, when no mouse is plugged in. */ Status = i8042ReadDataWait(DeviceExtension, &Value); if(!NT_SUCCESS(Status)) { WARN_(I8042PRT, "Last byte was not transmitted after mouse reset, status 0x%08lx\n", Status); goto failure; } else if(Value != 0x00) { WARN_(I8042PRT, "Last byte after mouse reset was not 0x00, but 0x%02x\n", Value); goto failure; } DeviceExtension->Flags |= MOUSE_PRESENT; INFO_(I8042PRT, "Mouse detected\n"); return; failure: /* There is probably no mouse present. On some systems, the probe locks the entire keyboard controller. Let's try to get access to the keyboard again by sending a reset */ i8042Flush(DeviceExtension); i8042Write(DeviceExtension, DeviceExtension->ControlPort, CTRL_SELF_TEST); i8042ReadDataWait(DeviceExtension, &Value); i8042Flush(DeviceExtension); INFO_(I8042PRT, "Mouse not detected\n"); } static NTSTATUS <API key>( IN <API key> DeviceExtension) { <API key> PortDeviceExtension; KIRQL DirqlMax; NTSTATUS Status; TRACE_(I8042PRT, "<API key>()\n"); PortDeviceExtension = DeviceExtension->Common.PortDeviceExtension; DirqlMax = MAX( PortDeviceExtension->KeyboardInterrupt.Dirql, PortDeviceExtension->MouseInterrupt.Dirql); INFO_(I8042PRT, "KeyboardInterrupt.Vector %lu\n", PortDeviceExtension->KeyboardInterrupt.Vector); INFO_(I8042PRT, "KeyboardInterrupt.Dirql %lu\n", PortDeviceExtension->KeyboardInterrupt.Dirql); INFO_(I8042PRT, "KeyboardInterrupt.DirqlMax %lu\n", DirqlMax); INFO_(I8042PRT, "KeyboardInterrupt.InterruptMode %s\n", PortDeviceExtension->KeyboardInterrupt.InterruptMode == LevelSensitive ? "LevelSensitive" : "Latched"); INFO_(I8042PRT, "KeyboardInterrupt.ShareInterrupt %s\n", PortDeviceExtension->KeyboardInterrupt.ShareInterrupt ? "yes" : "no"); INFO_(I8042PRT, "KeyboardInterrupt.Affinity 0x%lx\n", PortDeviceExtension->KeyboardInterrupt.Affinity); Status = IoConnectInterrupt( &PortDeviceExtension->KeyboardInterrupt.Object, <API key>, DeviceExtension, &PortDeviceExtension->SpinLock, PortDeviceExtension->KeyboardInterrupt.Vector, PortDeviceExtension->KeyboardInterrupt.Dirql, DirqlMax, PortDeviceExtension->KeyboardInterrupt.InterruptMode, PortDeviceExtension->KeyboardInterrupt.ShareInterrupt, PortDeviceExtension->KeyboardInterrupt.Affinity, FALSE); if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "IoConnectInterrupt() failed with status 0x%08x\n", Status); return Status; } if (DirqlMax == PortDeviceExtension->KeyboardInterrupt.Dirql) PortDeviceExtension-><API key> = PortDeviceExtension->KeyboardInterrupt.Object; PortDeviceExtension->Flags |= <API key>; return STATUS_SUCCESS; } static NTSTATUS <API key>( IN <API key> DeviceExtension) { <API key> PortDeviceExtension; KIRQL DirqlMax; NTSTATUS Status; TRACE_(I8042PRT, "<API key>()\n"); Status = i8042MouInitialize(DeviceExtension); if (!NT_SUCCESS(Status)) return Status; PortDeviceExtension = DeviceExtension->Common.PortDeviceExtension; DirqlMax = MAX( PortDeviceExtension->KeyboardInterrupt.Dirql, PortDeviceExtension->MouseInterrupt.Dirql); INFO_(I8042PRT, "MouseInterrupt.Vector %lu\n", PortDeviceExtension->MouseInterrupt.Vector); INFO_(I8042PRT, "MouseInterrupt.Dirql %lu\n", PortDeviceExtension->MouseInterrupt.Dirql); INFO_(I8042PRT, "MouseInterrupt.DirqlMax %lu\n", DirqlMax); INFO_(I8042PRT, "MouseInterrupt.InterruptMode %s\n", PortDeviceExtension->MouseInterrupt.InterruptMode == LevelSensitive ? "LevelSensitive" : "Latched"); INFO_(I8042PRT, "MouseInterrupt.ShareInterrupt %s\n", PortDeviceExtension->MouseInterrupt.ShareInterrupt ? "yes" : "no"); INFO_(I8042PRT, "MouseInterrupt.Affinity 0x%lx\n", PortDeviceExtension->MouseInterrupt.Affinity); Status = IoConnectInterrupt( &PortDeviceExtension->MouseInterrupt.Object, <API key>, DeviceExtension, &PortDeviceExtension->SpinLock, PortDeviceExtension->MouseInterrupt.Vector, PortDeviceExtension->MouseInterrupt.Dirql, DirqlMax, PortDeviceExtension->MouseInterrupt.InterruptMode, PortDeviceExtension->MouseInterrupt.ShareInterrupt, PortDeviceExtension->MouseInterrupt.Affinity, FALSE); if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "IoConnectInterrupt() failed with status 0x%08x\n", Status); goto cleanup; } if (DirqlMax == PortDeviceExtension->MouseInterrupt.Dirql) PortDeviceExtension-><API key> = PortDeviceExtension->MouseInterrupt.Object; PortDeviceExtension->Flags |= MOUSE_INITIALIZED; Status = STATUS_SUCCESS; cleanup: if (!NT_SUCCESS(Status)) { PortDeviceExtension->Flags &= ~MOUSE_INITIALIZED; if (PortDeviceExtension->MouseInterrupt.Object) { <API key>(PortDeviceExtension->MouseInterrupt.Object); PortDeviceExtension-><API key> = PortDeviceExtension->KeyboardInterrupt.Object; } } return Status; } static NTSTATUS EnableInterrupts( IN <API key> DeviceExtension, IN UCHAR FlagsToDisable, IN UCHAR FlagsToEnable) { i8042Flush(DeviceExtension); if (!i8042ChangeMode(DeviceExtension, FlagsToDisable, FlagsToEnable)) return STATUS_UNSUCCESSFUL; return STATUS_SUCCESS; } static NTSTATUS StartProcedure( IN <API key> DeviceExtension) { NTSTATUS Status = STATUS_UNSUCCESSFUL; UCHAR FlagsToDisable = 0; UCHAR FlagsToEnable = 0; KIRQL Irql; if (DeviceExtension->DataPort == 0) { /* Unable to do something at the moment */ return STATUS_SUCCESS; } if (!(DeviceExtension->Flags & (KEYBOARD_PRESENT | MOUSE_PRESENT))) { /* Try to detect them */ TRACE_(I8042PRT, "Check if the controller is really a i8042\n"); Status = i8042BasicDetect(DeviceExtension); if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "i8042BasicDetect() failed with status 0x%08lx\n", Status); return STATUS_UNSUCCESSFUL; } /* First detect the mouse and then the keyboard! If we do it the other way round, some systems throw away settings like the keyboard translation, when detecting the mouse. */ TRACE_(I8042PRT, "Detecting mouse\n"); i8042DetectMouse(DeviceExtension); TRACE_(I8042PRT, "Detecting keyboard\n"); i8042DetectKeyboard(DeviceExtension); INFO_(I8042PRT, "Keyboard present: %s\n", DeviceExtension->Flags & KEYBOARD_PRESENT ? "YES" : "NO"); INFO_(I8042PRT, "Mouse present : %s\n", DeviceExtension->Flags & MOUSE_PRESENT ? "YES" : "NO"); TRACE_(I8042PRT, "Enabling i8042 interrupts\n"); if (DeviceExtension->Flags & KEYBOARD_PRESENT) { FlagsToDisable |= CCB_KBD_DISAB; FlagsToEnable |= CCB_KBD_INT_ENAB; } if (DeviceExtension->Flags & MOUSE_PRESENT) { FlagsToDisable |= CCB_MOUSE_DISAB; FlagsToEnable |= CCB_MOUSE_INT_ENAB; } Status = EnableInterrupts(DeviceExtension, FlagsToDisable, FlagsToEnable); if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "EnableInterrupts failed: %lx\n", Status); DeviceExtension->Flags &= ~(KEYBOARD_PRESENT | MOUSE_PRESENT); return Status; } } /* Connect interrupts */ if (DeviceExtension->Flags & KEYBOARD_PRESENT && DeviceExtension->Flags & KEYBOARD_CONNECTED && DeviceExtension->Flags & KEYBOARD_STARTED && !(DeviceExtension->Flags & <API key>)) { /* Keyboard is ready to be initialized */ Status = <API key>(DeviceExtension->KeyboardExtension); if (NT_SUCCESS(Status)) { DeviceExtension->Flags |= <API key>; } else { WARN_(I8042PRT, "<API key> failed: %lx\n", Status); } } if (DeviceExtension->Flags & MOUSE_PRESENT && DeviceExtension->Flags & MOUSE_CONNECTED && DeviceExtension->Flags & MOUSE_STARTED && !(DeviceExtension->Flags & MOUSE_INITIALIZED)) { /* Mouse is ready to be initialized */ Status = <API key>(DeviceExtension->MouseExtension); if (NT_SUCCESS(Status)) { DeviceExtension->Flags |= MOUSE_INITIALIZED; } else { WARN_(I8042PRT, "<API key> failed: %lx\n", Status); } /* Start the mouse */ Irql = <API key>(DeviceExtension-><API key>); /* HACK: the mouse has already been reset in i8042DetectMouse. This second reset prevents some touchpads/mice from working (Dell D531, D600). See CORE-6901 */ if (!(i8042HwFlags & FL_INITHACK)) { i8042IsrWritePort(DeviceExtension, MOU_CMD_RESET, CTRL_WRITE_MOUSE); } <API key>(DeviceExtension-><API key>, Irql); } return Status; } static NTSTATUS i8042PnpStartDevice( IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST AllocatedResources, IN PCM_RESOURCE_LIST <API key>) { <API key> DeviceExtension; <API key> PortDeviceExtension; <API key> ResourceDescriptor, <API key>; INTERRUPT_DATA InterruptData = { NULL }; BOOLEAN FoundDataPort = FALSE; BOOLEAN FoundControlPort = FALSE; BOOLEAN FoundIrq = FALSE; ULONG i; NTSTATUS Status; TRACE_(I8042PRT, "i8042PnpStartDevice(%p)\n", DeviceObject); DeviceExtension = (<API key>)DeviceObject->DeviceExtension; PortDeviceExtension = DeviceExtension->PortDeviceExtension; ASSERT(DeviceExtension->PnpState == dsStopped); if (!AllocatedResources) { WARN_(I8042PRT, "No allocated resources sent to driver\n"); return <API key>; } if (AllocatedResources->Count != 1) { WARN_(I8042PRT, "Wrong number of allocated resources sent to driver\n"); return <API key>; } if (AllocatedResources->List[0].PartialResourceList.Version != 1 || AllocatedResources->List[0].PartialResourceList.Revision != 1 || <API key>->List[0].PartialResourceList.Version != 1 || <API key>->List[0].PartialResourceList.Revision != 1) { WARN_(I8042PRT, "Revision mismatch: %u.%u != 1.1 or %u.%u != 1.1\n", AllocatedResources->List[0].PartialResourceList.Version, AllocatedResources->List[0].PartialResourceList.Revision, <API key>->List[0].PartialResourceList.Version, <API key>->List[0].PartialResourceList.Revision); return <API key>; } /* Get Irq and optionally control port and data port */ for (i = 0; i < AllocatedResources->List[0].PartialResourceList.Count; i++) { ResourceDescriptor = &AllocatedResources->List[0].PartialResourceList.PartialDescriptors[i]; <API key> = &<API key>->List[0].PartialResourceList.PartialDescriptors[i]; switch (ResourceDescriptor->Type) { case CmResourceTypePort: { if (ResourceDescriptor->u.Port.Length == 1) { /* We assume that the first resource will * be the control port and the second one * will be the data port... */ if (!FoundDataPort) { PortDeviceExtension->DataPort = ULongToPtr(ResourceDescriptor->u.Port.Start.u.LowPart); INFO_(I8042PRT, "Found data port: %p\n", PortDeviceExtension->DataPort); FoundDataPort = TRUE; } else if (!FoundControlPort) { PortDeviceExtension->ControlPort = ULongToPtr(ResourceDescriptor->u.Port.Start.u.LowPart); INFO_(I8042PRT, "Found control port: %p\n", PortDeviceExtension->ControlPort); FoundControlPort = TRUE; } else { /* FIXME: implement PS/2 Active Multiplexing */ ERR_(I8042PRT, "Unhandled I/O ranges provided: 0x%lx\n", ResourceDescriptor->u.Port.Length); } } else WARN_(I8042PRT, "Invalid I/O range length: 0x%lx\n", ResourceDescriptor->u.Port.Length); break; } case <API key>: { if (FoundIrq) return <API key>; InterruptData.Dirql = (KIRQL)<API key>->u.Interrupt.Level; InterruptData.Vector = <API key>->u.Interrupt.Vector; InterruptData.Affinity = <API key>->u.Interrupt.Affinity; if (<API key>->Flags & <API key>) InterruptData.InterruptMode = Latched; else InterruptData.InterruptMode = LevelSensitive; InterruptData.ShareInterrupt = (<API key>->ShareDisposition == <API key>); INFO_(I8042PRT, "Found irq resource: %lu\n", ResourceDescriptor->u.Interrupt.Level); FoundIrq = TRUE; break; } default: WARN_(I8042PRT, "Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type); } } if (!FoundIrq) { WARN_(I8042PRT, "Interrupt resource was not found in allocated resources list\n"); return <API key>; } else if (DeviceExtension->Type == Keyboard && (!FoundDataPort || !FoundControlPort)) { WARN_(I8042PRT, "Some required resources were not found in allocated resources list\n"); return <API key>; } else if (DeviceExtension->Type == Mouse && (FoundDataPort || FoundControlPort)) { WARN_(I8042PRT, "Too much resources were provided in allocated resources list\n"); return <API key>; } switch (DeviceExtension->Type) { case Keyboard: { RtlCopyMemory( &PortDeviceExtension->KeyboardInterrupt, &InterruptData, sizeof(INTERRUPT_DATA)); PortDeviceExtension->Flags |= KEYBOARD_STARTED; Status = StartProcedure(PortDeviceExtension); break; } case Mouse: { RtlCopyMemory( &PortDeviceExtension->MouseInterrupt, &InterruptData, sizeof(INTERRUPT_DATA)); PortDeviceExtension->Flags |= MOUSE_STARTED; Status = StartProcedure(PortDeviceExtension); break; } default: { WARN_(I8042PRT, "Unknown FDO type %u\n", DeviceExtension->Type); ASSERT(!(PortDeviceExtension->Flags & KEYBOARD_CONNECTED) || !(PortDeviceExtension->Flags & MOUSE_CONNECTED)); Status = <API key>; } } if (NT_SUCCESS(Status)) DeviceExtension->PnpState = dsStarted; return Status; } static VOID i8042RemoveDevice( IN PDEVICE_OBJECT DeviceObject) { <API key> DriverExtension; KIRQL OldIrql; <API key> DeviceExtension; DriverExtension = (<API key>)<API key>(DeviceObject->DriverObject, DeviceObject->DriverObject); DeviceExtension = (<API key>)DeviceObject->DeviceExtension; KeAcquireSpinLock(&DriverExtension->DeviceListLock, &OldIrql); RemoveEntryList(&DeviceExtension->ListEntry); KeReleaseSpinLock(&DriverExtension->DeviceListLock, OldIrql); IoDetachDevice(DeviceExtension->LowerDevice); IoDeleteDevice(DeviceObject); } NTSTATUS NTAPI i8042Pnp( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { PIO_STACK_LOCATION Stack; ULONG MinorFunction; I8042_DEVICE_TYPE DeviceType; ULONG_PTR Information = 0; NTSTATUS Status; Stack = <API key>(Irp); MinorFunction = Stack->MinorFunction; DeviceType = ((<API key>)DeviceObject->DeviceExtension)->Type; switch (MinorFunction) { case IRP_MN_START_DEVICE: /* 0x00 */ { TRACE_(I8042PRT, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n"); /* Call lower driver (if any) */ if (DeviceType != <API key>) { Status = ForwardIrpAndWait(DeviceObject, Irp); if (NT_SUCCESS(Status)) Status = i8042PnpStartDevice( DeviceObject, Stack->Parameters.StartDevice.AllocatedResources, Stack->Parameters.StartDevice.<API key>); } else Status = STATUS_SUCCESS; break; } case <API key>: /* (optional) 0x07 */ { switch (Stack->Parameters.<API key>.Type) { case BusRelations: { TRACE_(I8042PRT, "IRP_MJ_PNP / <API key> / BusRelations\n"); return ForwardIrpAndForget(DeviceObject, Irp); } case RemovalRelations: { TRACE_(I8042PRT, "IRP_MJ_PNP / <API key> / RemovalRelations\n"); return ForwardIrpAndForget(DeviceObject, Irp); } default: ERR_(I8042PRT, "IRP_MJ_PNP / <API key> / Unknown type 0x%lx\n", Stack->Parameters.<API key>.Type); return ForwardIrpAndForget(DeviceObject, Irp); } break; } case <API key>: /* (optional) 0x0d */ { TRACE_(I8042PRT, "IRP_MJ_PNP / <API key>\n"); return ForwardIrpAndForget(DeviceObject, Irp); } case <API key>: /* 0x14 */ { TRACE_(I8042PRT, "IRP_MJ_PNP / <API key>\n"); return ForwardIrpAndForget(DeviceObject, Irp); } case <API key>: { TRACE_(I8042PRT, "IRP_MJ_PNP / <API key>\n"); return ForwardIrpAndForget(DeviceObject, Irp); } case <API key>: { TRACE_(I8042PRT, "IRP_MJ_PNP / <API key>\n"); return ForwardIrpAndForget(DeviceObject, Irp); } case <API key>: { TRACE_(I8042PRT, "IRP_MJ_PNP / <API key>\n"); Status = ForwardIrpAndForget(DeviceObject, Irp); i8042RemoveDevice(DeviceObject); return Status; } default: { ERR_(I8042PRT, "IRP_MJ_PNP / unknown minor function 0x%x\n", MinorFunction); return ForwardIrpAndForget(DeviceObject, Irp); } } Irp->IoStatus.Information = Information; Irp->IoStatus.Status = Status; IoCompleteRequest(Irp, IO_NO_INCREMENT); return Status; }
<?php class Qlick_S<API key> extends Exception { /** * @var null|Exception */ private $_previous = null; /** * Construct the exception * * @param string $msg * @param int $code * @param Exception $previous * @return void */ public function __construct($msg = '', $code = 0, Exception $previous = null) { if (version_compare(PHP_VERSION, '5.3.0', '<')) { parent::__construct($msg, (int) $code); $this->_previous = $previous; } else { parent::__construct($msg, (int) $code, $previous); } } /** * Overloading * * For PHP < 5.3.0, provides access to the getPrevious() method. * * @param string $method * @param array $args * @return mixed */ public function __call($method, array $args) { if ('getprevious' == strtolower($method)) { return $this->_getPrevious(); } return null; } /** * String representation of the exception * * @return string */ public function __toString() { if (version_compare(PHP_VERSION, '5.3.0', '<')) { if (null !== ($e = $this->getPrevious())) { return $e->__toString() . "\n\nNext " . parent::__toString(); } } return parent::__toString(); } /** * Returns previous Exception * * @return Exception|null */ protected function _getPrevious() { return $this->_previous; } }
#!/usr/bin/perl # Controller - is4web.com.br # 2007 - 2011 package Controller; require 5.008; require Exporter; #use strict; use vars qw(@ISA $VERSION $INSTANCE %SWITCH); #CONTROLLER use Controller::DBConnector; use Controller::SQL; use Controller::LOG; use Controller::Date; use Controller::iUtils; use Controller::Is; use Controller::Mail; #use Controller::Financeiro; use Error; #TODO ver pra q e usar neh use File::Find; use Scalar::Util qw(looks_like_number); #use open ':utf8', ':std'; @ISA = qw( Controller::Date Controller::DBConnector Controller::SQL Controller::LOG Controller::iUtils Controller::Is Controller::Mail Exporter); #@EXPORT = qw(); #@EXPORT_OK = qw(); $VERSION = "2.0"; =pod =item variable - Added =item constant - Added accurancy =item staffGroups - Added staffGroups =item constant - Added constants =cut ##CONSTANTS## use constant { TICKETS_OWNER_USER => 0, TICKETS_OWNER_STAFF => 1, <API key> => 2, <API key> => 3, <API key> => 'ss', TICKETS_METHOD_HD => 'hd', <API key> => 'em', TICKETS_METHOD_CALL => 'cc', VISIBLE => 1, HIDDEN => 0, <API key> => 'B', <API key> => 'P', <API key> => 'C', <API key> => 'F', <API key> => 'T', <API key> => 'E', <API key> => 'A', <API key> => 'S', <API key> => 'C', <API key> => 'M', <API key> => 'B', <API key> => 'P', <API key> => 'R', <API key> => 'A', <API key> => 'A', <API key> => 'N', <API key> => 'T', <API key> => 'E', <API key> => 'P', <API key> => 'Q', <API key> => 'D', <API key> => 'C', TABLE_STAFFS => 'staff', TABLE_USERS => 'users', TABLE_SERVICES => 'servicos', TABLE_INVOICES => 'invoices', #TODO COLOCAR NOME DE TABELAS COM CONSTANTES TABLE_ACCOUNTS => 'cc', TABLE_BALANCES => 'saldos', TABLE_CREDITS => 'creditos', TABLE_CALLS => 'calls', TABLE_NOTES => 'notes', TABLE_CREDITCARDS => 'cc_info', TABLE_PLANS => 'planos', TABLE_PAYMENTS => 'pagamento', TABLE_FORMS => 'formularios', TABLE_STATS => 'stats', TABLE_PERMS => 'security', TABLE_PERMSGROUP => 'securitygroups', TABLE_SERVERS => 'servidores', TABLE_SETTINGS => 'settings', TABLE_USERS_CONFIG=> 'users_config', VALOR_M => 30, VALOR_A => 360, VALOR_D => 1, VALOR_U => -1, accuracy => '%.5f', }; sub new { my $proto = shift; my $class = ref($proto) || $proto; #Provide a unique instance $INSTANCE and return($INSTANCE); my $self = { @_ }; %{ $self->{configs} } = @_; my $log = Controller::LOG->new(@_); %$self = ( %$self, %$log, ); bless($self, $class); $INSTANCE = $self; #cache instance $SIG{'__DIE__'} = sub { $self->traceback($_[0]); }; $self->connect() || return $self; $self->_setswitchs; $self->_settings;#Init settings $self->_setlang($self->setting('language')); #set default language; $self->_setskin($self->setting('skin'));#Init default interface settings $self->_setCGI; $self->_setqueries; $self->_country_codes; $self->_feriados; $self->_templates; $self->get_time;#Init time return $self; } sub reDie { my $self = shift; $SIG{'__DIE__'} = sub { $self->traceback($_[0]); }; } sub configs { my $self = shift; return %{ $self->{configs} }; } # Abolir esse uso #sub _username { # my ($self) = shift; # $self->{'username'} = shift; # return 1; sub error_code { my $self = shift; return $self->{'errorCode'}=undef unless $self->error; $self->{'errorCode'} = $_[0] if $_[0] >= 0 && !$self->{'errorCode'} && $self->error && $Controller::SWITCH{skip_error} != 1; return $self->{'errorCode'}; } sub set_error { my $self = shift; $self->{ERR} = "@_" if "@_" ne "" && !$self->error && $Controller::SWITCH{skip_error} != 1; return 0; } #TODO fazer todo {ERR} virar error e {ERR} = virar set_error sub error { #TODO modificar o erro pra ser o cara q so mostra o erro e nao apaga my $self = shift; return $self->{ERR}; } sub clear_error { my $self = shift; my $handle = $self->{ERR}; $self->{ERR} = undef; #Error Acknowledge return $handle; } sub nice_error { my $self = shift; return undef unless $self->error; local $Controller::SWITCH{skip_error} = 1; # Skip the first frame [0], because it's the call to dotb. # Skip the second frame [1], because it's the call to die, with redirection my $frame = 0; my $tab = 1; while (my ($package, $filename, $line, $sub) = caller($frame++)) { if ($package eq 'main') { $sub =~ s/main:: push(@trace, trim("$sub() called from $filename on line $line")); } else { return undef if $sub eq '(eval)'; push(@trace, trim("$package::$sub() called from $filename on line $line\n")); } } my $mess = "Traceback (most recent call last):\n"; $mess .= join("\n", map { " "x$tab++ . $_ } reverse(@trace) )."\n"; $mess .= "Package error: ".$self->clear_error."\n"; $self->logevent($mess); $self->email (To => $self->setting('controller_mail'), From => $self->setting('adminemail'), Subject => $self->lang('sbj_nice_error'), Body => "Error: $mess" ); return $self->lang(1); } sub soft_reset { my $self = shift; foreach (keys %$self) { delete $self->{$_} if $_ =~ m/^_current/; } } sub hard_reset { my $self = shift; my $class = ref($self); my %configs = $self->configs; $INSTANCE = undef; $self = undef; $self = new Controller ( %configs ); # bless($self, $class); return $self; } #save itens info sub save { @_ = @_; my $self = shift; return if $self->error; return unless @{$_[2]}; do { $self->set_error($self->lang(51,'save')); return undef; } unless @{$_[1]} == @{$_[2]} && @{$_[3]} == @{$_[4]}; $self->execute_sql(qq|UPDATE `$_[0]` SET |.Controller::iSQLjoin($_[1],1,",") .qq| WHERE |.Controller::iSQLjoin($_[3],1,","), @{$_[2]}, @{$_[4]}); return $self->error ? 0 : 1; } #Itens info sub sid { #independente my $self = shift; $self->{_currentsid} = $self->num($_[0]) if exists $_[0]; #nao tem logica verificar isso $self->set_error($self->lang(3,'sid')) if exists $_[0] && $_[0] ne $self->service('id'); return $self->{_currentsid}; } sub pid {#pode depender my $self = shift; if (exists $_[0]) { $self->{_currentpid} = $self->num($_[0]) ; $self->sid(0);#Liberando dependencia } else { #return $self->{_currentpid} = $self->service('servicos') if !$self->{_currentpid} && $self->sid; $self->{_currentpid} = $self->service('servicos') if $self->sid > 0; $self->set_error($self->lang(3,'pid')) if $self->{_currentpid} <= 0 && ($self->sid > 0); } return $self->{_currentpid}; } sub uid { my $self = shift; if (exists $_[0]) { $self->{_currentuid} = $self->num($_[0]); $self->sid(0);#Liberando dependencia $self->balanceid(0); $self->invid(0); $self->callid(0); } else { $self->{_currentuid} = $self->service('username') if $self->sid > 0; $self->{_currentuid} = $self->balance('username') if $self->balanceid > 0; $self->{_currentuid} = $self->invoice('username') if $self->invid > 0; $self->{_currentuid} = $self->call('username') if $self->callid > 0 && $self->call('username') > 0; $self->set_error($self->lang(3,'uid')) if $self->{_currentuid} <= 0 && ($self->sid > 0 || $self->balanceid > 0 || $self->invid > 0 || ($self->callid > 0 && $self->call('username') > 0) ); } return $self->{_currentuid}; } sub srvid {#pode depender @_=@_; my $self = shift; if (exists $_[0]) { $self->{_currentsrvid} = $self->num($_[0]) ; $self->sid(0);#Liberando dependencia } else { $self->{_currentsrvid} = $self->service('servidor') if $self->sid > 0; $self->set_error($self->lang(3,'srvid')) if $self->{_currentsrvid} <= 0 && ($self->sid > 0); } return $self->{_currentsrvid}; } sub payid {#pode depender my $self = shift; if (exists $_[0]) { $self->{_currentpayid} = $self->num($_[0]) ; $self->sid(0);#Liberando dependencia } else { $self->{_currentpayid} = $self->service('pg') if $self->sid > 0; $self->set_error($self->lang(3,'payid')) if $self->{_currentpayid} <= 0 && ($self->sid > 0); } return $self->{_currentpayid}; } sub callid { my $self = shift; $self->{_currentcallid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentcallid}; } sub creditid { my $self = shift; $self->{_currentcreditid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentcreditid}; } sub balanceid { my $self = shift; $self->{_currentbalanceid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentbalanceid}; } sub actid { my $self = shift; $self->{_currentaccountid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentaccountid}; } sub invid { my $self = shift; $self->{_currentinvoiceid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentinvoiceid}; } sub ccid { my $self = shift; $self->{_currentccid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentccid}; } sub tid { my $self = shift; $self->{_currenttid} = $self->num($_[0]) if exists $_[0]; return $self->{_currenttid}; } sub staffid { my $self = shift; $self->{_currentstaffid} = $_[0] if exists $_[0]; return $self->{_currentstaffid}; } sub entid { my $self = shift; $self->{_currententid} = $self->num($_[0]) if exists $_[0]; return $self->{_currententid}; } sub deptid { my $self = shift; $self->{_currentdeptid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentdeptid}; } sub did { my $self = shift; $self->{_currentdid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentdid}; } sub logmailid { my $self = shift; $self->{_currentlogmailid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentlogmailid}; } sub bankid { my $self = shift; $self->{_currentbankid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentbankid}; } sub formtypeid { my $self = shift; $self->{_currentformtypeid} = $self->num($_[0]) if exists $_[0]; return $self->{_currentformtypeid}; } sub payment { my $self = shift; $self->get_payment unless exists $self->{payments}{$self->payid}{$_[0]} || exists $_[1]; $self->{payments}{$self->payid}{$_[0]} = $_[1] if exists $_[1]; return $self->{payments}{$self->payid}{$_[0]}; } sub payments { my ($self) = shift; return $self->get_payments(1034); } sub service { @_ = @_; my $self = shift; return \%{$self->{services}{$self->sid}} unless exists $_[0]; #copy %{ $self->{services}{$self->sid}{changed} } = %{ $_[1] } if $_[0] eq 'changed' && exists $_[1]; return keys %{ $self->{services}{$self->sid}{changed} } if $_[0] eq 'changed'; $self->get_service unless exists $self->{services}{$self->sid}{$_[0]} || $_[0] =~ m/^_/; #Create data hash if not exist my $atual = $_[0] eq 'dados' ? $self->{services}{$self->sid}{$_[0]}{$_[1]} : $self->{services}{$self->sid}{$_[0]}; $self->{services}{$self->sid}{$_[0]}{$_[1]} = $_[2] if $_[0] eq 'dados' && exists $_[1] && exists $_[2];#special field $self->{services}{$self->sid}{$_[0]} = $_[1] if exists $_[1] && $_[0] ne 'dados'; if (looks_like_number($atual)) { $self->{services}{$self->sid}{changed}{ $_[0] } = 1 if (exists $_[1] && $_[0] ne 'dados' && $atual != $_[1]) || (exists $_[2] && $_[0] eq 'dados' && $atual != $_[2]); } else { $self->{services}{$self->sid}{changed}{ $_[0] } = 1 if (exists $_[1] && $_[0] ne 'dados' && $atual ne $_[1]) || (exists $_[2] && $_[0] eq 'dados' && $atual ne $_[2]); } #$self->logevent("\nDados: ".join ',', keys %{ $self->{services}{$self->sid}{'dados'} }); #puta faz isso depois nao aki, return $self->action($self->{services}{$self->sid}{$_[0]}) if $_[0] eq 'action'; #special field return $self->{services}{$self->sid}{$_[0]}{$_[1]} if $_[0] eq 'dados' && exists $_[1]; # "$_[1]" BUG de charset no campo de dados return $self->{services}{$self->sid}{$_[0]}; } sub services { my ($self) = shift; $self->set_error($self->lang(3,'services')) and return unless $self->uid; return $self->get_services(781,$self->uid); #select * sobrescrevia alteracoes de runtime, se definisse um proximo, ele lia denovo e sobrescrevia pelo antigo #return grep {$self->{services}{$_}{'username'} == $self->uid} keys %{ $self->{services} }; } sub serviceprop { my ($self) = shift; $self->get_serviceprop unless exists $self->{services}{$self->sid}{'properties'}{$_[0]} || exists $_[1]; #Create data hash if not exist $self->{services}{$self->sid}{'properties'}{$_[0]}{$_[1]}{$_[2]} = $_[3] if $_[0] == 3 && exists $_[1] && exists $_[2] && exists $_[3];#special field $self->{services}{$self->sid}{'properties'}{$_[0]} = $_[1] if exists $_[1] && $_[0] != 3; return $self->{services}{$self->sid}{'properties'}{$_[0]}{$_[1]} if $_[0] == 3 && exists $_[1]; return $self->{services}{$self->sid}{'properties'}{$_[0]}; } sub servicesprop { my ($self,@sids) = @_; $self->set_error($self->lang(3,'servicesprop')) and return unless @sids; $self->get_servicesprop(824,join ',',@sids); } sub plan { my $self = shift; $self->get_plan unless exists $self->{plans}{$self->pid}{$_[0]} || exists $_[1]; $self->{plans}{$self->pid}{$_[0]}{$_[1]} = $_[2] if $_[0] eq 'descontos' && exists $_[1]; $self->{plans}{$self->pid}{$_[0]} = $_[1] if $_[0] ne 'descontos' && exists $_[1]; return $self->{plans}{$self->pid}{$_[0]}{$self->service('pg')} if $_[0] eq 'descontos' && exists $_[1]; return $self->{plans}{$self->pid}{$_[0]}; } sub plans { my ($self) = @_; $self->set_error($self->lang(3,'plans')) and return unless $self->uid; return $self->get_plans(608,'%',$self->uid); } sub server { my $self = shift; $self->get_server unless exists $self->{servers}{$self->srvid}{$_[0]} || exists $_[1]; $self->{servers}{$self->srvid}{$_[0]} = $_[1] if exists $_[1]; return $self->{servers}{$self->srvid}{$_[0]}; } sub servers { #TODO REDO my ($self,@srvids) = @_; $self->set_error($self->lang(3,'servers')) and return unless @srvids; return $self->get_servers(45,join ',', map { $self->{servers}{$_}{'id'} } @srvids); } sub user { my $self = shift; my @__ = @_; #Protect from split and grep return \%{$self->{users}{$self->uid}} unless exists $__[0]; #copy %{ $self->{users}{$self->uid}{changed} } = %{ $__[1] } if $__[0] eq 'changed' && exists $__[1]; return keys %{ $self->{users}{$self->uid}{changed} } if $__[0] eq 'changed'; $self->get_user unless exists $self->{users}{$self->uid}{$__[0]} || $__[0] eq 'emails' || $__[0] =~ m/^_/; my $getter = $__[0] eq 'email' ? join(',', @{ $self->{users}{$self->uid}{$__[0]} }) : $self->{users}{$self->uid}{$__[0]}; if (exists $__[1]) { #Setter my $setter = $__[0] eq 'email' ? join(',', grep { $self->is_valid_email($_) } split(/\s*?[,;]\s*?/,trim($__[1])) ) : $__[1]; if (looks_like_number($getter)) { $self->{users}{$self->uid}{changed}{ $__[0] } = 1 if $self->num($getter) != $self->num($setter); } else { $self->{users}{$self->uid}{changed}{ $__[0] } = 1 if $getter ne $setter; } $self->{users}{$self->uid}{$__[0]} = $__[0] eq 'email' ? [ split(',',trim($setter)) ] : $setter; } return join ',', @{ $self->user('email') } if $__[0] eq 'emails'; #use Data::Dumper; #die Dumper \%{$self->{users}{$self->uid}} unless exists $__[1]; return $self->{users}{$self->uid}{$__[0]}; } sub user_config { my $self = shift; my @__ = @_; #Protect from split and grep return \%{$self->{users_config}{$self->uid}} unless exists $__[0]; #copy return keys %{ $self->{users_config}{$self->uid}{changed} } if $__[0] eq 'changed'; $self->get_user_config unless exists $self->{users_config}{$self->uid}{$__[0]} || $__[0] =~ m/^_/; my $getter = $self->{users_config}{$self->uid}{$__[0]}; if (exists $__[1]) { #Setter my $setter = $__[1]; $self->{users_config}{$self->uid}{changed}{ $__[0] } = 1 if $getter ne $setter && $getter != $setter; $self->{users_config}{$self->uid}{$__[0]} = $__[1]; } return $self->{users_config}{$self->uid}{$__[0]}; } sub invoice { @_=@_; my $self = shift; return \%{$self->{invoices}{$self->invid}} unless exists $_[0]; #copy $self->get_invoice unless exists $self->{invoices}{$self->invid}{$_[0]} || exists $_[1]; $self->{invoices}{$self->invid}{$_[0]}{$_[1]} = $_[2] if $_[0] eq 'services' && exists $_[1] && exists $_[2];#special field $self->{invoices}{$self->invid}{$_[0]} = $_[1] if exists $_[1] && $_[0] ne 'services'; return $self->{invoices}{$self->invid}{$_[0]}{$_[1]} if $_[0] eq 'services' && exists $_[1]; return $self->{invoices}{$self->invid}{$_[0]}; } sub invoices { my ($self) = shift; $self->set_error($self->lang(3,'invoices')) and return unless $self->uid; return $self->get_invoices(439,'%',$self->uid); #return grep {$self->{balances}{$_}{'username'} == $self->uid} keys %{ $self->{balances} }; } sub account { my $self = shift; $self->get_account unless exists $self->{accounts}{$self->actid}{$_[0]} || exists $_[1]; $self->{accounts}{$self->actid}{$_[0]} = $_[1] if exists $_[1]; return $self->{accounts}{$self->actid}{$_[0]}; } sub accounts { my $self = shift; # $self->set_error($self->lang(3,'accounts')) and return unless $self->uid; $self->get_accounts(424); return keys %{ $self->{accounts} }; } sub credit { my $self = shift; $self->get_credit unless exists $self->{credits}{$self->creditid}{$_[0]} || exists $_[1]; $self->{credits}{$self->creditid}{$_[0]} = $_[1] if exists $_[1]; return $self->{credits}{$self->creditid}{$_[0]}; } sub credits { my ($self) = shift; $self->set_error($self->lang(3,'credits')) and return unless $self->uid; return $self->get_credits(482,$self->uid); } sub balance { my $self = shift; $self->get_balance unless exists $self->{balances}{$self->balanceid}{$_[0]} || exists $_[1]; $self->{balances}{$self->balanceid}{$_[0]} = $_[1] if exists $_[1]; return $self->{balances}{$self->balanceid}{$_[0]}; } sub balances { my ($self) = shift; $self->set_error($self->lang(3,'balances')) and return unless $self->uid; return $self->get_balances(450,'O',$self->uid); #return grep {$self->{balances}{$_}{'username'} == $self->uid} keys %{ $self->{balances} }; } sub servicebalances { my ($self) = shift; $self->set_error($self->lang(3,'servicebalances')) and return unless $self->sid; return $self->get_balances(454,'O',$self->sid); } sub call { my $self = shift; $self->get_call unless exists $self->{calls}{$self->callid}{$_[0]} || exists $_[1]; $self->{calls}{$self->callid}{$_[0]} = $_[1] if exists $_[1]; return $self->{calls}{$self->callid}{$_[0]}; } sub calls { my ($self) = shift; $self->set_error($self->lang(3,'calls')) and return unless $self->uid; #se tem sid vai ter uid return $self->get_calls(367,$self->sid) if $self->sid; return $self->get_calls(366,$self->uid) if $self->uid; return (); } sub followers { my $self = shift; $self->set_error($self->lang(3,'followers')) and return unless $self->callid; my $sth = $self->select_sql(380,$self->callid); my @followers = map {@{$_}} @{ $sth->fetchall_arrayref() }; $self->finish; return @followers; } sub following { my $self = shift; $self->set_error($self->lang(3,'following')) and return unless $self->staffid; my $sth = $self->select_sql(379,$self->staffid); my @following = map {@{$_}} @{ $sth->fetchall_arrayref() }; $self->finish; return @following; } sub creditcard { my $self = shift; $self->get_creditcard unless exists $self->{creditcards}{$self->ccid}{$_[0]} || exists $_[1]; $self->{creditcards}{$self->ccid}{$_[0]} = $_[1] if exists $_[1]; return $self->{creditcards}{$self->ccid}{$_[0]}; } sub creditcards { my $self = shift; $self->set_error($self->lang(3,'creditcards')) and return unless $self->uid; return $self->get_creditcards(855,$self->uid); #return keys %{ $self->{creditcards} }; } sub creditcard_active { my $self = shift; $self->set_error($self->lang(3,'creditcard_active')) and return unless $self->uid; $self->get_creditcards(852,$self->tid,1,$self->uid); my ($ccid) = grep { $self->{creditcards}{$_}{'active'} == 1 && $self->{creditcards}{$_}{'tarifa'} == $self->tid && $self->{creditcards}{$_}{'username'} == $self->uid} keys %{ $self->{creditcards} }; return $ccid; } sub tax { my $self = shift; $self->get_tax unless exists $self->{taxs}{$self->tid}{$_[0]} || exists $_[1]; $self->{taxs}{$self->tid}{$_[0]} = $_[1] if exists $_[1]; return $self->{taxs}{$self->tid}{$_[0]}; } sub taxs { my $self = shift; # $self->set_error($self->lang(3,'taxs')) and return unless $self->uid; return $self->get_taxs(872); #return keys %{ $self->{taxs} }; } sub enterprise { my $self = shift; $self->get_enterprise unless exists $self->{enterprises}{$self->entid}{$_[0]} || exists $_[1]; $self->{enterprises}{$self->entid}{$_[0]} = $_[1] if exists $_[1]; return $self->{enterprises}{$self->entid}{$_[0]}; } sub enterprises { my $self = shift; return $self->get_enterprises(303); #return keys %{ $self->{enterprises} }; } sub department { my $self = shift; $self->get_department unless exists $self->{departments}{$self->deptid}{$_[0]} || exists $_[1]; $self->{departments}{$self->deptid}{$_[0]} = $_[1] if exists $_[1]; return $self->{departments}{$self->deptid}{$_[0]}; } sub departments { my $self = shift; return $self->get_departments(266); #return keys %{ $self->{departments} }; } sub formtype { my $self = shift; $self->get_formtype unless exists $self->{formtypes}{$self->formtypeid}{$_[0]} || exists $_[1]; $self->{formtypes}{$self->formtypeid}{$_[0]} = $_[1] if exists $_[1]; return $self->{formtypes}{$self->formtypeid}{$_[0]}; } sub staff { my $self = shift; $self->get_staff unless exists $self->{staffs}{$self->staffid}{$_[0]} || exists $_[1]; $self->{staffs}{$self->staffid}{$_[0]} = $_[1] if exists $_[1]; return join ',', @{ $self->{staffs}{$self->staffid}{'email'} } if $_[0] eq 'emails'; return $self->{staffs}{$self->staffid}{$_[0]}; } sub staffGroups { my $self = shift; return undef if $self->error; $self->set_error($self->lang(3,'get_staffGroups')) and return unless $self->staffid; my $sth = $self->select_sql(1083, $self->staffid); my @gids = map {@{$_}} @{ $sth->fetchall_arrayref() }; $self->finish; return @gids; } sub groups { my $self = shift; return undef if $self->error; my $sth = $self->select_sql(1084); my @gids = map {@{$_}} @{ $sth->fetchall_arrayref() }; $self->finish; return @gids; } sub logmail { my $self = shift; $self->get_logmail unless exists $self->{logmails}{$self->logmailid}{$_[0]} || exists $_[1]; $self->{logmails}{$self->logmailid}{$_[0]} = $_[1] if exists $_[1]; return $self->{logmails}{$self->logmailid}{$_[0]}; } sub logmails { my $self = shift; return $self->get_logmails(163); } sub bank { my $self = shift; $self->get_bank unless exists $self->{banks}{$self->bankid}{$_[0]} || exists $_[1]; $self->{banks}{$self->bankid}{$_[0]} = $_[1] if exists $_[1]; return $self->{banks}{$self->bankid}{$_[0]}; } sub banks { my $self = shift; return $self->get_banks(427); } sub perm { my $self = shift; my $id = $self->uid || $self->staffid; $self->set_error($self->lang(3,'perm')) and return unless $id; $self->get_perm unless exists $self->{perms}{$id}; return $self->{perms}{$id}{$_[0]}{$_[1]}{$_[2]} || $self->{perms}{$id}{$_[0]}{'all'}{$_[2]} if exists $_[2]; return \%{ $self->{perms}{$id}{$_[0]}{$_[1]} } if exists $_[1]; #copy return \%{ $self->{perms}{$id}{$_[0]} } if exists $_[0]; #copy return \%{ $self->{perms}{$id} }; #copy } sub perms { #my $self = shift; #my $id = $self->uid || $self->staffid; #$self->set_error($self->lang(3,'perms')) and return unless $id; #return keys %{$self->perm}; } #Copy data sub copy_service { my ($self,$source,$target) = @_; $self->sid($source); my $ref = $self->service; $self->sid($target); my $ref2 = $self->service; %$ref2 = %$ref; return $self->sid($source); } sub shadow_copy { my $self = shift; if ($_[0] eq 'services') { my $ref = $self->service; %{ $self->{'shadow'}{$_[0]}{$self->sid} } = %$ref; } return 1; } sub AUTOLOAD { #Holds all undef methods my $self = $_[0]; my $type = ref($self) or die "$AUTOLOAD is not an object"; my $name = $AUTOLOAD; $name =~ s/.*://; # strip fully-qualified portion #Determinar qual modulo usar e importar #nao tenha buscar os padroes if ($name =~ s/_shadow$ use B::RecDeparse; my $deparse = B::RecDeparse->new; my $newsub = $deparse->coderef2text( eval "\\&Controller::$name" ); $newsub =~ s/\$\$self{(.+?)}/\$self->{'shadow'}{$1}/g; #$newsub =~ s/\$\$self{(.+?)}/\$\$self{'shadow'}{$1}/g; $newsub =~ s/package.* eval "sub func $newsub"; # the inverse operation return func(@_); } if ($name =~ /registrar|renew|expire/i) { $self->manual_action; return $self->error ? 0 : 1; } if ($name =~ /availdomain/i) { return 1; } $self->set_error("$name not implemented"); return undef;#Simular erro } sub lock_billing { my ($self) = shift; local $Controller::SWITCH{skip_log} = 1; my $date = exists $_[1] ? $_[1] : $self->today(); my $time = exists $_[2] ? $_[2] : undef; $self->execute_sql(21,$self->uid,$date,$time) if $self->uid; return 1; } sub unlock_billing { my ($self) = shift; local $Controller::SWITCH{skip_log} = 1; $self->execute_sql(22,$self->uid) if $self->uid; return 1; } sub action { my $self = shift; my %act = ( 'C' => $self->lang("CREATE"), 'M' => $self->lang("MODIFY"), 'B' => $self->lang("SUSPEND"), 'P' => $self->lang("SUSPENDRES"), 'R' => $self->lang("REMOVE"), 'A' => $self->lang("ACTIVATE"), 'N' => $self->lang("NOTHINGTODO") ); return $act{uc shift}; } sub valor { my ($self,$opt) = @_; if ($opt == 1) { return $self->VALOR_M if $self->plan('valor_tipo') eq 'M'; return $self->VALOR_A if $self->plan('valor_tipo') eq 'A'; return $self->VALOR_D if $self->plan('valor_tipo') eq 'D'; return $self->VALOR_U if $self->plan('valor_tipo') eq 'U'; } else { return $self->lang('Month') if $self->plan('valor_tipo') eq 'M'; return $self->lang('Year') if $self->plan('valor_tipo') eq 'A'; return $self->lang('Day') if $self->plan('valor_tipo') eq 'D'; return $self->lang('Unique') if $self->plan('valor_tipo') eq 'U'; } $self->set_error($self->lang(1003)); die $self->lang(1003); } sub installment { my $self = shift; my %inst = ( 'S' => $self->lang("INSTALLMENT_S"), 'O' => $self->lang("INSTALLMENT_O"), 'L' => $self->lang("INSTALLMENT_L"), 'D' => $self->lang("INSTALLMENT_D") ); return $inst{uc shift}; } #data mount sub mount_service { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $sid = $ref->{'id'}; push @ids_matched, $sid; foreach my $q (keys %{$sth->{NAME_hash}}) { #next if $q eq 'id'; TODO deixar o id pra verificar consistencia, ver sub sid() if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { $self->{'services'}{$sid}{lc $q} = $self->date($ref->{$q}); } elsif ($q eq 'dados') { $self->{'services'}{$sid}{lc $q} = undef; foreach (split("::",$ref->{$q})) { my ($col,$val) = split(" : ",$_); $self->{'services'}{$sid}{lc $q}{trim($col)} = trim($val); } } else { $self->{'services'}{$sid}{lc $q} = $ref->{$q}; } } } return @ids_matched; } sub get_service { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_service')) and return unless $self->sid; $self->select_sql(780,$self->sid); $self->mount_service; $self->finish; #$self->logevent("Get DB: ".join ',', keys %{ $self->{services}{$self->sid}{'dados'} }); return $self->error ? 0 : 1; } sub get_services { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_services')) and return unless $sql; $self->select_sql($sql,@params); my @services = $self->mount_service; $self->finish; return $self->error ? undef : @services; } sub mount_serviceprop { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $sid = $ref->{'servico'}; push @ids_matched, $sid; if ($ref->{'type'} == 3) { #4.90::3,4,5,6::2008|6.65::1,8::2009 foreach ( split('\|',$ref->{'value'}) ) { my($val,$months,$year) = split('::',$_,3); #Adicionado tipo 7 $self->{services}{$sid}{'properties'}{$ref->{'type'}}{$year} = { 'value' => $val, 'months' => [split ',', $months], } } } elsif ($ref->{'type'} == 7) { #{} hash dump $self->{services}{$sid}{'properties'}{$ref->{'type'}} = eval $ref->{'value'}; } else { my $value = $self->num($ref->{'value'}) < 0 ? 0 : $self->num($ref->{'value'}); $self->{services}{$sid}{'properties'}{$ref->{'type'}} = $value; } } return @ids_matched; } sub get_serviceprop { my ($self) = shift; return 0 if $self->error; #types 1 - dias gratis 2 - Sem taxa de setup 3 - Descontos em meses #4 - Nao se orientar pelo vc do usuario 5 - dias para finalizar 6 - fatura exclusiva #7 - Valores +- por mes/ano % ou $ $self->set_error($self->lang(3,'get_serviceprop')) and return unless $self->sid; $self->select_sql(824,$self->sid); $self->mount_serviceprop; $self->finish; return $self->error ? 0 : 1; } sub get_servicesprop { my ($self,$sql,@params) = @_; return 0 if $self->error; $self->set_error($self->lang(3,'get_serviceprop')) and return unless $sql; $self->select_sql($sql,@params); my @props = $self->mount_serviceprop; $self->finish; return $self->error ? undef : @props; } sub mount_plan { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $pid = $ref->{'servicos'}; push @ids_matched, $pid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq 'servicos'; $self->{'plans'}{$pid}{lc $q} = $ref->{$q}; } #isso nao existe, nao tem como acontecer $self->{'plans'}{$pid}{'descontos'}{$ref->{'pg'}} = $ref->{'desconto'}; } return @ids_matched; } sub get_plan { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_plan')) and return unless $self->pid; $self->select_sql(604,$self->pid); $self->mount_plan; $self->finish; return $self->error ? 0 : 1; } sub get_plans { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_plans')) and return unless $sql; $self->select_sql($sql,@params); my @plans = $self->mount_plan; $self->finish; return $self->error ? 0 : @plans; } sub mount_tax { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $tid = $ref->{'id'}; push @ids_matched, $tid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq 'id'; $self->{'taxs'}{$tid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_tax { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_tax')) and return unless $self->tid; $self->select_sql(871,$self->tid); $self->mount_tax; $self->finish; return $self->error ? 0 : 1; } sub get_taxs { my ($self,$sql,@params) = @_; return 0 if $self->error; $self->set_error($self->lang(3,'get_taxs')) and return unless $sql; $self->select_sql($sql,@params); my @taxs = $self->mount_tax; $self->finish; return $self->error ? 0 : @taxs; } sub mount_server { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $srvid = $ref->{'id'}; push @ids_matched, $srvid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; $self->{'servers'}{$srvid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_server { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_server')) and return unless $self->srvid; $self->select_sql(45,$self->srvid); $self->mount_server; $self->finish; return $self->error ? 0 : 1; } sub get_servers { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_servers')) and return unless $sql; $self->select_sql($sql,@params); my @servers = $self->mount_server; $self->finish; return $self->error ? 0 : @servers; } sub mount_payment { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $payid = $ref->{'id'}; push @ids_matched, $payid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; $self->{'payments'}{$payid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_payment { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_payment')) and return unless $self->payid; $self->select_sql(1030,$self->payid); my @payments = $self->mount_payment; $self->finish; return $self->error ? 0 : @payments; } sub get_payments { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_payments')) and return unless $sql; $self->select_sql($sql,@params); my @payments = $self->mount_payment; $self->finish; return $self->error ? undef : @payments; } sub mount_user { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $uid = $ref->{'username'}; push @ids_matched, $uid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "username"; if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { $self->{'users'}{$uid}{lc $q} = $self->date($ref->{$q}); } elsif ($q eq 'email') { $self->{'users'}{$uid}{lc $q} = [ grep { $self->is_valid_email($_) } split(/\s*?[,;]\s*?/,trim($ref->{$q})) ]; } else { $self->{'users'}{$uid}{lc $q} = $ref->{$q}; } } } return @ids_matched; } sub mount_user_config { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while($sth and (my $ref = $sth->fetchrow_hashref())) { my $set = lc $ref->{'setting'}; push @ids_matched, $set; $self->{'users_config'}{$ref->{'username'}}{$set} = $ref->{'value'}; } return @ids_matched; } sub get_user { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_user')) and return unless $self->uid; $self->select_sql(680,$self->uid); my @users = $self->mount_user; $self->finish; return $self->error ? 0 : @users; } sub get_user_config { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_user_config')) and return unless $self->uid; $self->select_sql(681,$self->uid); my @configs = $self->mount_user_config; $self->finish; return $self->error ? 0 : @configs; } sub get_users { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_users')) and return unless $sql; $self->select_sql($sql,@params); my @users = $self->mount_user; $self->finish; return $self->error ? undef : @users; } sub mount_invoice { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $invid = $ref->{'id'}; push @ids_matched, $invid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { $self->{'invoices'}{$invid}{lc $q} = $self->date($ref->{$q}); } elsif ($q eq 'services') { $self->{'invoices'}{$invid}{lc $q} = {}; #Inicializando $self->{'invoices'}{$invid}{lc $q}{$2} = $1 while $ref->{$q} =~ m/(\d+?)x(\d+?) -\s?/g; } else { $self->{'invoices'}{$invid}{lc $q} = $ref->{$q}; } } } return @ids_matched; } sub get_invoice { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_invoice')) and return unless $self->invid; $self->select_sql(437,$self->invid); $self->mount_invoice; $self->finish; return $self->error ? 0 : 1; } sub get_invoices { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_invoices')) and return unless $sql; $self->select_sql($sql,@params); my @invoices = $self->mount_invoice; $self->finish; return $self->error ? undef : @invoices; } sub mount_account { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $actid = $ref->{'id'}; push @ids_matched, $actid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; if ($q eq 'agencia') { my ($pre,$pos) = split('-',$ref->{$q}); $self->{'accounts'}{$actid}{lc ($q.'dv')} = $pos; $self->{'accounts'}{$actid}{lc $q} = $pre; } elsif ($q eq 'conta') { my ($pre,$pos) = split('-',$ref->{$q}); $self->{'accounts'}{$actid}{lc ($q.'dv')} =$pos; $self->{'accounts'}{$actid}{lc $q} =$pre; } else { $self->{'accounts'}{$actid}{lc $q} = $ref->{$q}; } } } return @ids_matched; } sub get_account { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_acccount')) and return unless $self->actid; my $sth = $self->select_sql(423,$self->actid); $self->mount_account; $self->finish; return $self->error ? 0 : 1; } sub get_accounts { my ($self,$sql,@params) = @_; return 0 if $self->error; $self->set_error($self->lang(3,'get_accounts')) and return unless $sql; $self->select_sql($sql,@params); my @accounts = $self->mount_account; $self->finish; return $self->error ? undef : @accounts; } sub mount_balance { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $bid = $ref->{'id'}; push @ids_matched, $bid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; $self->{'balances'}{$bid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_balance { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_balance')) and return unless $self->balanceid; $self->select_sql(449,$self->balanceid); $self->mount_balance; $self->finish; return $self->error ? 0 : 1; } sub get_balances { my ($self,$sql,@params) = @_; return 0 if $self->error; $self->set_error($self->lang(3,'get_balances')) and return unless $sql; $self->select_sql($sql,@params); my @balances = $self->mount_balance; $self->finish; return $self->error ? undef : @balances; } sub mount_credit { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $creditid = $ref->{'id'}; push @ids_matched, $creditid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; $self->{'credits'}{$creditid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_credit { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_credit')) and return unless $self->creditid; $self->select_sql(481,$self->creditid); $self->mount_credit; $self->finish; return $self->error ? 0 : 1; } sub get_credits { my ($self,$sql,@params) = @_; return 0 if $self->error; $self->set_error($self->lang(3,'get_credits')) and return unless $sql; $self->select_sql($sql,@params); my @credits = $self->mount_credit; $self->finish; return $self->error ? undef : @credits; } sub mount_call { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $callid = $ref->{'id'}; push @ids_matched, $callid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; $self->{'calls'}{$self->callid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_call { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_call')) and return unless $self->callid; $self->select_sql(365,$self->callid); $self->mount_call; $self->finish; return $self->error ? 0 : 1; } sub get_calls { my ($self,$sql,@params) = @_; return 0 if $self->error; $self->set_error($self->lang(3,'get_calls')) and return unless $sql; $self->select_sql($sql,@params); my @calls = $self->mount_call; $self->finish; return $self->error ? undef : @calls; } sub mount_creditcard { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $ccid = $ref->{'id'}; push @ids_matched, $ccid; #preciso listar mesmo que esteja recusado next if $ref->{'active'} == -1; #recusado foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; if ($q =~ m/^(?:ccn|cvv2)$/) { #campos criptografados $self->{'creditcards'}{$ccid}{lc $q} = Controller::decrypt_mm($ref->{$q}); } else { $self->{'creditcards'}{$ccid}{lc $q} = $ref->{$q}; } } #TODO ajustar isso, esses langs nem eram pra existir my $status = $self->lang('Active') if $ref->{'active'} == 1; $status = $self->lang('Activating') if $ref->{'active'} == 2; $status = $self->lang('Deactivated') if $ref->{'active'} == 0; $status = $self->lang('Refused') if $ref->{'active'} == -1; $self->{'creditcards'}{$ccid}{'status'} = $status; #last if $ref->{'active'} == 1;#1= Ativo -1= Recusado 0= Desativado 2= Ativando } return @ids_matched; } sub get_creditcard { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_creditcard')) and return unless $self->ccid; $self->select_sql(851,$self->ccid); $self->mount_creditcard; $self->finish; return $self->error ? 0 : 1; } sub get_creditcards { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_creditcards')) and return unless $sql; $self->select_sql($sql,@params); my @creditcards = $self->mount_creditcard; $self->finish; return $self->error ? undef : @creditcards; } sub mount_formtype { my ($self) = shift; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $id = $ref->{'id'}; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; if ($q eq 'properties') { #[1=30][3=4.90::3,4,5,6::2008|6.65::1,8::2009] foreach my $propertie ($ref->{$q} =~ /\[(.+?)\]/g) { my ($type,$value) = split('=',$propertie); $self->{'formtypes'}{$id}{'properties'}{$type} = $value; #repassar as info pra salvar, elas processada de nada ainda servem # if ($type == 3) { # foreach ( split('\|',$value) ) { # my($val,$months,$year) = split('::',$_,3); # $self->{'formtypes'}{$id}{'properties'}{$type}{$year} = { # 'value' => $val, # 'months' => [split ',', $months], # } else { # my $value = $self->num($value) < 0 ? 0 : $self->num($value); # $self->{'formtypes'}{$id}{'properties'}{$type} = $value; } } elsif ($q eq 'planos') { $self->{'formtypes'}{$id}{lc $q} = [ split ',', $ref->{$q} ]; } else { $self->{'formtypes'}{$id}{lc $q} = $ref->{$q}; } } } } sub get_formtype { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_formtype')) and return unless $self->formtypeid; $self->select_sql(1050,$self->formtypeid); $self->mount_formtype; $self->finish; return $self->error ? 0 : 1; } sub mount_staff { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $staffid = $ref->{'username'}; push @ids_matched, $staffid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq 'username'; $self->{'staffs'}{$staffid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_staff { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_staff')) and return unless $self->staffid; $self->select_sql(331,$self->staffid); $self->mount_staff; $self->finish; return $self->error ? 0 : 1; } sub get_staffs { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_staffs')) and return unless $sql; $self->select_sql($sql,@params); my @staffs = $self->mount_staff; $self->finish; return $self->error ? undef : @staffs; } sub mount_enterprise { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $entid = $ref->{'id'}; push @ids_matched, $entid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; $self->{'enterprises'}{$entid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_enterprise { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_enterprise')) and return unless $self->entid; $self->select_sql(304,$self->entid); $self->mount_enterprise; $self->finish; return $self->error ? 0 : 1; } sub get_enterprises { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_enterprises')) and return unless $sql; $self->select_sql($sql,@params); my @enterprises = $self->mount_enterprise; $self->finish; return $self->error ? 0 : @enterprises; } sub mount_department { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $deptid = $ref->{'id'}; push @ids_matched, $deptid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; $self->{'departments'}{$deptid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_department { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_department')) and return unless $self->deptid; $self->select_sql(267,$self->deptid); $self->mount_department; $self->finish; return $self->error ? 0 : 1; } sub get_departments { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_departments')) and return unless $sql; $self->select_sql($sql,@params); my @departments = $self->mount_department; $self->finish; return $self->error ? undef : @departments; } sub mount_discount { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $did = $ref->{'id'}; push @ids_matched, $did; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; $self->{'enterprises'}{$entid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_discount { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_enterprise')) and return unless $self->entid; $self->select_sql(304,$self->entid); $self->mount_enterprise; $self->finish; return $self->error ? 0 : 1; } sub get_discounts { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_enterprises')) and return unless $sql; $self->select_sql($sql,@params); my @enterprises = $self->mount_enterprise; $self->finish; return $self->error ? 0 : @enterprises; } sub mount_logmail { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $logmailid = $ref->{'id'}; push @ids_matched, $logmailid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "id"; if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { $self->{'logmails'}{$logmailid}{lc $q} = $self->date($ref->{$q}); } elsif ($q eq 'body') { $self->{'logmails'}{$logmailid}{lc $q} = $ref->{$q}; $self->{'logmails'}{$logmailid}{lc $q} =~ s/\\(\W)/$1/g; #Emails antigos } else { $self->{'logmails'}{$logmailid}{lc $q} = $ref->{$q}; } } } return @ids_matched; } sub get_logmail { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_logmail')) and return unless $self->logmailid; $self->select_sql(164,$self->logmailid); $self->mount_logmail; $self->finish; return $self->error ? 0 : 1; } sub get_logmails { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_logmails')) and return unless $sql; $self->select_sql($sql,@params); my @logmails = $self->mount_logmail; $self->finish; return $self->error ? 0 : @logmails; } sub mount_bank { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $bankid = $ref->{'codigo'}; push @ids_matched, $bankid; foreach my $q (keys %{$sth->{NAME_hash}}) { next if $q eq "codigo"; $self->{'banks'}{$bankid}{lc $q} = $ref->{$q}; } } return @ids_matched; } sub get_bank { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'get_bank')) and return unless $self->bankid; $self->select_sql(426,$self->bankid); $self->mount_bank; $self->finish; return $self->error ? 0 : 1; } sub get_banks { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_banks')) and return unless $sql; $self->select_sql($sql,@params); my @banks = $self->mount_bank; $self->finish; return $self->error ? 0 : @banks; } sub mount_perm { my ($self) = shift; my @ids_matched; my $sth = $self->last_select; while(my $ref = $sth->fetchrow_hashref()) { my $permid = $ref->{'username'}; push @ids_matched, $permid; #foreach my $q (keys %{$sth->{NAME_hash}}) { # next if $q eq "username"; my ($module,$type,$name) = split(/:/, $ref->{'right'}, 3); $self->{'perms'}{$permid}{lc $module}{lc $type}{lc $name} = $ref->{'value'} if $module && $type && $name; } return @ids_matched; } sub get_perm { my ($self) = shift; return 0 if $self->error; my $id = $self->uid || $self->staffid; $self->set_error($self->lang(3,'get_perm')) and return unless $id; if ($self->staffid && $self->staffGroups) { #Staff groups my $sql_1082 = $self->{queries}{1082}; my @gids = $self->staffGroups; $sql_1082 .= qq| `groupname` IN ('|.join('\',\'', @gids).qq|')| if @gids; $sql_1082 .= qq| ORDER BY (`username` = ?)|; #Permissao individual preferencial $self->select_sql($sql_1082,$id,$id,$id); } else { $self->select_sql(1081,$id); } $self->mount_perm; $self->finish; return $self->error ? 0 : 1; } sub get_perms { my ($self,$sql,@params) = @_; return undef if $self->error; $self->set_error($self->lang(3,'get_perms')) and return unless $sql; $self->select_sql($sql,@params); my @perms = $self->mount_perm; $self->finish; return $self->error ? 0 : @perms; } #Search items sub return_username { my ($self) = shift; #TODO sempre atualizar para novas tabelas #MUITO CUIDADO COM O UID ou SID ou OUTRO, POIS PERDE A REFERENCIA $self->invid($_[0]) and return $self->invoice('username') if ($self->TABLE_INVOICES && $_[1] =~ /(?:${\$self->TABLE_INVOICES})(?:,|$)/i); $self->callid($_[0]) and return $self->call('username') if ($self->TABLE_CALLS && $_[1] =~ /(?:${\$self->TABLE_CALLS})(?:,|$)/i); $self->callid($_[0]) and return $self->call('username') if ($self->TABLE_NOTES && $_[1] =~ /(?:${\$self->TABLE_NOTES})(?:,|$)/i); $self->balanceid($_[0]) and return $self->balance('username') if ($self->TABLE_BALANCES && $_[1] =~ /(?:${\$self->TABLE_BALANCES})(?:,|$)/i); $self->creditid($_[0]) and return $self->credit('username') if ($self->TABLE_CREDITS && $_[1] =~ /(?:${\$self->TABLE_CREDITS})(?:,|$)/i); $self->ccid($_[0]) and return $self->creditcard('username') if ($self->TABLE_CREDITCARDS && $_[1] =~ /(?:${\$self->TABLE_CREDITCARDS})(?:,|$)/i); } sub return_sender { my ($self) = shift; if ($_[0] eq 'User' && $self->uid) { my $level = $self->user('level'); #default will be the first $level =~ s/^[:]+ my $entid = (split('::',$level))[0]; $self->entid($self->num($entid)); $sender = $self->enterprise('mail_account') if $self->entid; } if ($_[0] eq 'Billing' && $self->uid) { my $level = $self->user('level'); #default will be the first $level =~ s/^[:]+ my $entid = (split('::',$level))[0]; $self->entid($self->num($entid)); $sender = $self->enterprise('mail_billing') if $self->entid; } return $sender || $self->setting('adminemail'); } sub search_srvid { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'search_server')) and return unless $_[0] || $_[1]; my $sth = $self->select_sql(qq|SELECT `id` FROM `servidores` WHERE `$_[0]` = ?|,$_[1]); my ($id) = $sth->fetchrow_array if $sth; $self->finish; return $self->error ? '' : $id; } sub search_sid { my ($self) = shift; return 0 if $self->error; $self->set_error($self->lang(3,'search_service')) and return unless $_[0] || $_[1]; my $op = '='; my $value = $_[1]; if ($_[0] eq 'dados') { $op = 'LIKE'; $value = '%'."$_[1] : $_[2]".'::%'; } my $sth = $self->select_sql(qq|SELECT `id` FROM `servicos` WHERE `$_[0]` $op ?|,$value); return 0 if $sth->rows != 1; my ($id) = $sth->fetchrow_array if $sth; $self->finish; return $self->error ? 0 : $id; } #Template System sub template { @_=@_; my $self = shift; return \%{$self->{templates}} unless exists $_[0]; #copy $self->{templates}{$_[0]} = $_[1] if exists $_[1]; return $self->{templates}{$_[0]}; } sub template_html { @_=@_; my $self = shift; return \%{$self->{templates}} unless exists $_[0]; #copy $self->{templates}{$_[0]} = $_[1] if exists $_[1]; $self->{templates}{$_[0]} =~ s/\n/<br>/g; return $self->{templates}{$_[0]}; } sub template_parse { my ($self,$ctype) = @_; if ($ctype eq 'text/plain') { $_ =~ s/\{(\S+?)\}/$self->template($1)/egi; } else { $_ =~ s/\{(\S+?)\}/$self->template_html($1)/egi; } } #Lang System sub lang_parse { my ($self) = @_; $_ =~ s/(\%(\S*?)\%)/$self->{lang}{$2} ? $self->{lang}{$2} : ( $2 ? "missing_$2": "%")/ge; } sub _setlang { my ($self,$language) = @_; return 0 if !$language; #protect ourself escape(\$language); if (-e $self->setting('app')."/lang/$language/lang.inc") { $self->{_setlang} = $language; our %LANG = (); my $ret = do($self->setting('app')."/lang/$language/lang.inc"); die "couldn't parse lang file: $@" if $@; die "couldn't do lang file: $!" unless defined $ret; die "couldn't run lang file" unless $ret; $self->{'lang'} = { %LANG }; return 1; } else { $self->set_error('Lang not found at '.$self->setting('app')."/lang/$language/lang.inc"); return 0; } } sub lang { my ($self,$no,@values) = @_; ($no,@values) = @$no if (ref $no eq "ARRAY"); # return "missing_$no_" unless exists $self->{lang}{$no}; return $no unless exists $self->{lang}{$no}; #Broke non-translations, who needs must override return sprintf("$self->{lang}{$no}",@values); } sub servicos { my ($self) = shift; my @q = split(" ","@_"); return 0 if $self->error; $self->set_error($self->lang(3,'servicos')) and return unless $self->num($self->{'service'}{'id'}); my $sth = $self->select_sql(qq|SELECT * FROM `servicos` INNER JOIN `planos` ON `servicos`.`servicos`=`planos`.`servicos` WHERE `id` = ?|,$self->num($self->{'service'}{'id'})); while(my $ref = $sth->fetchrow_hashref()) { foreach my $q (@q) { # next if $q eq "servidor" && $ref->{$q} eq 1;#pensar em utilizar isso if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { $self->{'service'}{lc $q} = $self->date($ref->{$q}); } else { $self->{'service'}{lc $q} = $ref->{$q}; } } } $self->finish; return $self->error ? 0 : 1; } #sub invoices { # my ($self) = shift; # my @q = split(" ","@_"); # return 0 if $self->error; # $self->set_error($self->lang(3,'invoices')) and return unless $self->num($self->{'invoice'}{'id'}); # my $sth = $self->select_sql(qq|SELECT `invoices`.*, `users`.`vencimento` FROM `invoices` INNER JOIN `users` ON `invoices`.`username`=`users`.`username` WHERE `id` = ?|,$self->num($self->{'invoice'}{'id'})); # while(my $ref = $sth->fetchrow_hashref()) { # foreach my $q (@q) { # if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { # $self->{'invoice'}{lc $q} = $self->date($ref->{$q}); # } else { # $self->{'invoice'}{lc $q} = $ref->{$q}; # $self->finish; # return $self->error ? 0 : 1; sub users { my ($self) = shift; my @q = split(" ","@_"); return 0 if $self->error; $self->set_error($self->lang(3,'users')) and return unless $self->num($self->{'user'}{'id'}); my $sth = $self->select_sql(qq|SELECT * FROM `users` WHERE `username` = ?|,$self->num($self->{'user'}{'id'})); while(my $ref = $sth->fetchrow_hashref()) { foreach my $q (@q) { if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { $self->{'user'}{lc $q} = $self->date($ref->{$q}); } else { $self->{'user'}{lc $q} = $ref->{$q}; } } } $self->finish; return $self->error ? 0 : 1; } sub pagamentos { my ($self) = shift; my @q = split(" ","@_"); return 0 if $self->error; $self->set_error($self->lang(3,'pagamentos')) and return unless $self->num($self->{'pagamento'}{'id'}); my $sth = $self->select_sql(qq|SELECT * FROM `pagamento` WHERE `id` = ?|,$self->num($self->{'pagamento'}{'id'})); while(my $ref = $sth->fetchrow_hashref()) { foreach my $q (@q) { if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { $self->{'pagamento'}{lc $q} = $self->date($ref->{$q}); } else { $self->{'pagamento'}{lc $q} = $ref->{$q}; } } } $self->finish; return $self->error ? 0 : 1; } sub planos { my ($self) = shift; my @q = split(" ","@_"); return 0 if $self->error; $self->set_error($self->lang(3,'planos')) && return unless $self->num($self->{'plano'}{'id'}); my $sth = $self->select_sql(qq|SELECT * FROM `planos` LEFT JOIN `planos_modules` ON `planos`.`servicos`=`planos_modules`.`plano` WHERE `servicos` = ?|,$self->num($self->{'plano'}{'id'})); while(my $ref = $sth->fetchrow_hashref()) { foreach my $q (@q) { if ($sth->{TYPE}->[$sth->{NAME_hash}{$q}] == 9) { $self->{'plano'}{lc $q} = $self->date($ref->{$q}); } else { $self->{'plano'}{lc $q} = $ref->{$q}; } } } $self->finish; return $self->error ? 0 : 1; } sub promo { my ($self,$type) = @_; return 0 if $self->error; #types 1 - dias gratis 2 - Sem taxa de setup 3 - Descontos em meses 4 - Nao se orientar pelo vc do usuario 5 - dias para finalizar 6 - fatura exclusiva $self->set_error($self->lang(3,'promocao')) and return unless $self->num($self->sid); $self->set_error($self->lang(3,'promocao')) and return unless $self->num($type); unless (defined $self->service('_promo'.$type)) { my $sth = $self->select_sql(qq|SELECT * FROM `promocao` WHERE `servico` = ?|,$self->sid); while (my $ref = $sth->fetchrow_hashref()) { my $r = $ref->{'value'}; $r = 0 if $r < 0 && $ref->{'type'} != 3; $self->service('_promo'.$ref->{'type'}, $r); } } if ($type == 1 || $type == 2 || $type == 4 || $type == 5 || $type == 6) { my $r = $self->num($self->service('_promo'.$type)); $r = 0 if $r < 0; return $r } return split("::",$self->service('_promo'.$type),3) if $type == 3; return undef; } sub _feriados { #put in memory for fast access my ($self) = @_; my $sth = $self->select_sql(qq|SELECT * FROM `feriados`|); while(my $ref = $sth->fetchrow_hashref()) { $self->{'feriados'}{$ref->{'mes'}}{$ref->{'dia'}} = $ref->{'desc'}; } $self->finish; return $self->error ? 0 : 1; } sub _settings { #put in memory for fast access my ($self) = @_; my $sth = $self->select_sql(qq|SELECT * FROM `settings`|); while(my $ref = $sth->fetchrow_hashref()) { my $setting = $ref->{'setting'}; $self->{settings}{$setting} = $ref->{'value'}; } $self->finish; return $self->error ? 0 : 1; } sub _setskin { my ($self,$skin) = @_; return 0 if !$skin; my $sth = $self->select_sql(qq|SELECT * FROM `skins` WHERE `name` = ?|,$skin); while(my $ref = $sth->fetchrow_hashref()) { my $setting = $ref->{'setting'}; $self->{skin}{$setting} = $ref->{'value'}; } $self->finish; #set name $self->{skin}{name} = $skin; return $self->error ? 0 : 1; } sub _templates { my ($self) = shift; $self->template('lang',$self->{_setlang}); $self->template('data',$self->setting('data')); $self->template('title',$self->setting('title')); $self->template('baseurl',$self->setting('baseurl')); $self->template('timen',$self->calendar('timenow')); $self->template('data_tpl',$self->skin('data_tpl')); $self->template('url_tpl',$self->skin('url_tpl')); $self->template('imgbase',$self->skin('imgbase')); $self->template('logo',$self->skin('logo_url')); return 1; } sub _country_codes { #put in memory for fast access my ($self) = @_; my $sth = $self->select_sql(qq|SELECT * FROM `countrycode`|); while(my $ref = $sth->fetchrow_hashref()) { my $country = $ref->{'id'}; $self->{country_codes}{uc $country} = { code => $ref->{'call'}, name => $ref->{'nome'} }; } $self->finish; return $self->error ? 0 : 1; } sub _setswitchs { our %SWITCH; #Defaults switchs $SWITCH{skip_sql} = 0; $SWITCH{skip_log} = 0; $SWITCH{skip_mail} = 0; $SWITCH{skip_logmail} = 0; $SWITCH{skip_error} = 0; return 1; } sub _setCGI { my ($self) = shift; require CGI; my $q = CGI->new(); my @pairs = split(/;/, $q->query_string()); foreach my $pair (@pairs) { my ($name, $value) = split(/=/, $pair); #Problema de charset era o binmode utf8 que escrevia no arquivo errado e a tela do terminal tbm, mudei pra UTF8 $self->param($name,Controller::URLDecode($value)); } foreach my $name ($q->cookie()) { $self->cookie($name,$q->cookie($name)); } return 1; } sub variable { @_=@_; my ($self) = shift; $self->{_variables}{$_[0]} = $_[1] if exists $_[1]; return $self->{_variables}{$_[0]}; } sub variables { my ($self) = shift; return keys %{$self->{_variables}}; } sub param { @_=@_; my ($self) = shift; $self->{_params}{$_[0]} = trim($_[1]) if exists $_[1]; return $self->{_params}{$_[0]}; } sub params { my ($self) = shift; return keys %{$self->{_params}}; } sub cookie { @_=@_; my ($self) = shift; $self->{_cookies}{$_[0]} = $_[1] if exists $_[1]; return $self->{_cookies}{$_[0]}; } sub cookies { my ($self) = shift; return keys %{$self->{_cookies}}; } sub country_code { my ($self, $key, $value) = @_; $self->{country_codes}{$key} = $value if $value; if (exists $self->{country_codes}{$key}) { return $self->{country_codes}{$key}; } $self->set_error($self->lang(14, $key)); die; } sub country_codes { my ($self) = shift; return sort keys %{$self->{country_codes}}; } sub setting { my ($self, $key, $value) = @_; $self->{settings}{$key} = $value if defined $value; if (exists $self->{settings}{$key}) { return $self->{settings}{$key}; } $self->set_error($self->lang(2, $key)); die $key if $self->connected; } sub settings { my ($self) = @_; return keys %{$self->{settings}}; } sub skin { my ($self, $key) = @_; if (exists $self->{'skin'}{$key}) { return $self->{'skin'}{$key}; } $self->set_error($self->lang(4, $key, $self->{'skin'}{'name'})); die; } sub skins { my $self = shift; my $sth = $self->select_sql(qq|SELECT DISTINCT `name` FROM `skins`|); my @skins = map {@{$_}} @{ $sth->fetchall_arrayref() }; $self->finish; return @skins; } sub gonext { my $self = @_; $self->{'_next'} = 1; return 1; } sub golast { my $self = @_; $self->{'_last'} = 1; return 1; } sub next { my $self = @_; if ($self->{'_next'} == 1) { $self->{'_next'} = undef; next; } if ($self->{'_last'} == 1) { $self->{'_last'} = undef; last; } } sub list_langs { my $self = shift; my @mods; my $base = $self->setting('app') .'/lang/'; opendir(F, $base ) || return undef; my @list = readdir(F); closedir F; foreach my $item (@list) { if (-d $base.$item) { push (@dirs, $item) if (-e $base.$item.'/lang.inc'); } } @{ $self->{list_langs} } = sort {lc($a) cmp lc($b)} @dirs; iUnique( $self->{list_langs} ); return @{ $self->{list_langs} }; } sub list_modules { my $self = shift; my @mods; my $match = sub { if ($File::Find::name =~ /\.pm$/) { open(F, $File::Find::name) || return undef; my $is_module; while(<F>) { $is_module = 1 if /^# Use: Module/; if ($is_module == 1 && /^ *package +(([^\s:]+(::)?){4}([^\s:]+){0,1});/) { push (@mods, $1); last; } } close(F); } }; find( $match, $self->setting('data').'/sistema/'.$self->setting('modules'), $self->setting('app').'/modules'); @{ $self->{list_modules} } = sort {lc($a) cmp lc($b)} @mods; iUnique( $self->{list_modules} ); return @{ $self->{list_modules} }; } sub DESTROY { my $self = @_; #warn 'Controller was closed'; } sub traceback { my $self = shift; my $err = shift; my @trace; #FIXME: empty list? # Skip the first frame [0], because it's the call to dotb. # Skip the second frame [1], because it's the call to die, with redirection my $frame = 2; my $tab = 1; while (my ($package, $filename, $line, $sub) = caller($frame++)) { if ($package eq 'main') { $sub =~ s/main:: push(@trace, trim("$sub() called from $filename on line $line")); } else { return undef if $sub eq '(eval)'; push(@trace, trim("$package::$sub() called from $filename on line $line\n")); } } #print STDERR "Content-type: text/plain\n\n" unless $mod_perl; my $mess .= "Traceback (most recent call last):\n"; $mess .= join("\n", map { " "x$tab++ . $_ } reverse(@trace) )."\n"; $mess .= "Package error: ".$self->error()."\n"; $mess .= "Error: $err"; #already has \n at end my $mod_perl = exists $ENV{MOD_PERL}; if ($mod_perl) { my $r; if ($ENV{<API key>} && $ENV{<API key>} == 2) { $mod_perl = 2; require Apache2::RequestRec; require Apache2::RequestIO; require Apache2::RequestUtil; require APR::Pool; require ModPerl::Util; require Apache2::Response; $r = Apache2::RequestUtil->request; } else { $r = Apache->request; } # If bytes have already been sent, then # we print the message out directly. # Otherwise we make a custom error # handler to produce the doc for us. if ($r->bytes_sent) { $r->print($mess); $mod_perl == 2 ? ModPerl::Util::exit(0) : $r->exit; } else { # MSIE won't display a custom 500 response unless it is >512 bytes! if ($ENV{HTTP_USER_AGENT} =~ /MSIE/) { $mess = "<!-- " . (' ' x 513) . " -->\n$mess"; } $r->custom_response(500,$mess); } } else { # my $bytes_written = eval{tell STDERR}; # if (defined $bytes_written && $bytes_written > 0) { # print STDERR $mess; # else { # print STDERR "Status: 500\n"; # print STDERR "Content-type: text/plain\n\n"; # print STDERR $mess; } $self->logevent($mess); #send message to cron lock $self->logcron($err) if $self->connected; #send a nice message to user $self->script_error($err); } sub script_error { my ($self) = shift; my $error = "@_"; $error ||= $self->error; #TODO estudar se o script_error pode ficar em um arquivo html print "Content-type: text/html\n\n"; print qq~<html><head><title>Erro</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head><body bgcolor="#FFFFFF"><p>&nbsp;</p><table width="600" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td colspan="3"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Controller: <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><font color="#990000">Erro de </font></b></font><font color="#990000">Script </font></b></font></td></tr><tr> <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr> <td colspan="3"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Controller n&atilde;o pode ser rodado pelos seguintes erros:</font></td> </tr><tr><td colspan="3" height="40"><font face="Courier New, Courier, mono" size="2"><br>$error<br></td></tr></table><p align="center">&nbsp;</p></body></html> ~; exit(1); } __END__; Diagnostics Find @ISA: use Class::ISA; print "Food::Fishstick path is:\n ", join(", ", Class::ISA::super_path($class)), "\n"; 1;
core:import( "<API key>" ) <API key> = <API key> or class( <API key>.<API key> ) function <API key>:init( ... ) <API key>.super.init( self, ... ) managers.player:preload() end -- Returns a value function <API key>:value( name ) return self._values[ name ] end function <API key>:client_on_executed( ... ) if not self._values.enabled then return end managers.player:set_player_state( self._values.state or managers.player:<API key>() ) end function <API key>:on_executed( instigator ) if not self._values.enabled then return end managers.player:set_player_state( self._values.state or managers.player:<API key>() ) managers.groupai:state():<API key>( self._values.state or managers.player:<API key>() ) managers.network:<API key>( self._id, { position = self._values.position, rotation = self._values.rotation } ) <API key>.super.on_executed( self, self._unit or instigator ) end
#ifndef <API key> #define <API key> #ifndef _MED_C89_ #include "codec_op_etsi_hifi.h" #endif #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif #ifdef _MED_C89_ typedef char Char; typedef signed char Word8; typedef unsigned char UWord8; typedef short Word16; typedef unsigned short UWord16; typedef long Word32; typedef unsigned long UWord32; typedef int Flag; #endif #define MAX_32 ((Word32)0x7fffffffL) #define MIN_32 ((Word32)0x80000000L) #define MAX_16 ((Word16)0x7fff) #define MIN_16 ((Word16)0x8000) #ifdef _MED_C89_ #define CODEC_OpSetOverflow(swFlag) (Overflow = swFlag) #define CODEC_OpGetOverflow() (Overflow) #define CODEC_OpSetCarry(swFlag) (Carry = swFlag) #define CODEC_OpGetCarry() (Carry) #define XT_INLINE static #endif #define round(L_var1) round_etsi(L_var1) #ifdef _MED_C89_ extern Flag Overflow; extern Flag Carry; #endif #ifdef _MED_C89_ /* ETSI : basic_op.h */ extern Word16 saturate (Word32 swVar); /* 32bit->16bit */ extern Word16 add(Word16 shwVar1, Word16 shwVar2); /* Short add */ extern Word16 sub(Word16 shwVar1, Word16 shwVar2); /* Short sub */ extern Word16 abs_s(Word16 shwVar1); /* Short abs */ extern Word16 shl(Word16 shwVar1, Word16 shwVar2); /* Short shift left */ extern Word16 shr(Word16 shwVar1, Word16 shwVar2); /* Short shift right*/ extern Word16 mult(Word16 shwVar1, Word16 shwVar2); /* Short mult */ extern Word32 L_mult(Word16 shwVar1, Word16 shwVar2); /* Long mult */ extern Word16 negate(Word16 shwVar1); /* Short negate */ extern Word16 extract_h(Word32 swVar1); /* Extract high */ extern Word16 extract_l(Word32 swVar1); /* Extract low */ extern Word16 round_etsi(Word32 swVar1); /* Round */ extern Word32 L_mac(Word32 swVar3, Word16 shwVar1, Word16 shwVar2); /* Mac */ extern Word32 L_msu(Word32 swVar3, Word16 shwVar1, Word16 shwVar2); /* Msu */ extern Word32 L_macNs(Word32 swVar3, Word16 shwVar1, Word16 shwVar2); /* Mac without sat */ extern Word32 L_msuNs(Word32 swVar3, Word16 shwVar1, Word16 shwVar2); /* Msu without sat */ extern Word32 L_add(Word32 swVar1, Word32 swVar2); /* Long add */ extern Word32 L_sub(Word32 swVar1, Word32 swVar2); /* Long sub */ extern Word32 L_add_c(Word32 swVar1, Word32 swVar2); /* Long add with c */ extern Word32 L_sub_c(Word32 swVar1, Word32 swVar2); /* Long sub with c */ extern Word32 L_negate(Word32 swVar1); /* Long negate */ extern Word16 mult_r(Word16 shwVar1, Word16 shwVar2); /* Mult with round */ extern Word32 L_shl(Word32 swVar1, Word16 shwVar2); /* Long shift left */ extern Word32 L_shr(Word32 swVar1, Word16 shwVar2); /* Long shift right */ extern Word16 shr_r(Word16 shwVar1, Word16 shwVar2); /* Shift right with round */ extern Word16 mac_r(Word32 swVar3, Word16 shwVar1, Word16 shwVar2); /* Mac with rounding */ extern Word16 msu_r(Word32 swVar3, Word16 shwVar1, Word16 shwVar2); /* Msu with rounding */ extern Word32 L_deposit_h(Word16 shwVar1); /* 16 bit shwVar1 -> MSB */ extern Word32 L_deposit_l(Word16 shwVar1); /* 16 bit shwVar1 -> LSB */ extern Word32 L_shr_r(Word32 swVar1, Word16 shwVar2); /* Long shift right with round */ extern Word32 L_abs(Word32 swVar1); /* Long abs */ extern Word32 L_sat(Word32 swVar1); /* Long saturation */ extern Word16 norm_s(Word16 shwVar1); /* Short norm */ extern Word16 div_s(Word16 shwVar1, Word16 shwVar2); /* Short division */ extern Word16 norm_l(Word32 swVar1); /* Long norm */ /* ETSI : oper_32b.h */ /* Extract from a 32 bit integer two 16 bit DPF */ extern void L_Extract(Word32 swVar32, Word16 *pshwHi, Word16 *pshwLo); /* Compose from two 16 bit DPF a 32 bit integer */ extern Word32 L_Comp(Word16 shwHi, Word16 shwLo); /* Multiply two 32 bit integers (DPF). The result is divided by 2**31 */ extern Word32 Mpy_32(Word16 shwHi1, Word16 shwLo1, Word16 shwHi2, Word16 shwLo2); /* Multiply a 16 bit integer by a 32 bit (DPF). The result is divided by 2**15 */ extern Word32 Mpy_32_16(Word16 shwHi, Word16 shwLo, Word16 shwN); /* Fractional integer division of two 32 bit numbers */ extern Word32 Div_32(Word32 swNum, Word16 denom_hi, Word16 denom_lo); /* ETSI : mac_32.h */ /* Multiply two 32 bit integers (DPF) and accumulate with (normal) 32 bit integer. The multiplication result is divided by 2**31 */ extern Word32 Mac_32(Word32 swVar32, Word16 shwHi1, Word16 shwLo1, Word16 shwHi2, Word16 shwLo2); /* Multiply a 16 bit integer by a 32 bit (DPF) and accumulate with (normal)32 bit integer. The multiplication result is divided by 2**15 */ extern Word32 Mac_32_16(Word32 swVar32, Word16 shwHi, Word16 shwLo, Word16 shwN); #endif /* ifdef _MED_C89_ */ #ifdef __cplusplus #if __cplusplus } #endif #endif #endif /* end of med_com_etsi_op.h */
#include "types.h" /* Error database */ typedef struct error ERROR; struct error { LINK(ERROR) link; /* Linked list of errors */ long line; /* Target line number */ long org; /* Original target line number */ unsigned char *file; /* Target file name */ long src; /* Error-file line number */ unsigned char *msg; /* The message */ } errors = { { &errors, &errors} }; ERROR *errptr = &errors; /* Current error row */ B *errbuf = NULL; /* Buffer with error messages */ /* Function which allows stepping through all error buffers, for multi-file search and replace. Give it a buffer. It finds next buffer in error list. Look at 'berror' for error information. */ /* This is made to work like bafter: it does not increment refcount of buffer */ B *beafter(B *b) { struct error *e; unsigned char *name = b->name; if (!name) name = USTR ""; for (e = errors.link.next; e != &errors; e = e->link.next) if (!zcmp(name, e->file)) break; if (e == &errors) { /* Given buffer is not in list? Return first buffer in list. */ e = errors.link.next; } while (e != &errors && !zcmp(name, e->file)) e = e->link.next; berror = 0; if (e != &errors) { B *b = bfind(e->file); /* bfind bumps refcount, so we have to unbump it */ if (b->count == 1) b->orphan = 1; /* Oops */ else --b->count; return b; } return 0; } /* Insert and delete notices */ void inserr(unsigned char *name, long int where, long int n, int bol) { ERROR *e; if (!n) return; if (name) { for (e = errors.link.next; e != &errors; e = e->link.next) { if (!zcmp(e->file, name)) { if (e->line > where) e->line += n; else if (e->line == where && bol) e->line += n; } } } } void delerr(unsigned char *name, long int where, long int n) { ERROR *e; if (!n) return; if (name) { for (e = errors.link.next; e != &errors; e = e->link.next) { if (!zcmp(e->file, name)) { if (e->line > where + n) e->line -= n; else if (e->line > where) e->line = where; } } } } /* Abort notice */ void abrerr(unsigned char *name) { ERROR *e; if (name) for (e = errors.link.next; e != &errors; e = e->link.next) if (!zcmp(e->file, name)) e->line = e->org; } /* Save notice */ void saverr(unsigned char *name) { ERROR *e; if (name) for (e = errors.link.next; e != &errors; e = e->link.next) if (!zcmp(e->file, name)) e->org = e->line; } /* Pool of free error nodes */ ERROR errnodes = { {&errnodes, &errnodes} }; /* Free an error node */ static void freeerr(ERROR *n) { vsrm(n->file); vsrm(n->msg); enquef(ERROR, link, &errnodes, n); } /* Free all errors */ static int freeall(void) { int count = 0; while (!qempty(ERROR, link, &errors)) { freeerr(deque_f(ERROR, link, errors.link.next)); ++count; } errptr = &errors; return count; } /* Parse error messages into database */ /* From joe's joe 2.9 */ /* First word (allowing ., /, _ and -) with a . is the file name. Next number is line number. Then there should be a ':' */ static void parseone(struct charmap *map,unsigned char *s,unsigned char **rtn_name,long *rtn_line) { int x, y, flg; unsigned char *name = NULL; long line = -1; y=0; flg=0; if (s[0] == 'J' && s[1] == 'O' && s[2] == 'E' && s[3] == ':') goto bye; do { /* Skip to first word */ for (x = y; s[x] && !(joe_isalnum_(map,s[x]) || s[x] == '.' || s[x] == '/'); ++x) ; /* Skip to end of first word */ for (y = x; joe_isalnum_(map,s[y]) || s[y] == '.' || s[y] == '/' || s[y]=='-'; ++y) if (s[y] == '.') flg = 1; } while (!flg && x!=y); /* Save file name */ if (x != y) name = vsncpy(NULL, 0, s + x, y - x); /* Skip to first number */ for (x = y; s[x] && (s[x] < '0' || s[x] > '9'); ++x) ; /* Skip to end of first number */ for (y = x; s[y] >= '0' && s[y] <= '9'; ++y) ; /* Save line number */ if (x != y) sscanf((char *)(s + x), "%ld", &line); if (line != -1) --line; /* Look for ':' */ flg = 0; while (s[y]) { /* Allow : anywhere on line: works for MIPS C compiler */ /* for (y = 0; s[y];) */ if (s[y]==':') { flg = 1; break; } ++y; } bye: if (!flg) line = -1; *rtn_name = name; *rtn_line = line; } /* Parser for file name lists from grep, find and ls. * * filename * filename:* * filename:line-number:* */ void parseone_grep(struct charmap *map,unsigned char *s,unsigned char **rtn_name,long *rtn_line) { int y; unsigned char *name = NULL; long line = -1; if (s[0] == 'J' && s[1] == 'O' && s[2] == 'E' && s[3] == ':') goto bye; /* Skip to first : or end of line */ for (y = 0;s[y] && s[y] != ':';++y); if (y) { /* This should be the file name */ name = vsncpy(NULL,0,s,y); line = 0; if (s[y] == ':') { /* Maybe there's a line number */ ++y; while (s[y] >= '0' && s[y] <= '9') line = line * 10 + (s[y++] - '0'); --line; if (line < 0 || s[y] != ':') { /* Line number is only valid if there's a second : */ line = 0; } } } bye: *rtn_name = name; *rtn_line = line; } static int parseit(struct charmap *map,unsigned char *s, long int row, void (*parseone)(struct charmap *map, unsigned char *s, unsigned char **rtn_name, long *rtn_line), unsigned char *current_dir) { unsigned char *name = NULL; long line = -1; ERROR *err; parseone(map,s,&name,&line); if (name) { if (line != -1) { /* We have an error */ err = (ERROR *) alitem(&errnodes, sizeof(ERROR)); err->file = name; if (current_dir) { err->file = vsncpy(NULL, 0, sv(current_dir)); err->file = vsncpy(sv(err->file), sv(name)); err->file = canonical(err->file); vsrm(name); } else { err->file = name; } err->org = err->line = line; err->src = row; err->msg = vsncpy(NULL, 0, sc("\\i")); err->msg = vsncpy(sv(err->msg), sv(s)); enqueb(ERROR, link, &errors, err); return 1; } else vsrm(name); } return 0; } /* Parse the error output contained in a buffer */ void kill_ansi(unsigned char *s); static long parserr(B *b) { if (markv(1)) { P *p = pdup(markb, USTR "parserr1"); P *q = pdup(markb, USTR "parserr2"); long nerrs = 0; errbuf = markb->b; freeall(); p_goto_bol(p); do { unsigned char *s; pset(q, p); p_goto_eol(p); s = brvs(q, (int) (p->byte - q->byte)); if (s) { kill_ansi(s); nerrs += parseit(q->b->o.charmap, s, q->line, (q->b->parseone ? q->b->parseone : parseone),q->b->current_dir); vsrm(s); } pgetc(p); } while (p->byte < markk->byte); prm(p); prm(q); return nerrs; } else { P *p = pdup(b->bof, USTR "parserr3"); P *q = pdup(p, USTR "parserr4"); long nerrs = 0; errbuf = b; freeall(); do { unsigned char *s; pset(q, p); p_goto_eol(p); s = brvs(q, (int) (p->byte - q->byte)); if (s) { kill_ansi(s); nerrs += parseit(q->b->o.charmap, s, q->line, (q->b->parseone ? q->b->parseone : parseone), q->b->current_dir); vsrm(s); } } while (pgetc(p) != NO_MORE_DATA); prm(p); prm(q); return nerrs; } } BW *find_a_good_bw(B *b) { W *w; BW *bw = 0; /* Find lowest window with buffer */ if ((w = maint->topwin) != NULL) { do { if ((w->watom->what&TYPETW) && ((BW *)w->object)->b==b && w->y>=0) bw = (BW *)w->object; w = w->link.next; } while (w != maint->topwin); } if (bw) return bw; /* Otherwise just find lowest window */ if ((w = maint->topwin) != NULL) { do { if ((w->watom->what&TYPETW) && w->y>=0) bw = (BW *)w->object; w = w->link.next; } while (w != maint->topwin); } return bw; } int parserrb(B *b) { BW *bw; int n; freeall(); bw = find_a_good_bw(b); unmark(bw); n = parserr(b); if (n) joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("%d messages found")), n); else joe_snprintf_0(msgbuf, sizeof(msgbuf), joe_gettext(_("No messages found"))); msgnw(bw->parent, msgbuf); return 0; } int urelease(BW *bw) { bw->b->parseone = 0; if (qempty(ERROR, link, &errors) && !errbuf) { joe_snprintf_0(msgbuf, sizeof(msgbuf), joe_gettext(_("No messages"))); } else { int count = freeall(); errbuf = NULL; joe_snprintf_1(msgbuf, sizeof(msgbuf), joe_gettext(_("%d messages cleared")), count); } msgnw(bw->parent, msgbuf); updall(); return 0; } int uparserr(BW *bw) { int n; freeall(); bw->b->parseone = parseone; n = parserr(bw->b); if (n) joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("%d messages found")), n); else joe_snprintf_0(msgbuf, sizeof(msgbuf), joe_gettext(_("No messages found"))); msgnw(bw->parent, msgbuf); return 0; } int ugparse(BW *bw) { int n; freeall(); bw->b->parseone = parseone_grep; n = parserr(bw->b); if (n) joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("%d messages found")), n); else joe_snprintf_0(msgbuf, sizeof(msgbuf), joe_gettext(_("No messages found"))); msgnw(bw->parent, msgbuf); return 0; } int jump_to_file_line(BW *bw,unsigned char *file,int line,unsigned char *msg) { int omid; if (!bw->b->name || zcmp(file, bw->b->name)) { if (doswitch(bw, vsdup(file), NULL, NULL)) return -1; bw = (BW *) maint->curwin->object; } omid = mid; mid = 1; pline(bw->cursor, line); dofollows(); mid = omid; bw->cursor->xcol = piscol(bw->cursor); msgnw(bw->parent, msg); return 0; } /* Show current message */ int ucurrent_msg(BW *bw) { if (errptr != &errors) { msgnw(bw->parent, errptr->msg); return 0; } else { msgnw(bw->parent, joe_gettext(_("No messages"))); return -1; } } /* Find line in error database: return pointer to message */ ERROR *srcherr(BW *bw,unsigned char *file,long line) { ERROR *p; for (p = errors.link.next; p != &errors; p=p->link.next) if (!zcmp(p->file,file) && p->org == line) { errptr = p; setline(errbuf, errptr->src); return errptr; } return 0; } /* Delete ansi formatting */ void kill_ansi(unsigned char *s) { unsigned char *d = s; while (*s) if (*s == 27) { while (*s && (*s == 27 || *s == '[' || (*s >= '0' && *s <= '9') || *s == ';')) ++s; if (*s) ++s; } else *d++ = *s++; *d = 0; } int ujump(BW *bw) { int rtn = -1; P *p = pdup(bw->cursor, USTR "ujump"); P *q = pdup(p, USTR "ujump"); unsigned char *s; p_goto_bol(p); p_goto_eol(q); s = brvs(p, (int) (q->byte - p->byte)); kill_ansi(s); prm(p); prm(q); if (s) { unsigned char *name = NULL; unsigned char *fullname = NULL; unsigned char *curd = get_cd(bw->parent); long line = -1; if (bw->b->parseone) bw->b->parseone(bw->b->o.charmap,s,&name,&line); else parseone_grep(bw->b->o.charmap,s,&name,&line); /* Prepend current directory.. */ fullname = vsncpy(NULL, 0, sv(curd)); fullname = vsncpy(sv(fullname), sv(name)); vsrm(name); name = canonical(fullname); if (name && line != -1) { ERROR *p = srcherr(bw, name, line); uprevw((BASE *)bw); /* Check that we made it to a tw */ if (p) rtn = jump_to_file_line(maint->curwin->object,name,p->line,NULL /* p->msg */); else rtn = jump_to_file_line(maint->curwin->object,name,line,NULL); vsrm(name); } vsrm(s); } return rtn; } int unxterr(BW *bw) { if (errptr->link.next == &errors) { msgnw(bw->parent, joe_gettext(_("No more errors"))); return -1; } errptr = errptr->link.next; setline(errbuf, errptr->src); return jump_to_file_line(bw,errptr->file,errptr->line,NULL /* errptr->msg */); } int uprverr(BW *bw) { if (errptr->link.prev == &errors) { msgnw(bw->parent, joe_gettext(_("No more errors"))); return -1; } errptr = errptr->link.prev; setline(errbuf, errptr->src); return jump_to_file_line(bw,errptr->file,errptr->line,NULL /* errptr->msg */); }
<?php // no direct access defined('_JEXEC') or die; /** * AKGrid class to dynamically generate HTML tables * * @package Windwalker.Framework * @subpackage class * @since 11.3 */ class AKGrid { /** * Array of columns * @var array * @since 11.3 */ protected $columns = array(); /** * Current active row * @var int * @since 11.3 */ protected $activeRow = 0; /** * Rows of the table (including header and footer rows) * @var array * @since 11.3 */ protected $rows = array(); /** * Header and Footer row-IDs * @var array * @since 11.3 */ protected $specialRows = array('header' => array(), 'footer' => array()); /** * Associative array of attributes for the table-tag * @var array * @since 11.3 */ protected $options; /** * Constructor for a AKGrid object * * @param array $options Associative array of attributes for the table-tag * * @since 11.3 */ public function __construct($options = array()) { $this->setTableOptions($options, true); } /** * Magic function to render this object as a table. * * @return string * * @since 11.3 */ public function __toString() { return $this->toString(); } /** * Method to set the attributes for a table-tag * * @param array $options Associative array of attributes for the table-tag * @param bool $replace Replace possibly existing attributes * * @return AKGrid This object for chaining * * @since 11.3 */ public function setTableOptions($options = array(), $replace = false) { if ($replace) { $this->options = $options; } else { $this->options = array_merge($this->options, $options); } return $this; } /** * Get the Attributes of the current table * * @return array Associative array of attributes * * @since 11.3 */ public function getTableOptions() { return $this->options; } /** * Add new column name to process * * @param string $name Internal column name * * @return AKGrid This object for chaining * * @since 11.3 */ public function addColumn($name) { $this->columns[] = $name; return $this; } /** * Returns the list of internal columns * * @return array List of internal columns * * @since 11.3 */ public function getColumns() { return $this->columns; } /** * Delete column by name * * @param string $name Name of the column to be deleted * * @return AKGrid This object for chaining * * @since 11.3 */ public function deleteColumn($name) { $index = array_search($name, $this->columns); if ($index !== false) { unset($this->columns[$index]); $this->columns = array_values($this->columns); } return $this; } /** * Method to set a whole range of columns at once * This can be used to re-order the columns, too * * @param array $columns List of internal column names * * @return AKGrid This object for chaining * * @since 11.3 */ public function setColumns($columns) { $this->columns = array_values($columns); return $this; } /** * Adds a row to the table and sets the currently * active row to the new row * * @param array $options Associative array of attributes for the row * @param int $special 1 for a new row in the header, 2 for a new row in the footer * * @return AKGrid This object for chaining * * @since 11.3 */ public function addRow($options = array(), $special = false) { $this->rows[]['_row'] = $options; $this->activeRow = count($this->rows) - 1; if ($special) { if ($special === 1) { $this->specialRows['header'][] = $this->activeRow; } else { $this->specialRows['footer'][] = $this->activeRow; } } return $this; } /** * Method to get the attributes of the currently active row * * @return array Associative array of attributes * * @since 11.3 */ public function getRowOptions() { return $this->rows[$this->activeRow]['_row']; } /** * Method to set the attributes of the currently active row * * @param array $options Associative array of attributes * * @return AKGrid This object for chaining * * @since 11.3 */ public function setRowOptions($options) { $this->rows[$this->activeRow]['_row'] = $options; return $this; } /** * Get the currently active row ID * * @return int ID of the currently active row * * @since 11.3 */ public function getActiveRow() { return $this->activeRow; } /** * Set the currently active row * * @param int $id ID of the row to be set to current * * @return AKGrid This object for chaining * * @since 11.3 */ public function setActiveRow($id) { $this->activeRow = (int) $id; return $this; } /** * Set cell content for a specific column for the * currently active row * * @param string $name Name of the column * @param string $content Content for the cell * @param array $option Associative array of attributes for the td-element * @param bool $replace If false, the content is appended to the current content of the cell * * @return AKGrid This object for chaining * * @since 11.3 */ public function setRowCell($name, $content, $option = array(), $replace = true) { if ($replace || !isset($this->rows[$this->activeRow][$name])) { $cell = new stdClass; $cell->options = $option; $cell->content = $content; $this->rows[$this->activeRow][$name] = $cell; } else { $this->rows[$this->activeRow][$name]->content .= $content; $this->rows[$this->activeRow][$name]->options = $option; } return $this; } /** * Get all data for a row * * @param int $id ID of the row to return * * @return array Array of columns of a table row * * @since 11.3 */ public function getRow($id = false) { if ($id === false) { $id = $this->activeRow; } if (isset($this->rows[(int) $id])) { return $this->rows[(int) $id]; } else { return false; } } /** * Get the IDs of all rows in the table * * @param int $special false for the standard rows, 1 for the header rows, 2 for the footer rows * * @return array Array of IDs * * @since 11.3 */ public function getRows($special = false) { if ($special) { if ($special === 1) { return $this->specialRows['header']; } else { return $this->specialRows['footer']; } } return array_diff(array_keys($this->rows), array_merge($this->specialRows['header'], $this->specialRows['footer'])); } /** * Delete a row from the object * * @param int $id ID of the row to be deleted * * @return AKGrid This object for chaining * * @since 11.3 */ public function deleteRow($id) { unset($this->rows[$id]); if (in_array($id, $this->specialRows['header'])) { unset($this->specialRows['header'][array_search($id, $this->specialRows['header'])]); } if (in_array($id, $this->specialRows['footer'])) { unset($this->specialRows['footer'][array_search($id, $this->specialRows['footer'])]); } if ($this->activeRow == $id) { end($this->rows); $this->activeRow = key($this->rows); } return $this; } /** * Render the HTML table * * @return string The rendered HTML table * * @since 11.3 */ public function toString() { $output = array(); $output[] = '<table' . $this->renderAttributes($this->getTableOptions()) . '>'; if (count($this->specialRows['header'])) { $output[] = $this->renderArea($this->specialRows['header'], 'thead', 'th'); } if (count($this->specialRows['footer'])) { $output[] = $this->renderArea($this->specialRows['footer'], 'tfoot'); } $ids = array_diff(array_keys($this->rows), array_merge($this->specialRows['header'], $this->specialRows['footer'])); if (count($ids)) { $output[] = $this->renderArea($ids); } $output[] = '</table>'; return implode('', $output); } /** * Render an area of the table * * @param array $ids IDs of the rows to render * @param string $area Name of the area to render. Valid: tbody, tfoot, thead * @param string $cell Name of the cell to render. Valid: td, th * * @return string The rendered table area * * @since 11.3 */ protected function renderArea($ids, $area = 'tbody', $cell = 'td') { $output = array(); $output[] = '<' . $area . ">\n"; foreach ($ids as $id) { $output[] = "\t<tr" . $this->renderAttributes($this->rows[$id]['_row']) . ">\n"; foreach ($this->getColumns() as $name) { if (isset($this->rows[$id][$name])) { $column = $this->rows[$id][$name]; $output[] = "\t\t<" . $cell . $this->renderAttributes($column->options) . '>' . $column->content . '</' . $cell . ">\n"; } } $output[] = "\t</tr>\n"; } $output[] = '</' . $area . '>'; return implode('', $output); } /** * Renders an HTML attribute from an associative array * * @param array $attributes Associative array of attributes * * @return string The HTML attribute string * * @since 11.3 */ protected function renderAttributes($attributes) { if (count((array) $attributes) == 0) { return ''; } $return = array(); foreach ($attributes as $key => $option) { $return[] = $key . '="' . $option . '"'; } return ' ' . implode(' ', $return); } }
<?php class Metabox { public static $boxes = array(); /** * @static * @param $type * @param $options * @return Metabox */ public static function factory($type, $options = null) { $parts = explode('_', $type); array_walk( $parts, function(&$item){ $item = ucfirst($item); } ); $class = 'Metabox_'.implode('_', $parts); if(class_exists($class)) { if( ! isset($options['type']) ) { $options['type'] = $type; } return new $class($options); } return false; } /** * @static * @param $key * @return Metabox */ public static function get($key) { return (isset(self::$boxes[$key]) ? self::$boxes[$key] : null); } public static function attr($box, $attr) { return (isset(self::$boxes[$box]->$attr) ? self::$boxes[$box]->$attr : null); } }
#ifndef <API key> #define <API key> #include <configs/bur_cfg_common.h> #include <configs/bur_am335x_common.h> #define CONFIG_AM335X_LCD #define CONFIG_LCD #define CONFIG_LCD_ROTATION #define <API key> #define <API key> #define LCD_BPP LCD_COLOR32 #define CONFIG_HW_WATCHDOG #define <API key> #define <API key> #define <API key> /* Bootcount using the RTC block */ #define <API key> 0x44E3E000 #define <API key> #define <API key> /* memory */ #define <API key> (5 * 1024 * 1024) /* Clock Defines */ #define V_OSCK 26000000 /* Clock output from T2 */ #define V_SCLK (V_OSCK) #define <API key> /* Support both device trees and ATAGs. */ #define CONFIG_OF_LIBFDT #define CONFIG_USE_FDT /* use fdt within board code */ #define <API key> #define CONFIG_CMDLINE_TAG #define <API key> #define CONFIG_INITRD_TAG #define CONFIG_CMD_BOOTZ /*#define CONFIG_MACH_TYPE 3589*/ #define CONFIG_MACH_TYPE 0xFFFFFFFF /* TODO: check with kernel*/ /* MMC/SD IP block */ #if defined(CONFIG_EMMC_BOOT) #define CONFIG_MMC #define CONFIG_GENERIC_MMC #define CONFIG_OMAP_HSMMC #define CONFIG_CMD_MMC #define <API key> /* RAW SD card / eMMC locations. */ #define <API key> 0x300 /*addr. 0x60000 */ #define <API key> 0x200 /* 256 KB */ #define <API key> #endif /* CONFIG_EMMC_BOOT */ /* * When we have SPI or NAND flash we expect to be making use of mtdparts, * both for ease of use in U-Boot and for passing information on to * the Linux kernel. */ #if defined(CONFIG_SPI_BOOT) || defined(CONFIG_NAND) #define CONFIG_MTD_DEVICE /* Required for mtdparts */ #define CONFIG_CMD_MTDPARTS #endif /* CONFIG_SPI_BOOT, ... */ #undef CONFIG_SPL_OS_BOOT #ifdef CONFIG_SPL_OS_BOOT #define <API key> 0x80F80000 /* RAW SD card / eMMC */ #define <API key> 0x900 /* address 0x120000 */ #define <API key> 0x80 /* address 0x10000 */ #define <API key> 0x80 /* 64KiB */ /* NAND */ #ifdef CONFIG_NAND #define <API key> 0x080000 /* end of u-boot */ #define <API key> 0x140000 #define <API key> 0x2000 #endif /* CONFIG_NAND */ #endif /* CONFIG_SPL_OS_BOOT */ #ifdef CONFIG_NAND #define <API key> /* OMAP4 and later ELM support */ #define <API key> #define <API key> #define <API key> #define CONFIG_SPL_NAND_ECC #define <API key> <API key> #define <API key> 0x80000 #endif /* CONFIG_NAND */ /* Always 64 KiB env size */ #define CONFIG_ENV_SIZE (64 << 10) #ifdef CONFIG_NAND #define NANDARGS \ "mtdids=" MTDIDS_DEFAULT "\0" \ "mtdparts=" MTDPARTS_DEFAULT "\0" \ "nandargs=setenv bootargs console=${console} " \ "${optargs} " \ "${optargs_rot} " \ "root=mtd6 " \ "rootfstype=jffs2\0" \ "kernelsize=0x400000\0" \ "nandboot=echo booting from nand ...; " \ "run nandargs; " \ "nand read ${loadaddr} kernel ${kernelsize}; " \ "bootz ${loadaddr} - ${dtbaddr}\0" \ "defboot=run nandboot\0" \ "bootlimit=1\0" \ "simplefb=1\0 " \ "altbootcmd=run usbscript\0" #else #define NANDARGS "" #endif /* CONFIG_NAND */ #ifdef CONFIG_MMC #define MMCARGS \ "dtbdev=mmc\0" \ "dtbpart=0:1\0" \ "mmcroot0=setenv bootargs ${optargs_rot} ${optargs} console=${console}\0" \ "mmcroot1=setenv bootargs ${optargs_rot} ${optargs} console=${console} " \ "root=/dev/mmcblk0p2 rootfstype=ext4\0" \ "mmcboot0=echo booting Updatesystem from mmc (ext4-fs) ...; " \ "setenv simplefb 1; " \ "ext4load mmc 0:1 ${loadaddr} /${kernel}; " \ "ext4load mmc 0:1 ${ramaddr} /${ramdisk}; " \ "run mmcroot0; bootz ${loadaddr} ${ramaddr} ${dtbaddr};\0" \ "mmcboot1=echo booting PPT-OS from mmc (ext4-fs) ...; " \ "setenv simplefb 0; " \ "ext4load mmc 0:2 ${loadaddr} /boot/${kernel}; " \ "run mmcroot1; bootz ${loadaddr} - ${dtbaddr};\0" \ "defboot=ext4load mmc 0:2 ${loadaddr} /boot/PPTImage.md5 && run mmcboot1; " \ "ext4load mmc 0:1 ${dtbaddr} /$dtb && run mmcboot0; " \ "run ramboot; run usbscript;\0" \ "bootlimit=1\0" \ "altbootcmd=run mmcboot0;\0" \ "upduboot=dhcp; " \ "tftp ${loadaddr} MLO && mmc write ${loadaddr} 100 100; " \ "tftp ${loadaddr} u-boot.img && mmc write ${loadaddr} 300 400;\0" #else #define MMCARGS "" #endif /* CONFIG_MMC */ #ifndef CONFIG_SPL_BUILD #define <API key> \ BUR_COMMON_ENV \ "verify=no\0" \ "autoload=0\0" \ "dtb=bur-ppt-ts30.dtb\0" \ "dtbaddr=0x80100000\0" \ "loadaddr=0x80200000\0" \ "ramaddr=0x80A00000\0" \ "kernel=zImage\0" \ "ramdisk=rootfs.cpio.uboot\0" \ "console=ttyO0,115200n8\0" \ "optargs=consoleblank=0 quiet panic=2\0" \ "nfsroot=/tftpboot/tseries/rootfs-small\0" \ "nfsopts=nolock\0" \ "ramargs=setenv bootargs ${optargs} console=${console} root=/dev/ram0\0" \ "netargs=setenv bootargs console=${console} " \ "${optargs} " \ "root=/dev/nfs " \ "nfsroot=${serverip}:${nfsroot},${nfsopts} rw " \ "ip=dhcp\0" \ "netboot=echo Booting from network ...; " \ "dhcp; " \ "tftp ${loadaddr} ${kernel}; " \ "tftp ${dtbaddr} ${dtb}; " \ "run netargs; " \ "bootz ${loadaddr} - ${dtbaddr}\0" \ "ramboot=echo Booting from network into RAM ...; "\ "if dhcp; then; " \ "tftp ${loadaddr} ${kernel}; " \ "tftp ${ramaddr} ${ramdisk}; " \ "if ext4load ${dtbdev} ${dtbpart} ${dtbaddr} /${dtb}; " \ "then; else tftp ${dtbaddr} ${dtb}; fi;" \ "run mmcroot0; " \ "bootz ${loadaddr} ${ramaddr} ${dtbaddr}; fi;\0" \ "netupdate=echo Updating UBOOT from Network (TFTP) ...; " \ "setenv autoload 0; " \ "dhcp && tftp 0x80000000 updateUBOOT.img && source;\0" \ NANDARGS \ MMCARGS #endif /* !CONFIG_SPL_BUILD*/ #define CONFIG_BOOTCOMMAND \ "run defboot;" #define CONFIG_BOOTDELAY 0 #ifdef CONFIG_NAND /* * GPMC block. We support 1 device and the physical address to * access CS0 at is 0x8000000. */ #define <API key> 1 #define <API key> 0x8000000 #define <API key> /* don't change OMAP_ELM, ECCSCHEME. ROM code only supports this */ #define <API key> #define <API key> <API key> #define <API key> #define <API key> (128*1024) #define <API key> 2048 #define <API key> (<API key> / \ <API key>) #define <API key> 64 #define <API key> <API key> #define <API key> {2, 3, 4, 5, 6, 7, 8, 9, \ 10, 11, 12, 13, 14, 15, 16, 17, \ 18, 19, 20, 21, 22, 23, 24, 25, \ 26, 27, 28, 29, 30, 31, 32, 33, \ 34, 35, 36, 37, 38, 39, 40, 41, \ 42, 43, 44, 45, 46, 47, 48, 49, \ 50, 51, 52, 53, 54, 55, 56, 57, } #define <API key> 512 #define <API key> 14 #define <API key> <API key> #define <API key> 0x80000 #define MTDIDS_DEFAULT "nand0=omap2-nand.0" #define MTDPARTS_DEFAULT "mtdparts=omap2-nand.0:" \ "128k(MLO)," \ "128k(MLO.backup)," \ "128k(dtb)," \ "128k(u-boot-env)," \ "512k(u-boot)," \ "4m(kernel),"\ "128m(rootfs),"\ "-(user)" #define <API key> 1 #endif /* CONFIG_NAND */ /* USB configuration */ #define <API key> #define <API key> #define <API key> #define <API key> /* attention! not only for gadget, enables also highspeed in hostmode */ #define <API key> #define CONFIG_AM335X_USB0 #define <API key> MUSB_HOST #define CONFIG_AM335X_USB1 #define <API key> MUSB_HOST #if defined(CONFIG_SPI_BOOT) /* McSPI IP block */ #define CONFIG_SPI #define CONFIG_OMAP3_SPI #define <API key> 24000000 #define <API key> #define <API key> #define CONFIG_SPL_SPI_LOAD #define <API key> 0x20000 #undef <API key> #define <API key> #define <API key> #define <API key> <API key> #define <API key> (4 << 10) /* 4 KB sectors */ #define CONFIG_ENV_OFFSET (768 << 10) /* 768 KiB in */ #define <API key> (896 << 10) /* 896 KiB in */ #elif defined(CONFIG_EMMC_BOOT) #undef <API key> #define <API key> #define <API key> 0 #define <API key> 2 #define CONFIG_ENV_OFFSET 0x40000 /* TODO: Adresse definieren */ #define <API key> (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) #define <API key> #elif defined(CONFIG_NAND) /* No NAND env support in SPL */ #ifdef CONFIG_SPL_BUILD #define <API key> #else #define <API key> #endif #define CONFIG_ENV_OFFSET 0x60000 #define <API key> CONFIG_ENV_SIZE #else #error "no storage for Environment defined!" #endif /* * Common filesystems support. When we have removable storage we * enabled a number of useful commands and support. */ #if defined(CONFIG_MMC) || defined(CONFIG_USB_STORAGE) #define <API key> #define CONFIG_CMD_FAT #define CONFIG_FAT_WRITE #define CONFIG_FS_EXT4 #define CONFIG_EXT4_WRITE #define CONFIG_CMD_EXT4 #define <API key> #define <API key> #endif /* CONFIG_MMC, ... */ #endif /* ! <API key> */
<!DOCTYPE HTML PUBLIC "- <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (1.8.0_25) on Sun Oct 26 12:20:02 GMT+02:00 2014 --> <title>Item</title> <meta name="date" content="2014-10-26"> <link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style"> <script type="text/javascript" src="../../script.js"></script> </head> <body> <script type="text/javascript"><! try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Item"; } } catch(err) { } var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":9,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10}; var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; var tableTab = "tableTab"; var activeTableTab = "activeTableTab"; </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <div class="topNav"><a name="navbar.top"> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> </a> <ul class="navList" title="Navigation"> <li><a href="../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/Item.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../deprecated-list.html">Deprecated</a></li> <li><a href="../../index-files/index-1.html">Index</a></li> <li><a href="../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev&nbsp;Class</li> <li>Next&nbsp;Class</li> </ul> <ul class="navList"> <li><a href="../../index.html?eshop/entity/Item.html" target="_top">Frames</a></li> <li><a href="Item.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method.summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method.detail">Method</a></li> </ul> </div> <a name="skip.navbar.top"> </a></div> <div class="header"> <div class="subTitle">eshop.entity</div> <h2 title="Class Item" class="title">Class Item</h2> </div> <div class="contentContainer"> <ul class="inheritance"> <li>java.lang.Object</li> <li> <ul class="inheritance"> <li>eshop.entity.Item</li> </ul> </li> </ul> <div class="description"> <ul class="blockList"> <li class="blockList"> <hr> <br> <pre>public class <span class="typeNameLabel">Item</span> extends java.lang.Object</pre> <div class="block">Item class models a stock item in eShop program. Items can be interactively produced using <a href="../../eshop/parser/Parser.html#inputItem--"><code>eshop.parser.Parser#inputItem() factory method</code></a></div> <dl> <dt><span class="simpleTagLabel">Since:</span></dt> <dd>0.1</dd> <dt><span class="simpleTagLabel">Version:</span></dt> <dd>0.1</dd> <dt><span class="simpleTagLabel">Author:</span></dt> <dd>Trayan Iliev, http://iproduct.org</dd> <dt><span class="seeLabel">See Also:</span></dt> <dd><a href="../../eshop/parser/Parser.html" title="class in eshop.parser"><code>Parser</code></a></dd> </dl> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="constructor.summary"> </a> <h3>Constructor Summary</h3> <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Constructor and Description</th> </tr> <tr class="altColor"> <td class="colOne"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#Item--">Item</a></span>()</code> <div class="block">No argument constructor</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#Item-long-java.lang.String-java.lang.String-">Item</a></span>(long&nbsp;id, java.lang.String&nbsp;name, java.lang.String&nbsp;manufacturer)</code> <div class="block">Constructor with mandatory arguments</div> </td> </tr> <tr class="altColor"> <td class="colOne"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#Item-long-java.lang.String-java.lang.String-java.lang.String-java.lang.String-double-int-">Item</a></span>(long&nbsp;id, java.lang.String&nbsp;name, java.lang.String&nbsp;manufacturer, java.lang.String&nbsp;category, java.lang.String&nbsp;description, double&nbsp;price, int&nbsp;stockQuantity)</code> <div class="block">Full constructor</div> </td> </tr> </table> </li> </ul> <ul class="blockList"> <li class="blockList"><a name="method.summary"> </a> <h3>Method Summary</h3> <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr id="i0" class="altColor"> <td class="colFirst"><code>boolean</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#equals-java.lang.Object-">equals</a></span>(java.lang.Object&nbsp;obj)</code>&nbsp;</td> </tr> <tr id="i1" class="rowColor"> <td class="colFirst"><code>java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#getCategory--">getCategory</a></span>()</code> <div class="block">Return item category.</div> </td> </tr> <tr id="i2" class="altColor"> <td class="colFirst"><code>java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#getDescription--">getDescription</a></span>()</code> <div class="block">Return item description</div> </td> </tr> <tr id="i3" class="rowColor"> <td class="colFirst"><code>long</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#getId--">getId</a></span>()</code> <div class="block">Returns item id</div> </td> </tr> <tr id="i4" class="altColor"> <td class="colFirst"><code>java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#getManufacturer--">getManufacturer</a></span>()</code> <div class="block">Return item manufacturer</div> </td> </tr> <tr id="i5" class="rowColor"> <td class="colFirst"><code>java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#getName--">getName</a></span>()</code> <div class="block">Returns item name</div> </td> </tr> <tr id="i6" class="altColor"> <td class="colFirst"><code>double</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#getPrice--">getPrice</a></span>()</code> <div class="block">Return item price in default currency</div> </td> </tr> <tr id="i7" class="rowColor"> <td class="colFirst"><code>int</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#getStockQuantity--">getStockQuantity</a></span>()</code> <div class="block">Returns stock quantity available for the item</div> </td> </tr> <tr id="i8" class="altColor"> <td class="colFirst"><code>int</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#hashCode--">hashCode</a></span>()</code>&nbsp;</td> </tr> <tr id="i9" class="rowColor"> <td class="colFirst"><code>static void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#main-java.lang.String:A-">main</a></span>(java.lang.String[]&nbsp;args)</code>&nbsp;</td> </tr> <tr id="i10" class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#setCategory-java.lang.String-">setCategory</a></span>(java.lang.String&nbsp;category)</code> <div class="block">Sets item category from a predefined list of categories.</div> </td> </tr> <tr id="i11" class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#setDescription-java.lang.String-">setDescription</a></span>(java.lang.String&nbsp;description)</code> <div class="block">Sets item description</div> </td> </tr> <tr id="i12" class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#setId-long-">setId</a></span>(long&nbsp;id)</code> <div class="block">Sets item id</div> </td> </tr> <tr id="i13" class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#<API key>.lang.String-">setManufacturer</a></span>(java.lang.String&nbsp;manufacturer)</code> <div class="block">Sets item manufacturer</div> </td> </tr> <tr id="i14" class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#setName-java.lang.String-">setName</a></span>(java.lang.String&nbsp;name)</code> <div class="block">Sets item name</div> </td> </tr> <tr id="i15" class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#setPrice-double-">setPrice</a></span>(double&nbsp;price)</code> <div class="block">Sets item price in default currency</div> </td> </tr> <tr id="i16" class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#<API key>-">setStockQuantity</a></span>(int&nbsp;stockQuantity)</code> <div class="block">Modifies the stock quantity available for the item</div> </td> </tr> <tr id="i17" class="rowColor"> <td class="colFirst"><code>java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../eshop/entity/Item.html#toString--">toString</a></span>()</code>&nbsp;</td> </tr> </table> <ul class="blockList"> <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> </a> <h3>Methods inherited from class&nbsp;java.lang.Object</h3> <code>getClass, notify, notifyAll, wait, wait, wait</code></li> </ul> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="constructor.detail"> </a> <h3>Constructor Detail</h3> <a name="Item </a> <ul class="blockList"> <li class="blockList"> <h4>Item</h4> <pre>public&nbsp;Item()</pre> <div class="block">No argument constructor</div> </li> </ul> <a name="Item-long-java.lang.String-java.lang.String-"> </a> <ul class="blockList"> <li class="blockList"> <h4>Item</h4> <pre>public&nbsp;Item(long&nbsp;id, java.lang.String&nbsp;name, java.lang.String&nbsp;manufacturer)</pre> <div class="block">Constructor with mandatory arguments</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>id</code> - item it</dd> <dd><code>name</code> - item name</dd> <dd><code>manufacturer</code> - item manufacturer</dd> </dl> </li> </ul> <a name="Item-long-java.lang.String-java.lang.String-java.lang.String-java.lang.String-double-int-"> </a> <ul class="blockListLast"> <li class="blockList"> <h4>Item</h4> <pre>public&nbsp;Item(long&nbsp;id, java.lang.String&nbsp;name, java.lang.String&nbsp;manufacturer, java.lang.String&nbsp;category, java.lang.String&nbsp;description, double&nbsp;price, int&nbsp;stockQuantity)</pre> <div class="block">Full constructor</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>@param</code> - id item it</dd> <dd><code>name</code> - item name</dd> <dd><code>manufacturer</code> - item manufacturer</dd> <dd><code>category</code> - category name from a predefined list of categories</dd> <dd><code>description</code> - optional item description</dd> <dd><code>price</code> - optional standard price for the item</dd> <dd><code>stockQuantity</code> - optional available stock quantity for the item</dd> </dl> </li> </ul> </li> </ul> <ul class="blockList"> <li class="blockList"><a name="method.detail"> </a> <h3>Method Detail</h3> <a name="getId </a> <ul class="blockList"> <li class="blockList"> <h4>getId</h4> <pre>public&nbsp;long&nbsp;getId()</pre> <div class="block">Returns item id</div> <dl> <dt><span class="returnLabel">Returns:</span></dt> <dd>the id</dd> </dl> </li> </ul> <a name="setId-long-"> </a> <ul class="blockList"> <li class="blockList"> <h4>setId</h4> <pre>public&nbsp;void&nbsp;setId(long&nbsp;id)</pre> <div class="block">Sets item id</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>id</code> - the id to set</dd> </dl> </li> </ul> <a name="getName </a> <ul class="blockList"> <li class="blockList"> <h4>getName</h4> <pre>public&nbsp;java.lang.String&nbsp;getName()</pre> <div class="block">Returns item name</div> <dl> <dt><span class="returnLabel">Returns:</span></dt> <dd>the name</dd> </dl> </li> </ul> <a name="setName-java.lang.String-"> </a> <ul class="blockList"> <li class="blockList"> <h4>setName</h4> <pre>public&nbsp;void&nbsp;setName(java.lang.String&nbsp;name)</pre> <div class="block">Sets item name</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>name</code> - the name to set</dd> </dl> </li> </ul> <a name="getManufacturer </a> <ul class="blockList"> <li class="blockList"> <h4>getManufacturer</h4> <pre>public&nbsp;java.lang.String&nbsp;getManufacturer()</pre> <div class="block">Return item manufacturer</div> <dl> <dt><span class="returnLabel">Returns:</span></dt> <dd>the manufacturer</dd> </dl> </li> </ul> <a name="<API key>.lang.String-"> </a> <ul class="blockList"> <li class="blockList"> <h4>setManufacturer</h4> <pre>public&nbsp;void&nbsp;setManufacturer(java.lang.String&nbsp;manufacturer)</pre> <div class="block">Sets item manufacturer</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>manufacturer</code> - the manufacturer to set</dd> </dl> </li> </ul> <a name="getCategory </a> <ul class="blockList"> <li class="blockList"> <h4>getCategory</h4> <pre>public&nbsp;java.lang.String&nbsp;getCategory()</pre> <div class="block">Return item category. See <a href="../../eshop/entity/Item.html#setCategory-java.lang.String-"><code>examples in #setCategory(String)</code></a></div> <dl> <dt><span class="returnLabel">Returns:</span></dt> <dd>the category</dd> </dl> </li> </ul> <a name="setCategory-java.lang.String-"> </a> <ul class="blockList"> <li class="blockList"> <h4>setCategory</h4> <pre>public&nbsp;void&nbsp;setCategory(java.lang.String&nbsp;category)</pre> <div class="block">Sets item category from a predefined list of categories. Example: <ul> <li>Processors</li> <li>Moteherboards</li> <li>Accessories</li> <li>etc.</li> </ul></div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>category</code> - the category to set</dd> </dl> </li> </ul> <a name="getDescription </a> <ul class="blockList"> <li class="blockList"> <h4>getDescription</h4> <pre>public&nbsp;java.lang.String&nbsp;getDescription()</pre> <div class="block">Return item description</div> <dl> <dt><span class="returnLabel">Returns:</span></dt> <dd>the description</dd> </dl> </li> </ul> <a name="setDescription-java.lang.String-"> </a> <ul class="blockList"> <li class="blockList"> <h4>setDescription</h4> <pre>public&nbsp;void&nbsp;setDescription(java.lang.String&nbsp;description)</pre> <div class="block">Sets item description</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>description</code> - the description to set</dd> </dl> </li> </ul> <a name="getPrice </a> <ul class="blockList"> <li class="blockList"> <h4>getPrice</h4> <pre>public&nbsp;double&nbsp;getPrice()</pre> <div class="block">Return item price in default currency</div> <dl> <dt><span class="returnLabel">Returns:</span></dt> <dd>the price</dd> </dl> </li> </ul> <a name="setPrice-double-"> </a> <ul class="blockList"> <li class="blockList"> <h4>setPrice</h4> <pre>public&nbsp;void&nbsp;setPrice(double&nbsp;price)</pre> <div class="block">Sets item price in default currency</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>price</code> - the price to set</dd> </dl> </li> </ul> <a name="getStockQuantity </a> <ul class="blockList"> <li class="blockList"> <h4>getStockQuantity</h4> <pre>public&nbsp;int&nbsp;getStockQuantity()</pre> <div class="block">Returns stock quantity available for the item</div> <dl> <dt><span class="returnLabel">Returns:</span></dt> <dd>the stockQuantity</dd> </dl> </li> </ul> <a name="<API key>-"> </a> <ul class="blockList"> <li class="blockList"> <h4>setStockQuantity</h4> <pre>public&nbsp;void&nbsp;setStockQuantity(int&nbsp;stockQuantity)</pre> <div class="block">Modifies the stock quantity available for the item</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>stockQuantity</code> - the stockQuantity to set</dd> </dl> </li> </ul> <a name="hashCode </a> <ul class="blockList"> <li class="blockList"> <h4>hashCode</h4> <pre>public&nbsp;int&nbsp;hashCode()</pre> <dl> <dt><span class="<API key>">Overrides:</span></dt> <dd><code>hashCode</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd> </dl> </li> </ul> <a name="equals-java.lang.Object-"> </a> <ul class="blockList"> <li class="blockList"> <h4>equals</h4> <pre>public&nbsp;boolean&nbsp;equals(java.lang.Object&nbsp;obj)</pre> <dl> <dt><span class="<API key>">Overrides:</span></dt> <dd><code>equals</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd> </dl> </li> </ul> <a name="toString </a> <ul class="blockList"> <li class="blockList"> <h4>toString</h4> <pre>public&nbsp;java.lang.String&nbsp;toString()</pre> <dl> <dt><span class="<API key>">Overrides:</span></dt> <dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd> </dl> </li> </ul> <a name="main-java.lang.String:A-"> </a> <ul class="blockListLast"> <li class="blockList"> <h4>main</h4> <pre>public static&nbsp;void&nbsp;main(java.lang.String[]&nbsp;args)</pre> </li> </ul> </li> </ul> </li> </ul> </div> </div> <div class="bottomNav"><a name="navbar.bottom"> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> </a> <ul class="navList" title="Navigation"> <li><a href="../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/Item.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../deprecated-list.html">Deprecated</a></li> <li><a href="../../index-files/index-1.html">Index</a></li> <li><a href="../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev&nbsp;Class</li> <li>Next&nbsp;Class</li> </ul> <ul class="navList"> <li><a href="../../index.html?eshop/entity/Item.html" target="_top">Frames</a></li> <li><a href="Item.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method.summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method.detail">Method</a></li> </ul> </div> <a name="skip.navbar.bottom"> </a></div> </body> </html>
<!DOCTYPE html> <html> <head> <title>Asterisk Project : Asterisk 12 <API key></title> <link rel="stylesheet" href="styles/site.css" type="text/css" /> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body class="theme-default aui-theme-default"> <div id="page"> <div id="main" class="aui-page-panel"> <div id="main-header"> <div id="breadcrumb-section"> <ol id="breadcrumbs"> <li class="first"> <span><a href="index.html">Asterisk Project</a></span> </li> <li> <span><a href="<API key>.html">Asterisk 12 Documentation</a></span> </li> <li> <span><a href="<API key>.html">Asterisk 12 Command Reference</a></span> </li> <li> <span><a href="<API key>.html">Asterisk 12 AMI Events</a></span> </li> </ol> </div> <h1 id="title-heading" class="pagetitle"> <span id="title-text"> Asterisk Project : Asterisk 12 <API key> </span> </h1> </div> <div id="content" class="view"> <div class="page-metadata"> Added by wikibot , edited by wikibot on Dec 18, 2013 </div> <div id="main-content" class="wiki-content group"> <h1 id="<API key>">ConfbridgeEnd</h1> <h3 id="<API key>">Synopsis</h3> <p>Raised when a conference ends.</p> <h3 id="<API key>">Description</h3> <h3 id="<API key>">Syntax</h3> <div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent"> <pre>Action: Conference: &lt;value&gt; BridgeUniqueid: &lt;value&gt; BridgeType: &lt;value&gt; BridgeTechnology: &lt;value&gt; BridgeCreator: &lt;value&gt; BridgeName: &lt;value&gt; BridgeNumChannels: &lt;value&gt; </pre> </div></div> <h5 id="<API key>">Arguments</h5> <ul> <li><code>Conference</code> - The name of the Confbridge conference.</li> <li><code>BridgeUniqueid</code></li> <li><code>BridgeType</code> - The type of bridge</li> <li><code>BridgeTechnology</code> - Technology in use by the bridge</li> <li><code>BridgeCreator</code> - Entity that created the bridge if applicable</li> <li><code>BridgeName</code> - Name used to refer to the bridge by its BridgeCreator if applicable</li> <li><code>BridgeNumChannels</code> - Number of channels in the bridge</li> </ul> <h3 id="<API key>">See Also</h3> <ul> <li><a href="<API key>.html">Asterisk 12 <API key></a></li> <li><a href="<API key>.html">Asterisk 12 <API key></a></li> </ul> <h3 id="<API key>">Import Version</h3> <p>This documentation was imported from Asterisk Version <API key></p> </div> </div> </div> <div id="footer"> <section class="footer-body"> <p>Document generated by Confluence on Dec 20, 2013 14:14</p> </section> </div> </div> </body> </html>