answer
stringlengths
15
1.25M
#include <map> #include <string> #include "base/memory/scoped_ptr.h" #include "chrome/renderer/extensions/<API key>.h" #include "extensions/common/message_bundle.h" #include "ipc/ipc_sender.h" #include "ipc/ipc_sync_message.h" #include "net/base/net_errors.h" #include "net/url_request/redirect_info.h" #include "net/url_request/url_request_status.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using testing::_; using testing::DoAll; using testing::Invoke; using testing::StrEq; using testing::Return; static const char* const kExtensionUrl_1 = "chrome-extension://some_id/popup.css"; static const char* const kExtensionUrl_2 = "chrome-extension://some_id2/popup.css"; static const char* const kExtensionUrl_3 = "chrome-extension://some_id3/popup.css"; void MessageDeleter(IPC::Message* message) { delete message; } class <API key> : public IPC::Sender { public: <API key>() { ON_CALL(*this, Send(_)) .WillByDefault(DoAll(Invoke(MessageDeleter), Return(true))); } virtual ~<API key>() {} MOCK_METHOD1(Send, bool(IPC::Message* message)); private: <API key>(<API key>); }; class MockRequestPeer : public content::RequestPeer { public: MockRequestPeer() {} virtual ~MockRequestPeer() {} MOCK_METHOD2(OnUploadProgress, void(uint64 position, uint64 size)); MOCK_METHOD2(OnReceivedRedirect, bool(const net::RedirectInfo& redirect_info, const content::<API key>& info)); MOCK_METHOD1(OnReceivedResponse, void(const content::<API key>& info)); MOCK_METHOD2(OnDownloadedData, void(int len, int encoded_data_length)); MOCK_METHOD3(OnReceivedData, void(const char* data, int data_length, int encoded_data_length)); MOCK_METHOD6(OnCompletedRequest, void( int error_code, bool <API key>, bool stale_copy_in_cache, const std::string& security_info, const base::TimeTicks& completion_time, int64_t total_transfer_size)); private: <API key>(MockRequestPeer); }; class <API key> : public testing::Test { protected: void SetUp() override { sender_.reset(new <API key>()); original_peer_.reset(new MockRequestPeer()); filter_peer_.reset( <API key>::<API key>( original_peer_.get(), sender_.get(), "text/css", GURL(kExtensionUrl_1))); } <API key>* <API key>( const std::string& mime_type, const GURL& request_url) { return <API key>::<API key>( original_peer_.get(), sender_.get(), mime_type, request_url); } std::string GetData(<API key>* filter_peer) { EXPECT_TRUE(NULL != filter_peer); return filter_peer->data_; } void SetData(<API key>* filter_peer, const std::string& data) { EXPECT_TRUE(NULL != filter_peer); filter_peer->data_ = data; } scoped_ptr<<API key>> sender_; scoped_ptr<MockRequestPeer> original_peer_; scoped_ptr<<API key>> filter_peer_; }; TEST_F(<API key>, <API key>) { filter_peer_.reset( <API key>("text/html", GURL(kExtensionUrl_1))); EXPECT_TRUE(NULL == filter_peer_.get()); } TEST_F(<API key>, <API key>) { EXPECT_TRUE(NULL != filter_peer_.get()); } TEST_F(<API key>, OnReceivedData) { EXPECT_TRUE(GetData(filter_peer_.get()).empty()); const std::string data_chunk("12345"); filter_peer_->OnReceivedData(data_chunk.c_str(), data_chunk.length(), -1); EXPECT_EQ(data_chunk, GetData(filter_peer_.get())); filter_peer_->OnReceivedData(data_chunk.c_str(), data_chunk.length(), -1); EXPECT_EQ(data_chunk + data_chunk, GetData(filter_peer_.get())); } MATCHER_P(IsURLRequestEqual, status, "") { return arg.status() == status; } TEST_F(<API key>, <API key>) { // It will self-delete once it exits OnCompletedRequest. <API key>* filter_peer = filter_peer_.release(); EXPECT_CALL(*original_peer_, OnReceivedResponse(_)); EXPECT_CALL(*original_peer_, OnCompletedRequest( net::ERR_ABORTED, false, false, "", base::TimeTicks(), -1)); filter_peer->OnCompletedRequest( net::ERR_FAILED, false, false, std::string(), base::TimeTicks(), -1); } TEST_F(<API key>, <API key>) { // It will self-delete once it exits OnCompletedRequest. <API key>* filter_peer = filter_peer_.release(); EXPECT_CALL(*original_peer_, OnReceivedData(_, _, _)).Times(0); EXPECT_CALL(*sender_, Send(_)).Times(0); EXPECT_CALL(*original_peer_, OnReceivedResponse(_)); EXPECT_CALL(*original_peer_, OnCompletedRequest( net::OK, false, false, "", base::TimeTicks(), -1)); filter_peer->OnCompletedRequest( net::OK, false, false, std::string(), base::TimeTicks(), -1); } TEST_F(<API key>, <API key>) { // It will self-delete once it exits OnCompletedRequest. <API key>* filter_peer = filter_peer_.release(); SetData(filter_peer, "some text"); EXPECT_CALL(*sender_, Send(_)); std::string data = GetData(filter_peer); EXPECT_CALL(*original_peer_, OnReceivedData(StrEq(data.data()), data.length(), -1)).Times(2); EXPECT_CALL(*original_peer_, OnReceivedResponse(_)).Times(2); EXPECT_CALL(*original_peer_, OnCompletedRequest( net::OK, false, false, "", base::TimeTicks(), -1)).Times(2); filter_peer->OnCompletedRequest( net::OK, false, false, std::string(), base::TimeTicks(), -1); // Test if Send gets called again (it shouldn't be) when first call returned // an empty dictionary. filter_peer = <API key>("text/css", GURL(kExtensionUrl_1)); SetData(filter_peer, "some text"); filter_peer->OnCompletedRequest( net::OK, false, false, std::string(), base::TimeTicks(), -1); } TEST_F(<API key>, <API key>) { // It will self-delete once it exits OnCompletedRequest. <API key>* filter_peer = <API key>("text/css", GURL(kExtensionUrl_2)); extensions::L10nMessagesMap messages; messages.insert(std::make_pair("text", "new text")); extensions::<API key>& l10n_messages_map = *extensions::<API key>(); l10n_messages_map["some_id2"] = messages; SetData(filter_peer, "some __MSG_text__"); // We already have messages in memory, Send will be skipped. EXPECT_CALL(*sender_, Send(_)).Times(0); // __MSG_text__ gets replaced with "new text". std::string data("some new text"); EXPECT_CALL(*original_peer_, OnReceivedData(StrEq(data.data()), data.length(), -1)); EXPECT_CALL(*original_peer_, OnReceivedResponse(_)); EXPECT_CALL(*original_peer_, OnCompletedRequest( net::OK, false, false, "", base::TimeTicks(), -1)); filter_peer->OnCompletedRequest( net::OK, false, false, std::string(), base::TimeTicks(), -1); } TEST_F(<API key>, <API key>) { // It will self-delete once it exits OnCompletedRequest. <API key>* filter_peer = <API key>("text/css", GURL(kExtensionUrl_3)); extensions::L10nMessagesMap messages; messages.insert(std::make_pair("text", "new text")); extensions::<API key>& l10n_messages_map = *extensions::<API key>(); l10n_messages_map["some_id3"] = messages; std::string message("some <API key>"); SetData(filter_peer, message); // We already have messages in memory, Send will be skipped. EXPECT_CALL(*sender_, Send(_)).Times(0); // <API key> is missing, so message stays the same. EXPECT_CALL(*original_peer_, OnReceivedData(StrEq(message.data()), message.length(), -1)); EXPECT_CALL(*original_peer_, OnReceivedResponse(_)); EXPECT_CALL(*original_peer_, OnCompletedRequest( net::OK, false, false, "", base::TimeTicks(), -1)); filter_peer->OnCompletedRequest( net::OK, false, false, std::string(), base::TimeTicks(), -1); }
#ifndef <API key> #define <API key> #include <map> #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "ipc/ipc_message.h" #include "ipc/ipc_sender.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/connection.h" #include "ppapi/proxy/<API key>.h" #include "ppapi/proxy/ppapi_message_utils.h" #include "ppapi/proxy/ppapi_proxy_export.h" #include "ppapi/proxy/<API key>.h" #include "ppapi/proxy/<API key>.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/tracked_callback.h" namespace ppapi { namespace proxy { class PluginDispatcher; class PPAPI_PROXY_EXPORT PluginResource : public Resource { public: enum Destination { RENDERER = 0, BROWSER = 1 }; PluginResource(Connection connection, PP_Instance instance); ~PluginResource() override; // Returns true if we've previously sent a create message to the browser // or renderer. Generally resources will use these to tell if they should // lazily send create messages. bool <API key>() const { return <API key>; } bool <API key>() const { return <API key>; } // This handles a reply to a resource call. It works by looking up the // callback that was registered when CallBrowser/CallRenderer was called // and calling it with |params| and |msg|. void OnReplyReceived(const proxy::<API key>& params, const IPC::Message& msg) override; // Resource overrides. // Note: Subclasses shouldn't override these methods directly. Instead, they // should implement <API key>() or InstanceWasDeleted() to get // notified. void <API key>() override; void <API key>() override; // Sends a create message to the browser or renderer for the current resource. void SendCreate(Destination dest, const IPC::Message& msg); // When the host returnes a resource to the plugin, it will create a pending // ResourceHost and send an ID back to the plugin that identifies the pending // object. The plugin uses this function to connect the plugin resource with // the pending host resource. See also <API key>. This // is in lieu of sending a create message. void AttachToPendingHost(Destination dest, int pending_host_id); // Sends the given IPC message as a resource request to the host // corresponding to this resource object and does not expect a reply. void Post(Destination dest, const IPC::Message& msg); // Like Post() but expects a response. |callback| is a |base::Callback| that // will be run when a reply message with a sequence number matching that of // the call is received. |ReplyMsgClass| is the type of the reply message that // is expected. An example of usage: // Call<<API key>>( // BROWSER, // <API key>(), // base::Bind(&MyPluginResource::ReplyHandler, base::Unretained(this))); // If a reply message to this call is received whose type does not match // |ReplyMsgClass| (for example, in the case of an error), the callback will // still be invoked but with the default values of the message parameters. // Returns the new request's sequence number which can be used to identify // the callback. This value will never be 0, which you can use to identify // an invalid callback. // Note: 1) When all plugin references to this resource are gone or the // corresponding plugin instance is deleted, all pending callbacks // are abandoned. // 2) It is *not* recommended to let |callback| hold any reference to // |this|, in which it will be stored. Otherwise, this object will // live forever if we fail to clean up the callback. It is safe to // use base::Unretained(this) or a weak pointer, because this object // will outlive the callback. template<typename ReplyMsgClass, typename CallbackType> int32_t Call(Destination dest, const IPC::Message& msg, const CallbackType& callback); // Comparing with the previous Call() method, this method takes // |reply_thread_hint| as a hint to determine which thread to handle the reply // message. // If |reply_thread_hint| is non-blocking, the reply message will be handled // on the target thread of the callback; otherwise, it will be handled on the // main thread. // If handling a reply message will cause a TrackedCallback to be run, it is // recommended to use this version of Call(). It eliminates unnecessary // thread switching and therefore has better performance. template<typename ReplyMsgClass, typename CallbackType> int32_t Call(Destination dest, const IPC::Message& msg, const CallbackType& callback, scoped_refptr<TrackedCallback> reply_thread_hint); // Calls the browser/renderer with sync messages. Returns the pepper error // code from the call. // |ReplyMsgClass| is the type of the reply message that is expected. If it // carries x parameters, then the method with x out parameters should be used. // An example of usage: // // Assuming the reply message carries a string and an integer. // std::string param_1; // int param_2 = 0; // int32_t result = SyncCall<<API key>>( // RENDERER, <API key>(), // &param_1, &param_2); template <class ReplyMsgClass> int32_t SyncCall(Destination dest, const IPC::Message& msg); template <class ReplyMsgClass, class A> int32_t SyncCall(Destination dest, const IPC::Message& msg, A* a); template <class ReplyMsgClass, class A, class B> int32_t SyncCall(Destination dest, const IPC::Message& msg, A* a, B* b); template <class ReplyMsgClass, class A, class B, class C> int32_t SyncCall(Destination dest, const IPC::Message& msg, A* a, B* b, C* c); template <class ReplyMsgClass, class A, class B, class C, class D> int32_t SyncCall( Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d); template <class ReplyMsgClass, class A, class B, class C, class D, class E> int32_t SyncCall( Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e); int32_t GenericSyncCall(Destination dest, const IPC::Message& msg, IPC::Message* reply_msg, <API key>* reply_params); const Connection& connection() { return connection_; } private: IPC::Sender* GetSender(Destination dest) { return dest == RENDERER ? connection_.renderer_sender : connection_.browser_sender; } // Helper function to send a |<API key>| to the given // destination with |nested_msg| and |call_params|. bool SendResourceCall(Destination dest, const <API key>& call_params, const IPC::Message& nested_msg); int32_t GetNextSequence(); Connection connection_; // Use GetNextSequence to retrieve the next value. int32_t <API key>; bool <API key>; bool <API key>; typedef std::map<int32_t, scoped_refptr<<API key>> > CallbackMap; CallbackMap callbacks_; scoped_refptr<<API key>> <API key>; <API key>(PluginResource); }; template<typename ReplyMsgClass, typename CallbackType> int32_t PluginResource::Call(Destination dest, const IPC::Message& msg, const CallbackType& callback) { return Call<ReplyMsgClass>(dest, msg, callback, NULL); } template<typename ReplyMsgClass, typename CallbackType> int32_t PluginResource::Call( Destination dest, const IPC::Message& msg, const CallbackType& callback, scoped_refptr<TrackedCallback> reply_thread_hint) { TRACE_EVENT2("ppapi proxy", "PluginResource::Call", "Class", <API key>(msg.type()), "Line", IPC_MESSAGE_ID_LINE(msg.type())); <API key> params(pp_resource(), <API key>++); // Stash the |callback| in |callbacks_| identified by the sequence number of // the call. scoped_refptr<<API key>> plugin_callback( new <API key><ReplyMsgClass, CallbackType>(callback)); callbacks_.insert(std::make_pair(params.sequence(), plugin_callback)); params.set_has_callback(); if (<API key>.get()) { <API key>->Register( pp_resource(), params.sequence(), reply_thread_hint); } SendResourceCall(dest, params, msg); return params.sequence(); } template <class ReplyMsgClass> int32_t PluginResource::SyncCall(Destination dest, const IPC::Message& msg) { IPC::Message reply; <API key> reply_params; return GenericSyncCall(dest, msg, &reply, &reply_params); } template <class ReplyMsgClass, class A> int32_t PluginResource::SyncCall( Destination dest, const IPC::Message& msg, A* a) { IPC::Message reply; <API key> reply_params; int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); if (UnpackMessage<ReplyMsgClass>(reply, a)) return result; return PP_ERROR_FAILED; } template <class ReplyMsgClass, class A, class B> int32_t PluginResource::SyncCall( Destination dest, const IPC::Message& msg, A* a, B* b) { IPC::Message reply; <API key> reply_params; int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); if (UnpackMessage<ReplyMsgClass>(reply, a, b)) return result; return PP_ERROR_FAILED; } template <class ReplyMsgClass, class A, class B, class C> int32_t PluginResource::SyncCall( Destination dest, const IPC::Message& msg, A* a, B* b, C* c) { IPC::Message reply; <API key> reply_params; int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); if (UnpackMessage<ReplyMsgClass>(reply, a, b, c)) return result; return PP_ERROR_FAILED; } template <class ReplyMsgClass, class A, class B, class C, class D> int32_t PluginResource::SyncCall( Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d) { IPC::Message reply; <API key> reply_params; int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); if (UnpackMessage<ReplyMsgClass>(reply, a, b, c, d)) return result; return PP_ERROR_FAILED; } template <class ReplyMsgClass, class A, class B, class C, class D, class E> int32_t PluginResource::SyncCall( Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e) { IPC::Message reply; <API key> reply_params; int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); if (UnpackMessage<ReplyMsgClass>(reply, a, b, c, d, e)) return result; return PP_ERROR_FAILED; } } // namespace proxy } // namespace ppapi #endif // <API key>
#include "CppUTest/TestHarness.h" #include <e32def.h> #include <e32std.h> #include <sys/time.h> #include <stdio.h> #include <stdarg.h> #include <string.h> #include <math.h> #include <stdlib.h> #include "CppUTest/<API key>.h" static jmp_buf test_exit_jmp_buf[10]; static int jmp_buf_index = 0; int <API key>(void (*function) (void* data), void* data) { if (0 == setjmp(test_exit_jmp_buf[jmp_buf_index])) { jmp_buf_index++; function(data); jmp_buf_index return 1; } return 0; } void <API key>() { jmp_buf_index longjmp(test_exit_jmp_buf[jmp_buf_index], 1); } void <API key>() { jmp_buf_index } void <API key>(UtestShell* shell, TestPlugin* plugin, TestResult* result) { printf("-p doesn't work on this platform as it is not implemented. Running inside the process\b"); shell->runOneTest(plugin, *result); } static long <API key>() { struct timeval tv; struct timezone tz; ::gettimeofday(&tv, &tz); return (tv.tv_sec * 1000) + (long)(tv.tv_usec * 0.001); } long (*<API key>)() = <API key>; TestOutput::WorkingEnvironment <API key>() { return TestOutput::eclipse; } static SimpleString <API key>() { time_t tm = time(NULL); return ctime(&tm); } SimpleString <API key>() = <API key>; int <API key>(char* str, size_t size, const char* format, va_list args) { return vsnprintf(str, size, format, args); } void <API key>() { fflush(stdout); } int <API key>(int c) { return putchar(c); } double <API key>(double d) { return fabs(d); } void* <API key>(size_t size) { return malloc(size); } void* <API key> (void* memory, size_t size) { return realloc(memory, size); } void <API key>(void* memory) { free(memory); } void* <API key>(void* s1, const void* s2, size_t size) { return memcpy(s1, s2, size); } void* <API key>(void* mem, int c, size_t size) { return memset(mem, c, size); } <API key> <API key>(const char* filename, const char* flag) { return fopen(filename, flag); } void <API key>(const char* str, <API key> file) { fputs(str, (FILE*)file); } void <API key>(<API key> file) { fclose((FILE*)file); } extern "C" { static int IsNanImplementation(double d) { return isnan(d); } static int IsInfImplementation(double d) { return isinf(d); } int (*<API key>)(double) = IsNanImplementation; int (*<API key>)(double) = IsInfImplementation; } static <API key> DummyMutexCreate(void) { FAIL("<API key> is not implemented"); return 0; } static void DummyMutexLock(<API key> mtx) { FAIL("<API key> is not implemented"); } static void DummyMutexUnlock(<API key> mtx) { FAIL("<API key> is not implemented"); } static void DummyMutexDestroy(<API key> mtx) { FAIL("<API key> is not implemented"); } <API key> (*<API key>)(void) = DummyMutexCreate; void (*<API key>)(<API key>) = DummyMutexLock; void (*<API key>)(<API key>) = DummyMutexUnlock; void (*<API key>)(<API key>) = DummyMutexDestroy;
(function (H) { var seriesTypes = H.seriesTypes, chartPrototype = H.Chart.prototype, defaultOptions = H.getOptions(), extend = H.extend, each = H.each; // Add language option extend(defaultOptions.lang, { noData: 'No data to display' }); // Add default display options for message defaultOptions.noData = { position: { x: 0, y: 0, align: 'center', verticalAlign: 'middle' }, attr: { }, style: { fontWeight: 'bold', fontSize: '12px', color: '#60606a' } }; /** * Define hasData functions for series. These return true if there are data points on this series within the plot area */ function hasDataPie() { return !!this.points.length; } each(['pie', 'gauge', 'waterfall', 'bubble'], function (type) { if (seriesTypes[type]) { seriesTypes[type].prototype.hasData = hasDataPie; } }); H.Series.prototype.hasData = function () { return this.visible && this.dataMax !== undefined && this.dataMin !== undefined; // #3703 }; /** * Display a no-data message. * * @param {String} str An optional message to show in place of the default one */ chartPrototype.showNoData = function (str) { var chart = this, options = chart.options, text = str || options.lang.noData, noDataOptions = options.noData; if (!chart.noDataLabel) { chart.noDataLabel = chart.renderer.label(text, 0, 0, null, null, null, null, null, 'no-data') .attr(noDataOptions.attr) .css(noDataOptions.style) .add(); chart.noDataLabel.align(extend(chart.noDataLabel.getBBox(), noDataOptions.position), false, 'plotBox'); } }; /** * Hide no-data message */ chartPrototype.hideNoData = function () { var chart = this; if (chart.noDataLabel) { chart.noDataLabel = chart.noDataLabel.destroy(); } }; /** * Returns true if there are data points within the plot area now */ chartPrototype.hasData = function () { var chart = this, series = chart.series, i = series.length; while (i if (series[i].hasData() && !series[i].options.isInternal) { return true; } } return false; }; /** * Show no-data message if there is no data in sight. Otherwise, hide it. */ function handleNoData() { var chart = this; if (chart.hasData()) { chart.hideNoData(); } else { chart.showNoData(); } } /** * Add event listener to handle automatic display of no-data message */ chartPrototype.callbacks.push(function (chart) { H.addEvent(chart, 'load', handleNoData); H.addEvent(chart, 'redraw', handleNoData); }); }(Highcharts));
<?php namespace Sylius\Behat\Page\Admin\ExchangeRate; use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface as <API key>; interface UpdatePageInterface extends <API key> { /** * @return string */ public function getRatio(); /** * @param string $ratio */ public function changeRatio($ratio); /** * @return bool */ public function <API key>(); /** * @return bool */ public function <API key>(); }
(function ($) { $.Redactor.opts.langs['el'] = { html: 'HTML', video: 'Εισαγωγή βίντεο...', image: 'Εισαγωγή εικόνας...', table: 'Πίνακας', link: 'Σύνδεσμος', link_insert: 'Εισαγωγή συνδέσμου...', link_edit: 'Edit link', unlink: 'Ακύρωση συνδέσμου', formatting: 'Μορφοποίηση', paragraph: 'Παράγραφος', quote: 'Παράθεση', code: 'Κώδικας', header1: 'Κεφαλίδα 1', header2: 'Κεφαλίδα 2', header3: 'Κεφαλίδα 3', header4: 'Κεφαλίδα 4', bold: 'Έντονα', italic: 'Πλάγια', fontcolor: 'Χρώμα γραμματοσειράς', backcolor: 'Χρώμα επισήμανσης κειμένου', unorderedlist: 'Κουκκίδες', orderedlist: 'Αρίθμηση', outdent: 'Μείωση εσοχής', indent: 'Αύξηση εσοχής', cancel: 'Ακύρωση', insert: 'Εισαγωγή', save: 'Αποθήκευση', _delete: 'Διαγραφή', insert_table: 'Εισαγωγή πίνακα...', insert_row_above: 'Προσθήκη σειράς επάνω', insert_row_below: 'Προσθήκη σειράς κάτω', insert_column_left: 'Προσθήκη στήλης αριστερά', insert_column_right: 'Προσθήκη στήλης δεξιά', delete_column: 'Διαγραφή στήλης', delete_row: 'Διαγραφή σειράς', delete_table: 'Διαγραφή πίνακα', rows: 'Γραμμές', columns: 'Στήλες', add_head: 'Προσθήκη κεφαλίδας', delete_head: 'Διαγραφή κεφαλίδας', title: 'Τίτλος', image_position: 'Θέση', none: 'Καμία', left: 'Αριστερά', right: 'Δεξιά', image_web_link: 'Υπερσύνδεσμος εικόνας', text: 'Κείμενο', mailto: 'Email', web: 'URL', video_html_code: 'Video Embed Code', file: 'Εισαγωγή αρχείου...', upload: 'Upload', download: 'Download', choose: 'Επέλεξε', or_choose: 'ή επέλεξε', drop_file_here: 'Σύρατε αρχεία εδώ', align_left: 'Στοίχιση αριστερά', align_center: 'Στοίχιση στο κέντρο', align_right: 'Στοίχιση δεξιά', align_justify: 'Πλήρησ στοίχηση', horizontalrule: 'Εισαγωγή οριζόντιας γραμμής', deleted: 'Διαγράφτηκε', anchor: 'Anchor', link_new_tab: 'Open link in new tab', underline: 'Underline', alignment: 'Alignment', filename: 'Name (optional)', edit: 'Edit' }; })( jQuery );
import Ember from 'ember-metal/core'; import { get } from 'ember-metal/property_get'; import { internal } from 'htmlbars-runtime'; import { read } from 'ember-metal/streams/utils'; export default { setupState(state, env, scope, params, hash) { var controller = hash.controller; if (controller) { if (!state.controller) { var context = params[0]; var controllerFactory = env.container.lookupFactory('controller:' + controller); var parentController = null; if (scope.locals.controller) { parentController = read(scope.locals.controller); } else if (scope.locals.view) { parentController = get(read(scope.locals.view), 'context'); } var controllerInstance = controllerFactory.create({ model: env.hooks.getValue(context), parentController: parentController, target: parentController }); params[0] = controllerInstance; return { controller: controllerInstance }; } return state; } return { controller: null }; }, isStable() { return true; }, isEmpty(state) { return false; }, render(morph, env, scope, params, hash, template, inverse, visitor) { if (morph.state.controller) { morph.addDestruction(morph.state.controller); hash.controller = morph.state.controller; } Ember.assert( '{{#with foo}} must be called with a single argument or the use the ' + '{{#with foo as |bar|}} syntax', params.length === 1 ); Ember.assert( 'The {{#with}} helper must be called with a block', !!template ); internal.continueBlock(morph, env, scope, 'with', params, hash, template, inverse, visitor); }, rerender(morph, env, scope, params, hash, template, inverse, visitor) { internal.continueBlock(morph, env, scope, 'with', params, hash, template, inverse, visitor); } };
package org.mockito.asm.util; import org.mockito.asm.AnnotationVisitor; import org.mockito.asm.Attribute; import org.mockito.asm.FieldVisitor; /** * A {@link FieldVisitor} that checks that its methods are properly used. */ public class CheckFieldAdapter implements FieldVisitor { private final FieldVisitor fv; private boolean end; public CheckFieldAdapter(final FieldVisitor fv) { this.fv = fv; } public AnnotationVisitor visitAnnotation( final String desc, final boolean visible) { checkEnd(); CheckMethodAdapter.checkDesc(desc, false); return new <API key>(fv.visitAnnotation(desc, visible)); } public void visitAttribute(final Attribute attr) { checkEnd(); if (attr == null) { throw new <API key>("Invalid attribute (must not be null)"); } fv.visitAttribute(attr); } public void visitEnd() { checkEnd(); end = true; fv.visitEnd(); } private void checkEnd() { if (end) { throw new <API key>("Cannot call a visit method after visitEnd has been called"); } } }
using System; using System.Security.Permissions; namespace System.Diagnostics.Eventing.Reader { internal class <API key> { public <API key>() { } public static EventLogPermission <API key>() { EventLogPermission logPermission = new EventLogPermission(); <API key> permEntry = new <API key>(<API key>.Administer, "."); logPermission.PermissionEntries.Add(permEntry); return logPermission; } } }
# GENERATED FROM XML -- DO NOT EDIT URI: index.html.en Content-Language: en Content-type: text/html; charset=ISO-8859-1 URI: index.html.fr Content-Language: fr Content-type: text/html; charset=ISO-8859-1 URI: index.html.ko.euc-kr Content-Language: ko Content-type: text/html; charset=EUC-KR URI: index.html.tr.utf8 Content-Language: tr Content-type: text/html; charset=UTF-8 URI: index.html.zh-cn.utf8 Content-Language: zh-cn Content-type: text/html; charset=UTF-8
#include "../SDL_internal.h" /* Useful functions and variables from SDL_pixel.c */ #include "SDL_blit.h" /* Pixel format functions */ extern int SDL_InitFormat(SDL_PixelFormat * format, Uint32 pixel_format); /* Blit mapping functions */ extern SDL_BlitMap *SDL_AllocBlitMap(void); extern void SDL_InvalidateMap(SDL_BlitMap * map); extern int SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst); extern void SDL_FreeBlitMap(SDL_BlitMap * map); /* Miscellaneous functions */ extern int SDL_CalculatePitch(SDL_Surface * surface); extern void SDL_DitherColors(SDL_Color * colors, int bpp); extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a); /* vi: set ts=4 sw=4 expandtab: */
<md-menu md-offset="40 25"> <div ng-click="$mdOpenMenu($event)" class="<API key>" ng-disabled="<API key>.<API key>() === 0"> <i class="fa fa-bell-o fa-2x <API key>"></i> <div class="<API key>" ng-if="<API key>.<API key>() > 0"> {{<API key>.<API key>()}} </div> </div> <md-menu-content> <md-menu-item layout="column" class="navbar-notification" ng-repeat="notification in <API key>.getNotifications()"> <div class="<API key>-{{notification.type}} <API key>" layout="row" layout-align="start center"> <i ng-if="!notification.icon" ng-class="{'<API key>' : (notification.type === 'warning' || notification.type === 'error'), 'fa-info-circle': notification.type === 'info'}" class="fa fa-2x <API key>"></i> <i ng-if="notification.icon" class="fa {{notification.icon}} fa-2x <API key>"></i> <div>{{notification.title}}</div> </div> <div class="<API key>"> {{notification.content}} </div> </md-menu-item> </md-menu-content> </md-menu>
#ifndef __IA_CSS_ANR_HOST_H #define __IA_CSS_ANR_HOST_H #include "ia_css_anr_types.h" #include "ia_css_anr_param.h" extern const struct ia_css_anr_config default_anr_config; void ia_css_anr_encode( struct <API key> *to, const struct ia_css_anr_config *from); void ia_css_anr_dump( const struct <API key> *anr, unsigned level); void <API key>( const struct ia_css_anr_config *config, unsigned level) ; #endif /* __IA_CSS_ANR_HOST_H */
/** @file script_info_dummy.cpp Implementation of a dummy Script. */ #include "../stdafx.h" #include <squirrel.h> #include "../string_func.h" #include "../strings_func.h" #include "../safeguards.h" /* The reason this exists in C++, is that a user can trash his ai/ or game/ dir, * leaving no Scripts available. The complexity to solve this is insane, and * therefore the alternative is used, and make sure there is always a Script * available, no matter what the situation is. By defining it in C++, there * is simply no way a user can delete it, and therefore safe to use. It has * to be noted that this Script is complete invisible for the user, and impossible * to select manual. It is a fail-over in case no Scripts are available. */ /** Run the dummy info.nut. */ void <API key>(HSQUIRRELVM vm, const char *type, const char *dir) { char dummy_script[4096]; char *dp = dummy_script; dp += seprintf(dp, lastof(dummy_script), "class Dummy%s extends %sInfo {\n", type, type); dp += seprintf(dp, lastof(dummy_script), "function GetAuthor() { return \"OpenTTD Developers Team\"; }\n"); dp += seprintf(dp, lastof(dummy_script), "function GetName() { return \"Dummy%s\"; }\n", type); dp += seprintf(dp, lastof(dummy_script), "function GetShortName() { return \"DUMM\"; }\n"); dp += seprintf(dp, lastof(dummy_script), "function GetDescription() { return \"A Dummy %s that is loaded when your %s/ dir is empty\"; }\n", type, dir); dp += seprintf(dp, lastof(dummy_script), "function GetVersion() { return 1; }\n"); dp += seprintf(dp, lastof(dummy_script), "function GetDate() { return \"2008-07-26\"; }\n"); dp += seprintf(dp, lastof(dummy_script), "function CreateInstance() { return \"Dummy%s\"; }\n", type); dp += seprintf(dp, lastof(dummy_script), "} RegisterDummy%s(Dummy%s());\n", type, type); const SQChar *sq_dummy_script = dummy_script; sq_pushroottable(vm); /* Load and run the script */ if (SQ_SUCCEEDED(sq_compilebuffer(vm, sq_dummy_script, strlen(sq_dummy_script), "dummy", SQTrue))) { sq_push(vm, -2); if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) { sq_pop(vm, 1); return; } } NOT_REACHED(); } /** Run the dummy AI and let it generate an error message. */ void Script_CreateDummy(HSQUIRRELVM vm, StringID string, const char *type) { /* We want to translate the error message. * We do this in three steps: * 1) We get the error message */ char error_message[1024]; GetString(error_message, string, lastof(error_message)); /* Make escapes for all quotes and slashes. */ char safe_error_message[1024]; char *q = safe_error_message; for (const char *p = error_message; *p != '\0' && q < lastof(safe_error_message) - 2; p++, q++) { if (*p == '"' || *p == '\\') *q++ = '\\'; *q = *p; } *q = '\0'; /* 2) We construct the AI's code. This is done by merging a header, body and footer */ char dummy_script[4096]; char *dp = dummy_script; dp += seprintf(dp, lastof(dummy_script), "class Dummy%s extends %sController {\n function Start()\n {\n", type, type); /* As special trick we need to split the error message on newlines and * emit each newline as a separate error printing string. */ char *newline; char *p = safe_error_message; do { newline = strchr(p, '\n'); if (newline != NULL) *newline = '\0'; dp += seprintf(dp, lastof(dummy_script), " %sLog.Error(\"%s\");\n", type, p); p = newline + 1; } while (newline != NULL); dp = strecpy(dp, " }\n}\n", lastof(dummy_script)); /* 3) We translate the error message in the character format that Squirrel wants. * We can use the fact that the wchar string printing also uses %s to print * old style char strings, which is what was generated during the script generation. */ const SQChar *sq_dummy_script = dummy_script; /* And finally we load and run the script */ sq_pushroottable(vm); if (SQ_SUCCEEDED(sq_compilebuffer(vm, sq_dummy_script, strlen(sq_dummy_script), "dummy", SQTrue))) { sq_push(vm, -2); if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) { sq_pop(vm, 1); return; } } NOT_REACHED(); }
#include <common.h> #include <linux/compat.h> #include <asm/io.h> #include <malloc.h> #include <spi.h> #include <asm/arch/clk.h> /* SSP chip registers */ struct ssp_regs { u32 cr0; u32 cr1; u32 data; u32 sr; u32 cpsr; u32 imsc; u32 ris; u32 mis; u32 icr; u32 dmacr; }; /* CR1 register defines */ #define SSP_CR1_SSP_ENABLE 0x0002 /* SR register defines */ #define SSP_SR_TNF 0x0002 /* SSP status RX FIFO not empty bit */ #define SSP_SR_RNE 0x0004 /* lpc32xx spi slave */ struct lpc32xx_spi_slave { struct spi_slave slave; struct ssp_regs *regs; }; static inline struct lpc32xx_spi_slave *<API key>( struct spi_slave *slave) { return container_of(slave, struct lpc32xx_spi_slave, slave); } /* spi_init is called during boot when CONFIG_CMD_SPI is defined */ void spi_init(void) { /* * nothing to do: clocking was enabled in lpc32xx_ssp_enable() * and configuration will be done in spi_setup_slave() */ } /* the following is called in sequence by do_spi_xfer() */ struct spi_slave *spi_setup_slave(uint bus, uint cs, uint max_hz, uint mode) { struct lpc32xx_spi_slave *lslave; /* we only set up SSP0 for now, so ignore bus */ if (mode & SPI_3WIRE) { error("3-wire mode not supported"); return NULL; } if (mode & SPI_SLAVE) { error("slave mode not supported\n"); return NULL; } if (mode & SPI_PREAMBLE) { error("preamble byte skipping not supported\n"); return NULL; } lslave = spi_alloc_slave(struct lpc32xx_spi_slave, bus, cs); if (!lslave) { printf("SPI_error: Fail to allocate lpc32xx_spi_slave\n"); return NULL; } lslave->regs = (struct ssp_regs *)SSP0_BASE; /* * 8 bit frame, SPI fmt, 500kbps -> clock divider is 26. * Set SCR to 0 and CPSDVSR to 26. */ writel(0x7, &lslave->regs->cr0); /* 8-bit chunks, SPI, 1 clk/bit */ writel(26, &lslave->regs->cpsr); /* SSP clock = HCLK/26 = 500kbps */ writel(0, &lslave->regs->imsc); /* do not raise any interrupts */ writel(0, &lslave->regs->icr); /* clear any pending interrupt */ writel(0, &lslave->regs->dmacr); /* do not do DMAs */ writel(SSP_CR1_SSP_ENABLE, &lslave->regs->cr1); /* enable SSP0 */ return &lslave->slave; } void spi_free_slave(struct spi_slave *slave) { struct lpc32xx_spi_slave *lslave = <API key>(slave); debug("(lpc32xx) spi_free_slave: 0x%08x\n", (u32)lslave); free(lslave); } int spi_claim_bus(struct spi_slave *slave) { /* only one bus and slave so far, always available */ return 0; } int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct lpc32xx_spi_slave *lslave = <API key>(slave); int bytelen = bitlen >> 3; int idx_out = 0; int idx_in = 0; int start_time; start_time = get_timer(0); while ((idx_out < bytelen) || (idx_in < bytelen)) { int status = readl(&lslave->regs->sr); if ((idx_out < bytelen) && (status & SSP_SR_TNF)) writel(((u8 *)dout)[idx_out++], &lslave->regs->data); if ((idx_in < bytelen) && (status & status & SSP_SR_RNE)) ((u8 *)din)[idx_in++] = readl(&lslave->regs->data); if (get_timer(start_time) >= <API key>) return -1; } return 0; } void spi_release_bus(struct spi_slave *slave) { /* do nothing */ }
class CfgUnitInsignia { class ACE_insignia_logo { displayName = "ACE3"; author = CSTRING(ACETeam); texture = PATHTOF(data\<API key>.paa); textureVehicle = ""; }; class ACE_insignia_banana { displayName = "ABE3"; author = CSTRING(ACETeam); texture = PATHTOF(data\insignia_banana_ca.paa); textureVehicle = ""; }; };
#include <linux/module.h> #include <linux/delay.h> #include <linux/i2c.h> #include <linux/err.h> #include <linux/interrupt.h> #include <linux/completion.h> #include <linux/platform_device.h> #include <linux/clk.h> #include <asm/io.h> /* timeout waiting for the controller to respond */ #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) #define OMAP_I2C_REV_REG 0x00 #define OMAP_I2C_IE_REG 0x04 #define OMAP_I2C_STAT_REG 0x08 #define OMAP_I2C_IV_REG 0x0c #define OMAP_I2C_SYSS_REG 0x10 #define OMAP_I2C_BUF_REG 0x14 #define OMAP_I2C_CNT_REG 0x18 #define OMAP_I2C_DATA_REG 0x1c #define OMAP_I2C_SYSC_REG 0x20 #define OMAP_I2C_CON_REG 0x24 #define OMAP_I2C_OA_REG 0x28 #define OMAP_I2C_SA_REG 0x2c #define OMAP_I2C_PSC_REG 0x30 #define OMAP_I2C_SCLL_REG 0x34 #define OMAP_I2C_SCLH_REG 0x38 #define <API key> 0x3c /* I2C Interrupt Enable Register (OMAP_I2C_IE): */ #define OMAP_I2C_IE_XRDY (1 << 4) /* TX data ready int enable */ #define OMAP_I2C_IE_RRDY (1 << 3) /* RX data ready int enable */ #define OMAP_I2C_IE_ARDY (1 << 2) /* Access ready int enable */ #define OMAP_I2C_IE_NACK (1 << 1) /* No ack interrupt enable */ #define OMAP_I2C_IE_AL (1 << 0) /* Arbitration lost int ena */ /* I2C Status Register (OMAP_I2C_STAT): */ #define OMAP_I2C_STAT_SBD (1 << 15) /* Single byte data */ #define OMAP_I2C_STAT_BB (1 << 12) /* Bus busy */ #define OMAP_I2C_STAT_ROVR (1 << 11) /* Receive overrun */ #define OMAP_I2C_STAT_XUDF (1 << 10) /* Transmit underflow */ #define OMAP_I2C_STAT_AAS (1 << 9) /* Address as slave */ #define OMAP_I2C_STAT_AD0 (1 << 8) /* Address zero */ #define OMAP_I2C_STAT_XRDY (1 << 4) /* Transmit data ready */ #define OMAP_I2C_STAT_RRDY (1 << 3) /* Receive data ready */ #define OMAP_I2C_STAT_ARDY (1 << 2) /* Register access ready */ #define OMAP_I2C_STAT_NACK (1 << 1) /* No ack interrupt enable */ #define OMAP_I2C_STAT_AL (1 << 0) /* Arbitration lost int ena */ /* I2C Buffer Configuration Register (OMAP_I2C_BUF): */ #define <API key> (1 << 15) /* RX DMA channel enable */ #define <API key> (1 << 7) /* TX DMA channel enable */ /* I2C Configuration Register (OMAP_I2C_CON): */ #define OMAP_I2C_CON_EN (1 << 15) /* I2C module enable */ #define OMAP_I2C_CON_BE (1 << 14) /* Big endian mode */ #define OMAP_I2C_CON_STB (1 << 11) /* Start byte mode (master) */ #define OMAP_I2C_CON_MST (1 << 10) /* Master/slave mode */ #define OMAP_I2C_CON_TRX (1 << 9) /* TX/RX mode (master only) */ #define OMAP_I2C_CON_XA (1 << 8) /* Expand address */ #define OMAP_I2C_CON_RM (1 << 2) /* Repeat mode (master only) */ #define OMAP_I2C_CON_STP (1 << 1) /* Stop cond (master only) */ #define OMAP_I2C_CON_STT (1 << 0) /* Start condition (master) */ /* I2C System Test Register (OMAP_I2C_SYSTEST): */ #ifdef DEBUG #define <API key> (1 << 15) /* System test enable */ #define <API key> (1 << 14) /* Free running mode */ #define <API key> (3 << 12) /* Test mode select */ #define <API key> (12) /* Test mode select */ #define <API key> (1 << 3) /* SCL line sense in */ #define <API key> (1 << 2) /* SCL line drive out */ #define <API key> (1 << 1) /* SDA line sense in */ #define <API key> (1 << 0) /* SDA line drive out */ #endif /* I2C System Status register (OMAP_I2C_SYSS): */ #define OMAP_I2C_SYSS_RDONE (1 << 0) /* Reset Done */ /* I2C System Configuration Register (OMAP_I2C_SYSC): */ #define OMAP_I2C_SYSC_SRST (1 << 1) /* Soft Reset */ /* REVISIT: Use platform_data instead of module parameters */ /* Fast Mode = 400 kHz, Standard = 100 kHz */ static int clock = 100; /* Default: 100 kHz */ module_param(clock, int, 0); MODULE_PARM_DESC(clock, "Set I2C clock in kHz: 400=fast mode (default == 100)"); struct omap_i2c_dev { struct device *dev; void __iomem *base; /* virtual */ int irq; struct clk *iclk; /* Interface clock */ struct clk *fclk; /* Functional clock */ struct completion cmd_complete; struct resource *ioarea; u16 cmd_err; u8 *buf; size_t buf_len; struct i2c_adapter adapter; unsigned rev1:1; }; static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, int reg, u16 val) { __raw_writew(val, i2c_dev->base + reg); } static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) { return __raw_readw(i2c_dev->base + reg); } static int omap_i2c_get_clocks(struct omap_i2c_dev *dev) { if (cpu_is_omap16xx() || cpu_is_omap24xx()) { dev->iclk = clk_get(dev->dev, "i2c_ick"); if (IS_ERR(dev->iclk)) { dev->iclk = NULL; return -ENODEV; } } dev->fclk = clk_get(dev->dev, "i2c_fck"); if (IS_ERR(dev->fclk)) { if (dev->iclk != NULL) { clk_put(dev->iclk); dev->iclk = NULL; } dev->fclk = NULL; return -ENODEV; } return 0; } static void omap_i2c_put_clocks(struct omap_i2c_dev *dev) { clk_put(dev->fclk); dev->fclk = NULL; if (dev->iclk != NULL) { clk_put(dev->iclk); dev->iclk = NULL; } } static void <API key>(struct omap_i2c_dev *dev) { if (dev->iclk != NULL) clk_enable(dev->iclk); clk_enable(dev->fclk); } static void <API key>(struct omap_i2c_dev *dev) { if (dev->iclk != NULL) clk_disable(dev->iclk); clk_disable(dev->fclk); } static int omap_i2c_init(struct omap_i2c_dev *dev) { u16 psc = 0; unsigned long fclk_rate = 12000000; unsigned long timeout; if (!dev->rev1) { omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, OMAP_I2C_SYSC_SRST); /* For some reason we need to set the EN bit before the * reset done bit gets set. */ timeout = jiffies + OMAP_I2C_TIMEOUT; omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) & OMAP_I2C_SYSS_RDONE)) { if (time_after(jiffies, timeout)) { dev_warn(dev->dev, "timeout waiting " "for controller reset\n"); return -ETIMEDOUT; } msleep(1); } } omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); if (cpu_class_is_omap1()) { struct clk *armxor_ck; armxor_ck = clk_get(NULL, "armxor_ck"); if (IS_ERR(armxor_ck)) dev_warn(dev->dev, "Could not get armxor_ck\n"); else { fclk_rate = clk_get_rate(armxor_ck); clk_put(armxor_ck); } /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically * 12, 13 or 19.2 MHz. So we should have code that produces: * * XOR MHz Divider Prescaler * 12 1 0 * 13 2 1 * 19.2 2 1 */ if (fclk_rate > 12000000) psc = fclk_rate / 12000000; } /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */ omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, psc); /* Program desired operating rate */ fclk_rate /= (psc + 1) * 1000; if (psc > 2) psc = 2; omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, fclk_rate / (clock * 2) - 7 + psc); omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, fclk_rate / (clock * 2) - 7 + psc); /* Take the I2C module out of reset: */ omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); /* Enable interrupts */ omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | OMAP_I2C_IE_AL)); return 0; } /* * Waiting on Bus Busy */ static int <API key>(struct omap_i2c_dev *dev) { unsigned long timeout; timeout = jiffies + OMAP_I2C_TIMEOUT; while (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) & OMAP_I2C_STAT_BB) { if (time_after(jiffies, timeout)) { dev_warn(dev->dev, "timeout waiting for bus ready\n"); return -ETIMEDOUT; } msleep(1); } return 0; } /* * Low level master read/write transaction. */ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) { struct omap_i2c_dev *dev = i2c_get_adapdata(adap); int r; u16 w; dev_dbg(dev->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n", msg->addr, msg->len, msg->flags, stop); if (msg->len == 0) return -EINVAL; omap_i2c_write_reg(dev, OMAP_I2C_SA_REG, msg->addr); /* REVISIT: Could the STB bit of I2C_CON be used with probing? */ dev->buf = msg->buf; dev->buf_len = msg->len; omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len); init_completion(&dev->cmd_complete); dev->cmd_err = 0; w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT; if (msg->flags & I2C_M_TEN) w |= OMAP_I2C_CON_XA; if (!(msg->flags & I2C_M_RD)) w |= OMAP_I2C_CON_TRX; if (stop) w |= OMAP_I2C_CON_STP; omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); r = <API key>(&dev->cmd_complete, OMAP_I2C_TIMEOUT); dev->buf_len = 0; if (r < 0) return r; if (r == 0) { dev_err(dev->dev, "controller timed out\n"); omap_i2c_init(dev); return -ETIMEDOUT; } if (likely(!dev->cmd_err)) return 0; /* We have an error */ if (dev->cmd_err & (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR | OMAP_I2C_STAT_XUDF)) { omap_i2c_init(dev); return -EIO; } if (dev->cmd_err & OMAP_I2C_STAT_NACK) { if (msg->flags & I2C_M_IGNORE_NAK) return 0; if (stop) { w = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG); w |= OMAP_I2C_CON_STP; omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); } return -EREMOTEIO; } return -EIO; } /* * Prepare controller for a transaction and call omap_i2c_xfer_msg * to do the work during IRQ processing. */ static int omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) { struct omap_i2c_dev *dev = i2c_get_adapdata(adap); int i; int r; <API key>(dev); /* REVISIT: initialize and use adap->retries. This is an optional * feature */ if ((r = <API key>(dev)) < 0) goto out; for (i = 0; i < num; i++) { r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1))); if (r != 0) break; } if (r == 0) r = num; out: <API key>(dev); return r; } static u32 omap_i2c_func(struct i2c_adapter *adap) { return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~<API key>); } static inline void <API key>(struct omap_i2c_dev *dev, u16 err) { dev->cmd_err |= err; complete(&dev->cmd_complete); } static inline void omap_i2c_ack_stat(struct omap_i2c_dev *dev, u16 stat) { omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); } static irqreturn_t omap_i2c_rev1_isr(int this_irq, void *dev_id) { struct omap_i2c_dev *dev = dev_id; u16 iv, w; iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); switch (iv) { case 0x00: /* None */ break; case 0x01: /* Arbitration lost */ dev_err(dev->dev, "Arbitration lost\n"); <API key>(dev, OMAP_I2C_STAT_AL); break; case 0x02: /* No acknowledgement */ <API key>(dev, OMAP_I2C_STAT_NACK); omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_STP); break; case 0x03: /* Register access ready */ <API key>(dev, 0); break; case 0x04: /* Receive data ready */ if (dev->buf_len) { w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG); *dev->buf++ = w; dev->buf_len if (dev->buf_len) { *dev->buf++ = w >> 8; dev->buf_len } } else dev_err(dev->dev, "RRDY IRQ while no data requested\n"); break; case 0x05: /* Transmit data ready */ if (dev->buf_len) { w = *dev->buf++; dev->buf_len if (dev->buf_len) { w |= *dev->buf++ << 8; dev->buf_len } omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); } else dev_err(dev->dev, "XRDY IRQ while no data to send\n"); break; default: return IRQ_NONE; } return IRQ_HANDLED; } static irqreturn_t omap_i2c_isr(int this_irq, void *dev_id) { struct omap_i2c_dev *dev = dev_id; u16 bits; u16 stat, w; int count = 0; bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) { dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat); if (count++ == 100) { dev_warn(dev->dev, "Too much work in one IRQ\n"); break; } omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); if (stat & OMAP_I2C_STAT_ARDY) { <API key>(dev, 0); continue; } if (stat & OMAP_I2C_STAT_RRDY) { w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG); if (dev->buf_len) { *dev->buf++ = w; dev->buf_len if (dev->buf_len) { *dev->buf++ = w >> 8; dev->buf_len } } else dev_err(dev->dev, "RRDY IRQ while no data " "requested\n"); omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RRDY); continue; } if (stat & OMAP_I2C_STAT_XRDY) { w = 0; if (dev->buf_len) { w = *dev->buf++; dev->buf_len if (dev->buf_len) { w |= *dev->buf++ << 8; dev->buf_len } } else dev_err(dev->dev, "XRDY IRQ while no " "data to send\n"); omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XRDY); continue; } if (stat & OMAP_I2C_STAT_ROVR) { dev_err(dev->dev, "Receive overrun\n"); dev->cmd_err |= OMAP_I2C_STAT_ROVR; } if (stat & OMAP_I2C_STAT_XUDF) { dev_err(dev->dev, "Transmit overflow\n"); dev->cmd_err |= OMAP_I2C_STAT_XUDF; } if (stat & OMAP_I2C_STAT_NACK) { <API key>(dev, OMAP_I2C_STAT_NACK); omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_STP); } if (stat & OMAP_I2C_STAT_AL) { dev_err(dev->dev, "Arbitration lost\n"); <API key>(dev, OMAP_I2C_STAT_AL); } } return count ? IRQ_HANDLED : IRQ_NONE; } static const struct i2c_algorithm omap_i2c_algo = { .master_xfer = omap_i2c_xfer, .functionality = omap_i2c_func, }; static int omap_i2c_probe(struct platform_device *pdev) { struct omap_i2c_dev *dev; struct i2c_adapter *adap; struct resource *mem, *irq, *ioarea; int r; /* NOTE: driver uses the static register mapping */ mem = <API key>(pdev, IORESOURCE_MEM, 0); if (!mem) { dev_err(&pdev->dev, "no mem resource?\n"); return -ENODEV; } irq = <API key>(pdev, IORESOURCE_IRQ, 0); if (!irq) { dev_err(&pdev->dev, "no irq resource?\n"); return -ENODEV; } ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1, pdev->name); if (!ioarea) { dev_err(&pdev->dev, "I2C region already claimed\n"); return -EBUSY; } if (clock > 200) clock = 400; /* Fast mode */ else clock = 100; /* Standard mode */ dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL); if (!dev) { r = -ENOMEM; goto err_release_region; } dev->dev = &pdev->dev; dev->irq = irq->start; dev->base = (void __iomem *) IO_ADDRESS(mem->start); <API key>(pdev, dev); if ((r = omap_i2c_get_clocks(dev)) != 0) goto err_free_mem; <API key>(dev); if (cpu_is_omap15xx()) dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20; /* reset ASAP, clearing any IRQs */ omap_i2c_init(dev); r = request_irq(dev->irq, dev->rev1 ? omap_i2c_rev1_isr : omap_i2c_isr, 0, pdev->name, dev); if (r) { dev_err(dev->dev, "failure requesting irq %i\n", dev->irq); goto err_unuse_clocks; } r = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n", pdev->id, r >> 4, r & 0xf, clock); adap = &dev->adapter; i2c_set_adapdata(adap, dev); adap->owner = THIS_MODULE; adap->class = I2C_CLASS_HWMON; strncpy(adap->name, "OMAP I2C adapter", sizeof(adap->name)); adap->algo = &omap_i2c_algo; adap->dev.parent = &pdev->dev; /* i2c device drivers may be active on return from add_adapter() */ adap->nr = pdev->id; r = <API key>(adap); if (r) { dev_err(dev->dev, "failure adding adapter\n"); goto err_free_irq; } <API key>(dev); return 0; err_free_irq: free_irq(dev->irq, dev); err_unuse_clocks: omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); <API key>(dev); omap_i2c_put_clocks(dev); err_free_mem: <API key>(pdev, NULL); kfree(dev); err_release_region: release_mem_region(mem->start, (mem->end - mem->start) + 1); return r; } static int omap_i2c_remove(struct platform_device *pdev) { struct omap_i2c_dev *dev = <API key>(pdev); struct resource *mem; <API key>(pdev, NULL); free_irq(dev->irq, dev); i2c_del_adapter(&dev->adapter); omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); omap_i2c_put_clocks(dev); kfree(dev); mem = <API key>(pdev, IORESOURCE_MEM, 0); release_mem_region(mem->start, (mem->end - mem->start) + 1); return 0; } static struct platform_driver omap_i2c_driver = { .probe = omap_i2c_probe, .remove = omap_i2c_remove, .driver = { .name = "i2c_omap", .owner = THIS_MODULE, }, }; /* I2C may be needed to bring up other drivers */ static int __init <API key>(void) { return <API key>(&omap_i2c_driver); } subsys_initcall(<API key>); static void __exit <API key>(void) { <API key>(&omap_i2c_driver); } module_exit(<API key>); MODULE_AUTHOR("MontaVista Software, Inc. (and others)"); MODULE_DESCRIPTION("TI OMAP I2C bus adapter"); MODULE_LICENSE("GPL");
#ifndef <API key> #define <API key> #include "code/oopRecorder.hpp" #include "code/relocInfo.hpp" class CodeStrings; class PhaseCFG; class Compile; class BufferBlob; class CodeBuffer; class Label; class CodeOffsets: public StackObj { public: enum Entries { Entry, Verified_Entry, Frame_Complete, // Offset in the code where the frame setup is (for forte stackwalks) is complete OSR_Entry, Dtrace_trap = OSR_Entry, // dtrace probes can never have an OSR entry so reuse it Exceptions, // Offset where exception handler lives Deopt, // Offset where deopt handler lives DeoptMH, // Offset where MethodHandle deopt handler lives UnwindHandler, // Offset to default unwind handler max_Entries }; // special value to note codeBlobs where profile (forte) stack walking is // always dangerous and suspect. enum { frame_never_safe = -1 }; private: int _values[max_Entries]; public: CodeOffsets() { _values[Entry ] = 0; _values[Verified_Entry] = 0; _values[Frame_Complete] = frame_never_safe; _values[OSR_Entry ] = 0; _values[Exceptions ] = -1; _values[Deopt ] = -1; _values[DeoptMH ] = -1; _values[UnwindHandler ] = -1; } int value(Entries e) { return _values[e]; } void set_value(Entries e, int val) { _values[e] = val; } }; // This class represents a stream of code and associated relocations. // There are a few in each CodeBuffer. // They are filled concurrently, and concatenated at the end. class CodeSection <API key> { friend class CodeBuffer; public: typedef int csize_t; // code size type; would be size_t except for history private: address _start; // first byte of contents (instructions) address _mark; // user mark, usually an instruction beginning address _end; // current end address address _limit; // last possible (allocated) end address relocInfo* _locs_start; // first byte of relocation information relocInfo* _locs_end; // first byte after relocation information relocInfo* _locs_limit; // first byte after relocation information buf address _locs_point; // last relocated position (grows upward) bool _locs_own; // did I allocate the locs myself? bool _frozen; // no more expansion of this section char _index; // my section number (SECT_INST, etc.) CodeBuffer* _outer; // enclosing CodeBuffer // (Note: _locs_point used to be called _last_reloc_offset.) CodeSection() { _start = NULL; _mark = NULL; _end = NULL; _limit = NULL; _locs_start = NULL; _locs_end = NULL; _locs_limit = NULL; _locs_point = NULL; _locs_own = false; _frozen = false; debug_only(_index = (char)-1); debug_only(_outer = (CodeBuffer*)badAddress); } void initialize_outer(CodeBuffer* outer, int index) { _outer = outer; _index = index; } void initialize(address start, csize_t size = 0) { assert(_start == NULL, "only one init step, please"); _start = start; _mark = NULL; _end = start; _limit = start + size; _locs_point = start; } void initialize_locs(int locs_capacity); void expand_locs(int new_capacity); void <API key>(const CodeSection* source_cs); // helper for CodeBuffer::expand() void take_over_code_from(CodeSection* cs) { _start = cs->_start; _mark = cs->_mark; _end = cs->_end; _limit = cs->_limit; _locs_point = cs->_locs_point; } public: address start() const { return _start; } address mark() const { return _mark; } address end() const { return _end; } address limit() const { return _limit; } csize_t size() const { return (csize_t)(_end - _start); } csize_t mark_off() const { assert(_mark != NULL, "not an offset"); return (csize_t)(_mark - _start); } csize_t capacity() const { return (csize_t)(_limit - _start); } csize_t remaining() const { return (csize_t)(_limit - _end); } relocInfo* locs_start() const { return _locs_start; } relocInfo* locs_end() const { return _locs_end; } int locs_count() const { return (int)(_locs_end - _locs_start); } relocInfo* locs_limit() const { return _locs_limit; } address locs_point() const { return _locs_point; } csize_t locs_point_off() const{ return (csize_t)(_locs_point - _start); } csize_t locs_capacity() const { return (csize_t)(_locs_limit - _locs_start); } csize_t locs_remaining()const { return (csize_t)(_locs_limit - _locs_end); } int index() const { return _index; } bool is_allocated() const { return _start != NULL; } bool is_empty() const { return _start == _end; } bool is_frozen() const { return _frozen; } bool has_locs() const { return _locs_end != NULL; } CodeBuffer* outer() const { return _outer; } // is a given address in this section? (2nd version is end-inclusive) bool contains(address pc) const { return pc >= _start && pc < _end; } bool contains2(address pc) const { return pc >= _start && pc <= _end; } bool allocates(address pc) const { return pc >= _start && pc < _limit; } bool allocates2(address pc) const { return pc >= _start && pc <= _limit; } void set_end(address pc) { assert(allocates2(pc), err_msg("not in CodeBuffer memory: " PTR_FORMAT " <= " PTR_FORMAT " <= " PTR_FORMAT, _start, pc, _limit)); _end = pc; } void set_mark(address pc) { assert(contains2(pc), "not in codeBuffer"); _mark = pc; } void set_mark_off(int offset) { assert(contains2(offset+_start),"not in codeBuffer"); _mark = offset + _start; } void set_mark() { _mark = _end; } void clear_mark() { _mark = NULL; } void set_locs_end(relocInfo* p) { assert(p <= locs_limit(), "locs data fits in allocated buffer"); _locs_end = p; } void set_locs_point(address pc) { assert(pc >= locs_point(), "relocation addr may not decrease"); assert(allocates2(pc), "relocation addr must be in this section"); _locs_point = pc; } // Code emission void emit_int8 ( int8_t x) { *((int8_t*) end()) = x; set_end(end() + sizeof(int8_t)); } void emit_int16( int16_t x) { *((int16_t*) end()) = x; set_end(end() + sizeof(int16_t)); } void emit_int32( int32_t x) { *((int32_t*) end()) = x; set_end(end() + sizeof(int32_t)); } void emit_int64( int64_t x) { *((int64_t*) end()) = x; set_end(end() + sizeof(int64_t)); } void emit_float( jfloat x) { *((jfloat*) end()) = x; set_end(end() + sizeof(jfloat)); } void emit_double(jdouble x) { *((jdouble*) end()) = x; set_end(end() + sizeof(jdouble)); } void emit_address(address x) { *((address*) end()) = x; set_end(end() + sizeof(address)); } // Share a scratch buffer for relocinfo. (Hacky; saves a resource allocation.) void <API key>(relocInfo* buf, int length); // Manage labels and their addresses. address target(Label& L, address branch_pc); // Emit a relocation. void relocate(address at, RelocationHolder const& rspec, int format = 0); void relocate(address at, relocInfo::relocType rtype, int format = 0) { if (rtype != relocInfo::none) relocate(at, Relocation::spec_simple(rtype), format); } // alignment requirement for starting offset // Requirements are that the instruction area and the // stubs area must start on CodeEntryAlignment, and // the ctable on sizeof(jdouble) int alignment() const { return MAX2((int)sizeof(jdouble), (int)CodeEntryAlignment); } // Slop between sections, used only when allocating temporary BufferBlob buffers. static csize_t end_slop() { return MAX2((int)sizeof(jdouble), (int)CodeEntryAlignment); } csize_t align_at_start(csize_t off) const { return (csize_t) align_size_up(off, alignment()); } // Mark a section frozen. Assign its remaining space to // the following section. It will never expand after this point. inline void freeze(); // { _outer->freeze_section(this); } // Ensure there's enough space left in the current section. // Return true if there was an expansion. bool <API key>(csize_t amount); #ifndef PRODUCT void decode(); void dump(); void print(const char* name); #endif //PRODUCT }; class CodeString; class CodeStrings <API key> { private: #ifndef PRODUCT CodeString* _strings; #endif CodeString* find(intptr_t offset) const; CodeString* find_last(intptr_t offset) const; public: CodeStrings() { #ifndef PRODUCT _strings = NULL; #endif } const char* add_string(const char * string) PRODUCT_RETURN_(return NULL;); void add_comment(intptr_t offset, const char * comment) PRODUCT_RETURN; void print_block_comment(outputStream* stream, intptr_t offset) const PRODUCT_RETURN; void assign(CodeStrings& other) PRODUCT_RETURN; void free() PRODUCT_RETURN; }; // A CodeBuffer describes a memory space into which assembly // code is generated. This memory space usually occupies the // interior of a single BufferBlob, but in some cases it may be // an arbitrary span of memory, even outside the code cache. // A code buffer comes in two variants: // (1) A CodeBuffer referring to an already allocated piece of memory: // This is used to direct 'static' code generation (e.g. for interpreter // or stubroutine generation, etc.). This code comes with NO relocation // information. // (2) A CodeBuffer referring to a piece of memory allocated when the // CodeBuffer is allocated. This is used for nmethod generation. // The memory can be divided up into several parts called sections. // Each section independently accumulates code (or data) an relocations. // Sections can grow (at the expense of a reallocation of the BufferBlob // and recopying of all active sections). When the buffered code is finally // written to an nmethod (or other CodeBlob), the contents (code, data, // and relocations) of the sections are padded to an alignment and concatenated. // Instructions and data in one section can contain relocatable references to // addresses in a sibling section. class CodeBuffer: public StackObj { friend class CodeSection; private: // CodeBuffers must be allocated on the stack except for a single // special case during expansion which is handled internally. This // is done to guarantee proper cleanup of resources. void* operator new(size_t size) throw() { return ResourceObj::operator new(size); } void operator delete(void* p) { ShouldNotCallThis(); } public: typedef int csize_t; // code size type; would be size_t except for history enum { // Here is the list of all possible sections. The order reflects // the final layout. SECT_FIRST = 0, SECT_CONSTS = SECT_FIRST, // Non-instruction data: Floats, jump tables, etc. SECT_INSTS, // Executable instructions. SECT_STUBS, // Outbound trampolines for supporting call sites. SECT_LIMIT, SECT_NONE = -1 }; private: enum { sect_bits = 2, // assert (SECT_LIMIT <= (1<<sect_bits)) sect_mask = (1<<sect_bits)-1 }; const char* _name; CodeSection _consts; // constants, jump tables CodeSection _insts; // instructions (the main section) CodeSection _stubs; // stubs (call site support), deopt, exception handling CodeBuffer* _before_expand; // dead buffer, from before the last expansion BufferBlob* _blob; // optional buffer in CodeCache for generated code address _total_start; // first address of combined memory buffer csize_t _total_size; // size in bytes of combined memory buffer OopRecorder* _oop_recorder; CodeStrings _strings; OopRecorder <API key>; // override with <API key> Arena* _overflow_arena; address _decode_begin; // start address for decode address decode_begin(); void initialize_misc(const char * name) { // all pointers other than code_start/end and those inside the sections assert(name != NULL, "must have a name"); _name = name; _before_expand = NULL; _blob = NULL; _oop_recorder = NULL; _decode_begin = NULL; _overflow_arena = NULL; } void initialize(address code_start, csize_t code_size) { _consts.initialize_outer(this, SECT_CONSTS); _insts.initialize_outer(this, SECT_INSTS); _stubs.initialize_outer(this, SECT_STUBS); _total_start = code_start; _total_size = code_size; // Initialize the main section: _insts.initialize(code_start, code_size); assert(!_stubs.is_allocated(), "no garbage here"); assert(!_consts.is_allocated(), "no garbage here"); _oop_recorder = &<API key>; } void <API key>(CodeSection* cs, csize_t size); void freeze_section(CodeSection* cs); // helper for CodeBuffer::expand() void take_over_code_from(CodeBuffer* cs); // ensure sections are disjoint, ordered, and contained in the blob void <API key>(); // copies combined relocations to the blob, returns bytes copied // (if target is null, it is a dry run only, just for sizing) csize_t copy_relocations_to(CodeBlob* blob) const; // copies combined code to the blob (assumes relocs are already in there) void copy_code_to(CodeBlob* blob); // moves code sections to new buffer (assumes relocs are already in there) void relocate_code_to(CodeBuffer* cb) const; // set up a model of the final layout of my contents void <API key>(CodeBuffer* dest) const; // Expand the given section so at least 'amount' is remaining. // Creates a new, larger BufferBlob, and rewrites the code & relocs. void expand(CodeSection* which_cs, csize_t amount); // Helper for expand. csize_t <API key>(CodeSection* which_cs, csize_t amount, csize_t* new_capacity); public: // (1) code buffer referring to pre-allocated instruction memory CodeBuffer(address code_start, csize_t code_size) { assert(code_start != NULL, "sanity"); initialize_misc("static buffer"); initialize(code_start, code_size); <API key>(); } // (2) CodeBuffer referring to pre-allocated CodeBlob. CodeBuffer(CodeBlob* blob); // (3) code buffer allocating codeBlob memory for code & relocation // info but with lazy initialization. The name must be something // informative. CodeBuffer(const char* name) { initialize_misc(name); } // (4) code buffer allocating codeBlob memory for code & relocation // info. The name must be something informative and code_size must // include both code and stubs sizes. CodeBuffer(const char* name, csize_t code_size, csize_t locs_size) { initialize_misc(name); initialize(code_size, locs_size); } ~CodeBuffer(); // Initialize a CodeBuffer constructed using constructor 3. Using // constructor 4 is equivalent to calling constructor 3 and then // calling this method. It's been factored out for convenience of // construction. void initialize(csize_t code_size, csize_t locs_size); CodeSection* consts() { return &_consts; } CodeSection* insts() { return &_insts; } CodeSection* stubs() { return &_stubs; } // present sections in order; return NULL at end; consts is #0, etc. CodeSection* code_section(int n) { // This makes the slightly questionable but portable assumption // that the various members (_consts, _insts, _stubs, etc.) are // adjacent in the layout of CodeBuffer. CodeSection* cs = &_consts + n; assert(cs->index() == n || !cs->is_allocated(), "sanity"); return cs; } const CodeSection* code_section(int n) const { // yucky const stuff return ((CodeBuffer*)this)->code_section(n); } static const char* code_section_name(int n); int section_index_of(address addr) const; bool contains(address addr) const { // handy for debugging return section_index_of(addr) > SECT_NONE; } // A stable mapping between 'locators' (small ints) and addresses. static int locator_pos(int locator) { return locator >> sect_bits; } static int locator_sect(int locator) { return locator & sect_mask; } static int locator(int pos, int sect) { return (pos << sect_bits) | sect; } int locator(address addr) const; address locator_address(int locator) const; // Heuristic for pre-packing the taken/not-taken bit of a predicted branch. bool is_backward_branch(Label& L); // Properties const char* name() const { return _name; } CodeBuffer* before_expand() const { return _before_expand; } BufferBlob* blob() const { return _blob; } void set_blob(BufferBlob* blob); void free_blob(); // Free the blob, if we own one. // Properties relative to the insts section: address insts_begin() const { return _insts.start(); } address insts_end() const { return _insts.end(); } void set_insts_end(address end) { _insts.set_end(end); } address insts_limit() const { return _insts.limit(); } address insts_mark() const { return _insts.mark(); } void set_insts_mark() { _insts.set_mark(); } void clear_insts_mark() { _insts.clear_mark(); } // is there anything in the buffer other than the current section? bool is_pure() const { return insts_size() == total_content_size(); } // size in bytes of output so far in the insts sections csize_t insts_size() const { return _insts.size(); } // same as insts_size(), except that it asserts there is no non-code here csize_t pure_insts_size() const { assert(is_pure(), "no non-code"); return insts_size(); } // capacity in bytes of the insts sections csize_t insts_capacity() const { return _insts.capacity(); } // number of bytes remaining in the insts section csize_t insts_remaining() const { return _insts.remaining(); } // is a given address in the insts section? (2nd version is end-inclusive) bool insts_contains(address pc) const { return _insts.contains(pc); } bool insts_contains2(address pc) const { return _insts.contains2(pc); } // Record any extra oops required to keep embedded metadata alive void <API key>(methodHandle method); // Allocated size in all sections, when aligned and concatenated // (this is the eventual state of the content in its final // CodeBlob). csize_t total_content_size() const; // Combined offset (relative to start of first section) of given // section, as eventually found in the final CodeBlob. csize_t total_offset_of(CodeSection* cs) const; // allocated size of all relocation data, including index, rounded up csize_t <API key>() const; // allocated size of any and all recorded oops csize_t total_oop_size() const { OopRecorder* recorder = oop_recorder(); return (recorder == NULL)? 0: recorder->oop_size(); } // allocated size of any and all recorded metadata csize_t total_metadata_size() const { OopRecorder* recorder = oop_recorder(); return (recorder == NULL)? 0: recorder->metadata_size(); } // Configuration functions, called immediately after the CB is constructed. // The section sizes are subtracted from the original insts section. // Note: Call them in reverse section order, because each steals from insts. void <API key>(csize_t size) { <API key>(&_consts, size); } void <API key>(csize_t size) { <API key>(&_stubs, size); } // Override default oop recorder. void <API key>(OopRecorder* r); OopRecorder* oop_recorder() const { return _oop_recorder; } CodeStrings& strings() { return _strings; } // Code generation void relocate(address at, RelocationHolder const& rspec, int format = 0) { _insts.relocate(at, rspec, format); } void relocate(address at, relocInfo::relocType rtype, int format = 0) { _insts.relocate(at, rtype, format); } // Management of overflow storage for binding of Labels. GrowableArray<int>* <API key>(); // NMethod generation void <API key>(CodeBlob* blob) { assert(blob != NULL, "sane"); copy_relocations_to(blob); copy_code_to(blob); } void copy_values_to(nmethod* nm) { if (!oop_recorder()->is_unused()) { oop_recorder()->copy_values_to(nm); } } // Transform an address from the code in this code buffer to a specified code buffer address transform_address(const CodeBuffer &cb, address addr) const; void block_comment(intptr_t offset, const char * comment) PRODUCT_RETURN; const char* code_string(const char* str) PRODUCT_RETURN_(return NULL;); // Log a little info about section usage in the CodeBuffer void log_section_sizes(const char* name); #ifndef PRODUCT public: // Printing / Decoding // decodes from decode_begin() to code_end() and sets decode_begin to end void decode(); void decode_all(); // decodes all the code void skip_decode(); // sets decode_begin to code_end(); void print(); #endif // The following header contains <API key> implementations #ifdef TARGET_ARCH_x86 # include "codeBuffer_x86.hpp" #endif #ifdef TARGET_ARCH_sparc # include "codeBuffer_sparc.hpp" #endif #ifdef TARGET_ARCH_zero # include "codeBuffer_zero.hpp" #endif #ifdef TARGET_ARCH_arm # include "codeBuffer_arm.hpp" #endif #ifdef TARGET_ARCH_ppc # include "codeBuffer_ppc.hpp" #endif }; inline void CodeSection::freeze() { _outer->freeze_section(this); } inline bool CodeSection::<API key>(csize_t amount) { if (remaining() < amount) { _outer->expand(this, amount); return true; } return false; } #endif // <API key>
// Use of this source code is governed by a BSD-style package patch import ( "bytes" "compress/zlib" "crypto/sha1" "encoding/git85" "fmt" "io" "os" ) func gitSHA1(data []byte) []byte { if len(data) == 0 { // special case: 0 length is all zeros sum return make([]byte, 20) } h := sha1.New() fmt.Fprintf(h, "blob %d\x00", len(data)) h.Write(data) return h.Sum() } // BUG(rsc): The Git binary delta format is not implemented, only Git binary literals. // GitBinaryLiteral represents a Git binary literal diff. type GitBinaryLiteral struct { OldSHA1 []byte // if non-empty, the SHA1 hash of the original New []byte // the new contents } // Apply implements the Diff interface's Apply method. func (d *GitBinaryLiteral) Apply(old []byte) ([]byte, os.Error) { if sum := gitSHA1(old); !bytes.HasPrefix(sum, d.OldSHA1) { return nil, ErrPatchFailure } return d.New, nil } func unhex(c byte) uint8 { switch { case '0' <= c && c <= '9': return c - '0' case 'a' <= c && c <= 'f': return c - 'a' + 10 case 'A' <= c && c <= 'F': return c - 'A' + 10 } return 255 } func getHex(s []byte) (data []byte, rest []byte) { n := 0 for n < len(s) && unhex(s[n]) != 255 { n++ } n &^= 1 // Only take an even number of hex digits. data = make([]byte, n/2) for i := range data { data[i] = unhex(s[2*i])<<4 | unhex(s[2*i+1]) } rest = s[n:] return } // ParseGitBinary parses raw as a Git binary patch. func ParseGitBinary(raw []byte) (Diff, os.Error) { var oldSHA1, newSHA1 []byte var sawBinary bool for { var first []byte first, raw, _ = getLine(raw, 1) first = bytes.TrimSpace(first) if s, ok := skip(first, "index "); ok { oldSHA1, s = getHex(s) if s, ok = skip(s, ".."); !ok { continue } newSHA1, s = getHex(s) continue } if _, ok := skip(first, "GIT binary patch"); ok { sawBinary = true continue } if n, _, ok := atoi(first, "literal ", 10); ok && sawBinary { data := make([]byte, n) d := git85.NewDecoder(bytes.NewBuffer(raw)) z, err := zlib.NewReader(d) if err != nil { return nil, err } defer z.Close() if _, err = io.ReadFull(z, data); err != nil { if err == os.EOF { err = io.ErrUnexpectedEOF } return nil, err } var buf [1]byte m, err := z.Read(buf[0:]) if m != 0 || err != os.EOF { return nil, os.NewError("Git binary literal longer than expected") } if sum := gitSHA1(data); !bytes.HasPrefix(sum, newSHA1) { return nil, os.NewError("Git binary literal SHA1 mismatch") } return &GitBinaryLiteral{oldSHA1, data}, nil } if !sawBinary { return nil, os.NewError("unexpected Git patch header: " + string(first)) } } panic("unreachable") }
# encoding: utf-8 require 'spec_helper' require_dependency 'post_creator' describe CategoryUser do it 'allows batch set' do user = Fabricate(:user) category1 = Fabricate(:category) category2 = Fabricate(:category) watching = CategoryUser.where(user_id: user.id, notification_level: CategoryUser.notification_levels[:watching]) CategoryUser.batch_set(user, :watching, [category1.id, category2.id]) expect(watching.pluck(:category_id).sort).to eq [category1.id, category2.id] CategoryUser.batch_set(user, :watching, []) expect(watching.count).to eq 0 CategoryUser.batch_set(user, :watching, [category2.id]) expect(watching.count).to eq 1 end context 'integration' do before do ActiveRecord::Base.observers.enable :all end it 'should operate correctly' do watched_category = Fabricate(:category) muted_category = Fabricate(:category) tracked_category = Fabricate(:category) user = Fabricate(:user) CategoryUser.create!(user: user, category: watched_category, notification_level: CategoryUser.notification_levels[:watching]) CategoryUser.create!(user: user, category: muted_category, notification_level: CategoryUser.notification_levels[:muted]) CategoryUser.create!(user: user, category: tracked_category, notification_level: CategoryUser.notification_levels[:tracking]) watched_post = create_post(category: watched_category) muted_post = create_post(category: muted_category) tracked_post = create_post(category: tracked_category) expect(Notification.where(user_id: user.id, topic_id: watched_post.topic_id).count).to eq 1 expect(Notification.where(user_id: user.id, topic_id: tracked_post.topic_id).count).to eq 0 tu = TopicUser.get(tracked_post.topic, user) expect(tu.notification_level).to eq TopicUser.notification_levels[:tracking] expect(tu.<API key>).to eq TopicUser.<API key>[:auto_track_category] end it "watches categories that have been changed" do user = Fabricate(:user) watched_category = Fabricate(:category) CategoryUser.create!(user: user, category: watched_category, notification_level: CategoryUser.notification_levels[:watching]) post = create_post expect(TopicUser.get(post.topic, user)).to be_blank # Now, change the topic's category post.topic.<API key>(watched_category.id) tu = TopicUser.get(post.topic, user) expect(tu.notification_level).to eq TopicUser.notification_levels[:watching] end it "unwatches categories that have been changed" do user = Fabricate(:user) watched_category = Fabricate(:category) CategoryUser.create!(user: user, category: watched_category, notification_level: CategoryUser.notification_levels[:watching]) post = create_post(category: watched_category) tu = TopicUser.get(post.topic, user) expect(tu.notification_level).to eq TopicUser.notification_levels[:watching] # Now, change the topic's category unwatched_category = Fabricate(:category) post.topic.<API key>(unwatched_category.id) expect(TopicUser.get(post.topic, user)).to be_blank end end end
#include <linux/types.h> #include <linux/kernel.h> #include <linux/slab.h> #include <drm/amdgpu_drm.h> #include "pp_instance.h" #include "smumgr.h" #include "cgs_common.h" #include "linux/delay.h" int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle) { struct pp_smumgr *smumgr; if ((handle == NULL) || (pp_init == NULL)) return -EINVAL; smumgr = kzalloc(sizeof(struct pp_smumgr), GFP_KERNEL); if (smumgr == NULL) return -ENOMEM; smumgr->device = pp_init->device; smumgr->chip_family = pp_init->chip_family; smumgr->chip_id = pp_init->chip_id; smumgr->usec_timeout = <API key>; smumgr->reload_fw = 1; handle->smu_mgr = smumgr; switch (smumgr->chip_family) { case AMDGPU_FAMILY_CZ: cz_smum_init(smumgr); break; case AMDGPU_FAMILY_VI: switch (smumgr->chip_id) { case CHIP_TOPAZ: iceland_smum_init(smumgr); break; case CHIP_TONGA: tonga_smum_init(smumgr); break; case CHIP_FIJI: fiji_smum_init(smumgr); break; case CHIP_POLARIS11: case CHIP_POLARIS10: case CHIP_POLARIS12: polaris10_smum_init(smumgr); break; default: return -EINVAL; } break; default: kfree(smumgr); return -EINVAL; } return 0; } int smum_fini(struct pp_smumgr *smumgr) { kfree(smumgr->device); kfree(smumgr); return 0; } int <API key>(struct pp_hwmgr *hwmgr, void *input, void *output, void *storage, int result) { if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable) return hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable(hwmgr); return 0; } int <API key>(struct pp_hwmgr *hwmgr, void *input, void *output, void *storage, int result) { if (NULL != hwmgr->smumgr->smumgr_funcs-><API key>) return hwmgr->smumgr->smumgr_funcs-><API key>(hwmgr); return 0; } int <API key>(struct pp_hwmgr *hwmgr) { if (NULL != hwmgr->smumgr->smumgr_funcs-><API key>) return hwmgr->smumgr->smumgr_funcs-><API key>(hwmgr); return 0; } int <API key>(struct pp_hwmgr *hwmgr, uint32_t type) { if (NULL != hwmgr->smumgr->smumgr_funcs->update_smc_table) return hwmgr->smumgr->smumgr_funcs->update_smc_table(hwmgr, type); return 0; } uint32_t smum_get_offsetof(struct pp_smumgr *smumgr, uint32_t type, uint32_t member) { if (NULL != smumgr->smumgr_funcs->get_offsetof) return smumgr->smumgr_funcs->get_offsetof(type, member); return 0; } int <API key>(struct pp_hwmgr *hwmgr) { if (NULL != hwmgr->smumgr->smumgr_funcs-><API key>) return hwmgr->smumgr->smumgr_funcs-><API key>(hwmgr); return 0; } int smum_get_argument(struct pp_smumgr *smumgr) { if (NULL != smumgr->smumgr_funcs->get_argument) return smumgr->smumgr_funcs->get_argument(smumgr); return 0; } uint32_t <API key>(struct pp_smumgr *smumgr, uint32_t value) { if (NULL != smumgr->smumgr_funcs->get_mac_definition) return smumgr->smumgr_funcs->get_mac_definition(value); return 0; } int <API key>(struct pp_smumgr *smumgr, void **table) { if (NULL != smumgr->smumgr_funcs-><API key>) return smumgr->smumgr_funcs-><API key>(smumgr, table); return 0; } int <API key>(struct pp_smumgr *smumgr) { if (NULL != smumgr->smumgr_funcs-><API key>) return smumgr->smumgr_funcs-><API key>(smumgr); return 0; } int <API key>(struct pp_smumgr *smumgr, uint16_t msg) { if (smumgr == NULL || smumgr->smumgr_funcs->send_msg_to_smc == NULL) return -EINVAL; return smumgr->smumgr_funcs->send_msg_to_smc(smumgr, msg); } int <API key>(struct pp_smumgr *smumgr, uint16_t msg, uint32_t parameter) { if (smumgr == NULL || smumgr->smumgr_funcs-><API key> == NULL) return -EINVAL; return smumgr->smumgr_funcs-><API key>( smumgr, msg, parameter); } /* * Returns once the part of the register indicated by the mask has * reached the given value. */ int <API key>(struct pp_smumgr *smumgr, uint32_t index, uint32_t value, uint32_t mask) { uint32_t i; uint32_t cur_value; if (smumgr == NULL || smumgr->device == NULL) return -EINVAL; for (i = 0; i < smumgr->usec_timeout; i++) { cur_value = cgs_read_register(smumgr->device, index); if ((cur_value & mask) == (value & mask)) break; udelay(1); } /* timeout means wrong logic*/ if (i == smumgr->usec_timeout) return -1; return 0; } int <API key>(struct pp_smumgr *smumgr, uint32_t index, uint32_t value, uint32_t mask) { uint32_t i; uint32_t cur_value; if (smumgr == NULL) return -EINVAL; for (i = 0; i < smumgr->usec_timeout; i++) { cur_value = cgs_read_register(smumgr->device, index); if ((cur_value & mask) != (value & mask)) break; udelay(1); } /* timeout means wrong logic */ if (i == smumgr->usec_timeout) return -1; return 0; } /* * Returns once the part of the register indicated by the mask * has reached the given value.The indirect space is described by * giving the memory-mapped index of the indirect index register. */ int <API key>(struct pp_smumgr *smumgr, uint32_t indirect_port, uint32_t index, uint32_t value, uint32_t mask) { if (smumgr == NULL || smumgr->device == NULL) return -EINVAL; cgs_write_register(smumgr->device, indirect_port, index); return <API key>(smumgr, indirect_port + 1, mask, value); } void <API key>( struct pp_smumgr *smumgr, uint32_t indirect_port, uint32_t index, uint32_t value, uint32_t mask) { if (smumgr == NULL || smumgr->device == NULL) return; cgs_write_register(smumgr->device, indirect_port, index); <API key>(smumgr, indirect_port + 1, value, mask); } int smu_allocate_memory(void *device, uint32_t size, enum cgs_gpu_mem_type type, uint32_t byte_align, uint64_t *mc_addr, void **kptr, void *handle) { int ret = 0; cgs_handle_t cgs_handle; if (device == NULL || handle == NULL || mc_addr == NULL || kptr == NULL) return -EINVAL; ret = cgs_alloc_gpu_mem(device, type, size, byte_align, 0, 0, (cgs_handle_t *)handle); if (ret) return -ENOMEM; cgs_handle = *(cgs_handle_t *)handle; ret = cgs_gmap_gpu_mem(device, cgs_handle, mc_addr); if (ret) goto error_gmap; ret = cgs_kmap_gpu_mem(device, cgs_handle, kptr); if (ret) goto error_kmap; return 0; error_kmap: cgs_gunmap_gpu_mem(device, cgs_handle); error_gmap: cgs_free_gpu_mem(device, cgs_handle); return ret; } int smu_free_memory(void *device, void *handle) { cgs_handle_t cgs_handle = (cgs_handle_t)handle; if (device == NULL || handle == NULL) return -EINVAL; cgs_kunmap_gpu_mem(device, cgs_handle); cgs_gunmap_gpu_mem(device, cgs_handle); cgs_free_gpu_mem(device, cgs_handle); return 0; } int smum_init_smc_table(struct pp_hwmgr *hwmgr) { if (NULL != hwmgr->smumgr->smumgr_funcs->init_smc_table) return hwmgr->smumgr->smumgr_funcs->init_smc_table(hwmgr); return 0; } int <API key>(struct pp_hwmgr *hwmgr) { if (NULL != hwmgr->smumgr->smumgr_funcs-><API key>) return hwmgr->smumgr->smumgr_funcs-><API key>(hwmgr); return 0; } int <API key>(struct pp_hwmgr *hwmgr) { if (NULL != hwmgr->smumgr->smumgr_funcs-><API key>) return hwmgr->smumgr->smumgr_funcs-><API key>(hwmgr); return 0; } /*this interface is needed by island ci/vi */ int <API key>(struct pp_hwmgr *hwmgr) { if (NULL != hwmgr->smumgr->smumgr_funcs-><API key>) return hwmgr->smumgr->smumgr_funcs-><API key>(hwmgr); return 0; } bool smum_is_dpm_running(struct pp_hwmgr *hwmgr) { if (NULL != hwmgr->smumgr->smumgr_funcs->is_dpm_running) return hwmgr->smumgr->smumgr_funcs->is_dpm_running(hwmgr); return true; }
shadowsocks-libev ============== [shadowsocks-libev][1] is a lightweight secured socks5 proxy for embedded devices and low end boxes. It is a port of [shadowsocks][2] created by @clowwindy maintained by @madeye and @linusyang. Suppose we have a VPS running Debian or Ubuntu. To deploy the service quickly, we can use [docker][3]. ## Install docker $ curl -sSL https://get.docker.com/ | sh $ docker --version ## Build docker image bash $ curl -sSL https://github.com/shadowsocks/shadowsocks-libev/raw/master/docker/alpine/Dockerfile | docker build -t shadowsocks-libev . $ docker images > You can also use a pre-built docker image: [vimagick/shadowsocks-libev][4] ![][5]. ## Run docker container bash $ docker run -d -e METHOD=aes-256-cfb -e PASSWORD=9MLSpPmNt -p 8388:8388 --restart always shadowsocks-libev $ docker ps > :warning: Click [here][6] to generate a strong password to protect your server. ## Use docker-compose to manage (optional) It is very handy to use [docker-compose][7] to manage docker containers. You can download the binary at <https://github.com/docker/compose/releases>. This is a sample `docker-compose.yml` file. yaml shadowsocks: image: shadowsocks-libev ports: - "8388:8388" environment: - METHOD=aes-256-cfb - PASSWORD=9MLSpPmNt restart: always It is highly recommended that you setup a directory tree to make things easy to manage. bash $ mkdir -p ~/fig/shadowsocks/ $ cd ~/fig/shadowsocks/ $ curl -sSLO https://github.com/shadowsocks/shadowsocks-libev/raw/master/docker/alpine/docker-compose.yml $ docker-compose up -d $ docker-compose ps ## Finish At last, download shadowsocks client [here][8]. Don't forget to share internet with your friends. yaml { "server": "your-vps-ip", "server_port": 8388, "local_address": "0.0.0.0", "local_port": 1080, "password": "9MLSpPmNt", "timeout": 600, "method": "aes-256-cfb" } [1]: https://github.com/shadowsocks/shadowsocks-libev [2]: https://shadowsocks.org/en/index.html [3]: https://github.com/docker/docker [4]: https://hub.docker.com/r/vimagick/shadowsocks-libev/ [5]: https://badge.imagelayers.io/vimagick/shadowsocks-libev:latest.svg [6]: https://duckduckgo.com/?q=password+12&t=ffsb&ia=answer [7]: https://github.com/docker/compose [8]: https://shadowsocks.org/en/download/clients.html
#!/bin/bash #set -x source $LIBMESH_DIR/examples/run_common.sh example_name=adjoints_ex3 example_dir=examples/adjoints/$example_name run_example "$example_name"
package org.jtalks.jcommune.plugin.api.web.validation.validators; import org.jtalks.jcommune.plugin.api.service.PluginBbCodeService; import org.jtalks.jcommune.plugin.api.web.validation.annotations.BbCodeAwareSize; import javax.validation.ConstraintValidator; import javax.validation.<API key>; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.<API key>; /** * Extends default @Size annotation to ignore BB codes in string. * As for now, applicable to string values only. * * @author Evgeniy Naumenko */ public class <API key> implements ConstraintValidator<BbCodeAwareSize, String>, <API key> { public static final String NEW_LINE_HTML = "<br/>"; public static final String QUOTE_HTML = "&quot"; public static final String <API key> = "\\[list\\][\n\r\\s]*(\\[\\*\\][\n\r\\s]*)*\\[\\/list\\]"; private int min; private int max; private ApplicationContext context; private PluginBbCodeService bbCodeService; @Autowired public <API key>(PluginBbCodeService bbCodeService) { this.bbCodeService = bbCodeService; } /** * {@inheritDoc} */ @Override public void initialize(BbCodeAwareSize <API key>) { this.min = <API key>.min(); this.max = <API key>.max(); } /** * The database stores both bb codes and symbols visible for users. * Post length with bb codes can't be greater than max value. * {@inheritDoc} */ @Override public boolean isValid(String value, <API key> context) { if (value != null) { String emptyListRemoved = removeEmptyListBb(value); String trimed = removeBBCodes(emptyListRemoved).trim(); int plainTextLength = getDisplayedLength(trimed); return plainTextLength >= min && value.length() <= max; } return false; } /** * Removes all BB codes from the text given, simply cutting * out all [...]-style tags found * * @param source text to cleanup * @return plain text without BB tags */ private String removeBBCodes(String source) { return getBBCodeService().stripBBCodes(source); } @Override public void <API key>(ApplicationContext ac) throws BeansException { this.context = ac; } private PluginBbCodeService getBBCodeService() { if (bbCodeService == null) { bbCodeService = this.context.getBean(PluginBbCodeService.class); } return bbCodeService; } /** * Calculate length of string which be displayed. * Needed because method <b>removeBBCodes</b> leaves "&quot" and "<br/>" symbols. * @param s String to calculate length. * @return Length of string which be displayed. */ private int getDisplayedLength(String s) { return s.replaceAll(QUOTE_HTML, "\"").replaceAll(NEW_LINE_HTML, "\n\r").length(); } /** * Removes all empty lists from text. Needed because <b>removeBBCodes</b> deletes * bb codes for list but not deletes bb codes for list elements. * @param text Text to remove empty lists. * @return Text without empty lists. */ private String removeEmptyListBb(String text) { return text.replaceAll(<API key>, ""); } }
Prism.languages.bbcode={tag:{pattern:/\[\/?[^\s=\]]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+))?(?:\s+[^\s=\]]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+))*\s*\]/,inside:{tag:{pattern:/^\[\/?[^\s=\]]+/,inside:{punctuation:/^\[\/?/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+)/i,inside:{punctuation:[/^=/,{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\]/,"attr-name":/[^\s=\]]+/}}},Prism.languages.shortcode=Prism.languages.bbcode;
#ifndef V8GCController_h #define V8GCController_h #include <v8.h> namespace WebCore { #ifndef NDEBUG #define <API key>(V) \ V(PROXY) \ V(NPOBJECT) \ V(SCHEDULED_ACTION) \ V(EVENT_LISTENER) \ V(NODE_FILTER) \ V(SCRIPTINSTANCE) \ V(SCRIPTVALUE) \ V(DATASOURCE) // Host information of persistent handles. enum GlobalHandleType { #define ENUM(name) name, <API key>(ENUM) #undef ENUM }; class GlobalHandleInfo { public: GlobalHandleInfo(void* host, GlobalHandleType type) : m_host(host), m_type(type) { } void* m_host; GlobalHandleType m_type; }; #endif // NDEBUG class V8GCController { public: #ifndef NDEBUG // For debugging and leak detection purpose. static void <API key>(GlobalHandleType, void*, v8::Persistent<v8::Value>); static void <API key>(void*, v8::Persistent<v8::Value>); #endif static void gcPrologue(); static void gcEpilogue(); static void checkMemoryUsage(); private: // Estimate of current working set. static int <API key>; }; } #endif // V8GCController_h
/* Try writing a file in the most normal way. */ #include <syscall.h> #include "tests/userprog/sample.inc" #include "tests/lib.h" #include "tests/main.h" void test_main (void) { int handle, byte_cnt; CHECK (create ("test.txt", sizeof sample - 1), "create \"test.txt\""); CHECK ((handle = open ("test.txt")) > 1, "open \"test.txt\""); byte_cnt = write (handle, sample, sizeof sample - 1); if (byte_cnt != sizeof sample - 1) fail ("write() returned %d instead of %zu", byte_cnt, sizeof sample - 1); }
package org.wso2.carbon.stratos.common.util; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.stratos.common.config.CloudServiceConfig; import org.wso2.carbon.stratos.common.config.<API key>; import org.wso2.carbon.stratos.common.config.PermissionConfig; import org.wso2.carbon.stratos.common.constants.StratosConstants; import org.wso2.carbon.stratos.common.internal.<API key>; import org.wso2.carbon.registry.core.Collection; import org.wso2.carbon.registry.core.RegistryConstants; import org.wso2.carbon.registry.core.Resource; import org.wso2.carbon.registry.core.session.UserRegistry; import org.wso2.carbon.user.core.UserStoreException; import org.wso2.carbon.utils.multitenancy.<API key>; public class CloudServicesUtil { private static final Log log = LogFactory.getLog(CloudServicesUtil.class); // TODO protect using Java security public static void activateAllServices(<API key> cloudServicesDesc, int tenantId) throws Exception { java.util.Collection<CloudServiceConfig> <API key> = cloudServicesDesc.<API key>(). values(); if (<API key> != null) { for (CloudServiceConfig cloudServiceConfig : <API key>) { if (cloudServiceConfig.isDefaultActive()) { String cloudServiceName = cloudServiceConfig.getName(); try { if (!CloudServicesUtil.<API key>(cloudServiceName, tenantId)) { CloudServicesUtil.<API key>(true, cloudServiceName, tenantId, cloudServicesDesc.<API key>(). get(cloudServiceName)); } } catch (Exception e) { String msg = "Error in activating the cloud service at the tenant" + "creation. tenant id: " + tenantId + ", service name: " + cloudServiceName; log.error(msg, e); throw new UserStoreException(msg, e); } } } } } public static void <API key>(<API key> cloudServicesDesc, String originalService, int tenantId) throws Exception { Map<String, CloudServiceConfig> cloudServiceConfigs = cloudServicesDesc.<API key>(); if (CloudServicesUtil.isServiceNameValid(cloudServicesDesc, originalService)) { if (!CloudServicesUtil.<API key>(originalService, tenantId)) { CloudServicesUtil.<API key>(true, originalService, tenantId, cloudServiceConfigs.get(originalService)); log.info("Successfully activated the " + originalService + " for the tenant " + tenantId); } // register the compulsory services if (!CloudServicesUtil.<API key>(StratosConstants.<API key>, tenantId)) { CloudServicesUtil.<API key>(true, StratosConstants.<API key>, tenantId, cloudServiceConfigs.get(StratosConstants.<API key>)); } if (!CloudServicesUtil.<API key>(StratosConstants.<API key>, tenantId)) { CloudServicesUtil.<API key>(true, StratosConstants.<API key>, tenantId, cloudServiceConfigs.get(StratosConstants.<API key>)); } } else { log.warn("Unable to activate the " + originalService + " for the tenant " + tenantId); } } public static void <API key>(boolean active, String cloudServiceName, int tenantId, CloudServiceConfig cloudServiceConfig) throws Exception { if (cloudServiceConfig.getLabel() == null) { // for the non-labled services, we are not setting/unsetting the // service active return; } UserRegistry govRegistry = <API key>.<API key>( <API key>.SUPER_TENANT_ID); UserRegistry configRegistry = <API key>.<API key>(tenantId); String <API key> = StratosConstants.<API key> + RegistryConstants.PATH_SEPARATOR + tenantId + RegistryConstants.PATH_SEPARATOR + cloudServiceName; Resource <API key>; if (govRegistry.resourceExists(<API key>)) { <API key> = govRegistry.get(<API key>); } else { <API key> = govRegistry.newCollection(); } <API key>.setProperty(StratosConstants.<API key>, active ? "true" : "false"); govRegistry.put(<API key>, <API key>); List<PermissionConfig> permissionConfigs = cloudServiceConfig.<API key>(); for (PermissionConfig permissionConfig : permissionConfigs) { String path = permissionConfig.getPath(); String name = permissionConfig.getName(); if (active) { if (!configRegistry.resourceExists(path)) { Collection collection = configRegistry.newCollection(); collection.setProperty(StratosConstants.DISPLAY_NAME, name); configRegistry.put(path, collection); } } else { if (configRegistry.resourceExists(path)) { configRegistry.delete(path); } } } } public static boolean <API key>(String cloudServiceName, int tenantId) throws Exception { UserRegistry govRegistry = <API key>.<API key>( <API key>.SUPER_TENANT_ID); return <API key>(cloudServiceName, tenantId, govRegistry); } public static boolean <API key>(String cloudServiceName, int tenantId, UserRegistry govRegistry) throws Exception { // The cloud manager is always active if (StratosConstants.<API key>.equals(cloudServiceName)) { return true; } String <API key> = StratosConstants.<API key> + RegistryConstants.PATH_SEPARATOR + tenantId + RegistryConstants.PATH_SEPARATOR + cloudServiceName; Resource <API key>; if (govRegistry.resourceExists(<API key>)) { <API key> = govRegistry.get(<API key>); String isActiveStr = <API key>.getProperty( StratosConstants.<API key>); return "true".equals(isActiveStr); } return false; } public static boolean isServiceNameValid(<API key> cloudServicesDesc, String cloudServiceName) { if(cloudServiceName == null) { return false; } java.util.Collection<CloudServiceConfig> <API key> = cloudServicesDesc.<API key>().values(); if (cloudServiceName.equals(StratosConstants.<API key>)) { return false; } for (CloudServiceConfig cloudServiceConfig : <API key>) { if (cloudServiceConfig.getName().equals(cloudServiceName)) { return true; } } return false; } }
class A[+T, -U] val z: A[T, U] forSome {type T <: Int; type U >: Int} = new A[Int, Int] val o: A[Int, Float] = z //False
// <API key>: Apache-2.0 WITH LLVM-exception #include "llvm/Remarks/Remark.h" #include "llvm/Remarks/RemarkStringTable.h" #include "gtest/gtest.h" using namespace llvm; TEST(RemarksAPI, Comparison) { remarks::Remark R; R.RemarkType = remarks::Type::Missed; R.PassName = "pass"; R.RemarkName = "name"; R.FunctionName = "func"; R.Loc = remarks::RemarkLocation{"path", 3, 4}; R.Hotness = 5; R.Args.emplace_back(); R.Args.back().Key = "key"; R.Args.back().Val = "value"; R.Args.emplace_back(); R.Args.back().Key = "keydebug"; R.Args.back().Val = "valuedebug"; R.Args.back().Loc = remarks::RemarkLocation{"argpath", 6, 7}; // Check that == works. EXPECT_EQ(R, R); // Check that != works. remarks::Remark R2 = R.clone(); R2.FunctionName = "func0"; EXPECT_NE(R, R2); // Check that we iterate through all the arguments. remarks::Remark R3 = R.clone(); R3.Args.back().Val = "not"; EXPECT_NE(R, R3); } TEST(RemarksAPI, Clone) { remarks::Remark R; R.RemarkType = remarks::Type::Missed; R.PassName = "pass"; R.RemarkName = "name"; R.FunctionName = "func"; R.Loc = remarks::RemarkLocation{"path", 3, 4}; R.Hotness = 5; R.Args.emplace_back(); R.Args.back().Key = "key"; R.Args.back().Val = "value"; R.Args.emplace_back(); R.Args.back().Key = "keydebug"; R.Args.back().Val = "valuedebug"; R.Args.back().Loc = remarks::RemarkLocation{"argpath", 6, 7}; // Check that clone works. remarks::Remark R2 = R.clone(); EXPECT_EQ(R, R2); } TEST(RemarksAPI, ArgsAsMsg) { remarks::Remark R; R.RemarkType = remarks::Type::Missed; R.Args.emplace_back(); R.Args.back().Key = "key"; R.Args.back().Val = "can not do this "; R.Args.emplace_back(); R.Args.back().Key = "keydebug"; R.Args.back().Val = "because of that."; R.Args.back().Loc = remarks::RemarkLocation{"argpath", 6, 7}; EXPECT_EQ(R.getArgsAsMsg(), "can not do this because of that."); } TEST(RemarksAPI, <API key>) { remarks::StringTable StrTab; // Empty table. EXPECT_EQ(StrTab.SerializedSize, 0UL); remarks::Remark R; R.RemarkType = remarks::Type::Missed; R.PassName = "pass"; R.RemarkName = "name"; R.FunctionName = "func"; R.Loc = remarks::RemarkLocation{"path", 3, 4}; R.Args.emplace_back(); R.Args.back().Key = "keydebug"; R.Args.back().Val = "valuedebug"; R.Args.back().Loc = remarks::RemarkLocation{"argpath", 6, 7}; // Check that internalize starts using the strings from the string table. remarks::Remark R2 = R.clone(); StrTab.internalize(R2); // Check that the pointers in the remarks are different. EXPECT_NE(R.PassName.data(), R2.PassName.data()); EXPECT_NE(R.RemarkName.data(), R2.RemarkName.data()); EXPECT_NE(R.FunctionName.data(), R2.FunctionName.data()); EXPECT_NE(R.Loc->SourceFilePath.data(), R2.Loc->SourceFilePath.data()); EXPECT_NE(R.Args.back().Key.data(), R2.Args.back().Key.data()); EXPECT_NE(R.Args.back().Val.data(), R2.Args.back().Val.data()); EXPECT_NE(R.Args.back().Loc->SourceFilePath.data(), R2.Args.back().Loc->SourceFilePath.data()); // Check that the internalized remark is using the pointers from the string table. EXPECT_EQ(StrTab.add(R.PassName).second.data(), R2.PassName.data()); EXPECT_EQ(StrTab.add(R.RemarkName).second.data(), R2.RemarkName.data()); EXPECT_EQ(StrTab.add(R.FunctionName).second.data(), R2.FunctionName.data()); EXPECT_EQ(StrTab.add(R.Loc->SourceFilePath).second.data(), R2.Loc->SourceFilePath.data()); EXPECT_EQ(StrTab.add(R.Args.back().Key).second.data(), R2.Args.back().Key.data()); EXPECT_EQ(StrTab.add(R.Args.back().Val).second.data(), R2.Args.back().Val.data()); EXPECT_EQ(StrTab.add(R.Args.back().Loc->SourceFilePath).second.data(), R2.Args.back().Loc->SourceFilePath.data()); }
<?php include_once dirname(__FILE__).'/../../bootstrap/unit.php'; class myQuery extends opDoctrineQuery { public static $lastQueryCacheHash = ''; public function <API key>() { self::$lastQueryCacheHash = parent::<API key>(); return self::$lastQueryCacheHash; } } $_app = 'pc_frontend'; $_env = 'test'; $configuration = <API key>::<API key>($_app, $_env, true); new sfDatabaseManager($configuration); Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_QUERY_CLASS, 'myQuery'); $t = new lime_test(null, new lime_output_color()); $keys = array(); Doctrine::getTable('AdminUser')->find(1); $keys['find'] = myQuery::$lastQueryCacheHash; Doctrine::getTable('AdminUser')->findAll(); $keys['find_all'] = myQuery::$lastQueryCacheHash; Doctrine::getTable('AdminUser')->findById(1); $keys['find_by_id'] = myQuery::$lastQueryCacheHash; Doctrine::getTable('AdminUser')->findOneById(1); $keys['find_one_by_id'] = myQuery::$lastQueryCacheHash; Doctrine::getTable('AdminUser')->findByIdAndUsername(1, 'admin'); $keys['<API key>'] = myQuery::$lastQueryCacheHash; Doctrine::getTable('AdminUser')-><API key>(1, 'admin'); $keys['<API key>'] = myQuery::$lastQueryCacheHash; Doctrine::getTable('AdminUser')-><API key>('admin', 'password'); $keys['<API key>'] = myQuery::$lastQueryCacheHash; Doctrine::getTable('AdminUser')-><API key>('admin', 'password'); $keys['<API key>'] = myQuery::$lastQueryCacheHash; $t->isnt($keys['find'], $keys['find_all'], '->find() and ->findAll() generates different query cache keys'); $t->isnt($keys['find'], $keys['find_by_id'], '->find() and ->findById() generates different query cache keys'); $t->is($keys['find'], $keys['find_one_by_id'], '->find() and ->findOneById() generates same query cache keys'); $t->isnt($keys['find'], $keys['<API key>'], '->find() and ->findByIdAndUsername() generates different query cache keys'); $t->isnt($keys['find'], $keys['<API key>'], '->find() and -><API key>() generates different query cache keys'); $t->isnt($keys['find'], $keys['<API key>'], '->find() and -><API key>() generates different query cache keys'); $t->isnt($keys['find'], $keys['<API key>'], '->find() and -><API key>() generates different query cache keys'); $t->isnt($keys['find_all'], $keys['find_by_id'], '->findAll() and ->findById() generates different query cache keys'); $t->isnt($keys['find_all'], $keys['find_one_by_id'], '->findAll() and ->findOneById() generates different query cache keys'); $t->isnt($keys['find_all'], $keys['<API key>'], '->findAll() and ->findByIdAndUsername() generates different query cache keys'); $t->isnt($keys['find_all'], $keys['<API key>'], '->findAll() and -><API key>() generates different query cache keys'); $t->isnt($keys['find_all'], $keys['<API key>'], '->findAll() and -><API key>() generates different query cache keys'); $t->isnt($keys['find_all'], $keys['<API key>'], '->findAll() and -><API key>() generates different query cache keys'); $t->isnt($keys['find_by_id'], $keys['find_one_by_id'], '->findById() and ->findOneById() generates different query cache keys'); $t->isnt($keys['find_by_id'], $keys['<API key>'], '->findById() and ->findByIdAndUsername() generates different query cache keys'); $t->isnt($keys['find_by_id'], $keys['<API key>'], '->findById() and ->findOneById() generates different query cache keys'); $t->isnt($keys['find_by_id'], $keys['<API key>'], '->findById() and -><API key>() generates different query cache keys'); $t->isnt($keys['find_by_id'], $keys['<API key>'], '->findById() and -><API key>() generates different query cache keys'); $t->isnt($keys['find_one_by_id'], $keys['<API key>'], '->findOneById() and ->findByIdAndUsername() generates different query cache keys'); $t->isnt($keys['find_one_by_id'], $keys['<API key>'], '->findOneById() and -><API key>() generates different query cache keys'); $t->isnt($keys['find_one_by_id'], $keys['<API key>'], '->findOneById() and -><API key>() generates different query cache keys'); $t->isnt($keys['find_one_by_id'], $keys['<API key>'], '->findOneById() and -><API key>() generates different query cache keys'); $t->isnt($keys['<API key>'], $keys['<API key>'], '->findByIdAndUsername() and -><API key>() generates different query cache keys'); $t->isnt($keys['<API key>'], $keys['<API key>'], '->findByIdAndUsername() and -><API key>() generates different query cache keys'); $t->isnt($keys['<API key>'], $keys['<API key>'], '->findByIdAndUsername() and -><API key>() generates different query cache keys'); $t->isnt($keys['<API key>'], $keys['<API key>'], '-><API key>() and -><API key>() generates different query cache keys'); $t->isnt($keys['<API key>'], $keys['<API key>'], '-><API key>() and -><API key>() generates different query cache keys'); $t->isnt($keys['<API key>'], $keys['<API key>'], '-><API key>() and -><API key>() generates different query cache keys');
cask 'wifispoof' do version '3.4.3' sha256 '<SHA256-like>' # sweetpproductions.com/products was verified as official when first introduced to the cask url "https://sweetpproductions.com/products/wifispoof#{version.major}/WiFiSpoof#{version.major}.dmg" appcast "https://sweetpproductions.com/products/wifispoof#{version.major}/appcast.xml" name 'WiFiSpoof' homepage 'https://wifispoof.com/' auto_updates true app 'WiFiSpoof.app' end
# -*- coding: utf-8 -*- import os from operator import itemgetter from gluon.storage import Storage from gluon.dal import DAL, Field, Row DBHOST = os.environ.get('DBHOST', 'localhost') DATABASE_URI = 'mysql://benchmarkdbuser:benchmarkdbpass@%s:3306/hello_world' % DBHOST class Dal(object): def __init__(self, table=None, pool_size=8): self.db = DAL(DATABASE_URI, migrate_enabled=False, pool_size=pool_size) if table == 'World': self.db.define_table('World', Field('randomNumber', 'integer')) elif table == 'Fortune': self.db.define_table('Fortune', Field('message')) def get_world(self, wid): # Setting `cacheable=True` improves performance by foregoing the creation # of some non-essential attributes. It does *not* actually cache the # database results (it simply produces a Rows object that *could be* cached). return self.db(self.db.World.id == wid).select(cacheable=True)[0].as_dict() def update_world(self, wid, randomNumber): self.db(self.db.World.id == wid).update(randomNumber=randomNumber) def get_fortunes(self, new_message): fortunes = self.db(self.db.Fortune).select(cacheable=True) fortunes.records.append(Row(new_message)) return fortunes.sort(itemgetter('message')) class RawDal(Dal): def __init__(self): super(RawDal, self).__init__() self.world_updates = [] def get_world(self, wid): return self.db.executesql('SELECT * FROM World WHERE id = %s', placeholders=[wid], as_dict=True)[0] def update_world(self, wid, randomNumber): self.world_updates.extend([randomNumber, wid]) def flush_world_updates(self): query = ';'.join('UPDATE World SET randomNumber=%s WHERE id=%s' for _ in xrange(len(self.world_updates) / 2)) self.db.executesql(query, placeholders=self.world_updates) def get_fortunes(self, new_message): fortunes = self.db.executesql('SELECT * FROM Fortune', as_dict=True) fortunes.append(new_message) return sorted(fortunes, key=itemgetter('message')) def num_queries(queries): try: num = int(queries) return 1 if num < 1 else 500 if num > 500 else num except ValueError: return 1
<!DOCTYPE html> <! Copyright (c) 2012 Intel Corporation. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of works must retain the original copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the original copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this work without specific prior written permission. THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Authors: Cao, Jun <junx.cao@intel.com> <html> <head> <title>WebGL Test: <API key></title> <link rel="author" title="Intel" href="http: <link rel="help" href="https: <meta name="flags" content="" /> <meta name="assert" content="Check if <API key>.<API key> exists"/> <script src="../resources/testharness.js"></script> <script src="../resources/testharnessreport.js"></script> <script src="support/webgl.js"></script> </head> <body> <div id="log"></div> <canvas id="canvas" width="200" height="100" style="border:1px solid #c3c3c3;"> Your browser does not support the canvas element. </canvas> <script> getwebgl(); <API key>(webgl, '<API key>'); </script> </body> </html>
#include "config.h" #include "core/rendering/RenderApplet.h" #include "core/frame/UseCounter.h" #include "core/html/HTMLAppletElement.h" namespace blink { RenderApplet::RenderApplet(HTMLAppletElement* applet) : <API key>(applet) { setInline(true); UseCounter::count(document(), UseCounter::HTMLAppletElement); } RenderApplet::~RenderApplet() { } } // namespace blink
<!DOCTYPE html> <!-- this file is auto-generated. DO NOT EDIT. <html> <head> <meta charset="utf-8"> <title>WebGL GLSL conformance test: <API key>.html</title> <link rel="stylesheet" href="../../../../resources/js-test-style.css" /> <link rel="stylesheet" href="../../../resources/ogles-tests.css" /> <script src="../../../../resources/js-test-pre.js"></script> <script src="../../../resources/webgl-test-utils.js"></script> <script src="../../ogles-utils.js"></script> </head> <body> <canvas id="example" width="500" height="500" style="width: 16px; height: 16px;"></canvas> <div id="description"></div> <div id="console"></div> </body> <script> "use strict"; OpenGLESTestRunner.run({ "tests": [ { "referenceProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "../default/default.frag" }, "model": null, "testProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "<API key>.frag" }, "name": "<API key>.test.html", "pattern": "compare" }, { "referenceProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "../default/default.frag" }, "model": "grid", "testProgram": { "vertexShader": "<API key>.vert", "fragmentShader": "../default/default.frag" }, "name": "<API key>.test.html", "pattern": "compare" }, { "referenceProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "../default/default.frag" }, "model": null, "testProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "<API key>.frag" }, "name": "<API key>.test.html", "pattern": "compare" }, { "referenceProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "../default/default.frag" }, "model": "grid", "testProgram": { "vertexShader": "<API key>.vert", "fragmentShader": "../default/default.frag" }, "name": "<API key>.test.html", "pattern": "compare" }, { "referenceProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "../default/default.frag" }, "model": null, "testProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "<API key>.frag" }, "name": "<API key>.test.html", "pattern": "compare" }, { "referenceProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "../default/default.frag" }, "model": "grid", "testProgram": { "vertexShader": "<API key>.vert", "fragmentShader": "../default/default.frag" }, "name": "<API key>.test.html", "pattern": "compare" }, { "referenceProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "../default/default.frag" }, "model": null, "testProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "<API key>.frag" }, "name": "<API key>.test.html", "pattern": "compare" }, { "referenceProgram": { "vertexShader": "../default/default.vert", "fragmentShader": "../default/default.frag" }, "model": "grid", "testProgram": { "vertexShader": "<API key>.vert", "fragmentShader": "../default/default.frag" }, "name": "<API key>.test.html", "pattern": "compare" } ] }); var successfullyParsed = true; </script> </html>
<!doctype html> <meta charset="utf-8"> <title>@layer rule parsing / serialization</title> <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> <link rel="author" title="Mozilla" href="https://mozilla.org"> <link rel="help" href="https://drafts.csswg.org/css-cascade-5/#layering"> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="/css/support/parsing-testcommon.js"></script> <script> test_valid_rule("@layer A;"); test_valid_rule("@layer A, B, C;"); test_valid_rule("@layer A.A;"); test_valid_rule("@layer A, B.C.D, C;"); test_invalid_rule("@layer;"); test_invalid_rule("@layer A . A;"); test_valid_rule("@layer {\n}"); test_valid_rule("@layer A {\n}"); test_valid_rule("@layer A.B {\n}"); test_invalid_rule("@layer A . B {\n}"); test_invalid_rule("@layer A, B, C {\n}"); </script>
#include "ui/compositor/test/<API key>.h" #include "base/basictypes.h" #include "base/bind.h" #include "base/compiler_specific.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/<API key>.h" #include "ui/compositor/compositor.h" #include "ui/gfx/geometry/rect.h" namespace ui { class <API key> : public TestCompositorHost { public: <API key>(const gfx::Rect& bounds, ui::ContextFactory* context_factory); ~<API key>() override; private: // Overridden from TestCompositorHost: void Show() override; ui::Compositor* GetCompositor() override; gfx::Rect bounds_; ui::ContextFactory* context_factory_; scoped_ptr<ui::Compositor> compositor_; <API key>(<API key>); }; <API key>::<API key>( const gfx::Rect& bounds, ui::ContextFactory* context_factory) : bounds_(bounds), context_factory_(context_factory) {} <API key>::~<API key>() {} void <API key>::Show() { // Ozone should rightly have a backing native framebuffer // An in-memory array draw into by OSMesa is a reasonble // fascimile of a dumb framebuffer at present. // GLSurface will allocate the array so long as it is provided // with a non-0 widget. // TODO(rjkroege): Use a "real" ozone widget when it is compositor_.reset(new ui::Compositor(1, context_factory_, base::<API key>::Get())); compositor_->SetScaleAndSize(1.0f, bounds_.size()); } ui::Compositor* <API key>::GetCompositor() { return compositor_.get(); } // static TestCompositorHost* TestCompositorHost::Create( const gfx::Rect& bounds, ui::ContextFactory* context_factory) { return new <API key>(bounds, context_factory); } } // namespace ui
'use strict'; // This file relies on the fact that the following declaration has been made // in runtime.js: // var $Array = global.Array; // Proposed for ES7 // <SHA1-like> function ArrayIncludes(searchElement, fromIndex) { var array = ToObject(this); var len = ToLength(array.length); if (len === 0) { return false; } var n = ToInteger(fromIndex); var k; if (n >= 0) { k = n; } else { k = len + n; if (k < 0) { k = 0; } } while (k < len) { var elementK = array[k]; if (SameValueZero(searchElement, elementK)) { return true; } ++k; } return false; } function <API key>() { %<API key>(); %FunctionSetLength(ArrayIncludes, 1); // Set up the non-enumerable functions on the Array prototype object. InstallFunctions($Array.prototype, DONT_ENUM, $Array( "includes", ArrayIncludes )); } <API key>();
<! THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. Copyright (c) Microsoft Corporation. All rights reserved <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>News</title> <!-- WinJS references --> <link href="/Microsoft.WinJS.4.0/css/ui-dark.css" rel="stylesheet" /> <script src="/Microsoft.WinJS.4.0/js/WinJS.js"></script> <link href="/css/default.css" rel="stylesheet" /> <link href="/pages/news/news.css" rel="stylesheet" /> <script src="/pages/news/news.js"></script> </head> <body> <!-- Template for the feed header --> <div id="feedHeaderTemplate" data-win-control="WinJS.Binding.Template" data-win-options="{extractChild: true}"> <button class="group-header win-type-x-large <API key>" data-win-bind="groupKey: key" role="link"> <span class="group-title win-type-x-large win-type-ellipsis" data-win-bind="innerText: title;" ></span> <span class="group-chevron"></span> </button> </div> <!-- Template for the image article item --> <div id="<API key>" data-win-control="WinJS.Binding.Template" data-win-options="{extractChild: true}"> <div data-win-bind="className: tileType"> <div class="image" data-win-bind="style.background: imageBackground"></div> <div class="overlay"> <h4 class="title" data-win-bind="innerText: title"></h4> </div> </div> </div> <!-- Template for the text article item --> <div id="textArticleTemplate" data-win-control="WinJS.Binding.Template" data-win-options="{extractChild: true}"> <div data-win-bind="className: tileType"> <h2 class="title" data-win-bind="innerText: title"></h2> </div> </div> <!-- Template for feed error --> <div id="errorTemplate" data-win-control="WinJS.Binding.Template"> <div data-win-bind="className: tileType"> <h2 class="error" data-win-bind="innerText: error"></h2> </div> </div> <!-- Template for the feed item --> <div id="feedTileTemplate" data-win-control="WinJS.Binding.Template" data-win-options="{extractChild: true}"> <div class="feedTile"> <h2 class="title" data-win-bind="innerText: title"></h2> </div> </div> <!-- The content that will be loaded and displayed. --> <div id="news" class="fragment"> <header aria-label="Header content" role="banner"> <h1 class="titlearea win-type-ellipsis"> <span class="pagetitle">News</span> </h1> </header> <section aria-label="Main content" role="main"> <div id="errorDiv"></div> <div id="<API key>" data-win-control="WinJS.UI.SemanticZoom"> <!-- The control that provides the zoomed-in view. --> <div id="articlesListView-in" aria-label="List of articles" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'none' }"></div> <!-- The control that provides the zoomed-out view. --> <div id="<API key>" aria-label="List of feeds" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'none', tapBehavior: 'invokeOnly' }"> </div> </div> </section> </div> </body> </html>
<!DOCTYPE html> <! - THE HEAD PART - <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>SLIDER REVOLUTION - The Responsive Slider jQuery Plugin</title> <link rel="icon" type="image/png" href="images/sitelogo.png" /> <!-- commented, remove this line to use IE & iOS favicons --> <link rel="shortcut icon" href="images/favicon.ico" /> <!-- get jQuery from the google apis --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.js?ver=3.4.2'></script> <!-- CSS STYLE --> <link rel="stylesheet" type="text/css" href="css/style.css" media="screen" /> <link rel="stylesheet" type="text/css" href="css/preview.css" media="screen" /> <!-- jQuery KenBurn Slider --> <script type="text/javascript" src="rs-plugin/js/jquery.themepunch.plugins.min.js"></script> <script type="text/javascript" src="rs-plugin/js/jquery.themepunch.revolution.min.js"></script> <!-- MODULES ONLY FOR THE DEMONSTATION --> <script type="text/javascript" src="previewjs/preview-normal.js"></script> <!-- REVOLUTION BANNER CSS SETTINGS --> <link rel="stylesheet" type="text/css" href="rs-plugin/css/settings.css" media="screen" /> <link rel="stylesheet" type="text/css" href="rs-plugin/css/captions.css" media="screen" /> <!-- GOOGLE FONTS --> <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,800,300,600' rel='stylesheet' type='text/css'> </head> <! - THE BODY PART - <body class="body-dark"> <! <div id="debug" style="position:fixed; top:10px; left:10px; background:#000; color:#efefef; width:100px; height:100px;z-index:10000;"></div> <div class="header"> <!-- LOGO AND BUY BUTTON --> <div class="left"> <div class="logo"></div> </div> <div class="right"> <a href="http://codecanyon.net/item/<API key>/2580848"><div class="purchase"><div class="purchase-inside">BUY NOW <strong>FOR $15</strong></div></div></a> </div> <div class="clear"></div> <div class="divider"></div> <!-- MENU --> <div class="menu"> <div class="left"> <a class="menupoint red"href="index.html">RESPONSIVE</a> <a class="menupoint"href="index-fullwidth.html">FULL-WIDTH</a> <a class="menupoint"href="index-static.html">FIXED</a> </div> <div class="right"> <a class="menupoint red"href="index.html">HOW TO GET STARTED?</a> </div> <div class="clear"></div> </div> <div class="divider"></div> </div> <div class="space30"></div> <! - THEMEPUNCH BANNER - <div class="bannercontainer responsive"> <div class="banner"> <ul> <!-- THE FIRST SLIDE --> <li data-transition="3dcurtain-vertical" data-slotamount="10" data-masterspeed="300" data-thumb="images/thumbs/thumb1.jpg"> <!-- THE MAIN IMAGE IN THE SLIDE --> <img src="images/slides/slide13.jpg" > <!-- THE CAPTIONS OF THE FIRST SLIDE --> <div class="caption large_text sfb" data-x="44" data-y="47" data-speed="300" data-start="800" data-easing="easeOutExpo" >OVER <span style="color: #ffcc00;">1000</span> SATISFIED CUSTOMERS</div> <div class="caption randomrotate" data-x="48" data-y="131" data-speed="600" data-start="1100" data-easing="easeOutExpo" ><img src="images/slides/p1.jpg" alt="Image 2"></div> <div class="caption randomrotate" data-x="90" data-y="206" data-speed="600" data-start="1200" data-easing="easeOutExpo" ><img src="images/slides/p2.jpg" alt="Image 3"></div> <div class="caption randomrotate" data-x="205" data-y="140" data-speed="600" data-start="1300" data-easing="easeOutExpo" ><img src="images/slides/p3.jpg" alt="Image 4"></div> <div class="caption randomrotate" data-x="188" data-y="246" data-speed="300" data-start="1400" data-easing="easeOutExpo" ><img src="images/slides/p4.jpg" alt="Image 5"></div> <div class="caption randomrotate" data-x="55" data-y="316" data-speed="600" data-start="1500" data-easing="easeOutExpo" ><img src="images/slides/p5.jpg" alt="Image 6"></div> <div class="caption randomrotate" data-x="173" data-y="329" data-speed="300" data-start="1600" data-easing="easeOutExpo" ><img src="images/slides/p6.jpg" alt="Image 7"></div> <div class="caption randomrotate" data-x="255" data-y="294" data-speed="300" data-start="1700" data-easing="easeOutExpo" ><img src="images/slides/p7.jpg" alt="Image 8"></div> <div class="caption randomrotate" data-x="275" data-y="166" data-speed="300" data-start="1800" data-easing="easeOutExpo" ><img src="images/slides/p8.jpg" alt="Image 9"></div> <div class="caption randomrotate" data-x="84" data-y="113" data-speed="300" data-start="1900" data-easing="easeOutExpo" ><img src="images/slides/p9.jpg" alt="Image 10"></div> <div class="caption randomrotate" data-x="26" data-y="225" data-speed="300" data-start="2000" data-easing="easeOutExpo" ><img src="images/slides/p10.jpg" alt="Image 11"></div> <div class="caption randomrotate" data-x="110" data-y="187" data-speed="300" data-start="2100" data-easing="easeOutExpo" ><img src="images/slides/p11.jpg" alt="Image 12"></div> <div class="caption randomrotate" data-x="183" data-y="221" data-speed="300" data-start="2200" data-easing="easeOutExpo" ><img src="images/slides/p12.jpg" alt="Image 13"></div> </li> <!-- THE SECOND SLIDE --> <li data-transition="papercut" data-slotamount="15" data-masterspeed="300" data-delay="9400" data-thumb="images/thumbs/thumb2.jpg"> <img src="images/slides/slide21.jpg" > <div class="caption very_big_white lfl stl" data-x="18" data-y="293" data-speed="300" data-start="500" data-easing="easeOutExpo" data-end="8800" data-endspeed="300" data-endeasing="easeInSine" >TIMELINED CAPTIONS</div> <div class="caption big_white lfl stl" data-x="18" data-y="333" data-speed="300" data-start="800" data-easing="easeOutExpo" data-end="9100" data-endspeed="300" data-endeasing="easeInSine" >MOVE CAPTIONS IN AND OUT ON ONE SLIDE</div> <div class="caption lft ltb" data-x="500" data-y="0" data-speed="600" data-start="1100" data-easing="easeOutExpo" data-end="3100" data-endspeed="600" data-endeasing="easeInSine" ><img src="images/slides/drink1.jpg" alt="Image 3"></div> <div class="caption bold_red_text sft stb" data-x="720" data-y="290" data-speed="300" data-start="1400" data-easing="easeOutExpo" data-end="3300" data-endspeed="300" data-endeasing="easeInSine" >STRAWBERRY COCTAIL</div> <div class="caption big_black sfb stb" data-x="720" data-y="320" data-speed="300" data-start="1700" data-easing="easeOutExpo" data-end="3200" data-endspeed="300" data-endeasing="easeInSine" >$ 7.49</div> <div class="caption lft ltb" data-x="500" data-y="0" data-speed="600" data-start="3600" data-easing="easeOutExpo" data-end="5600" data-endspeed="600" data-endeasing="easeInSine" ><img src="images/slides/drink2.jpg" alt="Image 6"></div> <div class="caption bold_brown_text sft stb" data-x="720" data-y="290" data-speed="300" data-start="3900" data-easing="easeOutExpo" data-end="5800" data-endspeed="300" data-endeasing="easeInSine" >COKE & RUM</div> <div class="caption big_black sfb stb" data-x="720" data-y="320" data-speed="300" data-start="4200" data-easing="easeOutExpo" data-end="5700" data-endspeed="300" data-endeasing="easeInSine" >$ 5.99</div> <div class="caption lft ltb" data-x="500" data-y="0" data-speed="600" data-start="6100" data-easing="easeOutExpo" data-end="8100" data-endspeed="300" data-endeasing="easeInSine" ><img src="images/slides/drink3.jpg" alt="Image 9"></div> <div class="caption bold_green_text sft stb" data-x="720" data-y="290" data-speed="300" data-start="6400" data-easing="easeOutExpo" data-end="8300" data-endspeed="300" data-endeasing="easeInSine" >MOJITO COCTAIL</div> <div class="caption big_black sfb stb" data-x="720" data-y="320" data-speed="300" data-start="6700" data-easing="easeOutExpo" data-end="8200" data-endspeed="300" data-endeasing="easeInSine" >$ 6.79</div> </li> <li data-transition="turnoff" data-slotamount="1" data-masterspeed="300" > <img src="images/slides/slide31.jpg" > <div class="caption large_text fade" data-x="509" data-y="290" data-speed="300" data-start="800" data-easing="easeOutExpo" ></div> <div class="caption <API key> randomrotate" data-x="641" data-y="95" data-speed="300" data-start="1100" data-easing="easeOutExpo" >SLIDER</div> <div class="caption large_black_text randomrotate" data-x="642" data-y="161" data-speed="300" data-start="1400" data-easing="easeOutExpo" >REVOLUTION</div> <div class="caption bold_red_text randomrotate" data-x="645" data-y="201" data-speed="300" data-start="1700" data-easing="easeOutExpo" >GOT FULLSCREEN VIDEO</div> <div class="caption sfb" data-x="640" data-y="223" data-speed="300" data-start="2000" data-easing="easeOutBack" ><img src="images/slides/video.jpg" alt="Image 7"></div> <div class="caption sft" data-x="639" data-y="383" data-speed="300" data-start="2300" data-easing="easeOutExpo" data-linktoslide="4" ><img src="images/slides/videobutton.jpg" alt="Image 8"></div> </li> <!-- THE THIRD SLIDE --> <li data-transition="slidedown" data-slotamount="7" data-masterspeed="300" data-thumb="images/thumbs/thumb4.jpg"> <img src="images/slides/black.jpg" > <div class="caption fade fullscreenvideo" data-autoplay="false" data-x="0" data-y="0" data-speed="500" data-start="10" data-easing="easeOutBack"><iframe src="http://player.vimeo.com/video/22775048?title=0&amp;byline=0&amp;portrait=0;api=1" width="100%" height="100%"></iframe></div> <div class="caption big_white sft stt" data-x="327" data-y="25" data-speed="300" data-start="500" data-easing="easeOutExpo" data-end="4000" data-endspeed="300" data-endeasing="easeInSine" >Have Fun Watching the Video</div> </li> <!-- THE FOURTH SLIDE --> <li data-transition="slideleft" data-slotamount="1" data-masterspeed="300" data-thumb="images/thumbs/thumb5.jpg"> <img src="images/slides/slide4.jpg" > <div class="caption large_text sft" data-x="50" data-y="44" data-speed="300" data-start="800" data-easing="easeOutExpo" >TOUCH ENABLED</div> <div class="caption medium_text sfl" data-x="79" data-y="82" data-speed="300" data-start="1100" data-easing="easeOutExpo" >AND</div> <div class="caption large_text sfr" data-x="128" data-y="78" data-speed="300" data-start="1100" data-easing="easeOutExpo" ><span style="color: #ffc600;">RESPONSIVE</span></div> <div class="caption lfl" data-x="53" data-y="192" data-speed="300" data-start="1400" data-easing="easeOutExpo" ><img src="images/slides/imac.png" alt="Image 4"></div> <div class="caption lfl" data-x="253" data-y="282" data-speed="300" data-start="1500" data-easing="easeOutExpo" ><img src="images/slides/ipad.png" alt="Image 5"></div> <div class="caption lfl" data-x="322" data-y="313" data-speed="300" data-start="1600" data-easing="easeOutExpo" ><img src="images/slides/iphone.png" alt="Image 6"></div> </li> <!-- THE FIFTH SLIDE --> <li data-transition="flyin" data-slotamount="1" data-masterspeed="300" data-thumb="images/thumbs/thumb6.jpg"> <img src="images/slides/slide51.jpg" > <div class="caption large_text sfl" data-x="38" data-y="200" data-speed="300" data-start="1000" data-easing="easeOutExpo" >A Happy</div> <div class="caption large_text sfl" data-x="37" data-y="243" data-speed="300" data-start="1300" data-easing="easeOutExpo" >Holiday Season</div> <div class="caption randomrotate" data-x="610" data-y="174" data-speed="800" data-start="1600" data-easing="easeOutExpo" ><img src="images/slides/TP_logo.png" alt="Image 4"></div> </li> </ul> <div class="tp-bannertimer"></div> </div> </div> <div id="unvisible_button"></div> <div class="space30"></div> <div class="configurator"> <!-- THE 1ST CONFIG FIELD -- TRANSITIONS --> <div class="one_third"> <table> <tbody> <tr> <td class="config_title">1</td> <td class="divider"></td> </tr> </tbody> </table> <div class="space15"></div> <div class="conftitle">TRANSITION <span>(TAKES IMMEDIATE EFFECT)</span></div> <div class="selecter"> <div class="dropdown"> <div class="dropcontent">Select a Transition Type</div> <div class="dropbutton"></div> <div class="clear"></div> </div> <select class="selecttransition"> <option value="Demo">ORIGINAL PREVIEW</option> <option value="random">&nbsp;&nbsp;&nbsp;Random Transitions</option> <option value="random-standard">STANDARD</option> <option value="boxslide">&nbsp;&nbsp;&nbsp;Box Mask</option> <option value="boxfade">&nbsp;&nbsp;&nbsp;Box Mask Mosaic</option> <option value="slotzoom-horizontal">&nbsp;&nbsp;&nbsp;Slot Zoom Horizontal</option> <option value="<API key>">&nbsp;&nbsp;&nbsp;Slot Slide Horizontal</option> <option value="slotfade-horizontal">&nbsp;&nbsp;&nbsp;Slot Fade Horizontal</option> <option value="slotzoom-vertical">&nbsp;&nbsp;&nbsp;Slot Zoom Vertical</option> <option value="slotslide-vertical">&nbsp;&nbsp;&nbsp;Slot Slide Vertical</option> <option value="slotfade-vertical">&nbsp;&nbsp;&nbsp;Slot Fade Vertical</option> <option value="curtain-1">&nbsp;&nbsp;&nbsp;Curtain One</option> <option value="curtain-2">&nbsp;&nbsp;&nbsp;Curtain Two</option> <option value="curtain-3">&nbsp;&nbsp;&nbsp;Curtain Three</option> <option value="slideleft">&nbsp;&nbsp;&nbsp;Slide Left</option> <option value="slideright">&nbsp;&nbsp;&nbsp;Slide Right</option> <option value="slideup">&nbsp;&nbsp;&nbsp;Slide Up</option> <option value="slidedown">&nbsp;&nbsp;&nbsp;Slide Down</option> <option value="fade">&nbsp;&nbsp;&nbsp;Fade</option> <option value="random-premium">PREMIUM</option> <option value="flyin">&nbsp;&nbsp;&nbsp;Fly In</option> <option value="cubic">&nbsp;&nbsp;&nbsp;Cubic</option> <option value="turnoff">&nbsp;&nbsp;&nbsp;Turn Off</option> <option value="<API key>">&nbsp;&nbsp;&nbsp;3D Curtain Horizontal</option> <option value="3dcurtain-vertical">&nbsp;&nbsp;&nbsp;3D Curtain Vertical</option> <option value="papercut">&nbsp;&nbsp;&nbsp;Paper Cut</option> </select> </div> </div> <!-- THE 2ND CONFIG FIELD -- ROTATOR --> <div class="one_third"> <table> <tbody> <tr> <td class="config_title">2</td> <td class="divider"></td> </tr> </tbody> </table> <div class="space15"></div> <div class="rotbutcont"> <div style="float:left"> <div class="rotator"><div class="rotator-line"></div></div> </div> <div style="float:left"> <div class="conftitle">ROTATION <span>(SIMPLE TRANSITIONS)</span></div> <div class="rotatefield inputfield">0 degrees</div> </div> <div class="clear"></div> </div> </div> <!-- THE 3thd CONFIG FIELD -- SLOT AMOUNT --> <div class="one_third last"> <table> <tbody> <tr> <td class="config_title">3</td> <td class="divider"></td> </tr> </tbody> </table> <div class="space15"></div> <div class="conftitle">SLOT AMOUNT <span>(USED IN TRANSITIONS)</span></div> <div class="pmbutcont"> <div class="slotamount inputfield" style="float:left;margin-right:5px;width:130px;">Pre Defined Slots</div> <div class="slot plus"></div><div class="slot minus"></div> <div class="clear"></div> </div> </div> <div class="clear"></div> <div class="space10"></div> <table> <tbody> <tr> <td class="config_title">4</td> <td class="divider"></td> </tr> </tbody> </table> <!-- THE 4th CONFIGS WITH THREE DROP DOWN LISTS --> <div class="one_third"> <div class="space15"></div> <div class="conftitle">NAVIGATION STYLE</div> <div class="selecter"> <div class="dropdown"> <div class="dropcontent">Select a Navigation Style</div> <div class="dropbutton"></div> <div class="clear"></div> </div> <select class="selectnavstyle dselect"> <option value="round">Round Bullets</option> <option value="navbar">NavBar with Bullets</option> <option value="round-old">Round Bullets (old version)</option> <option value="square-old">Square Bullets (old version)</option> <option value="navbar-old">NavBar with Bullets (old version)</option> </select> </div> </div> <div class="one_third"> <div class="space15"></div> <div class="conftitle">NAVIGATION ARROWS</div> <div class="selecter"> <div class="dropdown"> <div class="dropcontent">Select Position of Arrows</div> <div class="dropbutton"></div> <div class="clear"></div> </div> <select class="selectnavarrows dselect"> <option value="verticalcentered">Vertical Centered</option> <option value="nexttobullets">Next to Bullets</option> <option value="none">Hide Arrows</option> </select> </div> </div> <div class="one_third last"> <div class="space15"></div> <div class="conftitle">NAVIGATION THUMBS</div> <div class="selecter"> <div class="dropdown"> <div class="dropcontent">Select Navigation Type</div> <div class="dropbutton"></div> <div class="clear"></div> </div> <select class="selectnavtype dselect"> <option value="bullet">Bullets</option> <option value="thumb">Thumbnails</option> <option value="none">No Navigation</option> </select> </select> </div> </div> <div class="clear"></div> <div style="width:100%;height:75px;"></div> <!-- What Else do we have ? --> <table> <tbody> <tr> <td class="config_title small">What else can you set ?</td> <td class="divider small"></td> </tr> </tbody> </table> <div class="space15"></div> <div class="one_third"> <div class="infofield"> <ul> <li>Change <span>Speed of Transitions</span></li> <li>Set <span>Countdown time per slide</span> and/or Global</li> <li>Turn on / off <span>Visibility of Countdown</span></li> <li>Set the <span>Position of Contdown</span></li> <li>Set per slide <span>Link and Target</span></li> <li>Add <span>Unlimited</span> amount of <span>Captions</span></li> <li>Set <span>Start time and speed</span> of Captions</li> <li>Set <span>End time and speed</span> of Captions</li> </ul> </div> </div> <div class="one_third"> <div class="infofield"> <ul> <li>Set different<span>End and Start Transitions</span> of Captions</li> <li><span>Randomrotate, slide, fade</span> Caption Transitions</li> <li>Turn on/off <span>Hiding Navigation</span> and set delay</li> <li>Set <span>link</span> per Captions</li> <li>Add <span>YouTube and Vimeo</span> Captions</li> <li>Set <span>Fullscreen</span> YouTube and Vimeo Videos</li> <li>Set <span>AutoStart</span> for Videos</li> <li>Video Playback stops Countdown</li> </ul> </div> </div> <div class="one_third last"> <div class="infofield"> <ul> <li>Turn on/off <span>Hover functions</span></li> <li>Set <span>Size and Amount</span> of visible Thumbs</li> <li>Turn on / off <span>Touch</span> functions</li> <li>Choose between 3 different <span>Shadows</span></li> <li>Use <span>Api</span> to stop, play, swap slides, and many more.</li> <li>Set <span>FullWidth</span>,<span>Responsive</span> or <span>Static</span> size.</li> <li>Turn on/off <span>on Hover Stop</span> function</li> <li>Option to <span>Link within the slides</span> via Captions</li> </ul> </div> </div> <div class="clear"></div> <div style="width:100%;height:60px;"></div> <!-- SOME INFORMATIONS HERE --> <table> <tbody> <tr> <td class="config_title small">Why Use Slider Revolution</td> <td class="divider small"></td> </tr> </tbody> </table> <div class="space15"></div> <div class="infofield"> <span>With an abundance of sliders and banner rotators available on the web, why exactly should you chose Slider Revolution over other products?</span><br>Slider Revolution is a fully developed slide displaying system offering the capability to show images, videos and captions paired with simple, modern and fancy 3D transitions. On top of that, Slider Revolution is fully responsive and mobile optimized and can take on any dimensions. </div> <div style="width:100%;height:60px;"></div> <!-- SOME INFORMATIONS HERE --> <table> <tbody> <tr> <td class="config_title small">Slider Compatibility</td> <td class="divider small"></td> </tr> </tbody> </table> <table class="features"> <tbody> <tr class="titles"> <td></td> <td>BASIC SLIDER FEATURES</td> <td>SIMPLE TRANSITIONS</td> <td>PREMIUM TRANSITIONS</td> <td>ROTATION</td> </tr> <tr> <td>FIREFOX<span> 10+</span></td> <td><div class="yo"></div></td> <td><div class="yo"></div></td> <td><div class="yo"></div></td> <td><div class="yo"></div></td> </tr> <tr> <td>WEBKIT<br><span> CHROME,SAFARI,OPERA</td> <td><div class="yo"></div></td> <td><div class="yo"></div></td> <td><div class="yo"></div></td> <td><div class="yo"></div></td> </tr> <tr> <td>IE9</td> <td><div class="yo"></div></td> <td><div class="yo"></div></td> <td><div class="nop"></div></td> <td><div class="nop"></div></td> </tr> <tr> <td>IE7 + 8</td> <td><div class="yo"></div></td> <td><div class="yo"></div></td> <td><div class="nop"></div></td> <td><div class="nop"></div></td> </tr> </tbody> </table> <div style="width:100%;height:60px;"></div> <!-- SOME INFORMATIONS HERE --> <table> <tbody> <tr> <td class="config_title small">Testimonials</td> <td class="divider small"></td> </tr> </tbody> </table> <div class="space15"></div> <div class="slogan">Over 1000+ happy buyers can‘t be wrong!</div> <div class="space40"></div> <div class="testimonials"> <span>Nicolas-Gilles</span> says:<br> <i>Just to let my testimony of appreciation for the support. Efficiency and speed ! 5/5<br>Good Work<br>Nicolas-Gilles</i> </div> <div class="testimonials"> <span>rhj123456</span> says:<br> <i>Wow, you did a really great job on this. I have a whole slider built without looking at the docs. I love that.<br>Nice work!!!.</i> </div> <div class="testimonials"> <span>tverdouw</span> says:<br> <i>Awesome slider, with awesome options. Thanks!</i> </div> <div class="testimonials"> <span>dervish01</span> says:<br> <i>Hi just purchased the plugin and I have to say a great plugin.<br>You can see it at www.acornwebstudio.co.uk<br>really makes websites look great.<br>THANKS .</i> </div> <div class="testimonials"> <span>themesplugins</span> says:<br> <i>We selected your plugin as Top 100 Plugins for WordPress.</i> </div> <div class="testimonials"> <span>sailo</span> says:<br> <i>Perfect, thanks themepunch </i> </div> </div> <!-- END OF CONFIGURATOR --> <div style="width:100%;height:60px;"></div> <script> var api; jQuery(document).ready(function() { api = jQuery('.banner').revolution( { delay:5000, startheight:500, startwidth:960, hideThumbs:300, thumbWidth:100, // Thumb With and Height and Amount (only if navigation Tyope set to thumb !) thumbHeight:50, thumbAmount:5, navigationType:"bullet", // bullet, thumb, none navigationArrows:"nexttobullets", // nexttobullets, solo (old name verticalcentered), none navigationStyle:"round", // round,square,navbar,round-old,square-old,navbar-old, or any from the list in the docu (choose between 50+ different item), custom navigationHAlign:"center", // Vertical Align top,center,bottom navigationVAlign:"bottom", // Horizontal Align left,center,right navigationHOffset:0, navigationVOffset:20, soloArrowLeftHalign:"left", soloArrowLeftValign:"center", <API key>:20, <API key>:0, <API key>:"right", <API key>:"center", <API key>:20, <API key>:0, touchenabled:"on", // Enable Swipe Function : on/off onHoverStop:"on", // Stop Banner Timet at Hover on Slide on/off stopAtSlide:-1, stopAfterLoops:-1, shadow:1, //0 = no Shadow, 1,2,3 = 3 Different Art of Shadows (No Shadow in Fullwidth Version !) fullWidth:"off" // Turns On or Off the Fullwidth Image Centering in FullWidth Modus }); }); </script> </body> </html>
<!DOCTYPE html> <html> <head> <title>Use resetView to reset the header width</title> <meta charset="utf-8"> <link rel="stylesheet" href="../assets/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="../assets/bootstrap-table/src/bootstrap-table.css"> <link rel="stylesheet" href="../assets/examples.css"> <script src="../assets/jquery.min.js"></script> <script src="../assets/bootstrap/js/bootstrap.min.js"></script> <script src="../assets/bootstrap-table/src/bootstrap-table.js"></script> <script src="../ga.js"></script> <style> .div-table { /*display: table;*/ border: 1px solid #ccc; } .cell-left { /*display: table-cell;*/ float: left; width:80%; } .cell-right { /*display: table-cell;*/ float: right; width:20%; } </style> </head> <body> <div class="container"> <h1>Use resetView to reset the header width(<a href="https://github.com/wenzhixin/bootstrap-table/issues/283" target="_blank">#283</a>).</h1> <p> <button id="b" type="button" class="btn btn-default">Larger</button> <button id="s" type="button" class="btn btn-default">Smaller</button> </p> <div id="d" class="div-table"> <div class="cell-left"> <table id="table" data-height="500"></table> </div> <div class="cell-right"> RRR </div> <div class="clearfix"></div> </div> </div> <script> var $table = $('#table'); $(function () { buildTable($('#table'), 10, 50); var $d = $(' var width = $d.width(); $('#b').click(function(){ width = width + 100; $d.css('width', width + 'px'); $('#table').bootstrapTable('resetView'); }); $('#s').click(function(){ width = width - 100; $d.css('width', width + 'px'); $('#table').bootstrapTable('resetView'); }); }); function buildTable($el, cells, rows) { var i, j, row, columns = [], data = []; for (i = 0; i < cells; i++) { columns.push({ field: 'field' + i, title: 'Cell' + i }); } for (i = 0; i < rows; i++) { row = {}; for (j = 0; j < cells; j++) { row['field' + j] = 'Row-' + i + '-' + j; } data.push(row); } $el.bootstrapTable('destroy').bootstrapTable({ columns: columns, data: data }); } </script> </body> </html>
(function() { 'use strict'; angular.module('lumx.utils.depth', []); angular.module('lumx.utils.event-scheduler', []); angular.module('lumx.utils.transclude-replace', []); angular.module('lumx.utils.utils', []); angular.module('lumx.utils', [ 'lumx.utils.depth', 'lumx.utils.event-scheduler', 'lumx.utils.transclude-replace', 'lumx.utils.utils' ]); angular.module('lumx.button', []); angular.module('lumx.checkbox', []); angular.module('lumx.data-table', []); angular.module('lumx.date-picker', []); angular.module('lumx.dialog', ['lumx.utils.event-scheduler']); angular.module('lumx.dropdown', ['lumx.utils.event-scheduler']); angular.module('lumx.fab', []); angular.module('lumx.file-input', []); angular.module('lumx.icon', []); angular.module('lumx.notification', ['lumx.utils.event-scheduler']); angular.module('lumx.progress', []); angular.module('lumx.radio-button', []); angular.module('lumx.ripple', []); angular.module('lumx.search-filter', []); angular.module('lumx.select', []); angular.module('lumx.stepper', []); angular.module('lumx.switch', []); angular.module('lumx.tabs', []); angular.module('lumx.text-field', []); angular.module('lumx.tooltip', []); angular.module('lumx', [ 'lumx.button', 'lumx.checkbox', 'lumx.data-table', 'lumx.date-picker', 'lumx.dialog', 'lumx.dropdown', 'lumx.fab', 'lumx.file-input', 'lumx.icon', 'lumx.notification', 'lumx.progress', 'lumx.radio-button', 'lumx.ripple', 'lumx.search-filter', 'lumx.select', 'lumx.stepper', 'lumx.switch', 'lumx.tabs', 'lumx.text-field', 'lumx.tooltip', 'lumx.utils' ]); })(); (function() { 'use strict'; angular .module('lumx.utils.depth') .service('LxDepthService', LxDepthService); function LxDepthService() { var service = this; var depth = 1000; service.getDepth = getDepth; service.register = register; function getDepth() { return depth; } function register() { depth++; } } })(); (function() { 'use strict'; angular .module('lumx.utils.event-scheduler') .service('<API key>', <API key>); <API key>.$inject = ['$document', 'LxUtils']; function <API key>($document, LxUtils) { var service = this; var handlers = {}; var schedule = {}; service.register = register; service.unregister = unregister; function handle(event) { var scheduler = schedule[event.type]; if (angular.isDefined(scheduler)) { for (var i = 0, length = scheduler.length; i < length; i++) { var handler = scheduler[i]; if (angular.isDefined(handler) && angular.isDefined(handler.callback) && angular.isFunction(handler.callback)) { handler.callback(event); if (event.<API key>()) { break; } } } } } function register(eventName, callback) { var handler = { eventName: eventName, callback: callback }; var id = LxUtils.generateUUID(); handlers[id] = handler; if (angular.isUndefined(schedule[eventName])) { schedule[eventName] = []; $document.on(eventName, handle); } schedule[eventName].unshift(handlers[id]); return id; } function unregister(id) { var found = false; var handler = handlers[id]; if (angular.isDefined(handler) && angular.isDefined(schedule[handler.eventName])) { var index = schedule[handler.eventName].indexOf(handler); if (angular.isDefined(index) && index > -1) { schedule[handler.eventName].splice(index, 1); delete handlers[id]; found = true; } if (schedule[handler.eventName].length === 0) { delete schedule[handler.eventName]; $document.off(handler.eventName, handle); } } return found; } } })(); (function() { 'use strict'; angular .module('lumx.utils.transclude-replace') .directive('ngTranscludeReplace', ngTranscludeReplace); ngTranscludeReplace.$inject = ['$log']; function ngTranscludeReplace($log) { return { terminal: true, restrict: 'EA', link: link }; function link(scope, element, attrs, ctrl, transclude) { if (!transclude) { $log.error('orphan', 'Illegal use of ngTranscludeReplace directive in the template! ' + 'No parent directive that requires a transclusion found. '); return; } transclude(function(clone) { if (clone.length) { element.replaceWith(clone); } else { element.remove(); } }); } } })(); (function() { 'use strict'; angular .module('lumx.utils.utils') .service('LxUtils', LxUtils); function LxUtils() { var service = this; service.debounce = debounce; service.generateUUID = generateUUID; service.disableBodyScroll = disableBodyScroll; // http://underscorejs.org/#debounce (1.8.3) function debounce(func, wait, immediate) { var timeout, args, context, timestamp, result; wait = wait || 500; var later = function() { var last = Date.now() - timestamp; if (last < wait && last >= 0) { timeout = setTimeout(later, wait - last); } else { timeout = null; if (!immediate) { result = func.apply(context, args); if (!timeout) { context = args = null; } } } }; var debounced = function() { context = this; args = arguments; timestamp = Date.now(); var callNow = immediate && !timeout; if (!timeout) { timeout = setTimeout(later, wait); } if (callNow) { result = func.apply(context, args); context = args = null; } return result; }; debounced.clear = function() { clearTimeout(timeout); timeout = context = args = null; }; return debounced; } function generateUUID() { var d = new Date().getTime(); var uuid = '<API key>'.replace(/[xy]/g, function(c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)) .toString(16); }); return uuid.toUpperCase(); } function disableBodyScroll() { var body = document.body; var documentElement = document.documentElement; var prevDocumentStyle = documentElement.style.cssText || ''; var prevBodyStyle = body.style.cssText || ''; var viewportTop = window.scrollY || window.pageYOffset || 0; var clientWidth = body.clientWidth; var <API key> = body.scrollHeight > window.innerHeight + 1; if (<API key>) { angular.element('body').css({ position: 'fixed', width: '100%', top: -viewportTop + 'px' }); } if (body.clientWidth < clientWidth) { body.style.overflow = 'hidden'; } // This should be applied after the manipulation to the body, because // adding a scrollbar can potentially resize it, causing the measurement // to change. if (<API key>) { documentElement.style.overflowY = 'scroll'; } return function restoreScroll() { // Reset the inline style CSS to the previous. body.style.cssText = prevBodyStyle; documentElement.style.cssText = prevDocumentStyle; // The body loses its scroll position while being fixed. body.scrollTop = viewportTop; }; } } })(); (function() { 'use strict'; angular .module('lumx.button') .directive('lxButton', lxButton); function lxButton() { var buttonClass; return { restrict: 'E', templateUrl: getTemplateUrl, compile: compile, replace: true, transclude: true }; function compile(element, attrs) { setButtonStyle(element, attrs.lxSize, attrs.lxColor, attrs.lxType); return function(scope, element, attrs) { attrs.$observe('lxSize', function(lxSize) { setButtonStyle(element, lxSize, attrs.lxColor, attrs.lxType); }); attrs.$observe('lxColor', function(lxColor) { setButtonStyle(element, attrs.lxSize, lxColor, attrs.lxType); }); attrs.$observe('lxType', function(lxType) { setButtonStyle(element, attrs.lxSize, attrs.lxColor, lxType); }); element.on('click', function(event) { if (attrs.disabled === true) { event.preventDefault(); event.<API key>(); } }); }; } function getTemplateUrl(element, attrs) { return isAnchor(attrs) ? 'link.html' : 'button.html'; } function isAnchor(attrs) { return angular.isDefined(attrs.href) || angular.isDefined(attrs.ngHref) || angular.isDefined(attrs.ngLink) || angular.isDefined(attrs.uiSref); } function setButtonStyle(element, size, color, type) { var buttonBase = 'btn'; var buttonSize = angular.isDefined(size) ? size : 'm'; var buttonColor = angular.isDefined(color) ? color : 'primary'; var buttonType = angular.isDefined(type) ? type : 'raised'; element.removeClass(buttonClass); buttonClass = buttonBase + ' btn--' + buttonSize + ' btn--' + buttonColor + ' btn--' + buttonType; element.addClass(buttonClass); } } })(); (function() { 'use strict'; angular .module('lumx.checkbox') .directive('lxCheckbox', lxCheckbox) .directive('lxCheckboxLabel', lxCheckboxLabel) .directive('lxCheckboxHelp', lxCheckboxHelp); function lxCheckbox() { return { restrict: 'E', templateUrl: 'checkbox.html', scope: { lxColor: '@?', name: '@?', ngChange: '&?', ngDisabled: '=?', ngFalseValue: '@?', ngModel: '=', ngTrueValue: '@?', theme: '@?lxTheme' }, controller: <API key>, controllerAs: 'lxCheckbox', bindToController: true, transclude: true, replace: true }; } <API key>.$inject = ['$scope', '$timeout', 'LxUtils']; function <API key>($scope, $timeout, LxUtils) { var lxCheckbox = this; var checkboxId; var checkboxHasChildren; var timer; lxCheckbox.getCheckboxId = getCheckboxId; lxCheckbox.<API key> = <API key>; lxCheckbox.setCheckboxId = setCheckboxId; lxCheckbox.<API key> = <API key>; lxCheckbox.triggerNgChange = triggerNgChange; $scope.$on('$destroy', function() { $timeout.cancel(timer); }); init(); function getCheckboxId() { return checkboxId; } function <API key>() { return checkboxHasChildren; } function init() { setCheckboxId(LxUtils.generateUUID()); <API key>(false); lxCheckbox.ngTrueValue = angular.isUndefined(lxCheckbox.ngTrueValue) ? true : lxCheckbox.ngTrueValue; lxCheckbox.ngFalseValue = angular.isUndefined(lxCheckbox.ngFalseValue) ? false : lxCheckbox.ngFalseValue; lxCheckbox.lxColor = angular.isUndefined(lxCheckbox.lxColor) ? 'accent' : lxCheckbox.lxColor; } function setCheckboxId(_checkboxId) { checkboxId = _checkboxId; } function <API key>(<API key>) { checkboxHasChildren = <API key>; } function triggerNgChange() { timer = $timeout(lxCheckbox.ngChange); } } function lxCheckboxLabel() { return { restrict: 'AE', require: ['^lxCheckbox', '^lxCheckboxLabel'], templateUrl: 'checkbox-label.html', link: link, controller: <API key>, controllerAs: 'lxCheckboxLabel', bindToController: true, transclude: true, replace: true }; function link(scope, element, attrs, ctrls) { ctrls[0].<API key>(true); ctrls[1].setCheckboxId(ctrls[0].getCheckboxId()); } } function <API key>() { var lxCheckboxLabel = this; var checkboxId; lxCheckboxLabel.getCheckboxId = getCheckboxId; lxCheckboxLabel.setCheckboxId = setCheckboxId; function getCheckboxId() { return checkboxId; } function setCheckboxId(_checkboxId) { checkboxId = _checkboxId; } } function lxCheckboxHelp() { return { restrict: 'AE', require: '^lxCheckbox', templateUrl: 'checkbox-help.html', transclude: true, replace: true }; } })(); (function() { 'use strict'; angular .module('lumx.data-table') .directive('lxDataTable', lxDataTable); function lxDataTable() { return { restrict: 'E', templateUrl: 'data-table.html', scope: { border: '=?lxBorder', selectable: '=?lxSelectable', thumbnail: '=?lxThumbnail', tbody: '=lxTbody', thead: '=lxThead' }, link: link, controller: <API key>, controllerAs: 'lxDataTable', bindToController: true, transclude: true, replace: true }; function link(scope, element, attrs, ctrl) { attrs.$observe('id', function(_newId) { ctrl.id = _newId; }); } } <API key>.$inject = ['$rootScope', '$sce', '$scope']; function <API key>($rootScope, $sce, $scope) { var lxDataTable = this; lxDataTable.areAllRowsSelected = areAllRowsSelected; lxDataTable.border = angular.isUndefined(lxDataTable.border) ? true : lxDataTable.border; lxDataTable.sort = sort; lxDataTable.toggle = toggle; lxDataTable.toggleAllSelected = toggleAllSelected; lxDataTable.$sce = $sce; lxDataTable.allRowsSelected = false; lxDataTable.selectedRows = []; $scope.$on('<API key>', function(event, id, row) { if (id === lxDataTable.id && angular.isDefined(row)) { if (angular.isArray(row) && row.length > 0) { row = row[0]; } _select(row); } }); $scope.$on('<API key>', function(event, id) { if (id === lxDataTable.id) { _selectAll(); } }); $scope.$on('<API key>', function(event, id, row) { if (id === lxDataTable.id && angular.isDefined(row)) { if (angular.isArray(row) && row.length > 0) { row = row[0]; } _unselect(row); } }); $scope.$on('<API key>', function(event, id) { if (id === lxDataTable.id) { _unselectAll(); } }); function _selectAll() { lxDataTable.selectedRows.length = 0; for (var i = 0, len = lxDataTable.tbody.length; i < len; i++) { if (!lxDataTable.tbody[i].lxDataTableDisabled) { lxDataTable.tbody[i].lxDataTableSelected = true; lxDataTable.selectedRows.push(lxDataTable.tbody[i]); } } lxDataTable.allRowsSelected = true; $rootScope.$broadcast('<API key>', lxDataTable.id, lxDataTable.selectedRows); } function _select(row) { toggle(row, true); } function _unselectAll() { for (var i = 0, len = lxDataTable.tbody.length; i < len; i++) { if (!lxDataTable.tbody[i].lxDataTableDisabled) { lxDataTable.tbody[i].lxDataTableSelected = false; } } lxDataTable.allRowsSelected = false; lxDataTable.selectedRows.length = 0; $rootScope.$broadcast('<API key>', lxDataTable.id, lxDataTable.selectedRows); } function _unselect(row) { toggle(row, false); } function areAllRowsSelected() { var displayedRows = 0; for (var i = 0, len = lxDataTable.tbody.length; i < len; i++) { if (!lxDataTable.tbody[i].lxDataTableDisabled) { displayedRows++; } } if (displayedRows === lxDataTable.selectedRows.length) { lxDataTable.allRowsSelected = true; } else { lxDataTable.allRowsSelected = false; } } function sort(_column) { if (!_column.sortable) { return; } for (var i = 0, len = lxDataTable.thead.length; i < len; i++) { if (lxDataTable.thead[i].sortable && lxDataTable.thead[i].name !== _column.name) { lxDataTable.thead[i].sort = undefined; } } if (!_column.sort || _column.sort === 'desc') { _column.sort = 'asc'; } else { _column.sort = 'desc'; } $rootScope.$broadcast('<API key>', lxDataTable.id, _column); } function toggle(_row, _newSelectedStatus) { if (_row.lxDataTableDisabled || !lxDataTable.selectable) { return; } _row.lxDataTableSelected = angular.isDefined(_newSelectedStatus) ? _newSelectedStatus : !_row.lxDataTableSelected; if (_row.lxDataTableSelected) { // Make sure it's not already in. if (lxDataTable.selectedRows.length === 0 || (lxDataTable.selectedRows.length && lxDataTable.selectedRows.indexOf(_row) === -1)) { lxDataTable.selectedRows.push(_row); lxDataTable.areAllRowsSelected(); $rootScope.$broadcast('<API key>', lxDataTable.id, lxDataTable.selectedRows); } } else { if (lxDataTable.selectedRows.length && lxDataTable.selectedRows.indexOf(_row) > -1) { lxDataTable.selectedRows.splice(lxDataTable.selectedRows.indexOf(_row), 1); lxDataTable.allRowsSelected = false; $rootScope.$broadcast('<API key>', lxDataTable.id, lxDataTable.selectedRows); } } } function toggleAllSelected() { if (lxDataTable.allRowsSelected) { _unselectAll(); } else { _selectAll(); } } } })(); (function() { 'use strict'; angular .module('lumx.data-table') .service('LxDataTableService', LxDataTableService); LxDataTableService.$inject = ['$rootScope']; function LxDataTableService($rootScope) { var service = this; service.select = select; service.selectAll = selectAll; service.unselect = unselect; service.unselectAll = unselectAll; function select(_dataTableId, row) { $rootScope.$broadcast('<API key>', _dataTableId, row); } function selectAll(_dataTableId) { $rootScope.$broadcast('<API key>', _dataTableId); } function unselect(_dataTableId, row) { $rootScope.$broadcast('<API key>', _dataTableId, row); } function unselectAll(_dataTableId) { $rootScope.$broadcast('<API key>', _dataTableId); } } })(); (function() { 'use strict'; angular .module('lumx.date-picker') .directive('lxDatePicker', lxDatePicker); lxDatePicker.$inject = ['LxDatePickerService', 'LxUtils']; function lxDatePicker(LxDatePickerService, LxUtils) { return { restrict: 'AE', templateUrl: 'date-picker.html', scope: { autoClose: '=?lxAutoClose', callback: '&?lxCallback', color: '@?lxColor', escapeClose: '=?lxEscapeClose', inputFormat: '@?lxInputFormat', maxDate: '=?lxMaxDate', ngModel: '=', minDate: '=?lxMinDate', locale: '@lxLocale' }, link: link, controller: <API key>, controllerAs: 'lxDatePicker', bindToController: true, replace: true, transclude: true }; function link(scope, element, attrs) { if (angular.isDefined(attrs.id)) { attrs.$observe('id', function(_newId) { scope.lxDatePicker.pickerId = _newId; LxDatePickerService.registerScope(scope.lxDatePicker.pickerId, scope); }); } else { scope.lxDatePicker.pickerId = LxUtils.generateUUID(); LxDatePickerService.registerScope(scope.lxDatePicker.pickerId, scope); } } } <API key>.$inject = ['$element', '$scope', '$timeout', '$transclude', 'LxDatePickerService', 'LxUtils']; function <API key>($element, $scope, $timeout, $transclude, LxDatePickerService, LxUtils) { var lxDatePicker = this; var input; var modelController; var timer1; var timer2; var watcher1; var watcher2; lxDatePicker.closeDatePicker = closeDatePicker; lxDatePicker.<API key> = <API key>; lxDatePicker.hideYearSelection = hideYearSelection; lxDatePicker.getDateFormatted = getDateFormatted; lxDatePicker.nextMonth = nextMonth; lxDatePicker.openDatePicker = openDatePicker; lxDatePicker.previousMonth = previousMonth; lxDatePicker.select = select; lxDatePicker.selectYear = selectYear; lxDatePicker.autoClose = angular.isDefined(lxDatePicker.autoClose) ? lxDatePicker.autoClose : true; lxDatePicker.color = angular.isDefined(lxDatePicker.color) ? lxDatePicker.color : 'primary'; lxDatePicker.element = $element.find('.lx-date-picker'); lxDatePicker.escapeClose = angular.isDefined(lxDatePicker.escapeClose) ? lxDatePicker.escapeClose : true; lxDatePicker.isOpen = false; lxDatePicker.moment = moment; lxDatePicker.yearSelection = false; lxDatePicker.uuid = LxUtils.generateUUID(); $transclude(function(clone) { if (clone.length) { lxDatePicker.hasInput = true; timer1 = $timeout(function() { input = $element.find('.lx-date-input input'); modelController = input.data('$ngModelController'); watcher2 = $scope.$watch(function() { return modelController.$viewValue; }, function(newValue, oldValue) { if (angular.isUndefined(newValue)) { lxDatePicker.ngModel = undefined; } }); }); } }); watcher1 = $scope.$watch(function() { return lxDatePicker.ngModel; }, init); $scope.$on('$destroy', function() { $timeout.cancel(timer1); $timeout.cancel(timer2); if (angular.isFunction(watcher1)) { watcher1(); } if (angular.isFunction(watcher2)) { watcher2(); } }); function closeDatePicker() { LxDatePickerService.close(lxDatePicker.pickerId); } function <API key>() { lxDatePicker.yearSelection = true; timer2 = $timeout(function() { var yearSelector = angular.element('.<API key>'); var activeYear = yearSelector.find('.<API key>'); yearSelector.scrollTop(yearSelector.scrollTop() + activeYear.position().top - yearSelector.height() / 2 + activeYear.height() / 2); }); } function hideYearSelection() { lxDatePicker.yearSelection = false; } function generateCalendar() { lxDatePicker.days = []; var previousDay = angular.copy(lxDatePicker.ngModelMoment).date(0); var firstDayOfMonth = angular.copy(lxDatePicker.ngModelMoment).date(1); var lastDayOfMonth = firstDayOfMonth.clone().endOf('month'); var maxDays = lastDayOfMonth.date(); lxDatePicker.emptyFirstDays = []; for (var i = firstDayOfMonth.day() === 0 ? 6 : firstDayOfMonth.day() - 1; i > 0; i { lxDatePicker.emptyFirstDays.push( {}); } for (var j = 0; j < maxDays; j++) { var date = angular.copy(previousDay.add(1, 'days')); date.selected = angular.isDefined(lxDatePicker.ngModel) && date.isSame(lxDatePicker.ngModel, 'day'); date.today = date.isSame(moment(), 'day'); if (angular.isDefined(lxDatePicker.minDate) && date.toDate() < lxDatePicker.minDate) { date.disabled = true; } if (angular.isDefined(lxDatePicker.maxDate) && date.toDate() > lxDatePicker.maxDate) { date.disabled = true; } lxDatePicker.days.push(date); } lxDatePicker.emptyLastDays = []; for (var k = 7 - (lastDayOfMonth.day() === 0 ? 7 : lastDayOfMonth.day()); k > 0; k { lxDatePicker.emptyLastDays.push( {}); } } function getDateFormatted() { var dateFormatted = lxDatePicker.ngModelMoment.format('llll').replace(lxDatePicker.ngModelMoment.format('LT'), '').trim().replace(lxDatePicker.ngModelMoment.format('YYYY'), '').trim(); var <API key> = dateFormatted.slice(-1); if (<API key> === ',') { dateFormatted = dateFormatted.slice(0, -1); } return dateFormatted; } function init() { moment.locale(lxDatePicker.locale); lxDatePicker.ngModelMoment = angular.isDefined(lxDatePicker.ngModel) ? moment(angular.copy(lxDatePicker.ngModel)) : moment(); lxDatePicker.days = []; lxDatePicker.daysOfWeek = [moment.weekdaysMin(1), moment.weekdaysMin(2), moment.weekdaysMin(3), moment.weekdaysMin(4), moment.weekdaysMin(5), moment.weekdaysMin(6), moment.weekdaysMin(0)]; lxDatePicker.years = []; for (var y = moment().year() - 100; y <= moment().year() + 100; y++) { lxDatePicker.years.push(y); } generateCalendar(); } function nextMonth() { lxDatePicker.ngModelMoment = lxDatePicker.ngModelMoment.add(1, 'month'); generateCalendar(); } function openDatePicker() { LxDatePickerService.open(lxDatePicker.pickerId); } function previousMonth() { lxDatePicker.ngModelMoment = lxDatePicker.ngModelMoment.subtract(1, 'month'); generateCalendar(); } function select(_day) { if (!_day.disabled) { lxDatePicker.ngModel = _day.toDate(); lxDatePicker.ngModelMoment = angular.copy(_day); if (angular.isDefined(lxDatePicker.callback)) { lxDatePicker.callback( { newDate: lxDatePicker.ngModel }); } if (angular.isDefined(modelController) && lxDatePicker.inputFormat) { modelController.$setViewValue(angular.copy(_day).format(lxDatePicker.inputFormat)); modelController.$render(); } generateCalendar(); } } function selectYear(_year) { lxDatePicker.yearSelection = false; lxDatePicker.ngModelMoment = lxDatePicker.ngModelMoment.year(_year); generateCalendar(); } } })(); (function() { 'use strict'; angular .module('lumx.date-picker') .service('LxDatePickerService', LxDatePickerService); LxDatePickerService.$inject = ['$rootScope', '$timeout', 'LxDepthService', '<API key>']; function LxDatePickerService($rootScope, $timeout, LxDepthService, <API key>) { var service = this; var activeDatePickerId; var datePickerFilter; var idEventScheduler; var scopeMap = {}; service.close = closeDatePicker; service.open = openDatePicker; service.registerScope = registerScope; function closeDatePicker(_datePickerId) { if (angular.isDefined(idEventScheduler)) { <API key>.unregister(idEventScheduler); idEventScheduler = undefined; } activeDatePickerId = undefined; $rootScope.$broadcast('<API key>', _datePickerId); datePickerFilter.removeClass('<API key>'); scopeMap[_datePickerId].element.removeClass('<API key>'); $timeout(function() { angular.element('body').removeClass('<API key>-' + scopeMap[_datePickerId].uuid); datePickerFilter.remove(); scopeMap[_datePickerId].element .hide() .appendTo(scopeMap[_datePickerId].elementParent); scopeMap[_datePickerId].isOpen = false; $rootScope.$broadcast('<API key>', _datePickerId); }, 600); } function onKeyUp(_event) { if (_event.keyCode == 27 && angular.isDefined(activeDatePickerId)) { closeDatePicker(activeDatePickerId); } _event.stopPropagation(); } function openDatePicker(_datePickerId) { LxDepthService.register(); activeDatePickerId = _datePickerId; angular.element('body').addClass('<API key>-' + scopeMap[_datePickerId].uuid); datePickerFilter = angular.element('<div/>', { class: '<API key>' }); datePickerFilter .css('z-index', LxDepthService.getDepth()) .appendTo('body'); if (scopeMap[activeDatePickerId].autoClose) { datePickerFilter.on('click', function() { closeDatePicker(activeDatePickerId); }); } if (scopeMap[activeDatePickerId].escapeClose) { idEventScheduler = <API key>.register('keyup', onKeyUp); } scopeMap[activeDatePickerId].element .css('z-index', LxDepthService.getDepth() + 1) .appendTo('body') .show(); $timeout(function() { $rootScope.$broadcast('<API key>', activeDatePickerId); scopeMap[activeDatePickerId].isOpen = true; datePickerFilter.addClass('<API key>'); scopeMap[activeDatePickerId].element.addClass('<API key>'); }, 100); $timeout(function() { $rootScope.$broadcast('<API key>', activeDatePickerId); }, 700); } function registerScope(_datePickerId, _datePickerScope) { scopeMap[_datePickerId] = _datePickerScope.lxDatePicker; } } })(); (function() { 'use strict'; angular .module('lumx.dialog') .directive('lxDialog', lxDialog) .directive('lxDialogHeader', lxDialogHeader) .directive('lxDialogContent', lxDialogContent) .directive('lxDialogFooter', lxDialogFooter) .directive('lxDialogClose', lxDialogClose); function lxDialog() { return { restrict: 'E', template: '<div class="dialog" ng-class="{ \'dialog--l\': !lxDialog.size || lxDialog.size === \'l\', \'dialog--s\': lxDialog.size === \'s\', \'dialog--m\': lxDialog.size === \'m\' }"><div ng-if="lxDialog.isOpen" ng-transclude></div></div>', scope: { autoClose: '=?lxAutoClose', escapeClose: '=?lxEscapeClose', size: '@?lxSize' }, link: link, controller: LxDialogController, controllerAs: 'lxDialog', bindToController: true, replace: true, transclude: true }; function link(scope, element, attrs, ctrl) { attrs.$observe('id', function(_newId) { ctrl.id = _newId; }); } } LxDialogController.$inject = ['$element', '$interval', '$rootScope', '$scope', '$timeout', '$window', 'LxDepthService', '<API key>', 'LxUtils']; function LxDialogController($element, $interval, $rootScope, $scope, $timeout, $window, LxDepthService, <API key>, LxUtils) { var lxDialog = this; var dialogFilter = angular.element('<div/>', { class: 'dialog-filter' }); var dialogHeight; var dialogInterval; var dialogScrollable; var elementParent = $element.parent(); var idEventScheduler; var resizeDebounce; var windowHeight; lxDialog.autoClose = angular.isDefined(lxDialog.autoClose) ? lxDialog.autoClose : true; lxDialog.escapeClose = angular.isDefined(lxDialog.escapeClose) ? lxDialog.escapeClose : true; lxDialog.isOpen = false; lxDialog.uuid = LxUtils.generateUUID(); $scope.$on('lx-dialog__open', function(event, id) { if (id === lxDialog.id) { open(); } }); $scope.$on('lx-dialog__close', function(event, id) { if (id === lxDialog.id) { close(); } }); $scope.$on('$destroy', function() { close(); }); function checkDialogHeight() { var dialog = $element; var dialogHeader = dialog.find('.dialog__header'); var dialogContent = dialog.find('.dialog__content'); var dialogFooter = dialog.find('.dialog__footer'); if (!dialogFooter.length) { dialogFooter = dialog.find('.dialog__actions'); } if (angular.isUndefined(dialogHeader)) { return; } var heightToCheck = 60 + dialogHeader.outerHeight() + dialogContent.outerHeight() + dialogFooter.outerHeight(); if (dialogHeight === heightToCheck && windowHeight === $window.innerHeight) { return; } dialogHeight = heightToCheck; windowHeight = $window.innerHeight; if (heightToCheck >= $window.innerHeight) { dialog.addClass('dialog--is-fixed'); dialogScrollable .css( { top: dialogHeader.outerHeight(), bottom: dialogFooter.outerHeight() }) .off('scroll', checkScrollEnd) .on('scroll', checkScrollEnd); } else { dialog.removeClass('dialog--is-fixed'); dialogScrollable .removeAttr('style') .off('scroll', checkScrollEnd); } } function <API key>() { if (resizeDebounce) { $timeout.cancel(resizeDebounce); } resizeDebounce = $timeout(function() { checkDialogHeight(); }, 200); } function checkScrollEnd() { if (dialogScrollable.scrollTop() + dialogScrollable.innerHeight() >= dialogScrollable[0].scrollHeight) { $rootScope.$broadcast('<API key>', lxDialog.id); dialogScrollable.off('scroll', checkScrollEnd); $timeout(function() { dialogScrollable.on('scroll', checkScrollEnd); }, 500); } } function onKeyUp(_event) { if (_event.keyCode == 27) { close(); } _event.stopPropagation(); } function open() { if (lxDialog.isOpen) { return; } LxDepthService.register(); angular.element('body').addClass('no-scroll-dialog-' + lxDialog.uuid); dialogFilter .css('z-index', LxDepthService.getDepth()) .appendTo('body'); if (lxDialog.autoClose) { dialogFilter.on('click', function() { close(); }); } if (lxDialog.escapeClose) { idEventScheduler = <API key>.register('keyup', onKeyUp); } $element .css('z-index', LxDepthService.getDepth() + 1) .appendTo('body') .show(); $timeout(function() { $rootScope.$broadcast('<API key>', lxDialog.id); lxDialog.isOpen = true; dialogFilter.addClass('<API key>'); $element.addClass('dialog--is-shown'); }, 100); $timeout(function() { if ($element.find('.dialog__scrollable').length === 0) { $element.find('.dialog__content').wrap(angular.element('<div/>', { class: 'dialog__scrollable' })); } dialogScrollable = $element.find('.dialog__scrollable'); }, 200); $timeout(function() { $rootScope.$broadcast('lx-dialog__open-end', lxDialog.id); }, 700); dialogInterval = $interval(function() { checkDialogHeight(); }, 500); angular.element($window).on('resize', <API key>); } function close() { if (!lxDialog.isOpen) { return; } if (angular.isDefined(idEventScheduler)) { <API key>.unregister(idEventScheduler); idEventScheduler = undefined; } angular.element($window).off('resize', <API key>); $element.find('.dialog__scrollable').off('scroll', checkScrollEnd); $rootScope.$broadcast('<API key>', lxDialog.id); if (resizeDebounce) { $timeout.cancel(resizeDebounce); } $interval.cancel(dialogInterval); dialogFilter.removeClass('<API key>'); $element.removeClass('dialog--is-shown'); $timeout(function() { angular.element('body').removeClass('no-scroll-dialog-' + lxDialog.uuid); dialogFilter.remove(); $element .hide() .removeClass('dialog--is-fixed') .appendTo(elementParent); lxDialog.isOpen = false; dialogHeight = undefined; $rootScope.$broadcast('<API key>', lxDialog.id); }, 600); } } function lxDialogHeader() { return { restrict: 'E', template: '<div class="dialog__header" ng-transclude></div>', replace: true, transclude: true }; } function lxDialogContent() { return { restrict: 'E', template: '<div class="dialog__scrollable"><div class="dialog__content" ng-transclude></div></div>', replace: true, transclude: true }; } function lxDialogFooter() { return { restrict: 'E', template: '<div class="dialog__footer" ng-transclude></div>', replace: true, transclude: true }; } lxDialogClose.$inject = ['LxDialogService']; function lxDialogClose(LxDialogService) { return { restrict: 'A', link: function(scope, element) { element.on('click', function() { LxDialogService.close(element.parents('.dialog').attr('id')); }); scope.$on('$destroy', function() { element.off(); }); } }; } })(); (function() { 'use strict'; angular .module('lumx.dialog') .service('LxDialogService', LxDialogService); LxDialogService.$inject = ['$rootScope']; function LxDialogService($rootScope) { var service = this; service.open = open; service.close = close; function open(_dialogId) { $rootScope.$broadcast('lx-dialog__open', _dialogId); } function close(_dialogId) { $rootScope.$broadcast('lx-dialog__close', _dialogId); } } })(); (function() { 'use strict'; angular .module('lumx.dropdown') .directive('lxDropdown', lxDropdown) .directive('lxDropdownToggle', lxDropdownToggle) .directive('lxDropdownMenu', lxDropdownMenu) .directive('lxDropdownFilter', lxDropdownFilter); function lxDropdown() { return { restrict: 'E', templateUrl: 'dropdown.html', scope: { depth: '@?lxDepth', effect: '@?lxEffect', escapeClose: '=?lxEscapeClose', hover: '=?lxHover', hoverDelay: '=?lxHoverDelay', offset: '@?lxOffset', overToggle: '=?lxOverToggle', position: '@?lxPosition', width: '@?lxWidth' }, link: link, controller: <API key>, controllerAs: 'lxDropdown', bindToController: true, transclude: true }; function link(scope, element, attrs, ctrl) { var backwardOneWay = ['position', 'width']; var backwardTwoWay = ['escapeClose', 'overToggle']; angular.forEach(backwardOneWay, function(attribute) { if (angular.isDefined(attrs[attribute])) { attrs.$observe(attribute, function(newValue) { scope.lxDropdown[attribute] = newValue; }); } }); angular.forEach(backwardTwoWay, function(attribute) { if (angular.isDefined(attrs[attribute])) { scope.$watch(function() { return scope.$parent.$eval(attrs[attribute]); }, function(newValue) { scope.lxDropdown[attribute] = newValue; }); } }); attrs.$observe('id', function(_newId) { ctrl.uuid = _newId; }); scope.$on('$destroy', function() { if (ctrl.isOpen) { ctrl.closeDropdownMenu(); } }); } } <API key>.$inject = ['$element', '$interval', '$scope', '$timeout', '$window', 'LxDepthService', 'LxDropdownService', '<API key>', 'LxUtils' ]; function <API key>($element, $interval, $scope, $timeout, $window, LxDepthService, LxDropdownService, <API key>, LxUtils) { var lxDropdown = this; var dropdownInterval; var dropdownMenu; var dropdownToggle; var idEventScheduler; var openTimeout; var positionTarget; var scrollMask = angular.element('<div/>', { class: 'scroll-mask' }); var enableBodyScroll; lxDropdown.closeDropdownMenu = closeDropdownMenu; lxDropdown.openDropdownMenu = openDropdownMenu; lxDropdown.<API key> = <API key>; lxDropdown.<API key> = <API key>; lxDropdown.toggle = toggle; lxDropdown.uuid = LxUtils.generateUUID(); lxDropdown.effect = angular.isDefined(lxDropdown.effect) ? lxDropdown.effect : 'expand'; lxDropdown.escapeClose = angular.isDefined(lxDropdown.escapeClose) ? lxDropdown.escapeClose : true; lxDropdown.hasToggle = false; lxDropdown.isOpen = false; lxDropdown.overToggle = angular.isDefined(lxDropdown.overToggle) ? lxDropdown.overToggle : false; lxDropdown.position = angular.isDefined(lxDropdown.position) ? lxDropdown.position : 'left'; $scope.$on('lx-dropdown__open', function(_event, _params) { if (_params.uuid === lxDropdown.uuid && !lxDropdown.isOpen) { LxDropdownService.closeActiveDropdown(); LxDropdownService.<API key>(lxDropdown.uuid); positionTarget = _params.target; <API key>(angular.element(positionTarget)); openDropdownMenu(); } }); $scope.$on('lx-dropdown__close', function(_event, _params) { if (_params.uuid === lxDropdown.uuid && lxDropdown.isOpen) { closeDropdownMenu(); } }); $scope.$on('$destroy', function() { $timeout.cancel(openTimeout); }); function closeDropdownMenu() { $interval.cancel(dropdownInterval); LxDropdownService.<API key>(); var velocityProperties; var velocityEasing; scrollMask.remove(); if (angular.isFunction(enableBodyScroll)) { enableBodyScroll(); } enableBodyScroll = undefined; if (lxDropdown.hasToggle) { dropdownToggle .off('wheel') .css('z-index', ''); } dropdownMenu .off('wheel') .css( { overflow: 'hidden' }); if (lxDropdown.effect === 'expand') { velocityProperties = { width: 0, height: 0 }; velocityEasing = 'easeOutQuint'; } else if (lxDropdown.effect === 'fade') { velocityProperties = { opacity: 0 }; velocityEasing = 'linear'; } if (lxDropdown.effect === 'expand' || lxDropdown.effect === 'fade') { dropdownMenu.velocity(velocityProperties, { duration: 200, easing: velocityEasing, complete: function() { dropdownMenu .removeAttr('style') .removeClass('<API key>') .appendTo($element.find('.dropdown')); $scope.$apply(function() { lxDropdown.isOpen = false; if (lxDropdown.escapeClose) { <API key>.unregister(idEventScheduler); idEventScheduler = undefined; } }); } }); } else if (lxDropdown.effect === 'none') { dropdownMenu .removeAttr('style') .removeClass('<API key>') .appendTo($element.find('.dropdown')); lxDropdown.isOpen = false; if (lxDropdown.escapeClose) { <API key>.unregister(idEventScheduler); idEventScheduler = undefined; } } } function getAvailableHeight() { var <API key>; var <API key>; var direction; var <API key> = dropdownToggle.outerHeight(); var dropdownToggleTop = dropdownToggle.offset().top - angular.element($window).scrollTop(); var windowHeight = $window.innerHeight; if (lxDropdown.overToggle) { <API key> = dropdownToggleTop + <API key>; <API key> = windowHeight - dropdownToggleTop; } else { <API key> = dropdownToggleTop; <API key> = windowHeight - (dropdownToggleTop + <API key>); } if (<API key> > <API key>) { direction = 'top'; } else { direction = 'bottom'; } return { top: <API key>, bottom: <API key>, direction: direction }; } function <API key>() { var availableHeight = getAvailableHeight(); var dropdownMenuWidth; var dropdownMenuLeft; var dropdownMenuRight; var dropdownToggleWidth = dropdownToggle.outerWidth(); var <API key> = dropdownToggle.outerHeight(); var dropdownToggleTop = dropdownToggle.offset().top - angular.element($window).scrollTop(); var windowWidth = $window.innerWidth; var windowHeight = $window.innerHeight; if (angular.isDefined(lxDropdown.width)) { if (lxDropdown.width.indexOf('%') > -1) { dropdownMenuWidth = dropdownToggleWidth * (lxDropdown.width.slice(0, -1) / 100); } else { dropdownMenuWidth = lxDropdown.width; } } else { dropdownMenuWidth = 'auto'; } if (lxDropdown.position === 'left') { dropdownMenuLeft = dropdownToggle.offset().left; dropdownMenuRight = 'auto'; } else if (lxDropdown.position === 'right') { dropdownMenuLeft = 'auto'; dropdownMenuRight = windowWidth - dropdownToggle.offset().left - dropdownToggleWidth; } else if (lxDropdown.position === 'center') { dropdownMenuLeft = (dropdownToggle.offset().left + (dropdownToggleWidth / 2)) - (dropdownMenuWidth / 2); dropdownMenuRight = 'auto'; } dropdownMenu.css( { left: dropdownMenuLeft, right: dropdownMenuRight, width: dropdownMenuWidth }); if (availableHeight.direction === 'top') { dropdownMenu.css( { bottom: lxDropdown.overToggle ? (windowHeight - dropdownToggleTop - <API key>) : (windowHeight - dropdownToggleTop + ~~lxDropdown.offset) }); return availableHeight.top; } else if (availableHeight.direction === 'bottom') { dropdownMenu.css( { top: lxDropdown.overToggle ? dropdownToggleTop : (dropdownToggleTop + <API key> + ~~lxDropdown.offset) }); return availableHeight.bottom; } } function openDropdownMenu() { lxDropdown.isOpen = true; LxDepthService.register(); scrollMask .css('z-index', LxDepthService.getDepth()) .appendTo('body'); scrollMask.on('wheel', function preventDefault(e) { e.preventDefault(); }); enableBodyScroll = LxUtils.disableBodyScroll(); if (lxDropdown.hasToggle) { dropdownToggle .css('z-index', LxDepthService.getDepth() + 1) .on('wheel', function preventDefault(e) { e.preventDefault(); }); } dropdownMenu .addClass('<API key>') .css('z-index', LxDepthService.getDepth() + 1) .appendTo('body'); dropdownMenu.on('wheel', function preventDefault(e) { var d = e.originalEvent.deltaY; if (d < 0 && dropdownMenu.scrollTop() === 0) { e.preventDefault(); } else { if (d > 0 && (dropdownMenu.scrollTop() == dropdownMenu.get(0).scrollHeight - dropdownMenu.innerHeight())) { e.preventDefault(); } } }); if (lxDropdown.escapeClose) { idEventScheduler = <API key>.register('keyup', onKeyUp); } openTimeout = $timeout(function() { var availableHeight = <API key>() - ~~lxDropdown.offset; var dropdownMenuHeight = dropdownMenu.outerHeight(); var dropdownMenuWidth = dropdownMenu.outerWidth(); var enoughHeight = true; if (availableHeight < dropdownMenuHeight) { enoughHeight = false; dropdownMenuHeight = availableHeight; } if (lxDropdown.effect === 'expand') { dropdownMenu.css( { width: 0, height: 0, opacity: 1, overflow: 'hidden' }); dropdownMenu.find('.<API key>').css( { width: dropdownMenuWidth, height: dropdownMenuHeight }); dropdownMenu.velocity( { width: dropdownMenuWidth }, { duration: 200, easing: 'easeOutQuint', queue: false }); dropdownMenu.velocity( { height: dropdownMenuHeight }, { duration: 500, easing: 'easeOutQuint', queue: false, complete: function() { dropdownMenu.css( { overflow: 'auto' }); if (angular.isUndefined(lxDropdown.width)) { dropdownMenu.css( { width: 'auto' }); } $timeout(<API key>); dropdownMenu.find('.<API key>').removeAttr('style'); dropdownInterval = $interval(<API key>, 500); } }); } else if (lxDropdown.effect === 'fade') { dropdownMenu.css( { height: dropdownMenuHeight }); dropdownMenu.velocity( { opacity: 1, }, { duration: 200, easing: 'linear', queue: false, complete: function() { $timeout(<API key>); dropdownInterval = $interval(<API key>, 500); } }); } else if (lxDropdown.effect === 'none') { dropdownMenu.css( { opacity: 1 }); $timeout(<API key>); dropdownInterval = $interval(<API key>, 500); } }); } function onKeyUp(_event) { if (_event.keyCode == 27) { closeDropdownMenu(); } _event.stopPropagation(); } function <API key>(_dropdownMenu) { dropdownMenu = _dropdownMenu; } function <API key>(_dropdownToggle) { if (!positionTarget) { lxDropdown.hasToggle = true; } dropdownToggle = _dropdownToggle; } function toggle() { if (!lxDropdown.isOpen) { openDropdownMenu(); } else { closeDropdownMenu(); } } function <API key>() { if (positionTarget) { <API key>(angular.element(positionTarget)); } var availableHeight = getAvailableHeight(); var dropdownMenuHeight = dropdownMenu.find('.<API key>').outerHeight(); dropdownMenu.css( { height: 'auto' }); if ((availableHeight[availableHeight.direction] - ~~lxDropdown.offset) < dropdownMenuHeight) { if (availableHeight.direction === 'top') { dropdownMenu.css( { top: 0 }); } else if (availableHeight.direction === 'bottom') { dropdownMenu.css( { bottom: 0 }); } } else { if (availableHeight.direction === 'top') { dropdownMenu.css( { top: 'auto' }); } else if (availableHeight.direction === 'bottom') { dropdownMenu.css( { bottom: 'auto' }); } } } } lxDropdownToggle.$inject = ['$timeout', 'LxDropdownService']; function lxDropdownToggle($timeout, LxDropdownService) { return { restrict: 'AE', templateUrl: 'dropdown-toggle.html', require: '^lxDropdown', scope: true, link: link, replace: true, transclude: true }; function link(scope, element, attrs, ctrl) { var hoverTimeout = []; var mouseEvent = ctrl.hover ? 'mouseenter' : 'click'; ctrl.<API key>(element); element.on(mouseEvent, function(_event) { if (mouseEvent === 'mouseenter' && 'ontouchstart' in window) { return; } if (!ctrl.hover) { _event.stopPropagation(); } LxDropdownService.closeActiveDropdown(); LxDropdownService.<API key>(ctrl.uuid); if (ctrl.hover) { ctrl.mouseOnToggle = true; if (!ctrl.isOpen) { hoverTimeout[0] = $timeout(function() { scope.$apply(function() { ctrl.openDropdownMenu(); }); }, ctrl.hoverDelay); } } else { scope.$apply(function() { ctrl.toggle(); }); } }); if (ctrl.hover) { element.on('mouseleave', function() { ctrl.mouseOnToggle = false; $timeout.cancel(hoverTimeout[0]); hoverTimeout[1] = $timeout(function() { if (!ctrl.mouseOnMenu) { scope.$apply(function() { ctrl.closeDropdownMenu(); }); } }, ctrl.hoverDelay); }); } scope.$on('$destroy', function() { element.off(); if (ctrl.hover) { $timeout.cancel(hoverTimeout[0]); $timeout.cancel(hoverTimeout[1]); } }); } } lxDropdownMenu.$inject = ['$timeout']; function lxDropdownMenu($timeout) { return { restrict: 'E', templateUrl: 'dropdown-menu.html', require: ['lxDropdownMenu', '^lxDropdown'], scope: true, link: link, controller: <API key>, controllerAs: 'lxDropdownMenu', bindToController: true, replace: true, transclude: true }; function link(scope, element, attrs, ctrls) { var hoverTimeout; ctrls[1].<API key>(element); ctrls[0].setParentController(ctrls[1]); if (ctrls[1].hover) { element.on('mouseenter', function() { ctrls[1].mouseOnMenu = true; }); element.on('mouseleave', function() { ctrls[1].mouseOnMenu = false; hoverTimeout = $timeout(function() { if (!ctrls[1].mouseOnToggle) { scope.$apply(function() { ctrls[1].closeDropdownMenu(); }); } }, ctrls[1].hoverDelay); }); } scope.$on('$destroy', function() { if (ctrls[1].hover) { element.off(); $timeout.cancel(hoverTimeout); } }); } } <API key>.$inject = ['$element']; function <API key>($element) { var lxDropdownMenu = this; lxDropdownMenu.setParentController = setParentController; function addDropdownDepth() { if (lxDropdownMenu.parentCtrl.depth) { $element.addClass('<API key>-' + lxDropdownMenu.parentCtrl.depth); } else { $element.addClass('<API key>'); } } function setParentController(_parentCtrl) { lxDropdownMenu.parentCtrl = _parentCtrl; addDropdownDepth(); } } lxDropdownFilter.$inject = ['$timeout']; function lxDropdownFilter($timeout) { return { restrict: 'A', link: link }; function link(scope, element) { var focusTimeout; element.on('click', function(_event) { _event.stopPropagation(); }); focusTimeout = $timeout(function() { element.find('input').focus(); }, 200); scope.$on('$destroy', function() { $timeout.cancel(focusTimeout); element.off(); }); } } })(); (function() { 'use strict'; angular .module('lumx.dropdown') .service('LxDropdownService', LxDropdownService); LxDropdownService.$inject = ['$document', '$rootScope', '$timeout']; function LxDropdownService($document, $rootScope, $timeout) { var service = this; var activeDropdownUuid; service.close = close; service.closeActiveDropdown = closeActiveDropdown; service.open = open; service.isOpen = isOpen; service.<API key> = <API key>; service.<API key> = <API key>; $document.on('click', closeActiveDropdown); function close(_uuid) { $rootScope.$broadcast('lx-dropdown__close', { uuid: _uuid }); } function closeActiveDropdown() { $rootScope.$broadcast('lx-dropdown__close', { uuid: activeDropdownUuid }); } function open(_uuid, _target) { $rootScope.$broadcast('lx-dropdown__open', { uuid: _uuid, target: _target }); } function isOpen(_uuid) { return activeDropdownUuid === _uuid; } function <API key>(_uuid) { activeDropdownUuid = _uuid; } function <API key>() { activeDropdownUuid = undefined; } } })(); (function() { 'use strict'; angular .module('lumx.fab') .directive('lxFab', lxFab) .directive('lxFabTrigger', lxFabTrigger) .directive('lxFabActions', lxFabActions); function lxFab() { return { restrict: 'E', templateUrl: 'fab.html', scope: true, link: link, controller: LxFabController, controllerAs: 'lxFab', bindToController: true, transclude: true, replace: true }; function link(scope, element, attrs, ctrl) { attrs.$observe('lxDirection', function(newDirection) { ctrl.setFabDirection(newDirection); }); } } function LxFabController() { var lxFab = this; lxFab.setFabDirection = setFabDirection; function setFabDirection(_direction) { lxFab.lxDirection = _direction; } } function lxFabTrigger() { return { restrict: 'E', require: '^lxFab', templateUrl: 'fab-trigger.html', transclude: true, replace: true }; } function lxFabActions() { return { restrict: 'E', require: '^lxFab', templateUrl: 'fab-actions.html', link: link, transclude: true, replace: true }; function link(scope, element, attrs, ctrl) { scope.parentCtrl = ctrl; } } })(); (function() { 'use strict'; angular .module('lumx.file-input') .directive('lxFileInput', lxFileInput); function lxFileInput() { return { restrict: 'E', templateUrl: 'file-input.html', scope: { label: '@lxLabel', callback: '&?lxCallback' }, link: link, controller: <API key>, controllerAs: 'lxFileInput', bindToController: true, replace: true }; function link(scope, element, attrs, ctrl) { var input = element.find('input'); input .on('change', ctrl.updateModel) .on('blur', function() { element.removeClass('<API key>'); }); scope.$on('$destroy', function() { input.off(); }); } } <API key>.$inject = ['$element', '$scope', '$timeout']; function <API key>($element, $scope, $timeout) { var lxFileInput = this; var input = $element.find('input'); var timer; lxFileInput.updateModel = updateModel; $scope.$on('$destroy', function() { $timeout.cancel(timer); }); function setFileName() { if (input.val()) { lxFileInput.fileName = input.val().replace(/C:\\fakepath\\/i, ''); $element.addClass('<API key>'); $element.addClass('<API key>'); } else { lxFileInput.fileName = undefined; $element.removeClass('<API key>'); } input.val(undefined); } function updateModel() { if (angular.isDefined(lxFileInput.callback)) { lxFileInput.callback( { newFile: input[0].files[0] }); } timer = $timeout(setFileName); } } })(); (function() { 'use strict'; angular .module('lumx.icon') .directive('lxIcon', lxIcon); function lxIcon() { return { restrict: 'E', templateUrl: 'icon.html', scope: { color: '@?lxColor', id: '@lxId', size: '@?lxSize', type: '@?lxType' }, controller: LxIconController, controllerAs: 'lxIcon', bindToController: true, replace: true }; } function LxIconController() { var lxIcon = this; lxIcon.getClass = getClass; function getClass() { var iconClass = []; iconClass.push('mdi-' + lxIcon.id); if (angular.isDefined(lxIcon.size)) { iconClass.push('icon--' + lxIcon.size); } if (angular.isDefined(lxIcon.color)) { iconClass.push('icon--' + lxIcon.color); } if (angular.isDefined(lxIcon.type)) { iconClass.push('icon--' + lxIcon.type); } return iconClass; } } })(); (function() { 'use strict'; angular .module('lumx.notification') .service('<API key>', <API key>); <API key>.$inject = ['$injector', '$rootScope', '$timeout', 'LxDepthService', '<API key>']; function <API key>($injector, $rootScope, $timeout, LxDepthService, <API key>) { var service = this; var dialogFilter; var dialog; var idEventScheduler; var notificationList = []; var actionClicked = false; service.alert = showAlertDialog; service.confirm = showConfirmDialog; service.error = notifyError; service.info = notifyInfo; service.notify = notify; service.success = notifySuccess; service.warning = notifyWarning; // NOTIFICATION function deleteNotification(_notification, _callback) { _callback = (!angular.isFunction(_callback)) ? angular.noop : _callback; var notifIndex = notificationList.indexOf(_notification); var dnOffset = angular.isDefined(notificationList[notifIndex]) ? 24 + notificationList[notifIndex].height : 24; for (var idx = 0; idx < notifIndex; idx++) { if (notificationList.length > 1) { notificationList[idx].margin -= dnOffset; notificationList[idx].elem.css('marginBottom', notificationList[idx].margin + 'px'); } } _notification.elem.removeClass('<API key>'); $timeout(function() { _notification.elem.remove(); // Find index again because notificationList may have changed notifIndex = notificationList.indexOf(_notification); if (notifIndex != -1) { notificationList.splice(notifIndex, 1); } _callback(actionClicked); actionClicked = false }, 400); } function getElementHeight(_elem) { return parseFloat(window.getComputedStyle(_elem, null).height); } function moveNotificationUp() { var newNotifIndex = notificationList.length - 1; notificationList[newNotifIndex].height = getElementHeight(notificationList[newNotifIndex].elem[0]); var upOffset = 0; for (var idx = newNotifIndex; idx >= 0; idx { if (notificationList.length > 1 && idx !== newNotifIndex) { upOffset = 24 + notificationList[newNotifIndex].height; notificationList[idx].margin += upOffset; notificationList[idx].elem.css('marginBottom', notificationList[idx].margin + 'px'); } } } function notify(_text, _icon, _sticky, _color, _action, _callback, _delay) { var $compile = $injector.get('$compile'); LxDepthService.register(); var notification = angular.element('<div/>', { class: 'notification' }); var notificationText = angular.element('<span/>', { class: '<API key>', html: _text }); var notificationTimeout; var notificationDelay = _delay || 6000; if (angular.isDefined(_icon)) { var notificationIcon = angular.element('<i/>', { class: 'notification__icon mdi mdi-' + _icon }); notification .addClass('<API key>') .append(notificationIcon); } if (angular.isDefined(_color)) { notification.addClass('notification--' + _color); } notification.append(notificationText); if (angular.isDefined(_action)) { var notificationAction = angular.element('<button/>', { class: '<API key> btn btn--m btn--flat', html: _action }); if (angular.isDefined(_color)) { notificationAction.addClass('btn--' + _color); } else { notificationAction.addClass('btn--white'); } notificationAction.attr('lx-ripple', ''); $compile(notificationAction)($rootScope); notificationAction.bind('click', function() { actionClicked = true; }); notification .addClass('<API key>') .append(notificationAction); } notification .css('z-index', LxDepthService.getDepth()) .appendTo('body'); $timeout(function() { notification.addClass('<API key>'); }, 100); var data = { elem: notification, margin: 0 }; notificationList.push(data); moveNotificationUp(); notification.bind('click', function() { deleteNotification(data, _callback); if (angular.isDefined(notificationTimeout)) { $timeout.cancel(notificationTimeout); } }); if (angular.isUndefined(_sticky) || !_sticky) { notificationTimeout = $timeout(function() { deleteNotification(data, _callback); }, notificationDelay); } } function notifyError(_text, _sticky) { notify(_text, 'alert-circle', _sticky, 'red'); } function notifyInfo(_text, _sticky) { notify(_text, 'information-outline', _sticky, 'blue'); } function notifySuccess(_text, _sticky) { notify(_text, 'check', _sticky, 'green'); } function notifyWarning(_text, _sticky) { notify(_text, 'alert', _sticky, 'orange'); } // ALERT & CONFIRM function buildDialogActions(_buttons, _callback, _unbind) { var $compile = $injector.get('$compile'); var dialogActions = angular.element('<div/>', { class: 'dialog__actions' }); var dialogLastBtn = angular.element('<button/>', { class: 'btn btn--m btn--blue btn--flat', text: _buttons.ok }); if (angular.isDefined(_buttons.cancel)) { var dialogFirstBtn = angular.element('<button/>', { class: 'btn btn--m btn--red btn--flat', text: _buttons.cancel }); dialogFirstBtn.attr('lx-ripple', ''); $compile(dialogFirstBtn)($rootScope); dialogActions.append(dialogFirstBtn); dialogFirstBtn.bind('click', function() { _callback(false); closeDialog(); }); } dialogLastBtn.attr('lx-ripple', ''); $compile(dialogLastBtn)($rootScope); dialogActions.append(dialogLastBtn); dialogLastBtn.bind('click', function() { _callback(true); closeDialog(); }); if (!_unbind) { idEventScheduler = <API key>.register('keyup', function(event) { if (event.keyCode == 13) { _callback(true); closeDialog(); } else if (event.keyCode == 27) { _callback(angular.isUndefined(_buttons.cancel)); closeDialog(); } event.stopPropagation(); }); } return dialogActions; } function buildDialogContent(_text) { var dialogContent = angular.element('<div/>', { class: 'dialog__content p++ pt0 tc-black-2', text: _text }); return dialogContent; } function buildDialogHeader(_title) { var dialogHeader = angular.element('<div/>', { class: 'dialog__header p++ fs-title', text: _title }); return dialogHeader; } function closeDialog() { if (angular.isDefined(idEventScheduler)) { $timeout(function() { <API key>.unregister(idEventScheduler); idEventScheduler = undefined; }, 1); } dialogFilter.removeClass('<API key>'); dialog.removeClass('dialog--is-shown'); $timeout(function() { dialogFilter.remove(); dialog.remove(); }, 600); } function showAlertDialog(_title, _text, _button, _callback, _unbind) { LxDepthService.register(); dialogFilter = angular.element('<div/>', { class: 'dialog-filter' }); dialog = angular.element('<div/>', { class: 'dialog dialog--alert' }); var dialogHeader = buildDialogHeader(_title); var dialogContent = buildDialogContent(_text); var dialogActions = buildDialogActions( { ok: _button }, _callback, _unbind); dialogFilter .css('z-index', LxDepthService.getDepth()) .appendTo('body'); dialog .append(dialogHeader) .append(dialogContent) .append(dialogActions) .css('z-index', LxDepthService.getDepth() + 1) .appendTo('body') .show() .focus(); $timeout(function() { angular.element(document.activeElement).blur(); dialogFilter.addClass('<API key>'); dialog.addClass('dialog--is-shown'); }, 100); } function showConfirmDialog(_title, _text, _buttons, _callback, _unbind) { LxDepthService.register(); dialogFilter = angular.element('<div/>', { class: 'dialog-filter' }); dialog = angular.element('<div/>', { class: 'dialog dialog--alert' }); var dialogHeader = buildDialogHeader(_title); var dialogContent = buildDialogContent(_text); var dialogActions = buildDialogActions(_buttons, _callback, _unbind); dialogFilter .css('z-index', LxDepthService.getDepth()) .appendTo('body'); dialog .append(dialogHeader) .append(dialogContent) .append(dialogActions) .css('z-index', LxDepthService.getDepth() + 1) .appendTo('body') .show() .focus(); $timeout(function() { angular.element(document.activeElement).blur(); dialogFilter.addClass('<API key>'); dialog.addClass('dialog--is-shown'); }, 100); } } })(); (function() { 'use strict'; angular .module('lumx.progress') .directive('lxProgress', lxProgress); function lxProgress() { return { restrict: 'E', templateUrl: 'progress.html', scope: { lxColor: '@?', lxDiameter: '@?', lxType: '@', lxValue: '@' }, controller: <API key>, controllerAs: 'lxProgress', bindToController: true, replace: true }; } function <API key>() { var lxProgress = this; lxProgress.<API key> = <API key>; lxProgress.<API key> = <API key>; lxProgress.getProgressDiameter = getProgressDiameter; init(); function <API key>() { if (angular.isDefined(lxProgress.lxValue)) { return { 'stroke-dasharray': lxProgress.lxValue * 1.26 + ',200' }; } } function <API key>() { if (angular.isDefined(lxProgress.lxValue)) { return { 'transform': 'scale(' + lxProgress.lxValue / 100 + ', 1)' }; } } function getProgressDiameter() { if (lxProgress.lxType === 'circular') { return { 'transform': 'scale(' + parseInt(lxProgress.lxDiameter) / 100 + ')' }; } return; } function init() { lxProgress.lxDiameter = angular.isDefined(lxProgress.lxDiameter) ? lxProgress.lxDiameter : 100; lxProgress.lxColor = angular.isDefined(lxProgress.lxColor) ? lxProgress.lxColor : 'primary'; } } })(); (function() { 'use strict'; angular .module('lumx.radio-button') .directive('lxRadioGroup', lxRadioGroup) .directive('lxRadioButton', lxRadioButton) .directive('lxRadioButtonLabel', lxRadioButtonLabel) .directive('lxRadioButtonHelp', lxRadioButtonHelp); function lxRadioGroup() { return { restrict: 'E', templateUrl: 'radio-group.html', transclude: true, replace: true }; } function lxRadioButton() { return { restrict: 'E', templateUrl: 'radio-button.html', scope: { lxColor: '@?', name: '@', ngChange: '&?', ngDisabled: '=?', ngModel: '=', ngValue: '=?', value: '@?' }, controller: <API key>, controllerAs: 'lxRadioButton', bindToController: true, transclude: true, replace: true }; } <API key>.$inject = ['$scope', '$timeout', 'LxUtils']; function <API key>($scope, $timeout, LxUtils) { var lxRadioButton = this; var radioButtonId; var <API key>; var timer; lxRadioButton.getRadioButtonId = getRadioButtonId; lxRadioButton.<API key> = <API key>; lxRadioButton.setRadioButtonId = setRadioButtonId; lxRadioButton.<API key> = <API key>; lxRadioButton.triggerNgChange = triggerNgChange; $scope.$on('$destroy', function() { $timeout.cancel(timer); }); init(); function getRadioButtonId() { return radioButtonId; } function <API key>() { return <API key>; } function init() { setRadioButtonId(LxUtils.generateUUID()); <API key>(false); if (angular.isDefined(lxRadioButton.value) && angular.isUndefined(lxRadioButton.ngValue)) { lxRadioButton.ngValue = lxRadioButton.value; } lxRadioButton.lxColor = angular.isUndefined(lxRadioButton.lxColor) ? 'accent' : lxRadioButton.lxColor; } function setRadioButtonId(_radioButtonId) { radioButtonId = _radioButtonId; } function <API key>(<API key>) { <API key> = <API key>; } function triggerNgChange() { timer = $timeout(lxRadioButton.ngChange); } } function lxRadioButtonLabel() { return { restrict: 'AE', require: ['^lxRadioButton', '^lxRadioButtonLabel'], templateUrl: 'radio-button-label.html', link: link, controller: <API key>, controllerAs: 'lxRadioButtonLabel', bindToController: true, transclude: true, replace: true }; function link(scope, element, attrs, ctrls) { ctrls[0].<API key>(true); ctrls[1].setRadioButtonId(ctrls[0].getRadioButtonId()); } } function <API key>() { var lxRadioButtonLabel = this; var radioButtonId; lxRadioButtonLabel.getRadioButtonId = getRadioButtonId; lxRadioButtonLabel.setRadioButtonId = setRadioButtonId; function getRadioButtonId() { return radioButtonId; } function setRadioButtonId(_radioButtonId) { radioButtonId = _radioButtonId; } } function lxRadioButtonHelp() { return { restrict: 'AE', require: '^lxRadioButton', templateUrl: 'radio-button-help.html', transclude: true, replace: true }; } })(); (function() { 'use strict'; angular .module('lumx.ripple') .directive('lxRipple', lxRipple); lxRipple.$inject = ['$timeout']; function lxRipple($timeout) { return { restrict: 'A', link: link, }; function link(scope, element, attrs) { var timer; element .css( { position: 'relative', overflow: 'hidden' }) .on('mousedown', function(e) { var ripple; if (element.find('.ripple').length === 0) { ripple = angular.element('<span/>', { class: 'ripple' }); if (attrs.lxRipple) { ripple.addClass('bgc-' + attrs.lxRipple); } element.prepend(ripple); } else { ripple = element.find('.ripple'); } ripple.removeClass('ripple--is-animated'); if (!ripple.height() && !ripple.width()) { var diameter = Math.max(element.outerWidth(), element.outerHeight()); ripple.css( { height: diameter, width: diameter }); } var x = e.pageX - element.offset().left - ripple.width() / 2; var y = e.pageY - element.offset().top - ripple.height() / 2; ripple.css( { top: y + 'px', left: x + 'px' }).addClass('ripple--is-animated'); timer = $timeout(function() { ripple.removeClass('ripple--is-animated'); }, 651); }); scope.$on('$destroy', function() { $timeout.cancel(timer); element.off(); }); } } })(); (function() { 'use strict'; angular .module('lumx.search-filter') .filter('lxSearchHighlight', lxSearchHighlight) .directive('lxSearchFilter', lxSearchFilter); lxSearchHighlight.$inject = ['$sce']; function lxSearchHighlight($sce) { function escapeRegexp(queryToEscape) { return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1'); } return function (matchItem, query, icon) { var string = ''; if (icon) { string += '<i class="mdi mdi-' + icon + '"></i>'; } string += query && matchItem ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem; return $sce.trustAsHtml(string); }; } function lxSearchFilter() { return { restrict: 'E', templateUrl: 'search-filter.html', scope: { autocomplete: '&?lxAutocomplete', closed: '=?lxClosed', color: '@?lxColor', icon: '@?lxIcon', onSelect: '=?lxOnSelect', searchOnFocus: '=?lxSearchOnFocus', theme: '@?lxTheme', width: '@?lxWidth' }, link: link, controller: <API key>, controllerAs: 'lxSearchFilter', bindToController: true, replace: true, transclude: true }; function link(scope, element, attrs, ctrl, transclude) { var input; attrs.$observe('lxWidth', function(newWidth) { if (angular.isDefined(scope.lxSearchFilter.closed) && scope.lxSearchFilter.closed) { element.find('.<API key>').css('width', newWidth); } }); transclude(function() { input = element.find('input'); ctrl.setInput(input); ctrl.setModel(input.data('$ngModelController')); input.on('focus', ctrl.focusInput); input.on('blur', ctrl.blurInput); input.on('keydown', ctrl.keyEvent); }); scope.$on('$destroy', function() { input.off(); }); } } <API key>.$inject = ['$element', '$scope', 'LxDropdownService', '<API key>', 'LxUtils']; function <API key>($element, $scope, LxDropdownService, <API key>, LxUtils) { var lxSearchFilter = this; var <API key>; var input; var itemSelected = false; lxSearchFilter.blurInput = blurInput; lxSearchFilter.clearInput = clearInput; lxSearchFilter.focusInput = focusInput; lxSearchFilter.getClass = getClass; lxSearchFilter.keyEvent = keyEvent; lxSearchFilter.openInput = openInput; lxSearchFilter.selectItem = selectItem; lxSearchFilter.setInput = setInput; lxSearchFilter.setModel = setModel; lxSearchFilter.activeChoiceIndex = -1; lxSearchFilter.color = angular.isDefined(lxSearchFilter.color) ? lxSearchFilter.color : 'black'; lxSearchFilter.dropdownId = LxUtils.generateUUID(); lxSearchFilter.theme = angular.isDefined(lxSearchFilter.theme) ? lxSearchFilter.theme : 'light'; function blurInput() { if (angular.isDefined(lxSearchFilter.closed) && lxSearchFilter.closed && !input.val()) { $element.velocity( { width: 40 }, { duration: 400, easing: 'easeOutQuint', queue: false }); } if (!input.val()) { lxSearchFilter.modelController.$setViewValue(undefined); } } function clearInput() { lxSearchFilter.modelController.$setViewValue(undefined); lxSearchFilter.modelController.$render(); // Temporarily disabling search on focus since we never want to trigger it when clearing the input. var searchOnFocus = lxSearchFilter.searchOnFocus; lxSearchFilter.searchOnFocus = false; input.focus(); lxSearchFilter.searchOnFocus = searchOnFocus; } function focusInput() { if (!lxSearchFilter.searchOnFocus) { return; } updateAutocomplete(lxSearchFilter.modelController.$viewValue, true); } function getClass() { var searchFilterClass = []; if (angular.isUndefined(lxSearchFilter.closed) || !lxSearchFilter.closed) { searchFilterClass.push('<API key>'); } if (angular.isDefined(lxSearchFilter.closed) && lxSearchFilter.closed) { searchFilterClass.push('<API key>'); } if (input.val()) { searchFilterClass.push('<API key>'); } if (angular.isDefined(lxSearchFilter.color)) { searchFilterClass.push('search-filter--' + lxSearchFilter.color); } if (angular.isDefined(lxSearchFilter.theme)) { searchFilterClass.push('<API key>-' + lxSearchFilter.theme); } if (angular.isFunction(lxSearchFilter.autocomplete)) { searchFilterClass.push('<API key>'); } if (LxDropdownService.isOpen(lxSearchFilter.dropdownId)) { searchFilterClass.push('<API key>'); } return searchFilterClass; } function keyEvent(_event) { if (!angular.isFunction(lxSearchFilter.autocomplete)) { return; } if (!LxDropdownService.isOpen(lxSearchFilter.dropdownId)) { lxSearchFilter.activeChoiceIndex = -1; } switch (_event.keyCode) { case 13: keySelect(); if (lxSearchFilter.activeChoiceIndex > -1) { _event.preventDefault(); } break; case 38: keyUp(); _event.preventDefault(); break; case 40: keyDown(); _event.preventDefault(); break; } $scope.$apply(); } function keyDown() { if (lxSearchFilter.autocompleteList.length) { lxSearchFilter.activeChoiceIndex += 1; if (lxSearchFilter.activeChoiceIndex >= lxSearchFilter.autocompleteList.length) { lxSearchFilter.activeChoiceIndex = 0; } } } function keySelect() { if (!lxSearchFilter.autocompleteList || lxSearchFilter.activeChoiceIndex === -1) { return; } selectItem(lxSearchFilter.autocompleteList[lxSearchFilter.activeChoiceIndex]); } function keyUp() { if (lxSearchFilter.autocompleteList.length) { lxSearchFilter.activeChoiceIndex -= 1; if (lxSearchFilter.activeChoiceIndex < 0) { lxSearchFilter.activeChoiceIndex = lxSearchFilter.autocompleteList.length - 1; } } } function <API key>(autocompleteList) { lxSearchFilter.autocompleteList = autocompleteList; if (lxSearchFilter.autocompleteList.length) { LxDropdownService.open(lxSearchFilter.dropdownId, $element); } else { LxDropdownService.close(lxSearchFilter.dropdownId); } lxSearchFilter.isLoading = false; } function onAutocompleteError(error) { <API key>.error(error); lxSearchFilter.isLoading = false; } function openInput() { if (angular.isDefined(lxSearchFilter.closed) && lxSearchFilter.closed) { $element.velocity( { width: angular.isDefined(lxSearchFilter.width) ? parseInt(lxSearchFilter.width) : 240 }, { duration: 400, easing: 'easeOutQuint', queue: false, complete: function() { input.focus(); } }); } else { input.focus(); } } function selectItem(_item) { itemSelected = true; LxDropdownService.close(lxSearchFilter.dropdownId); lxSearchFilter.modelController.$setViewValue(_item); lxSearchFilter.modelController.$render(); if (angular.isFunction(lxSearchFilter.onSelect)) { lxSearchFilter.onSelect(_item); } } function setInput(_input) { input = _input; } function setModel(_modelController) { lxSearchFilter.modelController = _modelController; if (angular.isFunction(lxSearchFilter.autocomplete) && angular.isFunction(lxSearchFilter.autocomplete())) { <API key> = LxUtils.debounce(function() { lxSearchFilter.isLoading = true; (lxSearchFilter.autocomplete()).apply(this, arguments); }, 500); lxSearchFilter.modelController.$parsers.push(updateAutocomplete); } } function updateAutocomplete(_newValue, _immediate) { if ((_newValue || (angular.isUndefined(_newValue) && lxSearchFilter.searchOnFocus)) && !itemSelected) { if (_immediate) { lxSearchFilter.isLoading = true; (lxSearchFilter.autocomplete())(_newValue, <API key>, onAutocompleteError); } else { <API key>(_newValue, <API key>, onAutocompleteError); } } else { <API key>.clear(); LxDropdownService.close(lxSearchFilter.dropdownId); } itemSelected = false; return _newValue; } } })(); (function() { 'use strict'; angular .module('lumx.select') .filter('filterChoices', filterChoices) .directive('lxSelect', lxSelect) .directive('lxSelectSelected', lxSelectSelected) .directive('lxSelectChoices', lxSelectChoices); filterChoices.$inject = ['$filter']; function filterChoices($filter) { return function(choices, externalFilter, textFilter) { if (externalFilter) { return choices; } var toFilter = []; if (!angular.isArray(choices)) { if (angular.isObject(choices)) { for (var idx in choices) { if (angular.isArray(choices[idx])) { toFilter = toFilter.concat(choices[idx]); } } } } else { toFilter = choices; } return $filter('filter')(toFilter, textFilter); }; } function lxSelect() { return { restrict: 'E', templateUrl: 'select.html', scope: { allowClear: '=?lxAllowClear', allowNewValue: '=?lxAllowNewValue', autocomplete: '=?lxAutocomplete', newValueTransform: '=?lxNewValueTransform', choices: '=?lxChoices', choicesCustomStyle: '=?<API key>', customStyle: '=?lxCustomStyle', displayFilter: '=?lxDisplayFilter', error: '=?lxError', filter: '&?lxFilter', fixedLabel: '=?lxFixedLabel', helper: '=?lxHelper', helperMessage: '@?lxHelperMessage', label: '@?lxLabel', loading: '=?lxLoading', modelToSelection: '&?lxModelToSelection', multiple: '=?lxMultiple', ngChange: '&?', ngDisabled: '=?', ngModel: '=', selectionToModel: '&?lxSelectionToModel', theme: '@?lxTheme', valid: '=?lxValid', viewMode: '@?lxViewMode' }, link: link, controller: LxSelectController, controllerAs: 'lxSelect', bindToController: true, replace: true, transclude: true }; function link(scope, element, attrs) { var backwardOneWay = ['customStyle']; var backwardTwoWay = ['allowClear', 'choices', 'error', 'loading', 'multiple', 'valid']; angular.forEach(backwardOneWay, function(attribute) { if (angular.isDefined(attrs[attribute])) { attrs.$observe(attribute, function(newValue) { scope.lxSelect[attribute] = newValue; }); } }); angular.forEach(backwardTwoWay, function(attribute) { if (angular.isDefined(attrs[attribute])) { scope.$watch(function() { return scope.$parent.$eval(attrs[attribute]); }, function(newValue) { if (attribute === 'multiple' && angular.isUndefined(newValue)) { scope.lxSelect[attribute] = true; } else { scope.lxSelect[attribute] = newValue; } }); } }); attrs.$observe('placeholder', function(newValue) { scope.lxSelect.label = newValue; }); attrs.$observe('change', function(newValue) { scope.lxSelect.ngChange = function(data) { return scope.$parent.$eval(newValue, data); }; }); attrs.$observe('filter', function(newValue) { scope.lxSelect.filter = function(data) { return scope.$parent.$eval(newValue, data); }; scope.lxSelect.displayFilter = true; }); attrs.$observe('modelToSelection', function(newValue) { scope.lxSelect.modelToSelection = function(data) { return scope.$parent.$eval(newValue, data); }; }); attrs.$observe('selectionToModel', function(newValue) { scope.lxSelect.selectionToModel = function(data) { return scope.$parent.$eval(newValue, data); }; }); } } LxSelectController.$inject = ['$interpolate', '$element', '$filter', '$sce', 'LxDropdownService', 'LxUtils']; function LxSelectController($interpolate, $element, $filter, $sce, LxDropdownService, LxUtils) { var lxSelect = this; var choiceTemplate; var selectedTemplate; lxSelect.displayChoice = displayChoice; lxSelect.displaySelected = displaySelected; lxSelect.displaySubheader = displaySubheader; lxSelect.getFilteredChoices = getFilteredChoices; lxSelect.getSelectedModel = getSelectedModel; lxSelect.isSelected = isSelected; lxSelect.keyEvent = keyEvent; lxSelect.<API key> = <API key>; lxSelect.<API key> = <API key>; lxSelect.select = select; lxSelect.toggleChoice = toggleChoice; lxSelect.unselect = unselect; lxSelect.updateFilter = updateFilter; lxSelect.helperDisplayable = helperDisplayable; lxSelect.activeChoiceIndex = -1; lxSelect.activeSelectedIndex = -1; lxSelect.uuid = LxUtils.generateUUID(); lxSelect.filterModel = undefined; lxSelect.ngModel = angular.isUndefined(lxSelect.ngModel) && lxSelect.multiple ? [] : lxSelect.ngModel; lxSelect.unconvertedModel = lxSelect.multiple ? [] : undefined; lxSelect.viewMode = angular.isUndefined(lxSelect.viewMode) ? 'field' : 'chips'; function arrayObjectIndexOf(arr, obj) { for (var i = 0; i < arr.length; i++) { if (angular.equals(arr[i], obj)) { return i; } } return -1; } function displayChoice(_choice) { var choiceScope = { $choice: _choice }; return $sce.trustAsHtml($interpolate(choiceTemplate)(choiceScope)); } function displaySelected(_selected) { var selectedScope = {}; if (!angular.isArray(lxSelect.choices)) { var found = false; for (var header in lxSelect.choices) { if (found) { break; } if (lxSelect.choices.hasOwnProperty(header)) { for (var idx = 0, len = lxSelect.choices[header].length; idx < len; idx++) { if (angular.equals(_selected, lxSelect.choices[header][idx])) { selectedScope.$selectedSubheader = header; found = true; break; } } } } } if (angular.isDefined(_selected)) { selectedScope.$selected = _selected; } else { selectedScope.$selected = getSelectedModel(); } return $sce.trustAsHtml($interpolate(selectedTemplate)(selectedScope)); } function displaySubheader(_subheader) { return $sce.trustAsHtml(_subheader); } function getFilteredChoices() { return $filter('filterChoices')(lxSelect.choices, lxSelect.filter, lxSelect.filterModel); } function getSelectedModel() { if (angular.isDefined(lxSelect.modelToSelection) || angular.isDefined(lxSelect.selectionToModel)) { return lxSelect.unconvertedModel; } else { return lxSelect.ngModel; } } function isSelected(_choice) { if (lxSelect.multiple && angular.isDefined(getSelectedModel())) { return arrayObjectIndexOf(getSelectedModel(), _choice) !== -1; } else if (angular.isDefined(getSelectedModel())) { return angular.equals(getSelectedModel(), _choice); } } function keyEvent(_event) { if (_event.keyCode !== 8) { lxSelect.activeSelectedIndex = -1; } if (!LxDropdownService.isOpen('dropdown-' + lxSelect.uuid)) { lxSelect.activeChoiceIndex = -1; } switch (_event.keyCode) { case 8: keyRemove(); break; case 13: keySelect(); _event.preventDefault(); break; case 38: keyUp(); _event.preventDefault(); break; case 40: keyDown(); _event.preventDefault(); break; } } function keyDown() { var filteredChoices = $filter('filterChoices')(lxSelect.choices, lxSelect.filter, lxSelect.filterModel); if (filteredChoices.length) { lxSelect.activeChoiceIndex += 1; if (lxSelect.activeChoiceIndex >= filteredChoices.length) { lxSelect.activeChoiceIndex = 0; } } if (lxSelect.autocomplete) { LxDropdownService.open('dropdown-' + lxSelect.uuid, '#<API key>-' + lxSelect.uuid); } } function keyRemove() { if (lxSelect.filterModel || !lxSelect.getSelectedModel().length) { return; } if (lxSelect.activeSelectedIndex === -1) { lxSelect.activeSelectedIndex = lxSelect.getSelectedModel().length - 1; } else { unselect(lxSelect.getSelectedModel()[lxSelect.activeSelectedIndex]); } } function keySelect() { var filteredChoices = $filter('filterChoices')(lxSelect.choices, lxSelect.filter, lxSelect.filterModel); if (filteredChoices.length && filteredChoices[lxSelect.activeChoiceIndex]) { toggleChoice(filteredChoices[lxSelect.activeChoiceIndex]); } else if (lxSelect.filterModel && lxSelect.allowNewValue) { if (angular.isArray(getSelectedModel())) { var value = angular.isFunction(lxSelect.newValueTransform) ? lxSelect.newValueTransform(lxSelect.filterModel) : lxSelect.filterModel; var identical = getSelectedModel().some(function (item) { return angular.equals(item, value); }); if (!identical) { getSelectedModel().push(value); } } lxSelect.filterModel = undefined; LxDropdownService.close('dropdown-' + lxSelect.uuid); } } function keyUp() { var filteredChoices = $filter('filterChoices')(lxSelect.choices, lxSelect.filter, lxSelect.filterModel); if (filteredChoices.length) { lxSelect.activeChoiceIndex -= 1; if (lxSelect.activeChoiceIndex < 0) { lxSelect.activeChoiceIndex = filteredChoices.length - 1; } } if (lxSelect.autocomplete) { LxDropdownService.open('dropdown-' + lxSelect.uuid, '#<API key>-' + lxSelect.uuid); } } function <API key>(_choiceTemplate) { choiceTemplate = _choiceTemplate; } function <API key>(_selectedTemplate) { selectedTemplate = _selectedTemplate; } function select(_choice) { if (lxSelect.multiple && angular.isUndefined(lxSelect.ngModel)) { lxSelect.ngModel = []; } if (angular.isDefined(lxSelect.selectionToModel)) { lxSelect.selectionToModel( { data: _choice, callback: function(resp) { if (lxSelect.multiple) { lxSelect.ngModel.push(resp); } else { lxSelect.ngModel = resp; } if (lxSelect.autocomplete) { $element.find('.<API key>').focus(); } } }); } else { if (lxSelect.multiple) { lxSelect.ngModel.push(_choice); } else { lxSelect.ngModel = _choice; } if (lxSelect.autocomplete) { $element.find('.<API key>').focus(); } } } function toggleChoice(_choice, _event) { if (lxSelect.multiple && !lxSelect.autocomplete) { _event.stopPropagation(); } if (lxSelect.multiple && isSelected(_choice)) { unselect(_choice); } else { select(_choice); } if (lxSelect.autocomplete) { lxSelect.activeChoiceIndex = -1; lxSelect.filterModel = undefined; LxDropdownService.close('dropdown-' + lxSelect.uuid); } } function unselect(_choice) { if (angular.isDefined(lxSelect.selectionToModel)) { lxSelect.selectionToModel( { data: _choice, callback: function(resp) { removeElement(lxSelect.ngModel, resp); if (lxSelect.autocomplete) { $element.find('.<API key>').focus(); lxSelect.activeSelectedIndex = -1; } } }); removeElement(lxSelect.unconvertedModel, _choice); } else { removeElement(lxSelect.ngModel, _choice); if (lxSelect.autocomplete) { $element.find('.<API key>').focus(); lxSelect.activeSelectedIndex = -1; } } } function updateFilter() { if (angular.isDefined(lxSelect.filter)) { lxSelect.filter( { newValue: lxSelect.filterModel }); } if (lxSelect.autocomplete) { lxSelect.activeChoiceIndex = -1; if (lxSelect.filterModel) { LxDropdownService.open('dropdown-' + lxSelect.uuid, '#<API key>-' + lxSelect.uuid); } else { LxDropdownService.close('dropdown-' + lxSelect.uuid); } } } function helperDisplayable() { // If helper message is not defined, message is not displayed... if (angular.isUndefined(lxSelect.helperMessage)) { return false; } // If helper is defined return it's state. if (angular.isDefined(lxSelect.helper)) { return lxSelect.helper; } // Else check if there's choices. var choices = lxSelect.getFilteredChoices(); if (angular.isArray(choices)) { return !choices.length; } else if (angular.isObject(choices)) { return !Object.keys(choices).length; } return true; } function removeElement(model, element) { var index = -1; for (var i = 0, len = model.length; i < len; i++) { if (angular.equals(element, model[i])) { index = i; break; } } if (index > -1) { model.splice(index, 1); } } } function lxSelectSelected() { return { restrict: 'E', require: ['lxSelectSelected', '^lxSelect'], templateUrl: 'select-selected.html', link: link, controller: <API key>, controllerAs: 'lxSelectSelected', bindToController: true, transclude: true }; function link(scope, element, attrs, ctrls, transclude) { ctrls[0].setParentController(ctrls[1]); transclude(scope, function(clone) { var template = ''; for (var i = 0; i < clone.length; i++) { template += clone[i].data || clone[i].outerHTML || ''; } ctrls[1].<API key>(template); }); } } function <API key>() { var lxSelectSelected = this; lxSelectSelected.clearModel = clearModel; lxSelectSelected.setParentController = setParentController; lxSelectSelected.removeSelected = removeSelected; function clearModel(_event) { _event.stopPropagation(); lxSelectSelected.parentCtrl.ngModel = undefined; lxSelectSelected.parentCtrl.unconvertedModel = undefined; } function setParentController(_parentCtrl) { lxSelectSelected.parentCtrl = _parentCtrl; } function removeSelected(_selected, _event) { _event.stopPropagation(); lxSelectSelected.parentCtrl.unselect(_selected); } } function lxSelectChoices() { return { restrict: 'E', require: ['lxSelectChoices', '^lxSelect'], templateUrl: 'select-choices.html', link: link, controller: <API key>, controllerAs: 'lxSelectChoices', bindToController: true, transclude: true }; function link(scope, element, attrs, ctrls, transclude) { ctrls[0].setParentController(ctrls[1]); transclude(scope, function(clone) { var template = ''; for (var i = 0; i < clone.length; i++) { template += clone[i].data || clone[i].outerHTML || ''; } ctrls[1].<API key>(template); }); } } <API key>.$inject = ['$scope', '$timeout']; function <API key>($scope, $timeout) { var lxSelectChoices = this; var timer; lxSelectChoices.isArray = isArray; lxSelectChoices.setParentController = setParentController; $scope.$on('$destroy', function() { $timeout.cancel(timer); }); function isArray() { return angular.isArray(lxSelectChoices.parentCtrl.choices); } function setParentController(_parentCtrl) { lxSelectChoices.parentCtrl = _parentCtrl; $scope.$watch(function() { return lxSelectChoices.parentCtrl.ngModel; }, function(newModel, oldModel) { timer = $timeout(function() { if (newModel !== oldModel && angular.isDefined(lxSelectChoices.parentCtrl.ngChange)) { lxSelectChoices.parentCtrl.ngChange( { newValue: newModel, oldValue: oldModel }); } if (angular.isDefined(lxSelectChoices.parentCtrl.modelToSelection) || angular.isDefined(lxSelectChoices.parentCtrl.selectionToModel)) { toSelection(); } }); }, true); } function toSelection() { if (lxSelectChoices.parentCtrl.multiple) { lxSelectChoices.parentCtrl.unconvertedModel = []; angular.forEach(lxSelectChoices.parentCtrl.ngModel, function(item) { lxSelectChoices.parentCtrl.modelToSelection( { data: item, callback: function(resp) { lxSelectChoices.parentCtrl.unconvertedModel.push(resp); } }); }); } else { lxSelectChoices.parentCtrl.modelToSelection( { data: lxSelectChoices.parentCtrl.ngModel, callback: function(resp) { lxSelectChoices.parentCtrl.unconvertedModel = resp; } }); } } } })(); (function() { 'use strict'; angular .module('lumx.stepper') .directive('lxStepper', lxStepper) .directive('lxStep', lxStep) .directive('lxStepNav', lxStepNav); /* Stepper */ function lxStepper() { return { restrict: 'E', templateUrl: 'stepper.html', scope: { cancel: '&?lxCancel', complete: '&lxComplete', isLinear: '=?lxIsLinear', labels: '=?lxLabels', layout: '@?lxLayout' }, controller: LxStepperController, controllerAs: 'lxStepper', bindToController: true, transclude: true }; } function LxStepperController() { var lxStepper = this; var _classes = []; var _defaultValues = { isLinear: true, labels: { 'back': 'Back', 'cancel': 'Cancel', 'continue': 'Continue', 'optional': 'Optional' }, layout: 'horizontal' }; lxStepper.addStep = addStep; lxStepper.getClasses = getClasses; lxStepper.goToStep = goToStep; lxStepper.isComplete = isComplete; lxStepper.updateStep = updateStep; lxStepper.activeIndex = 0; lxStepper.isLinear = angular.isDefined(lxStepper.isLinear) ? lxStepper.isLinear : _defaultValues.isLinear; lxStepper.labels = angular.isDefined(lxStepper.labels) ? lxStepper.labels : _defaultValues.labels; lxStepper.layout = angular.isDefined(lxStepper.layout) ? lxStepper.layout : _defaultValues.layout; lxStepper.steps = []; function addStep(step) { lxStepper.steps.push(step); } function getClasses() { _classes.length = 0; _classes.push('lx-stepper--layout-' + lxStepper.layout); if (lxStepper.isLinear) { _classes.push('<API key>'); } if (lxStepper.steps[lxStepper.activeIndex].feedback) { _classes.push('<API key>'); } if (lxStepper.steps[lxStepper.activeIndex].isLoading) { _classes.push('<API key>'); } return _classes; } function goToStep(index, bypass) { // Check if the the wanted step previous steps are optionals. If so, check if the step before the last optional step is valid to allow going to the wanted step from the nav (only if linear stepper). var <API key>; if (!bypass && lxStepper.isLinear) { for (var i = index - 1; i >= 0; i { if (angular.isDefined(lxStepper.steps[i]) && !lxStepper.steps[i].isOptional) { <API key> = lxStepper.steps[i]; break; } } if (angular.isDefined(<API key>) && <API key>.isValid === true) { bypass = true; } } // Check if the wanted step previous step is not valid to disallow going to the wanted step from the nav (only if linear stepper). if (!bypass && lxStepper.isLinear && angular.isDefined(lxStepper.steps[index - 1]) && (angular.isUndefined(lxStepper.steps[index - 1].isValid) || lxStepper.steps[index - 1].isValid === false)) { return; } if (index < lxStepper.steps.length) { lxStepper.activeIndex = parseInt(index); } } function isComplete() { var countMandatory = 0; var countValid = 0; for (var i = 0, len = lxStepper.steps.length; i < len; i++) { if (!lxStepper.steps[i].isOptional) { countMandatory++; if (lxStepper.steps[i].isValid === true) { countValid++; } } } if (countValid === countMandatory) { lxStepper.complete(); return true; } } function updateStep(step) { for (var i = 0, len = lxStepper.steps.length; i < len; i++) { if (lxStepper.steps[i].uuid === step.uuid) { lxStepper.steps[i].index = step.index; lxStepper.steps[i].label = step.label; return; } } } } /* Step */ function lxStep() { return { restrict: 'E', require: ['lxStep', '^lxStepper'], templateUrl: 'step.html', scope: { feedback: '@?lxFeedback', isEditable: '=?lxIsEditable', isOptional: '=?lxIsOptional', label: '@lxLabel', submit: '&?lxSubmit', validate: '&?lxValidate' }, link: link, controller: LxStepController, controllerAs: 'lxStep', bindToController: true, replace: true, transclude: true }; function link(scope, element, attrs, ctrls) { ctrls[0].init(ctrls[1], element.index()); attrs.$observe('lxFeedback', function(feedback) { ctrls[0].setFeedback(feedback); }); attrs.$observe('lxLabel', function(label) { ctrls[0].setLabel(label); }); attrs.$observe('lxIsEditable', function(isEditable) { ctrls[0].setIsEditable(isEditable); }); attrs.$observe('lxIsOptional', function(isOptional) { ctrls[0].setIsOptional(isOptional); }); } } LxStepController.$inject = ['$q', '<API key>', 'LxUtils']; function LxStepController($q, <API key>, LxUtils) { var lxStep = this; var _classes = []; var _nextStepIndex; lxStep.getClasses = getClasses; lxStep.init = init; lxStep.previousStep = previousStep; lxStep.setFeedback = setFeedback; lxStep.setLabel = setLabel; lxStep.setIsEditable = setIsEditable; lxStep.setIsOptional = setIsOptional; lxStep.submitStep = submitStep; lxStep.step = { errorMessage: undefined, feedback: undefined, index: undefined, isEditable: false, isLoading: false, isOptional: false, isValid: undefined, label: undefined, uuid: LxUtils.generateUUID() }; function getClasses() { _classes.length = 0; if (lxStep.step.index === lxStep.parent.activeIndex) { _classes.push('lx-step--is-active'); } return _classes; } function init(parent, index) { lxStep.parent = parent; lxStep.step.index = index; lxStep.parent.addStep(lxStep.step); } function previousStep() { if (lxStep.step.index > 0) { lxStep.parent.goToStep(lxStep.step.index - 1); } } function setFeedback(feedback) { lxStep.step.feedback = feedback; updateParentStep(); } function setLabel(label) { lxStep.step.label = label; updateParentStep(); } function setIsEditable(isEditable) { lxStep.step.isEditable = isEditable; updateParentStep(); } function setIsOptional(isOptional) { lxStep.step.isOptional = isOptional; updateParentStep(); } function submitStep() { if (lxStep.step.isValid === true && !lxStep.step.isEditable) { lxStep.parent.goToStep(_nextStepIndex, true); return; } var validateFunction = lxStep.validate; var validity = true; if (angular.isFunction(validateFunction)) { validity = validateFunction(); } if (validity === true) { lxStep.step.isLoading = true; updateParentStep(); var submitFunction = lxStep.submit; if (!angular.isFunction(submitFunction)) { submitFunction = function() { return $q(function(resolve) { resolve(); }); }; } var promise = submitFunction(); promise.then(function(nextStepIndex) { lxStep.step.isValid = true; updateParentStep(); var isComplete = lxStep.parent.isComplete(); if (!isComplete) { _nextStepIndex = angular.isDefined(nextStepIndex) && nextStepIndex > lxStep.parent.activeIndex && (!lxStep.parent.isLinear || (lxStep.parent.isLinear && lxStep.parent.steps[nextStepIndex - 1].isOptional)) ? nextStepIndex : lxStep.step.index + 1; lxStep.parent.goToStep(_nextStepIndex, true); } }).catch(function(error) { <API key>.error(error); }).finally(function() { lxStep.step.isLoading = false; updateParentStep(); }); } else { lxStep.step.isValid = false; lxStep.step.errorMessage = validity; updateParentStep(); } } function updateParentStep() { lxStep.parent.updateStep(lxStep.step); } } /* Step nav */ function lxStepNav() { return { restrict: 'E', require: ['lxStepNav', '^lxStepper'], templateUrl: 'step-nav.html', scope: { activeIndex: '@lxActiveIndex', step: '=lxStep' }, link: link, controller: LxStepNavController, controllerAs: 'lxStepNav', bindToController: true, replace: true, transclude: false }; function link(scope, element, attrs, ctrls) { ctrls[0].init(ctrls[1]); } } function LxStepNavController() { var lxStepNav = this; var _classes = []; lxStepNav.getClasses = getClasses; lxStepNav.init = init; function getClasses() { _classes.length = 0; if (parseInt(lxStepNav.step.index) === parseInt(lxStepNav.activeIndex)) { _classes.push('<API key>'); } if (lxStepNav.step.isValid === true) { _classes.push('<API key>'); } else if (lxStepNav.step.isValid === false) { _classes.push('<API key>'); } if (lxStepNav.step.isEditable) { _classes.push('<API key>'); } if (lxStepNav.step.isOptional) { _classes.push('<API key>'); } return _classes; } function init(parent, index) { lxStepNav.parent = parent; } } })(); (function() { 'use strict'; angular .module('lumx.switch') .directive('lxSwitch', lxSwitch) .directive('lxSwitchLabel', lxSwitchLabel) .directive('lxSwitchHelp', lxSwitchHelp); function lxSwitch() { return { restrict: 'E', templateUrl: 'switch.html', scope: { ngModel: '=', name: '@?', ngTrueValue: '@?', ngFalseValue: '@?', ngChange: '&?', ngDisabled: '=?', lxColor: '@?', lxPosition: '@?' }, controller: LxSwitchController, controllerAs: 'lxSwitch', bindToController: true, transclude: true, replace: true }; } LxSwitchController.$inject = ['$scope', '$timeout', 'LxUtils']; function LxSwitchController($scope, $timeout, LxUtils) { var lxSwitch = this; var switchId; var switchHasChildren; var timer; lxSwitch.getSwitchId = getSwitchId; lxSwitch.<API key> = <API key>; lxSwitch.setSwitchId = setSwitchId; lxSwitch.<API key> = <API key>; lxSwitch.triggerNgChange = triggerNgChange; $scope.$on('$destroy', function() { $timeout.cancel(timer); }); init(); function getSwitchId() { return switchId; } function <API key>() { return switchHasChildren; } function init() { setSwitchId(LxUtils.generateUUID()); <API key>(false); lxSwitch.ngTrueValue = angular.isUndefined(lxSwitch.ngTrueValue) ? true : lxSwitch.ngTrueValue; lxSwitch.ngFalseValue = angular.isUndefined(lxSwitch.ngFalseValue) ? false : lxSwitch.ngFalseValue; lxSwitch.lxColor = angular.isUndefined(lxSwitch.lxColor) ? 'accent' : lxSwitch.lxColor; lxSwitch.lxPosition = angular.isUndefined(lxSwitch.lxPosition) ? 'left' : lxSwitch.lxPosition; } function setSwitchId(_switchId) { switchId = _switchId; } function <API key>(_switchHasChildren) { switchHasChildren = _switchHasChildren; } function triggerNgChange() { timer = $timeout(lxSwitch.ngChange); } } function lxSwitchLabel() { return { restrict: 'AE', require: ['^lxSwitch', '^lxSwitchLabel'], templateUrl: 'switch-label.html', link: link, controller: <API key>, controllerAs: 'lxSwitchLabel', bindToController: true, transclude: true, replace: true }; function link(scope, element, attrs, ctrls) { ctrls[0].<API key>(true); ctrls[1].setSwitchId(ctrls[0].getSwitchId()); } } function <API key>() { var lxSwitchLabel = this; var switchId; lxSwitchLabel.getSwitchId = getSwitchId; lxSwitchLabel.setSwitchId = setSwitchId; function getSwitchId() { return switchId; } function setSwitchId(_switchId) { switchId = _switchId; } } function lxSwitchHelp() { return { restrict: 'AE', require: '^lxSwitch', templateUrl: 'switch-help.html', transclude: true, replace: true }; } })(); (function() { 'use strict'; angular .module('lumx.tabs') .directive('lxTabs', lxTabs) .directive('lxTab', lxTab) .directive('lxTabsPanes', lxTabsPanes) .directive('lxTabPane', lxTabPane); function lxTabs() { return { restrict: 'E', templateUrl: 'tabs.html', scope: { layout: '@?lxLayout', theme: '@?lxTheme', color: '@?lxColor', indicator: '@?lxIndicator', activeTab: '=?lxActiveTab', panesId: '@?lxPanesId', links: '=?lxLinks' }, controller: LxTabsController, controllerAs: 'lxTabs', bindToController: true, replace: true, transclude: true }; } LxTabsController.$inject = ['LxUtils', '$element', '$scope', '$timeout']; function LxTabsController(LxUtils, $element, $scope, $timeout) { var lxTabs = this; var tabsLength; var timer1; var timer2; var timer3; var timer4; lxTabs.removeTab = removeTab; lxTabs.setActiveTab = setActiveTab; lxTabs.setViewMode = setViewMode; lxTabs.tabIsActive = tabIsActive; lxTabs.updateTabs = updateTabs; lxTabs.activeTab = angular.isDefined(lxTabs.activeTab) ? lxTabs.activeTab : 0; lxTabs.color = angular.isDefined(lxTabs.color) ? lxTabs.color : 'primary'; lxTabs.indicator = angular.isDefined(lxTabs.indicator) ? lxTabs.indicator : 'accent'; lxTabs.layout = angular.isDefined(lxTabs.layout) ? lxTabs.layout : 'full'; lxTabs.tabs = []; lxTabs.theme = angular.isDefined(lxTabs.theme) ? lxTabs.theme : 'light'; lxTabs.viewMode = angular.isDefined(lxTabs.links) ? 'separate' : 'gather'; $scope.$watch(function() { return lxTabs.activeTab; }, function(_newActiveTab, _oldActiveTab) { timer1 = $timeout(function() { <API key>(_oldActiveTab); if (lxTabs.viewMode === 'separate') { angular.element('#' + lxTabs.panesId).find('.tabs__pane').hide(); angular.element('#' + lxTabs.panesId).find('.tabs__pane').eq(lxTabs.activeTab).show(); } }); }); $scope.$watch(function() { return lxTabs.links; }, function(_newLinks) { lxTabs.viewMode = angular.isDefined(_newLinks) ? 'separate' : 'gather'; angular.forEach(_newLinks, function(link, index) { var tab = { uuid: (angular.isUndefined(link.uuid) || link.uuid.length === 0) ? LxUtils.generateUUID() : link.uuid, index: index, label: link.label, icon: link.icon, disabled: link.disabled }; updateTabs(tab); }); }); timer2 = $timeout(function() { tabsLength = lxTabs.tabs.length; }); $scope.$on('$destroy', function() { $timeout.cancel(timer1); $timeout.cancel(timer2); $timeout.cancel(timer3); $timeout.cancel(timer4); }); function removeTab(_tab) { lxTabs.tabs.splice(_tab.index, 1); angular.forEach(lxTabs.tabs, function(tab, index) { tab.index = index; }); if (lxTabs.activeTab === 0) { timer3 = $timeout(function() { <API key>(); }); } else { setActiveTab(lxTabs.tabs[0]); } } function setActiveTab(_tab) { if (!_tab.disabled) { lxTabs.activeTab = _tab.index; } } function <API key>(_previousActiveTab) { var direction = lxTabs.activeTab > _previousActiveTab ? 'right' : 'left'; var indicator = $element.find('.tabs__indicator'); var activeTab = $element.find('.tabs__link').eq(lxTabs.activeTab); var indicatorLeft = activeTab.position().left; var indicatorRight = $element.outerWidth() - (indicatorLeft + activeTab.outerWidth()); if (angular.isUndefined(_previousActiveTab)) { indicator.css( { left: indicatorLeft, right: indicatorRight }); } else { var animationProperties = { duration: 200, easing: 'easeOutQuint' }; if (direction === 'left') { indicator.velocity( { left: indicatorLeft }, animationProperties); indicator.velocity( { right: indicatorRight }, animationProperties); } else { indicator.velocity( { right: indicatorRight }, animationProperties); indicator.velocity( { left: indicatorLeft }, animationProperties); } } } function setViewMode(_viewMode) { lxTabs.viewMode = _viewMode; } function tabIsActive(_index) { return lxTabs.activeTab === _index; } function updateTabs(_tab) { var newTab = true; angular.forEach(lxTabs.tabs, function(tab) { if (tab.index === _tab.index) { newTab = false; tab.uuid = _tab.uuid; tab.icon = _tab.icon; tab.label = _tab.label; } }); if (newTab) { lxTabs.tabs.push(_tab); if (angular.isDefined(tabsLength)) { timer4 = $timeout(function() { <API key>(); }); } } } } function lxTab() { return { restrict: 'E', require: ['lxTab', '^lxTabs'], templateUrl: 'tab.html', scope: { ngDisabled: '=?' }, link: link, controller: LxTabController, controllerAs: 'lxTab', bindToController: true, replace: true, transclude: true }; function link(scope, element, attrs, ctrls) { ctrls[0].init(ctrls[1], element.index()); attrs.$observe('lxLabel', function(_newLabel) { ctrls[0].setLabel(_newLabel); }); attrs.$observe('lxIcon', function(_newIcon) { ctrls[0].setIcon(_newIcon); }); } } LxTabController.$inject = ['$scope', 'LxUtils']; function LxTabController($scope, LxUtils) { var lxTab = this; var parentCtrl; var tab = { uuid: LxUtils.generateUUID(), index: undefined, label: undefined, icon: undefined, disabled: false }; lxTab.init = init; lxTab.setIcon = setIcon; lxTab.setLabel = setLabel; lxTab.tabIsActive = tabIsActive; $scope.$watch(function() { return lxTab.ngDisabled; }, function(_isDisabled) { if (_isDisabled) { tab.disabled = true; } else { tab.disabled = false; } parentCtrl.updateTabs(tab); }); $scope.$on('$destroy', function() { parentCtrl.removeTab(tab); }); function init(_parentCtrl, _index) { parentCtrl = _parentCtrl; tab.index = _index; parentCtrl.updateTabs(tab); } function setIcon(_icon) { tab.icon = _icon; parentCtrl.updateTabs(tab); } function setLabel(_label) { tab.label = _label; parentCtrl.updateTabs(tab); } function tabIsActive() { return parentCtrl.tabIsActive(tab.index); } } function lxTabsPanes() { return { restrict: 'E', templateUrl: 'tabs-panes.html', scope: true, replace: true, transclude: true }; } function lxTabPane() { return { restrict: 'E', templateUrl: 'tab-pane.html', scope: true, replace: true, transclude: true }; } })(); (function() { 'use strict'; angular .module('lumx.text-field') .directive('lxTextField', lxTextField); lxTextField.$inject = ['$timeout']; function lxTextField($timeout) { return { restrict: 'E', templateUrl: 'text-field.html', scope: { allowClear: '=?lxAllowClear', error: '=?lxError', fixedLabel: '=?lxFixedLabel', focus: '=?lxFocus', icon: '@?lxIcon', label: '@lxLabel', ngDisabled: '=?', theme: '@?lxTheme', valid: '=?lxValid' }, link: link, controller: <API key>, controllerAs: 'lxTextField', bindToController: true, replace: true, transclude: true }; function link(scope, element, attrs, ctrl, transclude) { var backwardOneWay = ['icon', 'label', 'theme']; var backwardTwoWay = ['error', 'fixedLabel', 'valid']; var input; var timer; angular.forEach(backwardOneWay, function(attribute) { if (angular.isDefined(attrs[attribute])) { attrs.$observe(attribute, function(newValue) { scope.lxTextField[attribute] = newValue; }); } }); angular.forEach(backwardTwoWay, function(attribute) { if (angular.isDefined(attrs[attribute])) { scope.$watch(function() { return scope.$parent.$eval(attrs[attribute]); }, function(newValue) { scope.lxTextField[attribute] = newValue; }); } }); transclude(function() { input = element.find('textarea'); if (input[0]) { input.on('cut paste drop keydown', function() { timer = $timeout(ctrl.<API key>); }); } else { input = element.find('input'); } input.addClass('text-field__input'); ctrl.setInput(input); ctrl.setModel(input.data('$ngModelController')); input.on('focus', function() { var phase = scope.$root.$$phase; if (phase === '$apply' || phase === '$digest') { ctrl.focusInput(); } else { scope.$apply(ctrl.focusInput); } }); input.on('blur', ctrl.blurInput); }); scope.$on('$destroy', function() { $timeout.cancel(timer); input.off(); }); } } <API key>.$inject = ['$scope', '$timeout']; function <API key>($scope, $timeout) { var lxTextField = this; var input; var modelController; var timer1; var timer2; lxTextField.blurInput = blurInput; lxTextField.clearInput = clearInput; lxTextField.focusInput = focusInput; lxTextField.hasValue = hasValue; lxTextField.setInput = setInput; lxTextField.setModel = setModel; lxTextField.<API key> = <API key>; $scope.$watch(function() { return modelController.$viewValue; }, function(newValue, oldValue) { if (angular.isDefined(newValue) && newValue) { lxTextField.isActive = true; } else { lxTextField.isActive = false; } }); $scope.$watch(function() { return lxTextField.focus; }, function(newValue, oldValue) { if (angular.isDefined(newValue) && newValue) { $timeout(function() { input.focus(); // Reset the value so we can re-focus the field later on if we want to. lxTextField.focus = false; }); } }); $scope.$on('$destroy', function() { $timeout.cancel(timer1); $timeout.cancel(timer2); }); function blurInput() { if (!hasValue()) { $scope.$apply(function() { lxTextField.isActive = false; }); } $scope.$apply(function() { lxTextField.isFocus = false; }); } function clearInput(_event) { _event.stopPropagation(); modelController.$setViewValue(undefined); modelController.$render(); } function focusInput() { lxTextField.isActive = true; lxTextField.isFocus = true; } function hasValue() { return angular.isDefined(input.val()) && input.val().length > 0; } function init() { lxTextField.isActive = hasValue(); lxTextField.focus = angular.isDefined(lxTextField.focus) ? lxTextField.focus : false; lxTextField.isFocus = lxTextField.focus; } function setInput(_input) { input = _input; timer1 = $timeout(init); if (input.selector === 'textarea') { timer2 = $timeout(<API key>); } } function setModel(_modelControler) { modelController = _modelControler; } function <API key>() { var tmpTextArea = angular.element('<textarea class="text-field__input" style="width: ' + input.width() + 'px;">' + input.val() + '</textarea>'); tmpTextArea.appendTo('body'); input.css( { height: tmpTextArea[0].scrollHeight + 'px' }); tmpTextArea.remove(); } } })(); (function() { 'use strict'; angular .module('lumx.tooltip') .directive('lxTooltip', lxTooltip); function lxTooltip() { return { restrict: 'A', scope: { tooltip: '@lxTooltip', position: '@?lxTooltipPosition' }, link: link, controller: LxTooltipController, controllerAs: 'lxTooltip', bindToController: true }; function link(scope, element, attrs, ctrl) { if (angular.isDefined(attrs.lxTooltip)) { attrs.$observe('lxTooltip', function(newValue) { ctrl.updateTooltipText(newValue); }); } if (angular.isDefined(attrs.lxTooltipPosition)) { attrs.$observe('lxTooltipPosition', function(newValue) { scope.lxTooltip.position = newValue; }); } element.on('mouseenter', ctrl.showTooltip); element.on('mouseleave', ctrl.hideTooltip); scope.$on('$destroy', function() { element.off(); }); } } LxTooltipController.$inject = ['$element', '$scope', '$timeout', 'LxDepthService']; function LxTooltipController($element, $scope, $timeout, LxDepthService) { var lxTooltip = this; var timer1; var timer2; var tooltip; var tooltipBackground; var tooltipLabel; lxTooltip.hideTooltip = hideTooltip; lxTooltip.showTooltip = showTooltip; lxTooltip.updateTooltipText = updateTooltipText; lxTooltip.position = angular.isDefined(lxTooltip.position) ? lxTooltip.position : 'top'; $scope.$on('$destroy', function() { if (angular.isDefined(tooltip)) { tooltip.remove(); tooltip = undefined; } $timeout.cancel(timer1); $timeout.cancel(timer2); }); function hideTooltip() { if (angular.isDefined(tooltip)) { tooltip.removeClass('tooltip--is-active'); timer1 = $timeout(function() { if (angular.isDefined(tooltip)) { tooltip.remove(); tooltip = undefined; } }, 200); } } function setTooltipPosition() { var width = $element.outerWidth(), height = $element.outerHeight(), top = $element.offset().top, left = $element.offset().left; tooltip .append(tooltipBackground) .append(tooltipLabel) .appendTo('body'); if (lxTooltip.position === 'top') { tooltip.css( { left: left - (tooltip.outerWidth() / 2) + (width / 2), top: top - tooltip.outerHeight() }); } else if (lxTooltip.position === 'bottom') { tooltip.css( { left: left - (tooltip.outerWidth() / 2) + (width / 2), top: top + height }); } else if (lxTooltip.position === 'left') { tooltip.css( { left: left - tooltip.outerWidth(), top: top + (height / 2) - (tooltip.outerHeight() / 2) }); } else if (lxTooltip.position === 'right') { tooltip.css( { left: left + width, top: top + (height / 2) - (tooltip.outerHeight() / 2) }); } } function showTooltip() { if (angular.isUndefined(tooltip)) { LxDepthService.register(); tooltip = angular.element('<div/>', { class: 'tooltip tooltip--' + lxTooltip.position }); tooltipBackground = angular.element('<div/>', { class: 'tooltip__background' }); tooltipLabel = angular.element('<span/>', { class: 'tooltip__label', text: lxTooltip.tooltip }); setTooltipPosition(); tooltip .append(tooltipBackground) .append(tooltipLabel) .css('z-index', LxDepthService.getDepth()) .appendTo('body'); timer2 = $timeout(function() { tooltip.addClass('tooltip--is-active'); }); } } function updateTooltipText(_newValue) { if (angular.isDefined(tooltipLabel)) { tooltipLabel.text(_newValue); } } } })(); angular.module("lumx.dropdown").run(['$templateCache', function(a) { a.put('dropdown.html', '<div class="dropdown"\n' + ' ng-class="{ \'<API key>\': lxDropdown.hasToggle,\n' + ' \'dropdown--is-open\': lxDropdown.isOpen }"\n' + ' ng-transclude></div>\n' + ''); a.put('dropdown-toggle.html', '<div class="dropdown-toggle" ng-transclude></div>\n' + ''); a.put('dropdown-menu.html', '<div class="dropdown-menu">\n' + ' <div class="<API key>" ng-transclude ng-if="lxDropdownMenu.parentCtrl.isOpen"></div>\n' + '</div>\n' + ''); }]); angular.module("lumx.file-input").run(['$templateCache', function(a) { a.put('file-input.html', '<div class="input-file">\n' + ' <span class="input-file__label">{{ lxFileInput.label }}</span>\n' + ' <span class="<API key>">{{ lxFileInput.fileName }}</span>\n' + ' <input type="file" class="input-file__input">\n' + '</div>\n' + ''); }]); angular.module("lumx.text-field").run(['$templateCache', function(a) { a.put('text-field.html', '<div class="text-field"\n' + ' ng-class="{ \'text-field--error\': lxTextField.error,\n' + ' \'<API key>\': lxTextField.fixedLabel,\n' + ' \'<API key>\': lxTextField.icon,\n' + ' \'<API key>\': lxTextField.hasValue(),\n' + ' \'<API key>\': lxTextField.isActive,\n' + ' \'<API key>\': lxTextField.ngDisabled,\n' + ' \'<API key>\': lxTextField.isFocus,\n' + ' \'<API key>\': !lxTextField.theme || lxTextField.theme === \'light\',\n' + ' \'<API key>\': lxTextField.theme === \'dark\',\n' + ' \'text-field--valid\': lxTextField.valid }">\n' + ' <div class="text-field__icon" ng-if="lxTextField.icon">\n' + ' <i class="mdi mdi-{{ lxTextField.icon }}"></i>\n' + ' </div>\n' + '\n' + ' <label class="text-field__label">\n' + ' {{ lxTextField.label }}\n' + ' </label>\n' + '\n' + ' <div ng-transclude></div>\n' + '\n' + ' <span class="text-field__clear" ng-click="lxTextField.clearInput($event)" ng-if="lxTextField.allowClear">\n' + ' <i class="mdi mdi-close-circle"></i>\n' + ' </span>\n' + '</div>\n' + ''); }]); angular.module("lumx.search-filter").run(['$templateCache', function(a) { a.put('search-filter.html', '<div class="search-filter" ng-class="lxSearchFilter.getClass()">\n' + ' <div class="<API key>">\n' + ' <div class="<API key>">\n' + ' <lx-button type="submit" lx-size="l" lx-color="{{ lxSearchFilter.color }}" lx-type="icon" ng-click="lxSearchFilter.openInput()">\n' + ' <i class="mdi mdi-magnify"></i>\n' + ' </lx-button>\n' + ' </div>\n' + '\n' + ' <div class="<API key>" ng-transclude></div>\n' + '\n' + ' <div class="<API key>">\n' + ' <lx-button type="button" lx-size="l" lx-color="{{ lxSearchFilter.color }}" lx-type="icon" ng-click="lxSearchFilter.clearInput()">\n' + ' <i class="mdi mdi-close"></i>\n' + ' </lx-button>\n' + ' </div>\n' + ' </div>\n' + '\n' + ' <div class="<API key>" ng-if="lxSearchFilter.isLoading">\n' + ' <lx-progress lx-type="linear"></lx-progress>\n' + ' </div>\n' + '\n' + ' <lx-dropdown id="{{ lxSearchFilter.dropdownId }}" lx-effect="none" lx-width="100%" ng-if="lxSearchFilter.autocomplete">\n' + ' <lx-dropdown-menu class="<API key>">\n' + ' <ul>\n' + ' <li ng-repeat="item in lxSearchFilter.autocompleteList track by $index">\n' + ' <a class="<API key>"\n' + ' ng-class="{ \'<API key>\': lxSearchFilter.activeChoiceIndex === $index }"\n' + ' ng-click="lxSearchFilter.selectItem(item)"\n' + ' ng-bind-html="item | lxSearchHighlight:lxSearchFilter.modelController.$viewValue:lxSearchFilter.icon"></a>\n' + ' </li>\n' + ' </ul>\n' + ' </lx-dropdown-menu>\n' + ' </lx-dropdown>\n' + '</div>'); }]); angular.module("lumx.select").run(['$templateCache', function(a) { a.put('select.html', '<div class="lx-select"\n' + ' ng-class="{ \'lx-select--error\': lxSelect.error,\n' + ' \'<API key>\': lxSelect.fixedLabel && lxSelect.viewMode === \'field\',\n' + ' \'<API key>\': (!lxSelect.multiple && lxSelect.getSelectedModel()) || (lxSelect.multiple && lxSelect.getSelectedModel().length),\n' + ' \'<API key>\': lxSelect.ngDisabled,\n' + ' \'<API key>\': lxSelect.multiple,\n' + ' \'<API key>\': !lxSelect.multiple,\n' + ' \'<API key>\': !lxSelect.theme || lxSelect.theme === \'light\',\n' + ' \'<API key>\': lxSelect.theme === \'dark\',\n' + ' \'lx-select--valid\': lxSelect.valid,\n' + ' \'<API key>\': lxSelect.customStyle,\n' + ' \'<API key>\': !lxSelect.customStyle,\n' + ' \'<API key>\': !lxSelect.multiple || (lxSelect.multiple && lxSelect.viewMode === \'field\'),\n' + ' \'<API key>\': lxSelect.multiple && lxSelect.viewMode === \'chips\',\n' + ' \'<API key>\': lxSelect.autocomplete }">\n' + ' <span class="lx-select-label" ng-if="!lxSelect.autocomplete">\n' + ' {{ ::lxSelect.label }}\n' + ' </span>\n' + '\n' + ' <lx-dropdown id="dropdown-{{ lxSelect.uuid }}" lx-width="100%" lx-effect="{{ lxSelect.autocomplete ? \'none\' : \'expand\' }}">\n' + ' <ng-transclude></ng-transclude>\n' + ' </lx-dropdown>\n' + '</div>\n' + ''); a.put('select-selected.html', '<div>\n' + ' <lx-dropdown-toggle ng-if="::!lxSelectSelected.parentCtrl.autocomplete">\n' + ' <ng-include src="\'<API key>.html\'"></ng-include>\n' + ' </lx-dropdown-toggle>\n' + '\n' + ' <ng-include src="\'<API key>.html\'" ng-if="::lxSelectSelected.parentCtrl.autocomplete"></ng-include>\n' + '</div>\n' + ''); a.put('<API key>.html', '<div class="<API key>" id="<API key>-{{ lxSelectSelected.parentCtrl.uuid }}">\n' + ' <div class="lx-select-selected" ng-if="!lxSelectSelected.parentCtrl.multiple && lxSelectSelected.parentCtrl.getSelectedModel()">\n' + ' <span class="<API key>"\n' + ' ng-bind-html="lxSelectSelected.parentCtrl.displaySelected()"></span>\n' + '\n' + ' <a class="<API key>"\n' + ' ng-click="lxSelectSelected.clearModel($event)"\n' + ' ng-if="::lxSelectSelected.parentCtrl.allowClear">\n' + ' <i class="mdi mdi-close-circle"></i>\n' + ' </a>\n' + ' </div>\n' + '\n' + ' <div class="lx-select-selected" ng-if="lxSelectSelected.parentCtrl.multiple">\n' + ' <span class="<API key>"\n' + ' ng-class="{ \'<API key>\': lxSelectSelected.parentCtrl.activeSelectedIndex === $index }"\n' + ' ng-click="lxSelectSelected.removeSelected(selected, $event)"\n' + ' ng-repeat="selected in lxSelectSelected.parentCtrl.getSelectedModel()"\n' + ' ng-bind-html="lxSelectSelected.parentCtrl.displaySelected(selected)"></span>\n' + '\n' + ' <input type="text"\n' + ' placeholder="{{ ::lxSelectSelected.parentCtrl.label }}"\n' + ' class="<API key>"\n' + ' ng-model="lxSelectSelected.parentCtrl.filterModel"\n' + ' ng-change="lxSelectSelected.parentCtrl.updateFilter()"\n' + ' ng-keydown="lxSelectSelected.parentCtrl.keyEvent($event)"\n' + ' ng-if="::lxSelectSelected.parentCtrl.autocomplete && !lxSelectSelected.parentCtrl.ngDisabled">\n' + ' </div>\n' + '</div>'); a.put('select-choices.html', '<lx-dropdown-menu class="lx-select-choices"\n' + ' ng-class="{ \'<API key>\': lxSelectChoices.parentCtrl.choicesCustomStyle,\n' + ' \'<API key>\': !lxSelectChoices.parentCtrl.choicesCustomStyle,\n' + ' \'<API key>\': lxSelectChoices.parentCtrl.multiple,\n' + ' \'<API key>\': !lxSelectChoices.parentCtrl.multiple, }">\n' + ' <ul>\n' + ' <li class="<API key>" ng-if="::lxSelectChoices.parentCtrl.displayFilter && !lxSelectChoices.parentCtrl.autocomplete">\n' + ' <lx-search-filter lx-dropdown-filter>\n' + ' <input type="text" ng-model="lxSelectChoices.parentCtrl.filterModel" ng-change="lxSelectChoices.parentCtrl.updateFilter()">\n' + ' </lx-search-filter>\n' + ' </li>\n' + ' \n' + ' <div ng-if="::lxSelectChoices.isArray()">\n' + ' <li class="<API key>"\n' + ' ng-class="{ \'<API key>\': lxSelectChoices.parentCtrl.isSelected(choice),\n' + ' \'<API key>\': lxSelectChoices.parentCtrl.activeChoiceIndex === $index }"\n' + ' ng-repeat="choice in lxSelectChoices.parentCtrl.choices | filterChoices:lxSelectChoices.parentCtrl.filter:lxSelectChoices.parentCtrl.filterModel"\n' + ' ng-bind-html="::lxSelectChoices.parentCtrl.displayChoice(choice)"\n' + ' ng-click="lxSelectChoices.parentCtrl.toggleChoice(choice, $event)"></li>\n' + ' </div>\n' + '\n' + ' <div ng-if="::!lxSelectChoices.isArray()">\n' + ' <li class="<API key>"\n' + ' ng-repeat-start="(subheader, children) in lxSelectChoices.parentCtrl.choices"\n' + ' ng-bind-html="::lxSelectChoices.parentCtrl.displaySubheader(subheader)"></li>\n' + '\n' + ' <li class="<API key>"\n' + ' ng-class="{ \'<API key>\': lxSelectChoices.parentCtrl.isSelected(choice),\n' + ' \'<API key>\': lxSelectChoices.parentCtrl.activeChoiceIndex === $index }"\n' + ' ng-repeat-end\n' + ' ng-repeat="choice in children | filterChoices:lxSelectChoices.parentCtrl.filter:lxSelectChoices.parentCtrl.filterModel"\n' + ' ng-bind-html="::lxSelectChoices.parentCtrl.displayChoice(choice)"\n' + ' ng-click="lxSelectChoices.parentCtrl.toggleChoice(choice, $event)"></li>\n' + ' </div>\n' + '\n' + ' <li class="<API key>" ng-if="lxSelectChoices.parentCtrl.helperDisplayable()">\n' + ' {{ lxSelectChoices.parentCtrl.helperMessage }}\n' + ' </li>\n' + '\n' + ' <li class="<API key>" ng-if="lxSelectChoices.parentCtrl.loading">\n' + ' <lx-progress lx-type="circular" lx-color="primary" lx-diameter="20"></lx-progress>\n' + ' </li>\n' + ' </ul>\n' + '</lx-dropdown-menu>\n' + ''); }]); angular.module("lumx.tabs").run(['$templateCache', function(a) { a.put('tabs.html', '<div class="tabs tabs--layout-{{ lxTabs.layout }} tabs--theme-{{ lxTabs.theme }} tabs--color-{{ lxTabs.color }} tabs--indicator-{{ lxTabs.indicator }}">\n' + ' <div class="tabs__links">\n' + ' <a class="tabs__link"\n' + ' ng-class="{ \'<API key>\': lxTabs.tabIsActive(tab.index),\n' + ' \'<API key>\': tab.disabled }"\n' + ' ng-repeat="tab in lxTabs.tabs"\n' + ' ng-click="lxTabs.setActiveTab(tab)"\n' + ' lx-ripple>\n' + ' <i class="mdi mdi-{{ tab.icon }}" ng-if="tab.icon"></i>\n' + ' <span ng-if="tab.label">{{ tab.label }}</span>\n' + ' </a>\n' + ' </div>\n' + ' \n' + ' <div class="tabs__panes" ng-if="lxTabs.viewMode === \'gather\'" ng-transclude></div>\n' + ' <div class="tabs__indicator"></div>\n' + '</div>\n' + ''); a.put('tabs-panes.html', '<div class="tabs">\n' + ' <div class="tabs__panes" ng-transclude></div>\n' + '</div>'); a.put('tab.html', '<div class="tabs__pane" ng-class="{ \'<API key>\': lxTab.ngDisabled }">\n' + ' <div ng-if="lxTab.tabIsActive()" ng-transclude></div>\n' + '</div>\n' + ''); a.put('tab-pane.html', '<div class="tabs__pane" ng-transclude></div>\n' + ''); }]); angular.module("lumx.date-picker").run(['$templateCache', function(a) { a.put('date-picker.html', '<div class="lx-date">\n' + ' <!-- Date picker input -->\n' + ' <div class="lx-date-input" ng-click="lxDatePicker.openDatePicker()" ng-if="lxDatePicker.hasInput">\n' + ' <ng-transclude></ng-transclude>\n' + ' </div>\n' + ' \n' + ' <!-- Date picker -->\n' + ' <div class="lx-date-picker lx-date-picker--{{ lxDatePicker.color }}">\n' + ' <div ng-if="lxDatePicker.isOpen">\n' + ' <!-- Date picker: header -->\n' + ' <div class="<API key>">\n' + ' <a class="<API key>"\n' + ' ng-class="{ \'<API key>\': lxDatePicker.yearSelection }"\n' + ' ng-click="lxDatePicker.<API key>()">\n' + ' {{ lxDatePicker.moment(lxDatePicker.ngModel).format(\'YYYY\') }}\n' + ' </a>\n' + '\n' + ' <a class="<API key>"\n' + ' ng-class="{ \'<API key>\': !lxDatePicker.yearSelection }"\n' + ' ng-click="lxDatePicker.hideYearSelection()">\n' + ' {{ lxDatePicker.getDateFormatted() }}\n' + ' </a>\n' + ' </div>\n' + ' \n' + ' <!-- Date picker: content -->\n' + ' <div class="<API key>">\n' + ' <!-- Calendar -->\n' + ' <div class="<API key>" ng-if="!lxDatePicker.yearSelection">\n' + ' <div class="lx-date-picker__nav">\n' + ' <lx-button lx-size="l" lx-color="black" lx-type="icon" ng-click="lxDatePicker.previousMonth()">\n' + ' <i class="mdi mdi-chevron-left"></i>\n' + ' </lx-button>\n' + '\n' + ' <span>{{ lxDatePicker.ngModelMoment.format(\'MMMM YYYY\') }}</span>\n' + ' \n' + ' <lx-button lx-size="l" lx-color="black" lx-type="icon" ng-click="lxDatePicker.nextMonth()">\n' + ' <i class="mdi mdi-chevron-right"></i>\n' + ' </lx-button>\n' + ' </div>\n' + '\n' + ' <div class="<API key>">\n' + ' <span ng-repeat="day in lxDatePicker.daysOfWeek">{{ day }}</span>\n' + ' </div>\n' + '\n' + ' <div class="<API key>">\n' + ' <span class="lx-date-picker__day <API key>"\n' + ' ng-repeat="x in lxDatePicker.emptyFirstDays">&nbsp;</span>\n' + '\n' + ' <div class="lx-date-picker__day"\n' + ' ng-class="{ \'<API key>\': day.selected,\n' + ' \'<API key>\': day.today && !day.selected,\n' + ' \'<API key>\': day.disabled }"\n' + ' ng-repeat="day in lxDatePicker.days">\n' + ' <a ng-click="lxDatePicker.select(day)">{{ day ? day.format(\'D\') : \'\' }}</a>\n' + ' </div>\n' + '\n' + ' <span class="lx-date-picker__day <API key>"\n' + ' ng-repeat="x in lxDatePicker.emptyLastDays">&nbsp;</span>\n' + ' </div>\n' + ' </div>\n' + '\n' + ' <!-- Year selection -->\n' + ' <div class="<API key>" ng-if="lxDatePicker.yearSelection">\n' + ' <a class="<API key>"\n' + ' ng-class="{ \'<API key>\': year == lxDatePicker.moment(lxDatePicker.ngModel).format(\'YYYY\') }"\n' + ' ng-repeat="year in lxDatePicker.years"\n' + ' ng-click="lxDatePicker.selectYear(year)"\n' + ' ng-if="lxDatePicker.yearSelection">\n' + ' {{ year }}\n' + ' </a>\n' + ' </div>\n' + ' </div>\n' + '\n' + ' <!-- Actions -->\n' + ' <div class="<API key>">\n' + ' <lx-button lx-color="{{ lxDatePicker.color }}" lx-type="flat" ng-click="lxDatePicker.closeDatePicker()">\n' + ' Ok\n' + ' </lx-button>\n' + ' </div>\n' + ' </div>\n' + ' </div>\n' + '</div>'); }]); angular.module("lumx.progress").run(['$templateCache', function(a) { a.put('progress.html', '<div class="progress-container progress-container--{{ lxProgress.lxType }} progress-container--{{ lxProgress.lxColor }}"\n' + ' ng-class="{ \'<API key>\': lxProgress.lxValue,\n' + ' \'<API key>\': !lxProgress.lxValue }">\n' + ' <div class="progress-circular"\n' + ' ng-if="lxProgress.lxType === \'circular\'"\n' + ' ng-style="lxProgress.getProgressDiameter()">\n' + ' <svg class="<API key>">\n' + ' <circle class="<API key>" cx="50" cy="50" r="20" fill="none" stroke-width="4" stroke-miterlimit="10" ng-style="lxProgress.<API key>()">\n' + ' </svg>\n' + ' </div>\n' + '\n' + ' <div class="progress-linear" ng-if="lxProgress.lxType === \'linear\'">\n' + ' <div class="<API key>"></div>\n' + ' <div class="<API key> <API key>" ng-style="lxProgress.<API key>()"></div>\n' + ' <div class="<API key> <API key>"></div>\n' + ' </div>\n' + '</div>\n' + ''); }]); angular.module("lumx.button").run(['$templateCache', function(a) { a.put('link.html', '<a ng-transclude lx-ripple></a>\n' + ''); a.put('button.html', '<button ng-transclude lx-ripple></button>\n' + ''); }]); angular.module("lumx.checkbox").run(['$templateCache', function(a) { a.put('checkbox.html', '<div class="checkbox checkbox--{{ lxCheckbox.lxColor }}"\n' + ' ng-class="{ \'<API key>\': !lxCheckbox.theme || lxCheckbox.theme === \'light\',\n' + ' \'<API key>\': lxCheckbox.theme === \'dark\' }" >\n' + ' <input id="{{ lxCheckbox.getCheckboxId() }}"\n' + ' type="checkbox"\n' + ' class="checkbox__input"\n' + ' name="{{ lxCheckbox.name }}"\n' + ' ng-model="lxCheckbox.ngModel"\n' + ' ng-true-value="{{ lxCheckbox.ngTrueValue }}"\n' + ' ng-false-value="{{ lxCheckbox.ngFalseValue }}"\n' + ' ng-change="lxCheckbox.triggerNgChange()"\n' + ' ng-disabled="lxCheckbox.ngDisabled">\n' + '\n' + ' <label for="{{ lxCheckbox.getCheckboxId() }}" class="checkbox__label" ng-transclude ng-if="!lxCheckbox.<API key>()"></label>\n' + ' <<API key> ng-if="lxCheckbox.<API key>()"></<API key>>\n' + '</div>\n' + ''); a.put('checkbox-label.html', '<label for="{{ lxCheckboxLabel.getCheckboxId() }}" class="checkbox__label" ng-transclude></label>\n' + ''); a.put('checkbox-help.html', '<span class="checkbox__help" ng-transclude></span>\n' + ''); }]); angular.module("lumx.radio-button").run(['$templateCache', function(a) { a.put('radio-group.html', '<div class="radio-group" ng-transclude></div>\n' + ''); a.put('radio-button.html', '<div class="radio-button radio-button--{{ lxRadioButton.lxColor }}">\n' + ' <input id="{{ lxRadioButton.getRadioButtonId() }}"\n' + ' type="radio"\n' + ' class="radio-button__input"\n' + ' name="{{ lxRadioButton.name }}"\n' + ' ng-model="lxRadioButton.ngModel"\n' + ' ng-value="lxRadioButton.ngValue"\n' + ' ng-change="lxRadioButton.triggerNgChange()"\n' + ' ng-disabled="lxRadioButton.ngDisabled">\n' + '\n' + ' <label for="{{ lxRadioButton.getRadioButtonId() }}" class="radio-button__label" ng-transclude ng-if="!lxRadioButton.<API key>()"></label>\n' + ' <<API key> ng-if="lxRadioButton.<API key>()"></<API key>>\n' + '</div>\n' + ''); a.put('radio-button-label.html', '<label for="{{ lxRadioButtonLabel.getRadioButtonId() }}" class="radio-button__label" ng-transclude></label>\n' + ''); a.put('radio-button-help.html', '<span class="radio-button__help" ng-transclude></span>\n' + ''); }]); angular.module("lumx.stepper").run(['$templateCache', function(a) { a.put('stepper.html', '<div class="lx-stepper" ng-class="lxStepper.getClasses()">\n' + ' <div class="lx-stepper__header" ng-if="lxStepper.layout === \'horizontal\'">\n' + ' <div class="lx-stepper__nav">\n' + ' <lx-step-nav lx-active-index="{{ lxStepper.activeIndex }}" lx-step="step" ng-repeat="step in lxStepper.steps"></lx-step-nav>\n' + ' </div>\n' + '\n' + ' <div class="<API key>" ng-if="lxStepper.steps[lxStepper.activeIndex].feedback">\n' + ' <span>{{ lxStepper.steps[lxStepper.activeIndex].feedback }}</span>\n' + ' </div>\n' + ' </div>\n' + '\n' + ' <div class="lx-stepper__steps" ng-transclude></div>\n' + '</div>'); a.put('step.html', '<div class="lx-step" ng-class="lxStep.getClasses()">\n' + ' <div class="lx-step__nav" ng-if="lxStep.parent.layout === \'vertical\'">\n' + ' <lx-step-nav lx-active-index="{{ lxStep.parent.activeIndex }}" lx-step="lxStep.step"></lx-step-nav>\n' + ' </div>\n' + '\n' + ' <div class="lx-step__wrapper" ng-if="lxStep.parent.activeIndex === lxStep.step.index">\n' + ' <div class="lx-step__content">\n' + ' <ng-transclude></ng-transclude>\n' + '\n' + ' <div class="lx-step__progress" ng-if="lxStep.step.isLoading">\n' + ' <lx-progress lx-type="circular"></lx-progress>\n' + ' </div>\n' + ' </div>\n' + '\n' + ' <div class="lx-step__actions" ng-if="lxStep.parent.activeIndex === lxStep.step.index">\n' + ' <div class="lx-step__action <API key>">\n' + ' <lx-button ng-click="lxStep.submitStep()" ng-disabled="lxStep.isLoading">{{ lxStep.parent.labels.continue }}</lx-button>\n' + ' </div>\n' + '\n' + ' <div class="lx-step__action <API key>" ng-if="lxStep.parent.cancel">\n' + ' <lx-button lx-color="black" lx-type="flat" ng-click="lxStep.parent.cancel()" ng-disabled="lxStep.isLoading">{{ lxStep.parent.labels.cancel }}</lx-button>\n' + ' </div>\n' + '\n' + ' <div class="lx-step__action <API key>" ng-if="lxStep.parent.isLinear">\n' + ' <lx-button lx-color="black" lx-type="flat" ng-click="lxStep.previousStep()" ng-disabled="lxStep.isLoading || lxStep.step.index === 0">{{ lxStep.parent.labels.back }}</lx-button>\n' + ' </div>\n' + ' </div>\n' + ' </div>\n' + '</div>'); a.put('step-nav.html', '<div class="lx-step-nav" ng-click="lxStepNav.parent.goToStep(lxStepNav.step.index)" ng-class="lxStepNav.getClasses()" lx-ripple>\n' + ' <div class="<API key> <API key>" ng-if="lxStepNav.step.isValid === undefined">\n' + ' <span>{{ lxStepNav.step.index + 1 }}</span>\n' + ' </div>\n' + '\n' + ' <div class="<API key> <API key>" ng-if="lxStepNav.step.isValid === true">\n' + ' <lx-icon lx-id="check" ng-if="!lxStepNav.step.isEditable"></lx-icon>\n' + ' <lx-icon lx-id="pencil" ng-if="lxStepNav.step.isEditable"></lx-icon>\n' + ' </div>\n' + '\n' + ' <div class="<API key> <API key>" ng-if="lxStepNav.step.isValid === false">\n' + ' <lx-icon lx-id="alert"></lx-icon>\n' + ' </div>\n' + '\n' + ' <div class="<API key>">\n' + ' <div class="lx-step-nav__label">\n' + ' <span>{{ lxStepNav.step.label }}</span>\n' + ' </div>\n' + '\n' + ' <div class="lx-step-nav__state">\n' + ' <span ng-if="(lxStepNav.step.isValid === undefined || lxStepNav.step.isValid === true) && lxStepNav.step.isOptional">{{ lxStepNav.parent.labels.optional }}</span>\n' + ' <span ng-if="lxStepNav.step.isValid === false">{{ lxStepNav.step.errorMessage }}</span>\n' + ' </div>\n' + ' </div>\n' + '</div>'); }]); angular.module("lumx.switch").run(['$templateCache', function(a) { a.put('switch.html', '<div class="switch switch--{{ lxSwitch.lxColor }} switch--{{ lxSwitch.lxPosition }}">\n' + ' <input id="{{ lxSwitch.getSwitchId() }}"\n' + ' type="checkbox"\n' + ' class="switch__input"\n' + ' name="{{ lxSwitch.name }}"\n' + ' ng-model="lxSwitch.ngModel"\n' + ' ng-true-value="{{ lxSwitch.ngTrueValue }}"\n' + ' ng-false-value="{{ lxSwitch.ngFalseValue }}"\n' + ' ng-change="lxSwitch.triggerNgChange()"\n' + ' ng-disabled="lxSwitch.ngDisabled">\n' + '\n' + ' <label for="{{ lxSwitch.getSwitchId() }}" class="switch__label" ng-transclude ng-if="!lxSwitch.<API key>()"></label>\n' + ' <<API key> ng-if="lxSwitch.<API key>()"></<API key>>\n' + '</div>\n' + ''); a.put('switch-label.html', '<label for="{{ lxSwitchLabel.getSwitchId() }}" class="switch__label" ng-transclude></label>\n' + ''); a.put('switch-help.html', '<span class="switch__help" ng-transclude></span>\n' + ''); }]); angular.module("lumx.fab").run(['$templateCache', function(a) { a.put('fab.html', '<div class="fab">\n' + ' <<API key>></<API key>>\n' + '</div>\n' + ''); a.put('fab-trigger.html', '<div class="fab__primary" ng-transclude></div>\n' + ''); a.put('fab-actions.html', '<div class="fab__actions fab__actions--{{ parentCtrl.lxDirection }}" ng-transclude></div>\n' + ''); }]); angular.module("lumx.icon").run(['$templateCache', function(a) { a.put('icon.html', '<i class="icon mdi" ng-class="lxIcon.getClass()"></i>'); }]); angular.module("lumx.data-table").run(['$templateCache', function(a) { a.put('data-table.html', '<div class="<API key>">\n' + ' <table class="data-table"\n' + ' ng-class="{ \'<API key>\': !lxDataTable.border,\n' + ' \'<API key>\': lxDataTable.thumbnail }">\n' + ' <thead>\n' + ' <tr ng-class="{ \'<API key>\': lxDataTable.selectable,\n' + ' \'<API key>\': lxDataTable.selectable && lxDataTable.allRowsSelected }">\n' + ' <th ng-if="lxDataTable.thumbnail"></th>\n' + ' <th ng-click="lxDataTable.toggleAllSelected()"\n' + ' ng-if="lxDataTable.selectable"></th>\n' + ' <th ng-class=" { \'<API key>\': th.sortable,\n' + ' \'<API key>\': th.sortable && th.sort === \'asc\',\n' + ' \'<API key>\': th.sortable && th.sort === \'desc\' }"\n' + ' ng-click="lxDataTable.sort(th)"\n' + ' ng-repeat="th in lxDataTable.thead track by $index"\n' + ' ng-if="!lxDataTable.thumbnail || (lxDataTable.thumbnail && $index != 0)">\n' + ' <lx-icon lx-id="{{ th.icon }}" ng-if="th.icon"></lx-icon>\n' + ' <span>{{ th.label }}</span>\n' + ' </th>\n' + ' </tr>\n' + ' </thead>\n' + '\n' + ' <tbody>\n' + ' <tr ng-class="{ \'<API key>\': lxDataTable.selectable,\n' + ' \'<API key>\': lxDataTable.selectable && tr.lxDataTableDisabled,\n' + ' \'<API key>\': lxDataTable.selectable && tr.lxDataTableSelected }"\n' + ' ng-repeat="tr in lxDataTable.tbody"\n' + ' ng-click="lxDataTable.toggle(tr)">\n' + ' <td ng-if="lxDataTable.thumbnail">\n' + ' <div ng-if="lxDataTable.thead[0].format" ng-bind-html="lxDataTable.$sce.trustAsHtml(lxDataTable.thead[0].format(tr))"></div>\n' + ' </td>\n' + ' <td ng-if="lxDataTable.selectable"></td>\n' + ' <td ng-repeat="th in lxDataTable.thead track by $index"\n' + ' ng-if="!lxDataTable.thumbnail || (lxDataTable.thumbnail && $index != 0)">\n' + ' <span ng-if="!th.format">{{ tr[th.name] }}</span>\n' + ' <div ng-if="th.format" ng-bind-html="lxDataTable.$sce.trustAsHtml(th.format(tr))"></div>\n' + ' </td>\n' + ' </tr>\n' + ' </tbody>\n' + ' </table>\n' + '</div>'); }]);
<?php defined('C5_EXECUTE') or die("Access Denied."); if (ENABLE_AREA_LAYOUTS == false) { die(t('Area layouts have been disabled.')); } global $c; $form = Loader::helper('form'); //Loader::model('layout'); if( intval($_REQUEST['lpID']) ){ $layoutPreset = LayoutPreset::getByID($_REQUEST['lpID']); if(is_object($layoutPreset)){ $layout = $layoutPreset->getLayoutObject(); } }elseif(intval($_REQUEST['layoutID'])){ $layout = Layout::getById( intval($_REQUEST['layoutID']) ); }else $layout = new Layout( array('type'=>'table','rows'=>1,'columns'=>3 ) ); if(!$layout ){ echo t('Error: Layout not found'); }else{ $layoutPresets=LayoutPreset::getList(); if(intval($layout->lpID)) $layoutPreset = LayoutPreset::getById($layout->lpID); ?> <?php if (!$_REQUEST['refresh']) { ?> <div id="<API key>"> <?php } ?> <style type="text/css"> #<API key> { margin-top:12px; } #<API key> table td { padding-bottom:4px; vertical-align:top; padding-bottom:12px; padding-right:12px; } #<API key> table td.padBottom { } </style> <form method="post" class="ccm-ui" id="ccmAreaLayoutForm" action="<?php echo $action?>" style="width:96%; margin:auto;"> <input id="<API key>" name="layoutID" type="hidden" value="<?php echo intval( $layout->layoutID ) ?>" /> <input id="<API key>" name="arHandle" type="hidden" value="<?php echo htmlentities( $a->getAreaHandle(), ENT_COMPAT, APP_CHARSET) ?>" /> <?php if (count($layoutPresets) > 0) { ?> <h2><?php echo t('Saved Presets')?></h2> <input type="hidden" id="<API key>" value="<?php echo $refreshAction?>" /> <select id="<API key>" name="lpID"> <option value="0"><?php echo t('** Custom (No Preset)') ?></option> <?php foreach($layoutPresets as $availablePreset){ ?> <option value="<?php echo $availablePreset->getLayoutPresetID() ?>" <?php echo ($availablePreset->getLayoutPresetID()==intval($layout->lpID))?'selected':''?>><?php echo $availablePreset->getLayoutPresetName() ?></option> <?php } ?> </select> <a href="javascript:void(0)" id="<API key>" style="display: none" onclick="ccmLayoutEdit.deletePreset()"><img src="<?php echo ASSETS_URL_IMAGES?>/icons/delete_small.png" style="vertical-align: middle" width="16" height="16" border="0" /></a> <br/><br/> <?php } ?> <div id="<API key>"> <table> <tr> <td><?php echo t('Columns')?>:</td> <td class="val"> <input name="layout_columns" type="text" value="<?php echo intval($layout->columns) ?>" size=2 /> </td> </tr> <tr> <td class="padBottom"><?php echo t('Rows')?>:</td> <td class="val padBottom"> <input name="layout_rows" type="text" value="<?php echo intval($layout->rows) ?>" size=2 /> </td> </tr> <tr> <td class="padBottom"><?php echo t('Spacing')?>:</td> <td class="val padBottom"> <input name="spacing" type="text" value="<?php echo intval($layout->spacing) ?>" size=2 /> <?php echo t('px')?> </td> </tr> <tr> <td class="padBottom"><label for="locked"><?php echo t('Lock Widths') ?>:</label></td> <td class="val padBottom"> <input id="locked" name="locked" type="checkbox" value="1" <?php echo ( intval($layout->locked) ) ? 'checked="checked"' : '' ?> /> </td> </tr> </table> </div> <?php //To Do: only provide this option if there's 1) blocks in the main area, or 2) existing layouts if( !intval($layout->layoutID) ){ ?> <?php /* <div style="margin:16px 0px"> <?php echo t('Add layout to: ') ?> <input name="add_to_position" type="radio" value="top" /> <?php echo t('top') ?>&nbsp; <input name="add_to_position" type="radio" value="bottom" checked="checked" /> <?php echo t('bottom') ?> </div> */ ?> <input type="hidden" name="add_to_position" value="bottom" /> <?php } ?> <?php if ( is_object($layoutPreset) ) { ?> <div id="layoutPresetActions" style="display: none"> <label class="radio"><?php echo $form->radio('layoutPresetAction', '<API key>', true)?> <?php echo t('Update "%s" preset everywhere it is used?', $layoutPreset->getLayoutPresetName())?></label> <label class="radio"><?php echo $form->radio('layoutPresetAction', 'save_as_custom')?> <?php echo t('Use this layout here, and leave "%s" unchanged?', $layoutPreset->getLayoutPresetName())?></label> <label class="radio"><?php echo $form->radio('layoutPresetAction', 'create_new_preset')?> <?php echo t('Save this style as a new preset?')?><br/><span style="margin-left: 20px"><?php echo $form->text('layoutPresetNameAlt', array('style' => 'width: 127px', 'disabled' => true))?></span></label> </div> <?php } ?> <div id="<API key>" style="margin-bottom:16px;"> <label for="layoutPresetAction" class="checkbox inline"> <?php echo $form->checkbox('layoutPresetAction', 'create_new_preset')?> <?php echo t('Save this style as a new preset.')?> </label> <span style="margin-left: 10px"><?php echo $form->text('layoutPresetName', array('style' => 'width: 127px', 'disabled' => true))?></span> </div> <?php if(!$_REQUEST['refresh']) { ?> <div class="ccm-buttons dialog-buttons"> <a href="#" class="btn ccm-button-left cancel" onclick="jQuery.fn.dialog.closeTop(); return false"><?php echo t('Cancel')?></a> <a href="javascript:void(0)" onclick="$('#ccmAreaLayoutForm').submit()" class="ccm-button-right accept btn primary"><?php echo intval($layout->layoutID)?t('Save Changes'):t('Add')?></a> </div> <?php } ?> </form> <script type="text/javascript"> $(function() { ccmLayoutEdit.init(); }); </script> <?php if (!$_REQUEST['refresh']) { ?> </div> <?php } ?> <?php } ?>
.datepicker { padding: 4px; -<API key>: 4px; -moz-border-radius: 4px; border-radius: 4px; direction: ltr; } .datepicker-inline { width: 220px; } .datepicker.datepicker-rtl { direction: rtl; } .datepicker.datepicker-rtl table tr td span { float: right; } .datepicker-dropdown { top: 0; left: 0; } .datepicker-dropdown:before { content: ''; display: inline-block; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 7px solid #ccc; border-top: 0; border-bottom-color: rgba(0, 0, 0, 0.2); position: absolute; } .datepicker-dropdown:after { content: ''; display: inline-block; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 6px solid #ffffff; border-top: 0; position: absolute; } .datepicker-dropdown.<API key>:before { left: 6px; } .datepicker-dropdown.<API key>:after { left: 7px; } .datepicker-dropdown.<API key>:before { right: 6px; } .datepicker-dropdown.<API key>:after { right: 7px; } .datepicker-dropdown.<API key>:before { top: -7px; } .datepicker-dropdown.<API key>:after { top: -6px; } .datepicker-dropdown.<API key>:before { bottom: -7px; border-bottom: 0; border-top: 7px solid #999; } .datepicker-dropdown.<API key>:after { bottom: -6px; border-bottom: 0; border-top: 6px solid #ffffff; } .datepicker > div { display: none; } .datepicker.days .datepicker-days, .datepicker.months .datepicker-months, .datepicker.years .datepicker-years { display: block; } .datepicker table { margin: 0; -<API key>: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .datepicker td, .datepicker th { text-align: center; width: 20px; height: 20px; -<API key>: 4px; -moz-border-radius: 4px; border-radius: 4px; border: none; } .table-striped .datepicker table tr td, .table-striped .datepicker table tr th { background-color: transparent; } .datepicker table tr td.day:hover, .datepicker table tr td.day.focused { background: #eeeeee; cursor: pointer; } .datepicker table tr td.old, .datepicker table tr td.new { color: #999999; } .datepicker table tr td.disabled, .datepicker table tr td.disabled:hover { background: none; color: #999999; cursor: default; } .datepicker table tr td.highlighted { background: #d9edf7; border-radius: 0; } .datepicker table tr td.today, .datepicker table tr td.today:hover, .datepicker table tr td.today.disabled, .datepicker table tr td.today.disabled:hover { background-color: #fde19a; background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a); background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a)); background-image: -<API key>(top, #fdd49a, #fdf59a); background-image: -o-linear-gradient(top, #fdd49a, #fdf59a); background-image: linear-gradient(top, #fdd49a, #fdf59a); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0); border-color: #fdf59a #fdf59a #fbed50; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #000; } .datepicker table tr td.today:hover, .datepicker table tr td.today:hover:hover, .datepicker table tr td.today.disabled:hover, .datepicker table tr td.today.disabled:hover:hover, .datepicker table tr td.today:active, .datepicker table tr td.today:hover:active, .datepicker table tr td.today.disabled:active, .datepicker table tr td.today.disabled:hover:active, .datepicker table tr td.today.active, .datepicker table tr td.today:hover.active, .datepicker table tr td.today.disabled.active, .datepicker table tr td.today.disabled:hover.active, .datepicker table tr td.today.disabled, .datepicker table tr td.today:hover.disabled, .datepicker table tr td.today.disabled.disabled, .datepicker table tr td.today.disabled:hover.disabled, .datepicker table tr td.today[disabled], .datepicker table tr td.today:hover[disabled], .datepicker table tr td.today.disabled[disabled], .datepicker table tr td.today.disabled:hover[disabled] { background-color: #fdf59a; } .datepicker table tr td.today:active, .datepicker table tr td.today:hover:active, .datepicker table tr td.today.disabled:active, .datepicker table tr td.today.disabled:hover:active, .datepicker table tr td.today.active, .datepicker table tr td.today:hover.active, .datepicker table tr td.today.disabled.active, .datepicker table tr td.today.disabled:hover.active { background-color: #fbf069 \9; } .datepicker table tr td.today:hover:hover { color: #000; } .datepicker table tr td.today.active:hover { color: #fff; } .datepicker table tr td.range, .datepicker table tr td.range:hover, .datepicker table tr td.range.disabled, .datepicker table tr td.range.disabled:hover { background: #eeeeee; -<API key>: 0; -moz-border-radius: 0; border-radius: 0; } .datepicker table tr td.range.today, .datepicker table tr td.range.today:hover, .datepicker table tr td.range.today.disabled, .datepicker table tr td.range.today.disabled:hover { background-color: #f3d17a; background-image: -moz-linear-gradient(top, #f3c17a, #f3e97a); background-image: -ms-linear-gradient(top, #f3c17a, #f3e97a); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f3c17a), to(#f3e97a)); background-image: -<API key>(top, #f3c17a, #f3e97a); background-image: -o-linear-gradient(top, #f3c17a, #f3e97a); background-image: linear-gradient(top, #f3c17a, #f3e97a); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0); border-color: #f3e97a #f3e97a #edde34; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -<API key>: 0; -moz-border-radius: 0; border-radius: 0; } .datepicker table tr td.range.today:hover, .datepicker table tr td.range.today:hover:hover, .datepicker table tr td.range.today.disabled:hover, .datepicker table tr td.range.today.disabled:hover:hover, .datepicker table tr td.range.today:active, .datepicker table tr td.range.today:hover:active, .datepicker table tr td.range.today.disabled:active, .datepicker table tr td.range.today.disabled:hover:active, .datepicker table tr td.range.today.active, .datepicker table tr td.range.today:hover.active, .datepicker table tr td.range.today.disabled.active, .datepicker table tr td.range.today.disabled:hover.active, .datepicker table tr td.range.today.disabled, .datepicker table tr td.range.today:hover.disabled, .datepicker table tr td.range.today.disabled.disabled, .datepicker table tr td.range.today.disabled:hover.disabled, .datepicker table tr td.range.today[disabled], .datepicker table tr td.range.today:hover[disabled], .datepicker table tr td.range.today.disabled[disabled], .datepicker table tr td.range.today.disabled:hover[disabled] { background-color: #f3e97a; } .datepicker table tr td.range.today:active, .datepicker table tr td.range.today:hover:active, .datepicker table tr td.range.today.disabled:active, .datepicker table tr td.range.today.disabled:hover:active, .datepicker table tr td.range.today.active, .datepicker table tr td.range.today:hover.active, .datepicker table tr td.range.today.disabled.active, .datepicker table tr td.range.today.disabled:hover.active { background-color: #efe24b \9; } .datepicker table tr td.selected, .datepicker table tr td.selected:hover, .datepicker table tr td.selected.disabled, .datepicker table tr td.selected.disabled:hover { background-color: #9e9e9e; background-image: -moz-linear-gradient(top, #b3b3b3, #808080); background-image: -ms-linear-gradient(top, #b3b3b3, #808080); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b3b3b3), to(#808080)); background-image: -<API key>(top, #b3b3b3, #808080); background-image: -o-linear-gradient(top, #b3b3b3, #808080); background-image: linear-gradient(top, #b3b3b3, #808080); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0); border-color: #808080 #808080 #595959; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } .datepicker table tr td.selected:hover, .datepicker table tr td.selected:hover:hover, .datepicker table tr td.selected.disabled:hover, .datepicker table tr td.selected.disabled:hover:hover, .datepicker table tr td.selected:active, .datepicker table tr td.selected:hover:active, .datepicker table tr td.selected.disabled:active, .datepicker table tr td.selected.disabled:hover:active, .datepicker table tr td.selected.active, .datepicker table tr td.selected:hover.active, .datepicker table tr td.selected.disabled.active, .datepicker table tr td.selected.disabled:hover.active, .datepicker table tr td.selected.disabled, .datepicker table tr td.selected:hover.disabled, .datepicker table tr td.selected.disabled.disabled, .datepicker table tr td.selected.disabled:hover.disabled, .datepicker table tr td.selected[disabled], .datepicker table tr td.selected:hover[disabled], .datepicker table tr td.selected.disabled[disabled], .datepicker table tr td.selected.disabled:hover[disabled] { background-color: #808080; } .datepicker table tr td.selected:active, .datepicker table tr td.selected:hover:active, .datepicker table tr td.selected.disabled:active, .datepicker table tr td.selected.disabled:hover:active, .datepicker table tr td.selected.active, .datepicker table tr td.selected:hover.active, .datepicker table tr td.selected.disabled.active, .datepicker table tr td.selected.disabled:hover.active { background-color: #666666 \9; } .datepicker table tr td.active, .datepicker table tr td.active:hover, .datepicker table tr td.active.disabled, .datepicker table tr td.active.disabled:hover { background-color: #006dcc; background-image: -moz-linear-gradient(top, #0088cc, #0044cc); background-image: -ms-linear-gradient(top, #0088cc, #0044cc); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); background-image: -<API key>(top, #0088cc, #0044cc); background-image: -o-linear-gradient(top, #0088cc, #0044cc); background-image: linear-gradient(top, #0088cc, #0044cc); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); border-color: #0044cc #0044cc #002a80; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } .datepicker table tr td.active:hover, .datepicker table tr td.active:hover:hover, .datepicker table tr td.active.disabled:hover, .datepicker table tr td.active.disabled:hover:hover, .datepicker table tr td.active:active, .datepicker table tr td.active:hover:active, .datepicker table tr td.active.disabled:active, .datepicker table tr td.active.disabled:hover:active, .datepicker table tr td.active.active, .datepicker table tr td.active:hover.active, .datepicker table tr td.active.disabled.active, .datepicker table tr td.active.disabled:hover.active, .datepicker table tr td.active.disabled, .datepicker table tr td.active:hover.disabled, .datepicker table tr td.active.disabled.disabled, .datepicker table tr td.active.disabled:hover.disabled, .datepicker table tr td.active[disabled], .datepicker table tr td.active:hover[disabled], .datepicker table tr td.active.disabled[disabled], .datepicker table tr td.active.disabled:hover[disabled] { background-color: #0044cc; } .datepicker table tr td.active:active, .datepicker table tr td.active:hover:active, .datepicker table tr td.active.disabled:active, .datepicker table tr td.active.disabled:hover:active, .datepicker table tr td.active.active, .datepicker table tr td.active:hover.active, .datepicker table tr td.active.disabled.active, .datepicker table tr td.active.disabled:hover.active { background-color: #003399 \9; } .datepicker table tr td span { display: block; width: 23%; height: 54px; line-height: 54px; float: left; margin: 1%; cursor: pointer; -<API key>: 4px; -moz-border-radius: 4px; border-radius: 4px; } .datepicker table tr td span:hover { background: #eeeeee; } .datepicker table tr td span.disabled, .datepicker table tr td span.disabled:hover { background: none; color: #999999; cursor: default; } .datepicker table tr td span.active, .datepicker table tr td span.active:hover, .datepicker table tr td span.active.disabled, .datepicker table tr td span.active.disabled:hover { background-color: #006dcc; background-image: -moz-linear-gradient(top, #0088cc, #0044cc); background-image: -ms-linear-gradient(top, #0088cc, #0044cc); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); background-image: -<API key>(top, #0088cc, #0044cc); background-image: -o-linear-gradient(top, #0088cc, #0044cc); background-image: linear-gradient(top, #0088cc, #0044cc); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); border-color: #0044cc #0044cc #002a80; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } .datepicker table tr td span.active:hover, .datepicker table tr td span.active:hover:hover, .datepicker table tr td span.active.disabled:hover, .datepicker table tr td span.active.disabled:hover:hover, .datepicker table tr td span.active:active, .datepicker table tr td span.active:hover:active, .datepicker table tr td span.active.disabled:active, .datepicker table tr td span.active.disabled:hover:active, .datepicker table tr td span.active.active, .datepicker table tr td span.active:hover.active, .datepicker table tr td span.active.disabled.active, .datepicker table tr td span.active.disabled:hover.active, .datepicker table tr td span.active.disabled, .datepicker table tr td span.active:hover.disabled, .datepicker table tr td span.active.disabled.disabled, .datepicker table tr td span.active.disabled:hover.disabled, .datepicker table tr td span.active[disabled], .datepicker table tr td span.active:hover[disabled], .datepicker table tr td span.active.disabled[disabled], .datepicker table tr td span.active.disabled:hover[disabled] { background-color: #0044cc; } .datepicker table tr td span.active:active, .datepicker table tr td span.active:hover:active, .datepicker table tr td span.active.disabled:active, .datepicker table tr td span.active.disabled:hover:active, .datepicker table tr td span.active.active, .datepicker table tr td span.active:hover.active, .datepicker table tr td span.active.disabled.active, .datepicker table tr td span.active.disabled:hover.active { background-color: #003399 \9; } .datepicker table tr td span.old, .datepicker table tr td span.new { color: #999999; } .datepicker .datepicker-switch { width: 145px; } .datepicker .datepicker-switch, .datepicker .prev, .datepicker .next, .datepicker tfoot tr th { cursor: pointer; } .datepicker .datepicker-switch:hover, .datepicker .prev:hover, .datepicker .next:hover, .datepicker tfoot tr th:hover { background: #eeeeee; } .datepicker .cw { font-size: 10px; width: 12px; padding: 0 2px 0 5px; vertical-align: middle; } .input-append.date .add-on, .input-prepend.date .add-on { cursor: pointer; } .input-append.date .add-on i, .input-prepend.date .add-on i { margin-top: 3px; } .input-daterange input { text-align: center; } .input-daterange input:first-child { -<API key>: 3px 0 0 3px; -moz-border-radius: 3px 0 0 3px; border-radius: 3px 0 0 3px; } .input-daterange input:last-child { -<API key>: 0 3px 3px 0; -moz-border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0; } .input-daterange .add-on { display: inline-block; width: auto; min-width: 16px; height: 18px; padding: 4px 5px; font-weight: normal; line-height: 18px; text-align: center; text-shadow: 0 1px 0 #ffffff; vertical-align: middle; background-color: #eeeeee; border: 1px solid #ccc; margin-left: -5px; margin-right: -5px; }
// File: chapter14/appUnderTest/app/scripts/app.js angular.module('fifaApp', ['ngRoute']) .config(function($routeProvider) { $routeProvider.when('/', { templateUrl: 'views/team_list.html', controller: 'TeamListCtrl as teamListCtrl' }) .when('/login', { templateUrl: 'views/login.html', }) .when('/team/:code', { templateUrl: 'views/team_details.html', controller:'TeamDetailsCtrl as teamDetailsCtrl', resolve: { auth: ['$q', '$location', 'UserService', function($q, $location, UserService) { return UserService.session().then( function(success) {}, function(err) { $location.path('/login'); return $q.reject(err); }); }] } }); $routeProvider.otherwise({ redirectTo: '/' }); });
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #include "<API key>.h" #include "ns3/log.h" #include "ns3/object-vector.h" #include "ns3/packet.h" #include "ns3/queue-disc.h" namespace ns3 { <API key> ("TrafficControlLayer"); <API key> (TrafficControlLayer); TypeId TrafficControlLayer::GetTypeId (void) { static TypeId tid = TypeId ("ns3::TrafficControlLayer") .SetParent<Object> () .SetGroupName ("TrafficControl") .AddConstructor<TrafficControlLayer> () .AddAttribute ("RootQueueDiscList", "The list of root queue discs associated to this Traffic Control layer.", ObjectVectorValue (), <API key> (&TrafficControlLayer::m_rootQueueDiscs), <API key><QueueDisc> ()) ; return tid; } TypeId TrafficControlLayer::GetInstanceTypeId (void) const { return GetTypeId (); } TrafficControlLayer::TrafficControlLayer () : Object () { <API key> (); } void TrafficControlLayer::DoDispose (void) { NS_LOG_FUNCTION (this); m_node = 0; m_rootQueueDiscs.clear (); m_handlers.clear (); <API key>.clear (); Object::DoDispose (); } void TrafficControlLayer::DoInitialize (void) { NS_LOG_FUNCTION (this); for (uint32_t j = 0; j < m_rootQueueDiscs.size (); j++) { if (m_rootQueueDiscs[j]) { Ptr<NetDevice> device = m_node->GetDevice (j); // NetDevices supporting flow control can set the number of device transmission // queues through the NetDevice queue interface during initialization. Thus, // ensure that the device has completed initialization device->Initialize (); std::map<Ptr<NetDevice>, NetDeviceInfo>::iterator qdMap = <API key>.find (device); NS_ASSERT (qdMap != <API key>.end ()); Ptr<<API key>> devQueueIface = qdMap->second.first; NS_ASSERT (devQueueIface); devQueueIface-><API key> (true); // set the wake callbacks on netdevice queues if (m_rootQueueDiscs[j]->GetWakeMode () == QueueDisc::WAKE_ROOT) { for (uint32_t i = 0; i < devQueueIface->GetTxQueuesN (); i++) { devQueueIface->GetTxQueue (i)->SetWakeCallback (MakeCallback (&QueueDisc::Run, m_rootQueueDiscs[j])); qdMap->second.second.push_back (m_rootQueueDiscs[j]); } } else if (m_rootQueueDiscs[j]->GetWakeMode () == QueueDisc::WAKE_CHILD) { NS_ASSERT_MSG (m_rootQueueDiscs[j]-><API key> () == devQueueIface->GetTxQueuesN (), "The number of child queue discs does not match the number of netdevice queues"); for (uint32_t i = 0; i < devQueueIface->GetTxQueuesN (); i++) { devQueueIface->GetTxQueue (i)->SetWakeCallback (MakeCallback (&QueueDisc::Run, m_rootQueueDiscs[j]->GetQueueDiscClass (i)->GetQueueDisc ())); qdMap->second.second.push_back (m_rootQueueDiscs[j]->GetQueueDiscClass (i)->GetQueueDisc ()); } } // initialize the queue disc m_rootQueueDiscs[j]->Initialize (); } } Object::DoInitialize (); } void TrafficControlLayer::SetupDevice (Ptr<NetDevice> device) { NS_LOG_FUNCTION (this << device); // ensure this setup is done just once (in case of dual stack nodes) if (device->GetObject<<API key>> ()) { NS_LOG_DEBUG ("The setup for this device has been already done."); return; } // create a <API key> object and aggregate it to the device Ptr<<API key>> devQueueIface = CreateObject<<API key>> (); device->AggregateObject (devQueueIface); // store a pointer to the created queue interface NS_ASSERT_MSG (<API key>.find (device) == <API key>.end (), "This is a bug: SetupDevice should be called only once per device"); <API key>[device] = NetDeviceInfo (devQueueIface, QueueDiscVector ()); } void TrafficControlLayer::<API key> (Node::ProtocolHandler handler, uint16_t protocolType, Ptr<NetDevice> device) { NS_LOG_FUNCTION (this << protocolType << device); struct <API key> entry; entry.handler = handler; entry.protocol = protocolType; entry.device = device; entry.promiscuous = false; m_handlers.push_back (entry); NS_LOG_DEBUG ("Handler for NetDevice: " << device << " registered for protocol " << protocolType << "."); } void TrafficControlLayer::<API key> (Ptr<NetDevice> device, Ptr<QueueDisc> qDisc) { NS_LOG_FUNCTION (this << device); uint32_t index = GetDeviceIndex (device); NS_ASSERT_MSG (index < m_node->GetNDevices (), "The provided device does not belong to" << " the node which this TrafficControlLayer object is aggregated to" ); if (index >= m_rootQueueDiscs.size ()) { m_rootQueueDiscs.resize (index+1); } NS_ASSERT_MSG (m_rootQueueDiscs[index] == 0, "Cannot install a root queue disc on a " << "device already having one. Delete the existing queue disc first."); m_rootQueueDiscs[index] = qDisc; } Ptr<QueueDisc> TrafficControlLayer::<API key> (Ptr<NetDevice> device) { NS_LOG_FUNCTION (this << device); uint32_t index = GetDeviceIndex (device); NS_ASSERT_MSG (index < m_node->GetNDevices (), "The provided device does not belong to" << " the node which this TrafficControlLayer object is aggregated to" ); if (index >= m_rootQueueDiscs.size ()) { m_rootQueueDiscs.resize (index+1); } return m_rootQueueDiscs[index]; } void TrafficControlLayer::<API key> (Ptr<NetDevice> device) { NS_LOG_FUNCTION (this << device); uint32_t index = GetDeviceIndex (device); NS_ASSERT_MSG (index < m_node->GetNDevices (), "The provided device does not belong to" << " the node which this TrafficControlLayer object is aggregated to" ); NS_ASSERT_MSG (index < m_rootQueueDiscs.size () && m_rootQueueDiscs[index] != 0, "No root queue disc" << " installed on device " << device); // remove the root queue disc m_rootQueueDiscs[index] = 0; } void TrafficControlLayer::SetNode (Ptr<Node> node) { NS_LOG_FUNCTION (this << node); m_node = node; } void TrafficControlLayer::NotifyNewAggregate () { NS_LOG_FUNCTION (this); if (m_node == 0) { Ptr<Node> node = this->GetObject<Node> (); //verify that it's a valid node and that //the node was not set before if (node != 0) { this->SetNode (node); } } Object::NotifyNewAggregate (); } uint32_t TrafficControlLayer::GetDeviceIndex (Ptr<NetDevice> device) { NS_LOG_FUNCTION (this << device); uint32_t i; for (i = 0; i < m_node->GetNDevices () && device != m_node->GetDevice (i); i++); return i; } void TrafficControlLayer::Receive (Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION (this << device << p << protocol << from << to << packetType); bool found = false; for (ProtocolHandlerList::iterator i = m_handlers.begin (); i != m_handlers.end (); i++) { if (i->device == 0 || (i->device != 0 && i->device == device)) { if (i->protocol == 0 || i->protocol == protocol) { NS_LOG_DEBUG ("Found handler for packet " << p << ", protocol " << protocol << " and NetDevice " << device << ". Send packet up"); i->handler (device, p, protocol, from, to, packetType); found = true; } } } if (! found) { NS_FATAL_ERROR ("Handler for protocol " << p << " and device " << device << " not found. It isn't forwarded up; it dies here."); } } void TrafficControlLayer::Send (Ptr<NetDevice> device, Ptr<QueueDiscItem> item) { NS_LOG_FUNCTION (this << device << item); NS_LOG_DEBUG ("Send packet to device " << device << " protocol number " << item->GetProtocol ()); std::map<Ptr<NetDevice>, NetDeviceInfo>::iterator qdMap = <API key>.find (device); NS_ASSERT (qdMap != <API key>.end ()); Ptr<<API key>> devQueueIface = qdMap->second.first; NS_ASSERT (devQueueIface); // determine the transmission queue of the device where the packet will be enqueued uint8_t txq = devQueueIface->GetSelectedQueue (item); NS_ASSERT (txq < devQueueIface->GetTxQueuesN ()); if (qdMap->second.second.empty ()) { // The device has no attached queue disc, thus add the header to the packet and // send it directly to the device if the selected queue is not stopped if (!devQueueIface->GetTxQueue (txq)->IsStopped ()) { item->AddHeader (); device->Send (item->GetPacket (), item->GetAddress (), item->GetProtocol ()); } } else { // Enqueue the packet in the queue disc associated with the netdevice queue // selected for the packet and try to dequeue packets from such queue disc item->SetTxQueueIndex (txq); Ptr<QueueDisc> qDisc = qdMap->second.second[txq]; NS_ASSERT (qDisc); qDisc->Enqueue (item); qDisc->Run (); } } } // namespace ns3
#ifndef TRINITY_GUARDAI_H #define TRINITY_GUARDAI_H #include "ScriptedCreature.h" class Creature; class TC_GAME_API GuardAI : public ScriptedAI { public: explicit GuardAI(Creature* creature); static int32 Permissible(Creature const* creature); void UpdateAI(uint32 diff) override; bool CanSeeAlways(WorldObject const* obj) override; void EnterEvadeMode(EvadeReason /*why*/) override; void JustDied(Unit* killer) override; }; #endif
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ #ifndef <API key> #define <API key> #include "ns3/ptr.h" #include "address.h" #include "mac48-address.h" #include "mac64-address.h" #include "net-device.h" namespace ns3 { class NetDevice; /** * \ingroup address * * \brief an address for a packet socket */ class PacketSocketAddress { public: PacketSocketAddress (); void SetProtocol (uint16_t protocol); void SetAllDevices (void); void SetSingleDevice (uint32_t device); void SetPhysicalAddress (const Address address); uint16_t GetProtocol (void) const; uint32_t GetSingleDevice (void) const; bool IsSingleDevice (void) const; Address GetPhysicalAddress (void) const; /** * \returns a new Address instance * * Convert an instance of this class to a polymorphic Address instance. */ operator Address () const; /** * \param address a polymorphic address * * Convert a polymorphic address to an Mac48Address instance. * The conversion performs a type check. */ static PacketSocketAddress ConvertFrom (const Address &address); /** * \param address address to test * \returns true if the address matches, false otherwise. */ static bool IsMatchingType (const Address &address); private: static uint8_t GetType (void); Address ConvertTo (void) const; uint16_t m_protocol; bool m_isSingleDevice; uint32_t m_device; Address m_address; }; } // namespace ns3 #endif /* <API key> */
#include <linux/semaphore.h> #include <wlan_hdd_tx_rx.h> #include <<API key>.h> #include <wlan_hdd_dp_utils.h> #include <wlan_qct_tl.h> #include <linux/netdevice.h> #include <linux/skbuff.h> #include <linux/etherdevice.h> //#include <vos_list.h> #include <vos_types.h> #include <aniGlobal.h> #include <halTypes.h> #include <net/ieee80211_radiotap.h> #include <linux/ratelimit.h> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) #include <soc/qcom/subsystem_restart.h> #else #include <mach/subsystem_restart.h> #endif #if 0 static void <API key>(struct sk_buff * skb) { VOS_TRACE( <API key>, <API key>,"%s: head = %p", __func__, skb->head); //VOS_TRACE( <API key>, <API key>,"%s: data = %p", __func__, skb->data); VOS_TRACE( <API key>, <API key>,"%s: tail = %p", __func__, skb->tail); VOS_TRACE( <API key>, <API key>,"%s: end = %p", __func__, skb->end); VOS_TRACE( <API key>, <API key>,"%s: len = %d", __func__, skb->len); VOS_TRACE( <API key>, <API key>,"%s: data_len = %d", __func__, skb->data_len); VOS_TRACE( <API key>, <API key>,"%s: mac_len = %d", __func__, skb->mac_len); VOS_TRACE( <API key>, <API key>,"0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[0], skb->data[1], skb->data[2], skb->data[3], skb->data[4], skb->data[5], skb->data[6], skb->data[7]); VOS_TRACE( <API key>, <API key>,"0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8], skb->data[9], skb->data[10], skb->data[11], skb->data[12], skb->data[13], skb->data[14], skb->data[15]); } #endif extern void <API key>(bool suspend); #define <API key> 20*HZ #define <API key> 1 #define <API key> 5 static <API key>(<API key>, \ <API key>, \ <API key>); void <API key>( void *pUsrData ) { hdd_context_t *pHddCtx = (hdd_context_t *)pUsrData; v_TIME_t currentTS; if (NULL == pHddCtx) { VOS_TRACE( <API key>, <API key>, "%s: Invalid user data, context", __func__); return; } currentTS = <API key>(); if (pHddCtx->cfg_ini->trafficIdleTimeout < (currentTS - pHddCtx->traffic_monitor.lastFrameTs)) { VOS_TRACE( <API key>, <API key>, "%s: No Data Activity calling Wlan Suspend", __func__ ); <API key>(1); atomic_set(&pHddCtx->traffic_monitor.isActiveMode, 0); } else { vos_timer_start(&pHddCtx->traffic_monitor.trafficTimer, pHddCtx->cfg_ini->trafficIdleTimeout); } return; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter ) { hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); VOS_STATUS status = VOS_STATUS_SUCCESS; status = <API key>(pHddCtx); if (0 != status) { VOS_TRACE( VOS_MODULE_ID_HDD, <API key>, "%s: HDD context is not valid", __func__); return status; } if ((pHddCtx->cfg_ini-><API key>) && (!pHddCtx->traffic_monitor.isInitialized)) { atomic_set(&pHddCtx->traffic_monitor.isActiveMode, 1); vos_timer_init(&pHddCtx->traffic_monitor.trafficTimer, VOS_TIMER_TYPE_SW, <API key>, pHddCtx); vos_lock_init(&pHddCtx->traffic_monitor.trafficLock); pHddCtx->traffic_monitor.isInitialized = 1; pHddCtx->traffic_monitor.lastFrameTs = 0; /* Start traffic monitor timer here * If no AP assoc, immediatly go into suspend */ VOS_TRACE( <API key>, <API key>, "%s Start Traffic Monitor Timer", __func__); vos_timer_start(&pHddCtx->traffic_monitor.trafficTimer, pHddCtx->cfg_ini->trafficIdleTimeout); } else { VOS_TRACE( <API key>, <API key>, "%s Traffic Monitor is not Enable in ini file", __func__); } return status; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter ) { hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); VOS_STATUS status = VOS_STATUS_SUCCESS; status = <API key>(pHddCtx); if (-ENODEV == status) { VOS_TRACE( VOS_MODULE_ID_HDD, <API key>, "%s: HDD context is not valid", __func__); return status; } if (pHddCtx->traffic_monitor.isInitialized) { if (<API key> != <API key>(&pHddCtx->traffic_monitor.trafficTimer)) { VOS_TRACE( <API key>, <API key>, "%s Stop Traffic Monitor Timer", __func__); vos_timer_stop(&pHddCtx->traffic_monitor.trafficTimer); } VOS_TRACE( <API key>, <API key>, "%s Destroy Traffic Monitor Timer", __func__); vos_timer_destroy(&pHddCtx->traffic_monitor.trafficTimer); vos_lock_destroy(&pHddCtx->traffic_monitor.trafficLock); pHddCtx->traffic_monitor.isInitialized = 0; } return VOS_STATUS_SUCCESS; } static VOS_STATUS <API key>( hdd_adapter_t *pAdapter ) { VOS_STATUS status = VOS_STATUS_SUCCESS; v_SINT_t i = -1; v_U8_t STAId = 0; hdd_list_node_t *anchor = NULL; skb_list_node_t *pktNode = NULL; struct sk_buff *skb = NULL; spin_lock_bh( &pAdapter->staInfo_lock ); for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) { if (FALSE == pAdapter->aStaInfo[STAId].isUsed) { continue; } for (i = 0; i < NUM_TX_QUEUES; i ++) { spin_lock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i].lock); while (true) { status = <API key> ( &pAdapter->aStaInfo[STAId].wmm_tx_queue[i], &anchor); if (VOS_STATUS_E_EMPTY != status) { //If success then we got a valid packet from some AC pktNode = list_entry(anchor, skb_list_node_t, anchor); skb = pktNode->skb; ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txFlushed; ++pAdapter->hdd_stats.hddTxRxStats.txFlushedAC[i]; kfree_skb(skb); continue; } //current list is empty break; } pAdapter->aStaInfo[STAId].txSuspended[i] = VOS_FALSE; spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i].lock); } pAdapter->aStaInfo[STAId].vosLowResource = VOS_FALSE; } spin_unlock_bh( &pAdapter->staInfo_lock ); return status; } int <API key>(struct sk_buff *skb, struct net_device *dev) { VOS_STATUS status; WLANTL_ACEnumType ac = WLANTL_AC_BE; sme_QosWmmUpType up = SME_QOS_WMM_UP_BE; skb_list_node_t *pktNode = NULL; v_SIZE_t pktListSize = 0; v_BOOL_t txSuspended = VOS_FALSE; hdd_adapter_t *pAdapter = (hdd_adapter_t *)netdev_priv(dev); hdd_ap_ctx_t *pHddApCtx = <API key>(pAdapter); vos_list_node_t *anchor = NULL; v_U8_t STAId = WLAN_MAX_STA_COUNT; //Extract the destination address from ethernet frame v_MACADDR_t *pDestMacAddress = (v_MACADDR_t*)skb->data; int os_status = NETDEV_TX_OK; pDestMacAddress = (v_MACADDR_t*)skb->data; ++pAdapter->hdd_stats.hddTxRxStats.txXmitCalled; VOS_TRACE( <API key>, <API key>, "%s: enter", __func__); spin_lock_bh( &pAdapter->staInfo_lock ); if (<API key>( pDestMacAddress ) || <API key>(pDestMacAddress)) { //The BC/MC station ID is assigned during BSS starting phase. SAP will return the station //ID used for BC/MC traffic. The station id is registered to TL as well. STAId = pHddApCtx->uBCStaId; /* Setting priority for broadcast packets which doesn't go to select_queue function */ skb->priority = SME_QOS_WMM_UP_BE; skb->queue_mapping = HDD_LINUX_AC_BE; VOS_TRACE( <API key>, <API key>, "%s: BC/MC packet", __func__); } else { STAId = *(v_U8_t *)(((v_U8_t *)(skb->data)) - 1); if (STAId == <API key>) { VOS_TRACE( <API key>, <API key>, "%s: Failed to find right station", __func__); ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; kfree_skb(skb); goto xmit_done; } else if (FALSE == pAdapter->aStaInfo[STAId].isUsed ) { VOS_TRACE( <API key>, <API key>, "%s: STA %d is unregistered", __func__, STAId); ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; kfree_skb(skb); goto xmit_done; } if ( (<API key> != pAdapter->aStaInfo[STAId].tlSTAState) && (<API key> != pAdapter->aStaInfo[STAId].tlSTAState) ) { VOS_TRACE( <API key>, <API key>, "%s: Station not connected yet", __func__); ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; kfree_skb(skb); goto xmit_done; } else if(<API key> == pAdapter->aStaInfo[STAId].tlSTAState) { if(ntohs(skb->protocol) != <API key>) { VOS_TRACE( <API key>, <API key>, "%s: NON-EAPOL packet in non-Authenticated state", __func__); ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; kfree_skb(skb); goto xmit_done; } } } //Get TL AC corresponding to Qdisc queue index/AC. ac = hdd_QdiscAcToTlAC[skb->queue_mapping]; //user priority from IP header, which is already extracted and set from //select_queue call back function up = skb->priority; ++pAdapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[ac]; VOS_TRACE( <API key>, <API key>, "%s: Classified as ac %d up %d", __func__, ac, up); // If the memory differentiation mode is enabled, the memory limit of each queue will be // checked. Over-limit packets will be dropped. spin_lock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); hdd_list_size(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac], &pktListSize); if(pktListSize >= pAdapter->aTxQueueLimit[ac]) { VOS_TRACE( <API key>, <API key>, "%s: station %d ac %d queue over limit %d", __func__, STAId, ac, pktListSize); pAdapter->aStaInfo[STAId].txSuspended[ac] = VOS_TRUE; netif_stop_subqueue(dev, <API key>(skb)); txSuspended = VOS_TRUE; } /* If 3/4th of the max queue size is used then enable the flag. * This flag indicates to place the DHCP packets in VOICE AC queue.*/ if (WLANTL_AC_BE == ac) { if (pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].count >= <API key>) { VOS_TRACE( VOS_MODULE_ID_HDD, <API key>, "%s: TX queue for Best Effort AC is 3/4th full", __func__); pAdapter->aStaInfo[STAId].vosLowResource = VOS_TRUE; } else { pAdapter->aStaInfo[STAId].vosLowResource = VOS_FALSE; } } spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); if (VOS_TRUE == txSuspended) { VOS_TRACE( VOS_MODULE_ID_HDD, <API key>, "%s: TX queue full for AC=%d Disable OS TX queue", __func__, ac ); os_status = NETDEV_TX_BUSY; goto xmit_done; } //Use the skb->cb field to hold the list node information pktNode = (skb_list_node_t *)&skb->cb; //Stick the OS packet inside this node. pktNode->skb = skb; //Stick the User Priority inside this node pktNode->userPriority = up; INIT_LIST_HEAD(&pktNode->anchor); spin_lock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); status = <API key>(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac], &pktNode->anchor, &pktListSize ); spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); if ( !<API key>( status ) ) { VOS_TRACE( <API key>, <API key>, "%s:Insert Tx queue failed. Pkt dropped", __func__); ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac]; ++pAdapter->stats.tx_dropped; kfree_skb(skb); goto xmit_done; } ++pAdapter->hdd_stats.hddTxRxStats.txXmitQueued; ++pAdapter->hdd_stats.hddTxRxStats.txXmitQueuedAC[ac]; ++pAdapter->hdd_stats.hddTxRxStats.pkt_tx_count; if (1 == pktListSize) { //Let TL know we have a packet to send for this AC status = <API key>( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, STAId, ac ); if ( !<API key>( status ) ) { VOS_TRACE( <API key>, <API key>, "%s: Failed to signal TL for AC=%d STAId =%d", __func__, ac, STAId ); //Remove the packet from queue. It must be at the back of the queue, as TX thread cannot preempt us in the middle //as we are in a soft irq context. Also it must be the same packet that we just allocated. spin_lock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); status = <API key>( &pAdapter->aStaInfo[STAId].wmm_tx_queue[ac], &anchor); spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac]; kfree_skb(skb); goto xmit_done; } } dev->trans_start = jiffies; VOS_TRACE( <API key>, <API key>, "%s: exit", __func__); xmit_done: spin_unlock_bh( &pAdapter->staInfo_lock ); return os_status; } VOS_STATUS <API key>(struct sk_buff *skb, struct net_device *dev, v_U8_t STAId, v_U8_t up) { VOS_STATUS status = VOS_STATUS_SUCCESS; skb_list_node_t *pktNode = NULL; v_SIZE_t pktListSize = 0; hdd_adapter_t *pAdapter = (hdd_adapter_t *)netdev_priv(dev); v_U8_t ac; vos_list_node_t *anchor = NULL; ++pAdapter->hdd_stats.hddTxRxStats.txXmitCalled; VOS_TRACE( <API key>, <API key>, "%s: enter", __func__); spin_lock_bh( &pAdapter->staInfo_lock ); if ( FALSE == pAdapter->aStaInfo[STAId].isUsed ) { VOS_TRACE( <API key>, <API key>, "%s: STA %d is unregistered", __func__, STAId ); kfree_skb(skb); status = <API key>; goto xmit_end; } /* If the QoS is not enabled on the receiving station, then send it with BE priority */ if ( !pAdapter->aStaInfo[STAId].isQosEnabled ) up = SME_QOS_WMM_UP_BE; ac = hddWmmUpToAcMap[up]; ++pAdapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[ac]; VOS_TRACE( <API key>, <API key>, "%s: Classified as ac %d up %d", __func__, ac, up); skb->queue_mapping = hddLinuxUpToAcMap[up]; //Use the skb->cb field to hold the list node information pktNode = (skb_list_node_t *)&skb->cb; //Stick the OS packet inside this node. pktNode->skb = skb; //Stick the User Priority inside this node pktNode->userPriority = up; INIT_LIST_HEAD(&pktNode->anchor); spin_lock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); hdd_list_size(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac], &pktListSize); if(pAdapter->aStaInfo[STAId].txSuspended[ac] || pktListSize >= pAdapter->aTxQueueLimit[ac]) { VOS_TRACE( <API key>, <API key>, "%s: station %d ac %d queue over limit %d", __func__, STAId, ac, pktListSize); /* TODO:Rx Flowchart should be trigerred here to SUPEND SSC on RX side. * SUSPEND should be done based on Threshold. RESUME would be * triggered in fetch cbk after recovery. */ kfree_skb(skb); spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); status = <API key>; goto xmit_end; } status = <API key>(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac], &pktNode->anchor, &pktListSize ); spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); if ( !<API key>( status ) ) { VOS_TRACE( <API key>, <API key>, "%s:Insert Tx queue failed. Pkt dropped", __func__); ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac]; ++pAdapter->stats.tx_dropped; kfree_skb(skb); status = <API key>; goto xmit_end; } ++pAdapter->hdd_stats.hddTxRxStats.txXmitQueued; ++pAdapter->hdd_stats.hddTxRxStats.txXmitQueuedAC[ac]; if (1 == pktListSize) { //Let TL know we have a packet to send for this AC //VOS_TRACE( <API key>, <API key>,"%s:Indicating Packet to TL", __func__); status = <API key>( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, STAId, ac ); if ( !<API key>( status ) ) { VOS_TRACE( <API key>, <API key>, "%s: Failed to signal TL for AC=%d STAId =%d", __func__, ac, STAId ); //Remove the packet from queue. It must be at the back of the queue, as TX thread cannot preempt us in the middle //as we are in a soft irq context. Also it must be the same packet that we just allocated. spin_lock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); status = <API key>( &pAdapter->aStaInfo[STAId].wmm_tx_queue[ac], &anchor); spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; ++pAdapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac]; kfree_skb(skb); status = <API key>; goto xmit_end; } } VOS_TRACE( <API key>, <API key>, "%s: exit", __func__); xmit_end: spin_unlock_bh( &pAdapter->staInfo_lock ); return status; } void <API key>(struct net_device *dev) { hdd_adapter_t *pAdapter = <API key>(dev); struct netdev_queue *txq; int i = 0; VOS_TRACE( <API key>, <API key>, "%s: Transmission timeout occurred", __func__); if ( NULL == pAdapter ) { VOS_TRACE( <API key>, <API key>, FL("pAdapter is NULL")); VOS_ASSERT(0); return; } ++pAdapter->hdd_stats.hddTxRxStats.txTimeoutCount; for (i = 0; i < 8; i++) { txq = netdev_get_tx_queue(dev, i); VOS_TRACE( <API key>, <API key>, "Queue%d status: %d", i, <API key>(txq)); } VOS_TRACE( <API key>, <API key>, "carrier state: %d", netif_carrier_ok(dev)); ++pAdapter->hdd_stats.hddTxRxStats.<API key>; if (pAdapter->hdd_stats.hddTxRxStats.<API key> > <API key>) { // Driver could not recover, issue SSR VOS_TRACE(<API key>, <API key>, "%s: Cannot recover from Data stall Issue SSR", __func__); WLANTL_FatalError(); return; } /* If Tx stalled for a long time then *hdd_tx_timeout* is called * every 5sec. The TL debug spits out a lot of information on the * serial console, if it is called every time *hdd_tx_timeout* is * called then we may get a watchdog bite on the Application * processor, so ratelimit the TL debug logs. */ if (__ratelimit(&<API key>)) { hdd_wmm_tx_snapshot(pAdapter); <API key>(VOS_TRUE); } } struct net_device_stats* hdd_softap_stats(struct net_device *dev) { hdd_adapter_t* priv = netdev_priv(dev); return &priv->stats; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter ) { VOS_STATUS status = VOS_STATUS_SUCCESS; v_SINT_t i = -1; v_SIZE_t size = 0; v_U8_t STAId = 0; v_U8_t pACWeights[] = { <API key>, <API key>, <API key>, <API key> }; pAdapter->isVosOutOfResource = VOS_FALSE; pAdapter->isVosLowResource = VOS_FALSE; vos_mem_zero(&pAdapter->stats, sizeof(struct net_device_stats)); while (++i != NUM_TX_QUEUES) hdd_list_init( &pAdapter->wmm_tx_queue[i], <API key>); /* Initial HDD buffer control / flow control fields*/ <API key> (<API key>, &size); pAdapter->aTxQueueLimit[WLANTL_AC_BK] = <API key>; pAdapter->aTxQueueLimit[WLANTL_AC_BE] = <API key>; pAdapter->aTxQueueLimit[WLANTL_AC_VI] = <API key>; pAdapter->aTxQueueLimit[WLANTL_AC_VO] = <API key>; spin_lock_init( &pAdapter->staInfo_lock ); for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) { vos_mem_zero(&pAdapter->aStaInfo[STAId], sizeof(hdd_station_info_t)); for (i = 0; i < NUM_TX_QUEUES; i ++) { hdd_list_init(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i], <API key>); } } /* Update the AC weights suitable for SoftAP mode of operation */ WLANTL_SetACWeights((WLAN_HDD_GET_CTX(pAdapter))->pvosContext, pACWeights); if (VOS_STATUS_SUCCESS != <API key>(pAdapter)) { VOS_TRACE( <API key>, <API key>, "%s: failed to start Traffic Monito timer ", __func__ ); return VOS_STATUS_E_INVAL; } return status; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter ) { VOS_STATUS status = VOS_STATUS_SUCCESS; if (VOS_STATUS_SUCCESS != <API key>(pAdapter)) { VOS_TRACE( <API key>, <API key>, "%s: Fail to Stop Traffic Monito timer", __func__ ); return VOS_STATUS_E_INVAL; } status = <API key>(pAdapter); return status; } static VOS_STATUS <API key>( hdd_adapter_t *pAdapter, v_U8_t STAId ) { v_U8_t i = -1; hdd_list_node_t *anchor = NULL; skb_list_node_t *pktNode = NULL; struct sk_buff *skb = NULL; if (FALSE == pAdapter->aStaInfo[STAId].isUsed) { return VOS_STATUS_SUCCESS; } for (i = 0; i < NUM_TX_QUEUES; i ++) { spin_lock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i].lock); while (true) { if (VOS_STATUS_E_EMPTY != <API key>(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i], &anchor)) { //If success then we got a valid packet from some AC pktNode = list_entry(anchor, skb_list_node_t, anchor); skb = pktNode->skb; ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txFlushed; ++pAdapter->hdd_stats.hddTxRxStats.txFlushedAC[i]; kfree_skb(skb); continue; } //current list is empty break; } spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i].lock); } return VOS_STATUS_SUCCESS; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA) { v_U8_t i = 0; spin_lock_bh( &pAdapter->staInfo_lock ); if (pAdapter->aStaInfo[STAId].isUsed) { VOS_TRACE( <API key>, <API key>, "%s: Reinit station %d", __func__, STAId ); spin_unlock_bh( &pAdapter->staInfo_lock ); return <API key>; } vos_mem_zero(&pAdapter->aStaInfo[STAId], sizeof(hdd_station_info_t)); for (i = 0; i < NUM_TX_QUEUES; i ++) { hdd_list_init(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i], <API key>); } pAdapter->aStaInfo[STAId].isUsed = TRUE; pAdapter->aStaInfo[STAId].isDeauthInProgress = FALSE; vos_copy_macaddr( &pAdapter->aStaInfo[STAId].macAddrSTA, pmacAddrSTA); spin_unlock_bh( &pAdapter->staInfo_lock ); return VOS_STATUS_SUCCESS; } VOS_STATUS <API key> ( hdd_adapter_t *pAdapter, v_U8_t STAId ) { VOS_STATUS status = VOS_STATUS_SUCCESS; v_U8_t ac; /**Track whether OS TX queue has been disabled.*/ v_BOOL_t txSuspended[NUM_TX_QUEUES]; v_U8_t tlAC; hdd_hostapd_state_t *pHostapdState; v_U8_t i; pHostapdState = <API key>(pAdapter); spin_lock_bh( &pAdapter->staInfo_lock ); if (FALSE == pAdapter->aStaInfo[STAId].isUsed) { VOS_TRACE( <API key>, <API key>, "%s: Deinit station not inited %d", __func__, STAId ); spin_unlock_bh( &pAdapter->staInfo_lock ); return <API key>; } status = <API key>(pAdapter, STAId); pAdapter->aStaInfo[STAId].isUsed = FALSE; pAdapter->aStaInfo[STAId].isDeauthInProgress = FALSE; /* if this STA had any of its WMM TX queues suspended, then the associated queue on the network interface was disabled. check to see if that is the case, in which case we need to re-enable the interface queue. but we only do this if the BSS is running since, if the BSS is stopped, all of the interfaces have been stopped and should not be re-enabled */ if (BSS_START == pHostapdState->bssState) { for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++) { tlAC = hdd_QdiscAcToTlAC[ac]; txSuspended[ac] = pAdapter->aStaInfo[STAId].txSuspended[tlAC]; } } vos_mem_zero(&pAdapter->aStaInfo[STAId], sizeof(hdd_station_info_t)); /* re-init spin lock, since netdev can still open adapter until * driver gets unloaded */ for (i = 0; i < NUM_TX_QUEUES; i ++) { hdd_list_init(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i], <API key>); } if (BSS_START == pHostapdState->bssState) { for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++) { if (txSuspended[ac]) { VOS_TRACE( <API key>, <API key>, "%s: TX queue re-enabled", __func__); netif_wake_subqueue(pAdapter->dev, ac); } } } spin_unlock_bh( &pAdapter->staInfo_lock ); return status; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter ) { return <API key>(pAdapter); } VOS_STATUS <API key>( v_VOID_t *vosContext, vos_pkt_t *pVosPacket, VOS_STATUS vosStatusIn ) { VOS_STATUS status = VOS_STATUS_SUCCESS; hdd_adapter_t *pAdapter = NULL; void* pOsPkt = NULL; if( ( NULL == vosContext ) || ( NULL == pVosPacket ) ) { VOS_TRACE( <API key>, <API key>, "%s: Null params being passed", __func__); return <API key>; } //Return the skb to the OS status = <API key>( pVosPacket, &pOsPkt, VOS_TRUE ); if(!<API key>( status )) { //This is bad but still try to free the VOSS resources if we can VOS_TRACE( <API key>, <API key>, "%s: Failure extracting skb from vos pkt", __func__); <API key>( pVosPacket ); return <API key>; } //Get the Adapter context. pAdapter = (hdd_adapter_t *)netdev_priv(((struct sk_buff *)pOsPkt)->dev); if(pAdapter == NULL) { VOS_TRACE( <API key>, <API key>, "%s: HDD adapter context is Null", __func__); } else { ++pAdapter->hdd_stats.hddTxRxStats.txCompleted; } kfree_skb((struct sk_buff *)pOsPkt); //Return the VOS packet resources. status = <API key>( pVosPacket ); if(!<API key>( status )) { VOS_TRACE( <API key>, <API key>, "%s: Could not return VOS packet to the pool", __func__); } return status; } VOS_STATUS <API key>( v_VOID_t *vosContext, v_U8_t *pStaId, WLANTL_ACEnumType ac, vos_pkt_t **ppVosPacket, WLANTL_MetaInfoType *pPktMetaInfo ) { VOS_STATUS status = <API key>; hdd_adapter_t *pAdapter = NULL; hdd_list_node_t *anchor = NULL; skb_list_node_t *pktNode = NULL; struct sk_buff *skb = NULL; vos_pkt_t *pVosPacket = NULL; v_MACADDR_t* pDestMacAddress = NULL; v_TIME_t timestamp; v_SIZE_t size = 0; v_U8_t STAId = WLAN_MAX_STA_COUNT; hdd_context_t *pHddCtx = NULL; v_U8_t proto_type = 0; //Sanity check on inputs if ( ( NULL == vosContext ) || ( NULL == pStaId ) || ( NULL == ppVosPacket ) || ( NULL == pPktMetaInfo ) ) { VOS_TRACE( <API key>, <API key>, "%s: Null Params being passed", __func__); return <API key>; } //Get the HDD context. pHddCtx = (hdd_context_t *)vos_get_context( VOS_MODULE_ID_HDD, vosContext ); if ( NULL == pHddCtx ) { VOS_TRACE( <API key>, <API key>, "%s: HDD adapter context is Null", __func__); return <API key>; } STAId = *pStaId; if (STAId >= WLAN_MAX_STA_COUNT) { VOS_TRACE( <API key>, <API key>, "%s: Invalid STAId %d passed by TL", __func__, STAId); return <API key>; } pAdapter = pHddCtx->sta_to_adapter[STAId]; if ((NULL == pAdapter) || (<API key> != pAdapter->magic)) { VOS_ASSERT(0); return <API key>; } if (FALSE == pAdapter->aStaInfo[STAId].isUsed ) { VOS_TRACE( <API key>, <API key>, "%s: Unregistered STAId %d passed by TL", __func__, STAId); return <API key>; } /* Monitor traffic */ if ( pHddCtx->cfg_ini-><API key> ) { pHddCtx->traffic_monitor.lastFrameTs = <API key>(); if ( !atomic_read(&pHddCtx->traffic_monitor.isActiveMode) ) { vos_lock_acquire(&pHddCtx->traffic_monitor.trafficLock); /* It was IDLE mode, * this is new state, then switch mode from suspend to resume */ if ( !atomic_read(&pHddCtx->traffic_monitor.isActiveMode) ) { <API key>(0); vos_timer_start(&pHddCtx->traffic_monitor.trafficTimer, pHddCtx->cfg_ini->trafficIdleTimeout); atomic_set(&pHddCtx->traffic_monitor.isActiveMode, 1); } vos_lock_release(&pHddCtx->traffic_monitor.trafficLock); } } ++pAdapter->hdd_stats.hddTxRxStats.txFetched; *ppVosPacket = NULL; //Make sure the AC being asked for is sane if( ac > WLANTL_MAX_AC || ac < 0) { VOS_TRACE( <API key>, <API key>, "%s: Invalid AC %d passed by TL", __func__, ac); return <API key>; } ++pAdapter->hdd_stats.hddTxRxStats.txFetchedAC[ac]; VOS_TRACE( <API key>, <API key>, "%s: AC %d passed by TL", __func__, ac); //Get the vos packet. I don't want to dequeue and enqueue again if we are out of VOS resources //This simplifies the locking and unlocking of Tx queue status = <API key>( &pVosPacket, <API key>, NULL, //OS Pkt is not being passed <API key>, pAdapter ); if (status == <API key> || status == <API key>) { //Remember VOS is in a low resource situation pAdapter->isVosOutOfResource = VOS_TRUE; ++pAdapter->hdd_stats.hddTxRxStats.txFetchLowResources; VOS_TRACE( <API key>, <API key>, "%s: VOSS in Low Resource scenario", __func__); //TL needs to handle this case. VOS_STATUS_E_EMPTY is returned when the queue is empty. return <API key>; } /* Only fetch this station and this AC. Return VOS_STATUS_E_EMPTY if nothing there. Do not get next AC as the other branch does. */ spin_lock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); hdd_list_size(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac], &size); if (0 == size) { spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); <API key>(pVosPacket); return VOS_STATUS_E_EMPTY; } status = <API key>( &pAdapter->aStaInfo[STAId].wmm_tx_queue[ac], &anchor ); spin_unlock_bh(&pAdapter->aStaInfo[STAId].wmm_tx_queue[ac].lock); VOS_TRACE( <API key>, <API key>, "%s: AC %d has packets pending", __func__, ac); if(VOS_STATUS_SUCCESS == status) { //If success then we got a valid packet from some AC pktNode = list_entry(anchor, skb_list_node_t, anchor); skb = pktNode->skb; } else { ++pAdapter->hdd_stats.hddTxRxStats.txFetchDequeueError; VOS_TRACE( <API key>, <API key>, "%s: Error in de-queuing skb from Tx queue status = %d", __func__, status ); <API key>(pVosPacket); return <API key>; } //Attach skb to VOS packet. status = <API key>( pVosPacket, skb ); if (status != VOS_STATUS_SUCCESS) { VOS_TRACE( <API key>, <API key>, "%s: Error attaching skb", __func__); <API key>(pVosPacket); ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txFetchDequeueError; kfree_skb(skb); return <API key>; } //Just being paranoid. To be removed later if(pVosPacket == NULL) { VOS_TRACE( <API key>, <API key>, "%s: VOS packet returned by VOSS is NULL", __func__); ++pAdapter->stats.tx_dropped; ++pAdapter->hdd_stats.hddTxRxStats.txFetchDequeueError; kfree_skb(skb); return <API key>; } //Return VOS packet to TL; *ppVosPacket = pVosPacket; //Fill out the meta information needed by TL //FIXME This timestamp is really the time stamp of wrap_data_packet <API key>( pVosPacket, &timestamp ); pPktMetaInfo->usTimeStamp = (v_U16_t)timestamp; if ( 1 < size ) { pPktMetaInfo->bMorePackets = 1; //HDD has more packets to send } else { pPktMetaInfo->bMorePackets = 0; } pPktMetaInfo->ucIsEapol = 0; if(pAdapter->aStaInfo[STAId].tlSTAState != <API key>) { if (TRUE == hdd_IsEAPOLPacket( pVosPacket )) { VOS_TRACE( <API key>, <API key>, "%s: VOS packet is EAPOL packet", __func__); pPktMetaInfo->ucIsEapol = 1; } } if (pHddCtx->cfg_ini->gEnableDebugLog) { proto_type = <API key>(skb, pHddCtx->cfg_ini->gEnableDebugLog); if (<API key> & proto_type) { VOS_TRACE(VOS_MODULE_ID_HDD, <API key>, "SAP TX EAPOL"); } else if (<API key> & proto_type) { VOS_TRACE(VOS_MODULE_ID_HDD, <API key>, "SAP TX DHCP"); } } //xg: @@@@: temporarily disble these. will revisit later { pPktMetaInfo->ucUP = pktNode->userPriority; pPktMetaInfo->ucTID = pPktMetaInfo->ucUP; } pPktMetaInfo->ucType = 0; //FIXME Don't know what this is //Extract the destination address from ethernet frame pDestMacAddress = (v_MACADDR_t*)skb->data; // we need 802.3 to 802.11 frame translation // (note that Bcast/Mcast will be translated in SW, unicast in HW) pPktMetaInfo->ucDisableFrmXtl = 0; pPktMetaInfo->ucBcast = <API key>( pDestMacAddress ) ? 1 : 0; pPktMetaInfo->ucMcast = <API key>( pDestMacAddress ) ? 1 : 0; if ( (pAdapter->aStaInfo[STAId].txSuspended[ac]) && (size <= ((pAdapter->aTxQueueLimit[ac]*3)/4) )) { VOS_TRACE( <API key>, <API key>, "%s: TX queue re-enabled", __func__); pAdapter->aStaInfo[STAId].txSuspended[ac] = VOS_FALSE; netif_wake_subqueue(pAdapter->dev, <API key>(skb)); } // We're giving the packet to TL so consider it transmitted from // a statistics perspective. We account for it here instead of // when the packet is returned for two reasons. First, TL will // manipulate the skb to the point where the len field is not // accurate, leading to inaccurate byte counts if we account for // it later. Second, TL does not provide any feedback as to // whether or not the packet was successfully sent over the air, // so the packet counts will be the same regardless of where we // account for them pAdapter->stats.tx_bytes += skb->len; ++pAdapter->stats.tx_packets; ++pAdapter->hdd_stats.hddTxRxStats.txFetchDequeued; ++pAdapter->hdd_stats.hddTxRxStats.txFetchDequeuedAC[ac]; pAdapter->hdd_stats.hddTxRxStats.<API key> = 0; VOS_TRACE( <API key>, <API key>, "%s: Valid VOS PKT returned to TL", __func__); return status; } VOS_STATUS <API key>( vos_pkt_t *pVosPacket, v_VOID_t *userData ) { VOS_STATUS status; v_SINT_t i = 0; v_SIZE_t size = 0; hdd_adapter_t* pAdapter = (hdd_adapter_t *)userData; v_U8_t STAId = WLAN_MAX_STA_COUNT; if(pAdapter == NULL) { VOS_TRACE( <API key>, <API key>, "%s: HDD adapter context is Null", __func__); return <API key>; } //Return the packet to VOS. We just needed to know that VOS is out of low resource //situation. Here we will only signal TL that there is a pending data for a STA. //VOS packet will be requested (if needed) when TL comes back to fetch data. <API key>( pVosPacket ); pAdapter->isVosOutOfResource = VOS_FALSE; // Indicate to TL that there is pending data if a queue is non empty. // This Code wasnt included in earlier version which resulted in // Traffic stalling for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) { if ((pAdapter->aStaInfo[STAId].tlSTAState == <API key>) || (pAdapter->aStaInfo[STAId].tlSTAState == <API key>)) { for( i=NUM_TX_QUEUES-1; i>=0; --i ) { size = 0; hdd_list_size(&pAdapter->aStaInfo[STAId].wmm_tx_queue[i], &size); if ( size > 0 ) { status = <API key>( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, STAId, (WLANTL_ACEnumType)i ); if( !<API key>( status ) ) { VOS_TRACE( <API key>, <API key>, "%s: Failure in indicating pkt to TL for ac=%d", __func__,i); } } } } } return VOS_STATUS_SUCCESS; } VOS_STATUS <API key>( v_VOID_t *vosContext, vos_pkt_t *pVosPacketChain, v_U8_t staId, <API key>* pRxMetaInfo ) { hdd_adapter_t *pAdapter = NULL; VOS_STATUS status = <API key>; int rxstat; struct sk_buff *skb = NULL; vos_pkt_t* pVosPacket; vos_pkt_t* pNextVosPacket; hdd_context_t *pHddCtx = NULL; v_U8_t proto_type; //Sanity check on inputs if ( ( NULL == vosContext ) || ( NULL == pVosPacketChain ) || ( NULL == pRxMetaInfo ) ) { VOS_TRACE( <API key>, <API key>, "%s: Null params being passed", __func__); return <API key>; } pHddCtx = (hdd_context_t *)vos_get_context( VOS_MODULE_ID_HDD, vosContext ); if ( NULL == pHddCtx ) { VOS_TRACE( <API key>, <API key>, "%s: HDD adapter context is Null", __func__); return <API key>; } pAdapter = pHddCtx->sta_to_adapter[staId]; if( NULL == pAdapter ) { VOS_ASSERT(0); return <API key>; } /* Monitor traffic */ if ( pHddCtx->cfg_ini-><API key> ) { pHddCtx->traffic_monitor.lastFrameTs = <API key>(); if ( !atomic_read(&pHddCtx->traffic_monitor.isActiveMode) ) { vos_lock_acquire(&pHddCtx->traffic_monitor.trafficLock); /* It was IDLE mode, * this is new state, then switch mode from suspend to resume */ if ( !atomic_read(&pHddCtx->traffic_monitor.isActiveMode) ) { <API key>(0); vos_timer_start(&pHddCtx->traffic_monitor.trafficTimer, pHddCtx->cfg_ini->trafficIdleTimeout); atomic_set(&pHddCtx->traffic_monitor.isActiveMode, 1); } vos_lock_release(&pHddCtx->traffic_monitor.trafficLock); } } ++pAdapter->hdd_stats.hddTxRxStats.rxChains; // walk the chain until all are processed pVosPacket = pVosPacketChain; do { // get the pointer to the next packet in the chain // (but don't unlink the packet since we free the entire chain later) status = <API key>( pVosPacket, &pNextVosPacket, VOS_FALSE); // both "success" and "empty" are acceptable results if (!((status == VOS_STATUS_SUCCESS) || (status == VOS_STATUS_E_EMPTY))) { ++pAdapter->hdd_stats.hddTxRxStats.rxDropped; VOS_TRACE( <API key>, <API key>, "%s: Failure walking packet chain", __func__); return <API key>; } // Extract the OS packet (skb). // Tell VOS to detach the OS packet from the VOS packet status = <API key>( pVosPacket, (v_VOID_t **)&skb, VOS_TRUE ); if(!<API key>( status )) { ++pAdapter->hdd_stats.hddTxRxStats.rxDropped; VOS_TRACE( <API key>, <API key>, "%s: Failure extracting skb from vos pkt", __func__); return <API key>; } //<API key>(skb); skb->dev = pAdapter->dev; if(skb->dev == NULL) { VOS_TRACE( <API key>, <API key>, "ERROR!!Invalid netdevice"); return <API key>; } ++pAdapter->hdd_stats.hddTxRxStats.rxPackets; ++pAdapter->stats.rx_packets; pAdapter->stats.rx_bytes += skb->len; if (pHddCtx->cfg_ini->gEnableDebugLog) { proto_type = <API key>(skb, pHddCtx->cfg_ini->gEnableDebugLog); if (<API key> & proto_type) { VOS_TRACE(VOS_MODULE_ID_HDD, <API key>, "SAP RX EAPOL"); } else if (<API key> & proto_type) { VOS_TRACE(VOS_MODULE_ID_HDD, <API key>, "SAP RX DHCP"); } } if (WLAN_RX_BCMC_STA_ID == pRxMetaInfo->ucDesSTAId) { //MC/BC packets. Duplicate a copy of packet struct sk_buff *pSkbCopy; hdd_ap_ctx_t *pHddApCtx; pHddApCtx = <API key>(pAdapter); if (!(pHddApCtx-><API key>)) { pSkbCopy = skb_copy(skb, GFP_ATOMIC); if (pSkbCopy) { <API key>(pSkbCopy, pSkbCopy->dev, pHddApCtx->uBCStaId, (pRxMetaInfo->ucUP)); } } else { VOS_TRACE(<API key>, <API key>, "%s: skb allocation fails", __func__); } } //(WLAN_RX_BCMC_STA_ID == staId) if ((WLAN_RX_BCMC_STA_ID == pRxMetaInfo->ucDesSTAId) || (<API key> == pRxMetaInfo->ucDesSTAId)) { VOS_TRACE( <API key>, <API key>, "%s: send one packet to kernel", __func__); skb->protocol = eth_type_trans(skb, skb->dev); skb->ip_summed = CHECKSUM_NONE; #ifdef WLAN_OPEN_SOURCE #ifdef <API key> wake_lock_timeout(&pHddCtx->rx_wake_lock, msecs_to_jiffies(<API key>)); #endif #endif rxstat = netif_rx_ni(skb); if (NET_RX_SUCCESS == rxstat) { ++pAdapter->hdd_stats.hddTxRxStats.rxDelivered; ++pAdapter->hdd_stats.hddTxRxStats.pkt_rx_count; } else { ++pAdapter->hdd_stats.hddTxRxStats.rxRefused; } } else if ((<API key>(pAdapter))-><API key>) { kfree_skb(skb); } else { //loopback traffic status = <API key>(skb, skb->dev, pRxMetaInfo->ucDesSTAId, (pRxMetaInfo->ucUP)); } // now process the next packet in the chain pVosPacket = pNextVosPacket; } while (pVosPacket); //Return the entire VOS packet chain to the resource pool status = <API key>( pVosPacketChain ); if(!<API key>( status )) { VOS_TRACE( <API key>, <API key>, "%s: Failure returning vos pkt", __func__); } pAdapter->dev->last_rx = jiffies; return status; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter, tANI_U8 staId ) { VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; hdd_context_t *pHddCtx; if (NULL == pAdapter) { VOS_TRACE(<API key>, <API key>, "%s: pAdapter is NULL", __func__); return VOS_STATUS_E_INVAL; } if (<API key> != pAdapter->magic) { VOS_TRACE(<API key>, <API key>, "%s: Invalid pAdapter magic", __func__); return VOS_STATUS_E_INVAL; } pHddCtx = (hdd_context_t*)(pAdapter->pHddCtx); //Clear station in TL and then update HDD data structures. This helps //to block RX frames from other station to this station. vosStatus = <API key>( pHddCtx->pvosContext, staId ); if ( !<API key>( vosStatus ) ) { VOS_TRACE( <API key>, <API key>, "<API key>() failed to for staID %d. " "Status= %d [0x%08lX]", staId, vosStatus, vosStatus ); } vosStatus = <API key> ( pAdapter, staId ); if( <API key> == vosStatus ) { VOS_TRACE ( <API key>, <API key>, "<API key>() failed for staID %d. " "Status = %d [0x%08lX]", staId, vosStatus, vosStatus ); return( vosStatus ); } pHddCtx->sta_to_adapter[staId] = NULL; return( vosStatus ); } VOS_STATUS <API key>( hdd_adapter_t *pAdapter, v_BOOL_t fAuthRequired, v_BOOL_t fPrivacyBit, v_U8_t staId, v_U8_t ucastSig, v_U8_t bcastSig, v_MACADDR_t *pPeerMacAddress, v_BOOL_t fWmmEnabled ) { VOS_STATUS vosStatus = <API key>; WLAN_STADescType staDesc = {0}; hdd_context_t *pHddCtx = pAdapter->pHddCtx; hdd_adapter_t *pmonAdapter = NULL; //eCsrEncryptionType connectedCipherAlgo; //v_BOOL_t fConnected; /* * Clean up old entry if it is not cleaned up properly */ if ( pAdapter->aStaInfo[staId].isUsed ) { VOS_TRACE( <API key>, <API key>, "clean up old entry for STA %d", staId); <API key>( pAdapter, staId ); } // Get the Station ID from the one saved during the assocation. staDesc.ucSTAId = staId; /*Save the pAdapter Pointer for this staId*/ pHddCtx->sta_to_adapter[staId] = pAdapter; staDesc.wSTAType = WLAN_STA_SOFTAP; vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) ); vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, &pAdapter->macAddressCurrent,6 ); vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent ); VOS_TRACE( <API key>, <API key>, "register station"); VOS_TRACE( <API key>, <API key>, "station mac " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(staDesc.vSTAMACAddress.bytes)); VOS_TRACE( <API key>, <API key>, "BSSIDforIBSS " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(staDesc.vBSSIDforIBSS.bytes)); VOS_TRACE( <API key>, <API key>, "SOFTAP SELFMAC " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(staDesc.vSelfMACAddress.bytes)); vosStatus = <API key>(pAdapter, staId, &staDesc.vSTAMACAddress); staDesc.ucQosEnabled = fWmmEnabled; VOS_TRACE( <API key>, <API key>, "HDD SOFTAP register TL QoS_enabled=%d", staDesc.ucQosEnabled ); staDesc.ucProtectedFrame = (v_U8_t)fPrivacyBit ; // For PRIMA UMA frame translation is not enable yet. staDesc.ucSwFrameTXXlation = 1; staDesc.ucSwFrameRXXlation = 1; staDesc.ucAddRmvLLC = 1; // Initialize signatures and state staDesc.ucUcastSig = ucastSig; staDesc.ucBcastSig = bcastSig; staDesc.ucInitState = fAuthRequired ? <API key> : <API key>; staDesc.<API key> = VOS_FALSE; // Register the Station with TL... vosStatus = <API key>( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, <API key>, <API key>, <API key>, &staDesc, 0 ); if ( !<API key>( vosStatus ) ) { VOS_TRACE( <API key>, <API key>, "SOFTAP <API key>() failed to register. Status= %d [0x%08X]", vosStatus, vosStatus ); return vosStatus; } //Timer value should be in milliseconds if ( pHddCtx->cfg_ini->dynSplitscan && ( <API key> != <API key>(&pHddCtx->tx_rx_trafficTmr))) { vos_timer_start(&pHddCtx->tx_rx_trafficTmr, pHddCtx->cfg_ini-><API key>); } // if ( WPA ), tell TL to go to 'connected' and after keys come to the driver, // then go to 'authenticated'. For all other authentication types (those that do // not require upper layer authentication) we can put TL directly into 'authenticated' // state. //VOS_ASSERT( fConnected ); pAdapter->aStaInfo[staId].ucSTAId = staId; pAdapter->aStaInfo[staId].isQosEnabled = fWmmEnabled; if ( !fAuthRequired ) { VOS_TRACE( <API key>, <API key>, "open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", pAdapter->aStaInfo[staId].ucSTAId ); // Connections that do not need Upper layer auth, transition TL directly // to 'Authenticated' state. vosStatus = <API key>( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId, <API key> ); pAdapter->aStaInfo[staId].tlSTAState = <API key>; pAdapter->sessionCtx.ap.uIsAuthenticated = VOS_TRUE; } else { VOS_TRACE( <API key>, <API key>, "ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", pAdapter->aStaInfo[staId].ucSTAId ); vosStatus = <API key>( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId, <API key> ); pAdapter->aStaInfo[staId].tlSTAState = <API key>; pAdapter->sessionCtx.ap.uIsAuthenticated = VOS_FALSE; } pmonAdapter= hdd_get_mon_adapter( pAdapter->pHddCtx); if(pmonAdapter) { VOS_TRACE( <API key>, <API key>, "Turn on Monitor the carrier"); netif_carrier_on(pmonAdapter->dev); //Enable Tx queue <API key>(pmonAdapter->dev); } netif_carrier_on(pAdapter->dev); //Enable Tx queue <API key>(pAdapter->dev); return( vosStatus ); } VOS_STATUS <API key>( hdd_adapter_t *pAdapter, v_BOOL_t fPrivacyBit) { VOS_STATUS vosStatus = <API key>; hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); v_MACADDR_t broadcastMacAddr = <API key>; pHddCtx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = pAdapter; pHddCtx->sta_to_adapter[<API key>] = pAdapter; vosStatus = <API key>( pAdapter, VOS_FALSE, fPrivacyBit, (<API key>(pAdapter))->uBCStaId, 0, 1, &broadcastMacAddr,0); return vosStatus; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter) { return <API key>( pAdapter, (<API key>(pAdapter))->uBCStaId); } VOS_STATUS hdd_softap_stop_bss( hdd_adapter_t *pAdapter) { hdd_context_t *pHddCtx; VOS_STATUS vosStatus = <API key>; v_U8_t staId = 0; pHddCtx = WLAN_HDD_GET_CTX(pAdapter); /*bss deregister is not allowed during wlan driver loading or unloading*/ if (<API key>(pHddCtx)) { VOS_TRACE(VOS_MODULE_ID_HDD, <API key>, "%s:Loading_unloading in Progress. Ignore!!!",__func__); return VOS_STATUS_E_PERM; } vosStatus = <API key>( pAdapter); if (!<API key>(vosStatus)) { VOS_TRACE( <API key>, <API key>, "%s: Failed to deregister BC sta Id %d", __func__, (<API key>(pAdapter))->uBCStaId); } for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) { if (pAdapter->aStaInfo[staId].isUsed)// This excludes BC sta as it is already deregistered { vosStatus = <API key>( pAdapter, staId); if (!<API key>(vosStatus)) { VOS_TRACE( <API key>, <API key>, "%s: Failed to deregister sta Id %d", __func__, staId); } } } return vosStatus; } VOS_STATUS <API key>( hdd_adapter_t *pAdapter, v_MACADDR_t *pDestMacAddress, WLANTL_STAStateType state) { v_U8_t ucSTAId = WLAN_MAX_STA_COUNT; VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS; v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; VOS_TRACE( <API key>, <API key>, "%s: enter", __func__); if (VOS_STATUS_SUCCESS != hdd_softap_GetStaId(pAdapter, pDestMacAddress, &ucSTAId)) { VOS_TRACE( <API key>, <API key>, "%s: Failed to find right station", __func__); return <API key>; } if (FALSE == <API key>(&pAdapter->aStaInfo[ucSTAId].macAddrSTA, pDestMacAddress)) { VOS_TRACE( <API key>, <API key>, "%s: Station MAC address does not matching", __func__); return <API key>; } vosStatus = <API key>( pVosContext, ucSTAId, state ); VOS_TRACE( <API key>, <API key>, "%s: change station to state %d succeed", __func__, state); if (VOS_STATUS_SUCCESS == vosStatus) { pAdapter->aStaInfo[ucSTAId].tlSTAState = <API key>; } VOS_TRACE(<API key>, <API key>, "%s exit",__func__); return vosStatus; } VOS_STATUS hdd_softap_GetStaId(hdd_adapter_t *pAdapter, v_MACADDR_t *pMacAddress, v_U8_t *staId) { v_U8_t i; for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { if (vos_mem_compare(&pAdapter->aStaInfo[i].macAddrSTA, pMacAddress, sizeof(v_MACADDR_t)) && pAdapter->aStaInfo[i].isUsed) { *staId = i; return VOS_STATUS_SUCCESS; } } return <API key>; } VOS_STATUS <API key>(hdd_adapter_t *pAdapter, v_U8_t *staId) { v_U8_t i; for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { if (pAdapter->aStaInfo[i].isUsed && (!<API key>(&pAdapter->aStaInfo[i].macAddrSTA))) { *staId = i; return VOS_STATUS_SUCCESS; } } return <API key>; }
#include "ixgbe.h" #include "ixgbe_type.h" #include "ixgbe_dcb.h" #include "ixgbe_dcb_82598.h" /** * <API key> - Config Rx data arbiter * @hw: pointer to hardware structure * @refill: refill credits index by traffic class * @max: max credits index by traffic class * @prio_type: priority type indexed by traffic class * * Configure Rx Data Arbiter and credits for each traffic class. */ s32 <API key>(struct ixgbe_hw *hw, u16 *refill, u16 *max, u8 *prio_type) { u32 reg = 0; u32 credit_refill = 0; u32 credit_max = 0; u8 i = 0; reg = IXGBE_READ_REG(hw, IXGBE_RUPPBMR) | IXGBE_RUPPBMR_MQA; IXGBE_WRITE_REG(hw, IXGBE_RUPPBMR, reg); reg = IXGBE_READ_REG(hw, IXGBE_RMCS); /* Enable Arbiter */ reg &= ~IXGBE_RMCS_ARBDIS; /* Enable Receive Recycle within the BWG */ reg |= IXGBE_RMCS_RRM; /* Enable Deficit Fixed Priority arbitration*/ reg |= IXGBE_RMCS_DFP; IXGBE_WRITE_REG(hw, IXGBE_RMCS, reg); /* Configure traffic class credits and priority */ for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { credit_refill = refill[i]; credit_max = max[i]; reg = credit_refill | (credit_max << <API key>); if (prio_type[i] == prio_link) reg |= IXGBE_RT2CR_LSP; IXGBE_WRITE_REG(hw, IXGBE_RT2CR(i), reg); } reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL); reg |= <API key>; reg |= IXGBE_RDRXCTL_MPBEN; reg |= IXGBE_RDRXCTL_MCEN; IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg); reg = IXGBE_READ_REG(hw, IXGBE_RXCTRL); /* Make sure there is enough descriptors before arbitration */ reg &= ~IXGBE_RXCTRL_DMBYPS; IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, reg); return 0; } /** * <API key> - Config Tx Desc. arbiter * @hw: pointer to hardware structure * @refill: refill credits index by traffic class * @max: max credits index by traffic class * @bwg_id: bandwidth grouping indexed by traffic class * @prio_type: priority type indexed by traffic class * * Configure Tx Descriptor Arbiter and credits for each traffic class. */ s32 <API key>(struct ixgbe_hw *hw, u16 *refill, u16 *max, u8 *bwg_id, u8 *prio_type) { u32 reg, max_credits; u8 i; reg = IXGBE_READ_REG(hw, IXGBE_DPMCS); /* Enable arbiter */ reg &= ~IXGBE_DPMCS_ARBDIS; reg |= IXGBE_DPMCS_TSOEF; /* Configure Max TSO packet size 34KB including payload and headers */ reg |= (0x4 << <API key>); IXGBE_WRITE_REG(hw, IXGBE_DPMCS, reg); /* Configure traffic class credits and priority */ for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { max_credits = max[i]; reg = max_credits << <API key>; reg |= refill[i]; reg |= (u32)(bwg_id[i]) << <API key>; if (prio_type[i] == prio_group) reg |= IXGBE_TDTQ2TCCR_GSP; if (prio_type[i] == prio_link) reg |= IXGBE_TDTQ2TCCR_LSP; IXGBE_WRITE_REG(hw, IXGBE_TDTQ2TCCR(i), reg); } return 0; } /** * <API key> - Config Tx data arbiter * @hw: pointer to hardware structure * @refill: refill credits index by traffic class * @max: max credits index by traffic class * @bwg_id: bandwidth grouping indexed by traffic class * @prio_type: priority type indexed by traffic class * * Configure Tx Data Arbiter and credits for each traffic class. */ s32 <API key>(struct ixgbe_hw *hw, u16 *refill, u16 *max, u8 *bwg_id, u8 *prio_type) { u32 reg; u8 i; reg = IXGBE_READ_REG(hw, IXGBE_PDPMCS); /* Enable Data Plane Arbiter */ reg &= ~IXGBE_PDPMCS_ARBDIS; /* Enable DFP and Transmit Recycle Mode */ reg |= (IXGBE_PDPMCS_TPPAC | IXGBE_PDPMCS_TRM); IXGBE_WRITE_REG(hw, IXGBE_PDPMCS, reg); /* Configure traffic class credits and priority */ for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { reg = refill[i]; reg |= (u32)(max[i]) << <API key>; reg |= (u32)(bwg_id[i]) << <API key>; if (prio_type[i] == prio_group) reg |= IXGBE_TDPT2TCCR_GSP; if (prio_type[i] == prio_link) reg |= IXGBE_TDPT2TCCR_LSP; IXGBE_WRITE_REG(hw, IXGBE_TDPT2TCCR(i), reg); } /* Enable Tx packet buffer division */ reg = IXGBE_READ_REG(hw, IXGBE_DTXCTL); reg |= <API key>; IXGBE_WRITE_REG(hw, IXGBE_DTXCTL, reg); return 0; } /** * <API key> - Config priority flow control * @hw: pointer to hardware structure * @pfc_en: enabled pfc bitmask * * Configure Priority Flow Control for each traffic class. */ s32 <API key>(struct ixgbe_hw *hw, u8 pfc_en) { u32 fcrtl, reg; u8 i; /* Enable Transmit Priority Flow Control */ reg = IXGBE_READ_REG(hw, IXGBE_RMCS); reg &= ~<API key>; reg |= <API key>; IXGBE_WRITE_REG(hw, IXGBE_RMCS, reg); /* Enable Receive Priority Flow Control */ reg = IXGBE_READ_REG(hw, IXGBE_FCTRL); reg &= ~(IXGBE_FCTRL_RPFCE | IXGBE_FCTRL_RFCE); if (pfc_en) reg |= IXGBE_FCTRL_RPFCE; IXGBE_WRITE_REG(hw, IXGBE_FCTRL, reg); /* Configure PFC Tx thresholds per TC */ for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { if (!(pfc_en & BIT(i))) { IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), 0); IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), 0); continue; } fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE; reg = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN; IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl); IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), reg); } /* Configure pause time */ reg = hw->fc.pause_time * 0x00010001; for (i = 0; i < (MAX_TRAFFIC_CLASS / 2); i++) IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg); /* Configure flow control refresh threshold value */ IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2); return 0; } /** * <API key> - Configure traffic class statistics * @hw: pointer to hardware structure * * Configure queue statistics registers, all queues belonging to same traffic * class uses a single set of queue statistics counters. */ static s32 <API key>(struct ixgbe_hw *hw) { u32 reg = 0; u8 i = 0; u8 j = 0; /* Receive Queues stats setting - 8 queues per statistics reg */ for (i = 0, j = 0; i < 15 && j < 8; i = i + 2, j++) { reg = IXGBE_READ_REG(hw, IXGBE_RQSMR(i)); reg |= ((0x1010101) * j); IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), reg); reg = IXGBE_READ_REG(hw, IXGBE_RQSMR(i + 1)); reg |= ((0x1010101) * j); IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i + 1), reg); } /* Transmit Queues stats setting - 4 queues per statistics reg */ for (i = 0; i < 8; i++) { reg = IXGBE_READ_REG(hw, IXGBE_TQSMR(i)); reg |= ((0x1010101) * i); IXGBE_WRITE_REG(hw, IXGBE_TQSMR(i), reg); } return 0; } /** * <API key> - Config and enable DCB * @hw: pointer to hardware structure * @pfc_en: enabled pfc bitmask * @refill: refill credits index by traffic class * @max: max credits index by traffic class * @bwg_id: bandwidth grouping indexed by traffic class * @prio_type: priority type indexed by traffic class * * Configure dcb settings and enable dcb mode. */ s32 <API key>(struct ixgbe_hw *hw, u8 pfc_en, u16 *refill, u16 *max, u8 *bwg_id, u8 *prio_type) { <API key>(hw, refill, max, prio_type); <API key>(hw, refill, max, bwg_id, prio_type); <API key>(hw, refill, max, bwg_id, prio_type); <API key>(hw, pfc_en); <API key>(hw); return 0; }
! { dg-do compile } ! Test the fix for PR32157, in which overloading 'LEN', as ! in 'test' below would cause a compile error. ! ! Contributed by Michael Richmond <michael.a.richmond@nasa.gov> ! subroutine len(c) implicit none character :: c c = "X" end subroutine len subroutine test() implicit none character :: str external len call len(str) if(str /= "X") STOP 1 end subroutine test PROGRAM VAL implicit none external test intrinsic len call test() if(len(" ") /= 1) STOP 2 END
package autotest.afe; import java.util.ArrayList; import java.util.List; public class CheckBoxPanel { public static interface Display { public ICheckBox generateCheckBox(int index); } private List<ICheckBox> checkBoxes = new ArrayList<ICheckBox>(); private Display display; public void bindDisplay(Display display) { this.display = display; } public ICheckBox generateCheckBox() { return display.generateCheckBox(checkBoxes.size()); } public void add(ICheckBox checkBox) { checkBoxes.add(checkBox); } public List<ICheckBox> getChecked() { List<ICheckBox> result = new ArrayList<ICheckBox>(); for(ICheckBox checkBox : checkBoxes) { if (checkBox.getValue()) { result.add(checkBox); } } return result; } public void setEnabled(boolean enabled) { for(ICheckBox thisBox : checkBoxes) { thisBox.setEnabled(enabled); } } public void reset() { for (ICheckBox thisBox : checkBoxes) { thisBox.setValue(false); } } }
/*! \file * \brief Asterisk datastore objects */ #ifndef <API key> #define <API key> #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/linkedlists.h" /*! \brief Structure for a data store type */ struct ast_datastore_info { const char *type; /*!< Type of data store */ void *(*duplicate)(void *data); /*!< Duplicate item data (used for inheritance) */ void (*destroy)(void *data); /*!< Destroy function */ /*! * \brief Fix up channel references * * \arg data The datastore data * \arg old_chan The old channel owning the datastore * \arg new_chan The new channel owning the datastore * * This is exactly like the fixup callback of the channel technology interface. * It allows a datastore to fix any pointers it saved to the owning channel * in case that the owning channel has changed. Generally, this would happen * when the datastore is set to be inherited, and a masquerade occurs. * * \return nothing. */ void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan); }; /*! \brief Structure for a data store object */ struct ast_datastore { const char *uid; /*!< Unique data store identifier */ void *data; /*!< Contained data */ const struct ast_datastore_info *info; /*!< Data store type information */ unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */ AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */ }; /*! * \brief Create a data store object * \param[in] info information describing the data store object * \param[in] uid unique identifer * \version 1.6.1 moved here and renamed from <API key> */ struct ast_datastore * attribute_malloc <API key>(const struct ast_datastore_info *info, const char *uid, const char *file, int line, const char *function); #define ast_datastore_alloc(info, uid) <API key>(info, uid, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief Free a data store object * \param[in] datastore datastore to free * \version 1.6.1 moved here and renamed from <API key> */ int ast_datastore_free(struct ast_datastore *datastore); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* <API key> */
package autotest.tko; import autotest.common.Utils; public abstract class LabelField extends ParameterizedField { @Override public String getSqlCondition(String value) { String condition = " IS NOT NULL"; if (value.equals(Utils.JSON_NULL)) { condition = " IS NULL"; } return getFilteringName() + condition; } @Override public String getFilteringName() { return getQuotedSqlName() + ".id"; } }
/* This file contains support code for C++ demangling that is common to a styles of demangling, and GDB specific. */ #include "defs.h" #include "command.h" #include "gdbcmd.h" #include "demangle.h" #include "gdb-demangle.h" #include "gdb_string.h" /* Select the default C++ demangling style to use. The default is "auto", which allows gdb to attempt to pick an appropriate demangling style for the executable it has loaded. It can be set to a specific style ("gnu", "lucid", "arm", "hp", etc.) in which case gdb will never attempt to do auto selection of the style unless you do an explicit "set demangle auto". To select one of these as the default, set <API key> in the appropriate target configuration file. */ #ifndef <API key> #define <API key> <API key> #endif /* See documentation in gdb-demangle.h. */ int demangle = 1; static void show_demangle (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { fprintf_filtered (file, _("Demangling of encoded C++/ObjC names " "when displaying symbols is %s.\n"), value); } /* See documentation in gdb-demangle.h. */ int asm_demangle = 0; static void show_asm_demangle (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { fprintf_filtered (file, _("Demangling of C++/ObjC names in " "disassembly listings is %s.\n"), value); } /* String name for the current demangling style. Set by the "set demangle-style" command, printed as part of the output by the "show demangle-style" command. */ static const char *<API key>; /* The array of names of the known demanglyng styles. Generated by <API key> from <API key>[] array. */ static const char **<API key>; static void <API key>(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { fprintf_filtered (file, _("The current C++ demangling style is \"%s\".\n"), value); } /* Set current demangling style. Called by the "set demangle-style" command after it has updated the <API key> to match what the user has entered. If the user has entered a string that matches a known demangling style name in the demanglers[] array then just leave the string alone and update the <API key> enum value to match. If the user has entered a string that doesn't match, including an empty string, then print a list of the currently known styles and restore the <API key> to match the <API key> enum value. Note: Assumes that <API key> always points to a malloc'd string, even if it is a null-string. */ static void <API key> (char *ignore, int from_tty, struct cmd_list_element *c) { const struct demangler_engine *dem; int i; /* First just try to match whatever style name the user supplied with one of the known ones. Don't bother special casing for an empty name, we just treat it as any other style name that doesn't match. If we match, update the current demangling style enum. */ for (dem = <API key>, i = 0; dem->demangling_style != unknown_demangling; dem++) { if (strcmp (<API key>, dem-><API key>) == 0) { <API key> = dem->demangling_style; <API key> = <API key>[i]; break; } i++; } /* We should have found a match, given we only add known styles to the enumeration list. */ gdb_assert (dem->demangling_style != unknown_demangling); } /* G++ uses a special character to indicate certain internal names. Which character it is depends on the platform: - Usually '$' on systems where the assembler will accept that - Usually '.' otherwise (this includes most sysv4-like systems and most ELF targets) - Occasionally '_' if neither of the above is usable We check '$' first because it is the safest, and '.' often has another meaning. We don't currently try to handle '_' because the precise forms of the names are different on those targets. */ static char cplus_markers[] = {'$', '.', '\0'}; /* See documentation in gdb-demangle.h. */ int is_cplus_marker (int c) { return c && strchr (cplus_markers, c) != NULL; } extern <API key> <API key>; /* -Wmissing-prototypes */ void <API key> (void) { int i, ndems; /* Fill the <API key>[] array, and set the default demangling style chosen at compilation time. */ for (ndems = 0; <API key>[ndems].demangling_style != unknown_demangling; ndems++) ; <API key> = xcalloc (ndems + 1, sizeof (char *)); for (i = 0; <API key>[i].demangling_style != unknown_demangling; i++) { <API key>[i] = xstrdup (<API key>[i].<API key>); if (<API key> == NULL && strcmp (<API key>, <API key>[i]) == 0) <API key> = <API key>[i]; } <API key> ("demangle", class_support, &demangle, _("\ Set demangling of encoded C++/ObjC names when displaying symbols."), _("\ Show demangling of encoded C++/ObjC names when displaying symbols."), NULL, NULL, show_demangle, &setprintlist, &showprintlist); <API key> ("asm-demangle", class_support, &asm_demangle, _("\ Set demangling of C++/ObjC names in disassembly listings."), _("\ Show demangling of C++/ObjC names in disassembly listings."), NULL, NULL, show_asm_demangle, &setprintlist, &showprintlist); <API key> ("demangle-style", class_support, <API key>, &<API key>, _("\ Set the current C++ demangling style."), _("\ Show the current C++ demangling style."), _("\ Use `set demangle-style' without arguments for a list of demangling styles."), <API key>, <API key>, &setlist, &showlist); }
DELETE FROM <API key> WHERE entry=1966; INSERT INTO <API key> VALUES (1966,'at_murkdeep');
tinymce.PluginManager.add("insertdatetime", function (e) { function t(t, n) { function i(e, t) { if (e = "" + e, e.length < t)for (var n = 0; n < t - e.length; n++)e = "0" + e; return e } return n = n || new Date, t = t.replace("%D", "%m/%d/%Y"), t = t.replace("%r", "%I:%M:%S %p"), t = t.replace("%Y", "" + n.getFullYear()), t = t.replace("%y", "" + n.getYear()), t = t.replace("%m", i(n.getMonth() + 1, 2)), t = t.replace("%d", i(n.getDate(), 2)), t = t.replace("%H", "" + i(n.getHours(), 2)), t = t.replace("%M", "" + i(n.getMinutes(), 2)), t = t.replace("%S", "" + i(n.getSeconds(), 2)), t = t.replace("%I", "" + ((n.getHours() + 11) % 12 + 1)), t = t.replace("%p", "" + (n.getHours() < 12 ? "AM" : "PM")), t = t.replace("%B", "" + e.translate(s[n.getMonth()])), t = t.replace("%b", "" + e.translate(o[n.getMonth()])), t = t.replace("%A", "" + e.translate(r[n.getDay()])), t = t.replace("%a", "" + e.translate(a[n.getDay()])), t = t.replace("%%", "%") } function n(n) { var i = t(n); if (e.settings.<API key>) { var a; a = /%[HMSIp]/.test(n) ? t("%Y-%m-%dT%H:%M") : t("%Y-%m-%d"), i = '<time datetime="' + a + '">' + i + "</time>"; var r = e.dom.getParent(e.selection.getStart(), "time"); if (r)return e.dom.setOuterHTML(r, i), void 0 } e.insertContent(i) } var i, a = "Sun Mon Tue Wed Thu Fri Sat Sun".split(" "), r = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "), o = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "), s = "January February March April May June July August September October November December".split(" "), l = []; e.addCommand("mceInsertDate", function () { n(e.getParam("<API key>", e.translate("%Y-%m-%d"))) }), e.addCommand("mceInsertTime", function () { n(e.getParam("<API key>", e.translate("%H:%M:%S"))) }), e.addButton("inserttime", { type: "splitbutton", title: "Insert time", onclick: function () { n(i || "%H:%M:%S") }, menu: l }), tinymce.each(e.settings.<API key> || ["%H:%M:%S", "%Y-%m-%d", "%I:%M:%S %p", "%D"], function (e) { l.push({ text: t(e), onclick: function () { i = e, n(e) } }) }), e.addMenuItem("insertdatetime", {icon: "date", text: "Insert date/time", menu: l, context: "insert"}) });
#ifndef BNX2X_CMN_H #define BNX2X_CMN_H #include <linux/types.h> #include <linux/pci.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include "bnx2x.h" #include "bnx2x_sriov.h" /* This is used as a replacement for an MCP if it's not present */ extern int load_count[2][3]; /* per-path: 0-common, 1-port0, 2-port1 */ extern int num_queues; extern int int_mode; #define BNX2X_PCI_FREE(x, y, size) \ do { \ if (x) { \ dma_free_coherent(&bp->pdev->dev, size, (void *)x, y); \ x = NULL; \ y = 0; \ } \ } while (0) #define BNX2X_FREE(x) \ do { \ if (x) { \ kfree((void *)x); \ x = NULL; \ } \ } while (0) #define BNX2X_PCI_ALLOC(x, y, size) \ do { \ x = dma_alloc_coherent(&bp->pdev->dev, size, y, \ GFP_KERNEL | __GFP_ZERO); \ if (x == NULL) \ goto alloc_mem_err; \ DP(NETIF_MSG_HW, "BNX2X_PCI_ALLOC: Physical %Lx Virtual %p\n", \ (unsigned long long)(*y), x); \ } while (0) #define BNX2X_PCI_FALLOC(x, y, size) \ do { \ x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \ if (x == NULL) \ goto alloc_mem_err; \ memset((void *)x, 0xFFFFFFFF, size); \ DP(NETIF_MSG_HW, "BNX2X_PCI_FALLOC: Physical %Lx Virtual %p\n",\ (unsigned long long)(*y), x); \ } while (0) #define BNX2X_ALLOC(x, size) \ do { \ x = kzalloc(size, GFP_KERNEL); \ if (x == NULL) \ goto alloc_mem_err; \ } while (0) /* Init */ /** * <API key> - request unload mode from the MCP. * * @bp: driver handle * @unload_mode: requested function's unload mode * * Return unload mode returned by the MCP: COMMON, PORT or FUNC. */ u32 <API key>(struct bnx2x *bp, int unload_mode); /** * <API key> - send UNLOAD_DONE command to the MCP. * * @bp: driver handle * @keep_link: true iff link should be kept up */ void <API key>(struct bnx2x *bp, bool keep_link); /** * bnx2x_config_rss_pf - configure RSS parameters in a PF. * * @bp: driver handle * @rss_obj: RSS object to use * @ind_table: indirection table to configure * @config_hash: re-configure RSS hash keys configuration */ int bnx2x_config_rss_pf(struct bnx2x *bp, struct <API key> *rss_obj, bool config_hash); /** * <API key> - init function object * * @bp: driver handle * * Initializes the Function Object with the appropriate * parameters which include a function slow path driver * interface. */ void <API key>(struct bnx2x *bp); /** * bnx2x_setup_queue - setup eth queue. * * @bp: driver handle * @fp: pointer to the fastpath structure * @leading: boolean * */ int bnx2x_setup_queue(struct bnx2x *bp, struct bnx2x_fastpath *fp, bool leading); /** * bnx2x_setup_leading - bring up a leading eth queue. * * @bp: driver handle */ int bnx2x_setup_leading(struct bnx2x *bp); /** * bnx2x_fw_command - send the MCP a request * * @bp: driver handle * @command: request * @param: request's parameter * * block until there is a reply */ u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param); /** * <API key> - initialize link parameters structure variables. * * @bp: driver handle * @load_mode: current mode */ int <API key>(struct bnx2x *bp, int load_mode); /** * bnx2x_link_set - configure hw according to link parameters structure. * * @bp: driver handle */ void bnx2x_link_set(struct bnx2x *bp); /** * <API key> - Forces link reset, and put the PHY * in reset as well. * * @bp: driver handle */ void <API key>(struct bnx2x *bp); /** * bnx2x_link_test - query link status. * * @bp: driver handle * @is_serdes: bool * * Returns 0 if link is UP. */ u8 bnx2x_link_test(struct bnx2x *bp, u8 is_serdes); /** * bnx2x_drv_pulse - write driver pulse to shmem * * @bp: driver handle * * writes the value in bp->fw_drv_pulse_wr_seq to drv_pulse mbox * in the shmem. */ void bnx2x_drv_pulse(struct bnx2x *bp); void bnx2x_igu_ack_sb(struct bnx2x *bp, u8 igu_sb_id, u8 segment, u16 index, u8 op, u8 update); /* Disable transactions from chip to host */ void bnx2x_pf_disable(struct bnx2x *bp); int bnx2x_pretend_func(struct bnx2x *bp, u16 pretend_func_val); /** * <API key> - handles link status change. * * @bp: driver handle */ void <API key>(struct bnx2x *bp); /** * bnx2x_link_report - report link status to upper layer. * * @bp: driver handle */ void bnx2x_link_report(struct bnx2x *bp); /* None-atomic version of bnx2x_link_report() */ void __bnx2x_link_report(struct bnx2x *bp); /** * bnx2x_get_mf_speed - calculate MF speed. * * @bp: driver handle * * Takes into account current linespeed and MF configuration. */ u16 bnx2x_get_mf_speed(struct bnx2x *bp); /** * bnx2x_msix_sp_int - MSI-X slowpath interrupt handler * * @irq: irq number * @dev_instance: private instance */ irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance); /** * bnx2x_interrupt - non MSI-X interrupt handler * * @irq: irq number * @dev_instance: private instance */ irqreturn_t bnx2x_interrupt(int irq, void *dev_instance); /** * bnx2x_cnic_notify - send command to cnic driver * * @bp: driver handle * @cmd: command */ int bnx2x_cnic_notify(struct bnx2x *bp, int cmd); /** * <API key> - provides cnic with IRQ information * * @bp: driver handle */ void <API key>(struct bnx2x *bp); /** * <API key> - provides cnic with updated info * * @bp: driver handle */ void <API key>(struct bnx2x *bp); /** * bnx2x_int_enable - enable HW interrupts. * * @bp: driver handle */ void bnx2x_int_enable(struct bnx2x *bp); /** * <API key> - disable interrupts. * * @bp: driver handle * @disable_hw: true, disable HW interrupts. * * This function ensures that there are no * ISRs or SP DPCs (sp_task) are running after it returns. */ void <API key>(struct bnx2x *bp, int disable_hw); /** * bnx2x_nic_init_cnic - init driver internals for cnic. * * @bp: driver handle * @load_code: COMMON, PORT or FUNCTION * * Initializes: * - rings * - status blocks * - etc. */ void bnx2x_nic_init_cnic(struct bnx2x *bp); /** * <API key> - init driver internals. * * @bp: driver handle * * Initializes: * - fastpath object * - fastpath rings * etc. */ void <API key>(struct bnx2x *bp); /** * <API key> - init driver internals. * * @bp: driver handle * @load_code: COMMON, PORT or FUNCTION * * Initializes: * - status blocks * - slowpath rings * - etc. */ void <API key>(struct bnx2x *bp, u32 load_code); /** * <API key> - allocate driver's memory for cnic. * * @bp: driver handle */ int <API key>(struct bnx2x *bp); /** * bnx2x_alloc_mem - allocate driver's memory. * * @bp: driver handle */ int bnx2x_alloc_mem(struct bnx2x *bp); /** * bnx2x_free_mem_cnic - release driver's memory for cnic. * * @bp: driver handle */ void bnx2x_free_mem_cnic(struct bnx2x *bp); /** * bnx2x_free_mem - release driver's memory. * * @bp: driver handle */ void bnx2x_free_mem(struct bnx2x *bp); /** * <API key> - set number of queues according to mode. * * @bp: driver handle */ void <API key>(struct bnx2x *bp); /** * bnx2x_chip_cleanup - cleanup chip internals. * * @bp: driver handle * @unload_mode: COMMON, PORT, FUNCTION * @keep_link: true iff link should be kept up. * * - Cleanup MAC configuration. * - Closes clients. * - etc. */ void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link); /** * <API key> - acquire HW lock. * * @bp: driver handle * @resource: resource bit which was locked */ int <API key>(struct bnx2x *bp, u32 resource); /** * <API key> - release HW lock. * * @bp: driver handle * @resource: resource bit which was locked */ int <API key>(struct bnx2x *bp, u32 resource); /** * <API key> - release recovery leader lock * * @bp: driver handle */ int <API key>(struct bnx2x *bp); /** * bnx2x_set_eth_mac - configure eth MAC address in the HW * * @bp: driver handle * @set: set or clear * * Configures according to the value in netdev->dev_addr. */ int bnx2x_set_eth_mac(struct bnx2x *bp, bool set); /** * bnx2x_set_rx_mode - set MAC filtering configurations. * * @dev: netdevice * * called with netif_tx_lock from dev_mcast.c * If bp->state is OPEN, should be called with * netif_addr_lock_bh() */ void bnx2x_set_rx_mode(struct net_device *dev); /** * <API key> - configure MAC filtering rules in a FW. * * @bp: driver handle * * If bp->state is OPEN, should be called with * netif_addr_lock_bh(). */ int <API key>(struct bnx2x *bp); /** * bnx2x_set_q_rx_mode - configures rx_mode for a single queue. * * @bp: driver handle * @cl_id: client id * @rx_mode_flags: rx mode configuration * @rx_accept_flags: rx accept configuration * @tx_accept_flags: tx accept configuration (tx switch) * @ramrod_flags: ramrod configuration */ int bnx2x_set_q_rx_mode(struct bnx2x *bp, u8 cl_id, unsigned long rx_mode_flags, unsigned long rx_accept_flags, unsigned long tx_accept_flags, unsigned long ramrod_flags); /* Parity errors related */ void bnx2x_set_pf_load(struct bnx2x *bp); bool bnx2x_clear_pf_load(struct bnx2x *bp); bool <API key>(struct bnx2x *bp, bool *global, bool print); bool bnx2x_reset_is_done(struct bnx2x *bp, int engine); void <API key>(struct bnx2x *bp); void <API key>(struct bnx2x *bp); void <API key>(struct bnx2x *bp); int <API key>(struct bnx2x *bp); /** * bnx2x_sp_event - handle ramrods completion. * * @fp: fastpath handle for the event * @rr_cqe: eth_rx_cqe */ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe); /** * bnx2x_ilt_set_info - prepare ILT configurations. * * @bp: driver handle */ void bnx2x_ilt_set_info(struct bnx2x *bp); /** * <API key> - prepare ILT configurations for SRC * and TM. * * @bp: driver handle */ void <API key>(struct bnx2x *bp); /** * bnx2x_dcbx_init - initialize dcbx protocol. * * @bp: driver handle */ void bnx2x_dcbx_init(struct bnx2x *bp, bool update_shmem); /** * <API key> - set power state to the requested value. * * @bp: driver handle * @state: required state D0 or D3hot * * Currently only D0 and D3hot are supported. */ int <API key>(struct bnx2x *bp, pci_power_t state); /** * <API key> - update MAX part of MF configuration in HW. * * @bp: driver handle * @value: new value */ void <API key>(struct bnx2x *bp, u32 value); /* Error handling */ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl); /* dev_close main block */ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link); /* dev_open main block */ int bnx2x_nic_load(struct bnx2x *bp, int load_mode); /* hard_xmit callback */ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev); int bnx2x_get_vf_config(struct net_device *dev, int vf, struct ifla_vf_info *ivi); int bnx2x_set_vf_mac(struct net_device *dev, int queue, u8 *mac); int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos); /* select_queue callback */ u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb); static inline void <API key>(struct bnx2x *bp, struct bnx2x_fastpath *fp, u16 bd_prod, u16 rx_comp_prod, u16 rx_sge_prod) { struct <API key> rx_prods = {0}; u32 i; /* Update producers */ rx_prods.bd_prod = bd_prod; rx_prods.cqe_prod = rx_comp_prod; rx_prods.sge_prod = rx_sge_prod; /* Make sure that the BD and SGE data is updated before updating the * producers since FW might read the BD/SGE right after the producer * is updated. * This is only applicable for weak-ordered memory model archs such * as IA-64. The following barrier is also mandatory since FW will * assumes BDs must have buffers. */ wmb(); for (i = 0; i < sizeof(rx_prods)/4; i++) REG_WR(bp, fp-><API key> + i*4, ((u32 *)&rx_prods)[i]); mmiowb(); /* keep prod updates ordered */ DP(NETIF_MSG_RX_STATUS, "queue[%d]: wrote bd_prod %u cqe_prod %u sge_prod %u\n", fp->index, bd_prod, rx_comp_prod, rx_sge_prod); } /* reload helper */ int <API key>(struct net_device *dev); int <API key>(struct net_device *dev, void *p); /* NAPI poll Rx part */ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget); /* NAPI poll Tx part */ int bnx2x_tx_int(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata); /* suspend/resume callbacks */ int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state); int bnx2x_resume(struct pci_dev *pdev); /* Release IRQ vectors */ void bnx2x_free_irq(struct bnx2x *bp); void <API key>(struct bnx2x *bp); void bnx2x_free_fp_mem(struct bnx2x *bp); int <API key>(struct bnx2x *bp); int bnx2x_alloc_fp_mem(struct bnx2x *bp); void bnx2x_init_rx_rings(struct bnx2x *bp); void <API key>(struct bnx2x *bp); void <API key>(struct bnx2x *bp); void bnx2x_free_skbs(struct bnx2x *bp); void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw); void bnx2x_netif_start(struct bnx2x *bp); int bnx2x_load_cnic(struct bnx2x *bp); /** * bnx2x_enable_msix - set msix configuration. * * @bp: driver handle * * fills msix_table, requests vectors, updates num_queues * according to number of available vectors. */ int bnx2x_enable_msix(struct bnx2x *bp); /** * bnx2x_enable_msi - request msi mode from OS, updated internals accordingly * * @bp: driver handle */ int bnx2x_enable_msi(struct bnx2x *bp); /** * bnx2x_poll - NAPI callback * * @napi: napi structure * @budget: * */ int bnx2x_poll(struct napi_struct *napi, int budget); /** * bnx2x_alloc_mem_bp - allocate memories outsize main driver structure * * @bp: driver handle */ int bnx2x_alloc_mem_bp(struct bnx2x *bp); /** * bnx2x_free_mem_bp - release memories outsize main driver structure * * @bp: driver handle */ void bnx2x_free_mem_bp(struct bnx2x *bp); /** * bnx2x_change_mtu - change mtu netdev callback * * @dev: net device * @new_mtu: requested mtu * */ int bnx2x_change_mtu(struct net_device *dev, int new_mtu); #ifdef NETDEV_FCOE_WWNN /** * bnx2x_fcoe_get_wwn - return the requested WWN value for this port * * @dev: net_device * @wwn: output buffer * @type: WWN type: NETDEV_FCOE_WWNN (node) or NETDEV_FCOE_WWPN (port) * */ int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type); #endif /** * bnx2x_tx_timeout - tx timeout netdev callback * * @dev: net device */ void bnx2x_tx_timeout(struct net_device *dev); /** * vlan rx register netdev callback * * @dev: net device * @vlgrp: VLAN group */ void <API key>(struct net_device *dev, struct vlan_group *vlgrp); static inline void <API key>(struct bnx2x_fastpath *fp) { barrier(); /* status block is written to by the chip */ fp->fp_hc_idx = fp->sb_running_index[SM_RX_ID]; } static inline void <API key>(struct bnx2x *bp, u8 igu_sb_id, u8 segment, u16 index, u8 op, u8 update, u32 igu_addr) { struct igu_regular cmd_data = {0}; cmd_data.sb_id_and_flags = ((index << <API key>) | (segment << <API key>) | (update << <API key>) | (op << <API key>)); DP(NETIF_MSG_INTR, "write 0x%08x to IGU addr 0x%x\n", cmd_data.sb_id_and_flags, igu_addr); REG_WR(bp, igu_addr, cmd_data.sb_id_and_flags); /* Make sure that ACK is written */ mmiowb(); barrier(); } static inline void bnx2x_hc_ack_sb(struct bnx2x *bp, u8 sb_id, u8 storm, u16 index, u8 op, u8 update) { u32 hc_addr = (HC_REG_COMMAND_REG + BP_PORT(bp)*32 + COMMAND_REG_INT_ACK); struct igu_ack_register igu_ack; igu_ack.status_block_index = index; igu_ack.sb_id_and_flags = ((sb_id << <API key>) | (storm << <API key>) | (update << <API key>) | (op << <API key>)); REG_WR(bp, hc_addr, (*(u32 *)&igu_ack)); /* Make sure that ACK is written */ mmiowb(); barrier(); } static inline void bnx2x_ack_sb(struct bnx2x *bp, u8 igu_sb_id, u8 storm, u16 index, u8 op, u8 update) { if (bp->common.int_block == INT_BLOCK_HC) bnx2x_hc_ack_sb(bp, igu_sb_id, storm, index, op, update); else { u8 segment; if (CHIP_INT_MODE_IS_BC(bp)) segment = storm; else if (igu_sb_id != bp->igu_dsb_id) segment = IGU_SEG_ACCESS_DEF; else if (storm == ATTENTION_ID) segment = IGU_SEG_ACCESS_ATTN; else segment = IGU_SEG_ACCESS_DEF; bnx2x_igu_ack_sb(bp, igu_sb_id, segment, index, op, update); } } static inline u16 bnx2x_hc_ack_int(struct bnx2x *bp) { u32 hc_addr = (HC_REG_COMMAND_REG + BP_PORT(bp)*32 + <API key>); u32 result = REG_RD(bp, hc_addr); barrier(); return result; } static inline u16 bnx2x_igu_ack_int(struct bnx2x *bp) { u32 igu_addr = (BAR_IGU_INTMEM + <API key>*8); u32 result = REG_RD(bp, igu_addr); DP(NETIF_MSG_INTR, "read 0x%08x from IGU addr 0x%x\n", result, igu_addr); barrier(); return result; } static inline u16 bnx2x_ack_int(struct bnx2x *bp) { barrier(); if (bp->common.int_block == INT_BLOCK_HC) return bnx2x_hc_ack_int(bp); else return bnx2x_igu_ack_int(bp); } static inline int <API key>(struct bnx2x_fp_txdata *txdata) { /* Tell compiler that consumer and producer can change */ barrier(); return txdata->tx_pkt_prod != txdata->tx_pkt_cons; } static inline u16 bnx2x_tx_avail(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata) { s16 used; u16 prod; u16 cons; prod = txdata->tx_bd_prod; cons = txdata->tx_bd_cons; used = SUB_S16(prod, cons); #ifdef BNX2X_STOP_ON_ERROR WARN_ON(used < 0); WARN_ON(used > txdata->tx_ring_size); WARN_ON((txdata->tx_ring_size - used) > MAX_TX_AVAIL); #endif return (s16)(txdata->tx_ring_size) - used; } static inline int <API key>(struct bnx2x_fp_txdata *txdata) { u16 hw_cons; /* Tell compiler that status block fields can change */ barrier(); hw_cons = le16_to_cpu(*txdata->tx_cons_sb); return hw_cons != txdata->tx_pkt_cons; } static inline bool bnx2x_has_tx_work(struct bnx2x_fastpath *fp) { u8 cos; <API key>(fp, cos) if (<API key>(fp->txdata_ptr[cos])) return true; return false; } #define <API key>(cqe_fp) (cqe_fp->marker == 0x0) #define BNX2X_SEED_CQE(cqe_fp) (cqe_fp->marker = 0xFFFFFFFF) static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp) { u16 cons; union eth_rx_cqe *cqe; struct <API key> *cqe_fp; cons = RCQ_BD(fp->rx_comp_cons); cqe = &fp->rx_comp_ring[cons]; cqe_fp = &cqe->fast_path_cqe; return <API key>(cqe_fp); } /** * bnx2x_tx_disable - disables tx from stack point of view * * @bp: driver handle */ static inline void bnx2x_tx_disable(struct bnx2x *bp) { netif_tx_disable(bp->dev); netif_carrier_off(bp->dev); } static inline void bnx2x_free_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp, u16 index) { struct sw_rx_page *sw_buf = &fp->rx_page_ring[index]; struct page *page = sw_buf->page; struct eth_rx_sge *sge = &fp->rx_sge_ring[index]; /* Skip "next page" elements */ if (!page) return; dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(sw_buf, mapping), SGE_PAGES, DMA_FROM_DEVICE); __free_pages(page, PAGES_PER_SGE_SHIFT); sw_buf->page = NULL; sge->addr_hi = 0; sge->addr_lo = 0; } static inline void <API key>(struct bnx2x *bp) { int i; /* Add NAPI objects */ <API key>(bp, i) netif_napi_add(bp->dev, &bnx2x_fp(bp, i, napi), bnx2x_poll, NAPI_POLL_WEIGHT); } static inline void bnx2x_add_all_napi(struct bnx2x *bp) { int i; /* Add NAPI objects */ for_each_eth_queue(bp, i) netif_napi_add(bp->dev, &bnx2x_fp(bp, i, napi), bnx2x_poll, NAPI_POLL_WEIGHT); } static inline void <API key>(struct bnx2x *bp) { int i; <API key>(bp, i) netif_napi_del(&bnx2x_fp(bp, i, napi)); } static inline void bnx2x_del_all_napi(struct bnx2x *bp) { int i; for_each_eth_queue(bp, i) netif_napi_del(&bnx2x_fp(bp, i, napi)); } int bnx2x_set_int_mode(struct bnx2x *bp); static inline void bnx2x_disable_msi(struct bnx2x *bp) { if (bp->flags & USING_MSIX_FLAG) { pci_disable_msix(bp->pdev); bp->flags &= ~(USING_MSIX_FLAG | <API key>); } else if (bp->flags & USING_MSI_FLAG) { pci_disable_msi(bp->pdev); bp->flags &= ~USING_MSI_FLAG; } } static inline int <API key>(struct bnx2x *bp) { return num_queues ? min_t(int, num_queues, BNX2X_MAX_QUEUES(bp)) : min_t(int, <API key>(), BNX2X_MAX_QUEUES(bp)); } static inline void <API key>(struct bnx2x_fastpath *fp) { int i, j; for (i = 1; i <= NUM_RX_SGE_PAGES; i++) { int idx = RX_SGE_CNT * i - 1; for (j = 0; j < 2; j++) { BIT_VEC64_CLEAR_BIT(fp->sge_mask, idx); idx } } } static inline void <API key>(struct bnx2x_fastpath *fp) { /* Set the mask to all 1-s: it's faster to compare to 0 than to 0xf-s */ memset(fp->sge_mask, 0xff, sizeof(fp->sge_mask)); /* Clear the two last indices in the page to 1: these are the indices that correspond to the "next" element, hence will never be indicated and should be removed from the calculations. */ <API key>(fp); } /* note that we are not allocating a new buffer, * we are just moving one from cons to prod * we are not creating a new mapping, * so there is no need to check for dma_mapping_error(). */ static inline void bnx2x_reuse_rx_data(struct bnx2x_fastpath *fp, u16 cons, u16 prod) { struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons]; struct sw_rx_bd *prod_rx_buf = &fp->rx_buf_ring[prod]; struct eth_rx_bd *cons_bd = &fp->rx_desc_ring[cons]; struct eth_rx_bd *prod_bd = &fp->rx_desc_ring[prod]; dma_unmap_addr_set(prod_rx_buf, mapping, dma_unmap_addr(cons_rx_buf, mapping)); prod_rx_buf->data = cons_rx_buf->data; *prod_bd = *cons_bd; } /* returns func by VN for current port */ static inline int func_by_vn(struct bnx2x *bp, int vn) { return 2 * vn + BP_PORT(bp); } static inline int <API key>(struct bnx2x *bp, bool config_hash) { return bnx2x_config_rss_pf(bp, &bp->rss_conf_obj, config_hash); } /** * bnx2x_func_start - init function * * @bp: driver handle * * Must be called before sending CLIENT_SETUP for the first client. */ static inline int bnx2x_func_start(struct bnx2x *bp) { struct <API key> func_params = {NULL}; struct <API key> *start_params = &func_params.params.start; /* Prepare parameters for function state transitions */ __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags); func_params.f_obj = &bp->func_obj; func_params.cmd = BNX2X_F_CMD_START; /* Function parameters */ start_params->mf_mode = bp->mf_mode; start_params->sd_vlan_tag = bp->mf_ov; start_params->network_cos_mode = OVERRIDE_COS; start_params->gre_tunnel_mode = IPGRE_TUNNEL; start_params->gre_tunnel_rss = <API key>; return <API key>(bp, &func_params); } /** * <API key> - fill in a MAC address in FW format * * @fw_hi: pointer to upper part * @fw_mid: pointer to middle part * @fw_lo: pointer to lower part * @mac: pointer to MAC address */ static inline void <API key>(__le16 *fw_hi, __le16 *fw_mid, __le16 *fw_lo, u8 *mac) { ((u8 *)fw_hi)[0] = mac[1]; ((u8 *)fw_hi)[1] = mac[0]; ((u8 *)fw_mid)[0] = mac[3]; ((u8 *)fw_mid)[1] = mac[2]; ((u8 *)fw_lo)[0] = mac[5]; ((u8 *)fw_lo)[1] = mac[4]; } static inline void <API key>(struct bnx2x *bp, struct bnx2x_fastpath *fp, int last) { int i; if (fp->disable_tpa) return; for (i = 0; i < last; i++) bnx2x_free_rx_sge(bp, fp, i); } static inline void <API key>(struct bnx2x_fastpath *fp) { int i; for (i = 1; i <= NUM_RX_RINGS; i++) { struct eth_rx_bd *rx_bd; rx_bd = &fp->rx_desc_ring[RX_DESC_CNT * i - 2]; rx_bd->addr_hi = cpu_to_le32(U64_HI(fp->rx_desc_mapping + BCM_PAGE_SIZE*(i % NUM_RX_RINGS))); rx_bd->addr_lo = cpu_to_le32(U64_LO(fp->rx_desc_mapping + BCM_PAGE_SIZE*(i % NUM_RX_RINGS))); } } /* Statistics ID are global per chip/path, while Client IDs for E1x are per * port. */ static inline u8 bnx2x_stats_id(struct bnx2x_fastpath *fp) { struct bnx2x *bp = fp->bp; if (!CHIP_IS_E1x(bp)) { /* there are special statistics counters for FCoE 136..140 */ if (IS_FCOE_FP(fp)) return bp->cnic_base_cl_id + (bp->pf_num >> 1); return fp->cl_id; } return fp->cl_id + BP_PORT(bp) * FP_SB_MAX_E1x; } static inline void <API key>(struct bnx2x_fastpath *fp, bnx2x_obj_type obj_type) { struct bnx2x *bp = fp->bp; /* Configure classification DBs */ bnx2x_init_mac_obj(bp, &bnx2x_sp_obj(bp, fp).mac_obj, fp->cl_id, fp->cid, BP_FUNC(bp), bnx2x_sp(bp, mac_rdata), bnx2x_sp_mapping(bp, mac_rdata), <API key>, &bp->sp_state, obj_type, &bp->macs_pool); } /** * <API key> - get number of active functions * * @bp: driver handle * * Calculates the number of active (not hidden) functions on the * current path. */ static inline u8 <API key>(struct bnx2x *bp) { u8 func_num = 0, i; /* 57710 has only one function per-port */ if (CHIP_IS_E1(bp)) return 1; /* Calculate a number of functions enabled on the current * PATH/PORT. */ if (CHIP_REV_IS_SLOW(bp)) { if (IS_MF(bp)) func_num = 4; else func_num = 2; } else { for (i = 0; i < E1H_FUNC_MAX / 2; i++) { u32 func_config = MF_CFG_RD(bp, func_mf_config[BP_PORT(bp) + 2 * i]. config); func_num += ((func_config & <API key>) ? 0 : 1); } } WARN_ON(!func_num); return func_num; } static inline void bnx2x_init_bp_objs(struct bnx2x *bp) { /* RX_MODE controlling object */ <API key>(bp, &bp->rx_mode_obj); /* multicast configuration controlling object */ <API key>(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid, BP_FUNC(bp), BP_FUNC(bp), bnx2x_sp(bp, mcast_rdata), bnx2x_sp_mapping(bp, mcast_rdata), <API key>, &bp->sp_state, BNX2X_OBJ_TYPE_RX); /* Setup CAM credit pools */ <API key>(bp, &bp->macs_pool, BP_FUNC(bp), <API key>(bp)); <API key>(bp, &bp->vlans_pool, BP_ABS_FUNC(bp)>>1, <API key>(bp)); /* RSS configuration object */ <API key>(bp, &bp->rss_conf_obj, bp->fp->cl_id, bp->fp->cid, BP_FUNC(bp), BP_FUNC(bp), bnx2x_sp(bp, rss_rdata), bnx2x_sp_mapping(bp, rss_rdata), <API key>, &bp->sp_state, BNX2X_OBJ_TYPE_RX); } static inline u8 bnx2x_fp_qzone_id(struct bnx2x_fastpath *fp) { if (CHIP_IS_E1x(fp->bp)) return fp->cl_id + BP_PORT(fp->bp) * <API key>; else return fp->cl_id; } u32 <API key>(struct bnx2x_fastpath *fp); static inline void bnx2x_init_txdata(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, u32 cid, int txq_index, __le16 *tx_cons_sb, struct bnx2x_fastpath *fp) { txdata->cid = cid; txdata->txq_index = txq_index; txdata->tx_cons_sb = tx_cons_sb; txdata->parent_fp = fp; txdata->tx_ring_size = IS_FCOE_FP(fp) ? MAX_TX_AVAIL : bp->tx_ring_size; DP(NETIF_MSG_IFUP, "created tx data cid %d, txq %d\n", txdata->cid, txdata->txq_index); } static inline u8 <API key>(struct bnx2x *bp, u8 cl_idx) { return bp->cnic_base_cl_id + cl_idx + (bp->pf_num >> 1) * <API key>; } static inline u8 bnx2x_cnic_fw_sb_id(struct bnx2x *bp) { /* the 'first' id is allocated for the cnic */ return bp->base_fw_ndsb; } static inline u8 <API key>(struct bnx2x *bp) { return bp->igu_base_sb; } static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp) { struct bnx2x_fastpath *fp = bnx2x_fcoe_fp(bp); unsigned long q_type = 0; bnx2x_fcoe(bp, rx_queue) = <API key>(bp); bnx2x_fcoe(bp, cl_id) = <API key>(bp, <API key>); bnx2x_fcoe(bp, cid) = BNX2X_FCOE_ETH_CID(bp); bnx2x_fcoe(bp, fw_sb_id) = DEF_SB_ID; bnx2x_fcoe(bp, igu_sb_id) = bp->igu_dsb_id; bnx2x_fcoe(bp, rx_cons_sb) = <API key>; bnx2x_init_txdata(bp, bnx2x_fcoe(bp, txdata_ptr[0]), fp->cid, FCOE_TXQ_IDX(bp), <API key>, fp); DP(NETIF_MSG_IFUP, "created fcoe tx data (fp index %d)\n", fp->index); /* qZone id equals to FW (per path) client id */ bnx2x_fcoe(bp, cl_qzone_id) = bnx2x_fp_qzone_id(fp); /* init shortcut */ bnx2x_fcoe(bp, <API key>) = <API key>(fp); /* Configure Queue State object */ __set_bit(BNX2X_Q_TYPE_HAS_RX, &q_type); __set_bit(BNX2X_Q_TYPE_HAS_TX, &q_type); /* No multi-CoS for FCoE L2 client */ BUG_ON(fp->max_cos != 1); <API key>(bp, &bnx2x_sp_obj(bp, fp).q_obj, fp->cl_id, &fp->cid, 1, BP_FUNC(bp), bnx2x_sp(bp, q_rdata), bnx2x_sp_mapping(bp, q_rdata), q_type); DP(NETIF_MSG_IFUP, "queue[%d]: bnx2x_init_sb(%p,%p) cl_id %d fw_sb %d igu_sb %d\n", fp->index, bp, fp->status_blk.e2_sb, fp->cl_id, fp->fw_sb_id, fp->igu_sb_id); } static inline int <API key>(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata) { int cnt = 1000; while (<API key>(txdata)) { if (!cnt) { BNX2X_ERR("timeout waiting for queue[%d]: txdata->tx_pkt_prod(%d) != txdata->tx_pkt_cons(%d)\n", txdata->txq_index, txdata->tx_pkt_prod, txdata->tx_pkt_cons); #ifdef BNX2X_STOP_ON_ERROR bnx2x_panic(); return -EBUSY; #else break; #endif } cnt usleep_range(1000, 2000); } return 0; } int <API key>(struct bnx2x *bp); static inline void <API key>(struct bnx2x *bp, u32 addr, size_t size, u32 *data) { int i; for (i = 0; i < size/4; i++) REG_WR(bp, addr + (i * 4), data[i]); } /** * bnx2x_wait_sp_comp - wait for the outstanding SP commands. * * @bp: driver handle * @mask: bits that need to be cleared */ static inline bool bnx2x_wait_sp_comp(struct bnx2x *bp, unsigned long mask) { int tout = 5000; /* Wait for 5 secs tops */ while (tout smp_mb(); netif_addr_lock_bh(bp->dev); if (!(bp->sp_state & mask)) { <API key>(bp->dev); return true; } <API key>(bp->dev); usleep_range(1000, 2000); } smp_mb(); netif_addr_lock_bh(bp->dev); if (bp->sp_state & mask) { BNX2X_ERR("Filtering completion timed out. sp_state 0x%lx, mask 0x%lx\n", bp->sp_state, mask); <API key>(bp->dev); return false; } <API key>(bp->dev); return true; } /** * <API key> - set CDU context validation values * * @bp: driver handle * @cxt: context of the connection on the host memory * @cid: SW CID of the connection to be configured */ void <API key>(struct bnx2x *bp, struct eth_context *cxt, u32 cid); void <API key>(struct bnx2x *bp, u8 fw_sb_id, u8 sb_index, u8 disable, u16 usec); void <API key>(struct bnx2x *bp); void <API key>(struct bnx2x *bp); /** * <API key> - extract MAX BW part from MF configuration. * * @bp: driver handle * @mf_cfg: MF configuration * */ static inline u16 <API key>(struct bnx2x *bp, u32 mf_cfg) { u16 max_cfg = (mf_cfg & <API key>) >> <API key>; if (!max_cfg) { DP(NETIF_MSG_IFUP | BNX2X_MSG_ETHTOOL, "Max BW configured to 0 - using 100 instead\n"); max_cfg = 100; } return max_cfg; } /* checks if HW supports GRO for given MTU */ static inline bool <API key>(int mtu) { /* gro frags per page */ int fpp = SGE_PAGE_SIZE / (mtu - <API key>); /* * 1. Number of frags should not grow above MAX_SKB_FRAGS * 2. Frag must fit the page */ return mtu <= SGE_PAGE_SIZE && (U_ETH_SGL_SIZE * fpp) <= MAX_SKB_FRAGS; } /** * <API key> - update iSCSI params according to licensing info. * * @bp: driver handle * */ void <API key>(struct bnx2x *bp); /** * <API key> - send notification to other functions. * * @bp: driver handle * */ static inline void <API key>(struct bnx2x *bp) { int func; int vn; /* Set the attention towards other drivers on the same port */ for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) { if (vn == BP_VN(bp)) continue; func = func_by_vn(bp, vn); REG_WR(bp, <API key> + (<API key> + func)*4, 1); } } /** * <API key> - update flags in shmem * * @bp: driver handle * @flags: flags to update * @set: set or clear * */ static inline void <API key>(struct bnx2x *bp, u32 flags, u32 set) { if (SHMEM2_HAS(bp, drv_flags)) { u32 drv_flags; <API key>(bp, <API key>); drv_flags = SHMEM2_RD(bp, drv_flags); if (set) SET_FLAGS(drv_flags, flags); else RESET_FLAGS(drv_flags, flags); SHMEM2_WR(bp, drv_flags, drv_flags); DP(NETIF_MSG_IFUP, "drv_flags 0x%08x\n", drv_flags); <API key>(bp, <API key>); } } static inline bool <API key>(struct bnx2x *bp, u8 *addr) { if (is_valid_ether_addr(addr) || (is_zero_ether_addr(addr) && (IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp)))) return true; return false; } /** * bnx2x_fill_fw_str - Fill buffer with FW version string * * @bp: driver handle * @buf: character buffer to fill with the fw name * @buf_len: length of the above buffer * */ void bnx2x_fill_fw_str(struct bnx2x *bp, char *buf, size_t buf_len); int <API key>(struct bnx2x *bp); void <API key>(struct bnx2x *bp); #endif /* BNX2X_CMN_H */
<?php if (!$os) { if (strstr($sysDescr, "KYOCERA ")) { $os = "kyocera"; } } ?>
# -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) store_version = 1 # Needed for dynamic plugin loading __license__ = 'GPL 3' __copyright__ = '2011, John Schember <john@nachtimwald.com>' __docformat__ = 'restructuredtext en' from calibre.gui2.store.basic_config import BasicStoreConfig from calibre.gui2.store.opensearch_store import OpenSearchOPDSStore from calibre.gui2.store.search_result import SearchResult class ArchiveOrgStore(BasicStoreConfig, OpenSearchOPDSStore): open_search_url = 'http://bookserver.archive.org/catalog/opensearch.xml' web_url = 'http: def search(self, query, max_results=10, timeout=60): for s in OpenSearchOPDSStore.search(self, query, max_results, timeout): s.detail_item = 'http: s.price = '$0.00' s.drm = SearchResult.DRM_UNLOCKED yield s def get_details(self, search_result, timeout): ''' The opensearch feed only returns a subset of formats that are available. We want to get a list of all formats that the user can get. ''' from calibre import browser from contextlib import closing from lxml import html br = browser() with closing(br.open(search_result.detail_item, timeout=timeout)) as nf: idata = html.fromstring(nf.read()) formats = ', '.join(idata.xpath('//p[@id="dl" and @class="content"]//a/text()')) search_result.formats = formats.upper() return True
/*! * JavaScript for the debug toolbar profiler, enabled through $wgDebugToolbar * and StartProfiler.php. * * @author Erik Bernhardson * @since 1.23 */ ( function ( mw, $ ) { 'use strict'; /** * @singleton * @class mw.Debug.profile */ var profile = mw.Debug.profile = { /** * Object containing data for the debug toolbar * * @property ProfileData */ data: null, /** * @property DOMElement */ container: null, /** * Initializes the profiling pane. */ init: function ( data, width, mergeThresholdPx, dropThresholdPx ) { data = data || mw.config.get( 'debugInfo' ).profile; profile.width = width || $(window).width() - 20; // merge events from same pixel(some events are very granular) mergeThresholdPx = mergeThresholdPx || 2; // only drop events if requested dropThresholdPx = dropThresholdPx || 0; if ( !Array.prototype.map || !Array.prototype.reduce || !Array.prototype.filter ) { profile.container = profile.buildRequiresES5(); } else if ( data.length === 0 ) { profile.container = profile.buildNoData(); } else { // generate a flyout profile.data = new ProfileData( data, profile.width, mergeThresholdPx, dropThresholdPx ); // draw it profile.container = profile.buildSvg( profile.container ); profile.attachFlyout(); } return profile.container; }, buildRequiresES5: function () { return $( '<div>' ) .text( 'An ES5 compatible javascript engine is required for the profile visualization.' ) .get( 0 ); }, buildNoData: function () { return $( '<div>' ).addClass( '<API key>' ) .text( 'No events recorded, ensure profiling is enabled in StartProfiler.php.' ) .get( 0 ); }, /** * Creates DOM nodes appropriately namespaced for SVG. * * @param string tag to create * @return DOMElement */ createSvgElement: document.createElementNS ? document.createElementNS.bind( document, 'http: // throw a error for browsers which does not support document.createElementNS (IE<8) : function () { throw new Error( 'document.createElementNS not supported' ); }, /** * @param DOMElement|undefined */ buildSvg: function ( node ) { var container, group, i, g, timespan = profile.data.timespan, gapPerEvent = 38, space = 10.5, currentHeight = space, totalHeight = 0; profile.ratio = ( profile.width - space * 2 ) / ( timespan.end - timespan.start ); totalHeight += gapPerEvent * profile.data.groups.length; if ( node ) { $( node ).empty(); } else { node = profile.createSvgElement( 'svg' ); node.setAttribute( 'version', '1.2' ); node.setAttribute( 'baseProfile', 'tiny' ); } node.style.height = totalHeight; node.style.width = profile.width; // use a container that can be transformed container = profile.createSvgElement( 'g' ); node.appendChild( container ); for ( i = 0; i < profile.data.groups.length; i++ ) { group = profile.data.groups[i]; g = profile.buildTimeline( group ); g.setAttribute( 'transform', 'translate( 0 ' + currentHeight + ' )' ); container.appendChild( g ); currentHeight += gapPerEvent; } return node; }, /** * @param Object group of periods to transform into graphics */ buildTimeline: function ( group ) { var text, tspan, line, i, sum = group.timespan.sum, ms = ' ~ ' + ( sum < 1 ? sum.toFixed( 2 ) : sum.toFixed( 0 ) ) + ' ms', timeline = profile.createSvgElement( 'g' ); timeline.setAttribute( 'class', '<API key>' ); // draw label text = profile.createSvgElement( 'text' ); text.setAttribute( 'x', profile.xCoord( group.timespan.start ) ); text.setAttribute( 'y', 0 ); text.textContent = group.name; timeline.appendChild( text ); // draw metadata tspan = profile.createSvgElement( 'tspan' ); tspan.textContent = ms; text.appendChild( tspan ); // draw timeline periods for ( i = 0; i < group.periods.length; i++ ) { timeline.appendChild( profile.buildPeriod( group.periods[i] ) ); } // full-width line under each timeline line = profile.createSvgElement( 'line' ); line.setAttribute( 'class', '<API key>' ); line.setAttribute( 'x1', 0 ); line.setAttribute( 'y1', 28 ); line.setAttribute( 'x2', profile.width ); line.setAttribute( 'y2', 28 ); timeline.appendChild( line ); return timeline; }, /** * @param Object period to transform into graphics */ buildPeriod: function ( period ) { var node, head = profile.xCoord( period.start ), tail = profile.xCoord( period.end ), g = profile.createSvgElement( 'g' ); g.setAttribute( 'class', '<API key>' ); $( g ).data( 'period', period ); if ( head + 16 > tail ) { node = profile.createSvgElement( 'rect' ); node.setAttribute( 'x', head ); node.setAttribute( 'y', 8 ); node.setAttribute( 'width', 2 ); node.setAttribute( 'height', 9 ); g.appendChild( node ); node = profile.createSvgElement( 'rect' ); node.setAttribute( 'x', head ); node.setAttribute( 'y', 8 ); node.setAttribute( 'width', ( period.end - period.start ) * profile.ratio || 2 ); node.setAttribute( 'height', 6 ); g.appendChild( node ); } else { node = profile.createSvgElement( 'polygon' ); node.setAttribute( 'points', pointList( [ [ head, 8 ], [ head, 19 ], [ head + 8, 8 ], [ head, 8] ] ) ); g.appendChild( node ); node = profile.createSvgElement( 'polygon' ); node.setAttribute( 'points', pointList( [ [ tail, 8 ], [ tail, 19 ], [ tail - 8, 8 ], [ tail, 8 ] ] ) ); g.appendChild( node ); node = profile.createSvgElement( 'line' ); node.setAttribute( 'x1', head ); node.setAttribute( 'y1', 9 ); node.setAttribute( 'x2', tail ); node.setAttribute( 'y2', 9 ); g.appendChild( node ); } return g; }, /** * @param Object */ buildFlyout: function ( period ) { var contained, sum, ms, mem, i, node = $( '<div>' ); for ( i = 0; i < period.contained.length; i++ ) { contained = period.contained[i]; sum = contained.end - contained.start; ms = '' + ( sum < 1 ? sum.toFixed( 2 ) : sum.toFixed( 0 ) ) + ' ms'; mem = formatBytes( contained.memory ); $( '<div>' ).text( contained.source.name ) .append( $( '<span>' ).text( ' ~ ' + ms + ' / ' + mem ).addClass( '<API key>' ) ) .appendTo( node ); } return node; }, /** * Attach a hover flyout to all .<API key> groups. */ attachFlyout: function () { // for some reason addClass and removeClass from jQuery // arn't working on svg elements in chrome <= 33.0 (possibly more) var $container = $( profile.container ), addClass = function ( node, value ) { var current = node.getAttribute( 'class' ), list = current ? current.split( ' ' ) : false, idx = list ? list.indexOf( value ) : -1; if ( idx === -1 ) { node.setAttribute( 'class', current ? ( current + ' ' + value ) : value ); } }, removeClass = function ( node, value ) { var current = node.getAttribute( 'class' ), list = current ? current.split( ' ' ) : false, idx = list ? list.indexOf( value ) : -1; if ( idx !== -1 ) { list.splice( idx, 1 ); node.setAttribute( 'class', list.join( ' ' ) ); } }, // hide all tipsy flyouts hide = function () { $container.find( '.<API key>.tipsy-visible' ) .each( function () { removeClass( this, 'tipsy-visible' ); $( this ).tipsy( 'hide' ); } ); }; $container.find( '.<API key>' ).tipsy( { fade: true, gravity: function () { return $.fn.tipsy.autoNS.call( this ) + $.fn.tipsy.autoWE.call( this ); }, className: '<API key>', center: false, html: true, trigger: 'manual', title: function () { return profile.buildFlyout( $( this ).data( 'period' ) ).html(); } } ).on( 'mouseenter', function () { hide(); addClass( this, 'tipsy-visible' ); $( this ).tipsy( 'show' ); } ); $container.on( 'mouseleave', function ( event ) { var $from = $( event.relatedTarget ), $to = $( event.target ); // only close the tipsy if we are not if ( $from.closest( '.tipsy' ).length === 0 && $to.closest( '.tipsy' ).length === 0 && $to.get( 0 ).namespaceURI !== 'http: ) { hide(); } } ).on( 'click', function () { // convenience method for closing hide(); } ); }, /** * @return number the x co-ordinate for the specified timestamp */ xCoord: function ( msTimestamp ) { return ( msTimestamp - profile.data.timespan.start ) * profile.ratio; } }; function ProfileData( data, width, mergeThresholdPx, dropThresholdPx ) { // validate input data this.data = data.map( function ( event ) { event.periods = event.periods.filter( function ( period ) { return period.start && period.end && period.start < period.end // period start must be a reasonable ms timestamp && period.start > 1000000; } ); return event; } ).filter( function ( event ) { return event.name && event.periods.length > 0; } ); // start and end time of the data this.timespan = this.data.reduce( function ( result, event ) { return event.periods.reduce( periodMinMax, result ); }, periodMinMax.initial() ); // transform input data this.groups = this.collate( width, mergeThresholdPx, dropThresholdPx ); return this; } /** * There are too many unique events to display a line for each, * so this does a basic grouping. */ ProfileData.groupOf = function ( label ) { var pos, prefix = 'Profile section ended by close(): '; if ( label.indexOf( prefix ) === 0 ) { label = label.substring( prefix.length ); } pos = [ '::', ':', '-' ].reduce( function ( result, separator ) { var pos = label.indexOf( separator ); if ( pos === -1 ) { return result; } else if ( result === -1 ) { return pos; } else { return Math.min( result, pos ); } }, -1 ); if ( pos === -1 ) { return label; } else { return label.substring( 0, pos ); } }; /** * @return Array list of objects with `name` and `events` keys */ ProfileData.groupEvents = function ( events ) { var group, i, groups = {}; // Group events together for ( i = events.length - 1; i >= 0; i group = ProfileData.groupOf( events[i].name ); if ( groups[group] ) { groups[group].push( events[i] ); } else { groups[group] = [events[i]]; } } // Return an array of groups return Object.keys( groups ).map( function ( group ) { return { name: group, events: groups[group] }; } ); }; ProfileData.periodSorter = function ( a, b ) { if ( a.start === b.start ) { return a.end - b.end; } return a.start - b.start; }; ProfileData.<API key> = function ( mergeThresholdMs ) { return function ( result, period ) { if ( result.length === 0 ) { // period is first result return [{ start: period.start, end: period.end, contained: [period] }]; } var last = result[result.length - 1]; if ( period.end < last.end ) { // end is contained within previous result[result.length - 1].contained.push( period ); } else if ( period.start - mergeThresholdMs < last.end ) { // neighbors within merging distance result[result.length - 1].end = period.end; result[result.length - 1].contained.push( period ); } else { // period is next result result.push({ start: period.start, end: period.end, contained: [period] }); } return result; }; }; /** * Collect all periods from the grouped events and apply merge and * drop transformations */ ProfileData.extractPeriods = function ( events, mergeThresholdMs, dropThresholdMs ) { // collect the periods from all events return events.reduce( function ( result, event ) { if ( !event.periods.length ) { return result; } result.push.apply( result, event.periods.map( function ( period ) { // maintain link from period to event period.source = event; return period; } ) ); return result; }, [] ) // sort combined periods .sort( ProfileData.periodSorter ) // Apply merge threshold. Original periods // are maintained in the `contained` property .reduce( ProfileData.<API key>( mergeThresholdMs ), [] ) // Apply drop threshold .filter( function ( period ) { return period.end - period.start > dropThresholdMs; } ); }; /** * runs a callback on all periods in the group. Only valid after * groups.periods[0..n].contained are populated. This runs against * un-transformed data and is better suited to summing or other * stat collection */ ProfileData.reducePeriods = function ( group, callback, result ) { return group.periods.reduce( function ( result, period ) { return period.contained.reduce( callback, result ); }, result ); }; /** * Transforms this.data grouping by labels, merging neighboring * events in the groups, and drops events and groups below the * display threshold. Groups are returned sorted by starting time. */ ProfileData.prototype.collate = function ( width, mergeThresholdPx, dropThresholdPx ) { // ms to pixel ratio var ratio = ( this.timespan.end - this.timespan.start ) / width, // transform thresholds to ms mergeThresholdMs = mergeThresholdPx * ratio, dropThresholdMs = dropThresholdPx * ratio; return ProfileData.groupEvents( this.data ) // generate data about the grouped events .map( function ( group ) { // Cleaned periods from all events group.periods = ProfileData.extractPeriods( group.events, mergeThresholdMs, dropThresholdMs ); // min and max timestamp per group group.timespan = ProfileData.reducePeriods( group, periodMinMax, periodMinMax.initial() ); // ms from first call to end of last call group.timespan.length = group.timespan.end - group.timespan.start; // collect the un-transformed periods group.timespan.sum = ProfileData.reducePeriods( group, function ( result, period ) { result.push( period ); return result; }, [] ) // sort by start time .sort( ProfileData.periodSorter ) // merge overlapping .reduce( ProfileData.<API key>( 0 ), [] ) // sum .reduce( function ( result, period ) { return result + period.end - period.start; }, 0 ); return group; }, this ) // remove groups that have had all their periods filtered .filter( function ( group ) { return group.periods.length > 0; } ) // sort events by first start .sort( function ( a, b ) { return ProfileData.periodSorter( a.timespan, b.timespan ); } ); }; // reducer to find edges of period array function periodMinMax( result, period ) { if ( period.start < result.start ) { result.start = period.start; } if ( period.end > result.end ) { result.end = period.end; } return result; } periodMinMax.initial = function () { return { start: Number.POSITIVE_INFINITY, end: Number.NEGATIVE_INFINITY }; }; function formatBytes( bytes ) { var i, sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; if ( bytes === 0 ) { return '0 Bytes'; } i = parseInt( Math.floor( Math.log( bytes ) / Math.log( 1024 ) ), 10 ); return Math.round( bytes / Math.pow( 1024, i ), 2 ) + ' ' + sizes[i]; } // turns a 2d array into a point list for svg // polygon points attribute // ex: [[1,2],[3,4],[4,2]] = '1,2 3,4 4,2' function pointList( pairs ) { return pairs.map( function ( pair ) { return pair.join( ',' ); } ).join( ' ' ); } }( mediaWiki, jQuery ) );
// <API key>.h // $Id: //poco/1.3/Foundation/include/Poco/<API key>.h // Library: Foundation // Package: Events // Module: <API key> // Definition of the <API key> interface. // and Contributors. // obtaining a copy of the software and accompanying documentation covered by // execute, and transmit the Software, and to prepare derivative works of the // Software, and to permit third-parties to whom the Software is furnished to // do so, all subject to the following: // must be included in all copies of the Software, in whole or in part, and // all derivative works of the Software, unless such copies or derivative // works are solely in the form of machine-executable object code generated by // a source language processor. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #ifndef <API key> #define <API key> #include "Poco/Foundation.h" namespace Poco { template <class TArgs, class TDelegate> class <API key> The interface that all notification strategies must implement. { public: <API key>() { } virtual ~<API key>() { } virtual void notify(const void* sender, TArgs& arguments) = 0; Sends a notification to all registered delegates, virtual void add(const TDelegate& pDelegate) = 0; Adds a delegate to the strategy, if the delegate is not yet present virtual void remove(const TDelegate& pDelegate) = 0; Removes a delegate from the strategy if found. virtual void clear() = 0; Removes all delegates from the strategy. virtual bool empty() const = 0; Returns false if the strategy contains at least one delegate. }; } // namespace Poco #endif
/* * ContextMenu Plugin * * */ (function($) { $.extend(mejs.MepDefaults, contextMenuItems = [ // demo of a fullscreen option { render: function(player) { // check for fullscreen plugin if (typeof player.enterFullScreen == 'undefined') return null; if (player.isFullScreen) { return "Turn off Fullscreen"; } else { return "Go Fullscreen"; } }, click: function(player) { if (player.isFullScreen) { player.exitFullScreen(); } else { player.enterFullScreen(); } } } , // demo of a mute/unmute button { render: function(player) { if (player.media.muted) { return "Unmute"; } else { return "Mute"; } }, click: function(player) { if (player.media.muted) { player.setMuted(false); } else { player.setMuted(true); } } }, // separator { isSeparator: true } , // demo of simple download video { render: function(player) { return "Download Video"; }, click: function(player) { window.location.href = player.media.currentSrc; } } ] ); $.extend(MediaElementPlayer.prototype, { buildcontextmenu: function(player, controls, layers, media) { // create context menu player.contextMenu = $('<div class="mejs-contextmenu"></div>') .appendTo($('body')) .hide(); // create events for showing context menu player.container.bind('contextmenu', function(e) { if (player.<API key>) { e.preventDefault(); player.renderContextMenu(e.clientX-1, e.clientY-1); return false; } }); player.container.bind('click', function() { player.contextMenu.hide(); }); player.contextMenu.bind('mouseleave', function() { //console.log('context hover out'); player.<API key>(); }); }, <API key>: true, enableContextMenu: function() { this.<API key> = true; }, disableContextMenu: function() { this.<API key> = false; }, contextMenuTimeout: null, <API key>: function() { //console.log('<API key>'); var t = this; t.<API key>(); t.contextMenuTimer = setTimeout(function() { t.hideContextMenu(); t.<API key>(); }, 750); }, <API key>: function() { var timer = this.contextMenuTimer; //console.log('<API key>', timer); if (timer != null) { clearTimeout(timer); delete timer; timer = null; } }, hideContextMenu: function() { this.contextMenu.hide(); }, renderContextMenu: function(x,y) { // alway re-render the items so that things like "turn fullscreen on" and "turn fullscreen off" are always written correctly var t = this, html = '', items = t.options.contextMenuItems; for (var i=0, il=items.length; i<il; i++) { if (items[i].isSeparator) { html += '<div class="<API key>"></div>'; } else { var rendered = items[i].render(t); // render can return null if the item doesn't need to be used at the moment if (rendered != null) { html += '<div class="<API key>" data-itemindex="' + i + '" id="element-' + (Math.random()*1000000) + '">' + rendered + '</div>'; } } } // position and show the context menu t.contextMenu .empty() .append($(html)) .css({top:y, left:x}) .show(); // bind events t.contextMenu.find('.<API key>').each(function() { // which one is this? var $dom = $(this), itemIndex = parseInt( $dom.data('itemindex'), 10 ), item = t.options.contextMenuItems[itemIndex]; // bind extra functionality? if (typeof item.show != 'undefined') item.show( $dom , t); // bind click action $dom.click(function() { // perform click action if (typeof item.click != 'undefined') item.click(t); // close t.contextMenu.hide(); }); }); // stop the controls from hiding setTimeout(function() { t.killControlsTimer('rev3'); }, 100); } }); })(mejs.$);
/** * @file GCC/ARMCMx/STM32L1xx/vectors.c * @brief Interrupt vectors for the STM32 family. * * @defgroup <API key> STM32L1xx Interrupt Vectors * @ingroup ARMCMx_SPECIFIC * @details Interrupt vectors for the STM32L1xx family. * @{ */ #include "ch.h" /** * @brief Type of an IRQ vector. */ typedef void (*irq_vector_t)(void); /** * @brief Type of a structure representing the whole vectors table. */ typedef struct { uint32_t *init_stack; irq_vector_t reset_vector; irq_vector_t nmi_vector; irq_vector_t hardfault_vector; irq_vector_t memmanage_vector; irq_vector_t busfault_vector; irq_vector_t usagefault_vector; irq_vector_t vector1c; irq_vector_t vector20; irq_vector_t vector24; irq_vector_t vector28; irq_vector_t svcall_vector; irq_vector_t debugmonitor_vector; irq_vector_t vector34; irq_vector_t pendsv_vector; irq_vector_t systick_vector; irq_vector_t vectors[45]; } vectors_t; #if !defined(__DOXYGEN__) extern uint32_t __main_stack_end__; extern void ResetHandler(void); extern void NMIVector(void); extern void HardFaultVector(void); extern void MemManageVector(void); extern void BusFaultVector(void); extern void UsageFaultVector(void); extern void Vector1C(void); extern void Vector20(void); extern void Vector24(void); extern void Vector28(void); extern void SVCallVector(void); extern void DebugMonitorVector(void); extern void Vector34(void); extern void PendSVVector(void); extern void SysTickVector(void); extern void Vector40(void); extern void Vector44(void); extern void Vector48(void); extern void Vector4C(void); extern void Vector50(void); extern void Vector54(void); extern void Vector58(void); extern void Vector5C(void); extern void Vector60(void); extern void Vector64(void); extern void Vector68(void); extern void Vector6C(void); extern void Vector70(void); extern void Vector74(void); extern void Vector78(void); extern void Vector7C(void); extern void Vector80(void); extern void Vector84(void); extern void Vector88(void); extern void Vector8C(void); extern void Vector90(void); extern void Vector94(void); extern void Vector98(void); extern void Vector9C(void); extern void VectorA0(void); extern void VectorA4(void); extern void VectorA8(void); extern void VectorAC(void); extern void VectorB0(void); extern void VectorB4(void); extern void VectorB8(void); extern void VectorBC(void); extern void VectorC0(void); extern void VectorC4(void); extern void VectorC8(void); extern void VectorCC(void); extern void VectorD0(void); extern void VectorD4(void); extern void VectorD8(void); extern void VectorDC(void); extern void VectorE0(void); extern void VectorE4(void); extern void VectorE8(void); extern void VectorEC(void); extern void VectorF0(void); #endif /* !defined(__DOXYGEN__) */ /** * @brief STM32L1xx vectors table. */ #if !defined(__DOXYGEN__) __attribute__ ((section("vectors"))) #endif vectors_t _vectors = { &__main_stack_end__,ResetHandler, NMIVector, HardFaultVector, MemManageVector, BusFaultVector, UsageFaultVector, Vector1C, Vector20, Vector24, Vector28, SVCallVector, DebugMonitorVector, Vector34, PendSVVector, SysTickVector, { Vector40, Vector44, Vector48, Vector4C, Vector50, Vector54, Vector58, Vector5C, Vector60, Vector64, Vector68, Vector6C, Vector70, Vector74, Vector78, Vector7C, Vector80, Vector84, Vector88, Vector8C, Vector90, Vector94, Vector98, Vector9C, VectorA0, VectorA4, VectorA8, VectorAC, VectorB0, VectorB4, VectorB8, VectorBC, VectorC0, VectorC4, VectorC8, VectorCC, VectorD0, VectorD4, VectorD8, VectorDC, VectorE0, VectorE4, VectorE8, VectorEC, VectorF0 } }; /** * @brief Unhandled exceptions handler. * @details Any undefined exception vector points to this function by default. * This function simply stops the system into an infinite loop. * * @notapi */ #if !defined(__DOXYGEN__) __attribute__ ((naked)) #endif void <API key>(void) { while (TRUE) ; } void NMIVector(void) __attribute__((weak, alias("<API key>"))); void HardFaultVector(void) __attribute__((weak, alias("<API key>"))); void MemManageVector(void) __attribute__((weak, alias("<API key>"))); void BusFaultVector(void) __attribute__((weak, alias("<API key>"))); void UsageFaultVector(void) __attribute__((weak, alias("<API key>"))); void Vector1C(void) __attribute__((weak, alias("<API key>"))); void Vector20(void) __attribute__((weak, alias("<API key>"))); void Vector24(void) __attribute__((weak, alias("<API key>"))); void Vector28(void) __attribute__((weak, alias("<API key>"))); void SVCallVector(void) __attribute__((weak, alias("<API key>"))); void DebugMonitorVector(void) __attribute__((weak, alias("<API key>"))); void Vector34(void) __attribute__((weak, alias("<API key>"))); void PendSVVector(void) __attribute__((weak, alias("<API key>"))); void SysTickVector(void) __attribute__((weak, alias("<API key>"))); void Vector40(void) __attribute__((weak, alias("<API key>"))); void Vector44(void) __attribute__((weak, alias("<API key>"))); void Vector48(void) __attribute__((weak, alias("<API key>"))); void Vector4C(void) __attribute__((weak, alias("<API key>"))); void Vector50(void) __attribute__((weak, alias("<API key>"))); void Vector54(void) __attribute__((weak, alias("<API key>"))); void Vector58(void) __attribute__((weak, alias("<API key>"))); void Vector5C(void) __attribute__((weak, alias("<API key>"))); void Vector60(void) __attribute__((weak, alias("<API key>"))); void Vector64(void) __attribute__((weak, alias("<API key>"))); void Vector68(void) __attribute__((weak, alias("<API key>"))); void Vector6C(void) __attribute__((weak, alias("<API key>"))); void Vector70(void) __attribute__((weak, alias("<API key>"))); void Vector74(void) __attribute__((weak, alias("<API key>"))); void Vector78(void) __attribute__((weak, alias("<API key>"))); void Vector7C(void) __attribute__((weak, alias("<API key>"))); void Vector80(void) __attribute__((weak, alias("<API key>"))); void Vector84(void) __attribute__((weak, alias("<API key>"))); void Vector88(void) __attribute__((weak, alias("<API key>"))); void Vector8C(void) __attribute__((weak, alias("<API key>"))); void Vector90(void) __attribute__((weak, alias("<API key>"))); void Vector94(void) __attribute__((weak, alias("<API key>"))); void Vector98(void) __attribute__((weak, alias("<API key>"))); void Vector9C(void) __attribute__((weak, alias("<API key>"))); void VectorA0(void) __attribute__((weak, alias("<API key>"))); void VectorA4(void) __attribute__((weak, alias("<API key>"))); void VectorA8(void) __attribute__((weak, alias("<API key>"))); void VectorAC(void) __attribute__((weak, alias("<API key>"))); void VectorB0(void) __attribute__((weak, alias("<API key>"))); void VectorB4(void) __attribute__((weak, alias("<API key>"))); void VectorB8(void) __attribute__((weak, alias("<API key>"))); void VectorBC(void) __attribute__((weak, alias("<API key>"))); void VectorC0(void) __attribute__((weak, alias("<API key>"))); void VectorC4(void) __attribute__((weak, alias("<API key>"))); void VectorC8(void) __attribute__((weak, alias("<API key>"))); void VectorCC(void) __attribute__((weak, alias("<API key>"))); void VectorD0(void) __attribute__((weak, alias("<API key>"))); void VectorD4(void) __attribute__((weak, alias("<API key>"))); void VectorD8(void) __attribute__((weak, alias("<API key>"))); void VectorDC(void) __attribute__((weak, alias("<API key>"))); void VectorE0(void) __attribute__((weak, alias("<API key>"))); void VectorE4(void) __attribute__((weak, alias("<API key>"))); void VectorE8(void) __attribute__((weak, alias("<API key>"))); void VectorEC(void) __attribute__((weak, alias("<API key>"))); void VectorF0(void) __attribute__((weak, alias("<API key>")));
<?php class <API key> extends <API key> { public function testInit() { $this->dbh = new <API key>('mysql'); $this->conn = Doctrine_Manager::getInstance()->openConnection($this->dbh); $this->conn->setCharset('utf8'); $this->conn->setAttribute(Doctrine_Core::<API key>, true); } public function prepareData() { } public function prepareTables() { $this->tables = array(); $this->tables[] = 'T1365_Person'; $this->tables[] = 'T1365_Skill'; $this->tables[] = '<API key>'; parent :: prepareTables(); } public function testTicket() { $q = Doctrine_Query::create() ->select('s.*, phs.*') ->from('T1365_Skill s') ->leftJoin('s.<API key> phs') ->where('phs.value0 > phs.value1'); $this->assertEqual( $q->getSqlQuery(), 'SELECT l.id AS l__id, l.name AS l__name, ' . 'l2.id AS l2__id, l2.fk_person_id AS l2__fk_person_id, l2.fk_skill_id AS l2__fk_skill_id, l2.value0 AS l2__value0, l2.value1 AS l2__value1 ' . 'FROM la__skill l LEFT JOIN <API key> l2 ON l.id = l2.fk_skill_id ' . 'WHERE (l2.value0 > l2.value1)' ); } } class T1365_Person extends Doctrine_Record { public function setTableDefinition() { $this->setTableName('la__person'); $this->hasColumn('name', 'string', 255); } public function setUp() { $this->hasMany('<API key>', array('local' => 'id', 'foreign' => 'fk_person_id')); } } class T1365_Skill extends Doctrine_Record { public function setTableDefinition() { $this->setTableName('la__skill'); $this->hasColumn('name', 'string', 255); } public function setUp() { $this->hasMany('<API key>', array('local' => 'id', 'foreign' => 'fk_skill_id')); } } class <API key> extends Doctrine_Record { public function setTableDefinition() { $this->setTableName('<API key>'); $this->hasColumn('fk_person_id', 'integer', 8, array( 'type' => 'integer', 'length' => '8' )); $this->hasColumn('fk_skill_id', 'integer', 8, array( 'type' => 'integer', 'length' => '8' )); $this->hasColumn('value0', 'enum', 3, array( 'type' => 'enum', 'values' => array( 0 => '0', 1 => '1', 2 => '2', 3 => '3' ), 'default' => 0, 'notnull' => true, 'length' => '3' )); $this->hasColumn('value1', 'enum', 3, array( 'type' => 'enum', 'values' => array( 0 => '0', 1 => '1', 2 => '2', 3 => '3' ), 'default' => 0, 'notnull' => true, 'length' => '3' )); } public function setUp() { $this->hasOne('T1365_Person', array('local' => 'fk_person_id', 'foreign' => 'id')); $this->hasOne('T1365_Skill', array('local' => 'fk_skill_id', 'foreign' => 'id')); } }
// file at the top-level directory of this distribution and at // option. This file may not be copied, modified, or distributed // except according to those terms. fn matcher(x: Option<isize>) { match x { ref Some(i) => {} //~ ERROR expected identifier, found enum pattern None => {} } } fn main() {}
module Vmdb module Initializer def self.init _log.info "- Program Name: #{$PROGRAM_NAME}, PID: #{Process.pid}, ENV['MIQ_GUID']: #{ENV['MIQ_GUID']}, ENV['EVMSERVER']: #{ENV['EVMSERVER']}" # When these classes are deserialized in ActiveRecord (e.g. EmsEvent, MiqQueue), they need to be preloaded require 'VMwareWebService/VimTypes' # UiWorker called in Development Mode # * command line(rails server) # * debugger if defined?(Rails::Server) # <API key> depends on seeding, principally MiqDatabase EvmDatabase.seed_primordial MiqUiWorker.<API key> MiqServer.my_server.<API key> MiqServer.my_server.update_attributes(:status => "started") end # Rails console needs session store configured if defined?(Rails::Console) MiqUiWorker.preload_for_console end end end end
from fabric.api import * import fabric.contrib.project as project import os import shutil import sys import SocketServer from pelican.server import <API key> # Local path configuration (can be absolute or relative to fabfile) env.deploy_path = 'output' DEPLOY_PATH = env.deploy_path # Remote server configuration production = 'root@localhost:22' dest_path = '/var/www' # Rackspace Cloud Files configuration settings env.cloudfiles_username = '<API key>' env.cloudfiles_<TwitterConsumerkey>' env.<API key> = '<API key>' # Github Pages configuration env.github_pages_branch = "master" # Port for `serve` PORT = 8000 def clean(): """Remove generated files""" if os.path.isdir(DEPLOY_PATH): shutil.rmtree(DEPLOY_PATH) os.makedirs(DEPLOY_PATH) def build(): """Build local version of site""" local('pelican -s pelicanconf.py') def rebuild(): """`build` with the delete switch""" local('pelican -d -s pelicanconf.py') def regenerate(): """Automatically regenerate site upon file modification""" local('pelican -r -s pelicanconf.py') def serve(): os.chdir(env.deploy_path) class <API key>(SocketServer.TCPServer): allow_reuse_address = True server = <API key>(('', PORT), <API key>) sys.stderr.write('Serving on port {0} ...\n'.format(PORT)) server.serve_forever() def reserve(): """`build`, then `serve`""" build() serve() def preview(): """Build production version of site""" local('pelican -s publishconf.py') def cf_upload(): """Publish to Rackspace Cloud Files""" rebuild() with lcd(DEPLOY_PATH): local('swift -v -A https://auth.api.rackspacecloud.com/v1.0 ' '-U {cloudfiles_username} ' '-K {cloudfiles_api_key} ' 'upload -c {<API key>} .'.format(**env)) @hosts(production) def publish(): """Publish to production via rsync""" local('pelican -s publishconf.py') project.rsync_project( remote_dir=dest_path, exclude=".DS_Store", local_dir=DEPLOY_PATH.rstrip('/') + '/', delete=True, extra_opts='-c', ) def gh_pages(): """Publish to GitHub Pages""" rebuild() local("ghp-import -b {github_pages_branch} {deploy_path} -p".format(**env))
package com.intellij.lang.jvm.actions; public interface <API key> extends <API key> { }
package com.baidu.disconf.web.service.user.vo; public class VisitorVo { private Long id; private String name; private String role; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getRole() { return role; } public void setRole(String role) { this.role = role; } @Override public String toString() { return "VisitorVo [id=" + id + ", name=" + name + ", role=" + role + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((role == null) ? 0 : role.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } VisitorVo other = (VisitorVo) obj; if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (role == null) { if (other.role != null) { return false; } } else if (!role.equals(other.role)) { return false; } return true; } }
package org.opencv.samples.puzzle15; import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.Scalar; import org.opencv.core.Size; import org.opencv.core.Point; import org.opencv.imgproc.Imgproc; import android.util.Log; /** * This class is a controller for puzzle game. * It converts the image from Camera into the shuffled image */ public class Puzzle15Processor { private static final int GRID_SIZE = 4; private static final int GRID_AREA = GRID_SIZE * GRID_SIZE; private static final int GRID_EMPTY_INDEX = GRID_AREA - 1; private static final String TAG = "Puzzle15Processor"; private static final Scalar GRID_EMPTY_COLOR = new Scalar(0x33, 0x33, 0x33, 0xFF); private int[] mIndexes; private int[] mTextWidths; private int[] mTextHeights; private Mat mRgba15; private Mat[] mCells15; private boolean mShowTileNumbers = true; public Puzzle15Processor() { mTextWidths = new int[GRID_AREA]; mTextHeights = new int[GRID_AREA]; mIndexes = new int [GRID_AREA]; for (int i = 0; i < GRID_AREA; i++) mIndexes[i] = i; } /* this method is intended to make processor prepared for a new game */ public synchronized void prepareNewGame() { do { shuffle(mIndexes); } while (!isPuzzleSolvable()); } /* This method is to make the processor know the size of the frames that * will be delivered via puzzleFrame. * If the frames will be different size - then the result is unpredictable */ public synchronized void prepareGameSize(int width, int height) { mRgba15 = new Mat(height, width, CvType.CV_8UC4); mCells15 = new Mat[GRID_AREA]; for (int i = 0; i < GRID_SIZE; i++) { for (int j = 0; j < GRID_SIZE; j++) { int k = i * GRID_SIZE + j; mCells15[k] = mRgba15.submat(i * height / GRID_SIZE, (i + 1) * height / GRID_SIZE, j * width / GRID_SIZE, (j + 1) * width / GRID_SIZE); } } for (int i = 0; i < GRID_AREA; i++) { Size s = Imgproc.getTextSize(Integer.toString(i + 1), 3/* <API key> */, 1, 2, null); mTextHeights[i] = (int) s.height; mTextWidths[i] = (int) s.width; } } /* this method to be called from the outside. it processes the frame and shuffles * the tiles as specified by mIndexes array */ public synchronized Mat puzzleFrame(Mat inputPicture) { Mat[] cells = new Mat[GRID_AREA]; int rows = inputPicture.rows(); int cols = inputPicture.cols(); rows = rows - rows%4; cols = cols - cols%4; for (int i = 0; i < GRID_SIZE; i++) { for (int j = 0; j < GRID_SIZE; j++) { int k = i * GRID_SIZE + j; cells[k] = inputPicture.submat(i * inputPicture.rows() / GRID_SIZE, (i + 1) * inputPicture.rows() / GRID_SIZE, j * inputPicture.cols()/ GRID_SIZE, (j + 1) * inputPicture.cols() / GRID_SIZE); } } rows = rows - rows%4; cols = cols - cols%4; // copy shuffled tiles for (int i = 0; i < GRID_AREA; i++) { int idx = mIndexes[i]; if (idx == GRID_EMPTY_INDEX) mCells15[i].setTo(GRID_EMPTY_COLOR); else { cells[idx].copyTo(mCells15[i]); if (mShowTileNumbers) { Imgproc.putText(mCells15[i], Integer.toString(1 + idx), new Point((cols / GRID_SIZE - mTextWidths[idx]) / 2, (rows / GRID_SIZE + mTextHeights[idx]) / 2), 3/* <API key> */, 1, new Scalar(255, 0, 0, 255), 2); } } } for (int i = 0; i < GRID_AREA; i++) cells[i].release(); drawGrid(cols, rows, mRgba15); return mRgba15; } public void toggleTileNumbers() { mShowTileNumbers = !mShowTileNumbers; } public void deliverTouchEvent(int x, int y) { int rows = mRgba15.rows(); int cols = mRgba15.cols(); int row = (int) Math.floor(y * GRID_SIZE / rows); int col = (int) Math.floor(x * GRID_SIZE / cols); if (row < 0 || row >= GRID_SIZE || col < 0 || col >= GRID_SIZE) { Log.e(TAG, "It is not expected to get touch event outside of picture"); return ; } int idx = row * GRID_SIZE + col; int idxtoswap = -1; // left if (idxtoswap < 0 && col > 0) if (mIndexes[idx - 1] == GRID_EMPTY_INDEX) idxtoswap = idx - 1; // right if (idxtoswap < 0 && col < GRID_SIZE - 1) if (mIndexes[idx + 1] == GRID_EMPTY_INDEX) idxtoswap = idx + 1; // top if (idxtoswap < 0 && row > 0) if (mIndexes[idx - GRID_SIZE] == GRID_EMPTY_INDEX) idxtoswap = idx - GRID_SIZE; // bottom if (idxtoswap < 0 && row < GRID_SIZE - 1) if (mIndexes[idx + GRID_SIZE] == GRID_EMPTY_INDEX) idxtoswap = idx + GRID_SIZE; // swap if (idxtoswap >= 0) { synchronized (this) { int touched = mIndexes[idx]; mIndexes[idx] = mIndexes[idxtoswap]; mIndexes[idxtoswap] = touched; } } } private void drawGrid(int cols, int rows, Mat drawMat) { for (int i = 1; i < GRID_SIZE; i++) { Imgproc.line(drawMat, new Point(0, i * rows / GRID_SIZE), new Point(cols, i * rows / GRID_SIZE), new Scalar(0, 255, 0, 255), 3); Imgproc.line(drawMat, new Point(i * cols / GRID_SIZE, 0), new Point(i * cols / GRID_SIZE, rows), new Scalar(0, 255, 0, 255), 3); } } private static void shuffle(int[] array) { for (int i = array.length; i > 1; i int temp = array[i - 1]; int randIx = (int) (Math.random() * i); array[i - 1] = array[randIx]; array[randIx] = temp; } } private boolean isPuzzleSolvable() { int sum = 0; for (int i = 0; i < GRID_AREA; i++) { if (mIndexes[i] == GRID_EMPTY_INDEX) sum += (i / GRID_SIZE) + 1; else { int smaller = 0; for (int j = i + 1; j < GRID_AREA; j++) { if (mIndexes[j] < mIndexes[i]) smaller++; } sum += smaller; } } return sum % 2 == 0; } }
// <API key> is used to check the current CPU usage and triggers a // callback when getting over a specified threshold. #ifndef <API key> #define <API key> #include "system_wrappers/interface/scoped_ptr.h" #include "typedefs.h" // NOLINT #include "video_engine/vie_defines.h" namespace webrtc { class CpuWrapper; class <API key>; class EventWrapper; class ThreadWrapper; class ViEBaseObserver; class <API key> { public: explicit <API key>(int engine_id); ~<API key>(); int Init(ViEBaseObserver* vie_base_observer); void Terminate(); bool <API key>(); protected: static bool <API key>(void* obj); bool ViEMonitorProcess(); private: const int engine_id_; // TODO(mfldoman) Make this one scoped_ptr. <API key>* pointer_cs_; ThreadWrapper* monitor_thread_; EventWrapper& monitor_event_; CpuWrapper* cpu_; ViEBaseObserver* vie_base_observer_; }; } // namespace webrtc #endif // <API key>
#include "apps/<API key>.h" #include "apps/<API key>.h" #include "apps/app_window_registry.h" #include "chrome/browser/profiles/profile.h" #include "components/keyed_service/content/<API key>.h" #include "extensions/browser/<API key>.h" namespace apps { // static AppLifetimeMonitor* <API key>::GetForProfile(Profile* profile) { return static_cast<AppLifetimeMonitor*>( GetInstance()-><API key>(profile, false)); } <API key>* <API key>::GetInstance() { return Singleton<<API key>>::get(); } <API key>::<API key>() : <API key>( "AppLifetimeMonitor", <API key>::GetInstance()) { DependsOn(AppWindowRegistry::Factory::GetInstance()); } <API key>::~<API key>() {} KeyedService* <API key>::<API key>( content::BrowserContext* profile) const { return new AppLifetimeMonitor(static_cast<Profile*>(profile)); } bool <API key>::<API key>() const { return true; } content::BrowserContext* <API key>::<API key>( content::BrowserContext* context) const { return extensions::<API key>::Get()-> GetOriginalContext(context); } } // namespace apps
#include "chrome/browser/ui/views/status_icons/status_tray_linux.h" #include "build/build_config.h" #if !defined(OS_CHROMEOS) #include "chrome/browser/ui/views/status_icons/<API key>.h" #include "ui/views/linux_ui/linux_ui.h" StatusTrayLinux::StatusTrayLinux() { } StatusTrayLinux::~StatusTrayLinux() { } StatusIcon* StatusTrayLinux::<API key>( StatusIconType type, const gfx::ImageSkia& image, const base::string16& tool_tip) { return <API key>::<API key>(image, tool_tip); } StatusTray* StatusTray::Create() { const views::LinuxUI* linux_ui = views::LinuxUI::instance(); // Only create a status tray if we can actually create status icons. if (linux_ui && linux_ui-><API key>()) return new StatusTrayLinux(); return NULL; } #else // defined(OS_CHROMEOS) StatusTray* StatusTray::Create() { return NULL; } #endif
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>body</title> <style type="text/css" media="screen"> body { margin: 1px; padding: 5px; } #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; } </style> <script src="../include_js.php"></script> <script type="text/javascript" charset="utf-8"> jQuery(function($) { $('body').click(function() { $('#marker').css( $(this).offset() ); return false; }); }); </script> </head> <body> <div id="marker"></div> </body> </html>
/** * The production x >>>= y is the same as x = x >>> y * * @path ch11/11.13/11.13.2/S11.13.2_A4.8_T1.3.js * @description Type(x) and Type(y) vary between primitive string and String object */ //CHECK x = "1"; x >>>= "1"; if (x !== 0) { $ERROR(' } //CHECK x = new String("1"); x >>>= "1"; if (x !== 0) { $ERROR(' } //CHECK x = "1"; x >>>= new String("1"); if (x !== 0) { $ERROR(' } //CHECK x = new String("1"); x >>>= new String("1"); if (x !== 0) { $ERROR(' } //CHECK x = "x"; x >>>= "1"; if (x !== 0) { $ERROR(' } //CHECK x = "1"; x >>>= "x"; if (x !== 1) { $ERROR(' }
Copyright (c) 2012 Ecma International. All rights reserved. /** * @path ch11/11.4/11.4.1/11.4.1-5-a-27-s.js * @description Strict Mode - TypeError is thrown after deleting a property, calling preventExtensions, and attempting to reassign the property * @onlyStrict */ function testcase() { "use strict"; var a = {x:0, get y() { return 0;}}; delete a.x; Object.preventExtensions(a); try { a.x = 1; return false; } catch (e) { return e instanceof TypeError; } } runTestCase(testcase);
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/tr",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n=t+" karakter daha girmelisiniz";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="En az "+t+" karakter daha girmelisiniz";return n},loadingMore:function(){return"Daha fazla…"},maximumSelected:function(e){var t="Sadece "+e.maximum+" seçim yapabilirsiniz";return t},noResults:function(){return"Sonuç bulunamadı"},searching:function(){return"Aranıyor…"}}}),{define:e.define,require:e.require}})();
<! Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ <!DOCTYPE html> <title>CSS Test: Test declaring a variable that consists of a comma-separated font family list with the comma coming from a variable reference.</title> <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au"> <link rel="help" href="http://www.w3.org/TR/css-variables-1/#syntax"> <link rel="match" href="<API key>.html"> <meta name="flags" content="ahem"> <link rel="stylesheet" href="/fonts/ahem.css" type="text/css"> <style> body { font-family: serif; } p { font-family: monospace; --a: Ahem var(--b) sans-serif; --b: ,; font-family: var(--a); } </style> <p>This text must be in Ahem.</p>
Copyright (c) 2012 Ecma International. All rights reserved. /** * @path ch15/15.2/15.2.3/15.2.3.5/15.2.3.5-4-258.js * @description Object.create - 'get' property of one property in 'Properties' is the primitive value null (8.10.5 step 7.b) */ function testcase() { try { Object.create({}, { prop: { get: null } }); return false; } catch (e) { return (e instanceof TypeError); } } runTestCase(testcase);
module.exports = require('./lib/socket.io');
var _complement = require('./internal/_complement'); var _curry2 = require('./internal/_curry2'); var filter = require('./filter'); module.exports = _curry2(function reject(fn, list) { return filter(_complement(fn), list); });
# Usage Comparison Between dojox/grid and dgrid ## Simple programmatic usage Given the following programmatic example using `dojox/grid`... js require(["dojox/grid/DataGrid", "dojo/store/Memory", "dojo/data/ObjectStore", "dojo/domReady!"], function(DataGrid, Memory, ObjectStore){ var memoryStore = new Memory({data: [ // data here... ]}); var objectStore = new ObjectStore({ objectStore: memoryStore }); var grid = new DataGrid({ structure: [ { field: "id", name: "ID", width: "10%" }, { field: "name", name: "Name", width: "20%" }, { field: "description", name: "Description", width: "70%" } ], store: objectStore }, "grid"); grid.startup(); }); A result similar to the above example could be achieved using dgrid with the following styles... css #dgrid .field-id { width: 10%; } #dgrid .field-name { width: 20%; } #dgrid .field-description { width: 70%; } and the following JavaScript... js require(["dgrid/OnDemandGrid", "dgrid/Keyboard", "dgrid/Selection", "dojo/_base/declare", "dojo/store/Memory", "dojo/domReady!"], function(OnDemandGrid, Keyboard, Selection, declare, Memory){ var memoryStore = new Memory({data: [ // data here... ]}); var grid = new declare([OnDemandGrid, Keyboard, Selection])({ columns: { id: { label: "ID" }, name: { label: "Name" }, description: { label: "Description" } }, store: memoryStore }, "grid"); // dgrid will call startup for you if the node appears to be in flow }); There are a few key differences worth pointing out: * Whereas `dojox/grid` expects styles to be specified within the column definition to be eventually applied inline to all cells in the column, dgrid lets CSS do the talking whenever possible for purposes of layout and appearance. This allows for better separation between visual and functional concerns. * `dojox/grid` operates with stores implementing the earlier `dojo/data` APIs; in order to use it with a store instance implementing the `dojo/store` APIs, the store must first be wrapped using the `dojo/data/ObjectStore` module. On the other hand, dgrid communicates with `dojo/store` APIs out of the box. (Conversely, however, if you *do* need to work with a `dojo/data` store, you would then have to pass it through the `dojo/store/DataStore` wrapper in order for dgrid to work with it.) * Note that in the dgrid version of the example, the Selection and Keyboard modules are required and mixed into the constructor to be instantiated, in order to enable those pieces of functionality which are baked-in by default in `dojox/grid` components. * Also note that the dgrid example's structure is a bit more concise, taking advantage of the ability to provide simple column arrangements via an object hash instead of an array, in which case the object's keys double as the columns' `field` values (i.e., which store item properties the columns represent). ## Programmatic usage, with sub-rows Assuming the same context as the examples in the previous section, here is a contrived example demonstrating use of sub-rows in `dojox/grid`... js var grid = new DataGrid({ structure: [ [ { field: "id", name: "ID", width: "10%" }, { field: "name", name: "Name", width: "20%" } ], [ { field: "description", name: "Description", width: "70%", colSpan: 2 } ] ], store: objectStore }, "grid"); grid.startup(); and the equivalent, using dgrid... (again assuming the same context as the previous example) js var grid = new declare([OnDemandGrid, Keyboard, Selection])({ subRows: [ [ { field: "id", label: "ID" }, { field: "name", label: "Name" } ], [ { field: "description", label: "Description", colSpan: 2 } ] ], store: memoryStore }, "grid"); Notice that `subRows` is now defined instead of `columns`. The `columns` property of dgrid components is usable *only* for simple cases involving a single sub-row. Also notice that each item in the top-level `subRows` array is itself another array, containing an object for each column. In this case, `field` must be specified in each column definition object, since there is no longer an object hash in order to infer field names from keys. ## Using views / columnsets The `dojox/grid` components implement a concept known as "views", which are represented as separate horizontal regions within a single grid. This feature is generally useful for situations where many fields are to be shown, and some should remain visible while others are able to scroll horizontally. This capability is also available in dgrid, via the ColumnSet mixin. For instance, continuing in the vein of the examples in the previous two sections, the following `dojox/grid` structure with multiple views... js var grid = new DataGrid({ structure: [ { // first view width: "10%", cells: [ { field: "id", name: "ID", width: "auto" } ] }, [ // second view [ { field: "name", name: "Name", width: "20%" }, { field: "description", name: "Description", width: "80%" } ] ] ], store: objectStore }, "grid"); grid.startup(); could be represented in dgrid, using the following CSS... css #dgrid .dgrid-column-set-0 { width: 10%; } #dgrid .field-name { width: 20%; } #dgrid .field-description { width: 80%; } and the following JavaScript... (require call included, to demonstrate additional dependency) js require(["dgrid/OnDemandGrid", "dgrid/ColumnSet", "dgrid/Keyboard", "dgrid/Selection", "dojo/_base/declare", "dojo/store/Memory", "dojo/domReady!"], function(OnDemandGrid, ColumnSet, Keyboard, Selection, declare, Memory){ // ... create memoryStore here ... var grid = new declare([OnDemandGrid, ColumnSet, Keyboard, Selection])({ columnSets: [ [ // first columnSet [ { field: "id", label: "ID" } ] ], [ // second columnSet [ { field: "name", label: "Name" }, { field: "description", label: "Description" } ] ] ], store: memoryStore }, "grid"); }); ## Specifying column layout via HTML While programmatic creation of grids is highly encouraged, dgrid does allow for declarative specification of grid layouts via a `table` element, somewhat along the same lines of `dojox/grid`. In the case of dgrid, this ability is not baked in by default, but is instead exposed primarily by the GridFromHtml module, which adds table-scanning capabilities atop the OnDemandGrid constructor. Note that unlike `dojox/grid`, which is *only* capable of reading declarative layouts through the use of `dojo/parser`, dgrid is also capable of creating instances programmatically while referencing a `table` node from which to read a declarative layout. For the purposes of the examples below, use of parser will be assumed, in order to allow comparison between `dojox/grid` and dgrid usage. For instance, the following declarative `dojox/grid` layout... html <table id="grid" data-dojo-type="dojox.grid.DataGrid" data-dojo-props="store: objectStore"> <thead> <tr> <th field="id" width="10%">ID</th> <th field="name" width="20%">Name</th> <th field="description" width="70%">Description</th> </tr> </thead> </table> could be achieved declaratively using dgrid as follows... html <table id="grid" data-dojo-type="dgrid.CustomGrid" data-dojo-props="store: memoryStore"> <thead> <tr> <th data-dgrid-column="{ field: 'id' }">ID</th> <th data-dgrid-column="{ field: 'name' }">Name</th> <th data-dgrid-column="{ field: 'description' }">Description</th> </tr> </thead> </table> provided the following script is used... js require(["dgrid/GridFromHtml", "dgrid/Keyboard", "dgrid/Selection", "dojo/store/Memory", "dojo/_base/declare", "dojo/parser", "dojo/domReady!"], function(GridFromHtml, Keyboard, Selection, Memory, declare, parser){ var memoryStore = window.memoryStore = new Memory({data: [ // ... data here ... ]}); // Globally expose a Grid constructor including the mixins we want. window.dgrid = { CustomGrid: declare([GridFromHtml, Keyboard, Selection]) }; // Parse the markup after exposing the global. parser.parse(); }); Notice that rather than specifying individual non-standard attributes inside the `th` elements, declarative layout specification with dgrid centers primarily around a data-attribute named `data-dgrid-column`. This attribute receives a string representation of a JavaScript object, which will ultimately become the basis for the column definition. (It operates much like `data-dojo-props`, except that the surrounding curly braces must be included.) Note that some properties which have standard equivalents, such as `colspan` and `rowspan`, can be specified directly as HTML attributes in the element instead. Additionally, the innerHTML of the `th` becomes the column's label. The script block above demonstrates the main catch to using dgrid declaratively with `dojo/parser`: since the modules in the dgrid package are written to be pure AMD, they do not expose globals, which means whatever constructors are to be used need to be exposed manually. Furthermore, rather than simply exposing the GridFromHtml constructor, the above example exposes a custom-declared constructor which mixes in desired functionality. Note that if column plugins are to be employed, these will also need to be similarly globally exposed. Column plugins may be specified in the column definitions of declarative grid layouts within the `data-dgrid-column` attribute; for example: html <th data-dgrid-column="dgrid.editor({ field: 'name', editOn: 'dblclick' })">Name</th> Column Layout via HTML with views / columnsets While both `dojox/grid` and dgrid also enable declarative creation of grids with multiple views/columnsets, in dgrid's case this is again separated to its own module, <API key>. This separation exists due to the significant amount of additional code necessary to resolve columnsets from the representative markup, combined with the relative rarity of cases calling for the additional functionality. As a quick example, here is what a simple declarative grid with two views could look like with `dojox/grid`... html <table id="grid" data-dojo-type="dojox.grid.DataGrid" data-dojo-props="store: objectStore"> <colgroup span="1" width="10%"></colgroup> <colgroup span="2"></colgroup> <thead> <tr> <th field="id" width="auto">ID</th> <th field="name" width="20%">Name</th> <th field="description" width="80%">Description</th> </tr> </thead> </table> and here is the equivalent, using dgrid... (this assumes the same styles are in play as the earlier programmatic ColumnSet example) html <table id="grid" data-dojo-type="dgrid.CustomGrid" data-dojo-props="store: memoryStore"> <colgroup span="1"></colgroup> <colgroup span="2"></colgroup> <thead> <tr> <th data-dgrid-column="{ field: 'id' }">ID</th> <th data-dgrid-column="{ field: 'name' }">Name</th> <th data-dgrid-column="{ field: 'description' }">Description</th> </tr> </thead> </table> ## Events `dojox/grid` and dgrid take significantly different approaches to handling events. `dojox/grid` provides a wide selection of stub methods which can be connected to in order to react to many common events on rows or cells in the header or body. The [Working with Grids](http://dojotoolkit.org/documentation/tutorials/1.7/working_grid/) tutorial gives an idea of what kinds of events are supported by `dojox/grid`. On the other hand, dgrid leaves it up to the developer as to which events are at all worth listening for. This results in generally far less overhead, since listeners are hooked up only for events of interest; at the same time, it still allows for the same range of event listeners as `dojox/grid`. `dojox/grid` components generally attach any useful information directly to the event object received by the handler callback. While dgrid does this to a certain degree for custom events, the most commonly-sought information is retrievable using the `row` and `cell` methods. See [Working with Events](../usage/Working-with-Events.md) for more information. As a quick side-by-side comparison, here is an example logging the name property of an item whose row was clicked, using `dojox/grid`... js grid.connect(grid, "onRowClick", function(evt){ var item = grid.getItem(evt.rowIndex); // don't forget to use store.getValue, since dojox/grid uses a dojo/data store console.log("Clicked item with name: " + grid.store.getValue(item, "name")); }); and using dgrid... js grid.on(".dgrid-row:click", function(evt){ var item = grid.row(evt).data; console.log("Clicked item with name: " + item.name); });
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.<API key>(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); var context_1 = require("./context/context"); var LINE_SEPARATOR = '\r\n'; var XmlFactory = (function () { function XmlFactory() { } XmlFactory.prototype.createXml = function (xmlElement, booleanTransformer) { var _this = this; var props = ""; if (xmlElement.properties) { if (xmlElement.properties.prefixedAttributes) { xmlElement.properties.prefixedAttributes.forEach(function (prefixedSet) { Object.keys(prefixedSet.map).forEach(function (key) { props += _this.<API key>(prefixedSet.prefix + key, prefixedSet.map[key], booleanTransformer); }); }); } if (xmlElement.properties.rawMap) { Object.keys(xmlElement.properties.rawMap).forEach(function (key) { props += _this.<API key>(key, xmlElement.properties.rawMap[key], booleanTransformer); }); } } var result = "<" + xmlElement.name + props; if (!xmlElement.children && !xmlElement.textNode) { return result + "/>" + LINE_SEPARATOR; } if (xmlElement.textNode) { return result + ">" + xmlElement.textNode + "</" + xmlElement.name + ">" + LINE_SEPARATOR; } result += ">" + LINE_SEPARATOR; xmlElement.children.forEach(function (it) { result += _this.createXml(it, booleanTransformer); }); return result + "</" + xmlElement.name + ">" + LINE_SEPARATOR; }; XmlFactory.prototype.<API key> = function (key, value, booleanTransformer) { if (!value) { return ""; } var xmlValue = value; if ((typeof (value) === 'boolean')) { if (booleanTransformer) { xmlValue = booleanTransformer(value); } } xmlValue = '"' + xmlValue + '"'; return " " + key + "=" + xmlValue; }; return XmlFactory; }()); XmlFactory = __decorate([ context_1.Bean('xmlFactory') ], XmlFactory); exports.XmlFactory = XmlFactory;
/** * High performant way to check whether an element with a specific class name is in the given document * Optimized for being heavily executed * Unleashes the power of live node lists * * @param {Object} doc The document object of the context where to check * @param {String} tagName Upper cased tag name * @example * wysihtml5.dom.<API key>(document, "foobar"); */ (function(wysihtml5) { var LIVE_CACHE = {}, DOCUMENT_IDENTIFIER = 1; function <API key>(doc) { return doc.<API key> || (doc.<API key> = DOCUMENT_IDENTIFIER++); } wysihtml5.dom.<API key> = function(doc, className) { // <API key> is not supported by IE<9 // but is sometimes mocked via library code (which then doesn't return live node lists) if (!wysihtml5.browser.<API key>()) { return !!doc.querySelector("." + className); } var key = <API key>(doc) + ":" + className, cacheEntry = LIVE_CACHE[key]; if (!cacheEntry) { cacheEntry = LIVE_CACHE[key] = doc.<API key>(className); } return cacheEntry.length > 0; }; })(wysihtml5);
// $Id: <API key>.cpp 80826 2008-03-04 14:51:23Z wotte $ // below. It is not the actual code provided by Unicode, Inc. but is an // ACE-ified and only slightly modified version. // Chad Elliott 4/28/2005 // Limitations on Rights to Redistribute This Code // Unicode, Inc. hereby grants the right to freely use the information // supplied in this file in the creation of products supporting the // Unicode Standard, and to make copies of this file in any form // for internal or external distribution as long as this notice // remains attached. #include "ace/<API key>.h" #if defined (ACE_USES_WCHAR) #include "ace/OS_NS_stdio.h" #include "ace/OS_Memory.h" #include "ace/Min_Max.h" <API key> static const ACE_UINT32 UNI_MAX_LEGAL_UTF32 = 0x0010FFFF; <API key>::<API key> (bool swap) : <API key> (swap) { } <API key>::~<API key> (void) { } <API key>::Result <API key>::to_utf8 (const void* source, size_t source_size, ACE_Byte* target, size_t target_size, bool strict) { static const ACE_UINT32 byteMask = 0xBF; static const ACE_UINT32 byteMark = 0x80; static const ACE_UINT32 UNI_SUR_HIGH_START = <API key> (); static const ACE_UINT32 UNI_SUR_LOW_END = get_UNI_SUR_LOW_END (); static const ACE_Byte* firstByteMark = get_first_byte_mark (); Result result = CONVERSION_OK; ACE_Byte* targetEnd = target + target_size; const ACE_UINT32* sourceStart = static_cast<const ACE_UINT32*> (source); const ACE_UINT32* sourceEnd = sourceStart + (source_size / sizeof (ACE_UINT32)); while (sourceStart < sourceEnd) { ACE_UINT32 nw = *sourceStart++; ACE_UINT32 ch = (this->swap_ ? ACE_SWAP_LONG (nw) : nw); unsigned short bytesToWrite = 0; if (strict) { if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { result = SOURCE_ILLEGAL; break; } } // Figure out how many bytes the result will require. Turn any // chars. if (ch < 0x80) { bytesToWrite = 1; } else if (ch < 0x800) { bytesToWrite = 2; } else if (ch < 0x10000) { bytesToWrite = 3; } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4; } else { result = SOURCE_ILLEGAL; break; } target += bytesToWrite; if (target > targetEnd) { result = TARGET_EXHAUSTED; break; } // NOTE: everything falls through. switch (bytesToWrite) { case 4: *--target = (ACE_Byte)((ch | byteMark) & byteMask); ch >>= 6; case 3: *--target = (ACE_Byte)((ch | byteMark) & byteMask); ch >>= 6; case 2: *--target = (ACE_Byte)((ch | byteMark) & byteMask); ch >>= 6; case 1: *--target = (ACE_Byte) (ch | firstByteMark[bytesToWrite]); } target += bytesToWrite; } return result; } <API key>::Result <API key>::from_utf8 (const ACE_Byte* source, size_t source_size, void* target, size_t target_size, bool strict) { static const ACE_UINT32 UNI_SUR_HIGH_START = <API key> (); static const ACE_UINT32 UNI_SUR_LOW_END = get_UNI_SUR_LOW_END (); static const ACE_UINT32 <API key> = <API key> (); static const ACE_Byte* <API key> = <API key> (); static const ACE_UINT32* offsetsFromUTF8 = <API key> (); Result result = CONVERSION_OK; const ACE_Byte* sourceEnd = source + source_size; ACE_UINT32* targetStart = static_cast<ACE_UINT32*> (target); ACE_UINT32* targetEnd = targetStart + target_size; while (source < sourceEnd) { ACE_UINT32 ch = 0; unsigned short extraBytesToRead = <API key>[*source]; if (source + extraBytesToRead >= sourceEnd) { result = SOURCE_EXHAUSTED; break; } // Do this check whether lenient or strict if (!this->is_legal_utf8 (source, extraBytesToRead + 1)) { result = SOURCE_ILLEGAL; break; } // The cases all fall through. See "Note A" below. switch (extraBytesToRead) { case 5: ch += *source++; ch <<= 6; case 4: ch += *source++; ch <<= 6; case 3: ch += *source++; ch <<= 6; case 2: ch += *source++; ch <<= 6; case 1: ch += *source++; ch <<= 6; case 0: ch += *source++; } ch -= offsetsFromUTF8[extraBytesToRead]; if (targetStart >= targetEnd) { result = TARGET_EXHAUSTED; break; } if (ch <= UNI_MAX_LEGAL_UTF32) { if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { if (strict) { result = SOURCE_ILLEGAL; break; } else { *targetStart++ = <API key>; } } else { *targetStart++ = ch; } } else { result = SOURCE_ILLEGAL; break; } } return result; } <API key>* <API key>::encoded (const ACE_Byte* source, size_t source_size) { static const size_t begin = 16; static const size_t converted = begin * 4; ACE_Byte target[converted]; <API key>* converter = 0; ACE_NEW_RETURN (converter, <API key> (false), 0); if (converter->to_utf8 (source, ACE_MIN (begin, source_size), target, converted) == CONVERSION_OK) { return converter; } else { delete converter; } return 0; } <API key> #endif /* ACE_USES_WCHAR */
#pragma once #if defined(<API key>) #include <queue> #include "DVDVideoCodec.h" #include <CoreVideo/CoreVideo.h> #include <CoreMedia/CoreMedia.h> // tracks a frame in and output queue in display order typedef struct frame_queue { double dts; double pts; int width; int height; double sort_time; FourCharCode pixel_buffer_format; CVPixelBufferRef pixel_buffer_ref; struct frame_queue *nextframe; } frame_queue; class DllAvUtil; class DllAvFormat; class <API key> : public CDVDVideoCodec { public: <API key>(); virtual ~<API key>(); // Required overrides virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options); virtual void Dispose(void); virtual int Decode(BYTE *pData, int iSize, double dts, double pts); virtual void Reset(void); virtual bool GetPicture(DVDVideoPicture *pDvdVideoPicture); virtual bool ClearPicture(DVDVideoPicture* pDvdVideoPicture); virtual void SetDropState(bool bDrop); virtual const char* GetName(void) { return (const char*)m_pFormatName; } protected: void DisplayQueuePop(void); void CreateVTSession(int width, int height, <API key> fmt_desc); void DestroyVTSession(void); static void VTDecoderCallback( void *refcon, CFDictionaryRef frameInfo, OSStatus status, UInt32 infoFlags, CVBufferRef imageBuffer); void *m_vt_session; // opaque videotoolbox session <API key> m_fmt_desc; const char *m_pFormatName; bool m_DropPictures; DVDVideoPicture m_videobuffer; double m_sort_time_offset; pthread_mutex_t m_queue_mutex; // mutex protecting queue manipulation frame_queue *m_display_queue; // display-order queue - next display frame is always at the queue head int32_t m_queue_depth; // we will try to keep the queue depth at m_max_ref_frames int32_t m_max_ref_frames; bool <API key>; bool <API key>; DllAvUtil *m_dllAvUtil; DllAvFormat *m_dllAvFormat; }; #endif
/* * inode functions */ #include "aufs.h" struct inode *au_igrab(struct inode *inode) { if (inode) { AuDebugOn(!atomic_read(&inode->i_count)); atomic_inc_return(&inode->i_count); } return inode; } static void <API key>(struct inode *inode, int do_version) { au_cpup_attr_all(inode, /*force*/0); au_update_iigen(inode); if (do_version) inode->i_version++; } int <API key>(struct inode *inode, int do_attr) { int err; aufs_bindex_t bindex, new_bindex; unsigned char update; struct inode *first; struct au_hinode *p, *q, tmp; struct super_block *sb; struct au_iinfo *iinfo; IiMustWriteLock(inode); update = 0; sb = inode->i_sb; iinfo = au_ii(inode); err = au_ii_realloc(iinfo, au_sbend(sb) + 1); if (unlikely(err)) goto out; p = iinfo->ii_hinode + iinfo->ii_bstart; first = p->hi_inode; err = 0; for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend; bindex++, p++) { if (!p->hi_inode) continue; new_bindex = au_br_index(sb, p->hi_id); if (new_bindex == bindex) continue; if (new_bindex < 0) { update++; au_hiput(p); p->hi_inode = NULL; continue; } if (new_bindex < iinfo->ii_bstart) iinfo->ii_bstart = new_bindex; if (iinfo->ii_bend < new_bindex) iinfo->ii_bend = new_bindex; /* swap two lower inode, and loop again */ q = iinfo->ii_hinode + new_bindex; tmp = *q; *q = *p; *p = tmp; if (tmp.hi_inode) { bindex p } } au_update_brange(inode, /*do_put_zero*/0); if (do_attr) <API key>(inode, update && S_ISDIR(inode->i_mode)); out: return err; } int au_refresh_hinode(struct inode *inode, struct dentry *dentry) { int err, update; unsigned int flags; aufs_bindex_t bindex, bend; unsigned char isdir; struct inode *first; struct au_hinode *p; struct au_iinfo *iinfo; err = <API key>(inode, /*do_attr*/0); if (unlikely(err)) goto out; update = 0; iinfo = au_ii(inode); p = iinfo->ii_hinode + iinfo->ii_bstart; first = p->hi_inode; isdir = S_ISDIR(inode->i_mode); flags = au_hi_flags(inode, isdir); bend = au_dbend(dentry); for (bindex = au_dbstart(dentry); bindex <= bend; bindex++) { struct inode *h_i; struct dentry *h_d; h_d = au_h_dptr(dentry, bindex); if (!h_d || !h_d->d_inode) continue; if (iinfo->ii_bstart <= bindex && bindex <= iinfo->ii_bend) { h_i = au_h_iptr(inode, bindex); if (h_i) { if (h_i == h_d->d_inode) continue; err = -EIO; break; } } if (bindex < iinfo->ii_bstart) iinfo->ii_bstart = bindex; if (iinfo->ii_bend < bindex) iinfo->ii_bend = bindex; au_set_h_iptr(inode, bindex, au_igrab(h_d->d_inode), flags); update = 1; } au_update_brange(inode, /*do_put_zero*/0); if (unlikely(err)) goto out; <API key>(inode, update && isdir); out: AuTraceErr(err); return err; } static int set_inode(struct inode *inode, struct dentry *dentry) { int err; unsigned int flags; umode_t mode; aufs_bindex_t bindex, bstart, btail; unsigned char isdir; struct dentry *h_dentry; struct inode *h_inode; struct au_iinfo *iinfo; IiMustWriteLock(inode); err = 0; isdir = 0; bstart = au_dbstart(dentry); h_inode = au_h_dptr(dentry, bstart)->d_inode; mode = h_inode->i_mode; switch (mode & S_IFMT) { case S_IFREG: btail = au_dbtail(dentry); inode->i_op = &aufs_iop; inode->i_fop = &aufs_file_fop; inode->i_mapping->a_ops = &aufs_aop; break; case S_IFDIR: isdir = 1; btail = au_dbtaildir(dentry); inode->i_op = &aufs_dir_iop; inode->i_fop = &aufs_dir_fop; break; case S_IFLNK: btail = au_dbtail(dentry); inode->i_op = &aufs_symlink_iop; break; case S_IFBLK: case S_IFCHR: case S_IFIFO: case S_IFSOCK: btail = au_dbtail(dentry); inode->i_op = &aufs_iop; init_special_inode(inode, mode, h_inode->i_rdev); break; default: AuIOErr("Unknown file type 0%o\n", mode); err = -EIO; goto out; } /* do not set inotify for whiteouted dirs (SHWH mode) */ flags = au_hi_flags(inode, isdir); if (au_opt_test(au_mntflags(dentry->d_sb), SHWH) && au_ftest_hi(flags, HINOTIFY) && dentry->d_name.len > AUFS_WH_PFX_LEN && !memcmp(dentry->d_name.name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)) au_fclr_hi(flags, HINOTIFY); iinfo = au_ii(inode); iinfo->ii_bstart = bstart; iinfo->ii_bend = btail; for (bindex = bstart; bindex <= btail; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (h_dentry) au_set_h_iptr(inode, bindex, au_igrab(h_dentry->d_inode), flags); } au_cpup_attr_all(inode, /*force*/1); out: return err; } /* successful returns with iinfo write_locked */ static int reval_inode(struct inode *inode, struct dentry *dentry, int *matched) { int err; aufs_bindex_t bindex, bend; struct inode *h_inode, *h_dinode; *matched = 0; /* * before this function, if aufs got any iinfo lock, it must be only * one, the parent dir. * it can happen by UDBA and the obsoleted inode number. */ err = -EIO; if (unlikely(inode->i_ino == parent_ino(dentry))) goto out; err = 0; <API key>(inode); h_dinode = au_h_dptr(dentry, au_dbstart(dentry))->d_inode; bend = au_ibend(inode); for (bindex = au_ibstart(inode); bindex <= bend; bindex++) { h_inode = au_h_iptr(inode, bindex); if (h_inode && h_inode == h_dinode) { *matched = 1; err = 0; if (au_iigen(inode) != au_digen(dentry)) err = au_refresh_hinode(inode, dentry); break; } } if (unlikely(err)) ii_write_unlock(inode); out: return err; } int au_ino(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino, unsigned int d_type, ino_t *ino) { int err; struct mutex *mtx; const int isdir = (d_type == DT_DIR); /* prevent hardlinks from race condition */ mtx = NULL; if (!isdir) { mtx = &au_sbr(sb, bindex)->br_xino.xi_nondir_mtx; mutex_lock(mtx); } err = au_xino_read(sb, bindex, h_ino, ino); if (unlikely(err)) goto out; if (!*ino) { err = -EIO; *ino = au_xino_new_ino(sb); if (unlikely(!*ino)) goto out; err = au_xino_write(sb, bindex, h_ino, *ino); if (unlikely(err)) goto out; } out: if (!isdir) mutex_unlock(mtx); return err; } /* successful returns with iinfo write_locked */ /* todo: return with unlocked? */ struct inode *au_new_inode(struct dentry *dentry, int must_new) { struct inode *inode; struct dentry *h_dentry; struct super_block *sb; ino_t h_ino, ino; int err, match; aufs_bindex_t bstart; sb = dentry->d_sb; bstart = au_dbstart(dentry); h_dentry = au_h_dptr(dentry, bstart); h_ino = h_dentry->d_inode->i_ino; err = au_xino_read(sb, bstart, h_ino, &ino); inode = ERR_PTR(err); if (unlikely(err)) goto out; new_ino: if (!ino) { ino = au_xino_new_ino(sb); if (unlikely(!ino)) { inode = ERR_PTR(-EIO); goto out; } } AuDbg("i%lu\n", (unsigned long)ino); inode = au_iget_locked(sb, ino); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out; AuDbg("%lx, new %d\n", inode->i_state, !!(inode->i_state & I_NEW)); if (inode->i_state & I_NEW) { <API key>(inode); err = set_inode(inode, dentry); unlock_new_inode(inode); if (!err) goto out; /* success */ iget_failed(inode); ii_write_unlock(inode); goto out_iput; } else if (!must_new) { err = reval_inode(inode, dentry, &match); if (!err) goto out; /* success */ else if (match) goto out_iput; } if (unlikely(<API key>(h_dentry->d_inode))) AuWarn1("Warning: Un-notified UDBA or repeatedly renamed dir," " b%d, %s, %.*s, hi%lu, i%lu.\n", bstart, au_sbtype(h_dentry->d_sb), AuDLNPair(dentry), (unsigned long)h_ino, (unsigned long)ino); ino = 0; err = au_xino_write(sb, bstart, h_ino, /*ino*/0); if (!err) { iput(inode); goto new_ino; } out_iput: iput(inode); inode = ERR_PTR(err); out: return inode; } int au_test_ro(struct super_block *sb, aufs_bindex_t bindex, struct inode *inode) { int err; err = au_br_rdonly(au_sbr(sb, bindex)); /* pseudo-link after flushed may happen out of bounds */ if (!err && inode && au_ibstart(inode) <= bindex && bindex <= au_ibend(inode)) { struct inode *hi = au_h_iptr(inode, bindex); if (hi) err = IS_IMMUTABLE(hi) ? -EROFS : 0; } return err; } int au_test_h_perm(struct inode *h_inode, int mask) { if (!current_fsuid()) return 0; return inode_permission(h_inode, mask); } int au_test_h_perm_sio(struct inode *h_inode, int mask) { if (au_test_nfs(h_inode->i_sb) && (mask & MAY_WRITE) && S_ISDIR(h_inode->i_mode)) mask |= MAY_READ; return au_test_h_perm(h_inode, mask); }
// <API key>: GPL-2.0 #include <linux/delay.h> #include <linux/ktime.h> #include "tb.h" #define USB4_DATA_DWORDS 16 #define USB4_DATA_RETRIES 3 enum usb4_switch_op { <API key> = 0x10, <API key> = 0x11, <API key> = 0x12, <API key> = 0x20, <API key> = 0x21, <API key> = 0x22, <API key> = 0x23, <API key> = 0x24, <API key> = 0x25, }; #define <API key> GENMASK(23, 2) #define <API key> 2 #define <API key> GENMASK(27, 24) #define <API key> 24 #define <API key> <API key> #define <API key> <API key> #define <API key> GENMASK(14, 2) #define <API key> 2 #define USB4_DROM_SIZE_MASK GENMASK(19, 15) #define <API key> 15 #define <API key> GENMASK(23, 0) typedef int (*read_block_fn)(struct tb_switch *, unsigned int, void *, size_t); typedef int (*write_block_fn)(struct tb_switch *, const void *, size_t); static int <API key>(struct tb_switch *sw, u32 offset, u32 bit, u32 value, int timeout_msec) { ktime_t timeout = ktime_add_ms(ktime_get(), timeout_msec); do { u32 val; int ret; ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, offset, 1); if (ret) return ret; if ((val & bit) == value) return 0; usleep_range(50, 100); } while (ktime_before(ktime_get(), timeout)); return -ETIMEDOUT; } static int <API key>(struct tb_switch *sw, void *data, size_t dwords) { if (dwords > USB4_DATA_DWORDS) return -EINVAL; return tb_sw_read(sw, data, TB_CFG_SWITCH, ROUTER_CS_9, dwords); } static int <API key>(struct tb_switch *sw, const void *data, size_t dwords) { if (dwords > USB4_DATA_DWORDS) return -EINVAL; return tb_sw_write(sw, data, TB_CFG_SWITCH, ROUTER_CS_9, dwords); } static int <API key>(struct tb_switch *sw, u32 *metadata) { return tb_sw_read(sw, metadata, TB_CFG_SWITCH, ROUTER_CS_25, 1); } static int <API key>(struct tb_switch *sw, u32 metadata) { return tb_sw_write(sw, &metadata, TB_CFG_SWITCH, ROUTER_CS_25, 1); } static int <API key>(struct tb_switch *sw, u16 address, void *buf, size_t size, read_block_fn read_block) { unsigned int retries = USB4_DATA_RETRIES; unsigned int offset; offset = address & 3; address = address & ~3; do { size_t nbytes = min_t(size_t, size, USB4_DATA_DWORDS * 4); unsigned int dwaddress, dwords; u8 data[USB4_DATA_DWORDS * 4]; int ret; dwaddress = address / 4; dwords = ALIGN(nbytes, 4) / 4; ret = read_block(sw, dwaddress, data, dwords); if (ret) { if (ret == -ETIMEDOUT) { if (retries continue; ret = -EIO; } return ret; } memcpy(buf, data + offset, nbytes); size -= nbytes; address += nbytes; buf += nbytes; } while (size > 0); return 0; } static int <API key>(struct tb_switch *sw, u16 address, const void *buf, size_t size, write_block_fn write_next_block) { unsigned int retries = USB4_DATA_RETRIES; unsigned int offset; offset = address & 3; address = address & ~3; do { u32 nbytes = min_t(u32, size, USB4_DATA_DWORDS * 4); u8 data[USB4_DATA_DWORDS * 4]; int ret; memcpy(data + offset, buf, nbytes); ret = write_next_block(sw, data, nbytes / 4); if (ret) { if (ret == -ETIMEDOUT) { if (retries continue; ret = -EIO; } return ret; } size -= nbytes; address += nbytes; buf += nbytes; } while (size > 0); return 0; } static int usb4_switch_op(struct tb_switch *sw, u16 opcode, u8 *status) { u32 val; int ret; val = opcode | ROUTER_CS_26_OV; ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); if (ret) return ret; ret = <API key>(sw, ROUTER_CS_26, ROUTER_CS_26_OV, 0, 500); if (ret) return ret; ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); if (val & ROUTER_CS_26_ONS) return -EOPNOTSUPP; *status = (val & <API key>) >> <API key>; return 0; } /** * usb4_switch_setup() - Additional setup for USB4 device * @sw: USB4 router to setup * * USB4 routers need additional settings in order to enable all the * tunneling. This function enables USB and PCIe tunneling if it can be * enabled (e.g the parent switch also supports them). If USB tunneling * is not available for some reason (like that there is Thunderbolt 3 * switch upstream) then the internal xHCI controller is enabled * instead. */ int usb4_switch_setup(struct tb_switch *sw) { struct tb_switch *parent; bool tbt3, xhci; u32 val = 0; int ret; if (!tb_route(sw)) return 0; ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1); if (ret) return ret; xhci = val & ROUTER_CS_6_HCI; tbt3 = !(val & ROUTER_CS_6_TNS); tb_sw_dbg(sw, "TBT3 support: %s, xHCI: %s\n", tbt3 ? "yes" : "no", xhci ? "yes" : "no"); ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); if (ret) return ret; parent = tb_switch_parent(sw); if (tb_switch_find_port(parent, TB_TYPE_USB3_DOWN)) { val |= ROUTER_CS_5_UTO; xhci = false; } /* Only enable PCIe tunneling if the parent router supports it */ if (tb_switch_find_port(parent, TB_TYPE_PCIE_DOWN)) { val |= ROUTER_CS_5_PTO; /* * xHCI can be enabled if PCIe tunneling is supported * and the parent does not have any USB3 dowstream * adapters (so we cannot do USB 3.x tunneling). */ if (xhci) val |= ROUTER_CS_5_HCO; } /* TBT3 supported by the CM */ val |= ROUTER_CS_5_C3S; /* Tunneling configuration is ready now */ val |= ROUTER_CS_5_CV; ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); if (ret) return ret; return <API key>(sw, ROUTER_CS_6, ROUTER_CS_6_CR, ROUTER_CS_6_CR, 50); } /** * <API key>() - Read UID from USB4 router * @sw: USB4 router * * Reads 64-bit UID from USB4 router config space. */ int <API key>(struct tb_switch *sw, u64 *uid) { return tb_sw_read(sw, uid, TB_CFG_SWITCH, ROUTER_CS_7, 2); } static int <API key>(struct tb_switch *sw, unsigned int dwaddress, void *buf, size_t dwords) { u8 status = 0; u32 metadata; int ret; metadata = (dwords << <API key>) & USB4_DROM_SIZE_MASK; metadata |= (dwaddress << <API key>) & <API key>; ret = <API key>(sw, metadata); if (ret) return ret; ret = usb4_switch_op(sw, <API key>, &status); if (ret) return ret; if (status) return -EIO; return <API key>(sw, buf, dwords); } /** * <API key>() - Read arbitrary bytes from USB4 router DROM * @sw: USB4 router * * Uses USB4 router operations to read router DROM. For devices this * should always work but for hosts it may return %-EOPNOTSUPP in which * case the host router does not have DROM. */ int <API key>(struct tb_switch *sw, unsigned int address, void *buf, size_t size) { return <API key>(sw, address, buf, size, <API key>); } static int <API key>(struct tb_port *port, bool configured) { int ret; u32 val; ret = tb_port_read(port, &val, TB_CFG_PORT, port->cap_usb4 + PORT_CS_19, 1); if (ret) return ret; if (configured) val |= PORT_CS_19_PC; else val &= ~PORT_CS_19_PC; return tb_port_write(port, &val, TB_CFG_PORT, port->cap_usb4 + PORT_CS_19, 1); } /** * <API key>() - Set upstream USB4 link configured * @sw: USB4 router * * Sets the upstream USB4 link to be configured for power management * purposes. */ int <API key>(struct tb_switch *sw) { struct tb_port *up; if (!tb_route(sw)) return 0; up = tb_upstream_port(sw); return <API key>(up, true); } /** * <API key>() - Un-set upstream USB4 link configuration * @sw: USB4 router * * Reverse of <API key>(). */ void <API key>(struct tb_switch *sw) { struct tb_port *up; if (sw->is_unplugged || !tb_route(sw)) return; up = tb_upstream_port(sw); <API key>(up, false); } /** * <API key>() - Are conditions met for lane bonding * @sw: USB4 router * * Checks whether conditions are met so that lane bonding can be * established with the upstream router. Call only for device routers. */ bool <API key>(struct tb_switch *sw) { struct tb_port *up; int ret; u32 val; up = tb_upstream_port(sw); ret = tb_port_read(up, &val, TB_CFG_PORT, up->cap_usb4 + PORT_CS_18, 1); if (ret) return false; return !!(val & PORT_CS_18_BE); } /** * <API key>() - Prepare the router to enter sleep * @sw: USB4 router * * Enables wakes and sets sleep bit for the router. Returns when the * router sleep ready bit has been asserted. */ int <API key>(struct tb_switch *sw) { int ret; u32 val; /* Set sleep bit and wait for sleep ready to be asserted */ ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); if (ret) return ret; val |= ROUTER_CS_5_SLP; ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); if (ret) return ret; return <API key>(sw, ROUTER_CS_6, ROUTER_CS_6_SLPR, ROUTER_CS_6_SLPR, 500); } /** * <API key>() - Return router NVM sector size * @sw: USB4 router * * If the router supports NVM operations this function returns the NVM * sector size in bytes. If NVM operations are not supported returns * %-EOPNOTSUPP. */ int <API key>(struct tb_switch *sw) { u32 metadata; u8 status; int ret; ret = usb4_switch_op(sw, <API key>, &status); if (ret) return ret; if (status) return status == 0x2 ? -EOPNOTSUPP : -EIO; ret = <API key>(sw, &metadata); if (ret) return ret; return metadata & <API key>; } static int <API key>(struct tb_switch *sw, unsigned int dwaddress, void *buf, size_t dwords) { u8 status = 0; u32 metadata; int ret; metadata = (dwords << <API key>) & <API key>; metadata |= (dwaddress << <API key>) & <API key>; ret = <API key>(sw, metadata); if (ret) return ret; ret = usb4_switch_op(sw, <API key>, &status); if (ret) return ret; if (status) return -EIO; return <API key>(sw, buf, dwords); } /** * <API key>() - Read arbitrary bytes from router NVM * @sw: USB4 router * @address: Starting address in bytes * @buf: Read data is placed here * @size: How many bytes to read * * Reads NVM contents of the router. If NVM is not supported returns * %-EOPNOTSUPP. */ int <API key>(struct tb_switch *sw, unsigned int address, void *buf, size_t size) { return <API key>(sw, address, buf, size, <API key>); } static int <API key>(struct tb_switch *sw, unsigned int address) { u32 metadata, dwaddress; u8 status = 0; int ret; dwaddress = address / 4; metadata = (dwaddress << <API key>) & <API key>; ret = <API key>(sw, metadata); if (ret) return ret; ret = usb4_switch_op(sw, <API key>, &status); if (ret) return ret; return status ? -EIO : 0; } static int <API key>(struct tb_switch *sw, const void *buf, size_t dwords) { u8 status; int ret; ret = <API key>(sw, buf, dwords); if (ret) return ret; ret = usb4_switch_op(sw, <API key>, &status); if (ret) return ret; return status ? -EIO : 0; } /** * <API key>() - Write to the router NVM * @sw: USB4 router * @address: Start address where to write in bytes * @buf: Pointer to the data to write * @size: Size of @buf in bytes * * Writes @buf to the router NVM using USB4 router operations. If NVM * write is not supported returns %-EOPNOTSUPP. */ int <API key>(struct tb_switch *sw, unsigned int address, const void *buf, size_t size) { int ret; ret = <API key>(sw, address); if (ret) return ret; return <API key>(sw, address, buf, size, <API key>); } /** * <API key>() - Authenticate new NVM * @sw: USB4 router * * After the new NVM has been written via <API key>(), this * function triggers NVM authentication process. If the authentication * is successful the router is power cycled and the new NVM starts * running. In case of failure returns negative errno. */ int <API key>(struct tb_switch *sw) { u8 status = 0; int ret; ret = usb4_switch_op(sw, <API key>, &status); if (ret) return ret; switch (status) { case 0x0: tb_sw_dbg(sw, "NVM authentication successful\n"); return 0; case 0x1: return -EINVAL; case 0x2: return -EAGAIN; case 0x3: return -EOPNOTSUPP; default: return -EIO; } } /** * <API key>() - Query availability of DP IN resource * @sw: USB4 router * @in: DP IN adapter * * For DP tunneling this function can be used to query availability of * DP IN resource. Returns true if the resource is available for DP * tunneling, false otherwise. */ bool <API key>(struct tb_switch *sw, struct tb_port *in) { u8 status; int ret; ret = <API key>(sw, in->port); if (ret) return false; ret = usb4_switch_op(sw, <API key>, &status); /* * If DP resource allocation is not supported assume it is * always available. */ if (ret == -EOPNOTSUPP) return true; else if (ret) return false; return !status; } /** * <API key>() - Allocate DP IN resource * @sw: USB4 router * @in: DP IN adapter * * Allocates DP IN resource for DP tunneling using USB4 router * operations. If the resource was allocated returns %0. Otherwise * returns negative errno, in particular %-EBUSY if the resource is * already allocated. */ int <API key>(struct tb_switch *sw, struct tb_port *in) { u8 status; int ret; ret = <API key>(sw, in->port); if (ret) return ret; ret = usb4_switch_op(sw, <API key>, &status); if (ret == -EOPNOTSUPP) return 0; else if (ret) return ret; return status ? -EBUSY : 0; } /** * <API key>() - Releases allocated DP IN resource * @sw: USB4 router * @in: DP IN adapter * * Releases the previously allocated DP IN resource. */ int <API key>(struct tb_switch *sw, struct tb_port *in) { u8 status; int ret; ret = <API key>(sw, in->port); if (ret) return ret; ret = usb4_switch_op(sw, <API key>, &status); if (ret == -EOPNOTSUPP) return 0; else if (ret) return ret; return status ? -EIO : 0; } static int usb4_port_idx(const struct tb_switch *sw, const struct tb_port *port) { struct tb_port *p; int usb4_idx = 0; /* Assume port is primary */ <API key>(sw, p) { if (!tb_port_is_null(p)) continue; if (tb_is_upstream_port(p)) continue; if (!p->link_nr) { if (p == port) break; usb4_idx++; } } return usb4_idx; } /** * <API key>() - Map USB4 port to a PCIe downstream adapter * @sw: USB4 router * @port: USB4 port * * USB4 routers have direct mapping between USB4 ports and PCIe * downstream adapters where the PCIe topology is extended. This * function returns the corresponding downstream PCIe adapter or %NULL * if no such mapping was possible. */ struct tb_port *<API key>(struct tb_switch *sw, const struct tb_port *port) { int usb4_idx = usb4_port_idx(sw, port); struct tb_port *p; int pcie_idx = 0; /* Find PCIe down port matching usb4_port */ <API key>(sw, p) { if (!<API key>(p)) continue; if (pcie_idx == usb4_idx && !<API key>(p)) return p; pcie_idx++; } return NULL; } /** * <API key>() - Map USB4 port to a USB3 downstream adapter * @sw: USB4 router * @port: USB4 port * * USB4 routers have direct mapping between USB4 ports and USB 3.x * downstream adapters where the USB 3.x topology is extended. This * function returns the corresponding downstream USB 3.x adapter or * %NULL if no such mapping was possible. */ struct tb_port *<API key>(struct tb_switch *sw, const struct tb_port *port) { int usb4_idx = usb4_port_idx(sw, port); struct tb_port *p; int usb_idx = 0; /* Find USB3 down port matching usb4_port */ <API key>(sw, p) { if (!<API key>(p)) continue; if (usb_idx == usb4_idx && !<API key>(p)) return p; usb_idx++; } return NULL; } /** * usb4_port_unlock() - Unlock USB4 downstream port * @port: USB4 port to unlock * * Unlocks USB4 downstream port so that the connection manager can * access the router below this port. */ int usb4_port_unlock(struct tb_port *port) { int ret; u32 val; ret = tb_port_read(port, &val, TB_CFG_PORT, ADP_CS_4, 1); if (ret) return ret; val &= ~ADP_CS_4_LCK; return tb_port_write(port, &val, TB_CFG_PORT, ADP_CS_4, 1); }
#ifndef _ASM_BYTEORDER_H #define _ASM_BYTEORDER_H #include <linux/compiler.h> #include <asm/types.h> #if defined(__MIPSEB__) # define __BIG_ENDIAN #elif defined(__MIPSEL__) # define __LITTLE_ENDIAN #else # error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???" #endif #define __SWAB_64_THRU_32__ #ifdef CONFIG_CPU_MIPSR2 static inline __attribute_const__ __u16 __arch_swab16(__u16 x) { __asm__( " wsbh %0, %1 \n" : "=r" (x) : "r" (x)); return x; } #define __arch_swab16 __arch_swab16 static inline __attribute_const__ __u32 __arch_swab32(__u32 x) { __asm__( " wsbh %0, %1 \n" " rotr %0, %0, 16 \n" : "=r" (x) : "r" (x)); return x; } #define __arch_swab32 __arch_swab32 #ifdef <API key> static inline __attribute_const__ __u64 __arch_swab64(__u64 x) { __asm__( " dsbh %0, %1\n" " dshd %0, %0" : "=r" (x) : "r" (x)); return x; } #define __arch_swab64 __arch_swab64 #endif /* <API key> */ #endif /* CONFIG_CPU_MIPSR2 */ #include <linux/byteorder.h> #endif /* _ASM_BYTEORDER_H */
#include "../../SDL_internal.h" #if <API key> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <malloc.h> #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_timer.h" #include "../SDL_audio_c.h" #include "../SDL_audiodev_c.h" #include "../SDL_sysaudio.h" #include "SDL_pspaudio.h" #include <pspaudio.h> #include <pspthreadman.h> /* The tag name used by PSP audio */ #define <API key> "psp" static int PSPAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) { int format, mixlen, i; this->hidden = (struct <API key> *) SDL_malloc(sizeof(*this->hidden)); if (this->hidden == NULL) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); switch (this->spec.format & 0xff) { case 8: case 16: this->spec.format = AUDIO_S16LSB; break; default: return SDL_SetError("Unsupported audio format"); } /* The sample count must be a multiple of 64. */ this->spec.samples = <API key>(this->spec.samples); this->spec.freq = 44100; /* Update the fragment size as size in bytes. */ <API key>(&this->spec); /* Allocate the mixing buffer. Its size and starting address must be a multiple of 64 bytes. Our sample count is already a multiple of 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen); if (this->hidden->rawbuf == NULL) { return SDL_SetError("Couldn't allocate mixing buffer"); } /* Setup the hardware channel. */ if (this->spec.channels == 1) { format = <API key>; } else { this->spec.channels = 2; format = <API key>; } this->hidden->channel = sceAudioChReserve(<API key>, this->spec.samples, format); if (this->hidden->channel < 0) { free(this->hidden->rawbuf); this->hidden->rawbuf = NULL; return SDL_SetError("Couldn't reserve hardware channel"); } memset(this->hidden->rawbuf, 0, mixlen); for (i = 0; i < NUM_BUFFERS; i++) { this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size]; } this->hidden->next_buffer = 0; return 0; } static void PSPAUDIO_PlayDevice(_THIS) { Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer]; if (this->spec.channels == 1) { <API key>(this->hidden->channel, <API key>, mixbuf); } else { <API key>(this->hidden->channel, <API key>, <API key>, mixbuf); } this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS; } /* This function waits until it is possible to write a full sound buffer */ static void PSPAUDIO_WaitDevice(_THIS) { /* Because we block when sending audio, there's no need for this function to do anything. */ } static Uint8 *<API key>(_THIS) { return this->hidden->mixbufs[this->hidden->next_buffer]; } static void <API key>(_THIS) { if (this->hidden->channel >= 0) { sceAudioChRelease(this->hidden->channel); } free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */ SDL_free(this->hidden); } static void PSPAUDIO_ThreadInit(_THIS) { /* Increase the priority of this audio thread by 1 to put it ahead of other SDL threads. */ SceUID thid; SceKernelThreadInfo status; thid = <API key>(); status.size = sizeof(SceKernelThreadInfo); if (<API key>(thid, &status) == 0) { <API key>(thid, status.currentPriority - 1); } } static int PSPAUDIO_Init(SDL_AudioDriverImpl * impl) { /* Set the function pointers */ impl->OpenDevice = PSPAUDIO_OpenDevice; impl->PlayDevice = PSPAUDIO_PlayDevice; impl->WaitDevice = PSPAUDIO_WaitDevice; impl->GetDeviceBuf = <API key>; impl->CloseDevice = <API key>; impl->ThreadInit = PSPAUDIO_ThreadInit; /* PSP audio device */ impl-><API key> = 1; /* impl->HasCaptureSupport = 1; impl-><API key> = 1; */ /* impl->DetectDevices = <API key>; impl->Deinitialize = DSOUND_Deinitialize; */ return 1; /* this audio target is available. */ } AudioBootStrap PSPAUDIO_bootstrap = { "psp", "PSP audio driver", PSPAUDIO_Init, 0 }; /* SDL_AUDI */ #endif /* <API key> */ /* vi: set ts=4 sw=4 expandtab: */
#include <linux/mm.h> #include <linux/module.h> #include <linux/file.h> #include <linux/slab.h> #include <linux/time.h> #include <linux/pm_qos.h> #include <linux/uio.h> #include <linux/dma-mapping.h> #include <sound/core.h> #include <sound/control.h> #include <sound/compress_offload.h> #include <sound/info.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/timer.h> #include <sound/minors.h> #include <asm/io.h> #if defined(CONFIG_MIPS) && defined(<API key>) #include <dma-coherence.h> #endif //htc audio ++ #include <sound/soc.h> #undef pr_info #undef pr_err #define pr_info(fmt, ...) pr_aud_info(fmt, ##__VA_ARGS__) #define pr_err(fmt, ...) pr_aud_err(fmt, ##__VA_ARGS__) //htc audio -- /* * Compatibility */ struct <API key> { unsigned int flags; unsigned int masks[<API key> - <API key> + 1]; struct snd_interval intervals[<API key> - <API key> + 1]; unsigned int rmask; unsigned int cmask; unsigned int info; unsigned int msbits; unsigned int rate_num; unsigned int rate_den; snd_pcm_uframes_t fifo_size; unsigned char reserved[64]; }; #ifdef <API key> #define <API key> _IOWR('A', 0x10, struct <API key>) #define <API key> _IOWR('A', 0x11, struct <API key>) static int <API key>(struct snd_pcm_substream *substream, struct <API key> __user * _oparams); static int <API key>(struct snd_pcm_substream *substream, struct <API key> __user * _oparams); #endif static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream); DEFINE_RWLOCK(snd_pcm_link_rwlock); EXPORT_SYMBOL(snd_pcm_link_rwlock); static DECLARE_RWSEM(snd_pcm_link_rwsem); static inline mm_segment_t snd_enter_user(void) { mm_segment_t fs = get_fs(); set_fs(get_ds()); return fs; } static inline void snd_leave_user(mm_segment_t fs) { set_fs(fs); } int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) { struct snd_pcm_runtime *runtime; struct snd_pcm *pcm = substream->pcm; struct snd_pcm_str *pstr = substream->pstr; memset(info, 0, sizeof(*info)); info->card = pcm->card->number; info->device = pcm->device; info->stream = substream->stream; info->subdevice = substream->number; strlcpy(info->id, pcm->id, sizeof(info->id)); strlcpy(info->name, pcm->name, sizeof(info->name)); info->dev_class = pcm->dev_class; info->dev_subclass = pcm->dev_subclass; info->subdevices_count = pstr->substream_count; info->subdevices_avail = pstr->substream_count - pstr->substream_opened; strlcpy(info->subname, substream->name, sizeof(info->subname)); runtime = substream->runtime; /* AB: FIXME!!! This is definitely nonsense */ if (runtime) { info->sync = runtime->sync; substream->ops->ioctl(substream, <API key>, info); } return 0; } int snd_pcm_info_user(struct snd_pcm_substream *substream, struct snd_pcm_info __user * _info) { struct snd_pcm_info *info; int err; info = kmalloc(sizeof(*info), GFP_KERNEL); if (! info) return -ENOMEM; err = snd_pcm_info(substream, info); if (err >= 0) { if (copy_to_user(_info, info, sizeof(*info))) err = -EFAULT; } kfree(info); return err; } #undef RULES_DEBUG #if 1 //htc audio #define HW_PARAM(v) [SNDRV_PCM_HW_PARAM_##v] = #v static const char * const <API key>[] = { HW_PARAM(ACCESS), HW_PARAM(FORMAT), HW_PARAM(SUBFORMAT), HW_PARAM(SAMPLE_BITS), HW_PARAM(FRAME_BITS), HW_PARAM(CHANNELS), HW_PARAM(RATE), HW_PARAM(PERIOD_TIME), HW_PARAM(PERIOD_SIZE), HW_PARAM(PERIOD_BYTES), HW_PARAM(PERIODS), HW_PARAM(BUFFER_TIME), HW_PARAM(BUFFER_SIZE), HW_PARAM(BUFFER_BYTES), HW_PARAM(TICK_TIME), }; #endif int snd_pcm_hw_refine(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { unsigned int k; struct snd_pcm_hardware *hw; struct snd_interval *i = NULL; struct snd_mask *m = NULL; struct <API key> *constrs = &substream->runtime->hw_constraints; unsigned int rstamps[constrs->rules_num]; unsigned int vstamps[<API key> + 1]; unsigned int stamp = 2; int changed, again; params->info = 0; params->fifo_size = 0; if (params->rmask & (1 << <API key>)) params->msbits = 0; if (params->rmask & (1 << <API key>)) { params->rate_num = 0; params->rate_den = 0; } for (k = <API key>; k <= <API key>; k++) { m = hw_param_mask(params, k); if (snd_mask_empty(m)) return -EINVAL; if (!(params->rmask & (1 << k))) continue; #ifdef RULES_DEBUG printk(KERN_DEBUG "%s = ", <API key>[k]); printk("%04x%04x%04x%04x -> ", m->bits[3], m->bits[2], m->bits[1], m->bits[0]); #endif changed = snd_mask_refine(m, constrs_mask(constrs, k)); #ifdef RULES_DEBUG printk("%04x%04x%04x%04x\n", m->bits[3], m->bits[2], m->bits[1], m->bits[0]); #endif if (changed) params->cmask |= 1 << k; if (changed < 0) { //htc audio ++ pr_info("refine mask %s \n",<API key>[k]); pr_info("fail mask 0x%x 0x%x 0x%x 0x%x\n", m->bits[3], m->bits[2], m->bits[1], m->bits[0]); //htc audio -- return changed; } } for (k = <API key>; k <= <API key>; k++) { i = hw_param_interval(params, k); if (snd_interval_empty(i)) return -EINVAL; if (!(params->rmask & (1 << k))) continue; #ifdef RULES_DEBUG printk(KERN_DEBUG "%s = ", <API key>[k]); if (i->empty) printk("empty"); else printk("%c%u %u%c", i->openmin ? '(' : '[', i->min, i->max, i->openmax ? ')' : ']'); printk(" -> "); #endif changed = snd_interval_refine(i, constrs_interval(constrs, k)); #ifdef RULES_DEBUG if (i->empty) printk("empty\n"); else printk("%c%u %u%c\n", i->openmin ? '(' : '[', i->min, i->max, i->openmax ? ')' : ']'); #endif if (changed) params->cmask |= 1 << k; if (changed < 0) { //htc audio ++ pr_info("refine interval %s fail\n",<API key>[k]); pr_info("fail max %u min %u\n",i->max,i->min); //htc audio -- return changed; } } for (k = 0; k < constrs->rules_num; k++) rstamps[k] = 0; for (k = 0; k <= <API key>; k++) vstamps[k] = (params->rmask & (1 << k)) ? 1 : 0; do { again = 0; for (k = 0; k < constrs->rules_num; k++) { struct snd_pcm_hw_rule *r = &constrs->rules[k]; unsigned int d; int doit = 0; if (r->cond && !(r->cond & params->flags)) continue; for (d = 0; r->deps[d] >= 0; d++) { if (vstamps[r->deps[d]] > rstamps[k]) { doit = 1; break; } } if (!doit) continue; #ifdef RULES_DEBUG printk(KERN_DEBUG "Rule %d [%p]: ", k, r->func); if (r->var >= 0) { printk("%s = ", <API key>[r->var]); if (hw_is_mask(r->var)) { m = hw_param_mask(params, r->var); printk("%x", *m->bits); } else { i = hw_param_interval(params, r->var); if (i->empty) printk("empty"); else printk("%c%u %u%c", i->openmin ? '(' : '[', i->min, i->max, i->openmax ? ')' : ']'); } } #endif changed = r->func(params, r); #ifdef RULES_DEBUG if (r->var >= 0) { printk(" -> "); if (hw_is_mask(r->var)) printk("%x", *m->bits); else { if (i->empty) printk("empty"); else printk("%c%u %u%c", i->openmin ? '(' : '[', i->min, i->max, i->openmax ? ')' : ']'); } } printk("\n"); #endif rstamps[k] = stamp; if (changed && r->var >= 0) { params->cmask |= (1 << r->var); vstamps[r->var] = stamp; again = 1; } if (changed < 0) { //htc audio ++ pr_info("refine rule %s fail",<API key>[r->var]); if (hw_is_mask(r->var)) { m = hw_param_mask(params, r->var); pr_info("fail rule mask %x", *m->bits); } else if (r->var >= <API key> && r->var <= <API key>) { i = hw_param_interval(params, r->var); if (i->empty) pr_info("empty"); else pr_info("fail rule max %u min %u",i->max,i->min); } //htc audio -- return changed; } stamp++; } } while (again); if (!params->msbits) { i = hw_param_interval(params, <API key>); if (snd_interval_single(i)) params->msbits = snd_interval_value(i); } if (!params->rate_den) { i = hw_param_interval(params, <API key>); if (snd_interval_single(i)) { params->rate_num = snd_interval_value(i); params->rate_den = 1; } } hw = &substream->runtime->hw; if (!params->info) params->info = hw->info & ~<API key>; if (!params->fifo_size) { m = hw_param_mask(params, <API key>); i = hw_param_interval(params, <API key>); if (snd_mask_min(m) == snd_mask_max(m) && snd_interval_min(i) == snd_interval_max(i)) { changed = substream->ops->ioctl(substream, <API key>, params); if (changed < 0) return changed; } } params->rmask = 0; return 0; } EXPORT_SYMBOL(snd_pcm_hw_refine); static int <API key>(struct snd_pcm_substream *substream, struct snd_pcm_hw_params __user * _params) { struct snd_pcm_hw_params *params; int err; pr_info("%s: ++\n",__func__); params = memdup_user(_params, sizeof(*params)); if (IS_ERR(params)) return PTR_ERR(params); err = snd_pcm_hw_refine(substream, params); if (copy_to_user(_params, params, sizeof(*params))) { if (!err) err = -EFAULT; } pr_info("%s: --\n",__func__); kfree(params); return err; } static int period_to_usecs(struct snd_pcm_runtime *runtime) { int usecs; if (! runtime->rate) return -1; /* invalid */ /* take 75% of period time as the deadline */ usecs = (750000 / runtime->rate) * runtime->period_size; usecs += ((750000 % runtime->rate) * runtime->period_size) / runtime->rate; return usecs; } static int snd_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_pcm_runtime *runtime; int err, usecs; unsigned int bits; snd_pcm_uframes_t frames; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; pr_info("%s ++", __func__); <API key>(substream); switch (runtime->status->state) { case <API key>: case <API key>: case <API key>: break; default: pr_info("%s --", __func__); <API key>(substream); return -EBADFD; } pr_info("%s --", __func__); <API key>(substream); #if defined(CONFIG_SND_PCM_OSS) || defined(<API key>) if (!substream->oss.oss) #endif if (atomic_read(&substream->mmap_count)) return -EBADFD; params->rmask = ~0U; err = snd_pcm_hw_refine(substream, params); if (err < 0) goto _error; err = <API key>(substream, params); if (err < 0) goto _error; if (substream->ops->hw_params != NULL) { err = substream->ops->hw_params(substream, params); if (err < 0) goto _error; } runtime->access = params_access(params); runtime->format = params_format(params); runtime->subformat = params_subformat(params); runtime->channels = params_channels(params); runtime->rate = params_rate(params); runtime->period_size = params_period_size(params); runtime->periods = params_periods(params); runtime->buffer_size = params_buffer_size(params); runtime->info = params->info; runtime->rate_num = params->rate_num; runtime->rate_den = params->rate_den; runtime->no_period_wakeup = (params->info & <API key>) && (params->flags & <API key>); bits = <API key>(runtime->format); runtime->sample_bits = bits; bits *= runtime->channels; runtime->frame_bits = bits; frames = 1; while (bits % 8 != 0) { bits *= 2; frames *= 2; } runtime->byte_align = bits / 8; runtime->min_align = frames; /* Default sw params */ runtime->tstamp_mode = <API key>; runtime->period_step = 1; runtime->control->avail_min = runtime->period_size; runtime->start_threshold = 1; runtime->stop_threshold = runtime->buffer_size; runtime->silence_threshold = 0; runtime->silence_size = 0; runtime->boundary = runtime->buffer_size; while (runtime->boundary * 2 * runtime->channels <= LONG_MAX - runtime->buffer_size) runtime->boundary *= 2; <API key>(substream); runtime->status->state = <API key>; if (<API key>(&substream->latency_pm_qos_req)) <API key>(&substream->latency_pm_qos_req); if ((usecs = period_to_usecs(runtime)) >= 0) pm_qos_add_request(&substream->latency_pm_qos_req, <API key>, usecs); return 0; _error: /* hardware might be unusable from this time, so we force application to retry to set the correct hardware parameter settings */ runtime->status->state = <API key>; if (substream->ops->hw_free != NULL) substream->ops->hw_free(substream); return err; } static int <API key>(struct snd_pcm_substream *substream, struct snd_pcm_hw_params __user * _params) { struct snd_pcm_hw_params *params; int err; pr_info("%s ++\n",__func__); params = memdup_user(_params, sizeof(*params)); if (IS_ERR(params)) return PTR_ERR(params); err = snd_pcm_hw_params(substream, params); if (copy_to_user(_params, params, sizeof(*params))) { if (!err) err = -EFAULT; } pr_info("%s --\n",__func__); kfree(params); return err; } static int snd_pcm_hw_free(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime; int result = 0; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; pr_info("%s ++", __func__); <API key>(substream); switch (runtime->status->state) { case <API key>: case <API key>: break; default: pr_info("%s --", __func__); <API key>(substream); return -EBADFD; } pr_info("%s --", __func__); <API key>(substream); if (atomic_read(&substream->mmap_count)) return -EBADFD; if (substream->ops->hw_free) result = substream->ops->hw_free(substream); runtime->status->state = <API key>; <API key>(&substream->latency_pm_qos_req); return result; } static int snd_pcm_sw_params(struct snd_pcm_substream *substream, struct snd_pcm_sw_params *params) { struct snd_pcm_runtime *runtime; int err; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; pr_info("%s ++", __func__); <API key>(substream); if (runtime->status->state == <API key>) { pr_info("%s --", __func__); <API key>(substream); return -EBADFD; } pr_info("%s --", __func__); <API key>(substream); if (params->tstamp_mode > <API key>) return -EINVAL; if (params->avail_min == 0) return -EINVAL; if (params->silence_size >= runtime->boundary) { if (params->silence_threshold != 0) return -EINVAL; } else { if (params->silence_size > params->silence_threshold) return -EINVAL; if (params->silence_threshold > runtime->buffer_size) return -EINVAL; } err = 0; pr_info("%s +++", __func__); <API key>(substream); runtime->tstamp_mode = params->tstamp_mode; runtime->period_step = params->period_step; runtime->control->avail_min = params->avail_min; runtime->start_threshold = params->start_threshold; runtime->stop_threshold = params->stop_threshold; runtime->silence_threshold = params->silence_threshold; runtime->silence_size = params->silence_size; params->boundary = runtime->boundary; if (snd_pcm_running(substream)) { if (substream->stream == <API key> && runtime->silence_size > 0) <API key>(substream, ULONG_MAX); err = <API key>(substream, runtime); } pr_info("%s ---", __func__); <API key>(substream); return err; } static int <API key>(struct snd_pcm_substream *substream, struct snd_pcm_sw_params __user * _params) { struct snd_pcm_sw_params params; int err; if (copy_from_user(&params, _params, sizeof(params))) return -EFAULT; err = snd_pcm_sw_params(substream, &params); if (copy_to_user(_params, &params, sizeof(params))) return -EFAULT; return err; } int snd_pcm_status(struct snd_pcm_substream *substream, struct snd_pcm_status *status) { struct snd_pcm_runtime *runtime = substream->runtime; pr_info("%s ++", __func__); <API key>(substream); status->state = runtime->status->state; status->suspended_state = runtime->status->suspended_state; if (status->state == <API key>) goto _end; status->trigger_tstamp = runtime->trigger_tstamp; if (snd_pcm_running(substream)) { <API key>(substream); if (runtime->tstamp_mode == <API key>) { status->tstamp = runtime->status->tstamp; goto _tstamp_end; } } snd_pcm_gettime(runtime, &status->tstamp); _tstamp_end: status->appl_ptr = runtime->control->appl_ptr; status->hw_ptr = runtime->status->hw_ptr; if (substream->stream == <API key>) { status->avail = <API key>(runtime); if (runtime->status->state == <API key> || runtime->status->state == <API key>) { status->delay = runtime->buffer_size - status->avail; status->delay += runtime->delay; } else status->delay = 0; } else { status->avail = <API key>(runtime); if (runtime->status->state == <API key>) status->delay = status->avail + runtime->delay; else status->delay = 0; } status->avail_max = runtime->avail_max; status->overrange = runtime->overrange; runtime->avail_max = 0; runtime->overrange = 0; _end: pr_info("%s --", __func__); <API key>(substream); return 0; } static int snd_pcm_status_user(struct snd_pcm_substream *substream, struct snd_pcm_status __user * _status) { struct snd_pcm_status status; int res; memset(&status, 0, sizeof(status)); res = snd_pcm_status(substream, &status); if (res < 0) return res; if (copy_to_user(_status, &status, sizeof(status))) return -EFAULT; return 0; } static int <API key>(struct snd_pcm_substream *substream, struct <API key> * info) { struct snd_pcm_runtime *runtime; unsigned int channel; channel = info->channel; runtime = substream->runtime; pr_info("%s ++", __func__); <API key>(substream); if (runtime->status->state == <API key>) { pr_info("%s --", __func__); <API key>(substream); return -EBADFD; } pr_info("%s --", __func__); <API key>(substream); if (channel >= runtime->channels) return -EINVAL; memset(info, 0, sizeof(*info)); info->channel = channel; return substream->ops->ioctl(substream, <API key>, info); } static int <API key>(struct snd_pcm_substream *substream, struct <API key> __user * _info) { struct <API key> info; int res; if (copy_from_user(&info, _info, sizeof(info))) return -EFAULT; res = <API key>(substream, &info); if (res < 0) return res; if (copy_to_user(_info, &info, sizeof(info))) return -EFAULT; return 0; } static void <API key>(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->trigger_master == NULL) return; if (runtime->trigger_master == substream) { snd_pcm_gettime(runtime, &runtime->trigger_tstamp); } else { <API key>(runtime->trigger_master); runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; } runtime->trigger_master = NULL; } struct action_ops { int (*pre_action)(struct snd_pcm_substream *substream, int state); int (*do_action)(struct snd_pcm_substream *substream, int state); void (*undo_action)(struct snd_pcm_substream *substream, int state); void (*post_action)(struct snd_pcm_substream *substream, int state); }; /* * this functions is core for handling of linked stream * Note: the stream state might be changed also on failure * Note2: call with calling stream lock + link lock */ static int <API key>(struct action_ops *ops, struct snd_pcm_substream *substream, int state, int do_lock) { struct snd_pcm_substream *s = NULL; struct snd_pcm_substream *s1; int res = 0; <API key>(s, substream) { if (do_lock && s != substream) spin_lock_nested(&s->self_group.lock, <API key>); res = ops->pre_action(s, state); if (res < 0) goto _unlock; } <API key>(s, substream) { res = ops->do_action(s, state); if (res < 0) { if (ops->undo_action) { <API key>(s1, substream) { if (s1 == s) /* failed stream */ break; ops->undo_action(s1, state); } } s = NULL; /* unlock all */ goto _unlock; } } <API key>(s, substream) { ops->post_action(s, state); } _unlock: if (do_lock) { /* unlock streams */ <API key>(s1, substream) { if (s1 != substream) spin_unlock(&s1->self_group.lock); if (s1 == s) /* end */ break; } } return res; } /* * Note: call with stream lock */ static int <API key>(struct action_ops *ops, struct snd_pcm_substream *substream, int state) { int res; res = ops->pre_action(substream, state); if (res < 0) return res; res = ops->do_action(substream, state); if (res == 0) ops->post_action(substream, state); else if (ops->undo_action) ops->undo_action(substream, state); return res; } /* * Note: call with stream lock */ static int snd_pcm_action(struct action_ops *ops, struct snd_pcm_substream *substream, int state) { int res; if (<API key>(substream)) { if (!spin_trylock(&substream->group->lock)) { spin_unlock(&substream->self_group.lock); spin_lock(&substream->group->lock); spin_lock(&substream->self_group.lock); } res = <API key>(ops, substream, state, 1); spin_unlock(&substream->group->lock); } else { res = <API key>(ops, substream, state); } return res; } /* * Note: don't use any locks before */ static int <API key>(struct action_ops *ops, struct snd_pcm_substream *substream, int state) { int res; read_lock_irq(&snd_pcm_link_rwlock); if (<API key>(substream)) { spin_lock(&substream->group->lock); spin_lock(&substream->self_group.lock); res = <API key>(ops, substream, state, 1); spin_unlock(&substream->self_group.lock); spin_unlock(&substream->group->lock); } else { spin_lock(&substream->self_group.lock); res = <API key>(ops, substream, state); spin_unlock(&substream->self_group.lock); } read_unlock_irq(&snd_pcm_link_rwlock); return res; } static int <API key>(struct action_ops *ops, struct snd_pcm_substream *substream, int state) { int res; down_read(&snd_pcm_link_rwsem); if (<API key>(substream)) res = <API key>(ops, substream, state, 0); else res = <API key>(ops, substream, state); up_read(&snd_pcm_link_rwsem); return res; } /* * start callbacks */ static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state != <API key>) return -EBADFD; if (substream->stream == <API key> && !substream->hw_no_buffer && !<API key>(substream)) return -EPIPE; runtime->trigger_master = substream; return 0; } static int snd_pcm_do_start(struct snd_pcm_substream *substream, int state) { if (substream->runtime->trigger_master != substream) return 0; return substream->ops->trigger(substream, <API key>); } static void snd_pcm_undo_start(struct snd_pcm_substream *substream, int state) { if (substream->runtime->trigger_master == substream) substream->ops->trigger(substream, <API key>); } static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; <API key>(substream); runtime->hw_ptr_jiffies = jiffies; runtime-><API key> = (runtime->buffer_size * HZ) / runtime->rate; runtime->status->state = state; if (substream->stream == <API key> && runtime->silence_size > 0) <API key>(substream, ULONG_MAX); if (substream->timer) snd_timer_notify(substream->timer, <API key>, &runtime->trigger_tstamp); } static struct action_ops <API key> = { .pre_action = snd_pcm_pre_start, .do_action = snd_pcm_do_start, .undo_action = snd_pcm_undo_start, .post_action = snd_pcm_post_start }; /** * snd_pcm_start - start all linked streams * @substream: the PCM substream instance */ int snd_pcm_start(struct snd_pcm_substream *substream) { return snd_pcm_action(&<API key>, substream, <API key>); } /* * stop callbacks */ static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state == <API key>) return -EBADFD; runtime->trigger_master = substream; return 0; } static int snd_pcm_do_stop(struct snd_pcm_substream *substream, int state) { if (substream->runtime->trigger_master == substream && snd_pcm_running(substream)) substream->ops->trigger(substream, <API key>); return 0; /* unconditonally stop all substreams */ } static void snd_pcm_post_stop(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state != state) { <API key>(substream); if (substream->timer) snd_timer_notify(substream->timer, <API key>, &runtime->trigger_tstamp); runtime->status->state = state; } wake_up(&runtime->sleep); wake_up(&runtime->tsleep); } static struct action_ops snd_pcm_action_stop = { .pre_action = snd_pcm_pre_stop, .do_action = snd_pcm_do_stop, .post_action = snd_pcm_post_stop }; /** * snd_pcm_stop - try to stop all running streams in the substream group * @substream: the PCM substream instance * @state: PCM state after stopping the stream * * The state of each stream is then changed to the given state unconditionally. */ int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) { return snd_pcm_action(&snd_pcm_action_stop, substream, state); } EXPORT_SYMBOL(snd_pcm_stop); /** * snd_pcm_drain_done - stop the DMA only when the given stream is playback * @substream: the PCM substream * * After stopping, the state is changed to SETUP. * Unlike snd_pcm_stop(), this affects only the given stream. */ int snd_pcm_drain_done(struct snd_pcm_substream *substream) { return <API key>(&snd_pcm_action_stop, substream, <API key>); } /* * pause callbacks */ static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, int push) { struct snd_pcm_runtime *runtime = substream->runtime; if (!(runtime->info & <API key>)) return -ENOSYS; if (push) { if (runtime->status->state != <API key>) return -EBADFD; } else if (runtime->status->state != <API key>) return -EBADFD; runtime->trigger_master = substream; return 0; } static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push) { if (substream->runtime->trigger_master != substream) return 0; /* some drivers might use hw_ptr to recover from the pause - update the hw_ptr now */ if (push) <API key>(substream); /* The jiffies check in <API key>*() is done by * a delta between the current jiffies, this gives a large enough * delta, effectively to skip the check once. */ substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; return substream->ops->trigger(substream, push ? <API key> : <API key>); } static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, int push) { if (substream->runtime->trigger_master == substream) substream->ops->trigger(substream, push ? <API key> : <API key>); } static void snd_pcm_post_pause(struct snd_pcm_substream *substream, int push) { struct snd_pcm_runtime *runtime = substream->runtime; <API key>(substream); if (push) { runtime->status->state = <API key>; if (substream->timer) snd_timer_notify(substream->timer, <API key>, &runtime->trigger_tstamp); wake_up(&runtime->sleep); wake_up(&runtime->tsleep); } else { runtime->status->state = <API key>; if (substream->timer) snd_timer_notify(substream->timer, <API key>, &runtime->trigger_tstamp); } } static struct action_ops <API key> = { .pre_action = snd_pcm_pre_pause, .do_action = snd_pcm_do_pause, .undo_action = snd_pcm_undo_pause, .post_action = snd_pcm_post_pause }; /* * Push/release the pause for all linked streams. */ static int snd_pcm_pause(struct snd_pcm_substream *substream, int push) { return snd_pcm_action(&<API key>, substream, push); } #ifdef CONFIG_PM /* suspend */ static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state == <API key>) return -EBUSY; runtime->trigger_master = substream; return 0; } static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->trigger_master != substream) return 0; if (! snd_pcm_running(substream)) return 0; substream->ops->trigger(substream, <API key>); return 0; /* suspend unconditionally */ } static void <API key>(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; <API key>(substream); if (substream->timer) snd_timer_notify(substream->timer, <API key>, &runtime->trigger_tstamp); runtime->status->suspended_state = runtime->status->state; runtime->status->state = <API key>; wake_up(&runtime->sleep); wake_up(&runtime->tsleep); } static struct action_ops <API key> = { .pre_action = snd_pcm_pre_suspend, .do_action = snd_pcm_do_suspend, .post_action = <API key> }; /** * snd_pcm_suspend - trigger SUSPEND to all linked streams * @substream: the PCM substream * * After this call, all streams are changed to SUSPENDED state. */ int snd_pcm_suspend(struct snd_pcm_substream *substream) { int err; unsigned long flags; if (! substream) return 0; <API key>(substream, flags); err = snd_pcm_action(&<API key>, substream, 0); <API key>(substream, flags); return err; } EXPORT_SYMBOL(snd_pcm_suspend); /** * snd_pcm_suspend_all - trigger SUSPEND to all substreams in the given pcm * @pcm: the PCM instance * * After this call, all streams are changed to SUSPENDED state. */ int snd_pcm_suspend_all(struct snd_pcm *pcm) { struct snd_pcm_substream *substream; int stream, err = 0; if (! pcm) return 0; for (stream = 0; stream < 2; stream++) { for (substream = pcm->streams[stream].substream; substream; substream = substream->next) { /* FIXME: the open/close code should lock this as well */ if (substream->runtime == NULL) continue; err = snd_pcm_suspend(substream); if (err < 0 && err != -EBUSY) return err; } } return 0; } EXPORT_SYMBOL(snd_pcm_suspend_all); /* resume */ static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (!(runtime->info & <API key>)) return -ENOSYS; runtime->trigger_master = substream; return 0; } static int snd_pcm_do_resume(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->trigger_master != substream) return 0; /* DMA not running previously? */ if (runtime->status->suspended_state != <API key> && (runtime->status->suspended_state != <API key> || substream->stream != <API key>)) return 0; return substream->ops->trigger(substream, <API key>); } static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, int state) { if (substream->runtime->trigger_master == substream && snd_pcm_running(substream)) substream->ops->trigger(substream, <API key>); } static void snd_pcm_post_resume(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; <API key>(substream); if (substream->timer) snd_timer_notify(substream->timer, <API key>, &runtime->trigger_tstamp); runtime->status->state = runtime->status->suspended_state; } static struct action_ops <API key> = { .pre_action = snd_pcm_pre_resume, .do_action = snd_pcm_do_resume, .undo_action = snd_pcm_undo_resume, .post_action = snd_pcm_post_resume }; static int snd_pcm_resume(struct snd_pcm_substream *substream) { struct snd_card *card = substream->pcm->card; int res; snd_power_lock(card); if ((res = snd_power_wait(card, SNDRV_CTL_POWER_D0)) >= 0) res = <API key>(&<API key>, substream, 0); snd_power_unlock(card); return res; } #else static int snd_pcm_resume(struct snd_pcm_substream *substream) { return -ENOSYS; } #endif /* CONFIG_PM */ /* * xrun ioctl * * Change the RUNNING stream(s) to XRUN state. */ static int snd_pcm_xrun(struct snd_pcm_substream *substream) { struct snd_card *card = substream->pcm->card; struct snd_pcm_runtime *runtime = substream->runtime; int result; snd_power_lock(card); if (runtime->status->state == <API key>) { result = snd_power_wait(card, SNDRV_CTL_POWER_D0); if (result < 0) goto _unlock; } pr_info("%s ++", __func__); <API key>(substream); switch (runtime->status->state) { case <API key>: result = 0; /* already there */ break; case <API key>: result = snd_pcm_stop(substream, <API key>); break; default: result = -EBADFD; } pr_info("%s --", __func__); <API key>(substream); _unlock: snd_power_unlock(card); return result; } /* * reset ioctl */ static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; switch (runtime->status->state) { case <API key>: case <API key>: case <API key>: case <API key>: return 0; default: return -EBADFD; } } static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; int err = substream->ops->ioctl(substream, <API key>, NULL); if (err < 0) return err; runtime->hw_ptr_base = 0; runtime->hw_ptr_interrupt = runtime->status->hw_ptr - runtime->status->hw_ptr % runtime->period_size; runtime->silence_start = runtime->status->hw_ptr; runtime->silence_filled = 0; return 0; } static void snd_pcm_post_reset(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; runtime->control->appl_ptr = runtime->status->hw_ptr; if (substream->stream == <API key> && runtime->silence_size > 0) <API key>(substream, ULONG_MAX); } static struct action_ops <API key> = { .pre_action = snd_pcm_pre_reset, .do_action = snd_pcm_do_reset, .post_action = snd_pcm_post_reset }; static int snd_pcm_reset(struct snd_pcm_substream *substream) { return <API key>(&<API key>, substream, 0); } /* * prepare ioctl */ /* we use the second argument for updating f_flags */ static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, int f_flags) { struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state == <API key> || runtime->status->state == <API key>) return -EBADFD; if (snd_pcm_running(substream)) return -EBUSY; substream->f_flags = f_flags; return 0; } static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, int state) { int err; err = substream->ops->prepare(substream); if (err < 0) return err; return snd_pcm_do_reset(substream, 0); } static void <API key>(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; runtime->control->appl_ptr = runtime->status->hw_ptr; runtime->status->state = <API key>; } static struct action_ops <API key> = { .pre_action = snd_pcm_pre_prepare, .do_action = snd_pcm_do_prepare, .post_action = <API key> }; /** * snd_pcm_prepare - prepare the PCM substream to be triggerable * @substream: the PCM substream instance * @file: file to refer f_flags */ static int snd_pcm_prepare(struct snd_pcm_substream *substream, struct file *file) { int res; struct snd_card *card = substream->pcm->card; int f_flags; if (file) f_flags = file->f_flags; else f_flags = substream->f_flags; snd_power_lock(card); if ((res = snd_power_wait(card, SNDRV_CTL_POWER_D0)) >= 0) res = <API key>(&<API key>, substream, f_flags); snd_power_unlock(card); return res; } /* * drain ioctl */ static int <API key>(struct snd_pcm_substream *substream, int state) { substream->runtime->trigger_master = substream; return 0; } static int <API key>(struct snd_pcm_substream *substream, int state) { struct snd_pcm_runtime *runtime = substream->runtime; if (substream->stream == <API key>) { switch (runtime->status->state) { case <API key>: /* start playback stream if possible */ if (! <API key>(substream)) { snd_pcm_do_start(substream, <API key>); snd_pcm_post_start(substream, <API key>); } break; case <API key>: runtime->status->state = <API key>; break; default: break; } } else { /* stop running stream */ if (runtime->status->state == <API key>) { int new_state = <API key>(runtime) > 0 ? <API key> : <API key>; snd_pcm_do_stop(substream, new_state); snd_pcm_post_stop(substream, new_state); } } return 0; } static void <API key>(struct snd_pcm_substream *substream, int state) { } static struct action_ops <API key> = { .pre_action = <API key>, .do_action = <API key>, .post_action = <API key> }; static int snd_pcm_drop(struct snd_pcm_substream *substream); /* * Drain the stream(s). * When the substream is linked, sync until the draining of all playback streams * is finished. * After this call, all streams are supposed to be either SETUP or DRAINING * (capture only) state. */ static int snd_pcm_drain(struct snd_pcm_substream *substream, struct file *file) { struct snd_card *card; struct snd_pcm_runtime *runtime; struct snd_pcm_substream *s; wait_queue_t wait; int result = 0; int nonblock = 0; card = substream->pcm->card; runtime = substream->runtime; if (runtime->status->state == <API key>) return -EBADFD; snd_power_lock(card); if (runtime->status->state == <API key>) { result = snd_power_wait(card, SNDRV_CTL_POWER_D0); if (result < 0) { snd_power_unlock(card); return result; } } if (file) { if (file->f_flags & O_NONBLOCK) nonblock = 1; } else if (substream->f_flags & O_NONBLOCK) nonblock = 1; down_read(&snd_pcm_link_rwsem); pr_info("%s ++", __func__); <API key>(substream); /* resume pause */ if (runtime->status->state == <API key>) snd_pcm_pause(substream, 0); /* pre-start/stop - all running streams are changed to DRAINING state */ result = snd_pcm_action(&<API key>, substream, 0); if (result < 0) goto unlock; /* in non-blocking, we don't wait in ioctl but let caller poll */ if (nonblock) { result = -EAGAIN; goto unlock; } for (;;) { long tout; struct snd_pcm_runtime *to_check; if (signal_pending(current)) { result = -ERESTARTSYS; break; } /* find a substream to drain */ to_check = NULL; <API key>(s, substream) { if (s->stream != <API key>) continue; runtime = s->runtime; if (runtime->status->state == <API key>) { to_check = runtime; break; } } if (!to_check) break; /* all drained */ <API key>(&wait, current); add_wait_queue(&to_check->sleep, &wait); pr_info("%s --", __func__); <API key>(substream); up_read(&snd_pcm_link_rwsem); snd_power_unlock(card); if (runtime->no_period_wakeup) tout = <API key>; else { tout = 10; if (runtime->rate) { long t = runtime->period_size * 2 / runtime->rate; tout = max(t, tout); } tout = msecs_to_jiffies(tout * 1000); } tout = <API key>(tout); snd_power_lock(card); down_read(&snd_pcm_link_rwsem); pr_info("%s ++", __func__); <API key>(substream); remove_wait_queue(&to_check->sleep, &wait); if (tout == 0) { if (substream->runtime->status->state == <API key>) result = -ESTRPIPE; else { snd_printd("playback drain error (DMA or IRQ trouble?)\n"); snd_pcm_stop(substream, <API key>); result = -EIO; } break; } } unlock: pr_info("%s --", __func__); <API key>(substream); up_read(&snd_pcm_link_rwsem); snd_power_unlock(card); return result; } static int <API key>(struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { struct snd_pcm_runtime *runtime; int err = 0; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; pr_debug("%s called with cmd = %d\n", __func__, cmd); err = substream->ops->ioctl(substream, cmd, arg); return err; } static int snd_user_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { struct snd_pcm_runtime *runtime; int err = 0; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; err = substream->ops->ioctl(substream, cmd, arg); return err; } /* * drop ioctl * * Immediately put all linked substreams into SETUP state. */ static int snd_pcm_drop(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime; int result = 0; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; if (runtime->status->state == <API key> || runtime->status->state == <API key> || runtime->status->state == <API key>) return -EBADFD; pr_info("%s ++", __func__); <API key>(substream); /* resume pause */ if (runtime->status->state == <API key>) snd_pcm_pause(substream, 0); snd_pcm_stop(substream, <API key>); /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ pr_info("%s --", __func__); <API key>(substream); return result; } /* WARNING: Don't forget to fput back the file */ static struct file *snd_pcm_file_fd(int fd) { struct file *file; struct inode *inode; unsigned int minor; file = fget(fd); if (!file) return NULL; inode = file_inode(file); if (!S_ISCHR(inode->i_mode) || imajor(inode) != snd_major) { fput(file); return NULL; } minor = iminor(inode); if (!<API key>(minor, <API key>) && !<API key>(minor, <API key>)) { fput(file); return NULL; } return file; } /* * PCM link handling */ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) { int res = 0; struct file *file; struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream1; struct snd_pcm_group *group; file = snd_pcm_file_fd(fd); if (!file) return -EBADFD; pcm_file = file->private_data; substream1 = pcm_file->substream; group = kmalloc(sizeof(*group), GFP_KERNEL); if (!group) { res = -ENOMEM; goto _nolock; } down_write(&snd_pcm_link_rwsem); write_lock_irq(&snd_pcm_link_rwlock); if (substream->runtime->status->state == <API key> || substream->runtime->status->state != substream1->runtime->status->state) { res = -EBADFD; goto _end; } if (<API key>(substream1)) { res = -EALREADY; goto _end; } if (!<API key>(substream)) { substream->group = group; spin_lock_init(&substream->group->lock); INIT_LIST_HEAD(&substream->group->substreams); list_add_tail(&substream->link_list, &substream->group->substreams); substream->group->count = 1; } list_add_tail(&substream1->link_list, &substream->group->substreams); substream->group->count++; substream1->group = substream->group; _end: write_unlock_irq(&snd_pcm_link_rwlock); up_write(&snd_pcm_link_rwsem); _nolock: fput(file); if (res < 0) kfree(group); return res; } static void relink_to_local(struct snd_pcm_substream *substream) { substream->group = &substream->self_group; INIT_LIST_HEAD(&substream->self_group.substreams); list_add_tail(&substream->link_list, &substream->self_group.substreams); } static int snd_pcm_unlink(struct snd_pcm_substream *substream) { struct snd_pcm_substream *s; int res = 0; down_write(&snd_pcm_link_rwsem); write_lock_irq(&snd_pcm_link_rwlock); if (!<API key>(substream)) { res = -EALREADY; goto _end; } list_del(&substream->link_list); substream->group->count if (substream->group->count == 1) { /* detach the last stream, too */ <API key>(s, substream) { relink_to_local(s); break; } kfree(substream->group); } relink_to_local(substream); _end: write_unlock_irq(&snd_pcm_link_rwlock); up_write(&snd_pcm_link_rwsem); return res; } /* * hw configurator */ static int snd_pcm_hw_rule_mul(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_interval t; snd_interval_mul(hw_param_interval_c(params, rule->deps[0]), hw_param_interval_c(params, rule->deps[1]), &t); return snd_interval_refine(hw_param_interval(params, rule->var), &t); } static int snd_pcm_hw_rule_div(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_interval t; snd_interval_div(hw_param_interval_c(params, rule->deps[0]), hw_param_interval_c(params, rule->deps[1]), &t); return snd_interval_refine(hw_param_interval(params, rule->var), &t); } static int <API key>(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_interval t; <API key>(hw_param_interval_c(params, rule->deps[0]), hw_param_interval_c(params, rule->deps[1]), (unsigned long) rule->private, &t); return snd_interval_refine(hw_param_interval(params, rule->var), &t); } static int <API key>(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_interval t; <API key>(hw_param_interval_c(params, rule->deps[0]), (unsigned long) rule->private, hw_param_interval_c(params, rule->deps[1]), &t); return snd_interval_refine(hw_param_interval(params, rule->var), &t); } static int <API key>(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { unsigned int k; struct snd_interval *i = hw_param_interval(params, rule->deps[0]); struct snd_mask m; struct snd_mask *mask = hw_param_mask(params, <API key>); snd_mask_any(&m); for (k = 0; k <= <API key>; ++k) { int bits; if (! snd_mask_test(mask, k)) continue; bits = <API key>(k); if (bits <= 0) continue; /* ignore invalid formats */ if ((unsigned)bits < i->min || (unsigned)bits > i->max) snd_mask_reset(&m, k); } return snd_mask_refine(mask, &m); } static int <API key>(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_interval t; unsigned int k; t.min = UINT_MAX; t.max = 0; t.openmin = 0; t.openmax = 0; for (k = 0; k <= <API key>; ++k) { int bits; if (! snd_mask_test(hw_param_mask(params, <API key>), k)) continue; bits = <API key>(k); if (bits <= 0) continue; /* ignore invalid formats */ if (t.min > (unsigned)bits) t.min = bits; if (t.max < (unsigned)bits) t.max = bits; } t.integer = 1; return snd_interval_refine(hw_param_interval(params, rule->var), &t); } #if SNDRV_PCM_RATE_5512 != 1 << 0 || <API key> != 1 << 12 #error "Change this table" #endif static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000 }; const struct <API key> snd_pcm_known_rates = { .count = ARRAY_SIZE(rates), .list = rates, }; static int <API key>(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_pcm_hardware *hw = rule->private; return snd_interval_list(hw_param_interval(params, rule->var), snd_pcm_known_rates.count, snd_pcm_known_rates.list, hw->rates); } static int <API key>(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_interval t; struct snd_pcm_substream *substream = rule->private; t.min = 0; t.max = substream->buffer_bytes_max; t.openmin = 0; t.openmax = 0; t.integer = 1; return snd_interval_refine(hw_param_interval(params, rule->var), &t); } int <API key>(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct <API key> *constrs = &runtime->hw_constraints; int k, err; for (k = <API key>; k <= <API key>; k++) { snd_mask_any(constrs_mask(constrs, k)); } for (k = <API key>; k <= <API key>; k++) { snd_interval_any(constrs_interval(constrs, k)); } <API key>(constrs_interval(constrs, <API key>)); <API key>(constrs_interval(constrs, <API key>)); <API key>(constrs_interval(constrs, <API key>)); <API key>(constrs_interval(constrs, <API key>)); <API key>(constrs_interval(constrs, <API key>)); err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, NULL, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, NULL, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, snd_pcm_hw_rule_div, NULL, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, snd_pcm_hw_rule_mul, NULL, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 8, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 8, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, snd_pcm_hw_rule_div, NULL, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 1000000, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 1000000, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, snd_pcm_hw_rule_div, NULL, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, snd_pcm_hw_rule_div, NULL, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 8, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 1000000, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, snd_pcm_hw_rule_mul, NULL, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 8, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 1000000, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 8, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 8, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 1000000, <API key>, <API key>, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, (void*) 1000000, <API key>, <API key>, -1); if (err < 0) return err; return 0; } int <API key>(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_hardware *hw = &runtime->hw; int err; unsigned int mask = 0; if (hw->info & <API key>) mask |= 1 << <API key>; if (hw->info & <API key>) mask |= 1 << <API key>; if (hw->info & SNDRV_PCM_INFO_MMAP) { if (hw->info & <API key>) mask |= 1 << <API key>; if (hw->info & <API key>) mask |= 1 << <API key>; if (hw->info & <API key>) mask |= 1 << <API key>; } err = <API key>(runtime, <API key>, mask); if (err < 0) return err; err = <API key>(runtime, <API key>, hw->formats); if (err < 0) return err; err = <API key>(runtime, <API key>, 1 << <API key>); if (err < 0) return err; err = <API key>(runtime, <API key>, hw->channels_min, hw->channels_max); if (err < 0) return err; err = <API key>(runtime, <API key>, hw->rate_min, hw->rate_max); if (err < 0) return err; err = <API key>(runtime, <API key>, hw->period_bytes_min, hw->period_bytes_max); if (err < 0) return err; err = <API key>(runtime, <API key>, hw->periods_min, hw->periods_max); if (err < 0) return err; err = <API key>(runtime, <API key>, hw->period_bytes_min, hw->buffer_bytes_max); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, substream, <API key>, -1); if (err < 0) return err; /* FIXME: remove */ if (runtime->dma_bytes) { err = <API key>(runtime, <API key>, 0, runtime->dma_bytes); if (err < 0) return -EINVAL; } if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | <API key>))) { err = snd_pcm_hw_rule_add(runtime, 0, <API key>, <API key>, hw, <API key>, -1); if (err < 0) return err; } /* FIXME: this belong to lowlevel */ <API key>(runtime, <API key>); return 0; } static void pcm_release_private(struct snd_pcm_substream *substream) { snd_pcm_unlink(substream); } void <API key>(struct snd_pcm_substream *substream) { substream->ref_count if (substream->ref_count > 0) return; snd_pcm_drop(substream); if (substream->hw_opened) { if (substream->ops->hw_free != NULL) substream->ops->hw_free(substream); substream->ops->close(substream); substream->hw_opened = 0; } if (<API key>(&substream->latency_pm_qos_req)) <API key>(&substream->latency_pm_qos_req); if (substream->pcm_release) { substream->pcm_release(substream); substream->pcm_release = NULL; } <API key>(substream); } EXPORT_SYMBOL(<API key>); int <API key>(struct snd_pcm *pcm, int stream, struct file *file, struct snd_pcm_substream **rsubstream) { struct snd_pcm_substream *substream; int err; err = <API key>(pcm, stream, file, &substream); if (err < 0) return err; if (substream->ref_count > 1) { *rsubstream = substream; return 0; } err = <API key>(substream); if (err < 0) { snd_printd("<API key> failed\n"); goto error; } if (substream->ops == NULL) { snd_printd("cannot open back end PCMs directly\n"); err = -ENODEV; goto error; } if ((err = substream->ops->open(substream)) < 0) goto error; substream->hw_opened = 1; err = <API key>(substream); if (err < 0) { snd_printd("<API key> failed\n"); goto error; } *rsubstream = substream; return 0; error: <API key>(substream); return err; } EXPORT_SYMBOL(<API key>); static int snd_pcm_open_file(struct file *file, struct snd_pcm *pcm, int stream) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; int err; err = <API key>(pcm, stream, file, &substream); if (err < 0) return err; pcm_file = kzalloc(sizeof(*pcm_file), GFP_KERNEL); if (pcm_file == NULL) { <API key>(substream); return -ENOMEM; } pcm_file->substream = substream; if (substream->ref_count == 1) { substream->file = pcm_file; substream->pcm_release = pcm_release_private; } file->private_data = pcm_file; return 0; } static int <API key>(struct inode *inode, struct file *file) { struct snd_pcm *pcm; int err = nonseekable_open(inode, file); if (err < 0) return err; pcm = <API key>(iminor(inode), <API key>); return snd_pcm_open(file, pcm, <API key>); } static int <API key>(struct inode *inode, struct file *file) { struct snd_pcm *pcm; int err = nonseekable_open(inode, file); if (err < 0) return err; pcm = <API key>(iminor(inode), <API key>); return snd_pcm_open(file, pcm, <API key>); } static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) { int err; wait_queue_t wait; if (pcm == NULL) { err = -ENODEV; goto __error1; } err = snd_card_file_add(pcm->card, file); if (err < 0) goto __error1; if (!try_module_get(pcm->card->module)) { err = -EFAULT; goto __error2; } <API key>(&wait, current); add_wait_queue(&pcm->open_wait, &wait); mutex_lock(&pcm->open_mutex); while (1) { err = snd_pcm_open_file(file, pcm, stream); if (err >= 0) break; if (err == -EAGAIN) { if (file->f_flags & O_NONBLOCK) { err = -EBUSY; break; } } else break; set_current_state(TASK_INTERRUPTIBLE); mutex_unlock(&pcm->open_mutex); schedule(); mutex_lock(&pcm->open_mutex); if (signal_pending(current)) { err = -ERESTARTSYS; break; } } remove_wait_queue(&pcm->open_wait, &wait); mutex_unlock(&pcm->open_mutex); if (err < 0) goto __error; return err; __error: module_put(pcm->card->module); __error2: <API key>(pcm->card, file); __error1: return err; } static int snd_pcm_release(struct inode *inode, struct file *file) { struct snd_pcm *pcm; struct snd_pcm_substream *substream; struct snd_pcm_file *pcm_file; pcm_file = file->private_data; substream = pcm_file->substream; if (snd_BUG_ON(!substream)) return -ENXIO; pcm = substream->pcm; mutex_lock(&pcm->open_mutex); <API key>(substream); kfree(pcm_file); mutex_unlock(&pcm->open_mutex); wake_up(&pcm->open_wait); module_put(pcm->card->module); <API key>(pcm->card, file); return 0; } static snd_pcm_sframes_t <API key>(struct snd_pcm_substream *substream, snd_pcm_uframes_t frames) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t appl_ptr; snd_pcm_sframes_t ret; snd_pcm_sframes_t hw_avail; if (frames == 0) return 0; pr_info("%s ++", __func__); <API key>(substream); switch (runtime->status->state) { case <API key>: break; case <API key>: case <API key>: if (<API key>(substream) >= 0) break; /* Fall through */ case <API key>: ret = -EPIPE; goto __end; case <API key>: ret = -ESTRPIPE; goto __end; default: ret = -EBADFD; goto __end; } hw_avail = <API key>(runtime); if (hw_avail <= 0) { ret = 0; goto __end; } if (frames > (snd_pcm_uframes_t)hw_avail) frames = hw_avail; appl_ptr = runtime->control->appl_ptr - frames; if (appl_ptr < 0) appl_ptr += runtime->boundary; runtime->control->appl_ptr = appl_ptr; ret = frames; __end: pr_info("%s --", __func__); <API key>(substream); return ret; } static snd_pcm_sframes_t <API key>(struct snd_pcm_substream *substream, snd_pcm_uframes_t frames) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t appl_ptr; snd_pcm_sframes_t ret; snd_pcm_sframes_t hw_avail; if (frames == 0) return 0; pr_info("%s ++", __func__); <API key>(substream); switch (runtime->status->state) { case <API key>: case <API key>: break; case <API key>: if (<API key>(substream) >= 0) break; /* Fall through */ case <API key>: ret = -EPIPE; goto __end; case <API key>: ret = -ESTRPIPE; goto __end; default: ret = -EBADFD; goto __end; } hw_avail = <API key>(runtime); if (hw_avail <= 0) { ret = 0; goto __end; } if (frames > (snd_pcm_uframes_t)hw_avail) frames = hw_avail; appl_ptr = runtime->control->appl_ptr - frames; if (appl_ptr < 0) appl_ptr += runtime->boundary; runtime->control->appl_ptr = appl_ptr; ret = frames; __end: pr_info("%s --", __func__); <API key>(substream); return ret; } static snd_pcm_sframes_t <API key>(struct snd_pcm_substream *substream, snd_pcm_uframes_t frames) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t appl_ptr; snd_pcm_sframes_t ret; snd_pcm_sframes_t avail; if (frames == 0) return 0; pr_info("%s ++", __func__); <API key>(substream); switch (runtime->status->state) { case <API key>: case <API key>: break; case <API key>: case <API key>: if (<API key>(substream) >= 0) break; /* Fall through */ case <API key>: ret = -EPIPE; goto __end; case <API key>: ret = -ESTRPIPE; goto __end; default: ret = -EBADFD; goto __end; } avail = <API key>(runtime); if (avail <= 0) { ret = 0; goto __end; } if (frames > (snd_pcm_uframes_t)avail) frames = avail; appl_ptr = runtime->control->appl_ptr + frames; if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) appl_ptr -= runtime->boundary; runtime->control->appl_ptr = appl_ptr; ret = frames; __end: pr_info("%s --", __func__); <API key>(substream); return ret; } static snd_pcm_sframes_t <API key>(struct snd_pcm_substream *substream, snd_pcm_uframes_t frames) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t appl_ptr; snd_pcm_sframes_t ret; snd_pcm_sframes_t avail; if (frames == 0) return 0; pr_info("%s ++", __func__); <API key>(substream); switch (runtime->status->state) { case <API key>: case <API key>: case <API key>: break; case <API key>: if (<API key>(substream) >= 0) break; /* Fall through */ case <API key>: ret = -EPIPE; goto __end; case <API key>: ret = -ESTRPIPE; goto __end; default: ret = -EBADFD; goto __end; } avail = <API key>(runtime); if (avail <= 0) { ret = 0; goto __end; } if (frames > (snd_pcm_uframes_t)avail) frames = avail; appl_ptr = runtime->control->appl_ptr + frames; if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) appl_ptr -= runtime->boundary; runtime->control->appl_ptr = appl_ptr; ret = frames; __end: pr_info("%s --", __func__); <API key>(substream); return ret; } static int snd_pcm_hwsync(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; int err; <API key>(substream); switch (runtime->status->state) { case <API key>: if (substream->stream == <API key>) goto __badfd; case <API key>: if ((err = <API key>(substream)) < 0) break; /* Fall through */ case <API key>: case <API key>: err = 0; break; case <API key>: err = -EPIPE; break; default: __badfd: err = -EBADFD; break; } <API key>(substream); return err; } static int snd_pcm_delay(struct snd_pcm_substream *substream, snd_pcm_sframes_t __user *res) { struct snd_pcm_runtime *runtime = substream->runtime; int err; snd_pcm_sframes_t n = 0; pr_info("%s ++", __func__); <API key>(substream); switch (runtime->status->state) { case <API key>: if (substream->stream == <API key>) goto __badfd; case <API key>: if ((err = <API key>(substream)) < 0) break; /* Fall through */ case <API key>: case <API key>: err = 0; if (substream->stream == <API key>) n = <API key>(runtime); else n = <API key>(runtime); n += runtime->delay; break; case <API key>: err = -EPIPE; break; default: __badfd: err = -EBADFD; break; } pr_info("%s --", __func__); <API key>(substream); if (!err) if (put_user(n, res)) err = -EFAULT; return err; } static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, struct snd_pcm_sync_ptr __user *_sync_ptr) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_sync_ptr sync_ptr; volatile struct snd_pcm_mmap_status *status; volatile struct <API key> *control; int err; snd_pcm_uframes_t hw_avail; memset(&sync_ptr, 0, sizeof(sync_ptr)); if (get_user(sync_ptr.flags, (unsigned __user *)&(_sync_ptr->flags))) return -EFAULT; if (copy_from_user(&sync_ptr.c.control, &(_sync_ptr->c.control), sizeof(struct <API key>))) return -EFAULT; status = runtime->status; control = runtime->control; if (sync_ptr.flags & <API key>) { err = snd_pcm_hwsync(substream); if (err < 0) return err; } <API key>(substream); if (!(sync_ptr.flags & <API key>)) control->appl_ptr = sync_ptr.c.control.appl_ptr; else sync_ptr.c.control.appl_ptr = control->appl_ptr; if (!(sync_ptr.flags & <API key>)) control->avail_min = sync_ptr.c.control.avail_min; else sync_ptr.c.control.avail_min = control->avail_min; if (runtime->render_flag & SNDRV_NON_DMA_MODE) { hw_avail = <API key>(runtime); if ((hw_avail >= runtime->start_threshold) && (runtime->render_flag & <API key>)) { if (substream->ops->restart) substream->ops->restart(substream); } } sync_ptr.s.status.state = status->state; sync_ptr.s.status.hw_ptr = status->hw_ptr; sync_ptr.s.status.tstamp = status->tstamp; sync_ptr.s.status.suspended_state = status->suspended_state; <API key>(substream); if (copy_to_user(_sync_ptr, &sync_ptr, sizeof(sync_ptr))) return -EFAULT; return 0; } static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) { struct snd_pcm_runtime *runtime = substream->runtime; int arg; if (get_user(arg, _arg)) return -EFAULT; if (arg < 0 || arg > <API key>) return -EINVAL; runtime->tstamp_type = <API key>; if (arg == <API key>) runtime->tstamp_type = <API key>; return 0; } //htc audio ++ static int <API key>(struct snd_pcm_substream *substream, int __user *_arg) { /* if substream is NULL, return error. */ if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; pr_info("%s: is called\n", __func__); return substream->ops->ioctl(substream, <API key>, _arg); } //htc audio -- static int <API key>(struct file *file, struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { switch (cmd) { case <API key>: return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0; case <API key>: return snd_pcm_info_user(substream, arg); case <API key>: /* just for compatibility */ return 0; case <API key>: return snd_pcm_tstamp(substream, arg); case <API key>: return <API key>(substream, arg); case <API key>: return <API key>(substream, arg); case <API key>: return snd_pcm_hw_free(substream); case <API key>: return <API key>(substream, arg); case <API key>: return snd_pcm_status_user(substream, arg); case <API key>: return <API key>(substream, arg); case <API key>: return snd_pcm_prepare(substream, file); case <API key>: return snd_pcm_reset(substream); case <API key>: return <API key>(&<API key>, substream, <API key>); case <API key>: return snd_pcm_link(substream, (int)(unsigned long) arg); case <API key>: return snd_pcm_unlink(substream); case <API key>: return snd_pcm_resume(substream); case <API key>: return snd_pcm_xrun(substream); case <API key>: return snd_pcm_hwsync(substream); case <API key>: return snd_pcm_delay(substream, arg); case <API key>: return snd_pcm_sync_ptr(substream, arg); #ifdef <API key> case <API key>: return <API key>(substream, arg); case <API key>: return <API key>(substream, arg); #endif case <API key>: return snd_pcm_drain(substream, file); case <API key>: return snd_pcm_drop(substream); case <API key>: { int res; pr_info("%s ++", __func__); <API key>(substream); res = snd_pcm_pause(substream, (int)(unsigned long)arg); pr_info("%s --", __func__); <API key>(substream); return res; } //htc audio ++ case <API key>: return <API key>(substream, arg); //htc audio -- case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: return <API key>(substream, cmd, arg); default: if (((cmd >> 8) & 0xff) == 'U') return snd_user_ioctl(substream, cmd, arg); } snd_printd("unknown ioctl = 0x%x\n", cmd); return -ENOTTY; } static int <API key>(struct file *file, struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { if (snd_BUG_ON(!substream)) return -ENXIO; if (snd_BUG_ON(substream->stream != <API key>)) return -EINVAL; switch (cmd) { case <API key>: { struct snd_xferi xferi; struct snd_xferi __user *_xferi = arg; struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t result; if (runtime->status->state == <API key>) return -EBADFD; if (put_user(0, &_xferi->result)) return -EFAULT; if (copy_from_user(&xferi, _xferi, sizeof(xferi))) return -EFAULT; result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); __put_user(result, &_xferi->result); return result < 0 ? result : 0; } case <API key>: { struct snd_xfern xfern; struct snd_xfern __user *_xfern = arg; struct snd_pcm_runtime *runtime = substream->runtime; void __user **bufs; snd_pcm_sframes_t result; if (runtime->status->state == <API key>) return -EBADFD; if (runtime->channels > 128) return -EINVAL; if (put_user(0, &_xfern->result)) return -EFAULT; if (copy_from_user(&xfern, _xfern, sizeof(xfern))) return -EFAULT; bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels); if (IS_ERR(bufs)) return PTR_ERR(bufs); result = snd_pcm_lib_writev(substream, bufs, xfern.frames); kfree(bufs); __put_user(result, &_xfern->result); return result < 0 ? result : 0; } case <API key>: { snd_pcm_uframes_t frames; snd_pcm_uframes_t __user *_frames = arg; snd_pcm_sframes_t result; if (get_user(frames, _frames)) return -EFAULT; if (put_user(0, _frames)) return -EFAULT; result = <API key>(substream, frames); __put_user(result, _frames); return result < 0 ? result : 0; } case <API key>: { snd_pcm_uframes_t frames; snd_pcm_uframes_t __user *_frames = arg; snd_pcm_sframes_t result; if (get_user(frames, _frames)) return -EFAULT; if (put_user(0, _frames)) return -EFAULT; result = <API key>(substream, frames); __put_user(result, _frames); return result < 0 ? result : 0; } } return <API key>(file, substream, cmd, arg); } static int <API key>(struct file *file, struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { if (snd_BUG_ON(!substream)) return -ENXIO; if (snd_BUG_ON(substream->stream != <API key>)) return -EINVAL; switch (cmd) { case <API key>: { struct snd_xferi xferi; struct snd_xferi __user *_xferi = arg; struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t result; if (runtime->status->state == <API key>) return -EBADFD; if (put_user(0, &_xferi->result)) return -EFAULT; if (copy_from_user(&xferi, _xferi, sizeof(xferi))) return -EFAULT; result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); __put_user(result, &_xferi->result); return result < 0 ? result : 0; } case <API key>: { struct snd_xfern xfern; struct snd_xfern __user *_xfern = arg; struct snd_pcm_runtime *runtime = substream->runtime; void *bufs; snd_pcm_sframes_t result; if (runtime->status->state == <API key>) return -EBADFD; if (runtime->channels > 128) return -EINVAL; if (put_user(0, &_xfern->result)) return -EFAULT; if (copy_from_user(&xfern, _xfern, sizeof(xfern))) return -EFAULT; bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels); if (IS_ERR(bufs)) return PTR_ERR(bufs); result = snd_pcm_lib_readv(substream, bufs, xfern.frames); kfree(bufs); __put_user(result, &_xfern->result); return result < 0 ? result : 0; } case <API key>: { snd_pcm_uframes_t frames; snd_pcm_uframes_t __user *_frames = arg; snd_pcm_sframes_t result; if (get_user(frames, _frames)) return -EFAULT; if (put_user(0, _frames)) return -EFAULT; result = <API key>(substream, frames); __put_user(result, _frames); return result < 0 ? result : 0; } case <API key>: { snd_pcm_uframes_t frames; snd_pcm_uframes_t __user *_frames = arg; snd_pcm_sframes_t result; if (get_user(frames, _frames)) return -EFAULT; if (put_user(0, _frames)) return -EFAULT; result = <API key>(substream, frames); __put_user(result, _frames); return result < 0 ? result : 0; } } return <API key>(file, substream, cmd, arg); } static long <API key>(struct file *file, unsigned int cmd, unsigned long arg) { struct snd_pcm_file *pcm_file; pcm_file = file->private_data; if ((((cmd >> 8) & 0xff) != 'A') && (((cmd >> 8) & 0xff) != 'C')) return -ENOTTY; return <API key>(file, pcm_file->substream, cmd, (void __user *)arg); } static long <API key>(struct file *file, unsigned int cmd, unsigned long arg) { struct snd_pcm_file *pcm_file; unsigned char ioctl_magic; pcm_file = file->private_data; ioctl_magic = ((cmd >> 8) & 0xff); if (ioctl_magic != 'A' && ioctl_magic != 'C' && ioctl_magic != 'U') return -ENOTTY; return <API key>(file, pcm_file->substream, cmd, (void __user *)arg); } int <API key>(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { mm_segment_t fs; int result; fs = snd_enter_user(); switch (substream->stream) { case <API key>: result = <API key>(NULL, substream, cmd, (void __user *)arg); break; case <API key>: result = <API key>(NULL, substream, cmd, (void __user *)arg); break; default: result = -EINVAL; break; } snd_leave_user(fs); return result; } EXPORT_SYMBOL(<API key>); static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count, loff_t * offset) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; if (runtime->status->state == <API key>) return -EBADFD; if (!frame_aligned(runtime, count)) return -EINVAL; count = bytes_to_frames(runtime, count); result = snd_pcm_lib_read(substream, buf, count); if (result > 0) result = frames_to_bytes(runtime, result); return result; } static ssize_t snd_pcm_write(struct file *file, const char __user *buf, size_t count, loff_t * offset) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; if (runtime->status->state == <API key>) return -EBADFD; if (!frame_aligned(runtime, count)) return -EINVAL; count = bytes_to_frames(runtime, count); result = snd_pcm_lib_write(substream, buf, count); if (result > 0) result = frames_to_bytes(runtime, result); return result; } static ssize_t snd_pcm_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; unsigned long i; void __user **bufs; snd_pcm_uframes_t frames; pcm_file = iocb->ki_filp->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; if (runtime->status->state == <API key>) return -EBADFD; if (nr_segs > 1024 || nr_segs != runtime->channels) return -EINVAL; if (!frame_aligned(runtime, iov->iov_len)) return -EINVAL; frames = bytes_to_samples(runtime, iov->iov_len); bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL); if (bufs == NULL) return -ENOMEM; for (i = 0; i < nr_segs; ++i) bufs[i] = iov[i].iov_base; result = snd_pcm_lib_readv(substream, bufs, frames); if (result > 0) result = frames_to_bytes(runtime, result); kfree(bufs); return result; } static ssize_t snd_pcm_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; unsigned long i; void __user **bufs; snd_pcm_uframes_t frames; pcm_file = iocb->ki_filp->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; if (runtime->status->state == <API key>) return -EBADFD; if (nr_segs > 128 || nr_segs != runtime->channels || !frame_aligned(runtime, iov->iov_len)) return -EINVAL; frames = bytes_to_samples(runtime, iov->iov_len); bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL); if (bufs == NULL) return -ENOMEM; for (i = 0; i < nr_segs; ++i) bufs[i] = iov[i].iov_base; result = snd_pcm_lib_writev(substream, bufs, frames); if (result > 0) result = frames_to_bytes(runtime, result); kfree(bufs); return result; } static unsigned int <API key>(struct file *file, poll_table * wait) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; unsigned int mask; snd_pcm_uframes_t avail; pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; poll_wait(file, &runtime->sleep, wait); <API key>(substream); avail = <API key>(runtime); switch (runtime->status->state) { case <API key>: case <API key>: case <API key>: if (avail >= runtime->control->avail_min) { mask = POLLOUT | POLLWRNORM; break; } /* Fall through */ case <API key>: mask = 0; break; default: mask = POLLOUT | POLLWRNORM | POLLERR; break; } <API key>(substream); return mask; } static unsigned int <API key>(struct file *file, poll_table * wait) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; unsigned int mask; snd_pcm_uframes_t avail; pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; poll_wait(file, &runtime->sleep, wait); <API key>(substream); avail = <API key>(runtime); switch (runtime->status->state) { case <API key>: case <API key>: case <API key>: if (avail >= runtime->control->avail_min) { mask = POLLIN | POLLRDNORM; break; } mask = 0; break; case <API key>: if (avail > 0) { mask = POLLIN | POLLRDNORM; break; } /* Fall through */ default: mask = POLLIN | POLLRDNORM | POLLERR; break; } <API key>(substream); return mask; } /* * mmap support */ /* * Only on coherent architectures, we can mmap the status and the control records * for effcient data transfer. On others, we have to use HWSYNC ioctl... */ #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA) /* * mmap status record */ static int <API key>(struct vm_area_struct *area, struct vm_fault *vmf) { struct snd_pcm_substream *substream = area->vm_private_data; struct snd_pcm_runtime *runtime; if (substream == NULL) return VM_FAULT_SIGBUS; runtime = substream->runtime; vmf->page = virt_to_page(runtime->status); get_page(vmf->page); return 0; } static const struct <API key> <API key> = { .fault = <API key>, }; static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { long size; if (!(area->vm_flags & VM_READ)) return -EINVAL; size = area->vm_end - area->vm_start; if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) return -EINVAL; area->vm_ops = &<API key>; area->vm_private_data = substream; area->vm_flags |= VM_RESERVED; return 0; } /* * mmap control record */ static int <API key>(struct vm_area_struct *area, struct vm_fault *vmf) { struct snd_pcm_substream *substream = area->vm_private_data; struct snd_pcm_runtime *runtime; if (substream == NULL) return VM_FAULT_SIGBUS; runtime = substream->runtime; vmf->page = virt_to_page(runtime->control); get_page(vmf->page); return 0; } static const struct <API key> <API key> = { .fault = <API key>, }; static int <API key>(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { long size; if (!(area->vm_flags & VM_READ)) return -EINVAL; size = area->vm_end - area->vm_start; if (size != PAGE_ALIGN(sizeof(struct <API key>))) return -EINVAL; area->vm_ops = &<API key>; area->vm_private_data = substream; area->vm_flags |= VM_RESERVED; return 0; } #else /* ! coherent mmap */ /* * don't support mmap for status and control records. */ static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { return -ENXIO; } static int <API key>(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { return -ENXIO; } #endif /* coherent mmap */ static inline struct page * <API key>(struct snd_pcm_substream *substream, unsigned long ofs) { void *vaddr = substream->runtime->dma_area + ofs; #if defined(CONFIG_MIPS) && defined(<API key>) if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) return virt_to_page(CAC_ADDR(vaddr)); #endif #if defined(CONFIG_PPC32) && defined(<API key>) if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) { dma_addr_t addr = substream->runtime->dma_addr + ofs; addr -= get_dma_offset(substream->dma_buffer.dev.dev); /* assume dma_handle set via pfn_to_phys() in * mm/dma-noncoherent.c */ return pfn_to_page(addr >> PAGE_SHIFT); } #endif return virt_to_page(vaddr); } /* * fault callback for mmapping a RAM page */ static int <API key>(struct vm_area_struct *area, struct vm_fault *vmf) { struct snd_pcm_substream *substream = area->vm_private_data; struct snd_pcm_runtime *runtime; unsigned long offset; struct page * page; size_t dma_bytes; if (substream == NULL) return VM_FAULT_SIGBUS; runtime = substream->runtime; offset = vmf->pgoff << PAGE_SHIFT; dma_bytes = PAGE_ALIGN(runtime->dma_bytes); if (offset > dma_bytes - PAGE_SIZE) return VM_FAULT_SIGBUS; if (substream->ops->page) page = substream->ops->page(substream, offset); else page = <API key>(substream, offset); if (!page) return VM_FAULT_SIGBUS; get_page(page); vmf->page = page; return 0; } static const struct <API key> snd_pcm_vm_ops_data = { .open = <API key>, .close = <API key>, }; static const struct <API key> <API key> = { .open = <API key>, .close = <API key>, .fault = <API key>, }; #ifndef <API key> /* This should be defined / handled globally! */ #ifdef CONFIG_ARM #define <API key> #endif #endif /* * mmap the DMA buffer on RAM */ int <API key>(struct snd_pcm_substream *substream, struct vm_area_struct *area) { area->vm_flags |= VM_RESERVED; #ifdef <API key> if (!substream->ops->page && substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) return dma_mmap_coherent(substream->dma_buffer.dev.dev, area, substream->runtime->dma_area, substream->runtime->dma_addr, area->vm_end - area->vm_start); #elif defined(CONFIG_MIPS) && defined(<API key>) if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV && !<API key>(substream->dma_buffer.dev.dev)) area->vm_page_prot = pgprot_noncached(area->vm_page_prot); #endif /* <API key> */ /* mmap with fault handler */ area->vm_ops = &<API key>; return 0; } EXPORT_SYMBOL_GPL(<API key>); /* * mmap the DMA buffer on I/O memory area */ #if <API key> int <API key>(struct snd_pcm_substream *substream, struct vm_area_struct *area) { long size; unsigned long offset; area->vm_page_prot = pgprot_noncached(area->vm_page_prot); area->vm_flags |= VM_IO; size = area->vm_end - area->vm_start; offset = area->vm_pgoff << PAGE_SHIFT; if (io_remap_pfn_range(area, area->vm_start, (substream->runtime->dma_addr + offset) >> PAGE_SHIFT, size, area->vm_page_prot)) return -EAGAIN; return 0; } EXPORT_SYMBOL(<API key>); #endif /* SNDRV_PCM_INFO_MMAP */ /* * mmap DMA buffer */ int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { struct snd_pcm_runtime *runtime; long size; unsigned long offset; size_t dma_bytes; int err; if (substream->stream == <API key>) { if (!(area->vm_flags & (VM_WRITE|VM_READ))) return -EINVAL; } else { if (!(area->vm_flags & VM_READ)) return -EINVAL; } runtime = substream->runtime; if (runtime->status->state == <API key>) return -EBADFD; if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) return -ENXIO; if (runtime->access == <API key> || runtime->access == <API key>) return -EINVAL; size = area->vm_end - area->vm_start; offset = area->vm_pgoff << PAGE_SHIFT; dma_bytes = PAGE_ALIGN(runtime->dma_bytes); if ((size_t)size > dma_bytes) return -EINVAL; if (offset > dma_bytes - size) return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_data; area->vm_private_data = substream; if (substream->ops->mmap) err = substream->ops->mmap(substream, area); else err = <API key>(substream, area); if (!err) atomic_inc(&substream->mmap_count); return err; } EXPORT_SYMBOL(snd_pcm_mmap_data); static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area) { struct snd_pcm_file * pcm_file; struct snd_pcm_substream *substream; unsigned long offset; pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; offset = area->vm_pgoff << PAGE_SHIFT; switch (offset) { case <API key>: if (pcm_file->no_compat_mmap) return -ENXIO; return snd_pcm_mmap_status(substream, file, area); case <API key>: if (pcm_file->no_compat_mmap) return -ENXIO; return <API key>(substream, file, area); default: return snd_pcm_mmap_data(substream, file, area); } return 0; } static int snd_pcm_fasync(int fd, struct file * file, int on) { struct snd_pcm_file * pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; return fasync_helper(fd, file, on, &runtime->fasync); } /* * ioctl32 compat */ #ifdef CONFIG_COMPAT #include "pcm_compat.c" #else #define <API key> NULL #endif /* * To be removed helpers to keep binary compatibility */ #ifdef <API key> #define __OLD_TO_NEW_MASK(x) ((x&7)|((x&0x07fffff8)<<5)) #define __NEW_TO_OLD_MASK(x) ((x&7)|((x&0xffffff00)>>5)) static void <API key>(struct snd_pcm_hw_params *params, struct <API key> *oparams) { unsigned int i; memset(params, 0, sizeof(*params)); params->flags = oparams->flags; for (i = 0; i < ARRAY_SIZE(oparams->masks); i++) params->masks[i].bits[0] = oparams->masks[i]; memcpy(params->intervals, oparams->intervals, sizeof(oparams->intervals)); params->rmask = __OLD_TO_NEW_MASK(oparams->rmask); params->cmask = __OLD_TO_NEW_MASK(oparams->cmask); params->info = oparams->info; params->msbits = oparams->msbits; params->rate_num = oparams->rate_num; params->rate_den = oparams->rate_den; params->fifo_size = oparams->fifo_size; } static void <API key>(struct <API key> *oparams, struct snd_pcm_hw_params *params) { unsigned int i; memset(oparams, 0, sizeof(*oparams)); oparams->flags = params->flags; for (i = 0; i < ARRAY_SIZE(oparams->masks); i++) oparams->masks[i] = params->masks[i].bits[0]; memcpy(oparams->intervals, params->intervals, sizeof(oparams->intervals)); oparams->rmask = __NEW_TO_OLD_MASK(params->rmask); oparams->cmask = __NEW_TO_OLD_MASK(params->cmask); oparams->info = params->info; oparams->msbits = params->msbits; oparams->rate_num = params->rate_num; oparams->rate_den = params->rate_den; oparams->fifo_size = params->fifo_size; } static int <API key>(struct snd_pcm_substream *substream, struct <API key> __user * _oparams) { struct snd_pcm_hw_params *params; struct <API key> *oparams = NULL; int err; params = kmalloc(sizeof(*params), GFP_KERNEL); if (!params) return -ENOMEM; oparams = memdup_user(_oparams, sizeof(*oparams)); if (IS_ERR(oparams)) { err = PTR_ERR(oparams); goto out; } <API key>(params, oparams); err = snd_pcm_hw_refine(substream, params); <API key>(oparams, params); if (copy_to_user(_oparams, oparams, sizeof(*oparams))) { if (!err) err = -EFAULT; } kfree(oparams); out: kfree(params); return err; } static int <API key>(struct snd_pcm_substream *substream, struct <API key> __user * _oparams) { struct snd_pcm_hw_params *params; struct <API key> *oparams = NULL; int err; params = kmalloc(sizeof(*params), GFP_KERNEL); if (!params) return -ENOMEM; oparams = memdup_user(_oparams, sizeof(*oparams)); if (IS_ERR(oparams)) { err = PTR_ERR(oparams); goto out; } <API key>(params, oparams); err = snd_pcm_hw_params(substream, params); <API key>(oparams, params); if (copy_to_user(_oparams, oparams, sizeof(*oparams))) { if (!err) err = -EFAULT; } kfree(oparams); out: kfree(params); return err; } #endif /* <API key> */ #ifndef CONFIG_MMU static unsigned long <API key>(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { struct snd_pcm_file *pcm_file = file->private_data; struct snd_pcm_substream *substream = pcm_file->substream; struct snd_pcm_runtime *runtime = substream->runtime; unsigned long offset = pgoff << PAGE_SHIFT; switch (offset) { case <API key>: return (unsigned long)runtime->status; case <API key>: return (unsigned long)runtime->control; default: return (unsigned long)runtime->dma_area + offset; } } #else # define <API key> NULL #endif /* * Register section */ const struct file_operations snd_pcm_f_ops[2] = { { .owner = THIS_MODULE, .write = snd_pcm_write, .aio_write = snd_pcm_aio_write, .open = <API key>, .release = snd_pcm_release, .llseek = no_llseek, .poll = <API key>, .unlocked_ioctl = <API key>, .compat_ioctl = <API key>, .mmap = snd_pcm_mmap, .fasync = snd_pcm_fasync, .get_unmapped_area = <API key>, }, { .owner = THIS_MODULE, .read = snd_pcm_read, .aio_read = snd_pcm_aio_read, .open = <API key>, .release = snd_pcm_release, .llseek = no_llseek, .poll = <API key>, .unlocked_ioctl = <API key>, .compat_ioctl = <API key>, .mmap = snd_pcm_mmap, .fasync = snd_pcm_fasync, .get_unmapped_area = <API key>, } };
source: API/PortGroups.md `<API key>` Get the graph based on the group type. Route: `/api/v0/devices/portgroups/:group` - group is the type of port group graph you want, I.e Transit, Peering, etc. You can specify multiple types comma separated. Input: - from: This is the date you would like the graph to start - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information. - to: This is the date you would like the graph to end - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information. - width: The graph width, defaults to 1075. - height: The graph height, defaults to 300. Example: curl curl -H 'X-Auth-<API key> https://librenms.org/api/v0/portgroups/transit,peering Output: Output is an image. `<API key>` Get the graph based on the multiple port id separated by commas `,`. Route: `/api/v0/devices/portgroups/multiport/bits/:id` - id is a comma separated list of port ids you want, I.e 1,2,3,4, etc. You can specify multiple IDs comma separated. Input: - from: This is the date you would like the graph to start - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information. - to: This is the date you would like the graph to end - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information. - width: The graph width, defaults to 1075. - height: The graph height, defaults to 300. Example: curl curl -H 'X-Auth-<API key> https://librenms.org/api/v0/portgroups/multiport/bits/1,2,3 Output: Output is an image.
#ifndef <API key> #define <API key> #include <gnuradio/filter/api.h> #include <gnuradio/gr_complex.h> #include <vector> #include <stdexcept> namespace gr { namespace filter { namespace kernel { /*! * \brief Base class template for Infinite Impulse Response filter (IIR) * * \details * * This class provides a templated kernel for IIR filters. These * iir_filters can be instantiated with a set of feed-forward * and feed-back taps in the constructor. We then call the * iir_filter::filter function to add a new sample to the * filter, or iir_filter::filter_n to add a vector of samples to * be filtered. * * Instantiating a filter means defining the templates for the * data types being processed by the filter. There are four templates: * * \li i_type the data type of the input data (i.e., float). * \li o_type the data type of the output data (i.e., float). * \li tap_type the data type of the filter taps (i.e., double). * \li acc_type the data type of the internal accumulator (i.e., double). * * The acc_type is specified to control how data is handled * internally in the filter. This should always be the highest * precision data type of any of the first three. Often, IIR * filters require double-precision values in the taps for * stability, and so the internal accumulator should also be * double precision. * * Example: * * \code * gr::filter::kernel::iir_filter<float,float,double,double> iir_filt(fftaps, fbtaps); * ... * float y = iir_filt.filter(x); * * <or> * * iir_filt.filter(y, x, N); // y and x are float arrays * \endcode * * Another example for handling complex samples with * double-precision taps (see filter::iir_filter_ccz): * * \code * gr:;filter::kernel::iir_filter<gr_complex, gr_complex, gr_complexd, gr_complexd> iir_filt(fftaps, fbtaps); * \endcode */ template<class i_type, class o_type, class tap_type, class acc_type> class FILTER_API iir_filter { public: /*! * \brief Construct an IIR with the given taps. * * This filter uses the Direct Form I implementation, where * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones. * * \p fftaps and \p fbtaps must have equal numbers of taps * * \p oldstyle: The old style of the IIR filter uses feedback * taps that are negative of what most definitions use (scipy * and Matlab among them). This parameter keeps using the old * GNU Radio style and is set to TRUE by default. When taps * generated from scipy, Matlab, or gr_filter_design, use the * new style by setting this to FALSE. * * The input and output satisfy a difference equation of the form \f[ y[n] \pm \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k] \f] * with the corresponding rational system function \f[ H(z) = \frac{\sum_{k=0}^{N} b_k z^{-k}}{1 \pm \sum_{k=1}^{M} a_k z^{-k}} \f] */ iir_filter(const std::vector<tap_type>& fftaps, const std::vector<tap_type>& fbtaps, bool oldstyle=true) throw (std::invalid_argument) { d_oldstyle = oldstyle; set_taps(fftaps, fbtaps); } iir_filter() : d_latest_n(0),d_latest_m(0) { } ~iir_filter() {} /*! * \brief compute a single output value. * \returns the filtered input value. */ o_type filter(const i_type input); /*! * \brief compute an array of N output values. * \p input must have N valid entries. */ void filter_n(o_type output[], const i_type input[], long n); /*! * \return number of taps in filter. */ unsigned ntaps_ff() const { return d_fftaps.size(); } unsigned ntaps_fb() const { return d_fbtaps.size(); } /*! * \brief install new taps. */ void set_taps(const std::vector<tap_type> &fftaps, const std::vector<tap_type> &fbtaps) throw (std::invalid_argument) { d_latest_n = 0; d_latest_m = 0; d_fftaps = fftaps; if(d_oldstyle) { d_fbtaps = fbtaps; } else { // New style negates taps a[1:N-1] to fit with most IIR // tap generating programs. d_fbtaps.resize(fbtaps.size()); d_fbtaps[0] = fbtaps[0]; for(size_t i = 1; i < fbtaps.size(); i++) { d_fbtaps[i] = -fbtaps[i]; } } int n = fftaps.size(); int m = fbtaps.size(); d_prev_input.clear(); d_prev_output.clear(); d_prev_input.resize(2 * n, 0); d_prev_output.resize(2 * m, 0); } protected: bool d_oldstyle; std::vector<tap_type> d_fftaps; std::vector<tap_type> d_fbtaps; int d_latest_n; int d_latest_m; std::vector<acc_type> d_prev_output; std::vector<i_type> d_prev_input; }; // general case. We may want to specialize this template<class i_type, class o_type, class tap_type, class acc_type> o_type iir_filter<i_type, o_type, tap_type, acc_type>::filter(const i_type input) { acc_type acc; unsigned i = 0; unsigned n = ntaps_ff(); unsigned m = ntaps_fb(); if(n == 0) return (o_type)0; int latest_n = d_latest_n; int latest_m = d_latest_m; acc = d_fftaps[0] * input; for(i = 1; i < n; i ++) acc += (d_fftaps[i] * d_prev_input[latest_n + i]); for(i = 1; i < m; i ++) acc += (d_fbtaps[i] * d_prev_output[latest_m + i]); // store the values twice to avoid having to handle wrap-around in the loop d_prev_output[latest_m] = acc; d_prev_output[latest_m+m] = acc; d_prev_input[latest_n] = input; d_prev_input[latest_n+n] = input; latest_n latest_m if(latest_n < 0) latest_n += n; if(latest_m < 0) latest_m += m; d_latest_m = latest_m; d_latest_n = latest_n; return (o_type)acc; } template<class i_type, class o_type, class tap_type, class acc_type> void iir_filter<i_type, o_type, tap_type, acc_type>::filter_n(o_type output[], const i_type input[], long n) { for(int i = 0; i < n; i++) output[i] = filter(input[i]); } template<> gr_complex iir_filter<gr_complex, gr_complex, float, gr_complex>::filter(const gr_complex input); template<> gr_complex iir_filter<gr_complex, gr_complex, double, gr_complexd>::filter(const gr_complex input); template<> gr_complex iir_filter<gr_complex, gr_complex, gr_complexd, gr_complexd>::filter(const gr_complex input); } /* namespace kernel */ } /* namespace filter */ } /* namespace gr */ #endif /* <API key> */
#ifndef __LWP_MUTEX_H__ #define __LWP_MUTEX_H__ #include <gctypes.h> #include <lwp_threadq.h> #define LWP_MUTEX_LOCKED 0 #define LWP_MUTEX_UNLOCKED 1 #define <API key> 0 #define <API key> 1 #define <API key> 2 #define LWP_MUTEX_FIFO 0 #define LWP_MUTEX_PRIORITY 1 #define <API key> 2 #define <API key> 3 #define <API key> 0 #define <API key> 1 #define <API key> 2 #define LWP_MUTEX_NOTOWNER 3 #define LWP_MUTEX_DELETED 4 #define LWP_MUTEX_TIMEOUT 5 #define <API key> 6 #ifdef __cplusplus extern "C" { #endif typedef struct _lwpmutexattr { u32 mode; u32 nest_behavior; u8 prioceil,onlyownerrelease; } lwp_mutex_attr; typedef struct _lwpmutex { lwp_thrqueue wait_queue; lwp_mutex_attr atrrs; u32 lock,nest_cnt,blocked_cnt; lwp_cntrl *holder; } lwp_mutex; void <API key>(lwp_mutex *mutex,lwp_mutex_attr *attrs,u32 init_lock); u32 <API key>(lwp_mutex *mutex); void <API key>(lwp_mutex *mutex,u64 timeout); void __lwp_mutex_flush(lwp_mutex *mutex,u32 status); static __inline__ u32 <API key>(lwp_mutex *mutex,u32 *isr_level); #define __lwp_mutex_seize(_mutex_t,_id,_wait,_timeout,_level) \ do { \ if(<API key>(_mutex_t,&_level)) { \ if(!_wait) { \ _CPU_ISR_Restore(_level); \ _thr_executing->wait.ret_code = <API key>; \ } else { \ <API key>(&(_mutex_t)->wait_queue); \ _thr_executing->wait.queue = &(_mutex_t)->wait_queue; \ _thr_executing->wait.id = _id; \ <API key>(); \ _CPU_ISR_Restore(_level); \ <API key>(_mutex_t,(u64)_timeout); \ } \ } \ } while(0) #ifdef LIBOGC_INTERNAL #include <libogc/lwp_mutex.inl> #endif #ifdef __cplusplus } #endif #endif
#!/usr/bin/env python import vtk from vtk.test import Testing from vtk.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() ren1 = vtk.vtkRenderer() renWin = vtk.vtkRenderWindow() renWin.AddRenderer(ren1) iren = vtk.<API key>() iren.SetRenderWindow(renWin) # create a scene with one of each cell type # Voxel voxelPoints = vtk.vtkPoints() voxelPoints.SetNumberOfPoints(8) voxelPoints.InsertPoint(0,0,0,0) voxelPoints.InsertPoint(1,1,0,0) voxelPoints.InsertPoint(2,0,1,0) voxelPoints.InsertPoint(3,1,1,0) voxelPoints.InsertPoint(4,0,0,1) voxelPoints.InsertPoint(5,1,0,1) voxelPoints.InsertPoint(6,0,1,1) voxelPoints.InsertPoint(7,1,1,1) aVoxel = vtk.vtkVoxel() aVoxel.GetPointIds().SetId(0,0) aVoxel.GetPointIds().SetId(1,1) aVoxel.GetPointIds().SetId(2,2) aVoxel.GetPointIds().SetId(3,3) aVoxel.GetPointIds().SetId(4,4) aVoxel.GetPointIds().SetId(5,5) aVoxel.GetPointIds().SetId(6,6) aVoxel.GetPointIds().SetId(7,7) aVoxelGrid = vtk.vtkUnstructuredGrid() aVoxelGrid.Allocate(1,1) aVoxelGrid.InsertNextCell(aVoxel.GetCellType(),aVoxel.GetPointIds()) aVoxelGrid.SetPoints(voxelPoints) aVoxelMapper = vtk.vtkDataSetMapper() aVoxelMapper.SetInputData(aVoxelGrid) aVoxelActor = vtk.vtkActor() aVoxelActor.SetMapper(aVoxelMapper) aVoxelActor.GetProperty().BackfaceCullingOn() # Hexahedron hexahedronPoints = vtk.vtkPoints() hexahedronPoints.SetNumberOfPoints(8) hexahedronPoints.InsertPoint(0,0,0,0) hexahedronPoints.InsertPoint(1,1,0,0) hexahedronPoints.InsertPoint(2,1,1,0) hexahedronPoints.InsertPoint(3,0,1,0) hexahedronPoints.InsertPoint(4,0,0,1) hexahedronPoints.InsertPoint(5,1,0,1) hexahedronPoints.InsertPoint(6,1,1,1) hexahedronPoints.InsertPoint(7,0,1,1) aHexahedron = vtk.vtkHexahedron() aHexahedron.GetPointIds().SetId(0,0) aHexahedron.GetPointIds().SetId(1,1) aHexahedron.GetPointIds().SetId(2,2) aHexahedron.GetPointIds().SetId(3,3) aHexahedron.GetPointIds().SetId(4,4) aHexahedron.GetPointIds().SetId(5,5) aHexahedron.GetPointIds().SetId(6,6) aHexahedron.GetPointIds().SetId(7,7) aHexahedronGrid = vtk.vtkUnstructuredGrid() aHexahedronGrid.Allocate(1,1) aHexahedronGrid.InsertNextCell(aHexahedron.GetCellType(),aHexahedron.GetPointIds()) aHexahedronGrid.SetPoints(hexahedronPoints) aHexahedronMapper = vtk.vtkDataSetMapper() aHexahedronMapper.SetInputData(aHexahedronGrid) aHexahedronActor = vtk.vtkActor() aHexahedronActor.SetMapper(aHexahedronMapper) aHexahedronActor.AddPosition(2,0,0) aHexahedronActor.GetProperty().BackfaceCullingOn() # Tetra tetraPoints = vtk.vtkPoints() tetraPoints.SetNumberOfPoints(4) tetraPoints.InsertPoint(0,0,0,0) tetraPoints.InsertPoint(1,1,0,0) tetraPoints.InsertPoint(2,.5,1,0) tetraPoints.InsertPoint(3,.5,.5,1) aTetra = vtk.vtkTetra() aTetra.GetPointIds().SetId(0,0) aTetra.GetPointIds().SetId(1,1) aTetra.GetPointIds().SetId(2,2) aTetra.GetPointIds().SetId(3,3) aTetraGrid = vtk.vtkUnstructuredGrid() aTetraGrid.Allocate(1,1) aTetraGrid.InsertNextCell(aTetra.GetCellType(),aTetra.GetPointIds()) aTetraGrid.SetPoints(tetraPoints) aTetraMapper = vtk.vtkDataSetMapper() aTetraMapper.SetInputData(aTetraGrid) aTetraActor = vtk.vtkActor() aTetraActor.SetMapper(aTetraMapper) aTetraActor.AddPosition(4,0,0) aTetraActor.GetProperty().BackfaceCullingOn() # Wedge wedgePoints = vtk.vtkPoints() wedgePoints.SetNumberOfPoints(6) wedgePoints.InsertPoint(0,0,1,0) wedgePoints.InsertPoint(1,0,0,0) wedgePoints.InsertPoint(2,0,.5,.5) wedgePoints.InsertPoint(3,1,1,0) wedgePoints.InsertPoint(4,1,0,0) wedgePoints.InsertPoint(5,1,.5,.5) aWedge = vtk.vtkWedge() aWedge.GetPointIds().SetId(0,0) aWedge.GetPointIds().SetId(1,1) aWedge.GetPointIds().SetId(2,2) aWedge.GetPointIds().SetId(3,3) aWedge.GetPointIds().SetId(4,4) aWedge.GetPointIds().SetId(5,5) aWedgeGrid = vtk.vtkUnstructuredGrid() aWedgeGrid.Allocate(1,1) aWedgeGrid.InsertNextCell(aWedge.GetCellType(),aWedge.GetPointIds()) aWedgeGrid.SetPoints(wedgePoints) aWedgeMapper = vtk.vtkDataSetMapper() aWedgeMapper.SetInputData(aWedgeGrid) aWedgeActor = vtk.vtkActor() aWedgeActor.SetMapper(aWedgeMapper) aWedgeActor.AddPosition(6,0,0) aWedgeActor.GetProperty().BackfaceCullingOn() # Pyramid pyramidPoints = vtk.vtkPoints() pyramidPoints.SetNumberOfPoints(5) pyramidPoints.InsertPoint(0,0,0,0) pyramidPoints.InsertPoint(1,1,0,0) pyramidPoints.InsertPoint(2,1,1,0) pyramidPoints.InsertPoint(3,0,1,0) pyramidPoints.InsertPoint(4,.5,.5,1) aPyramid = vtk.vtkPyramid() aPyramid.GetPointIds().SetId(0,0) aPyramid.GetPointIds().SetId(1,1) aPyramid.GetPointIds().SetId(2,2) aPyramid.GetPointIds().SetId(3,3) aPyramid.GetPointIds().SetId(4,4) aPyramidGrid = vtk.vtkUnstructuredGrid() aPyramidGrid.Allocate(1,1) aPyramidGrid.InsertNextCell(aPyramid.GetCellType(),aPyramid.GetPointIds()) aPyramidGrid.SetPoints(pyramidPoints) aPyramidMapper = vtk.vtkDataSetMapper() aPyramidMapper.SetInputData(aPyramidGrid) aPyramidActor = vtk.vtkActor() aPyramidActor.SetMapper(aPyramidMapper) aPyramidActor.AddPosition(8,0,0) aPyramidActor.GetProperty().BackfaceCullingOn() # Pixel pixelPoints = vtk.vtkPoints() pixelPoints.SetNumberOfPoints(4) pixelPoints.InsertPoint(0,0,0,0) pixelPoints.InsertPoint(1,1,0,0) pixelPoints.InsertPoint(2,0,1,0) pixelPoints.InsertPoint(3,1,1,0) aPixel = vtk.vtkPixel() aPixel.GetPointIds().SetId(0,0) aPixel.GetPointIds().SetId(1,1) aPixel.GetPointIds().SetId(2,2) aPixel.GetPointIds().SetId(3,3) aPixelGrid = vtk.vtkUnstructuredGrid() aPixelGrid.Allocate(1,1) aPixelGrid.InsertNextCell(aPixel.GetCellType(),aPixel.GetPointIds()) aPixelGrid.SetPoints(pixelPoints) aPixelMapper = vtk.vtkDataSetMapper() aPixelMapper.SetInputData(aPixelGrid) aPixelActor = vtk.vtkActor() aPixelActor.SetMapper(aPixelMapper) aPixelActor.AddPosition(0,0,2) aPixelActor.GetProperty().BackfaceCullingOn() # Quad quadPoints = vtk.vtkPoints() quadPoints.SetNumberOfPoints(4) quadPoints.InsertPoint(0,0,0,0) quadPoints.InsertPoint(1,1,0,0) quadPoints.InsertPoint(2,1,1,0) quadPoints.InsertPoint(3,0,1,0) aQuad = vtk.vtkQuad() aQuad.GetPointIds().SetId(0,0) aQuad.GetPointIds().SetId(1,1) aQuad.GetPointIds().SetId(2,2) aQuad.GetPointIds().SetId(3,3) aQuadGrid = vtk.vtkUnstructuredGrid() aQuadGrid.Allocate(1,1) aQuadGrid.InsertNextCell(aQuad.GetCellType(),aQuad.GetPointIds()) aQuadGrid.SetPoints(quadPoints) aQuadMapper = vtk.vtkDataSetMapper() aQuadMapper.SetInputData(aQuadGrid) aQuadActor = vtk.vtkActor() aQuadActor.SetMapper(aQuadMapper) aQuadActor.AddPosition(2,0,2) aQuadActor.GetProperty().BackfaceCullingOn() # Triangle trianglePoints = vtk.vtkPoints() trianglePoints.SetNumberOfPoints(3) trianglePoints.InsertPoint(0,0,0,0) trianglePoints.InsertPoint(1,1,0,0) trianglePoints.InsertPoint(2,.5,.5,0) aTriangle = vtk.vtkTriangle() aTriangle.GetPointIds().SetId(0,0) aTriangle.GetPointIds().SetId(1,1) aTriangle.GetPointIds().SetId(2,2) aTriangleGrid = vtk.vtkUnstructuredGrid() aTriangleGrid.Allocate(1,1) aTriangleGrid.InsertNextCell(aTriangle.GetCellType(),aTriangle.GetPointIds()) aTriangleGrid.SetPoints(trianglePoints) aTriangleMapper = vtk.vtkDataSetMapper() aTriangleMapper.SetInputData(aTriangleGrid) aTriangleActor = vtk.vtkActor() aTriangleActor.SetMapper(aTriangleMapper) aTriangleActor.AddPosition(4,0,2) aTriangleActor.GetProperty().BackfaceCullingOn() # Polygon polygonPoints = vtk.vtkPoints() polygonPoints.SetNumberOfPoints(4) polygonPoints.InsertPoint(0,0,0,0) polygonPoints.InsertPoint(1,1,0,0) polygonPoints.InsertPoint(2,1,1,0) polygonPoints.InsertPoint(3,0,1,0) aPolygon = vtk.vtkPolygon() aPolygon.GetPointIds().SetNumberOfIds(4) aPolygon.GetPointIds().SetId(0,0) aPolygon.GetPointIds().SetId(1,1) aPolygon.GetPointIds().SetId(2,2) aPolygon.GetPointIds().SetId(3,3) aPolygonGrid = vtk.vtkUnstructuredGrid() aPolygonGrid.Allocate(1,1) aPolygonGrid.InsertNextCell(aPolygon.GetCellType(),aPolygon.GetPointIds()) aPolygonGrid.SetPoints(polygonPoints) aPolygonMapper = vtk.vtkDataSetMapper() aPolygonMapper.SetInputData(aPolygonGrid) aPolygonActor = vtk.vtkActor() aPolygonActor.SetMapper(aPolygonMapper) aPolygonActor.AddPosition(6,0,2) aPolygonActor.GetProperty().BackfaceCullingOn() # Triangle Strip triangleStripPoints = vtk.vtkPoints() triangleStripPoints.SetNumberOfPoints(5) triangleStripPoints.InsertPoint(0,0,1,0) triangleStripPoints.InsertPoint(1,0,0,0) triangleStripPoints.InsertPoint(2,1,1,0) triangleStripPoints.InsertPoint(3,1,0,0) triangleStripPoints.InsertPoint(4,2,1,0) aTriangleStrip = vtk.vtkTriangleStrip() aTriangleStrip.GetPointIds().SetNumberOfIds(5) aTriangleStrip.GetPointIds().SetId(0,0) aTriangleStrip.GetPointIds().SetId(1,1) aTriangleStrip.GetPointIds().SetId(2,2) aTriangleStrip.GetPointIds().SetId(3,3) aTriangleStrip.GetPointIds().SetId(4,4) aTriangleStripGrid = vtk.vtkUnstructuredGrid() aTriangleStripGrid.Allocate(1,1) aTriangleStripGrid.InsertNextCell(aTriangleStrip.GetCellType(),aTriangleStrip.GetPointIds()) aTriangleStripGrid.SetPoints(triangleStripPoints) <API key> = vtk.vtkDataSetMapper() <API key>.SetInputData(aTriangleStripGrid) aTriangleStripActor = vtk.vtkActor() aTriangleStripActor.SetMapper(<API key>) aTriangleStripActor.AddPosition(8,0,2) aTriangleStripActor.GetProperty().BackfaceCullingOn() # Line linePoints = vtk.vtkPoints() linePoints.SetNumberOfPoints(2) linePoints.InsertPoint(0,0,0,0) linePoints.InsertPoint(1,1,1,0) aLine = vtk.vtkLine() aLine.GetPointIds().SetId(0,0) aLine.GetPointIds().SetId(1,1) aLineGrid = vtk.vtkUnstructuredGrid() aLineGrid.Allocate(1,1) aLineGrid.InsertNextCell(aLine.GetCellType(),aLine.GetPointIds()) aLineGrid.SetPoints(linePoints) aLineMapper = vtk.vtkDataSetMapper() aLineMapper.SetInputData(aLineGrid) aLineActor = vtk.vtkActor() aLineActor.SetMapper(aLineMapper) aLineActor.AddPosition(0,0,4) aLineActor.GetProperty().BackfaceCullingOn() # Poly line polyLinePoints = vtk.vtkPoints() polyLinePoints.SetNumberOfPoints(3) polyLinePoints.InsertPoint(0,0,0,0) polyLinePoints.InsertPoint(1,1,1,0) polyLinePoints.InsertPoint(2,1,0,0) aPolyLine = vtk.vtkPolyLine() aPolyLine.GetPointIds().SetNumberOfIds(3) aPolyLine.GetPointIds().SetId(0,0) aPolyLine.GetPointIds().SetId(1,1) aPolyLine.GetPointIds().SetId(2,2) aPolyLineGrid = vtk.vtkUnstructuredGrid() aPolyLineGrid.Allocate(1,1) aPolyLineGrid.InsertNextCell(aPolyLine.GetCellType(),aPolyLine.GetPointIds()) aPolyLineGrid.SetPoints(polyLinePoints) aPolyLineMapper = vtk.vtkDataSetMapper() aPolyLineMapper.SetInputData(aPolyLineGrid) aPolyLineActor = vtk.vtkActor() aPolyLineActor.SetMapper(aPolyLineMapper) aPolyLineActor.AddPosition(2,0,4) aPolyLineActor.GetProperty().BackfaceCullingOn() # Vertex vertexPoints = vtk.vtkPoints() vertexPoints.SetNumberOfPoints(1) vertexPoints.InsertPoint(0,0,0,0) aVertex = vtk.vtkVertex() aVertex.GetPointIds().SetId(0,0) aVertexGrid = vtk.vtkUnstructuredGrid() aVertexGrid.Allocate(1,1) aVertexGrid.InsertNextCell(aVertex.GetCellType(),aVertex.GetPointIds()) aVertexGrid.SetPoints(vertexPoints) aVertexMapper = vtk.vtkDataSetMapper() aVertexMapper.SetInputData(aVertexGrid) aVertexActor = vtk.vtkActor() aVertexActor.SetMapper(aVertexMapper) aVertexActor.AddPosition(0,0,6) aVertexActor.GetProperty().BackfaceCullingOn() # Poly Vertex polyVertexPoints = vtk.vtkPoints() polyVertexPoints.SetNumberOfPoints(3) polyVertexPoints.InsertPoint(0,0,0,0) polyVertexPoints.InsertPoint(1,1,0,0) polyVertexPoints.InsertPoint(2,1,1,0) aPolyVertex = vtk.vtkPolyVertex() aPolyVertex.GetPointIds().SetNumberOfIds(3) aPolyVertex.GetPointIds().SetId(0,0) aPolyVertex.GetPointIds().SetId(1,1) aPolyVertex.GetPointIds().SetId(2,2) aPolyVertexGrid = vtk.vtkUnstructuredGrid() aPolyVertexGrid.Allocate(1,1) aPolyVertexGrid.InsertNextCell(aPolyVertex.GetCellType(),aPolyVertex.GetPointIds()) aPolyVertexGrid.SetPoints(polyVertexPoints) aPolyVertexMapper = vtk.vtkDataSetMapper() aPolyVertexMapper.SetInputData(aPolyVertexGrid) aPolyVertexActor = vtk.vtkActor() aPolyVertexActor.SetMapper(aPolyVertexMapper) aPolyVertexActor.AddPosition(2,0,6) aPolyVertexActor.GetProperty().BackfaceCullingOn() # Pentagonal prism pentaPoints = vtk.vtkPoints() pentaPoints.SetNumberOfPoints(10) pentaPoints.InsertPoint(0,0.25,0.0,0.0) pentaPoints.InsertPoint(1,0.75,0.0,0.0) pentaPoints.InsertPoint(2,1.0,0.5,0.0) pentaPoints.InsertPoint(3,0.5,1.0,0.0) pentaPoints.InsertPoint(4,0.0,0.5,0.0) pentaPoints.InsertPoint(5,0.25,0.0,1.0) pentaPoints.InsertPoint(6,0.75,0.0,1.0) pentaPoints.InsertPoint(7,1.0,0.5,1.0) pentaPoints.InsertPoint(8,0.5,1.0,1.0) pentaPoints.InsertPoint(9,0.0,0.5,1.0) aPenta = vtk.vtkPentagonalPrism() aPenta.GetPointIds().SetId(0,0) aPenta.GetPointIds().SetId(1,1) aPenta.GetPointIds().SetId(2,2) aPenta.GetPointIds().SetId(3,3) aPenta.GetPointIds().SetId(4,4) aPenta.GetPointIds().SetId(5,5) aPenta.GetPointIds().SetId(6,6) aPenta.GetPointIds().SetId(7,7) aPenta.GetPointIds().SetId(8,8) aPenta.GetPointIds().SetId(9,9) aPentaGrid = vtk.vtkUnstructuredGrid() aPentaGrid.Allocate(1,1) aPentaGrid.InsertNextCell(aPenta.GetCellType(),aPenta.GetPointIds()) aPentaGrid.SetPoints(pentaPoints) aPentaMapper = vtk.vtkDataSetMapper() aPentaMapper.SetInputData(aPentaGrid) aPentaActor = vtk.vtkActor() aPentaActor.SetMapper(aPentaMapper) aPentaActor.AddPosition(10,0,0) aPentaActor.GetProperty().BackfaceCullingOn() # Hexagonal prism hexaPoints = vtk.vtkPoints() hexaPoints.SetNumberOfPoints(12) hexaPoints.InsertPoint(0,0.0,0.0,0.0) hexaPoints.InsertPoint(1,0.5,0.0,0.0) hexaPoints.InsertPoint(2,1.0,0.5,0.0) hexaPoints.InsertPoint(3,1.0,1.0,0.0) hexaPoints.InsertPoint(4,0.5,1.0,0.0) hexaPoints.InsertPoint(5,0.0,0.5,0.0) hexaPoints.InsertPoint(6,0.0,0.0,1.0) hexaPoints.InsertPoint(7,0.5,0.0,1.0) hexaPoints.InsertPoint(8,1.0,0.5,1.0) hexaPoints.InsertPoint(9,1.0,1.0,1.0) hexaPoints.InsertPoint(10,0.5,1.0,1.0) hexaPoints.InsertPoint(11,0.0,0.5,1.0) aHexa = vtk.vtkHexagonalPrism() aHexa.GetPointIds().SetId(0,0) aHexa.GetPointIds().SetId(1,1) aHexa.GetPointIds().SetId(2,2) aHexa.GetPointIds().SetId(3,3) aHexa.GetPointIds().SetId(4,4) aHexa.GetPointIds().SetId(5,5) aHexa.GetPointIds().SetId(6,6) aHexa.GetPointIds().SetId(7,7) aHexa.GetPointIds().SetId(8,8) aHexa.GetPointIds().SetId(9,9) aHexa.GetPointIds().SetId(10,10) aHexa.GetPointIds().SetId(11,11) aHexaGrid = vtk.vtkUnstructuredGrid() aHexaGrid.Allocate(1,1) aHexaGrid.InsertNextCell(aHexa.GetCellType(),aHexa.GetPointIds()) aHexaGrid.SetPoints(hexaPoints) aHexaMapper = vtk.vtkDataSetMapper() aHexaMapper.SetInputData(aHexaGrid) aHexaActor = vtk.vtkActor() aHexaActor.SetMapper(aHexaMapper) aHexaActor.AddPosition(12,0,0) aHexaActor.GetProperty().BackfaceCullingOn() ren1.SetBackground(.1,.2,.4) ren1.AddActor(aVoxelActor) aVoxelActor.GetProperty().SetDiffuseColor(1,0,0) ren1.AddActor(aHexahedronActor) aHexahedronActor.GetProperty().SetDiffuseColor(1,1,0) ren1.AddActor(aTetraActor) aTetraActor.GetProperty().SetDiffuseColor(0,1,0) ren1.AddActor(aWedgeActor) aWedgeActor.GetProperty().SetDiffuseColor(0,1,1) ren1.AddActor(aPyramidActor) aPyramidActor.GetProperty().SetDiffuseColor(1,0,1) ren1.AddActor(aPixelActor) aPixelActor.GetProperty().SetDiffuseColor(0,1,1) ren1.AddActor(aQuadActor) aQuadActor.GetProperty().SetDiffuseColor(1,0,1) ren1.AddActor(aTriangleActor) aTriangleActor.GetProperty().SetDiffuseColor(.3,1,.5) ren1.AddActor(aPolygonActor) aPolygonActor.GetProperty().SetDiffuseColor(1,.4,.5) ren1.AddActor(aTriangleStripActor) aTriangleStripActor.GetProperty().SetDiffuseColor(.3,.7,1) ren1.AddActor(aLineActor) aLineActor.GetProperty().SetDiffuseColor(.2,1,1) ren1.AddActor(aPolyLineActor) aPolyLineActor.GetProperty().SetDiffuseColor(1,1,1) ren1.AddActor(aVertexActor) aVertexActor.GetProperty().SetDiffuseColor(1,1,1) ren1.AddActor(aPolyVertexActor) aPolyVertexActor.GetProperty().SetDiffuseColor(1,1,1) ren1.AddActor(aPentaActor) aPentaActor.GetProperty().SetDiffuseColor(.2,.4,.7) ren1.AddActor(aHexaActor) aHexaActor.GetProperty().SetDiffuseColor(.7,.5,1) ren1.ResetCamera() ren1.GetActiveCamera().Azimuth(30) ren1.GetActiveCamera().Elevation(20) ren1.GetActiveCamera().Dolly(1.25) ren1.<API key>() renWin.Render() cellPicker = vtk.vtkCellPicker() pointPicker = vtk.vtkPointPicker() worldPicker = vtk.vtkWorldPointPicker() cellCount = 0 pointCount = 0 ren1.IsInViewport(0,0) x = 0 while x <= 265: y = 100 while y <= 200: cellPicker.Pick(x,y,0,ren1) pointPicker.Pick(x,y,0,ren1) worldPicker.Pick(x,y,0,ren1) if (cellPicker.GetCellId() != "-1"): cellCount = cellCount + 1 pass if (pointPicker.GetPointId() != "-1"): pointCount = pointCount + 1 pass y = y + 6 x = x + 6 # render the image iren.Initialize()
#include <kccachedb.h> using namespace std; using namespace kyotocabinet; // main routine int main(int argc, char** argv) { // create the database object GrassDB db; // open the database if (!db.open("*", GrassDB::OWRITER | GrassDB::OCREATE)) { cerr << "open error: " << db.error().name() << endl; } // store records if (!db.set("foo", "hop") || !db.set("bar", "step") || !db.set("baz", "jump")) { cerr << "set error: " << db.error().name() << endl; } // retrieve a record string value; if (db.get("foo", &value)) { cout << value << endl; } else { cerr << "get error: " << db.error().name() << endl; } // traverse records DB::Cursor* cur = db.cursor(); cur->jump(); string ckey, cvalue; while (cur->get(&ckey, &cvalue, true)) { cout << ckey << ":" << cvalue << endl; } delete cur; // close the database if (!db.close()) { cerr << "close error: " << db.error().name() << endl; } return 0; }
/** * \file cyutils.c * \version 5.40 * * \brief Provides a function to handle 24-bit value writes. * ******************************************************************************** * \copyright * Copyright 2008-2016, Cypress Semiconductor Corporation. All rights reserved. * You may use this file only in accordance with the license, terms, conditions, * disclaimers, and limitations in the end user license agreement accompanying * the software package with which this file was provided. *******************************************************************************/ #include "cytypes.h" #if (!CY_PSOC3) ************************************************************************//** void CySetReg24(uint32 volatile * addr, uint32 value) { uint8 volatile *tmpAddr; tmpAddr = (uint8 volatile *) addr; tmpAddr[0u] = (uint8) value; tmpAddr[1u] = (uint8) (value >> 8u); tmpAddr[2u] = (uint8) (value >> 16u); } #if(CY_PSOC4) ************************************************************************//** uint32 CyGetReg24(uint32 const volatile * addr) { uint8 const volatile *tmpAddr; uint32 value; tmpAddr = (uint8 const volatile *) addr; value = (uint32) tmpAddr[0u]; value |= ((uint32) tmpAddr[1u] << 8u ); value |= ((uint32) tmpAddr[2u] << 16u); return(value); } #endif /*(CY_PSOC4)*/ #endif /* (!CY_PSOC3) */ /* [] END OF FILE */
#ifndef <API key> #define <API key> #include <linux/ioctl.h> enum smschar_pnp_event_t { <API key>, <API key>, <API key>, <API key>, <API key>, <API key> }; struct smschar_buffer_t { unsigned long offset; /* offset in common buffer (mapped to user) */ int size; }; struct <API key> { int mode; char filename[200]; }; struct <API key> { char *fw_buf; int fw_size; }; struct <API key> { char *buf; int size; }; #define <API key> _IOW('K', 0, int) #define <API key> _IOR('K', 1, int) #define <API key> _IOR('K', 2, int) #define <API key> _IOR('K', 3, struct smschar_buffer_t) #define <API key> _IOR('K', 4, int) #define <API key> \ _IOWR('K', 5, struct <API key>) #define <API key> \ _IOW('K', 6, struct <API key>) #define <API key> _IO('K', 7) #define SMSCHAR_CANCEL_POLL _IO('K', 8) #define <API key> _IO('K', 9) #define <API key> \ _IOW('K', 10, struct <API key>) #define <API key> \ _IOW('K', 11, struct <API key>) #define <API key> _IOW('K', 12, int) #endif /* <API key> */