answer
stringlengths
15
1.25M
<API key> ================= Bash Scripts for Raspberry 24/7
/* $Id: <API key>.cpp $ */ /** @file * IPRT - User & Kernel Memory, Ring-0 Driver, Darwin. */ #include "the-darwin-kernel.h" #include "internal/iprt.h" #include <iprt/mem.h> #include <iprt/assert.h> #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) # include <iprt/asm-amd64-x86.h> #endif #include <iprt/err.h> RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb) { RT_ASSERT_INTS_ON(); int rc = copyin((const user_addr_t)R3PtrSrc, pvDst, cb); if (RT_LIKELY(rc == 0)) return VINF_SUCCESS; return VERR_ACCESS_DENIED; } RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb) { RT_ASSERT_INTS_ON(); int rc = copyout(pvSrc, R3PtrDst, cb); if (RT_LIKELY(rc == 0)) return VINF_SUCCESS; return VERR_ACCESS_DENIED; } RTR0DECL(bool) <API key>(RTR3PTR R3Ptr) { /* the commpage is above this. */ #ifdef RT_ARCH_X86 return R3Ptr < VM_MAX_ADDRESS; #else return R3Ptr < VM_MAX_PAGE_ADDRESS; #endif } RTR0DECL(bool) <API key>(void *pv) { /* Found no public #define or symbol for checking this, so we'll have to make do with thing found in the debugger and the sources. */ #ifdef RT_ARCH_X86 NOREF(pv); return true; /* Almost anything is a valid kernel address here. */ #elif defined(RT_ARCH_AMD64) return (uintptr_t)pv >= UINT64_C(0xffff800000000000); #else # error "PORTME" #endif } RTR0DECL(bool) <API key>(void) { /* As mentioned in <API key>, found no way of checking this at compiler or runtime. */ #ifdef RT_ARCH_X86 return false; #else return true; #endif }
// <auto-generated> // This code was generated by a tool. // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> namespace SteamShift.Properties { <summary> A strongly-typed resource class, for looking up localized strings, etc. </summary> // This class was auto-generated by the <API key> // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.<API key>( "System.Resources.Tools.<API key>", "4.0.0.0" )] [global::System.Diagnostics.<API key>()] [global::System.Runtime.CompilerServices.<API key>()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.<API key>( "Microsoft.Performance", "CA1811:<API key>" )] internal Resources() { } <summary> Returns the cached ResourceManager instance used by this class. </summary> [global::System.ComponentModel.<API key>( global::System.ComponentModel.<API key>.Advanced )] internal static global::System.Resources.ResourceManager ResourceManager { get { if ( ( resourceMan == null ) ) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager( "SteamShift.Properties.Resources", typeof( Resources ).Assembly ); resourceMan = temp; } return resourceMan; } } <summary> Overrides the current thread's CurrentUICulture property for all resource lookups using this strongly typed resource class. </summary> [global::System.ComponentModel.<API key>( global::System.ComponentModel.<API key>.Advanced )] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } }
<div id="obligee_volumen" class="viz" data-viz="treemap-a" data-graph="treemap-a"> <div class="row"> <div class="col-sm-12"> <h3>Volumen de recursos de revisión, por sujeto obligado y por sentido de la resolución: <span class="year-range">2007 - 2015</span></h3> <p class="lead">Recursos de revisión que se realizan por sujeto obligado, tanto de acceso a la información como de datos personales</p> <!--<a href="#" class="download" download><b></b>Descargar datos</a>--> </div> <div class="col-sm-10 col-sm-offset-1"> <p class="instructions">Da clic sobre un sector para observar la distribución del número de solicitudes por sujeto obligado y tipo de solicitud. Para regresar, da clic sobre el área gris en la parte superior de la gráfica. </p> </div> </div> <section id="treemap-a"></section> <!--source <div class="row"> <div class="col-sm-10 col-sm-offset-1"> <!--source <?php include "templates/source.php";?> <p class="lead info">Distribución de la gráfica</p> <ul class="info row"> <li class="col-sm-3">Primer nivel: <strong>Sector</strong></li> <li class="col-sm-3">Segundo nivel: <strong>Sujeto obligado</strong></li> <li class="col-sm-3">Tercer nivel: <strong>Sentido de la resolución</strong> </li> <li class="col-sm-3">Tamaño: <strong>Número de solicitudes</strong></li> </ul> </div> </div> </div>
#ifndef <API key> #define <API key> 1 #include <utility> #include <list> #include <algorithm> namespace LAC { namespace Difference { template<typename T> struct NeighborSet { typedef T data_t; typedef std::list<T> queue_t; typedef typename queue_t::iterator it_t; typedef typename queue_t::const_iterator const_it_t; NeighborSet(size_t count) : m_count(std::max((size_t)1,count)) {} ~NeighborSet(){} void Append(const T& d){ it_t it = std::lower_bound(m_queue.begin(), m_queue.end(), d); m_queue.insert(it, d); if(m_queue.size() > m_count) m_queue.pop_back(); } const_it_t Begin() const { return m_queue.begin(); } const_it_t End() const { return m_queue.end(); } size_t m_count; queue_t m_queue; }; } } #endif
package com.carpoolsophia; import java.util.concurrent.ExecutionException; import org.json.JSONException; import org.json.JSONObject; import android.app.Fragment; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import butterknife.InjectView; import butterknife.Views; import com.carpoolsophia.gcloudApi.model.CarpoolSophiaUser; import com.carpoolsophia.service.<API key>; import com.carpoolsophia.service.ProfileService; import com.facebook.AccessToken; import com.facebook.AccessTokenUtils; import com.facebook.GraphRequest; import com.facebook.GraphResponse; public class ProfileFragment extends Fragment { private final static String CLASSNAME = ProfileFragment.class.getSimpleName(); @InjectView(R.id.TestLoadFromFB) Button testLoadFromFbBtn; @InjectView(R.id.profile_firstName) EditText profileFirstName; @InjectView(R.id.profile_lastName) EditText profileLastName; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.profile_fragment, container, false); Views.inject(this, view); return view; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ProfileFragment finalThis = this; testLoadFromFbBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.w(ProfileFragment.class.getSimpleName(), "loadFromFB"); CarpoolSophiaUser user; try { user = (new LoadUserFromFbTask(finalThis).execute()).get(); if (user != null) { // Log.w(getClass().getSimpleName(), // "user loaded: "+<API key>.toJSONParse(user)); profileFirstName.setText(user.getFirstName()); profileLastName.setText(user.getLastName()); } } catch (<API key> e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } public void updateProfileInfo(View btn) { Log.w(getClass().getSimpleName(), "updateProfileInfo"); } private class LoadUserFromFbTask extends AsyncTask<CarpoolSophiaUser, Void, CarpoolSophiaUser> { private ProfileFragment profileFragment; public LoadUserFromFbTask(ProfileFragment fragment) { super(); this.profileFragment = fragment; } @SuppressWarnings("serial") protected CarpoolSophiaUser doInBackground(final CarpoolSophiaUser... users) { CarpoolSophiaUser user = <API key>.get() .getCurrentCSuser(); AccessToken access<API key>.deserializeToken(user .getAccessToken()); GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.<API key>() { @Override public void onCompleted(JSONObject object, GraphResponse response) { // Log.d(CLASSNAME, "JSONobject: " + object); // Log.d(CLASSNAME, "GraphResponse // response.getRawResponse()); } }); GraphResponse response = request.executeAndWait(); Log.d(CLASSNAME, "GraphResponse #2: " + response.getRawResponse()); CarpoolSophiaUser userFromFB = new CarpoolSophiaUser(); try { userFromFB.setFirstName(response.getJSONObject() .getString("first_name")); userFromFB.setLastName(response.getJSONObject().getString("last_name")); } catch (JSONException e) { e.printStackTrace(); } ProfileService.get().refreshCSUser(user, userFromFB); return user; } @Override protected void onPostExecute(CarpoolSophiaUser result) { super.onPostExecute(result); } } }
<!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.11"/> <title>ShipCAD: ShipCADlib/subdivbase.cpp File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { init_search(); }); </script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">ShipCAD </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.11 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File&#160;List</span></a></li> <li><a href="globals.html"><span>File&#160;Members</span></a></li> </ul> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="<API key>"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="<API key>.html">ShipCADlib</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">subdivbase.cpp File Reference</div> </div> </div><!--header <div class="contents"> <div class="textblock"><code>#include &lt;iostream&gt;</code><br /> <code>#include &quot;<a class="el" href="<API key>.html">subdivbase.h</a>&quot;</code><br /> <code>#include &quot;<a class="el" href="<API key>.html">subdivsurface.h</a>&quot;</code><br /> </div> <p><a href="<API key>.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:<API key>"><td class="memItemLeft" align="right" valign="top">ostream &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="subdivbase_8cpp.html#<API key>">operator&lt;&lt;</a> (ostream &amp;os, const <a class="el" href="<API key>.html">ShipCAD::SubdivisionBase</a> &amp;base)</td></tr> <tr class="separator:<API key>"><td class="memSeparator" colspan="2">&#160;</td></tr> </table> <h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="<API key>"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">ostream&amp; operator&lt;&lt; </td> <td>(</td> <td class="paramtype">ostream &amp;&#160;</td> <td class="paramname"><em>os</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="<API key>.html">ShipCAD::SubdivisionBase</a> &amp;&#160;</td> <td class="paramname"><em>base</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Definition at line <a class="el" href="<API key>.html#l00062">62</a> of file <a class="el" href="<API key>.html">subdivbase.cpp</a>.</p> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Sun Feb 25 2018 15:36:00 for ShipCAD by & <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.11 </small></address> </body> </html>
#include <linux/kernel.h> #include <linux/module.h> #include <linux/spinlock.h> #include <linux/slab.h> #include <linux/sched.h> #include <linux/fs.h> #include <linux/mm.h> #include <linux/kthread.h> #include <linux/freezer.h> #include <linux/writeback.h> #include <linux/blkdev.h> #include <linux/backing-dev.h> #include <linux/buffer_head.h> #include <linux/tracepoint.h> #include <trace/events/vfs.h> #include "internal.h" /* * Passed into wb_writeback(), essentially a subset of writeback_control */ struct wb_writeback_work { long nr_pages; struct super_block *sb; unsigned long *older_than_this; enum <API key> sync_mode; unsigned int tagged_writepages:1; unsigned int for_kupdate:1; unsigned int range_cyclic:1; unsigned int for_background:1; enum wb_reason reason; /* why was writeback initiated? */ struct list_head list; /* pending work list */ struct completion *done; /* set if the caller waits */ }; /* * Include the creation of the trace points after defining the * wb_writeback_work structure so that the definition remains local to this * file. */ #define CREATE_TRACE_POINTS #include <trace/events/writeback.h> /* * We don't actually have pdflush, but this one is exported though /proc... */ int nr_pdflush_threads; /** * <API key> - determine whether there is writeback in progress * @bdi: the device's backing_dev_info structure. * * Determine whether there is writeback waiting to be handled against a * backing device. */ int <API key>(struct backing_dev_info *bdi) { return test_bit(<API key>, &bdi->state); } static inline struct backing_dev_info *inode_to_bdi(struct inode *inode) { struct super_block *sb = inode->i_sb; if (strcmp(sb->s_type->name, "bdev") == 0) return inode->i_mapping->backing_dev_info; return sb->s_bdi; } static inline struct inode *wb_inode(struct list_head *head) { return list_entry(head, struct inode, i_wb_list); } /* Wakeup flusher thread or forker thread to fork it. Requires bdi->wb_lock. */ static void bdi_wakeup_flusher(struct backing_dev_info *bdi) { if (bdi->wb.task) { wake_up_process(bdi->wb.task); } else { /* * The bdi thread isn't there, wake up the forker thread which * will create and run it. */ wake_up_process(<API key>.wb.task); } } static void bdi_queue_work(struct backing_dev_info *bdi, struct wb_writeback_work *work) { <API key>(bdi, work); spin_lock_bh(&bdi->wb_lock); list_add_tail(&work->list, &bdi->work_list); if (!bdi->wb.task) <API key>(bdi, work); bdi_wakeup_flusher(bdi); spin_unlock_bh(&bdi->wb_lock); } static void <API key>(struct backing_dev_info *bdi, long nr_pages, bool range_cyclic, enum wb_reason reason) { struct wb_writeback_work *work; /* * This is WB_SYNC_NONE writeback, so if allocation fails just * wakeup the thread for old dirty data writeback */ work = kzalloc(sizeof(*work), GFP_ATOMIC); if (!work) { if (bdi->wb.task) { <API key>(bdi); wake_up_process(bdi->wb.task); } return; } work->sync_mode = WB_SYNC_NONE; work->nr_pages = nr_pages; work->range_cyclic = range_cyclic; work->reason = reason; bdi_queue_work(bdi, work); } /** * bdi_start_writeback - start writeback * @bdi: the backing device to write from * @nr_pages: the number of pages to write * @reason: reason why some writeback work was initiated * * Description: * This does WB_SYNC_NONE opportunistic writeback. The IO is only * started when this function returns, we make no guarantees on * completion. Caller need not hold sb s_umount semaphore. * */ void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages, enum wb_reason reason) { <API key>(bdi, nr_pages, true, reason); } /** * <API key> - start background writeback * @bdi: the backing device to write from * * Description: * This makes sure WB_SYNC_NONE background writeback happens. When * this function returns, it is only guaranteed that for given BDI * some IO is happening if we are over background dirty threshold. * Caller need not hold sb s_umount semaphore. */ void <API key>(struct backing_dev_info *bdi) { /* * We just wake up the flusher thread. It will perform background * writeback as soon as there is no other work to do. */ <API key>(bdi); spin_lock_bh(&bdi->wb_lock); bdi_wakeup_flusher(bdi); spin_unlock_bh(&bdi->wb_lock); } /* * Remove the inode from the writeback list it is on. */ void inode_wb_list_del(struct inode *inode) { struct backing_dev_info *bdi = inode_to_bdi(inode); spin_lock(&bdi->wb.list_lock); list_del_init(&inode->i_wb_list); spin_unlock(&bdi->wb.list_lock); } /* * Redirty an inode: set its when-it-was dirtied timestamp and move it to the * furthest end of its superblock's dirty-inode list. * * Before stamping the inode's ->dirtied_when, we check to see whether it is * already the <API key> inode on the b_dirty list. If that is * the case then the inode must have been redirtied while it was being written * out and we don't reset its dirtied_when. */ static void redirty_tail(struct inode *inode, struct bdi_writeback *wb) { assert_spin_locked(&wb->list_lock); if (!list_empty(&wb->b_dirty)) { struct inode *tail; tail = wb_inode(wb->b_dirty.next); if (time_before(inode->dirtied_when, tail->dirtied_when)) inode->dirtied_when = jiffies; } list_move(&inode->i_wb_list, &wb->b_dirty); } /* * requeue inode for re-scanning after bdi->b_io list is exhausted. */ static void requeue_io(struct inode *inode, struct bdi_writeback *wb) { assert_spin_locked(&wb->list_lock); list_move(&inode->i_wb_list, &wb->b_more_io); } static void inode_sync_complete(struct inode *inode) { /* * Prevent speculative execution through * spin_unlock(&wb->list_lock); */ smp_mb(); wake_up_bit(&inode->i_state, __I_SYNC); } static bool inode_dirtied_after(struct inode *inode, unsigned long t) { bool ret = time_after(inode->dirtied_when, t); #ifndef CONFIG_64BIT /* * For inodes being constantly redirtied, dirtied_when can get stuck. * It _appears_ to be in the future, but is actually in distant past. * This test is necessary to prevent such wrapped-around relative times * from permanently stopping the whole bdi writeback. */ ret = ret && time_before_eq(inode->dirtied_when, jiffies); #endif return ret; } /* * Move expired dirty inodes from @delaying_queue to @dispatch_queue. */ static int move_expired_inodes(struct list_head *delaying_queue, struct list_head *dispatch_queue, struct wb_writeback_work *work) { LIST_HEAD(tmp); struct list_head *pos, *node; struct super_block *sb = NULL; struct inode *inode; int do_sb_sort = 0; int moved = 0; while (!list_empty(delaying_queue)) { inode = wb_inode(delaying_queue->prev); if (work->older_than_this && inode_dirtied_after(inode, *work->older_than_this)) break; if (sb && sb != inode->i_sb) do_sb_sort = 1; sb = inode->i_sb; list_move(&inode->i_wb_list, &tmp); moved++; } /* just one sb in list, splice to dispatch_queue and we're done */ if (!do_sb_sort) { list_splice(&tmp, dispatch_queue); goto out; } /* Move inodes from one superblock together */ while (!list_empty(&tmp)) { sb = wb_inode(tmp.prev)->i_sb; <API key>(pos, node, &tmp) { inode = wb_inode(pos); if (inode->i_sb == sb) list_move(&inode->i_wb_list, dispatch_queue); } } out: return moved; } static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work) { int moved; assert_spin_locked(&wb->list_lock); list_splice_init(&wb->b_more_io, &wb->b_io); moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, work); <API key>(wb, work, moved); } static int write_inode(struct inode *inode, struct writeback_control *wbc) { if (inode->i_sb->s_op->write_inode && !is_bad_inode(inode)) return inode->i_sb->s_op->write_inode(inode, wbc); return 0; } /* * Wait for writeback on an inode to complete. */ static void <API key>(struct inode *inode, struct bdi_writeback *wb) { DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC); wait_queue_head_t *wqh; wqh = bit_waitqueue(&inode->i_state, __I_SYNC); while (inode->i_state & I_SYNC) { spin_unlock(&inode->i_lock); spin_unlock(&wb->list_lock); __wait_on_bit(wqh, &wq, inode_wait, <API key>); spin_lock(&wb->list_lock); spin_lock(&inode->i_lock); } } /* * Write out an inode's dirty pages. Called under wb->list_lock and * inode->i_lock. Either the caller has an active reference on the inode or * the inode has I_WILL_FREE set. * * If `wait' is set, wait on the writeout. * * The whole writeout design is quite complex and fragile. We want to avoid * starvation of particular inodes when others are being redirtied, prevent * livelocks, etc. */ static int <API key>(struct inode *inode, struct bdi_writeback *wb, struct writeback_control *wbc) { struct address_space *mapping = inode->i_mapping; long nr_to_write = wbc->nr_to_write; unsigned dirty; int ret; assert_spin_locked(&wb->list_lock); assert_spin_locked(&inode->i_lock); if (!atomic_read(&inode->i_count)) WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING))); else WARN_ON(inode->i_state & I_WILL_FREE); if (inode->i_state & I_SYNC) { /* * If this inode is locked for writeback and we are not doing * <API key>, move it to b_more_io so that * writeback can proceed with the other inodes on s_io. * * We'll have another go at writing back this inode when we * completed a full scan of b_io. */ if (wbc->sync_mode != WB_SYNC_ALL) { requeue_io(inode, wb); <API key>(inode, wbc, nr_to_write); return 0; } /* * It's a data-integrity sync. We must wait. */ <API key>(inode, wb); } BUG_ON(inode->i_state & I_SYNC); /* Set I_SYNC, reset I_DIRTY_PAGES */ inode->i_state |= I_SYNC; inode->i_state &= ~I_DIRTY_PAGES; spin_unlock(&inode->i_lock); spin_unlock(&wb->list_lock); ret = do_writepages(mapping, wbc); /* * Make sure to wait on the data before writing out the metadata. * This is important for filesystems that modify metadata on data * I/O completion. */ if (wbc->sync_mode == WB_SYNC_ALL) { int err = filemap_fdatawait(mapping); if (ret == 0) ret = err; } /* * Some filesystems may redirty the inode during the writeback * due to delalloc, clear dirty metadata flags right before * write_inode() */ spin_lock(&inode->i_lock); dirty = inode->i_state & I_DIRTY; inode->i_state &= ~(I_DIRTY_SYNC | I_DIRTY_DATASYNC); spin_unlock(&inode->i_lock); /* Don't write the inode if only I_DIRTY_PAGES was set */ if (dirty & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) { int err = write_inode(inode, wbc); if (ret == 0) ret = err; } spin_lock(&wb->list_lock); spin_lock(&inode->i_lock); inode->i_state &= ~I_SYNC; if (!(inode->i_state & I_FREEING)) { /* * Sync livelock prevention. Each inode is tagged and synced in * one shot. If still dirty, it will be redirty_tail()'ed below. * Update the dirty time to prevent enqueue and sync it again. */ if ((inode->i_state & I_DIRTY) && (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)) inode->dirtied_when = jiffies; if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { /* * We didn't write back all the pages. nfs_writepages() * sometimes bales out without doing anything. */ inode->i_state |= I_DIRTY_PAGES; if (wbc->nr_to_write <= 0) { /* * slice used up: queue for next turn */ requeue_io(inode, wb); } else { /* * Writeback blocked by something other than * congestion. Delay the inode for some time to * avoid spinning on the CPU (100% iowait) * retrying writeback of the dirty page/inode * that cannot be performed immediately. */ redirty_tail(inode, wb); } } else if (inode->i_state & I_DIRTY) { /* * Filesystems can dirty the inode during writeback * operations, such as delayed allocation during * submission or metadata updates after data IO * completion. */ redirty_tail(inode, wb); } else { /* * The inode is clean. At this point we either have * a reference to the inode or it's on it's way out. * No need to add it back to the LRU. */ list_del_init(&inode->i_wb_list); } } inode_sync_complete(inode); <API key>(inode, wbc, nr_to_write); return ret; } static long <API key>(struct backing_dev_info *bdi, struct wb_writeback_work *work) { long pages; /* * WB_SYNC_ALL mode does livelock avoidance by syncing dirty * inodes/pages in one big loop. Setting wbc.nr_to_write=LONG_MAX * here avoids calling into writeback_inodes_wb() more than once. * * The intended call sequence for WB_SYNC_ALL writeback is: * * wb_writeback() * writeback_sb_inodes() <== called only once * write_cache_pages() <== called once for each inode * (quickly) tag currently dirty pages * (maybe slowly) sync all tagged pages */ if (work->sync_mode == WB_SYNC_ALL || work->tagged_writepages) pages = LONG_MAX; else { pages = min(bdi->avg_write_bandwidth / 2, global_dirty_limit / DIRTY_SCOPE); pages = min(pages, work->nr_pages); pages = round_down(pages + MIN_WRITEBACK_PAGES, MIN_WRITEBACK_PAGES); } return pages; } /* * Write a portion of b_io inodes which belong to @sb. * * If @only_this_sb is true, then find and write all such * inodes. Otherwise write only ones which go sequentially * in reverse order. * * Return the number of pages and/or inodes written. */ static long writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb, struct wb_writeback_work *work) { struct writeback_control wbc = { .sync_mode = work->sync_mode, .tagged_writepages = work->tagged_writepages, .for_kupdate = work->for_kupdate, .for_background = work->for_background, .range_cyclic = work->range_cyclic, .range_start = 0, .range_end = LLONG_MAX, }; unsigned long start_time = jiffies; long write_chunk; long wrote = 0; /* count both pages and inodes */ while (!list_empty(&wb->b_io)) { struct inode *inode = wb_inode(wb->b_io.prev); if (inode->i_sb != sb) { if (work->sb) { /* * We only want to write back data for this * superblock, move all inodes not belonging * to it back onto the dirty list. */ redirty_tail(inode, wb); continue; } /* * The inode belongs to a different superblock. * Bounce back to the caller to unpin this and * pin the next superblock. */ break; } /* * Don't bother with new inodes or inodes beeing freed, first * kind does not need peridic writeout yet, and for the latter * kind writeout is handled by the freer. */ spin_lock(&inode->i_lock); if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { spin_unlock(&inode->i_lock); redirty_tail(inode, wb); continue; } __iget(inode); write_chunk = <API key>(wb->bdi, work); wbc.nr_to_write = write_chunk; wbc.pages_skipped = 0; <API key>(inode, wb, &wbc); work->nr_pages -= write_chunk - wbc.nr_to_write; wrote += write_chunk - wbc.nr_to_write; if (!(inode->i_state & I_DIRTY)) wrote++; if (wbc.pages_skipped) { /* * writeback is not making progress due to locked * buffers. Skip this inode for now. */ redirty_tail(inode, wb); } spin_unlock(&inode->i_lock); spin_unlock(&wb->list_lock); iput(inode); cond_resched(); spin_lock(&wb->list_lock); /* * bail out to wb_writeback() often enough to check * background threshold and other termination conditions. */ if (wrote) { if (<API key>(start_time + HZ / 10UL)) break; if (work->nr_pages <= 0) break; } } return wrote; } static long <API key>(struct bdi_writeback *wb, struct wb_writeback_work *work) { unsigned long start_time = jiffies; long wrote = 0; while (!list_empty(&wb->b_io)) { struct inode *inode = wb_inode(wb->b_io.prev); struct super_block *sb = inode->i_sb; if (!grab_super_passive(sb)) { /* * grab_super_passive() may fail consistently due to * s_umount being grabbed by someone else. Don't use * requeue_io() to avoid busy retrying the inode/sb. */ redirty_tail(inode, wb); continue; } wrote += writeback_sb_inodes(sb, wb, work); drop_super(sb); /* refer to the same tests at the end of writeback_sb_inodes */ if (wrote) { if (<API key>(start_time + HZ / 10UL)) break; if (work->nr_pages <= 0) break; } } /* Leave any unwritten inodes on b_io */ return wrote; } long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages, enum wb_reason reason) { struct wb_writeback_work work = { .nr_pages = nr_pages, .sync_mode = WB_SYNC_NONE, .range_cyclic = 1, .reason = reason, }; spin_lock(&wb->list_lock); if (list_empty(&wb->b_io)) queue_io(wb, &work); <API key>(wb, &work); spin_unlock(&wb->list_lock); return nr_pages - work.nr_pages; } static bool over_bground_thresh(struct backing_dev_info *bdi) { unsigned long background_thresh, dirty_thresh; global_dirty_limits(&background_thresh, &dirty_thresh); if (global_page_state(NR_FILE_DIRTY) + global_page_state(NR_UNSTABLE_NFS) > background_thresh) return true; if (bdi_stat(bdi, BDI_RECLAIMABLE) > bdi_dirty_limit(bdi, background_thresh)) return true; return false; } /* * Called under wb->list_lock. If there are multiple wb per bdi, * only the flusher working on the first wb should do it. */ static void wb_update_bandwidth(struct bdi_writeback *wb, unsigned long start_time) { <API key>(wb->bdi, 0, 0, 0, 0, 0, start_time); } /* * Explicit flushing or periodic writeback of "old" data. * * Define "old": the first time one of an inode's pages is dirtied, we mark the * dirtying-time in the inode's address_space. So this periodic writeback code * just walks the superblock inode list, writing back any inodes which are * older than a specific point in time. * * Try to run once per <API key>. But if a writeback event * takes longer than a <API key> interval, then leave a * one-second gap. * * older_than_this takes precedence over nr_to_write. So we'll only write back * all dirty pages if they are all attached to "old" mappings. */ static long wb_writeback(struct bdi_writeback *wb, struct wb_writeback_work *work) { unsigned long wb_start = jiffies; long nr_pages = work->nr_pages; unsigned long oldest_jif; struct inode *inode; long progress; oldest_jif = jiffies; work->older_than_this = &oldest_jif; spin_lock(&wb->list_lock); for (;;) { /* * Stop writeback when nr_pages has been consumed */ if (work->nr_pages <= 0) break; /* * Background writeout and kupdate-style writeback may * run forever. Stop them if there is other work to do * so that e.g. sync can proceed. They'll be restarted * after the other works are all done. */ if ((work->for_background || work->for_kupdate) && !list_empty(&wb->bdi->work_list)) break; /* * For background writeout, stop when we are below the * background dirty threshold */ if (work->for_background && !over_bground_thresh(wb->bdi)) break; if (work->for_kupdate) { oldest_jif = jiffies - msecs_to_jiffies(<API key> * 10); work->older_than_this = &oldest_jif; } <API key>(wb->bdi, work); if (list_empty(&wb->b_io)) queue_io(wb, work); if (work->sb) progress = writeback_sb_inodes(work->sb, wb, work); else progress = <API key>(wb, work); <API key>(wb->bdi, work); wb_update_bandwidth(wb, wb_start); /* * Did we write something? Try for more * * Dirty inodes are moved to b_io for writeback in batches. * The completion of the current batch does not necessarily * mean the overall work is done. So we keep looping as long * as made some progress on cleaning pages or inodes. */ if (progress) continue; /* * No more inodes for IO, bail */ if (list_empty(&wb->b_more_io)) break; /* * Nothing written. Wait for some inode to * become available for writeback. Otherwise * we'll just busyloop. */ if (!list_empty(&wb->b_more_io)) { <API key>(wb->bdi, work); inode = wb_inode(wb->b_more_io.prev); spin_lock(&inode->i_lock); <API key>(inode, wb); spin_unlock(&inode->i_lock); } } spin_unlock(&wb->list_lock); return nr_pages - work->nr_pages; } /* * Return the next wb_writeback_work struct that hasn't been processed yet. */ static struct wb_writeback_work * get_next_work_item(struct backing_dev_info *bdi) { struct wb_writeback_work *work = NULL; spin_lock_bh(&bdi->wb_lock); if (!list_empty(&bdi->work_list)) { work = list_entry(bdi->work_list.next, struct wb_writeback_work, list); list_del_init(&work->list); } spin_unlock_bh(&bdi->wb_lock); return work; } /* * Add in the number of potentially dirty inodes, because each inode * write can dirty pagecache in the underlying blockdev. */ static unsigned long get_nr_dirty_pages(void) { return global_page_state(NR_FILE_DIRTY) + global_page_state(NR_UNSTABLE_NFS) + get_nr_dirty_inodes(); } static long <API key>(struct bdi_writeback *wb) { if (over_bground_thresh(wb->bdi)) { struct wb_writeback_work work = { .nr_pages = LONG_MAX, .sync_mode = WB_SYNC_NONE, .for_background = 1, .range_cyclic = 1, .reason = <API key>, }; return wb_writeback(wb, &work); } return 0; } static long <API key>(struct bdi_writeback *wb) { unsigned long expired; long nr_pages; /* * When set to zero, disable periodic writeback */ if (!<API key>) return 0; expired = wb->last_old_flush + msecs_to_jiffies(<API key> * 10); if (time_before(jiffies, expired)) return 0; wb->last_old_flush = jiffies; nr_pages = get_nr_dirty_pages(); if (nr_pages) { struct wb_writeback_work work = { .nr_pages = nr_pages, .sync_mode = WB_SYNC_NONE, .for_kupdate = 1, .range_cyclic = 1, .reason = WB_REASON_PERIODIC, }; return wb_writeback(wb, &work); } return 0; } /* * Retrieve work items and do the writeback they describe */ long wb_do_writeback(struct bdi_writeback *wb, int force_wait) { struct backing_dev_info *bdi = wb->bdi; struct wb_writeback_work *work; long wrote = 0; set_bit(<API key>, &wb->bdi->state); while ((work = get_next_work_item(bdi)) != NULL) { /* * Override sync mode, in case we must wait for completion * because this thread is exiting now. */ if (force_wait) work->sync_mode = WB_SYNC_ALL; <API key>(bdi, work); wrote += wb_writeback(wb, work); /* * Notify the caller of completion if this is a synchronous * work item, otherwise just free it. */ if (work->done) complete(work->done); else kfree(work); } /* * Check for periodic writeback, kupdated() style */ wrote += <API key>(wb); wrote += <API key>(wb); clear_bit(<API key>, &wb->bdi->state); return wrote; } /* * Handle writeback of dirty data for the device backed by this bdi. Also * wakes up periodically and does kupdated style flushing. */ int <API key>(void *data) { struct bdi_writeback *wb = data; struct backing_dev_info *bdi = wb->bdi; long pages_written; current->flags |= PF_SWAPWRITE; set_freezable(); wb->last_active = jiffies; /* * Our parent may run at a different priority, just set us to normal */ set_user_nice(current, 0); <API key>(bdi); while (!kthread_should_stop()) { /* * Remove own delayed wake-up timer, since we are already awake * and we'll take care of the preriodic write-back. */ del_timer(&wb->wakeup_timer); pages_written = wb_do_writeback(wb, 0); <API key>(pages_written); if (pages_written) wb->last_active = jiffies; set_current_state(TASK_INTERRUPTIBLE); if (!list_empty(&bdi->work_list) || kthread_should_stop()) { __set_current_state(TASK_RUNNING); continue; } if (wb_has_dirty_io(wb) && <API key>) schedule_timeout(msecs_to_jiffies(<API key> * 10)); else { /* * We have nothing to do, so can go sleep without any * timeout and save power. When a work is queued or * something is made dirty - we will be woken up. */ schedule(); } try_to_freeze(); } /* Flush any work that raced with us exiting */ if (!list_empty(&bdi->work_list)) wb_do_writeback(wb, 1); <API key>(bdi); return 0; } /* * Start writeback of `nr_pages' pages. If `nr_pages' is zero, write back * the whole world. */ void <API key>(long nr_pages, enum wb_reason reason) { struct backing_dev_info *bdi; if (!nr_pages) { nr_pages = global_page_state(NR_FILE_DIRTY) + global_page_state(NR_UNSTABLE_NFS); } rcu_read_lock(); <API key>(bdi, &bdi_list, bdi_list) { if (!bdi_has_dirty_io(bdi)) continue; <API key>(bdi, nr_pages, false, reason); } rcu_read_unlock(); } static noinline void <API key>(struct inode *inode) { if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) { struct dentry *dentry; const char *name = "?"; dentry = d_find_alias(inode); if (dentry) { spin_lock(&dentry->d_lock); name = (const char *) dentry->d_name.name; } printk(KERN_DEBUG "%s(%d): dirtied inode %lu (%s) on %s\n", current->comm, task_pid_nr(current), inode->i_ino, name, inode->i_sb->s_id); if (dentry) { spin_unlock(&dentry->d_lock); dput(dentry); } } } /** * __mark_inode_dirty - internal function * @inode: inode to mark * @flags: what kind of dirty (i.e. I_DIRTY_SYNC) * Mark an inode as dirty. Callers should use mark_inode_dirty or * <API key>. * * Put the inode on the super block's dirty list. * * CAREFUL! We mark it dirty unconditionally, but move it onto the * dirty list only if it is hashed or if it refers to a blockdev. * If it was not hashed, it will never be added to the dirty list * even if it is later hashed, as it will have been marked dirty already. * * In short, make sure you hash any inodes _before_ you start marking * them dirty. * * Note that for blockdevs, inode->dirtied_when represents the dirtying time of * the block-special inode (/dev/hda1) itself. And the ->dirtied_when field of * the kernel-internal blockdev inode represents the dirtying time of the * blockdev's pages. This is why for I_DIRTY_PAGES we always use * page->mapping->host, so the page-dirtying time is recorded in the internal * blockdev inode. */ void __mark_inode_dirty(struct inode *inode, int flags) { struct super_block *sb = inode->i_sb; struct backing_dev_info *bdi = NULL; /* * Don't do this for I_DIRTY_PAGES - that doesn't actually * dirty the inode itself */ if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) { if (sb->s_op->dirty_inode) sb->s_op->dirty_inode(inode, flags); } /* * make sure that changes are seen by all cpus before we test i_state * -- mikulas */ smp_mb(); /* avoid the locking if we can */ if ((inode->i_state & flags) == flags) return; trace_dirty_inode(inode, current); if (unlikely(block_dump)) <API key>(inode); spin_lock(&inode->i_lock); if ((inode->i_state & flags) != flags) { const int was_dirty = inode->i_state & I_DIRTY; inode->i_state |= flags; /* * If the inode is being synced, just update its dirty state. * The unlocker will place the inode on the appropriate * superblock list, based upon its state. */ if (inode->i_state & I_SYNC) goto out_unlock_inode; /* * Only add valid (hashed) inodes to the superblock's * dirty list. Add blockdev inodes as well. */ if (!S_ISBLK(inode->i_mode)) { if (inode_unhashed(inode)) goto out_unlock_inode; } if (inode->i_state & I_FREEING) goto out_unlock_inode; /* * If the inode was already on b_dirty/b_io/b_more_io, don't * reposition it (that would break b_dirty time-ordering). */ if (!was_dirty) { bool wakeup_bdi = false; bdi = inode_to_bdi(inode); if (<API key>(bdi)) { WARN(!test_bit(BDI_registered, &bdi->state), "bdi-%s not registered\n", bdi->name); /* * If this is the first dirty inode for this * bdi, we have to wake-up the corresponding * bdi thread to make sure background * write-back happens later. */ if (!wb_has_dirty_io(&bdi->wb)) wakeup_bdi = true; } spin_unlock(&inode->i_lock); spin_lock(&bdi->wb.list_lock); inode->dirtied_when = jiffies; list_move(&inode->i_wb_list, &bdi->wb.b_dirty); spin_unlock(&bdi->wb.list_lock); if (wakeup_bdi) <API key>(bdi); return; } } out_unlock_inode: spin_unlock(&inode->i_lock); } EXPORT_SYMBOL(__mark_inode_dirty); /* * Write out a superblock's list of dirty inodes. A wait will be performed * upon no inodes, all inodes or the final one, depending upon sync_mode. * * If older_than_this is non-NULL, then only write out inodes which * had their first dirtying at a time earlier than *older_than_this. * * If `bdi' is non-zero then we're being asked to writeback a specific queue. * This function assumes that the blockdev superblock's inodes are backed by * a variety of queues, so all inodes are searched. For other superblocks, * assume that all inodes are backed by the same queue. * * The inodes to be written are parked on bdi->b_io. They are moved back onto * bdi->b_dirty as they are selected for writing. This way, none can be missed * on the writer throttling path, and we get decent balancing between many * throttled threads: we don't want them all piling up on inode_sync_wait. */ static void wait_sb_inodes(struct super_block *sb) { struct inode *inode, *old_inode = NULL; /* * We need to be protected against the filesystem going from * r/o to r/w or vice versa. */ WARN_ON(!rwsem_is_locked(&sb->s_umount)); spin_lock(&inode_sb_list_lock); /* * Data integrity sync. Must wait for all pages under writeback, * because there may have been pages dirtied before our sync * call, but which had writeout started before we write it out. * In which case, the inode may not be on the dirty list, but * we still have to wait for that writeout. */ list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { struct address_space *mapping = inode->i_mapping; spin_lock(&inode->i_lock); if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || (mapping->nrpages == 0)) { spin_unlock(&inode->i_lock); continue; } __iget(inode); spin_unlock(&inode->i_lock); spin_unlock(&inode_sb_list_lock); /* * We hold a reference to 'inode' so it couldn't have been * removed from s_inodes list while we dropped the * inode_sb_list_lock. We cannot iput the inode now as we can * be holding the last reference and we cannot iput it under * inode_sb_list_lock. So we keep the reference and iput it * later. */ iput(old_inode); old_inode = inode; filemap_fdatawait(mapping); cond_resched(); spin_lock(&inode_sb_list_lock); } spin_unlock(&inode_sb_list_lock); iput(old_inode); } /** * <API key> - writeback dirty inodes from given super_block * @sb: the superblock * @nr: the number of pages to write * @reason: reason why some writeback work initiated * * Start writeback on some inodes on this super_block. No guarantees are made * on how many (if any) will be written, and this function does not wait * for IO completion of submitted IO. */ void <API key>(struct super_block *sb, unsigned long nr, enum wb_reason reason) { <API key>(done); struct wb_writeback_work work = { .sb = sb, .sync_mode = WB_SYNC_NONE, .tagged_writepages = 1, .done = &done, .nr_pages = nr, .reason = reason, }; WARN_ON(!rwsem_is_locked(&sb->s_umount)); bdi_queue_work(sb->s_bdi, &work); wait_for_completion(&done); } EXPORT_SYMBOL(<API key>); /** * writeback_inodes_sb - writeback dirty inodes from given super_block * @sb: the superblock * @reason: reason why some writeback work was initiated * * Start writeback on some inodes on this super_block. No guarantees are made * on how many (if any) will be written, and this function does not wait * for IO completion of submitted IO. */ void writeback_inodes_sb(struct super_block *sb, enum wb_reason reason) { return <API key>(sb, get_nr_dirty_pages(), reason); } EXPORT_SYMBOL(writeback_inodes_sb); /** * <API key> - start writeback if none underway * @sb: the superblock * @reason: reason why some writeback work was initiated * * Invoke writeback_inodes_sb if no writeback is currently underway. * Returns 1 if writeback was started, 0 if not. */ int <API key>(struct super_block *sb, enum wb_reason reason) { if (!<API key>(sb->s_bdi)) { down_read(&sb->s_umount); writeback_inodes_sb(sb, reason); up_read(&sb->s_umount); return 1; } else return 0; } EXPORT_SYMBOL(<API key>); /** * <API key> - start writeback if none underway * @sb: the superblock * @nr: the number of pages to write * @reason: reason why some writeback work was initiated * * Invoke writeback_inodes_sb if no writeback is currently underway. * Returns 1 if writeback was started, 0 if not. */ int <API key>(struct super_block *sb, unsigned long nr, enum wb_reason reason) { if (!<API key>(sb->s_bdi)) { down_read(&sb->s_umount); <API key>(sb, nr, reason); up_read(&sb->s_umount); return 1; } else return 0; } EXPORT_SYMBOL(<API key>); /** * sync_inodes_sb - sync sb inode pages * @sb: the superblock * * This function writes and waits on any dirty inode belonging to this * super_block. */ void sync_inodes_sb(struct super_block *sb) { <API key>(done); struct wb_writeback_work work = { .sb = sb, .sync_mode = WB_SYNC_ALL, .nr_pages = LONG_MAX, .range_cyclic = 0, .done = &done, .reason = WB_REASON_SYNC, }; WARN_ON(!rwsem_is_locked(&sb->s_umount)); bdi_queue_work(sb->s_bdi, &work); wait_for_completion(&done); wait_sb_inodes(sb); } EXPORT_SYMBOL(sync_inodes_sb); /** * write_inode_now - write an inode to disk * @inode: inode to write to disk * @sync: whether the write should be synchronous or not * * This function commits an inode to disk immediately if it is dirty. This is * primarily needed by knfsd. * * The caller must either have a ref on the inode or must have set I_WILL_FREE. */ int write_inode_now(struct inode *inode, int sync) { struct bdi_writeback *wb = &inode_to_bdi(inode)->wb; int ret; struct writeback_control wbc = { .nr_to_write = LONG_MAX, .sync_mode = sync ? WB_SYNC_ALL : WB_SYNC_NONE, .range_start = 0, .range_end = LLONG_MAX, }; if (!<API key>(inode->i_mapping)) wbc.nr_to_write = 0; might_sleep(); spin_lock(&wb->list_lock); spin_lock(&inode->i_lock); ret = <API key>(inode, wb, &wbc); spin_unlock(&inode->i_lock); spin_unlock(&wb->list_lock); if (sync) inode_sync_wait(inode); return ret; } EXPORT_SYMBOL(write_inode_now); /** * sync_inode - write an inode and its pages to disk. * @inode: the inode to sync * @wbc: controls the writeback mode * * sync_inode() will write an inode and its pages to disk. It will also * correctly update the inode on its superblock's dirty inode lists and will * update inode->i_state. * * The caller must have a ref on the inode. */ int sync_inode(struct inode *inode, struct writeback_control *wbc) { struct bdi_writeback *wb = &inode_to_bdi(inode)->wb; int ret; spin_lock(&wb->list_lock); spin_lock(&inode->i_lock); ret = <API key>(inode, wb, wbc); spin_unlock(&inode->i_lock); spin_unlock(&wb->list_lock); return ret; } EXPORT_SYMBOL(sync_inode); /** * sync_inode_metadata - write an inode to disk * @inode: the inode to sync * @wait: wait for I/O to complete. * * Write an inode to disk and adjust its dirty state after completion. * * Note: only writes the actual inode, no associated data or other metadata. */ int sync_inode_metadata(struct inode *inode, int wait) { struct writeback_control wbc = { .sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_NONE, .nr_to_write = 0, /* metadata-only */ }; return sync_inode(inode, &wbc); } EXPORT_SYMBOL(sync_inode_metadata);
/* Hey EMACS -*- linux-c -*- */ /* $Id: toolbar.h 4392 2011-08-01 09:24:05Z debrouxl $ */ #ifndef GTOOLBAR_H #define GTOOLBAR_H void <API key>(void); void toolbar_set_button(int sr); #endif
(function ($, window, document) { "use strict"; $(document).on( 'ready', function(){ var $body = $('body'), $topbar = $( document.getElementById('topbar') ), $products_sliders = $('.<API key>, .<API key>'); $('#list-or-grid').on( 'click', 'a', function(){ var trigger = $(this), view = trigger.attr( 'class' ).replace('-view', ''); $( 'ul.products li' ).removeClass( 'list grid' ).addClass( view ); trigger.parent().find( 'a' ).removeClass( 'active' ); trigger.addClass( 'active' ); $.cookie( <API key>, view ); return false; }); var padding_nameprice = function () { $('li.product .product-wrapper .info-product.slideup').each(function () { $(this).find('h3').css( 'padding-' + ( ! yit.isRtl ? 'right' : 'left' ), $(this).find('span.price').width() + 10 ); }); }; if( $(window).width() > 1199 ){ padding_nameprice(); } $(document).on('<API key>', padding_nameprice ); var product, product_onsale; var add_to_cart = function() { $('ul.products').on('click', 'li.product .add_to_cart_button', function () { product = $(this).parents('li.product'); product_onsale = product.find('.product-wrapper > .onsale'); if( typeof yit.load_gif != 'undefined' ) { product.find('.thumb-wrapper').block({message: null, overlayCSS: {background: '#fff url(' + yit.load_gif + ') no-repeat center', opacity: 0.3, cursor: 'none'}}); } else{ product.find('.thumb-wrapper').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url.substring(0, woocommerce_params.ajax_loader_url.length - 7) + '.gif) no-repeat center', opacity: 0.3, cursor: 'none'}}); } }); } add_to_cart(); $(document).on('<API key>', add_to_cart ); $body.on('added_to_cart', function () { if( typeof product_onsale === 'undefined' && typeof product === 'undefined' ) return; $( '.products-slider.swiper .swiper-slide .opacity .<API key> span.product-add-to-cart a.added_to_cart.wc-forward') .addClass( 'btn btn-flat' ) .prev('a').remove(); if ( product_onsale.length ) { product_onsale.remove(); } product.find('.thumb-wrapper').append('<div class="added_to_cart_box"><div class="added_to_cart_label">' + yit.added_to_cart + '</div></div>'); product.find('.added_to_cart_label').append(product.find('a.added_to_cart')); product.find('.product-wrapper div:first-child').addClass('nohover'); setTimeout( function(){ product.find('.added_to_cart_box').fadeOut(2000, function(){ $(this).remove(); }); product.find('.product-wrapper div:first-child').removeClass('nohover'); }, 3000 ); if (product.find('.product-wrapper > .added_to_cart_ico').length == 0) { setTimeout(function() { product.find('.product-wrapper').append('<span class="added_to_cart_ico">' + yit.added_to_cart_ico + '</span>'); }, 4000); } product.find('.thumb-wrapper').unblock(); }); if( $.fn.owlCarousel && $.fn.imagesLoaded && $products_sliders.length ) { var product_slider = function(t) { t.imagesLoaded(function(){ var cols = t.data('columns') ? t.data('columns') : 4; var autoplay = (t.attr('data-autoplay')=='true') ? 3000 : false; var owl = t.find('.products').owlCarousel({ items : cols, responsiveClass : true, responsive:{ 0 : { items: 2 }, 479 : { items: 3 }, 767 : { items: 4 }, 992 : { items: cols } }, autoplay : autoplay, autoplayTimeout : 2000, autoplayHoverPause: true, loop : true, rtl: yit.isRtl == true }); // Custom Navigation Events t.on('click', '.es-nav-next', function () { owl.trigger('next.owl.carousel'); }); t.on('click', '.es-nav-prev', function () { owl.trigger('prev.owl.carousel'); }); }); }; // initialize slider in only visible tabs $products_sliders.each(function(){ var t = $(this); if( ! t.closest('.panel.group').length || t.closest('.panel.group').hasClass('showing') ){ product_slider( t ); } }); $('.tabs-container').on( 'yit_tabopened', function( e, tab ) { product_slider( tab.find( $products_sliders ) ); }); } var variations_select = function(){ // variations select if( $.fn.selectbox ) { var form = $('form.variations_form'); var select = form.find('select:not(.yith_wccl_custom)'); if( form.data('wccl') ) { select = select.filter(function(){ return $(this).data('type') == 'select' }); } select.selectbox({ effect: 'fade', onOpen: function() { //$('.variations select').trigger('focusin'); } }); var update_select = function(event){ // console.log(event); select.selectbox("detach"); select.selectbox("attach"); }; // fix variations select form.on( '<API key>', update_select); form.find('.reset_variations').on('click.yit', update_select); } }; variations_select(); $topbar.find('#lang_sel .lang_sel_sel').append('<span class="sf-sub-indicator"> +</span>'); $topbar.find('#<API key> > ul > li a.sbSelector').append('<span class="sf-sub-indicator"> +</span>'); $('.single-product-tabs.vertical').on('click', 'ul.tabs li .tab_name', function () { var tab_trigger = $(this), panel = tab_trigger.siblings('.panel'), container = tab_trigger.closest('.single-product-tabs'); if ( ! tab_trigger.hasClass('active') ) { //remove opened tab container.find('.tab_name.active').siblings('div.panel').slideToggle('slow'); container.find('.tab_name.active').removeClass('active'); //open tab tab_trigger.addClass('active'); } else { tab_trigger.removeClass('active'); } panel.slideToggle('slow'); }); var inquiry_form = function(){ if ( $('#inquiry-form .product-inquiry').length ) { $(document).on('click', '#inquiry-form .product-inquiry', function(event){ event.<API key>('click'); $(this).next('form.contact-form').slideToggle('slow'); }); } }; inquiry_form(); $(document).on('<API key>', inquiry_form); if( $( 'body').hasClass( 'single-product' ) ) { setTimeout( function() { if( $.trim( $( 'div.user-message').html() ) != '' || $.trim( $( '.contact-form li div.msg-error' ).text() ) != '' ) { $('form.contact-form').slideToggle('slow'); } }, 200 ); } var wishlist_share = function() { if ( $('#wishlist-share div.share-text').length ) { $(document).on('click', '#wishlist-share div.share-text', function(){ $(this).next('div.<API key>').slideToggle('slow'); }); } }; wishlist_share(); $(document).on('<API key>', wishlist_share); var wc_version = 2.2; if (typeof yit_woocommerce != 'undefined') wc_version = parseFloat(yit_woocommerce.version); if ( wc_version < 2.3 && $.fn.selectbox ) { $('#calc_shipping_state').next('.sbHolder').addClass('stateHolder'); $body.on('<API key>', function(){ $('.stateHolder').remove(); $('#calc_shipping_state').show().attr('sb', ''); $('select#calc_shipping_state').selectbox({ effect: 'fade', classHolder: 'stateHolder sbHolder' }); }); } // $('#login-form').on('submit', function(){ // var a = $('#reg_password').val(); // var b = $('#reg_password_retype').val(); // if(!(a==b)){ // $('#reg_password_retype').addClass('invalid'); // return false; // }else{ // $('#reg_password_retype').removeClass('invalid'); // return true; function quick_view_trigger() { $('div.quick-view a.trigger').yit_quick_view({ item_container: 'li.product', loader : 'div.single-product.woocommerce', assets : yit_quick_view.assets, before : function (trigger, item) { // add loading in the button if( typeof yit.load_gif != 'undefined' ) { trigger.parent().block({message: null, overlayCSS: {background: '#fff url(' + yit.load_gif + ') no-repeat center', opacity: 0.3, cursor: 'none'}}); } else{ trigger.parent().block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url.substring(0, woocommerce_params.ajax_loader_url.length - 7) + '.gif) no-repeat center', opacity: 0.3, cursor: 'none'}}); } item.find('.thumb-wrapper').addClass('hover'); }, openDialog : function (trigger, item) { // remove loading from button trigger.parent().unblock(); item.find('.thumb-wrapper').removeClass('hover'); }, completed : function (trigger, item, html, overlay) { var data = $('<div>' + html + '</div>'), title = data.find('h1.product_title').html(), price = data.find('p.price').html(), rating = data.find('div.star-rating').html(), container = document.getElementById('wrapper'), wrapper = $(overlay).find('.main .container'); // add main class to dialog container $(overlay).addClass('product-quick-view'); // head $('<p />').addClass('price').html(price).prependTo(wrapper.find('.head')); $('<div />').addClass('star-rating').html(rating).prependTo(wrapper.find('.head')); $('<h4 />').html(title).prependTo(wrapper.find('.head')); //prettyPhoto if ( typeof $.prettyPhoto != 'undefined' ) { data.find( "a[rel^='thumbnails'], a.zoom" ).prettyPhoto({ social_tools : false, theme : 'pp_woocommerce', horizontal_padding: 40, opacity : 0.9, deeplinking : false }); } // quantity fields $('div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)').addClass('buttons_added').append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />'); variations_select(); // add to cart $('form.cart', overlay).on('submit', function (e) { e.preventDefault(); var form = $(this), button = form.find('button'), product_url = item.find('a.thumb').attr('href'); if( typeof yit.load_gif != 'undefined' ) { button.block({message: null, overlayCSS: {background: '#fff url(' + yit.load_gif + ') no-repeat center', opacity: 0.3, cursor: 'none'}}); } else if (typeof( woocommerce_params.plugin_url ) != 'undefined') { button.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.3, cursor: 'none'}}); } else { button.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url.substring(0, woocommerce_params.ajax_loader_url.length - 7) + '.gif) no-repeat center', opacity: 0.3, cursor: 'none'}}); } $.post(product_url, form.serialize() + '&_wp_http_referer=' + product_url, function (result) { var message = $( '.woocommerce-message', result ), cart_dropdown = $( '#header .yit_cart_widget', result); if( typeof <API key> != 'undefined') { // update fragments var $<API key>; try { $<API key> = ( 'sessionStorage' in window && window.sessionStorage !== null ); window.sessionStorage.setItem('wc', 'test'); window.sessionStorage.removeItem('wc'); } catch (err) { $<API key> = false; } $.ajax({ url : <API key>.wc_ajax_url.toString().replace('%%endpoint%%', '<API key>'), type : 'POST', success: function (data) { if (data && data.fragments) { $.each(data.fragments, function (key, value) { $(key).replaceWith(value); }); if ($<API key>) { sessionStorage.setItem(<API key>.fragment_name, JSON.stringify(data.fragments)); sessionStorage.setItem('wc_cart_hash', data.cart_hash); } $(document.body).trigger('<API key>'); } } }); } // add message $('div.product', overlay).before(message); // remove loading button.unblock(); }); }); // others $('#wishlist-share').find('.<API key>').hide(); $('#inquiry-form').find('form.contact-form').hide(); }, action : '<API key>' }); } if ($.fn.yit_quick_view && typeof yit_quick_view != 'undefined') { quick_view_trigger(); $(document).on('<API key>', quick_view_trigger); } $( '.<API key> .add_to_wishlist').on( 'click', function() { var feedback = $(this).closest('.<API key>').find('.<API key> span.feedback'); feedback.fadeIn(); setTimeout( function(){ feedback.fadeOut('slow'); }, 4000 ); }); if( yit.price_filter_slider == 'no' || typeof yit.price_filter_slider == 'undefined' ) { var <API key> = function() { $( 'input#min_price, input#max_price' ).show(); $('form > div.<API key>').find( 'div.price_slider, div.price_label' ).hide(); }; <API key>(); } if ($.fn.yit_quick_view ) { var term_popup = function() { $('p.terms a').yit_quick_view({ item_container: 'p.terms', loader: '#primary .content', loadPage: true, before: function( trigger, item ) { // add loading in the button if( typeof yit.load_gif != 'undefined' ) { item.block({message: null, overlayCSS: {background: '#fff url(' + yit.load_gif + ') no-repeat center', opacity: 0.3, cursor: 'none'}}); } else { item.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url.substring(0, woocommerce_params.ajax_loader_url.length - 7) + '.gif) no-repeat center', opacity: 0.3, cursor: 'none'}}); } }, completed: function( trigger, item, html, overlay ) { var data = $('<div>' + html + '</div>'), title = trigger.text(), container = document.getElementById( 'wrapper' ), wrapper = $(overlay).find('.main .container'); // head $('<h4 />').html(title).prependTo( wrapper.find('.head') ); $(overlay).addClass('terms-popup'); $(overlay).find('.content').removeClass('col-sm-12 col-sm-9'); }, openDialog: function( trigger, item ) { item.unblock(); } }); }; $body.on('updated_checkout', term_popup); term_popup(); } }); })( jQuery, window, document );
package com.yh.admin.bo; import java.util.Date; import com.yh.platform.core.bo.BaseBo; public class UserAgent extends BaseBo { private static final long serialVersionUID = <API key>; private Long userAgentOid; private Long systemPositionOid; private String userId; private String agentUserId; private Date effectiveDate; private Date expiredDt; private String isActive; public Long <API key>() { return systemPositionOid; } public void <API key>(Long systemPositionOid) { this.systemPositionOid = systemPositionOid; } public Long getUserAgentOid() { return userAgentOid; } public void setUserAgentOid(Long userAgentOid) { this.userAgentOid = userAgentOid; } public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public String getAgentUserId() { return agentUserId; } public void setAgentUserId(String agentUserId) { this.agentUserId = agentUserId; } public Date getExpiredDt() { return expiredDt; } public void setExpiredDt(Date expiredDt) { this.expiredDt = expiredDt; } public String getIsActive() { return isActive; } public void setIsActive(String isActive) { this.isActive = isActive; } public Date getEffectiveDate() { return effectiveDate; } public void setEffectiveDate(Date effectiveDate) { this.effectiveDate = effectiveDate; } }
<?php namespace PHPExiftool\Driver\Tag\File; use PHPExiftool\Driver\AbstractTag; class PreviewPNG extends AbstractTag { protected $Id = 'PreviewPNG'; protected $Name = 'PreviewPNG'; protected $FullName = 'Extra'; protected $GroupName = 'File'; protected $g0 = 'File'; protected $g1 = 'File'; protected $g2 = 'Image'; protected $Type = '?'; protected $Writable = false; protected $Description = 'Preview PNG'; protected $flag_Binary = true; }
<?php // no direct access defined('_JEXEC') or die; JHtml::addIncludePath(JPATH_COMPONENT.'/helpers'); ?> <div class="blog<?php echo $this->pageclass_sfx;?>"> <?php if ($this->params->get('show_page_heading', 1)) : ?> <h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1> <?php endif; ?> <?php if ($this->params->get('show_category_title', 1) OR $this->params->get('page_subheading')) : ?> <h2> <?php echo $this->escape($this->params->get('page_subheading')); ?> <?php if ($this->params->get('show_category_title')) : ?> <span class="subheading-category"><?php echo $this->category->title;?></span> <?php endif; ?> </h2> <?php endif; ?> <?php if ($this->params->get('show_description', 1) || $this->params->def('<API key>', 1)) : ?> <div class="category-desc"> <?php if ($this->params->get('<API key>') && $this->category->getParams()->get('image')) : ?> <img src="<?php echo $this->category->getParams()->get('image'); ?>"/> <?php endif; ?> <?php if ($this->params->get('show_description') && $this->category->description) : ?> <?php echo JHtml::_('content.prepare', $this->category->description); ?> <?php endif; ?> <div class="clr"></div> </div> <?php endif; ?> <?php $leadingcount=0 ; ?> <?php if (!empty($this->lead_items)) : ?> <div class="items-leading"> <?php foreach ($this->lead_items as &$item) : ?> <div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>"> <?php $this->item = &$item; echo $this->loadTemplate('item'); ?> </div> <?php $leadingcount++; ?> <?php endforeach; ?> </div> <?php endif; ?> <?php $introcount=(count($this->intro_items)); $counter=0; ?> <?php if (!empty($this->intro_items)) : ?> <?php foreach ($this->intro_items as $key => &$item) : ?> <?php $key= ($key-$leadingcount)+1; $rowcount=( ((int)$key-1) % (int) $this->columns) +1; $row = $counter / $this->columns ; if ($rowcount==1) : ?> <div class="items-row cols-<?php echo (int) $this->columns;?> <?php echo 'row-'.$row ; ?>"> <?php endif; ?> <div class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>"> <?php $this->item = &$item; echo $this->loadTemplate('item'); ?> </div> <?php $counter++; ?> <?php if (($rowcount == $this->columns) or ($counter ==$introcount)): ?> <span class="row-separator"></span> </div> <?php endif; ?> <?php endforeach; ?> <?php endif; ?> <?php if (!empty($this->link_items)) : ?> <?php echo $this->loadTemplate('links'); ?> <?php endif; ?> <?php if (!empty($this->children[$this->category->id])&& $this->maxLevel != 0) : ?> <div class="cat-children"> <h3> <?php echo JTEXT::_('<API key>'); ?> </h3> <?php echo $this->loadTemplate('children'); ?> </div> <?php endif; ?> <?php if (($this->params->def('show_pagination', 1) == 1 || ($this->params->get('show_pagination') == 2)) && ($this->pagination->get('pages.total') > 1)) : ?> <div class="pagination"> <?php if ($this->params->def('<API key>', 1)) : ?> <p class="counter"> <?php echo $this->pagination->getPagesCounter(); ?> </p> <?php endif; ?> <?php echo $this->pagination->getPagesLinks(); ?> </div> <?php endif; ?> </div>
local function isBotAllowed (userId, chatId) local hash = 'anti-bot:allowed:'..chatId..':'..userId local banned = redis:get(hash) return banned end local function allowBot (userId, chatId) local hash = 'anti-bot:allowed:'..chatId..':'..userId redis:set(hash, true) end local function disallowBot (userId, chatId) local hash = 'anti-bot:allowed:'..chatId..':'..userId redis:del(hash) end -- Is anti-bot enabled on chat local function isAntiBotEnabled (chatId) local hash = 'anti-bot:enabled:'..chatId local enabled = redis:get(hash) return enabled end local function enableAntiBot (chatId) local hash = 'anti-bot:enabled:'..chatId redis:set(hash, true) end local function disableAntiBot (chatId) local hash = 'anti-bot:enabled:'..chatId redis:del(hash) end local function isABot (user) -- Flag its a bot 0001000000000000 local binFlagIsBot = 4096 local result = bit32.band(user.flags, binFlagIsBot) return result == binFlagIsBot end local function kickUser(userId, chatId) local chat = 'chat#id'..chatId local user = 'user#id'..userId chat_del_user(chat, user, function (data, success, result) if success ~= 1 then print('I can\'t kick '..data.user..' but should be kicked') end end, {chat=chat, user=user}) end local function run (msg, matches) -- We wont return text if is a service msg if matches[1] ~= 'chat_add_user' and matches[1] ~= 'chat_add_user_link' then if msg.to.type ~= 'chat' then return 'Anti-flood works only on channels' end end local chatId = msg.to.id if matches[1] == 'enable' then enableAntiBot(chatId) return 'Anti-bot enabled on this chat' end if matches[1] == 'disable' then disableAntiBot(chatId) return 'Anti-bot disabled on this chat' end if matches[1] == 'allow' then local userId = matches[2] allowBot(userId, chatId) return 'Bot '..userId..' allowed' end if matches[1] == 'disallow' then local userId = matches[2] disallowBot(userId, chatId) return 'Bot '..userId..' disallowed' end if matches[1] == 'chat_add_user' or matches[1] == 'chat_add_user_link' then local user = msg.action.user or msg.from if isABot(user) then print('It\'s a bot!') if isAntiBotEnabled(chatId) then print('Anti bot is enabled') local userId = user.id if not isBotAllowed(userId, chatId) then kickUser(userId, chatId) else print('This bot is allowed') end end end end end return { description = 'When bot enters group kick it.', usage = { '[/!]antibot enable: Enable Anti-bot on current chat', '[/!]antibot disable: Disable Anti-bot on current chat', '[/!]antibot allow <botId>: Allow <botId> on this chat', '[/!]antibot disallow <botId>: Disallow <botId> on this chat' }, patterns = { '^[/!]antibot (allow) (%d+)$', '^[/!]antibot (disallow) (%d+)$', '^[/!]antibot (enable)$', '^[/!]antibot (disable)$', '^!!tgservice (chat_add_user)$', '^!!tgservice (chat_add_user_link)$' }, run = run }
// Based on the ScummVM (GPLv2+) file of the same name #ifdef ENABLE_HE #include "scumm/he/floodfill_he.h" #include "scumm/he/intern_he.h" #include "scumm/resource.h" #include "scumm/scumm.h" namespace Scumm { static bool floodFillPixelCheck(int x, int y, const FloodFillState *ffs) { int diffColor = ffs->color1 - ffs->color2; if (x >= 0 && x < ffs->dst_w && y >= 0 && y < ffs->dst_h) { uint8 color = *(ffs->dst + y * ffs->dst_w + x); diffColor = color - ffs->color1; } return diffColor == 0; } static void <API key>(FloodFillState *ffs, const Common::Rect *r) { Common::Rect *dr = &ffs->dstBox; if (dr->right >= dr->left && dr->top <= dr->bottom) { int rw = r->right - r->left + 1; int rh = r->bottom - r->top + 1; assert(r->top + rh <= ffs->dst_h); assert(r->left + rw <= ffs->dst_w); uint8 *dst = ffs->dst + r->top * ffs->dst_w + r->left; if (rw <= 1) { --rh; while (rh >= 0) { *dst = ffs->color2; dst += ffs->dst_w; --rh; } } else { --rh; while (rh >= 0) { memset(dst, ffs->color2, rw); dst += ffs->dst_w; --rh; } } dr->extend(*r); } else { *dr = *r; } } static void floodFillAddLine(FloodFillLine **ffl, int y, int x1, int x2, int dy) { (*ffl)->y = y; (*ffl)->x1 = x1; (*ffl)->x2 = x2; (*ffl)->inc = dy; (*ffl)++; } static void floodFillProcess(int x, int y, FloodFillState *ffs, <API key> pixelCheckCallback) { ffs->dstBox.left = ffs->dstBox.top = 12345; ffs->dstBox.right = ffs->dstBox.bottom = -12345; FloodFillLine **fillLineCur = &ffs->fillLineTableCur; FloodFillLine **fillLineEnd = &ffs->fillLineTableEnd; assert(*fillLineCur < *fillLineEnd); if (ffs->srcBox.top <= y + 1 && ffs->srcBox.bottom >= y + 1) { (*fillLineCur)->y = y; (*fillLineCur)->x1 = x; (*fillLineCur)->x2 = x; (*fillLineCur)->inc = 1; (*fillLineCur)++; } assert(*fillLineCur < *fillLineEnd); if (ffs->srcBox.top <= y && ffs->srcBox.bottom >= y) { (*fillLineCur)->y = y + 1; (*fillLineCur)->x1 = x; (*fillLineCur)->x2 = x; (*fillLineCur)->inc = -1; (*fillLineCur)++; } assert(ffs->fillLineTable <= *fillLineCur); FloodFillLine **fillLineStart = fillLineCur; while (ffs->fillLineTable < *fillLineStart) { Common::Rect r; int x_start; FloodFillLine *fflCur = --(*fillLineCur); int dy = fflCur->inc; int x_end = fflCur->x2; int x1 = fflCur->x1; int x2 = fflCur->x1 + 1; r.bottom = r.top = y = fflCur->y + fflCur->inc; r.left = x2; r.right = x1; x = x1; while (ffs->srcBox.left <= x) { if (!(*pixelCheckCallback)(x, y, ffs)) { break; } r.left = x; --x; } if (r.right >= r.left && r.top <= r.bottom) { <API key>(ffs, &r); } if (x >= x1) goto skip; x_start = x + 1; if (x1 > x_start) { assert(*fillLineEnd > *fillLineCur); if (ffs->srcBox.top <= y - dy && ffs->srcBox.bottom >= y - dy) { --x1; floodFillAddLine(fillLineCur, y, x_start, x1, -dy); } } x = x2; while (x_start <= x_end) { r.left = x; r.top = y; r.right = x - 1; r.bottom = y; while (ffs->srcBox.right >= x) { if (!(*pixelCheckCallback)(x, y, ffs)) { break; } r.right = x; ++x; } if (r.right >= r.left && r.top <= r.bottom) { <API key>(ffs, &r); } assert(ffs->fillLineTableCur < ffs->fillLineTableEnd); if (ffs->srcBox.top <= y + dy && ffs->srcBox.bottom >= y + dy) { floodFillAddLine(&ffs->fillLineTableCur, y, x_start, x - 1, dy); } x_start = x_end + 1; if (x > x_start) { assert(ffs->fillLineTableCur < ffs->fillLineTableEnd); if (ffs->srcBox.top <= y - dy && ffs->srcBox.bottom >= y - dy) { floodFillAddLine(&ffs->fillLineTableCur, y, x_start, x - 1, -dy); } } skip: ++x; while (x <= x_end) { if ((*pixelCheckCallback)(x, y, ffs)) { break; } ++x; } x_start = x; } } } void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) { uint8 *dst; VirtScreen *vs = &vm->_virtscr[kMainVirtScreen]; if (ffp->flags & 0x8000) { dst = vs->getBackPixels(0, vs->topline); } else { dst = vs->getPixels(0, vs->topline); } uint8 color = ffp->flags & 0xFF; Common::Rect r; r.left = r.top = 12345; r.right = r.bottom = -12345; FloodFillState *ffs = new FloodFillState; ffs->fillLineTableCount = vs->getHeight() * 2; ffs->fillLineTable = new FloodFillLine[ffs->fillLineTableCount]; ffs->color2 = color; ffs->dst = dst; ffs->dst_w = vs->getWidth(); ffs->dst_h = vs->getHeight(); ffs->srcBox = ffp->box; ffs->fillLineTableCur = &ffs->fillLineTable[0]; ffs->fillLineTableEnd = &ffs->fillLineTable[ffs->fillLineTableCount]; if (ffp->x < 0 || ffp->y < 0 || ffp->x >= vs->getWidth() || ffp->y >= vs->getHeight()) { ffs->color1 = color; } else { ffs->color1 = *(dst + ffp->y * vs->getWidth() + ffp->x); } debug(5, "floodFill() x=%d y=%d color1=%d ffp->flags=0x%X", ffp->x, ffp->y, ffs->color1, ffp->flags); if (ffs->color1 != color) { floodFillProcess(ffp->x, ffp->y, ffs, floodFillPixelCheck); r = ffs->dstBox; } r.debugPrint(5, "floodFill() dirty_rect"); delete[] ffs->fillLineTable; delete ffs; vm->VAR(119) = 1; if (r.left <= r.right && r.top <= r.bottom) { if (ffp->flags & 0x8000) { vm->restoreBackgroundHE(r); } else { ++r.bottom; vm->markRectAsDirty(kMainVirtScreen, r); } } } void Wiz::fillWizFlood(const WizParameters *params) { if (params->processFlags & kWPFClipBox2) { int px = params->box2.left; int py = params->box2.top; uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum); if (dataPtr) { int state = 0; if (params->processFlags & kWPFNewState) { state = params->img.state; } uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0); assert(wizh); int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); int h = READ_LE_UINT32(wizh + 0x8); assert(c == 0); Common::Rect imageRect(w, h); if (params->processFlags & kWPFClipBox) { if (!imageRect.intersects(params->box)) { return; } imageRect.clip(params->box); } uint8 color = _vm->VAR(93); if (params->processFlags & kWPFFillColor) { color = params->fillColor; } if (imageRect.contains(px, py)) { uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0); assert(wizd); FloodFillState *ffs = new FloodFillState; ffs->fillLineTableCount = h * 2; ffs->fillLineTable = new FloodFillLine[ffs->fillLineTableCount]; ffs->color2 = color; ffs->dst = wizd; ffs->dst_w = w; ffs->dst_h = h; ffs->srcBox = imageRect; ffs->fillLineTableCur = &ffs->fillLineTable[0]; ffs->fillLineTableEnd = &ffs->fillLineTable[ffs->fillLineTableCount]; if (px < 0 || py < 0 || px >= w || py >= h) { ffs->color1 = color; } else { ffs->color1 = *(wizd + py * w + px); } debug(0, "floodFill() x=%d y=%d color1=%d", px, py, ffs->color1); if (ffs->color1 != color) { floodFillProcess(px, py, ffs, floodFillPixelCheck); } delete[] ffs->fillLineTable; delete ffs; } } } _vm->_res->setModified(rtImage, params->img.resNum); } } // End of namespace Scumm #endif // ENABLE_HE
<!DOCTYPE html PUBLIC "- <html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Language" content="zh-CN"><link href="stylesheet.css" media="all" rel="stylesheet" type="text/css"> <title>pg_database</title> <script>var _hmt=_hmt||[]; (function(){ var hm=document.createElement("script"); hm.src="//hm.baidu.com/hm.js?<API key>"; var s=document.<API key>("script")[0]; s.parentNode.insertBefore(hm,s); })();</script> </head><body class="SECT1"> <div> <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><th colspan="5" align="center" valign="bottom">PostgreSQL 8.2.3 </th></tr> <tr><td width="10%" align="left" valign="top"><a href="<API key>.html" accesskey="P"></a></td><td width="10%" align="left" valign="top"><a href="catalogs.html"></a></td><td width="60%" align="center" valign="bottom">43. </td><td width="10%" align="right" valign="top"><a href="catalogs.html"></a></td><td width="10%" align="right" valign="top"><a href="catalog-pg-depend.html" accesskey="N"></a></td></tr> </table> <hr align="LEFT" width="100%"></div> <div class="SECT1"><h1 class="SECT1"><a name="CATALOG-PG-DATABASE">43.15. <tt class="STRUCTNAME">pg_database</tt></a></h1><a name="AEN63288"></a> <p><tt class="STRUCTNAME">pg_database</tt> <a href="sql-createdatabase.html"><i>CREATE DATABASE</i></a> <a href="managing-databases.html">19</a></p> <p><tt class="STRUCTNAME">pg_database</tt> <tt class="STRUCTNAME">pg_database</tt> </p> <div class="TABLE"><a name="AEN63297"></a> <p><b>43-15. <tt class="STRUCTNAME">pg_database</tt> </b></p> <table border="1" class="CALSTABLE"><col><col><col><col> <thead> <tr><th></th><th></th><th></th><th></th></tr> </thead> <tbody> <tr><td><tt class="STRUCTFIELD">datname</tt></td><td><tt class="TYPE">name</tt></td><td>&nbsp;</td><td></td></tr> <tr><td><tt class="STRUCTFIELD">datdba</tt></td><td><tt class="TYPE">oid</tt></td><td><tt class="LITERAL"><a href="catalog-pg-authid.html"><tt class="STRUCTNAME">pg_authid</tt></a>.oid</tt></td><td></td></tr> <tr><td><tt class="STRUCTFIELD">encoding</tt></td><td><tt class="TYPE">int4</tt></td><td>&nbsp;</td><td>(<code class="FUNCTION">pg_encoding_to_char()</code> )</td></tr> <tr><td><tt class="STRUCTFIELD">datistemplate</tt></td><td><tt class="TYPE">bool</tt></td><td>&nbsp;</td><td> <tt class="COMMAND">CREATE DATABASE</tt> <tt class="LITERAL">TEMPLATE</tt> </td></tr> <tr><td><tt class="STRUCTFIELD">datallowconn</tt></td><td><tt class="TYPE">bool</tt></td><td>&nbsp;</td><td> <tt class="LITERAL">template0</tt> </td></tr> <tr><td><tt class="STRUCTFIELD">datconnlimit</tt></td><td><tt class="TYPE">int4</tt></td><td>&nbsp;</td><td>-1 </td></tr> <tr><td><tt class="STRUCTFIELD">datlastsysoid</tt></td><td><tt class="TYPE">oid</tt></td><td>&nbsp;</td><td> OID <span class="APPLICATION">pg_dump</span> </td></tr> <tr><td><tt class="STRUCTFIELD">datfrozenxid</tt></td><td><tt class="TYPE">xid</tt></td><td>&nbsp;</td><td> ID ("frozen") ID ID <tt class="LITERAL">pg_clog</tt> <tt class="STRUCTNAME">pg_class</tt>.<tt class="STRUCTFIELD">relfrozenxid</tt> </td></tr> <tr><td><tt class="STRUCTFIELD">dattablespace</tt></td><td><tt class="TYPE">oid</tt></td><td><tt class="LITERAL"><a href="<API key>.html"><tt class="STRUCTNAME">pg_tablespace</tt></a>.oid</tt></td><td> <tt class="STRUCTNAME">pg_class</tt>.<tt class="STRUCTFIELD">reltablespace</tt> </td></tr> <tr><td><tt class="STRUCTFIELD">datconfig</tt></td><td><tt class="TYPE">text[]</tt></td><td>&nbsp;</td><td></td></tr> <tr><td><tt class="STRUCTFIELD">datacl</tt></td><td><tt class="TYPE">aclitem[]</tt></td><td>&nbsp;</td><td> <a href="sql-grant.html"><i>GRANT</i></a> <a href="sql-revoke.html"><i>REVOKE</i></a> </td></tr> </tbody> </table> </div> </div> <div> <hr align="LEFT" width="100%"> <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td width="33%" align="left" valign="top"><a href="<API key>.html" accesskey="P"></a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H"></a></td><td width="33%" align="right" valign="top"><a href="catalog-pg-depend.html" accesskey="N"></a></td></tr> <tr><td width="33%" align="left" valign="top"><tt class="STRUCTNAME">pg_conversion</tt></td><td width="34%" align="center" valign="top"><a href="catalogs.html" accesskey="U"></a></td><td width="33%" align="right" valign="top"><tt class="STRUCTNAME">pg_depend</tt></td></tr> </table> </div> </body></html>
if (Meteor.isServer) { var / A lookup-table whose keys are generated each time an ‘you.register’ form is rendered using the `babelslug()` method. / The key is a babelslug, followed by hyphen, followed by a Meteor connection ID (like a session ID for anon users). / The value is the unix timestamp in milliseconds, which allows us to clear out old and unused babelslugs. / Two examples are shown here: recentBabelslugs = { // @todo for a multi-servo project, move this functionality to a shared mongoDB collection // '<API key>': 1409341347912, // '<API key>': 1409341399283 } / Clear out stale elements in the `recentBabelslugs` lookup-table. , <API key> = function () { var key , now = Date.now() ; for (key in recentBabelslugs) { if (15 * 60 * 1000 < now - recentBabelslugs[key]) { // allow a user 15 minutes to fill in the registration form delete recentBabelslugs[key]; } } } / Check how many times a given `username` exists in the user database. If all’s well, this should only ever return `0` or `1`. , usernameCount = function (username) { return Meteor.users.find({ 'profile.username': username }).count(); } / BabelSlug, from Rich Plastow’s work, 2014-02-09. , ucs2 = [ [ // animal { en:'slug' ,es:'babosa' ,ru:'\u0441\u043B\u0438\u0437\u043D\u044F\u043A',fr:'limace' ,zh:'\u86DE\u8753',ar:'\u064A\u0631\u0642\u0627\u0646\u0629' } , { en:'mouse' ,es:'rat\u00F3n',ru:'\u043C\u044B\u0448\u044C' ,fr:'souris' ,zh:'\u9F20\u6807',ar:'\u0641\u0623\u0631' } , { en:'cow' ,es:'vaca' ,ru:'\u043A\u043E\u0440\u043E\u0432\u0430' ,fr:'vache' ,zh:'\u725B' ,ar:'\u0628\u0642\u0631\u0629' } , { en:'cat' ,es:'gato' ,ru:'\u043A\u043E\u0448\u043A\u0430' ,fr:'chat' ,zh:'\u732B' ,ar:'\u0642\u0637' } , { en:'rabbit',es:'conejo' ,ru:'\u043A\u0440\u043E\u043B\u0438\u043A' ,fr:'lapin' ,zh:'\u5154' ,ar:'\u0623\u0631\u0646\u0628' } , { en:'deer' ,es:'ciervo' ,ru:'\u043E\u043B\u0435\u043D\u044C' ,fr:'cerf' ,zh:'\u9E7F' ,ar:'\u0623\u064A\u0644' } , { en:'bear' ,es:'oso' ,ru:'\u043C\u0435\u0434\u0432\u0435\u0434\u044C',fr:'ours' ,zh:'\u718A' ,ar:'\u062F\u064F\u0628\u0651' } , { en:'frog' ,es:'rana' ,ru:'\u043B\u044F\u0433\u0443\u0448\u043A\u0430',fr:'grenouille',zh:'\u9752\u86D9',ar:'\u0636\u0641\u062F\u0639' } ] // , [ // texture // { en:'-' ,es:'-' ,ru:'-' ,fr:'-' ,zh:'-' ,ar:'-' } // , { en:'dotted' ,es:'punteado',ru:[1087,1091,1085,1082,1090,1080,1088,1085,1099,1081],fr:'pointill\u00E9',zh:[26001,28857],ar:[1605,1606,1602,1591] } // , { en:'striped',es:'rayas' ,ru:[1087,1086,1083,1086,1089,1072,1090,1099,1081] ,fr:'ray\u00E9' ,zh:[26465,32441],ar:[1605,1602,1604,1605] } // , { en:'chess' ,es:'ajedrez' ,ru:[1096,1072,1093,1084,1072,1090,1099] ,fr:'\u00E9checs' ,zh:[26827] ,ar:[1588,1591,1585,1606,1580] } , [ // color1 { en:'-' ,es:'-' ,ru:'-' ,fr:'-' ,zh:'-' ,ar:'-' } , { en:'red' ,es:'rojo' ,ru:[1082,1088,1072,1089,1085,1099,1081] ,fr:'rouge' ,zh:[32418] ,ar:[1571,1581,1605,1585] } , { en:'orange' ,es:'naranja' ,ru:[1086,1088,1072,1085,1078,1077,1074,1099,1081],fr:'orange' ,zh:[27225] ,ar:[1575,1604,1576,1585,1578,1602,1575,1604,1610] } , { en:'yellow' ,es:'amarillo',ru:[1078,1077,1083,1090,1099,1081] ,fr:'jaune' ,zh:[40644] ,ar:[1571,1589,1601,1585] } , { en:'green' ,es:'verde' ,ru:[1079,1077,1083,1077,1085,1099,1081] ,fr:'vert' ,zh:[32511] ,ar:[1571,1582,1590,1585] } // , { en:'cyan' ,es:'cian' ,ru:[1075,1086,1083,1091,1073,1086,1081] ,fr:'cyan' ,zh:[38738] ,ar:[1587,1605,1575,1608,1610] } , { en:'blue' ,es:'azul' ,ru:[1089,1080,1085,1080,1081] ,fr:'bleu' ,zh:[34013] ,ar:[1571,1586,1585,1602] } , { en:'purple' ,es:'magenta' ,ru:[1087,1091,1088,1087,1091,1088,1085,1099,1081],fr:'magenta',zh:[27915,32418],ar:[1571,1585,1580,1608,1575,1606,1610] } // @todo translate purple (these are for magenta) ] , [ // emotion @todo convert remaining languages from 2014-Work/BabelSlug/README.md { en:'-' ,es:'-' ,fr:'-' } , { en:'happy' ,es:'feliz' ,fr:'heureux' } // , { en:'sad' ,es:'triste' ,fr:'triste' } , { en:'laughing' ,es:'risa' ,fr:'rire' } , { en:'sleepy' ,es:'soñoliento' ,fr:'somnolent' } , { en:'surprised',es:'sorprendido',fr:'étonné' } , { en:'confused' ,es:'confundido' ,fr:'embrouillé' } ] ] / Prepare an empty cache, which may contain HTML entities converted from `ucs2`, if required. , html = (function () { var i, j, l, m ,html = {}; for (i=0, l=ucs2.length; i<l; i++) { html[i] = []; for (j=0, m=ucs2[i].length; j<m; j++) { html[i][j] = {}; } } return html } ()) // !!!! `numberToPhrase()`, then `i` becomes `num`, and then `ucs2` becomes an array, and `i` is iterator !!!! , numberToPhrase = function (number, options) { var key, len, rem, word , num = ~~(number < 0 ? -number : number) // ensure `num` is a positive whole number, or zero , opt = options || {} , l18n = ucs2[0][0][opt.l18n] ? opt.l18n : 'en' // set to English if the localization option is invalid or unspecified , phrase = [] ; for (key in ucs2) { len = ucs2[key].length; rem = num % len; if (! opt.format || 'ucs2' === opt.format) { word = ucs2[key][rem][l18n]; // console.log('key ' + key + ' format ' + 'ucs2' + ' word ' + word); } else if ('html' === opt.format) { word = html[key][rem][l18n]; if (! word) { word = html[key][rem][l18n] = ucs2[key][rem][l18n].replace(/[\u00A0-\u2666]/g, function(c) { return '&#' + c.charCodeAt(0) + ';'; }); // console.log('ADD TO CACHE key ' + key + ' format ' + 'html' + ' word ' + word); } else { // console.log('GET IN CACHE key ' + key + ' format ' + 'html' + ' word ' + word); } } else { // @todo format error } if ('-' !== word) { phrase.unshift(word); } num = ~~(num / len); // prepare for the next part in `ucs2` if (0 === num) { break; } // low numbers don't need to step through every section in `ucs2` } return phrase.join('-'); } ; Meteor.methods({ babelslug: function () { var i, key, babelslug; if (this.isSimulation) { return; } // clientside stub (return value is ignored) / Housekeeping on the `recentBabelslugs` lut. <API key>(); / Try, 200 times, to find a username which has not been taken. @todo this is quite brute-force ... can we come up with a more elegant solution? for (i=200; i>0; i babelslug = numberToPhrase( Math.floor(Math.random() * 50000) ); if ( 3 === babelslug.split('-').length && ! recentBabelslugs[babelslug] && ! usernameCount(babelslug) ) { break; } // we are only using three-part usernames at present } if (! i) { throw new Meteor.Error(500, "Cannot generate a username! Please email " + Config.about.webmaster); } // @todo check `(! i)` can ever be truthy recentBabelslugs[babelslug] = { // later, when the form is submitted, we will check that the babelslug value is expected now: Date.now() // allows `<API key>()` to find stale babelslugs , cid: this.connection.id } return babelslug + '_' + this.connection.id; // @todo is `this.connection.id` ever some unexpected value, for example `null`? } }); Accounts.onCreateUser(function (options, user) { var babelslug, connectionId; / Housekeeping on the `recentBabelslugs` lut. <API key>(); / Validate the value of `<input id="<API key>" ...>`. babelslug = options.profile['you-babelslug'].split('_')[0]; connectionId = options.profile['you-babelslug'].split('_')[1]; if (! babelslug || ! connectionId) { throw new Meteor.Error(500, "The ‘username’ field is invalid."); // @todo better error-code than 500? } if (! recentBabelslugs[babelslug]) { throw new Meteor.Error(500, "Your registration form expired after 15 minutes. Please refresh the browser and try again."); } if ( usernameCount(babelslug) ) { throw new Meteor.Error(500, "The ‘username’ is already in use."); // prevent two `Meteor.user` records having the same username, which could happen on a multi-servo project, until we change `recentBabelslugs` to a shared mongoDB collection @todo } / Remove the babelslug, as it’s not needed any more. delete recentBabelslugs[babelslug]; / Record the username (‘info@loop.coop’ gets a special username). options.profile = options.profile || {}; options.profile.username = 'info@loop.coop' === options.email ? 'red-cat' : babelslug; / Record other registration data. if (options.profile['you-age-group-code']) { options.profile.agc = options.profile['you-age-group-code']; } if (options.profile['you-based-in-code']) { options.profile.bic = options.profile['you-based-in-code']; } if (options.profile['you-hear-about-code']) { options.profile.hac = options.profile['you-hear-about-code']; } if (options.profile['you-hear-about-text']) { options.profile.hat = options.profile['you-hear-about-text']; } if (options.profile['you-newsletter-opt']) { options.profile.nlo = options.profile['you-newsletter-opt']; } / The registration is valid, so record it as usual. http://docs.meteor.com/#<API key> user.profile = options.profile; return user; }); }
#pragma once #include <string> class GameSettings { private: int m_nFPS = 60; std::string m_strPath = "../Settings.ini"; private: GameSettings(); void Load(); void Save(); static GameSettings& GetInstance(); public: static int FPS(); };
package org.rebecalang.modeltransformer.ros.timedrebeca; import java.util.HashMap; import java.util.Map; import org.rebecalang.compiler.modelcompiler.corerebeca.<API key>; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.BinaryExpression; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.CastExpression; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.DotPrimary; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.Expression; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.FieldDeclaration; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.Literal; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.MsgsrvDeclaration; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.NonDetExpression; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.PlusSubExpression; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.PrimaryExpression; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.<API key>; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.<API key>; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.RebecaModel; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.TermPrimary; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.TernaryExpression; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.UnaryExpression; import org.rebecalang.compiler.modelcompiler.corerebeca.objectmodel.VariableDeclarator; import org.rebecalang.compiler.modelcompiler.timedrebeca.<API key>; import org.rebecalang.compiler.utils.<API key>; import org.rebecalang.compiler.utils.ExceptionContainer; import org.rebecalang.compiler.utils.Pair; import org.rebecalang.modeltransformer.<API key>; import org.rebecalang.modeltransformer.ros.Utilities; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class <API key> { public final static String NEW_LINE = "\r\n"; public final static String TAB = "\t"; static Integer i = 0; private String modelName; private <API key> rc; private RebecaModel rebecaModel; private Map <Pair<String, String>, String> methodCalls = new HashMap<Pair<String, String>, String>(); @Autowired <API key> <API key>; @Autowired ExceptionContainer exceptionContainer; public void prepare(String modelName, <API key> rc, RebecaModel rebecaModel) { this.modelName = modelName; this.rebecaModel = rebecaModel; this.rc = rc; } public String translate(Expression expression) { String retValue = ""; if (expression instanceof TernaryExpression) { TernaryExpression tExpression = (TernaryExpression)expression; Expression condition = tExpression.getCondition(); retValue = "(" + (translate(condition)) + ")"; retValue += " ? " + "(" + translate(tExpression.getLeft()) + ")"; retValue += " : " + "(" + translate(tExpression.getRight()) + ")"; } else if (expression instanceof BinaryExpression) { BinaryExpression bExpression = (BinaryExpression) expression; String op = bExpression.getOperator(); retValue = translate(bExpression.getLeft()) + " " + op + " " + translate(bExpression.getRight()); } else if (expression instanceof UnaryExpression) { UnaryExpression uExpression = (UnaryExpression) expression; retValue = uExpression.getOperator() + " " + translate(uExpression.getExpression()); } else if (expression instanceof CastExpression) { exceptionContainer.addException(new <API key>("This version of transformer does not supprt " + "\"cast\" expression.", expression.getLineNumber(), expression.getCharacter())); } else if (expression instanceof NonDetExpression) { NonDetExpression nonDetExpression = (NonDetExpression)expression; int numberOfChoices = nonDetExpression.getChoices().size(); retValue += nonDetExpression.getType().getTypeName(); retValue += "int numberOfChoices = " + Integer.toString(numberOfChoices) + ";" + NEW_LINE; retValue += "int choice = " + "rand() % " + Integer.toString(numberOfChoices) + ";" + NEW_LINE; int index = numberOfChoices; for (Expression nonDetChoice : ((NonDetExpression)expression).getChoices()) { retValue += "if (" + "choice ==" + Integer.toString(numberOfChoices - index) + ")" + NEW_LINE; retValue += ((NonDetExpression)nonDetChoice); index ++; } } else if (expression instanceof Literal) { Literal lExpression = (Literal) expression; retValue = lExpression.getLiteralValue(); if (retValue.equals("null")) retValue = "\"dummy\""; } else if (expression instanceof PlusSubExpression) { retValue = translate(((PlusSubExpression)expression).getValue()) + ((PlusSubExpression)expression).getOperator(); } else if (expression instanceof PrimaryExpression) { PrimaryExpression pExpression = (PrimaryExpression) expression; retValue = <API key>(pExpression); } else { exceptionContainer.addException( new <API key>("Unknown translation rule for expression type " + expression.getClass(), expression.getLineNumber(), expression.getCharacter())); } return retValue; } protected String <API key>(PrimaryExpression pExpression) { String retValue = ""; if (pExpression instanceof DotPrimary) { DotPrimary dotPrimary = (DotPrimary) pExpression; retValue = translateDotPrimary(dotPrimary); } else if (pExpression instanceof TermPrimary) { retValue = <API key>((TermPrimary) pExpression); } else if (pExpression instanceof <API key>) { <API key> rip = (<API key>) pExpression; boolean hasMoreVariable = false; String args = ""; try { <API key> rcd = (<API key>) <API key>.getMetaData(rip.getType()); if (!rcd.getStatevars().isEmpty()) { args += " , "; for (FieldDeclaration fd : rcd.getStatevars()) { for (VariableDeclarator vd : fd.<API key>()) { hasMoreVariable = true; String typeInit = fd.getType() == <API key>.BOOLEAN_TYPE ? "false" : fd.getType().canTypeCastTo(<API key>.INT_TYPE) ? "0" : "\"dummy\""; args += "(" + rcd.getName() + "-" + vd.getVariableName() + " |-> " + typeInit + ") " ; } } } if (!hasMoreVariable) args += "emptyValuation"; } catch (<API key> e) { e.printStackTrace(); } args += ","; hasMoreVariable = false; String typeName = rip.getType().getTypeName(); for (Expression expression : rip.getBindings()) { args += " arg(" + translate(expression) + ")"; hasMoreVariable = true; } for (Expression expression : rip.getArguments()) { args += " arg(" + translate(expression) + ")"; hasMoreVariable = true; } if (!hasMoreVariable) args += "noArg"; retValue = " new (" + typeName + args + ")"; } else { exceptionContainer.addException(new <API key>("Unknown translation rule for initializer type " + pExpression.getClass(), pExpression.getLineNumber(), pExpression.getCharacter())); } return retValue; } private String translateDotPrimary(DotPrimary dotPrimary) { String retValue = ""; if (!(dotPrimary.getLeft() instanceof TermPrimary) || !(dotPrimary.getRight() instanceof TermPrimary)) { exceptionContainer.addException(new <API key>("This version of transformer does not supprt " + "nested record access expression.", dotPrimary.getLineNumber(), dotPrimary.getCharacter())); } else { // if(TypesUtilities.getInstance().getSuperType(dotPrimary.getRight().getType()) == TypesUtilities.MSGSRV_TYPE) { if(dotPrimary.getRight().getType() == <API key>.MSGSRV_TYPE) { retValue = mapToROSPublishing(dotPrimary); } } return retValue; } private String mapToROSPublishing(DotPrimary dotPrimary) { String retValue = ""; /* map to ROS Publishing */ retValue = modelName + "::" + ((TermPrimary)dotPrimary.getRight()).getName() + " " + "pubMsg" + i.toString() + ";" + NEW_LINE; /* fill the ROS message fields with the arguments to be published */ int argumentIndex = 0; for (Expression expression : ((TermPrimary)dotPrimary.getRight()).<API key>().getArguments()) { <API key> toClass = null; TermPrimary toRebec = (TermPrimary)dotPrimary.getLeft(); toClass = Utilities.<API key>(rc, toRebec.getName(), rebecaModel); String toMsgsrvName = ((TermPrimary)dotPrimary.getRight()).getName(); MsgsrvDeclaration toMsgsrv = Utilities.findTheMsgsrv(toClass, toMsgsrvName); String argumentName = toMsgsrv.getFormalParameters().get(argumentIndex).getName(); retValue += "pubMsg" + i.toString() + "." + argumentName + " = " + translate(expression) + ";" + NEW_LINE; argumentIndex ++; } retValue += "pubMsg" + i.toString() + "." + "sender" + "=" + "sender" + ";" + NEW_LINE; retValue += ((TermPrimary) dotPrimary.getLeft()).getName() + "_" + ((TermPrimary)dotPrimary.getRight()).getName() + "_pub" + "." + "publish(" + "pubMsg" + i.toString() + ")" + ";" + NEW_LINE; i ++; /* to prevent from repeated names */ /* end of publishing */ /* storing the name of callee rebec and the name of called msgsrv in order to declare publishers */ Pair<String, String> methodCall = new Pair<String, String>( ((TermPrimary)dotPrimary.getLeft()).getName(), ((TermPrimary)dotPrimary.getRight()).getName() ); methodCalls.put(methodCall, ""); //<API key> rcd = (<API key>) TransformingContext.getInstance().lookupInContext("<API key>"); //retValue = ((TermPrimary) dotPrimary.getLeft()).getName(); //String typeName = TypesUtilities.getTypeName(((TermPrimary) dotPrimary.getLeft()).getType()); //System.out.println(typeName); return retValue; } private String <API key>(TermPrimary pExpression) { String retValue = ""; if(pExpression.getName().equals("assertion") || pExpression.getName().equals("after") || pExpression.getName().equals("deadline")){ return retValue; } if(pExpression.getName().equals("delay")) retValue += "sleep"; else if(pExpression.getName().equals("sender")) return "thisMsg.sender"; else retValue += pExpression.getName(); if( pExpression.<API key>() != null) { retValue += "("; for(Expression argument: pExpression.<API key>().getArguments()) { retValue += translate(argument) + ","; } if(! pExpression.<API key>().getArguments().isEmpty()) { retValue = retValue.substring(0, retValue.length() - 1); } retValue += ")"; } //To support movement in ROS if (retValue.compareTo("Move(1,0)")==0) { //ROSCode to publish on CM_Vel topic } else if (retValue.compareTo("Move(0,1)")==0) { //ROSCode to publish on CM_Vel topic } else if (retValue.compareTo("Move(-1,0)")==0) { //ROSCode to publish on CM_Vel topic } else if (retValue.compareTo("Move(0,-1)")==0) { //ROSCode to publish on CM_Vel topic } else if(retValue.compareTo("Move(1,1)")==0) { //ROSCode to publish on CM_Vel topic } else if(retValue.compareTo("Move(1,-1)")==0) { //ROSCode to publish on CM_Vel topic } else if(retValue.compareTo("Move(-1,1)")==0) { //ROSCode to publish on CM_Vel topic } else if(retValue.compareTo("Move(-1,-1)")==0) { //ROSCode to publish on CM_Vel topic } /* to support arrays */ for(Expression ex: pExpression.getIndices()) { retValue += "[" + translate(ex) + "]"; } return retValue; } public Map <Pair<String, String>, String> getMethodCalls() { return methodCalls; } }
#ifndef _LVM_UTIL_H #define _LVM_UTIL_H #define min(a, b) ({ typeof(a) _a = (a); \ typeof(b) _b = (b); \ (void) (&_a == &_b); \ _a < _b ? _a : _b; }) #define max(a, b) ({ typeof(a) _a = (a); \ typeof(b) _b = (b); \ (void) (&_a == &_b); \ _a > _b ? _a : _b; }) #define uninitialized_var(x) x = x #define KERNEL_VERSION(major, minor, release) (((major) << 16) + ((minor) << 8) + (release)) #endif
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!--NewPage <HTML> <HEAD> <!-- Generated by javadoc on Mon Jul 03 11:07:20 PDT 2000 --> <TITLE> : Class Ins_dup2 </TITLE> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"> </HEAD> <BODY BGCOLOR="white"> <A NAME="navbar_top"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A NAME="navbar_top_firstrow"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" ID="NavBarCell1Rev"> &nbsp;<FONT ID="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../ojvm/loading/instructions/Ins_dup_x2.html"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../ojvm/loading/instructions/Ins_dup2_x1.html"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Ins_dup2.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> </TR> <TR> <TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2"> SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#<API key>.loading.instructions.Instruction">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2"> DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <HR> <H2> <FONT SIZE="-1"> ojvm.loading.instructions</FONT> <BR> Class Ins_dup2</H2> <PRE> java.lang.Object | +--<A HREF="../../../ojvm/loading/instructions/Instruction.html">ojvm.loading.instructions.Instruction</A> | +--<B>ojvm.loading.instructions.Ins_dup2</B> </PRE> <HR> <DL> <DT>public class <B>Ins_dup2</B><DT>extends <A HREF="../../../ojvm/loading/instructions/Instruction.html">Instruction</A></DL> <P> The encapsulation of a dup2 instruction. <P> <HR> <P> <A NAME="<API key>.loading.instructions.Instruction"></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#EEEEFF" ID="<API key>"> <TD><B>Fields inherited from class ojvm.loading.instructions.<A HREF="../../../ojvm/loading/instructions/Instruction.html">Instruction</A></B></TD> </TR> <TR BGCOLOR="white" ID="TableRowColor"> <TD><CODE><A HREF="../../../ojvm/loading/instructions/Instruction.html#length">length</A>, <A HREF="../../../ojvm/loading/instructions/Instruction.html#OPCODE">OPCODE</A>, <A HREF="../../../ojvm/loading/instructions/Instruction.html#opcodeName">opcodeName</A></CODE></TD> </TR> </TABLE> &nbsp; <A NAME="constructor_summary"></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" ID="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Constructor Summary</B></FONT></TD> </TR> <TR BGCOLOR="white" ID="TableRowColor"> <TD><CODE><B><A HREF="../../../ojvm/loading/instructions/Ins_dup2.html#Ins_dup2(ojvm.loading.instructions.<API key>)">Ins_dup2</A></B>(<A HREF="../../../ojvm/loading/instructions/<API key>.html"><API key></A>&nbsp;classFile)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <A NAME="method_summary"></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" ID="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Method Summary</B></FONT></TD> </TR> <TR BGCOLOR="white" ID="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../ojvm/loading/instructions/Ins_dup2.html#accept(ojvm.operations.InstructionVisitor)">accept</A></B>(<A HREF="../../../ojvm/operations/InstructionVisitor.html">InstructionVisitor</A>&nbsp;iv)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" ID="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../ojvm/loading/instructions/Ins_dup2.html#toString()">toString</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp;<A NAME="<API key>.loading.instructions.Instruction"></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#EEEEFF" ID="<API key>"> <TD><B>Methods inherited from class ojvm.loading.instructions.<A HREF="../../../ojvm/loading/instructions/Instruction.html">Instruction</A></B></TD> </TR> <TR BGCOLOR="white" ID="TableRowColor"> <TD><CODE><A HREF="../../../ojvm/loading/instructions/Instruction.html#getLength()">getLength</A>, <A HREF="../../../ojvm/loading/instructions/Instruction.html#isActualInstruction()">isActualInstruction</A></CODE></TD> </TR> </TABLE> &nbsp;<A NAME="<API key>.lang.Object"></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#EEEEFF" ID="<API key>"> <TD><B>Methods inherited from class java.lang.Object</B></TD> </TR> <TR BGCOLOR="white" ID="TableRowColor"> <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait</CODE></TD> </TR> </TABLE> &nbsp; <P> <A NAME="constructor_detail"></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" ID="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Constructor Detail</B></FONT></TD> </TR> </TABLE> <A NAME="Ins_dup2(ojvm.loading.instructions.<API key>)"></A><H3> Ins_dup2</H3> <PRE> public <B>Ins_dup2</B>(<A HREF="../../../ojvm/loading/instructions/<API key>.html"><API key></A>&nbsp;classFile)</PRE> <DL> </DL> <A NAME="method_detail"></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" ID="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Method Detail</B></FONT></TD> </TR> </TABLE> <A NAME="accept(ojvm.operations.InstructionVisitor)"></A><H3> accept</H3> <PRE> public void <B>accept</B>(<A HREF="../../../ojvm/operations/InstructionVisitor.html">InstructionVisitor</A>&nbsp;iv) throws <A HREF="../../../ojvm/data/JavaException.html">JavaException</A></PRE> <DL> <DD><DL> <DT><B>Overrides:</B><DD><A HREF="../../../ojvm/loading/instructions/Instruction.html#accept(ojvm.operations.InstructionVisitor)">accept</A> in class <A HREF="../../../ojvm/loading/instructions/Instruction.html">Instruction</A></DL> </DD> </DL> <HR> <A NAME="toString()"></A><H3> toString</H3> <PRE> public java.lang.String <B>toString</B>()</PRE> <DL> <DD><DL> <DT><B>Overrides:</B><DD>toString in class java.lang.Object</DL> </DD> </DL> <HR> <A NAME="navbar_bottom"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A NAME="<API key>"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" ID="NavBarCell1Rev"> &nbsp;<FONT ID="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../ojvm/loading/instructions/Ins_dup_x2.html"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../ojvm/loading/instructions/Ins_dup2_x1.html"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Ins_dup2.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> </TR> <TR> <TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2"> SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#<API key>.loading.instructions.Instruction">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2"> DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <HR> </BODY> </HTML>
#!/usr/bin/perl =head1 NAME TMI pokal_sent.pl =head1 SYNOPSIS TBD =head1 AUTHOR admin@socapro.com =head1 CHANGELOG 2015-06-09 Thomas: Added Session Management =head1 COPYRIGHT Copyright (c) 2015, SocaPro Inc. Created 2015-06-09 =cut use lib '/tmapp/tmsrc/cgi-bin/'; use TMSession; my $session = TMSession::getSession(tmi_login => 1); my $trainer = $session->getUser(); my $leut = $trainer; use CGI; print "Content-type: text/html\n\n"; $query = new CGI; $url = $query->param('url'); $tip[1] = $query->param('30....'); $tip[2] = $query->param('31....'); $tip[3] = $query->param('32....'); $tip[4] = $query->param('33....'); $tip[5] = $query->param('34....'); $tip[6] = $query->param('35....'); $tip[7] = $query->param('36....'); $tip[8] = $query->param('37....'); $tip[9] = $query->param('38....'); $tip[10] = $query->param('39....'); $tips = $query->param('tips'); $pokal = $query->param('pokal'); open(D7,"/tmdata/tmi/pokal/tip_status.txt"); $tip_status = <D7> ; chomp $tip_status; close(D7); if ( $tip_status != 1 ) { print "<title>Pokal Tipabgabe</title><font face=verdana size=2><br><br><br><br><br><b>Die Tipabgabefrist ist bereits abgelaufen ...\n"; exit ; } print "Content-type: text/html\n\n"; print "<title>Pokal Tipabgabe</title><body bgcolor=white text=black>\n"; print "<form name=Testform action=/cgi-mod/tmi/login.pl method=post></form>"; print "<script language=JavaScript>"; print" function AbGehts()"; print" {"; print" document.Testform.submit();"; print" }"; print" window.setTimeout(\"AbGehts()\",7000);"; print" </script>"; print "<p align=left><body bgcolor=white text=black link=darkred link=darkred>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n"; require "/tmapp/tmsrc/cgi-bin/tag.pl" ; $agb = 0; for ($x=1 ; $x<=10 ; $x++ ) { if ( $tip[$x] ne "0&0" ) { $abg++ } $reihe = $reihe . $tip[$x] . '.' ; } if ( $abg != $tips ) { print "<font face=verdana size=2><br><br><br><br><br><b>Die Anzahl Ihrer abgegebenen Tips ist nicht korrekt ...<br>Sie haben $abg Tips anstatt der korrekten $tips Tips abgegeben .<br>Bitte kehren Sie zur Tipabgabe zurueck und korregieren Sie Ihre Tipabgabe .\n"; exit ; } $rf ="0"; $rx = "x" ; my $liga = 0; if ( $liga > 9 ) { $rf = "" } $suche = '&'.$trainer.'&' ; $s = 0; open(D2,"/tmdata/tmi/history.txt"); while(<D2>) { $s++; if ($_ =~ /$suche/) { @lor = split (/&/, $_); $liga = $s ; } } close(D2); $id_verein = 0; $y = 0; for ( $x = 1; $x < 19; $x++ ) { $y++; chomp $lor[$y]; $data[$x] = $lor[$y]; $teams[$x] = $lor[$y]; $team[$x] = $lor[$y]; $y++; chomp $lor[$y]; $datb[$x] = $lor[$y]; if ( $datb[$x] eq $trainer ) {$id = $x } if ( $datb[$x] eq $trainer ) {$id_verein = (($liga-1)*18)+ $x } if ( $datb[$x] eq $trainer ) {$verein = $data[$x] } $y++; chomp $lor[$y]; $datc[$x] = $lor[$y]; if ( $datb[$x] eq $trainer ) {$recipient = $datc[$x] } } $rr = 0; $li=0; $liga=0; open(D2,"/tmdata/tmi/history.txt"); while(<D2>) { $li++; @vereine = split (/&/, $_); $y = 0; for ( $x = 1; $x < 19; $x++ ) { $rr++; $y++; chomp $verein[$y]; $teams[$rr] = $vereine[$y]; $team[$rr] = $vereine[$y]; $y++; chomp $verein[$y]; $datb[$rr] = $vereine[$y]; $y++; chomp $verein[$y]; $datc[$rr] = $vereine[$y]; } } close(D2); my $url = "/tmdata/tmi/pokal/tips/" ; if ( $id_verein<10 ) { $url = $url . '0' } if ( $id_verein<100 ) { $url = $url . '0' } if ( $id_verein<1000 ) { $url = $url . '0' } open(D7,"/tmdata/tmi/pokal/pokal_datum.txt"); $spielrunde_ersatz = <D7> ; chomp $spielrunde_ersatz; close(D7); $runde = $spielrunde_ersatz; $url=$url.$id_verein. '-' . $pokal . '-' . $runde . '.txt' ; open(D2,">$url"); print D2 "$reihe\n"; close (D2) ; print "<font face=verdana size=2><br><br><br><b>&nbsp;&nbsp;Ihre Tipabgabe wurde registriert .<br>&nbsp;&nbsp;Sie werden zu Ihrem LogIn Bereich weitergeleitet ...\n";
#include "utils/fuzzer.h" #ifdef USE_FUZZER #include "client.h" #include "logger.h" #include "settings.h" #include "utils/stringutils.h" #include "debug.h" namespace { Logger *fuzz = nullptr; int fuzzRand = 50; } // namespace void Fuzzer::init() { fuzz = new Logger; fuzz->setLogFile(settings.localDataDir + "/fuzzer.log"); unsigned int sr = time(nullptr); fuzz->log("Srand: %u", sr); srand(sr); } bool Fuzzer::conditionTerminate(const char *const name) { if ((rand() % 100) <= fuzzRand) { fuzz->log("deleted: %s", name); return true; } fuzz->log("passed: %s", name); return false; } #endif
<?php /** * HTML attribute filters. * Most of these functions filter the generic values from the framework found in hoot/functions/attr.php * Attributes for non-generic structural elements (mostly theme specific) can be loaded in this file. * * @package hoot * @subpackage responsive-brix * @since responsive-brix 1.0 */ /* Modify Original Filters from Framework */ add_filter( 'hoot_attr_content', '<API key>' ); add_filter( 'hoot_attr_sidebar', '<API key>', 10, 2 ); /* New Theme Filters */ add_filter( '<API key>', '<API key>' ); add_filter( '<API key>', '<API key>', 10, 2 ); /* Misc Filters */ add_filter( '<API key>', '<API key>', 10, 2 ); /** * Modify Main content container of the page attributes. * * @since 1.0 * @access public * @param array $attr * @return array */ function <API key>( $attr ) { $layout_class = <API key>( 'content' ); if ( !empty( $layout_class ) ) { if ( isset( $attr['class'] ) ) $attr['class'] .= ' ' . $layout_class; else $attr['class'] = $layout_class; } return $attr; } /** * Modify Sidebar attributes. * * @since 1.0 * @access public * @param array $attr * @param string $context * @return array */ function <API key>( $attr, $context ) { if ( !empty( $context ) && $context == 'primary' ) { $layout_class = <API key>( 'primary-sidebar' ); if ( !empty( $layout_class ) ) { if ( isset( $attr['class'] ) ) $attr['class'] .= ' ' . $layout_class; else $attr['class'] = $layout_class; } } return $attr; } /** * Page wrapper attributes. * * @since 1.0 * @access public * @param array $attr * @return array */ function <API key>( $attr ) { $site_layout = hoot_get_mod( 'site_layout' ); $attr['class'] = ( $site_layout == 'boxed' ) ? 'grid site-boxed' : 'site-stretch'; $attr['class'] .= ' page-wrapper'; return $attr; } /** * Main content container of the page attributes when a page template is being displayed * * @since 1.0 * @access public * @param array $attr * @param string $context * @return array */ function <API key>( $attr, $context ) { if ( is_page_template() && $context == 'none' ) { $attr['id'] = 'content'; $attr['class'] = 'content sidebar-none'; $attr['role'] = 'main'; $attr['itemprop'] = 'mainContentOfPage'; $template_slug = basename( get_page_template(), '.php' ); $attr['class'] .= ' ' . sanitize_html_class( 'content-' . $template_slug ); } elseif ( function_exists( 'hoot_attr_content' ) ) { // Get page attributes for main content container of a non-template regular page $attr = apply_filters( "hoot_attr_content", $attr, $context ); } return $attr; } /** * Social Icons Widget - Icons * * @since 2.0 * @access public * @param array $attr * @param string $context * @return array */ function <API key>( $attr, $context ) { $attr['class'] = 'social-icons-icon'; if ( $context != 'email' ) $attr['target'] = '_blank'; return $attr; }
var iconhead={ title:"Icon Heading Shortcode", id :'<API key>', pluginName: 'iconhead', setRowColors:false }; (function() { <API key>(iconhead,800); })(); function <API key>(pluginObj){ if(jQuery(pluginObj.hashId).length){ jQuery(pluginObj.hashId).remove(); } // creates a form to be displayed everytime the button is clicked // you should achieve this using AJAX instead of direct html code like this var iconhead_fa=''; /*if(ebs.ebs_fa_inclusion==1){ iconhead_fa='<h4>Font Awesome</h4><ul name="<API key>" class="<API key>">'+ebsfaicons+'</ul>'; }*/ iconhead_fa='<h4>Font Awesome</h4><ul name="<API key>" class="<API key>">'+ebsfaicons+'</ul>'; // creates a form to be displayed everytime the button is clicked // you should achieve this using AJAX instead of direct html code like this var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="gallery-table" class="form-table">\ <tr>\ <th><label for="<API key>">Select Icon:</label></th>\ <td><div id="click_icon_list" class="oscitas-icon-div"><span id="osc_show_icon"></span><span class="show-drop"></span></div><input type="hidden" id="<API key>" value=""><input type="hidden" id="<API key>" value="">\ <div id="osc_show_iconlist" class="oscitas-icon" style="display:none;width:100%"><h4>Glyphicons</h4><ul name="<API key>" class="<API key>">'+ebsicons+'</ul>'+iconhead_fa+'</div>\ </td>\ </tr>\ <tr>\ <th><label for="<API key>">Icon Color:</label></th>\ <td><input type="text" name="label" id="<API key>" class="color" value="" /><br />\ </td>\ </tr>\ <tr>\ <th><label for="<API key>">Heading Type:</label></th>\ <td><select name="<API key>" id="<API key>">\ <option value="h1">H1</option>\ <option value="h2">H2</option>\ <option value="h3">H3</option>\ <option value="h4">H4</option>\ <option value="h5">H5</option>\ <option value="h6">H6</option>\ </select><br />\ </td>\ </tr>\ <tr>\ <th><label for="<API key>">Heading:</label></th>\ <td><input type="text" name="<API key>" id="<API key>" value="Heading"/><br />\ </td>\ </tr>\ <tr>\ <th><label for="<API key>">Custom Class:</label></th>\ <td><input type="text" name="line" id="<API key>" value=""/><br />\ </td>\ </tr>\ </table>\ <p class="submit">\ <input type="button" id="<API key>" class="button-primary" value="Insert Icon Heading" name="submit" />\ </p>\ </div>'); var table = form.find('table'); jQuery('.glyphicon').css('display','inline'); form.appendTo('body').hide(); form.find('.color').wpColorPicker(); table.find('#click_icon_list').click(function(){ if(!jQuery(this).hasClass('osc_icon_showing')){ jQuery(this).addClass('osc_icon_showing') table.find('#osc_show_iconlist').show(); } else{ jQuery(this).removeClass('osc_icon_showing') table.find('#osc_show_iconlist').hide(); } }); table.find('.<API key> li').click(function(){ var val=jQuery(this).attr('data-value'); var type=jQuery(this).attr('type'); table.find('.<API key> li').removeClass('osc_icon_selected'); jQuery(this).addClass('osc_icon_selected'); table.find('#click_icon_list').removeClass('osc_icon_showing'); table.find('#osc_show_iconlist').hide(); table.find('#osc_show_icon').removeClass().addClass(type).addClass(val); table.find('#<API key>').val(val); table.find('#<API key>').val(type); }); // // handles the click event of the submit button form.find('#<API key>').click(function() { // defines the options and their default values // again, this is not the most elegant way to do this // but well, this gets the job done nonetheless var type=jQuery('#<API key>').val(); var cusclass='',style=''; if(table.find('#<API key>').val()!=''){ style=' style="' + table.find('#<API key>').val()+'"' ; } if(table.find('#<API key>').val()!=''){ style+=' icontype="' + table.find('#<API key>').val()+'"' ; } if(table.find('#<API key>').val()!=''){ cusclass+= ' color="'+table.find('#<API key>').val()+'"'; } if(table.find('#<API key>').val()!=''){ cusclass+= ' class="'+table.find('#<API key>').val()+'"'; } var shortcode = '[iconheading type="'+type+'"'; shortcode += style+cusclass ; shortcode += ']'+table.find('#<API key>').val()+'[/iconheading]' ; // inserts the shortcode into the active editor tinyMCE.activeEditor.execCommand('mceInsertContent',0 , shortcode); // closes Dialoguebox close_dialogue(pluginObj.hashId); }); }
using System; using System.Threading.Tasks; using System.Windows.Threading; using Disp = System.Windows.Threading.Dispatcher; using Op = System.Windows.Threading.DispatcherOperation; using DO = System.Windows.Threading.DispatcherObject; using static System.Array; namespace AphidUI { public static class <API key> { public static void Invoke(this Disp dispatcher, Action action) => dispatcher.Invoke(action, Empty<object>()); public static void Sync(this Disp dispatcher, Action action) => dispatcher.Invoke(action, Empty<object>()); public static Op BeginInvoke(this Disp dispatcher, Action action, params object[] args) => dispatcher.BeginInvoke(action, args); public static Op Async(this Disp dispatcher, Action action, params object[] args) => dispatcher.BeginInvoke(action, args); public static Task Run(this Disp dispatcher, Action action, params object[] args) => dispatcher.BeginInvoke(action, args).Task; public static TResult Invoke<TResult>(this Disp dispatcher, Func<TResult> action) => (TResult)dispatcher.Invoke(action, Empty<object>()); public static TResult Sync<TResult>(this Disp dispatcher, Func<TResult> action) => (TResult)dispatcher.Invoke(action, Empty<object>()); public static Op BeginInvoke(this DO @do, Action action, params object[] args) => @do.Dispatcher.BeginInvoke(action, args); public static Op Async(this DO @do, Action action, params object[] args) => @do.Dispatcher.BeginInvoke(action, args); public static Task Run(this DO @do, Action action, params object[] args) => @do.BeginInvoke(action, args).Task; public static Task Run<TArg>(this DO @do, Action<TArg> action, TArg arg0) => @do.Dispatcher.BeginInvoke(action, new object[] { arg0 }).Task; public static void Invoke(this DO @do, Action action) => @do.Dispatcher.Invoke(action, Empty<object>()); public static void Sync(this DO @do, Action action) => @do.Dispatcher.Invoke(action, Empty<object>()); public static TResult Invoke<TResult>(this DO @do, Func<TResult> action) => (TResult)@do.Dispatcher.Invoke(action, Empty<object>()); public static TResult Sync<TResult>(this DO @do, Func<TResult> action) => (TResult)@do.Dispatcher.Invoke(action, Empty<object>()); public static <API key> DisableProcessing(this DO @do) => @do.Dispatcher.DisableProcessing(); } }
<?php /** * @desc Modify from component Media Manager of Joomla * */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die( 'Restricted access' ); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); /** * Weblinks Weblink Controller * * @package Joomla * @subpackage Weblinks * @since 1.5 */ class <API key> extends <API key> { /** * Upload a file * * @since 1.5 */ function upload() { global $mainframe; // Check for request forgeries JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); $file = JRequest::getVar( 'Filedata', '', 'files', 'array' ); $folder = JRequest::getVar( 'folder', '', '', 'path' ); $format = JRequest::getVar( 'format', 'html', '', 'cmd'); $return = JRequest::getVar( 'return-url', null, 'post', 'base64' ); $err = null; // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::<API key>('ftp'); // Make the filename safe jimport('joomla.filesystem.file'); $file['name'] = JFile::makeSafe($file['name']); if (isset($file['name'])) { $filepath = JPath::clean(<API key>.DS.$folder.DS.strtolower($file['name'])); if (!RepoHelper::canUpload( $file, $err )) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'Invalid: '.$filepath.': '.$err)); header('HTTP/1.0 415 Unsupported Media Type'); jexit('Error. Unsupported Media Type!'); } else { JError::raiseNotice(100, JText::_($err)); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } if (JFile::exists($filepath)) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'File already exists: '.$filepath)); header('HTTP/1.0 409 Conflict'); jexit('Error. File already exists'); } else { JError::raiseNotice(100, JText::_('Error. File already exists')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } if (!JFile::upload($file['tmp_name'], $filepath)) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'Cannot upload: '.$filepath)); header('HTTP/1.0 400 Bad Request'); jexit('Error. Unable to upload file'); } else { JError::raiseWarning(100, JText::_('Error. Unable to upload file')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } else { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance(); $log->addEntry(array('comment' => $folder)); jexit('Upload complete'); } else { $mainframe->enqueueMessage(JText::_('Upload complete')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } } else { $mainframe->redirect('index.php', 'Invalid Request', 'error'); } } /** * Deletes paths from the current path * * @param string $listFolder The image directory to delete a file from * @since 1.5 */ function delete() { global $mainframe; JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::<API key>('ftp'); // Get some data from the request $tmpl = JRequest::getCmd( 'tmpl' ); $paths = JRequest::getVar( 'rm', array(), '', 'array' ); $folder = JRequest::getVar( 'folder', '', '', 'path'); // Initialize variables $msg = array(); $ret = true; if (count($paths)) { foreach ($paths as $path) { if ($path !== JFile::makeSafe($path)) { JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path, ENT_COMPAT, 'UTF-8').' '.JText::_('WARNFILENAME')); continue; } $fullPath = JPath::clean(<API key>.DS.$folder.DS.$path); if (is_file($fullPath)) { $ret |= !JFile::delete($fullPath); } else if (is_dir($fullPath)) { $files = JFolder::files($fullPath, '.', true); $canDelete = true; foreach ($files as $file) { if ($file != 'index.html') { $canDelete = false; } } if ($canDelete) { $ret |= !JFolder::delete($fullPath); } else { //allow remove folder not empty on local repository $ret2 = JFolder::delete($fullPath); $ret |= !$ret2; if($ret2 == false) { JError::raiseWarning(100, JText::_('Unable to delete:').$fullPath); } } } } } if ($ret) { JError::raiseNotice(200, JText::_('Successfully delete a seleted item(s).')); } if ($tmpl == 'component') { // We are inside the iframe $mainframe->redirect('index.php?option='.JACOMPONENT.'&view=repolist&folder='.$folder.'&tmpl=component'); } else { $mainframe->redirect('index.php?option='.JACOMPONENT.'&view=repolist&folder='.$folder); } } function download() { global $mainframe; JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::<API key>('ftp'); // Get some data from the request $tmpl = JRequest::getCmd( 'tmpl' ); $paths = JRequest::getVar( 'rm', array(), '', 'array' ); $folder = JRequest::getVar( 'folder', '', '', 'path'); // Initialize variables $msg = array(); $ret = true; if (count($paths)) { foreach ($paths as $path) { $fullPath = JPath::clean(<API key>.DS.$folder.DS.$path); if(is_file($fullPath) && JFile::getExt($fullPath) == 'zip') { // Set headers header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$fullPath"); header("Content-Type: application/zip"); header("<API key>: binary"); // Read the file from disk readfile($fullPath); exit(); } } } if ($tmpl == 'component') { // We are inside the iframe $mainframe->redirect('index.php?option='.JACOMPONENT.'&view=repolist&folder='.$folder.'&tmpl=component'); } else { $mainframe->redirect('index.php?option='.JACOMPONENT.'&view=repolist&folder='.$folder); } } }
# Rshell A simple command shell designed by Trevor Smith and Chianh Wu. ## What it does (currently) This shell will handle standard command line programs and their arguments. Similarly, these commands can be linked with `&&`,`||`, or `;`. We are orking on adding precidence via parentheses. The shell itself will also handle comments starting with the `#` symbol. There is also a built in function that will test if a file or directory exits, and can be executed via `test` with flags `-e` to check existance, `-f` to check for a regular file, and `-d` to check if it is a directory. Also, `test` can be represented as `[]` (e.g. `test -e /home/user/` = `[ -e /home/user/ ]`); note also that this is white space sensetive `[-e /home/user/]` will not work. ## How to Run - `$ git clone https://github.com/tsmit019/rshell.git` - `$ cd rshell` - `$ git checkout hw4` - `$ make` - `$ bin/rshell` ## If you want to run test - `$ git clone https://github.com/tsmit019/rshell.git` - `$ cd rshell` - `$ git checkout hw4` - `$ make` - `$ cd tests` From here you can chose any of the `.sh` and run them. Make sure they are executable by checking using `ls -l`. If they are not executable, then type `chmod 711 *.sh` to make all the `.sh` files executable. ## Bugs Input redirection and output redirection work most of the time except for when they are the first set of commands (e.g. `cat < test.txt` will through an out of range. I have looked for the reason for a while and have not been able to identify why). But, if you use the redirects after a connector (e.g. `echo hhallllllllu && cat < test` or `ls -al; echo why does this not work > sad.txt`) then it works perfectly fine. Same for piping. I don't quite know. Nested redirects dont quite work as intended e.g. `cat < test.txt > test_clone.txt` will not write to test_clone.txt but just execute the `cat < test.txt`. If you give a command that is parenthese, connector, then command (e.g. `(echo a && echo b) || echo c`) you get a out of range error that I was not able to resolve. Similarly, any connector directly after a closing parenthese will cause this behavior and I am unsure why. I will try and fix this by the next release. Similarly, commands with connectors right after each other will through a similar out of range error. E.g `echo a && ||` will give you out of range.
name: Feature request about: Please consider reporting directly to https://github.com/magento/community-features <! Important: This repository is intended only for Magento 2 Technical Issues. Enter Feature Requests at https://github.com/magento/community-features. Project stakeholders monitor and manage requests. Feature requests entered using this form may be moved to the forum. Fields marked with (*) are required. Please don't remove the template. Description (*) <!--- Describe the feature you would like to add. --> Expected behavior (*) <!--- What is the expected behavior of this feature? How is it going to work? --> Benefits <!--- How do you think this feature would improve Magento? --> Additional information <!--- What other information can you provide about the desired feature? -->
<!DOCTYPE html> <html> <h1>muppets_mug5</h1> <p> BOLD: 2/2 correct and 0/2false</p> <p> SIFT: 0/2 correct and 2/2false</p><br> <img src = "../../../BVD_M01/muppets_mug/muppets_mug5.jpg" alt = "muppets_mug5.html" style= " width:320px;height:240px;"> <h1> Falsely compared to: </h1><br> <img src = "../../../" alt = "" style= " width:320px;height:240px;"> <img src = "../../../" alt = "" style= " width:320px;height:240px;"> </html>
#ifndef <API key> #define <API key> #ifdef __cplusplus extern "C" { #endif /** The format of images that may be loaded (force_channels). SOIL_LOAD_AUTO leaves the image in whatever format it was found. SOIL_LOAD_L forces the image to load as Luminous (greyscale) SOIL_LOAD_LA forces the image to load as Luminous with Alpha SOIL_LOAD_RGB forces the image to load as Red Green Blue SOIL_LOAD_RGBA forces the image to load as Red Green Blue Alpha **/ enum { SOIL_LOAD_AUTO = 0, SOIL_LOAD_L = 1, SOIL_LOAD_LA = 2, SOIL_LOAD_RGB = 3, SOIL_LOAD_RGBA = 4 }; /** Passed in as reuse_texture_ID, will cause SOIL to register a new texture ID using glGenTextures(). If the value passed into reuse_texture_ID > 0 then SOIL will just re-use that texture ID (great for reloading image assets in-game!) **/ enum { SOIL_CREATE_NEW_ID = 0 }; /** flags you can pass into <API key>() and <API key>(). (note that if <API key> is used the rest of the flags with the exception of <API key> will be ignored while loading already-compressed DDS files.) <API key>: force the image to be POT SOIL_FLAG_MIPMAPS: generate mipmaps for the texture <API key>: otherwise will clamp <API key>: for using (GL_ONE,<API key>) blending SOIL_FLAG_INVERT_Y: flip the image vertically <API key>: if the card can display them, will convert RGB to DXT1, RGBA to DXT5 <API key>: will load DDS files directly without _ANY_ additional processing <API key>: clamps RGB components to the range [16,235] SOIL_FLAG_CoCg_Y: Google YCoCg; RGB=>CoYCg, RGBA=>CoCgAY <API key>: uses <API key> ; pixel indexed & no repeat or MIPmaps or cubemaps **/ enum { <API key> = 1, SOIL_FLAG_MIPMAPS = 2, <API key> = 4, <API key> = 8, SOIL_FLAG_INVERT_Y = 16, <API key> = 32, <API key> = 64, <API key> = 128, SOIL_FLAG_CoCg_Y = 256, <API key> = 512 }; /** The types of images that may be saved. (TGA supports uncompressed RGB / RGBA) (BMP supports uncompressed RGB) (DDS supports DXT1 and DXT5) **/ enum { SOIL_SAVE_TYPE_TGA = 0, SOIL_SAVE_TYPE_BMP = 1, SOIL_SAVE_TYPE_DDS = 2 }; /** Defines the order of faces in a DDS cubemap. I recommend that you use the same order in single image cubemap files, so they will be interchangeable with DDS cubemaps when using SOIL. **/ #define <API key> "EWUDNS" /** The types of internal fake HDR representations SOIL_HDR_RGBE: RGB * pow( 2.0, A - 128.0 ) SOIL_HDR_RGBdivA: RGB / A SOIL_HDR_RGBdivA2: RGB / (A*A) **/ enum { SOIL_HDR_RGBE = 0, SOIL_HDR_RGBdivA = 1, SOIL_HDR_RGBdivA2 = 2 }; /** Loads an image from disk into an OpenGL texture. \param filename the name of the file to upload as a texture \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const char *filename, int force_channels, unsigned int reuse_texture_ID, unsigned int flags ); /** Loads 6 images from disk into an OpenGL cubemap texture. \param x_pos_file the name of the file to upload as the +x cube face \param x_neg_file the name of the file to upload as the -x cube face \param y_pos_file the name of the file to upload as the +y cube face \param y_neg_file the name of the file to upload as the -y cube face \param z_pos_file the name of the file to upload as the +z cube face \param z_neg_file the name of the file to upload as the -z cube face \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const char *x_pos_file, const char *x_neg_file, const char *y_pos_file, const char *y_neg_file, const char *z_pos_file, const char *z_neg_file, int force_channels, unsigned int reuse_texture_ID, unsigned int flags ); /** Loads 1 image from disk and splits it into an OpenGL cubemap texture. \param filename the name of the file to upload as a texture \param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc. \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const char *filename, const char face_order[6], int force_channels, unsigned int reuse_texture_ID, unsigned int flags ); /** Loads an HDR image from disk into an OpenGL texture. \param filename the name of the file to upload as a texture \param fake_HDR_format SOIL_HDR_RGBE, SOIL_HDR_RGBdivA, SOIL_HDR_RGBdivA2 \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const char *filename, int fake_HDR_format, int rescale_to_max, unsigned int reuse_texture_ID, unsigned int flags ); /** Loads an image from RAM into an OpenGL texture. \param buffer the image data in RAM just as if it were still in a file \param buffer_length the size of the buffer in bytes \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> | <API key> \param width \param height \param channels \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const unsigned char *const buffer, int buffer_length, int force_channels, unsigned int reuse_texture_ID, unsigned int flags, int *width, int *height, int *channels ); /** Loads an image from RAM into an OpenGL texture. \param buffer the image data in RAM just as if it were still in a file \param buffer_length the size of the buffer in bytes \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const unsigned char *const buffer, int buffer_length, int force_channels, unsigned int reuse_texture_ID, unsigned int flags ); /** Loads 6 images from memory into an OpenGL cubemap texture. \param x_pos_buffer the image data in RAM to upload as the +x cube face \param x_pos_buffer_length the size of the above buffer \param x_neg_buffer the image data in RAM to upload as the +x cube face \param x_neg_buffer_length the size of the above buffer \param y_pos_buffer the image data in RAM to upload as the +x cube face \param y_pos_buffer_length the size of the above buffer \param y_neg_buffer the image data in RAM to upload as the +x cube face \param y_neg_buffer_length the size of the above buffer \param z_pos_buffer the image data in RAM to upload as the +x cube face \param z_pos_buffer_length the size of the above buffer \param z_neg_buffer the image data in RAM to upload as the +x cube face \param z_neg_buffer_length the size of the above buffer \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const unsigned char *const x_pos_buffer, int x_pos_buffer_length, const unsigned char *const x_neg_buffer, int x_neg_buffer_length, const unsigned char *const y_pos_buffer, int y_pos_buffer_length, const unsigned char *const y_neg_buffer, int y_neg_buffer_length, const unsigned char *const z_pos_buffer, int z_pos_buffer_length, const unsigned char *const z_neg_buffer, int z_neg_buffer_length, int force_channels, unsigned int reuse_texture_ID, unsigned int flags ); /** Loads 1 image from RAM and splits it into an OpenGL cubemap texture. \param buffer the image data in RAM just as if it were still in a file \param buffer_length the size of the buffer in bytes \param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc. \param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const unsigned char *const buffer, int buffer_length, const char face_order[6], int force_channels, unsigned int reuse_texture_ID, unsigned int flags ); /** Creates a 2D OpenGL texture from raw image data. Note that the raw data is _NOT_ freed after the upload (so the user can load various versions). \param data the raw data to be uploaded as an OpenGL texture \param width the width of the image in pixels \param height the height of the image in pixels \param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const unsigned char *const data, int width, int height, int channels, unsigned int reuse_texture_ID, unsigned int flags ); /** Creates an OpenGL cubemap texture by splitting up 1 image into 6 parts. \param data the raw data to be uploaded as an OpenGL texture \param width the width of the image in pixels \param height the height of the image in pixels \param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA \param face_order the order of the faces in the file, and combination of NSWEUD, for North, South, Up, etc. \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture) \param flags can be any of <API key> | SOIL_FLAG_MIPMAPS | <API key> | <API key> | SOIL_FLAG_INVERT_Y | <API key> | <API key> \return 0-failed, otherwise returns the OpenGL texture handle **/ unsigned int <API key> ( const unsigned char *const data, int width, int height, int channels, const char face_order[6], unsigned int reuse_texture_ID, unsigned int flags ); /** Captures the OpenGL window (RGB) and saves it to disk \return 0 if it failed, otherwise returns 1 **/ int <API key> ( const char *filename, int image_type, int x, int y, int width, int height ); /** Loads an image from disk into an array of unsigned chars. Note that *channels return the original channel count of the image. If force_channels was other than SOIL_LOAD_AUTO, the resulting image has force_channels, but *channels may be different (if the original image had a different channel count). \return 0 if failed, otherwise returns 1 **/ unsigned char* SOIL_load_image ( const char *filename, int *width, int *height, int *channels, int force_channels ); /** Loads an image from memory into an array of unsigned chars. Note that *channels return the original channel count of the image. If force_channels was other than SOIL_LOAD_AUTO, the resulting image has force_channels, but *channels may be different (if the original image had a different channel count). \return 0 if failed, otherwise returns 1 **/ unsigned char* <API key> ( const unsigned char *const buffer, int buffer_length, int *width, int *height, int *channels, int force_channels ); /** Saves an image from an array of unsigned chars (RGBA) to disk \return 0 if failed, otherwise returns 1 **/ int SOIL_save_image ( const char *filename, int image_type, int width, int height, int channels, const unsigned char *const data ); /** Frees the image data (note, this is just C's "free()"...this function is present mostly so C++ programmers don't forget to use "free()" and call "delete []" instead [8^) **/ void <API key> ( unsigned char *img_data ); /** This function resturn a pointer to a string describing the last thing that happened inside SOIL. It can be used to determine why an image failed to load. **/ const char* SOIL_last_result ( void ); #ifdef __cplusplus } #endif #endif /* <API key> */
/* Framework */ html { height: 100%; } body { margin: 0; padding: 0; display: block !important; height: 100%; min-height: 740px; overflow-x: hidden; overflow-y: auto; background: rgb(215, 215, 215); background: -o-radial-gradient(rgb(240, 240, 240), rgb(190, 190, 190)); background: -moz-radial-gradient(rgb(240, 240, 240), rgb(190, 190, 190)); background: -<API key>(rgb(240, 240, 240), rgb(190, 190, 190)); background: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 500, from(rgb(240, 240, 240)), to(rgb(190, 190, 190))); -<API key>: antialiased; } .slides { width: 100%; height: 100%; left: 0; top: 0; position: absolute; -webkit-transform: translate3d(0, 0, 0); } .slides > article { display: block; position: absolute; overflow: hidden; width: 900px; height: 700px; left: 50%; top: 50%; margin-left: -450px; margin-top: -350px; padding: 40px 60px; box-sizing: border-box; -o-box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; border-radius: 10px; -o-border-radius: 10px; -moz-border-radius: 10px; -<API key>: 10px; background-color: white; box-shadow: 0 2px 6px rgba(0, 0, 0, .1); border: 1px solid rgba(0, 0, 0, .3); transition: transform .3s ease-out; -o-transition: -o-transform .3s ease-out; -moz-transition: -moz-transform .3s ease-out; -webkit-transition: -webkit-transform .3s ease-out; } .slides.layout-widescreen > article { margin-left: -550px; width: 1100px; } .slides.<API key> > article { margin-left: -550px; width: 1100px; padding: 40px 160px; } .slides.template-default > article:not(.nobackground):not(.biglogo) { background: url(images/google-logo-small.jpg) 710px 625px no-repeat; background-color: white; } .slides.template-io2011 > article:not(.nobackground):not(.biglogo) { background: url(images/colorbar.png) 0 600px repeat-x, url(images/googleio-logo.jpg) 640px 625px no-repeat; background-size: 100%, 225px; background-color: white; } .slides.layout-widescreen > article:not(.nobackground):not(.biglogo), .slides.<API key> > article:not(.nobackground):not(.biglogo) { <API key>: 0, 840px; } /* Clickable/tappable areas */ .slide-area { z-index: 1000; position: absolute; left: 0; top: 0; width: 150px; height: 700px; left: 50%; top: 50%; cursor: pointer; margin-top: -350px; tap-highlight-color: transparent; -<API key>: transparent; -<API key>: transparent; -<API key>: transparent; } #prev-slide-area { margin-left: -550px; } #next-slide-area { margin-left: 400px; } .slides.layout-widescreen #prev-slide-area, .slides.<API key> #prev-slide-area { margin-left: -650px; } .slides.layout-widescreen #next-slide-area, .slides.<API key> #next-slide-area { margin-left: 500px; } /* Slide styles */ .slides.template-default article.biglogo { background: white url(images/google-logo.jpg) 50% 50% no-repeat; } .slides.template-io2011 article.biglogo { background: white url(images/googleio-logo.jpg) 50% 50% no-repeat; background-size: 600px; } /* Slides */ .slides > article { display: none; } .slides > article.far-past { display: block; transform: translate(-2040px); -o-transform: translate(-2040px); -moz-transform: translate(-2040px); -webkit-transform: translate3d(-2040px, 0, 0); } .slides > article.past { display: block; transform: translate(-1020px); -o-transform: translate(-1020px); -moz-transform: translate(-1020px); -webkit-transform: translate3d(-1020px, 0, 0); } .slides > article.current { display: block; transform: translate(0); -o-transform: translate(0); -moz-transform: translate(0); -webkit-transform: translate3d(0, 0, 0); } .slides > article.next { display: block; transform: translate(1020px); -o-transform: translate(1020px); -moz-transform: translate(1020px); -webkit-transform: translate3d(1020px, 0, 0); } .slides > article.far-next { display: block; transform: translate(2040px); -o-transform: translate(2040px); -moz-transform: translate(2040px); -webkit-transform: translate3d(2040px, 0, 0); } .slides.layout-widescreen > article.far-past, .slides.<API key> > article.far-past { display: block; transform: translate(-2260px); -o-transform: translate(-2260px); -moz-transform: translate(-2260px); -webkit-transform: translate3d(-2260px, 0, 0); } .slides.layout-widescreen > article.past, .slides.<API key> > article.past { display: block; transform: translate(-1130px); -o-transform: translate(-1130px); -moz-transform: translate(-1130px); -webkit-transform: translate3d(-1130px, 0, 0); } .slides.layout-widescreen > article.current, .slides.<API key> > article.current { display: block; transform: translate(0); -o-transform: translate(0); -moz-transform: translate(0); -webkit-transform: translate3d(0, 0, 0); } .slides.layout-widescreen > article.next, .slides.<API key> > article.next { display: block; transform: translate(1130px); -o-transform: translate(1130px); -moz-transform: translate(1130px); -webkit-transform: translate3d(1130px, 0, 0); } .slides.layout-widescreen > article.far-next, .slides.<API key> > article.far-next { display: block; transform: translate(2260px); -o-transform: translate(2260px); -moz-transform: translate(2260px); -webkit-transform: translate3d(2260px, 0, 0); } /* Styles for slides */ .slides > article { font-family: 'Open Sans', Arial, sans-serif; color: rgb(102, 102, 102); text-shadow: 0 1px 1px rgba(0, 0, 0, .1); font-size: 30px; line-height: 36px; letter-spacing: -1px; } b { font-weight: 600; } .blue { color: rgb(0, 102, 204); } .yellow { color: rgb(255, 211, 25); } .green { color: rgb(0, 138, 53); } .red { color: rgb(255, 0, 0); } .black { color: black; } .white { color: white; } a { color: rgb(0, 102, 204); } a:visited { color: rgba(0, 102, 204, .75); } a:hover { color: black; } p { margin: 0; padding: 0; margin-top: 20px; } p:first-child { margin-top: 0; } h1 { font-size: 60px; line-height: 60px; padding: 0; margin: 0; margin-top: 200px; padding-right: 40px; font-weight: 600; letter-spacing: -3px; color: rgb(51, 51, 51); } h2 { font-size: 45px; line-height: 45px; position: absolute; bottom: 150px; padding: 0; margin: 0; padding-right: 40px; font-weight: 600; letter-spacing: -2px; color: rgb(51, 51, 51); } h3 { font-size: 30px; line-height: 36px; padding: 0; margin: 0; padding-right: 40px; font-weight: 600; letter-spacing: -1px; color: rgb(51, 51, 51); } article.fill h3 { background: rgba(0, 0, 0, .35); padding-top: .2em; padding-bottom: .3em; margin-top: -.2em; margin-left: -60px; padding-left: 60px; margin-right: -60px; padding-right: 60px; } ul { list-style: none; margin: 0; padding: 0; margin-top: 40px; margin-left: .75em; } ul:first-child { margin-top: 0; } ul ul { margin-top: .5em; } li { padding: 0; margin: 0; margin-bottom: .5em; } li::before { content: '·'; width: .75em; margin-left: -.75em; position: absolute; } pre { font-family: 'Droid Sans Mono', 'Courier New', monospace; font-size: 20px; line-height: 28px; padding: 5px 10px; letter-spacing: -1px; margin-top: 40px; margin-bottom: 40px; color: black; background: rgb(240, 240, 240); border: 1px solid rgb(224, 224, 224); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .1); overflow: hidden; } code { font-size: 95%; font-family: 'Droid Sans Mono', 'Courier New', monospace; color: black; } iframe { width: 100%; height: 620px; background: white; border: 1px solid rgb(192, 192, 192); margin: -1px; /*box-shadow: inset 0 2px 6px rgba(0, 0, 0, .1);*/ } h3 + iframe { margin-top: 40px; height: 540px; } article.fill iframe { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border: 0; margin: 0; border-radius: 10px; -o-border-radius: 10px; -moz-border-radius: 10px; -<API key>: 10px; z-index: -1; } article.fill img { position: absolute; left: 0; top: 0; min-width: 100%; min-height: 100%; border-radius: 10px; -o-border-radius: 10px; -moz-border-radius: 10px; -<API key>: 10px; z-index: -1; } img.centered { margin: 0 auto; display: block; } table { width: 100%; border-collapse: collapse; margin-top: 40px; } th { font-weight: 600; text-align: left; } td, th { border: 1px solid rgb(224, 224, 224); padding: 5px 10px; vertical-align: top; } .source { position: absolute; left: 60px; top: 644px; padding-right: 175px; font-size: 15px; letter-spacing: 0; line-height: 18px; } q { display: block; font-size: 60px; line-height: 72px; margin-left: 20px; margin-top: 100px; margin-right: 150px; } q::before { content: '“'; position: absolute; display: inline-block; margin-left: -2.1em; width: 2em; text-align: right; font-size: 90px; color: rgb(192, 192, 192); } q::after { content: '”'; position: absolute; margin-left: .1em; font-size: 90px; color: rgb(192, 192, 192); } div.author { text-align: right; font-size: 40px; margin-top: 20px; margin-right: 150px; } div.author::before { content: '—'; } /* Size variants */ article.smaller p, article.smaller ul { font-size: 20px; line-height: 24px; letter-spacing: 0; } article.smaller table { font-size: 20px; line-height: 24px; letter-spacing: 0; } article.smaller pre { font-size: 15px; line-height: 20px; letter-spacing: 0; } article.smaller q { font-size: 40px; line-height: 48px; } article.smaller q::before, article.smaller q::after { font-size: 60px; } /* Builds */ .build > * { transition: opacity 0.5s ease-in-out 0.2s; -o-transition: opacity 0.5s ease-in-out 0.2s; -moz-transition: opacity 0.5s ease-in-out 0.2s; -webkit-transition: opacity 0.5s ease-in-out 0.2s; } .to-build { opacity: 0; } /* Pretty print */ .prettyprint .str, /* string content */ .prettyprint .atv { /* a markup attribute value */ color: rgb(0, 138, 53); } .prettyprint .kwd, /* a keyword */ .prettyprint .tag { /* a markup tag name */ color: rgb(0, 102, 204); } .prettyprint .com { /* a comment */ color: rgb(127, 127, 127); font-style: italic; } .prettyprint .lit { /* a literal value */ color: rgb(127, 0, 0); } .prettyprint .pun, /* punctuation, lisp open bracket, lisp close bracket */ .prettyprint .opn, .prettyprint .clo { color: rgb(127, 127, 127); } .prettyprint .typ, /* a type name */ .prettyprint .atn, /* a markup attribute name */ .prettyprint .dec, .prettyprint .var { /* a declaration; a variable name */ color: rgb(127, 0, 127); } .mylogo{ width: 200px; height: 80px; background: white; position: absolute; bottom: 0; right: 0; }
/* Linux PINMUX.C */ #include <asm/arch/am_regs.h> #include <asm/arch/am_eth_reg.h> #include <asm/arch/pinmux.h> int clear_mio_mux(unsigned mux_index, unsigned mux_mask) { unsigned mux_reg[] = {PERIPHS_PIN_MUX_0, PERIPHS_PIN_MUX_1, PERIPHS_PIN_MUX_2,PERIPHS_PIN_MUX_3, PERIPHS_PIN_MUX_4,PERIPHS_PIN_MUX_5,PERIPHS_PIN_MUX_6,PERIPHS_PIN_MUX_7,PERIPHS_PIN_MUX_8, PERIPHS_PIN_MUX_9,PERIPHS_PIN_MUX_10,PERIPHS_PIN_MUX_11,PERIPHS_PIN_MUX_12}; if (mux_index < 13) { CLEAR_CBUS_REG_MASK(mux_reg[mux_index], mux_mask); return 0; } return -1; } int set_mio_mux(unsigned mux_index, unsigned mux_mask) { unsigned mux_reg[] = {PERIPHS_PIN_MUX_0, PERIPHS_PIN_MUX_1, PERIPHS_PIN_MUX_2,PERIPHS_PIN_MUX_3, PERIPHS_PIN_MUX_4,PERIPHS_PIN_MUX_5,PERIPHS_PIN_MUX_6,PERIPHS_PIN_MUX_7,PERIPHS_PIN_MUX_8, PERIPHS_PIN_MUX_9,PERIPHS_PIN_MUX_10,PERIPHS_PIN_MUX_11,PERIPHS_PIN_MUX_12}; if (mux_index < 13) { SET_CBUS_REG_MASK(mux_reg[mux_index], mux_mask); return 0; } return -1; } /* call it before pinmux init; call it before soft reset; */ void clearall_pinmux(void) { int i; for(i=0;i<13;i++) clear_mio_mux(i,0xffffffff); return; } /*ETH PINMUX SETTING More details can get from am_eth_pinmux.h */ int eth_set_pinmux(int bank_id,int clk_in_out_id,unsigned long ext_msk) { int ret=0; switch(bank_id) { case <API key>: if(ext_msk>0) set_mio_mux(ETH_BANK0_REG1,ext_msk); else set_mio_mux(ETH_BANK0_REG1,ETH_BANK0_REG1_VAL); break; case <API key>: if(ext_msk>0) set_mio_mux(ETH_BANK1_REG1,ext_msk); else set_mio_mux(ETH_BANK1_REG1,ETH_BANK1_REG1_VAL); break; default: printf("UNknow pinmux setting of ethernet!error bankid=%d,must be 0-2\n",bank_id); ret=-1; } switch(clk_in_out_id) { case <API key>: set_mio_mux(3,1<<11); break; case <API key>: set_mio_mux(3,1); break; case <API key>: set_mio_mux(3,1<<24); break; case <API key>: set_mio_mux(3,1<<13); break; case <API key>: set_mio_mux(3,1<<12); break; case <API key>: set_mio_mux(3,1<<1); break; case <API key>: set_mio_mux(3,1<<25); break; case <API key>: set_mio_mux(3,1<<14); break; default: printf("UNknow clk_in_out_id setting of ethernet!error clk_in_out_id=%d,must be 0-7\n",clk_in_out_id); ret=-1; } return ret; }
<?php // no direct access defined('_JEXEC') or die; /** * @package Joomla.Site * @subpackage mod_stats * @since 1.5 */ class modStatsHelper { static function &getList(&$params) { $app = JFactory::getApplication(); $db = JFactory::getDbo(); $rows = array(); $query = $db->getQuery(true); $serverinfo = $params->get('serverinfo'); $siteinfo = $params->get('siteinfo'); $counter = $params->get('counter'); $increase = $params->get('increase'); $i = 0; if ($serverinfo) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_OS'); $rows[$i]->data = substr(php_uname(), 0, 7); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_PHP'); $rows[$i]->data = phpversion(); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_MYSQL'); $rows[$i]->data = $db->getVersion(); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JTEXT::_('MOD_STATS_TIME'); $rows[$i]->data = JHTML::_('date','now', 'H:i'); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_CACHING'); $rows[$i]->data = $app->getCfg('caching') ? JText::_('JENABLED'):JText::_('JDISABLED'); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_GZIP'); $rows[$i]->data = $app->getCfg('gzip') ? JText::_('JENABLED'):JText::_('JDISABLED'); $i++; } if ($siteinfo) { $query->select('COUNT(id) AS count_users'); $query->from('#__users'); $db->setQuery($query); $users = $db->loadResult(); $query->clear(); $query->select('COUNT(id) AS count_items'); $query->from('#__content'); $query->where('state = 1'); $db->setQuery($query); $items = $db->loadResult(); $query->clear(); $query->select('COUNT(id) AS count_links '); $query->from('#__weblinks'); $query->where('state = 1'); $db->setQuery($query); $links = $db->loadResult(); if ($users) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_USERS'); $rows[$i]->data = $users; $i++; } if ($items) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_ARTICLES'); $rows[$i]->data = $items; $i++; } if ($links) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_WEBLINKS'); $rows[$i]->data = $links; $i++; } } if ($counter) { $query->clear(); $query->select('SUM(hits) AS count_hits'); $query->from('#__content'); $query->where('state = 1'); $db->setQuery($query); $hits = $db->loadResult(); if ($hits) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('<API key>'); $rows[$i]->data = $hits + $increase; $i++; } } return $rows; } }
<!DOCTYPE HTML PUBLIC "- <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_55) on Sun Feb 15 12:26:30 PST 2015 --> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"> <title>Uses of Class org.apache.solr.handler.component.HttpShardHandler (Solr 5.0.0 API)</title> <meta name="date" content="2015-02-15"> <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><! if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class org.apache.solr.handler.component.HttpShardHandler (Solr 5.0.0 API)"; } </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <div class="topNav"><a name="navbar_top"> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../../org/apache/solr/handler/component/HttpShardHandler.html" title="class in org.apache.solr.handler.component">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?org/apache/solr/handler/component/class-use/HttpShardHandler.html" target="_top">Frames</a></li> <li><a href="HttpShardHandler.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <a name="skip-navbar_top"> </a></div> <div class="header"> <h2 title="Uses of Class org.apache.solr.handler.component.HttpShardHandler" class="title">Uses of Class<br>org.apache.solr.handler.component.HttpShardHandler</h2> </div> <div class="classUseContainer">No usage of org.apache.solr.handler.component.HttpShardHandler</div> <div class="bottomNav"><a name="navbar_bottom"> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="<API key>"> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../../org/apache/solr/handler/component/HttpShardHandler.html" title="class in org.apache.solr.handler.component">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?org/apache/solr/handler/component/class-use/HttpShardHandler.html" target="_top">Frames</a></li> <li><a href="HttpShardHandler.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <a name="skip-navbar_bottom"> </a></div> <p class="legalCopy"><small> <i>Copyright &copy; 2000-2015 Apache Software Foundation. All Rights Reserved.</i> <script src='../../../../../../prettify.js' type='text/javascript'></script> <script type='text/javascript'> (function(){ var oldonload = window.onload; if (typeof oldonload != 'function') { window.onload = prettyPrint; } else { window.onload = function() { oldonload(); prettyPrint(); } } })(); </script> </small></p> </body> </html>
#include "config.h" #include "hwcompat.h" #include "kernel.h" #include "lcd.h" #include "system.h" /*** definitions ***/ #define <API key> ((char)0x00) #define <API key> ((char)0x10) #define <API key> ((char)0x20) #define <API key> ((char)0x28) #define <API key> ((char)0x40) #define <API key> ((char)0x81) #define <API key> ((char)0xA0) #define LCD_SET_LCD_BIAS ((char)0xA2) #define <API key> ((char)0xA4) #define <API key> ((char)0xA5) #define <API key> ((char)0xA6) #define <API key> ((char)0xA7) #define <API key> ((char)0xA8) #define LCD_SET_BIAS_TC_OSC ((char)0xA9) #define <API key> ((char)0xAA) #define <API key> ((char)0xAC) #define <API key> ((char)0xAD) #define LCD_SET_DISPLAY_OFF ((char)0xAE) #define LCD_SET_DISPLAY_ON ((char)0xAF) #define <API key> ((char)0xB0) #define <API key> ((char)0xC0) #define <API key> ((char)0xD2) #define <API key> ((char)0xD3) #define <API key> ((char)0xE0) #define LCD_SOFTWARE_RESET ((char)0xE2) #define LCD_NOP ((char)0xE3) #define <API key> ((char)0xEE) /* LCD command codes */ #define LCD_CNTL_RESET 0xe2 /* Software reset */ #define LCD_CNTL_POWER 0x2f /* Power control */ #define LCD_CNTL_CONTRAST 0x81 /* Contrast */ #define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */ #define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */ #define LCD_CNTL_DISPON 0xaf /* Display on */ #define LCD_CNTL_PAGE 0xb0 /* Page address */ #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ /** globals **/ static int xoffset; /* needed for flip */ /*** hardware configuration ***/ int <API key>(void) { return (HW_MASK & LCD_CONTRAST_BIAS) ? 31 : 49; } void lcd_set_contrast(int val) { lcd_write_command(LCD_CNTL_CONTRAST); lcd_write_command(val); } void <API key>(bool yesno) { if (yesno) lcd_write_command(<API key>); else lcd_write_command(<API key>); } /* turn the display upside down (call lcd_update() afterwards) */ void lcd_set_flip(bool yesno) { #ifdef <API key> if (!yesno) #else if (yesno) #endif { lcd_write_command(<API key>); lcd_write_command(<API key>); xoffset = 132 - LCD_WIDTH; /* 132 colums minus the 112 we have */ } else { lcd_write_command(<API key> | 0x01); lcd_write_command(<API key> | 0x08); xoffset = 0; } } void lcd_init_device(void) { /* Initialize PB0-3 as output pins */ PBCR2 &= 0xff00; /* MD = 00 */ PBIOR |= 0x000f; /* IOR = 1 */ /* inits like the original firmware */ lcd_write_command(LCD_SOFTWARE_RESET); lcd_write_command(<API key> + 4); lcd_write_command(<API key> + 0); /* force 1/4 bias: 0 */ lcd_write_command(<API key> + 7); /* power control register: op-amp=1, regulator=1, booster=1 */ lcd_write_command(LCD_SET_DISPLAY_ON); lcd_write_command(<API key>); lcd_set_flip(false); lcd_write_command(<API key> + 0); lcd_set_contrast(<API key>()); lcd_write_command(<API key>); lcd_write_command(<API key> + 0); lcd_write_command(<API key> + 0); lcd_clear_display(); lcd_update(); } /*** Update functions ***/ /* Performance function that works with an external buffer note that by and bheight are in 8-pixel units! */ void lcd_blit_mono(const unsigned char *data, int x, int by, int width, int bheight, int stride) { /* Copy display bitmap to hardware */ while (bheight { lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf)); lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); lcd_write_data(data, width); data += stride; } } /* Helper function for lcd_grey_phase_blit(). */ void lcd_grey_data(unsigned char *values, unsigned char *phases, int count); /* Performance function that works with an external buffer note that by and bheight are in 8-pixel units! */ void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, int x, int by, int width, int bheight, int stride) { stride <<= 3; /* 8 pixels per block */ while (bheight { lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf)); lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); lcd_grey_data(values, phases, width); values += stride; phases += stride; } } /* Update the display. This must be called after all other LCD functions that change the display. */ void lcd_update(void) { int y; /* Copy display bitmap to hardware */ for (y = 0; y < LCD_FBHEIGHT; y++) { lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); lcd_write_command (LCD_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf)); lcd_write_command (LCD_CNTL_LOWCOL | (xoffset & 0xf)); lcd_write_data (FBADDR(0, y), LCD_WIDTH); } } /* Update a fraction of the display. */ void lcd_update_rect(int x, int y, int width, int height) { int ymax; /* The Y coordinates have to work on even 8 pixel rows */ ymax = (y + height-1) >> 3; y >>= 3; if(x + width > LCD_WIDTH) width = LCD_WIDTH - x; if (width <= 0) return; /* nothing left to do, 0 is harmful to lcd_write_data() */ if(ymax >= LCD_FBHEIGHT) ymax = LCD_FBHEIGHT-1; /* Copy specified rectange bitmap to hardware */ for (; y <= ymax; y++) { lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset) >> 4) & 0xf)); lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); lcd_write_data (FBADDR(x,y), width); } }
// <auto-generated> // This code was generated from a template. // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // </auto-generated> namespace XORCISMModel { using System; using System.Collections.Generic; public partial class PERIMETER { public int PerimeterID { get; set; } } }
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package pt.jkaiui.core.messages; import java.util.regex.Matcher; import java.util.regex.Pattern; import pt.jkaiui.core.KaiString; import pt.jkaiui.manager.I_InMessage; /** * * @author yuu@akron */ public class ConnectedArena extends Message implements I_InMessage { public ConnectedArena() { } public Message parse(String s) { Pattern p = Pattern.compile("<API key>;"); Matcher m = p.matcher(s); if (m.matches()){ ConnectedArena msg = new ConnectedArena(); return msg; } return null; } }
#ifndef NO_OGL //OpenGL library #pragma comment( lib, "OpenGL32" ) // MFC #include "stdafx.h" //GUI #include "MainWnd.h" #include "FullscreenSettings.h" // Internals #include "../System.h" #include "../gba/GBA.h" #include "../gba/Globals.h" #include "../Util.h" #include "../gb/gbGlobals.h" #include "../common/memgzio.h" //Math #include <cmath> #include <sys/stat.h> // OpenGL #include <gl/GL.h> // main include file #include <GL/glu.h> #include "glFont.h" #include <gl/glext.h> typedef BOOL (APIENTRY *<API key>)( int ); extern int Init_2xSaI(u32); extern void winlog(const char *,...); extern int systemSpeed; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #ifdef MMX extern "C" bool cpu_mmx; extern bool detectMMX(); #endif class OpenGLDisplay : public IDisplay { private: HDC hDC; HGLRC hRC; GLuint texture; int width,height; float size; u8 *filterData; RECT destRect; bool failed; GLFONT font; int pitch; u8 *data; DWORD currentAdapter; void initializeMatrices( int w, int h ); bool initializeTexture( int w, int h ); void updateFiltering( int value ); void setVSync( int interval = 1 ); void calculateDestRect( int w, int h ); void initializeFont(); public: OpenGLDisplay(); virtual ~OpenGLDisplay(); virtual DISPLAY_TYPE getType() { return OPENGL; }; virtual void EnableOpenGL(); virtual void DisableOpenGL(); virtual bool initialize(); virtual void cleanup(); virtual void clear(); virtual void render(); virtual bool changeRenderSize( int w, int h ); virtual void resize( int w, int h ); virtual void setOption( const char *, int ); virtual bool <API key>( VIDEO_MODE &mode ); }; #include "gzglfont.h" //Load GL font void OpenGLDisplay::initializeFont() { int ret; z_stream strm; char *buf = (char *)malloc(GZGLFONT_SIZE); /* allocate inflate state */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.avail_in = 0; strm.next_in = Z_NULL; ret = inflateInit2(&strm, 16+MAX_WBITS); if (ret != Z_OK) return; strm.avail_in = sizeof(gzglfont); strm.next_in = gzglfont; strm.avail_out = GZGLFONT_SIZE; strm.next_out = (Bytef *)buf; ret = inflate(&strm, Z_NO_FLUSH); if (ret==Z_STREAM_END) { glGenTextures( 1, &texture ); glFontCreate(&font, (char *)buf, texture); texture=0; } free(buf); (void)inflateEnd(&strm); } //OpenGL class constructor OpenGLDisplay::OpenGLDisplay() { hDC = NULL; hRC = NULL; texture = 0; width = 0; height = 0; size = 0.0f; failed = false; filterData = NULL; currentAdapter = 0; } //OpenGL class destroyer OpenGLDisplay::~OpenGLDisplay() { cleanup(); } //Set OpenGL PFD and contexts void OpenGLDisplay::EnableOpenGL() { <API key> pfd; // get the device context (DC) hDC = GetDC( theApp.m_pMainWnd->GetSafeHwnd() ); // set the pixel format for the DC ZeroMemory( &pfd, sizeof( pfd ) ); pfd.nSize = sizeof( pfd ); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; SetPixelFormat (GetDC (theApp.m_pMainWnd->GetSafeHwnd()), ChoosePixelFormat ( GetDC (theApp.m_pMainWnd->GetSafeHwnd()), &pfd), &pfd); wglMakeCurrent (GetDC (theApp.m_pMainWnd->GetSafeHwnd()), wglCreateContext(GetDC (theApp.m_pMainWnd->GetSafeHwnd()) ) ); } //Remove contexts void OpenGLDisplay::DisableOpenGL() { wglMakeCurrent( NULL, NULL ); wglDeleteContext( hRC ); ReleaseDC( theApp.m_pMainWnd->GetSafeHwnd(), hDC ); } //Remove resources used void OpenGLDisplay::cleanup() { if(texture != 0) { glDeleteTextures(1, &texture); texture = 0; } DisableOpenGL(); if(filterData) { free(filterData); filterData = NULL; } width = 0; height = 0; size = 0.0f; DISPLAY_DEVICE dev; ZeroMemory( &dev, sizeof(dev) ); dev.cb = sizeof(dev); EnumDisplayDevices( NULL, currentAdapter, &dev, 0 ); // restore default video mode <API key>( dev.DeviceName, NULL, NULL, 0, NULL ); } //init renderer bool OpenGLDisplay::initialize() { switch( theApp.cartridgeType ) { case IMAGE_GBA: theApp.sizeX = 240; theApp.sizeY = 160; break; case IMAGE_GB: if ( gbBorderOn ) { theApp.sizeX = 256; theApp.sizeY = 224; } else { theApp.sizeX = 160; theApp.sizeY = 144; } break; } switch(theApp.videoOption) { case VIDEO_1X: theApp.surfaceSizeX = theApp.sizeX; theApp.surfaceSizeY = theApp.sizeY; break; case VIDEO_2X: theApp.surfaceSizeX = theApp.sizeX * 2; theApp.surfaceSizeY = theApp.sizeY * 2; break; case VIDEO_3X: theApp.surfaceSizeX = theApp.sizeX * 3; theApp.surfaceSizeY = theApp.sizeY * 3; break; case VIDEO_4X: theApp.surfaceSizeX = theApp.sizeX * 4; theApp.surfaceSizeY = theApp.sizeY * 4; break; case VIDEO_5X: theApp.surfaceSizeX = theApp.sizeX * 5; theApp.surfaceSizeY = theApp.sizeY * 5; break; case VIDEO_6X: theApp.surfaceSizeX = theApp.sizeX * 6; theApp.surfaceSizeY = theApp.sizeY * 6; break; case VIDEO_320x240: case VIDEO_640x480: case VIDEO_800x600: case VIDEO_1024x768: case VIDEO_1280x1024: case VIDEO_OTHER: { if( theApp.fullScreenStretch ) { theApp.surfaceSizeX = theApp.fsWidth; theApp.surfaceSizeY = theApp.fsHeight; } else { float scaleX = (float)theApp.fsWidth / (float)theApp.sizeX; float scaleY = (float)theApp.fsHeight / (float)theApp.sizeY; float min = ( scaleX < scaleY ) ? scaleX : scaleY; if( theApp.maxScale ) min = ( min > (float)theApp.maxScale ) ? (float)theApp.maxScale : min; theApp.surfaceSizeX = (int)((float)theApp.sizeX * min); theApp.surfaceSizeY = (int)((float)theApp.sizeY * min); } } break; } theApp.rect.left = 0; theApp.rect.top = 0; theApp.rect.right = theApp.sizeX; theApp.rect.bottom = theApp.sizeY; theApp.dest.left = 0; theApp.dest.top = 0; theApp.dest.right = theApp.surfaceSizeX; theApp.dest.bottom = theApp.surfaceSizeY; DWORD style = WS_POPUP | WS_VISIBLE; DWORD styleEx = 0; if( theApp.videoOption <= VIDEO_6X ) style |= WS_OVERLAPPEDWINDOW; else styleEx = 0; if( theApp.videoOption <= VIDEO_6X ) AdjustWindowRectEx( &theApp.dest, style, TRUE, styleEx ); else AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx ); int winSizeX = theApp.dest.right - theApp.dest.left; int winSizeY = theApp.dest.bottom - theApp.dest.top; int x = 0, y = 0; if( theApp.videoOption <= VIDEO_6X ) { x = theApp.windowPositionX; y = theApp.windowPositionY; } else { winSizeX = theApp.fsWidth; winSizeY = theApp.fsHeight; } theApp.updateMenuBar(); theApp.adjustDestRect(); currentAdapter = theApp.fsAdapter; DISPLAY_DEVICE dev; ZeroMemory( &dev, sizeof(dev) ); dev.cb = sizeof(dev); EnumDisplayDevices( NULL, currentAdapter, &dev, 0 ); if( theApp.videoOption >= VIDEO_320x240 ) { // enter full screen mode DEVMODE mode; ZeroMemory( &mode, sizeof(mode) ); mode.dmSize = sizeof(mode); mode.dmBitsPerPel = theApp.fsColorDepth; mode.dmPelsWidth = theApp.fsWidth; mode.dmPelsHeight = theApp.fsHeight; mode.dmDisplayFrequency = theApp.fsFrequency; mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; LONG ret = <API key>( dev.DeviceName, &mode, NULL, CDS_FULLSCREEN, NULL ); if( ret != <API key> ) { systemMessage( 0, "Can not change display mode!" ); failed = true; } } else { // restore default mode <API key>( dev.DeviceName, NULL, NULL, 0, NULL ); } EnableOpenGL(); initializeFont(); glPushAttrib( GL_ENABLE_BIT ); glDisable( GL_DEPTH_TEST ); glDisable( GL_CULL_FACE ); glEnable( GL_TEXTURE_2D ); glEnable(GL_BLEND); glBlendFunc(GL_ONE, <API key>); initializeMatrices( theApp.surfaceSizeX, theApp.surfaceSizeY ); setVSync( theApp.vsync ); #ifdef MMX if(!theApp.disableMMX) cpu_mmx = theApp.detectMMX(); else cpu_mmx = 0; #endif systemRedShift = 3; systemGreenShift = 11; systemBlueShift = 19; systemColorDepth = 32; theApp.fsColorDepth = 32; Init_2xSaI(32); <API key>(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1); theApp.updateFilter(); theApp.updateIFB(); pitch = theApp.filterWidth * (systemColorDepth>>3) + 4; data = pix + ( theApp.sizeX + 1 ) * 4; if(failed) return false; return true; } //clear colour buffer void OpenGLDisplay::clear() { glClearColor(0.0,0.0,0.0,1.0); glClear( GL_COLOR_BUFFER_BIT ); } //main render func void OpenGLDisplay::render() { clear(); pitch = theApp.filterWidth * (systemColorDepth>>3) + 4; data = pix + ( theApp.sizeX + 1 ) * 4; // apply pixel filter if(theApp.filterFunction) { data = filterData; theApp.filterFunction( pix + pitch, pitch, (u8*)theApp.delta, (u8*)filterData, width * 4 , theApp.filterWidth, theApp.filterHeight); } // Texturemap complete texture to surface // so we have free scaling and antialiasing if( theApp.filterFunction ) { glPixelStorei( <API key>, width); } else { glPixelStorei( <API key>, theApp.sizeX + 1 ); } glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,data ); glBegin( GL_QUADS ); glTexCoord2f( 0.0f, 0.0f ); glVertex3i( 0, 0, 0 ); glTexCoord2f( (float)(width) / size, 0.0f ); glVertex3i( theApp.surfaceSizeX, 0, 0 ); glTexCoord2f( (float)(width) / size, (float)(height) / size ); glVertex3i( theApp.surfaceSizeX, theApp.surfaceSizeY, 0 ); glTexCoord2f( 0.0f, (float)(height) / size ); glVertex3i( 0, theApp.surfaceSizeY, 0 ); glEnd(); if( theApp.showSpeed ) { // && ( theApp.videoOption > VIDEO_6X ) ) { char buffer[30]; if( theApp.showSpeed == 1 ) { sprintf( buffer, "%3d%%", systemSpeed ); } else { sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, theApp.showRenderedFrames ); } glFontBegin(&font); glPushMatrix(); float fontscale = (float)theApp.surfaceSizeX / 100.0f; glScalef(fontscale, fontscale, fontscale); glColor4f(1.0f, 0.25f, 0.25f, 1.0f); glFontTextOut(buffer, (theApp.surfaceSizeX-(strlen(buffer)*11))/(fontscale*2), (theApp.surfaceSizeY-20)/fontscale, 0); glPopMatrix(); glFontEnd(); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glBindTexture( GL_TEXTURE_2D, texture ); } if( theApp.screenMessage ) { if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !theApp.<API key> ) { glFontBegin(&font); glPushMatrix(); float fontscale = (float)theApp.surfaceSizeX / 100.0f; glScalef(fontscale, fontscale, fontscale); glColor4f(1.0f, 0.25f, 0.25f, 1.0f); glFontTextOut((char *)((const char *)theApp.screenMessageBuffer), (theApp.surfaceSizeX-(theApp.screenMessageBuffer.GetLength()*11))/(fontscale*2), (theApp.surfaceSizeY-40)/fontscale, 0); glPopMatrix(); glFontEnd(); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glBindTexture( GL_TEXTURE_2D, texture ); } else { theApp.screenMessage = false; } } glFlush(); SwapBuffers( hDC ); // since OpenGL draws on the back buffer, // we have to swap it to the front buffer to see the content } //resize screen void OpenGLDisplay::resize( int w, int h ) { initializeMatrices( w, h ); } //update filtering methods void OpenGLDisplay::updateFiltering( int value ) { switch( value ) { case 0: glTexParameteri(GL_TEXTURE_2D, <API key>, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, <API key>, GL_NEAREST); break; case 1: glTexParameteri(GL_TEXTURE_2D, <API key>, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, <API key>, GL_LINEAR); break; } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); } //init projection matrixes and viewports void OpenGLDisplay::initializeMatrices( int w, int h ) { if( theApp.fullScreenStretch ) { glViewport( 0, 0, w, h ); } else { calculateDestRect( w, h ); glViewport( destRect.left, destRect.top, destRect.right - destRect.left, destRect.bottom - destRect.top ); } glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( /* left */ 1.0f, /* right */ (GLdouble)(w - 1), /* bottom */ (GLdouble)(h - 1), /* top */ 1.0f, 0.0f, 1.0f ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } //init font texture bool OpenGLDisplay::initializeTexture( int w, int h ) { // size = 2^n // w = 24 > size = 256 = 2^8 // w = 255 > size = 256 = 2^8 // w = 256 > size = 512 = 2^9 // w = 300 > size = 512 = 2^9 // OpenGL textures have to be square and a power of 2 // We could use methods that allow tex's to not be powers of two // but that requires extra OGL extensions float n1 = log10( (float)w ) / log10( 2.0f ); float n2 = log10( (float)h ) / log10( 2.0f ); float n = ( n1 > n2 ) ? n1 : n2; if( ((float)((int)n)) != n ) { // round up n = ((float)((int)n)) + 1.0f; } size = pow( 2.0f, n ); glGenTextures( 1, &texture ); glBindTexture( GL_TEXTURE_2D, texture ); updateFiltering( theApp.glFilter ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)size, (GLsizei)size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL ); width = w; height = h; //return ( glGetError() == GL_NO_ERROR) ? true : false; // Workaround: We usually get GL_INVALID_VALUE, but somehow it works nevertheless // In consequence, we must not treat it as an error or else the app behaves as if an error occured. // This in the end results in theApp->input not being created = no input when switching from D3D to OGL return true; } //turn vsync on or off void OpenGLDisplay::setVSync( int interval ) { const char *extensions = (const char *)glGetString( GL_EXTENSIONS ); if( strstr( extensions, "<API key>" ) == 0 ) { winlog( "Error: <API key> extension not supported on your computer.\n" ); return; } else { <API key> wglSwapIntervalEXT = NULL; wglSwapIntervalEXT = (<API key>)wglGetProcAddress( "wglSwapIntervalEXT" ); if( wglSwapIntervalEXT ) { wglSwapIntervalEXT( interval ); } } } //change render size for fonts and filter data bool OpenGLDisplay::changeRenderSize( int w, int h ) { if( (width != w) || (height != h) ) { if( texture != 0 ) { glDeleteTextures( 1, &texture ); texture = 0; } if( !initializeTexture( w, h ) ) { failed = true; return false; } if (filterData) free(filterData); filterData = (u8 *)malloc(4*w*h); } return true; } //calculate RECTs void OpenGLDisplay::calculateDestRect( int w, int h ) { float scaleX = (float)w / (float)width; float scaleY = (float)h / (float)height; float min = (scaleX < scaleY) ? scaleX : scaleY; if( theApp.maxScale && (min > theApp.maxScale) ) { min = (float)theApp.maxScale; } destRect.left = 0; destRect.top = 0; destRect.right = (LONG)(width * min); destRect.bottom = (LONG)(height * min); if( destRect.right != w ) { LONG diff = (w - destRect.right) / 2; destRect.left += diff; destRect.right += diff; } if( destRect.bottom != h ) { LONG diff = (h - destRect.bottom) / 2; destRect.top += diff; destRect.bottom += diff; } } //config options void OpenGLDisplay::setOption( const char *option, int value ) { if( !_tcscmp( option, _T("vsync") ) ) { setVSync( value ); } if( !_tcscmp( option, _T("glFilter") ) ) { updateFiltering( value ); } if( !_tcscmp( option, _T("maxScale") ) ) { initializeMatrices( theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top ); } if( !_tcscmp( option, _T("fullScreenStretch") ) ) { initializeMatrices( theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top ); } } //set fullscreen mode bool OpenGLDisplay::<API key>( VIDEO_MODE &mode ) { FullscreenSettings dlg; dlg.setAPI( this->getType() ); INT_PTR ret = dlg.DoModal(); if( ret == IDOK ) { mode.adapter = dlg.m_device; switch( dlg.m_colorDepth ) { case 30: // TODO: support return false; break; case 24: mode.bitDepth = 32; break; case 16: case 15: mode.bitDepth = 16; break; } mode.width = dlg.m_width; mode.height = dlg.m_height; mode.frequency = dlg.m_refreshRate; return true; } else { return false; } } IDisplay *newOpenGLDisplay() { return new OpenGLDisplay(); } #endif // #ifndef NO_OGL
#ifndef WOLF_CRYPT_ASN_H #define WOLF_CRYPT_ASN_H #include <wolfssl/wolfcrypt/types.h> #ifndef NO_ASN #include <wolfssl/wolfcrypt/integer.h> #ifndef NO_RSA #include <wolfssl/wolfcrypt/rsa.h> #endif /* fips declare of RsaPrivateKeyDecode @wc_fips */ #if defined(HAVE_FIPS) && !defined(NO_RSA) #include <cyassl/ctaocrypt/rsa.h> #endif #ifndef NO_DH #include <wolfssl/wolfcrypt/dh.h> #endif #ifndef NO_DSA #include <wolfssl/wolfcrypt/dsa.h> #endif #ifndef NO_SHA #include <wolfssl/wolfcrypt/sha.h> #endif #ifndef NO_MD5 #include <wolfssl/wolfcrypt/md5.h> #endif #include <wolfssl/wolfcrypt/sha256.h> #include <wolfssl/wolfcrypt/asn_public.h> /* public interface */ #ifdef HAVE_ECC #include <wolfssl/wolfcrypt/ecc.h> #endif #ifdef __cplusplus extern "C" { #endif enum { ISSUER = 0, SUBJECT = 1, <API key> = 32, BEFORE = 0, AFTER = 1 }; /* ASN Tags */ enum ASN_Tags { ASN_BOOLEAN = 0x01, ASN_INTEGER = 0x02, ASN_BIT_STRING = 0x03, ASN_OCTET_STRING = 0x04, ASN_TAG_NULL = 0x05, ASN_OBJECT_ID = 0x06, ASN_ENUMERATED = 0x0a, ASN_UTF8STRING = 0x0c, ASN_SEQUENCE = 0x10, ASN_SET = 0x11, ASN_UTC_TIME = 0x17, ASN_OTHER_TYPE = 0x00, ASN_RFC822_TYPE = 0x01, ASN_DNS_TYPE = 0x02, ASN_DIR_TYPE = 0x04, <API key> = 0x18, CRL_EXTENSIONS = 0xa0, ASN_EXTENSIONS = 0xa3, ASN_LONG_LENGTH = 0x80 }; enum ASN_Flags{ ASN_CONSTRUCTED = 0x20, <API key> = 0x80 }; enum DN_Tags { ASN_COMMON_NAME = 0x03, ASN_SUR_NAME = 0x04, ASN_SERIAL_NUMBER = 0x05, /* serialNumber */ ASN_COUNTRY_NAME = 0x06, ASN_LOCALITY_NAME = 0x07, ASN_STATE_NAME = 0x08, ASN_ORG_NAME = 0x0a, ASN_ORGUNIT_NAME = 0x0b }; enum PBES { PBE_MD5_DES = 0, PBE_SHA1_DES = 1, PBE_SHA1_DES3 = 2, PBE_SHA1_RC4_128 = 3, PBES2 = 13 /* algo ID */ }; enum ENCRYPTION_TYPES { DES_TYPE = 0, DES3_TYPE = 1, RC4_TYPE = 2 }; enum ECC_TYPES { ECC_PREFIX_0 = 160, ECC_PREFIX_1 = 161 }; enum Misc_ASN { ASN_NAME_MAX = 256, MAX_SALT_SIZE = 64, /* MAX PKCS Salt length */ MAX_IV_SIZE = 64, /* MAX PKCS Iv length */ MAX_KEY_SIZE = 64, /* MAX PKCS Key length */ PKCS5 = 5, /* PKCS oid tag */ PKCS5v2 = 6, /* PKCS #5 v2.0 */ PKCS12 = 12, /* PKCS #12 */ MAX_UNICODE_SZ = 256, ASN_BOOL_SIZE = 2, /* including type */ ASN_ECC_HEADER_SZ = 2, /* String type + 1 byte len */ ASN_ECC_CONTEXT_SZ = 2, /* Content specific type + 1 byte len */ #ifdef NO_SHA KEYID_SIZE = SHA256_DIGEST_SIZE, #else KEYID_SIZE = SHA_DIGEST_SIZE, #endif RSA_INTS = 8, /* RSA ints in private key */ DSA_INTS = 5, /* DSA ints in private key */ MIN_DATE_SIZE = 13, MAX_DATE_SIZE = 32, ASN_GEN_TIME_SZ = 15, /* 7 numbers * 2 + Zulu tag */ MAX_ENCODED_SIG_SZ = 512, MAX_SIG_SZ = 256, MAX_ALGO_SZ = 20, MAX_SEQ_SZ = 5, /* enum(seq | con) + length(4) */ MAX_SET_SZ = 5, /* enum(set | con) + length(4) */ MAX_OCTET_STR_SZ = 5, /* enum(set | con) + length(4) */ MAX_EXP_SZ = 5, /* enum(contextspec|con|exp) + length(4) */ MAX_PRSTR_SZ = 5, /* enum(prstr) + length(4) */ MAX_VERSION_SZ = 5, /* enum + id + version(byte) + (header(2))*/ MAX_ENCODED_DIG_SZ = 73, /* sha512 + enum(bit or octet) + length(4) */ MAX_RSA_INT_SZ = 517, /* RSA raw sz 4096 for bits + tag + len(4) */ MAX_NTRU_KEY_SZ = 610, /* NTRU 112 bit public key */ MAX_NTRU_ENC_SZ = 628, /* NTRU 112 bit DER public encoding */ MAX_LENGTH_SZ = 4, /* Max length size for DER encoding */ MAX_RSA_E_SZ = 16, /* Max RSA public e size */ MAX_CA_SZ = 32, /* Max encoded CA basic constraint length */ MAX_SN_SZ = 35, /* Max encoded serial number (INT) length */ MAX_DER_DIGEST_SZ = MAX_ENCODED_DIG_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ, /* Maximum DER digest size */ #ifdef WOLFSSL_CERT_GEN #ifdef WOLFSSL_CERT_REQ /* Max encoded cert req attributes length */ MAX_ATTRIB_SZ = MAX_SEQ_SZ * 3 + (11 + MAX_SEQ_SZ) * 2 + MAX_PRSTR_SZ + CTC_NAME_SIZE, /* 11 is the OID size */ #endif #if defined(WOLFSSL_ALT_NAMES) || defined(WOLFSSL_CERT_EXT) MAX_EXTENSIONS_SZ = 1 + MAX_LENGTH_SZ + CTC_MAX_ALT_SIZE, #else MAX_EXTENSIONS_SZ = 1 + MAX_LENGTH_SZ + MAX_CA_SZ, #endif /* Max total extensions, id + len + others */ #endif #ifdef WOLFSSL_CERT_EXT MAX_KID_SZ = 45, /* Max encoded KID length (SHA-256 case) */ MAX_KEYUSAGE_SZ = 18, /* Max encoded Key Usage length */ MAX_OID_SZ = 32, /* Max DER length of OID*/ MAX_OID_STRING_SZ = 64, /* Max string length representation of OID*/ MAX_CERTPOL_NB = CTC_MAX_CERTPOL_NB,/* Max number of Cert Policy */ MAX_CERTPOL_SZ = CTC_MAX_CERTPOL_SZ, #endif OCSP_NONCE_EXT_SZ = 37, /* OCSP Nonce Extension size */ MAX_OCSP_EXT_SZ = 58, /* Max OCSP Extension length */ MAX_OCSP_NONCE_SZ = 16, /* OCSP Nonce size */ EIGHTK_BUF = 8192, /* Tmp buffer size */ MAX_PUBLIC_KEY_SZ = MAX_NTRU_ENC_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ * 2, /* use bigger NTRU size */ <API key> = 88,/* Extra header size for encrypted key */ TRAILING_ZERO = 1 /* Used for size of zero pad */ }; enum Oid_Types { oidHashType = 0, oidSigType = 1, oidKeyType = 2, oidCurveType = 3, oidBlkType = 4, oidOcspType = 5, oidCertExtType = 6, oidCertAuthInfoType = 7, oidCertPolicyType = 8, oidCertAltNameType = 9, oidCertKeyUseType = 10, oidKdfType = 11, oidIgnoreType }; enum Hash_Sum { MD2h = 646, MD5h = 649, SHAh = 88, SHA256h = 414, SHA384h = 415, SHA512h = 416 }; enum Block_Sum { DESb = 69, DES3b = 652 }; enum Key_Sum { DSAk = 515, RSAk = 645, NTRUk = 274, ECDSAk = 518 }; enum Ecc_Sum { ECC_256R1 = 526, ECC_384R1 = 210, ECC_521R1 = 211, ECC_160R1 = 184, ECC_192R1 = 520, ECC_224R1 = 209 }; enum KDF_Sum { PBKDF2_OID = 660 }; enum Extensions_Sum { BASIC_CA_OID = 133, ALT_NAMES_OID = 131, CRL_DIST_OID = 145, AUTH_INFO_OID = 69, AUTH_KEY_OID = 149, SUBJ_KEY_OID = 128, CERT_POLICY_OID = 146, KEY_USAGE_OID = 129, /* 2.5.29.15 */ INHIBIT_ANY_OID = 168, /* 2.5.29.54 */ EXT_KEY_USAGE_OID = 151, /* 2.5.29.37 */ NAME_CONS_OID = 144 /* 2.5.29.30 */ }; enum <API key> { CP_ANY_OID = 146 /* id-ce 32 0 */ }; enum SepHardwareName_Sum { HW_NAME_OID = 79 /* 1.3.6.1.5.5.7.8.4 from RFC 4108*/ }; enum AuthInfo_Sum { AIA_OCSP_OID = 116, /* 1.3.6.1.5.5.7.48.1 */ AIA_CA_ISSUER_OID = 117 /* 1.3.6.1.5.5.7.48.2 */ }; enum ExtKeyUsage_Sum { /* From RFC 5280 */ EKU_ANY_OID = 151, /* 2.5.29.37.0, anyExtendedKeyUsage */ EKU_SERVER_AUTH_OID = 71, /* 1.3.6.1.5.5.7.3.1, id-kp-serverAuth */ EKU_CLIENT_AUTH_OID = 72, /* 1.3.6.1.5.5.7.3.2, id-kp-clientAuth */ EKU_OCSP_SIGN_OID = 79 /* 1.3.6.1.5.5.7.3.9, OCSPSigning */ }; enum VerifyType { NO_VERIFY = 0, VERIFY = 1 }; #ifdef WOLFSSL_CERT_EXT enum KeyIdType { SKID_TYPE = 0, AKID_TYPE = 1 }; #endif /* Key usage extension bits */ #define KEYUSE_DIGITAL_SIG 0x0080 #define <API key> 0x0040 #define KEYUSE_KEY_ENCIPHER 0x0020 #define <API key> 0x0010 #define KEYUSE_KEY_AGREE 0x0008 #define <API key> 0x0004 #define KEYUSE_CRL_SIGN 0x0002 #define <API key> 0x0001 #define <API key> 0x8000 #define EXTKEYUSE_ANY 0x08 #define EXTKEYUSE_OCSP_SIGN 0x04 #define <API key> 0x02 #define <API key> 0x01 typedef struct DNS_entry DNS_entry; struct DNS_entry { DNS_entry* next; /* next on DNS list */ char* name; /* actual DNS name */ }; typedef struct Base_entry Base_entry; struct Base_entry { Base_entry* next; /* next on name base list */ char* name; /* actual name base */ int nameSz; /* name length */ byte type; /* Name base type (DNS or RFC822) */ }; struct DecodedName { char* fullName; int fullNameLen; int entryCount; int cnIdx; int cnLen; int snIdx; int snLen; int cIdx; int cLen; int lIdx; int lLen; int stIdx; int stLen; int oIdx; int oLen; int ouIdx; int ouLen; int emailIdx; int emailLen; int uidIdx; int uidLen; int serialIdx; int serialLen; }; typedef struct DecodedCert DecodedCert; typedef struct DecodedName DecodedName; typedef struct Signer Signer; #ifdef <API key> typedef struct TrustedPeerCert TrustedPeerCert; #endif /* <API key> */ struct DecodedCert { byte* publicKey; word32 pubKeySize; int pubKeyStored; word32 certBegin; /* offset to start of cert */ word32 sigIndex; /* offset to start of signature */ word32 sigLength; /* length of signature */ word32 signatureOID; /* sum of algorithm object id */ word32 keyOID; /* sum of key algo object id */ int version; /* cert version, 1 or 3 */ DNS_entry* altNames; /* alt names list of dns entries */ #ifndef <API key> DNS_entry* altEmailNames; /* alt names list of RFC822 entries */ Base_entry* permittedNames; /* Permitted name bases */ Base_entry* excludedNames; /* Excluded name bases */ #endif /* <API key> */ byte subjectHash[KEYID_SIZE]; /* hash of all Names */ byte issuerHash[KEYID_SIZE]; /* hash of all Names */ #ifdef HAVE_OCSP byte issuerKeyHash[KEYID_SIZE]; /* hash of the public Key */ #endif /* HAVE_OCSP */ byte* signature; /* not owned, points into raw cert */ char* subjectCN; /* CommonName */ int subjectCNLen; /* CommonName Length */ char subjectCNEnc; /* CommonName Encoding */ int subjectCNStored; /* have we saved a copy we own */ char issuer[ASN_NAME_MAX]; /* full name including common name */ char subject[ASN_NAME_MAX]; /* full name including common name */ int verify; /* Default to yes, but could be off */ byte* source; /* byte buffer holder cert, NOT owner */ word32 srcIdx; /* current offset into buffer */ word32 maxIdx; /* max offset based on init size */ void* heap; /* for user memory overrides */ byte serial[<API key>]; /* raw serial number */ int serialSz; /* raw serial bytes stored */ byte* extensions; /* not owned, points into raw cert */ int extensionsSz; /* length of cert extensions */ word32 extensionsIdx; /* if want to go back and parse later */ byte* extAuthInfo; /* Authority Information Access URI */ int extAuthInfoSz; /* length of the URI */ byte* extCrlInfo; /* CRL Distribution Points */ int extCrlInfoSz; /* length of the URI */ byte extSubjKeyId[KEYID_SIZE]; /* Subject Key ID */ byte extSubjKeyIdSet; /* Set when the SKID was read from cert */ byte extAuthKeyId[KEYID_SIZE]; /* Authority Key ID */ byte extAuthKeyIdSet; /* Set when the AKID was read from cert */ #ifndef <API key> byte <API key>; #endif /* <API key> */ byte isCA; /* CA basic constraint true */ byte weOwnAltNames; /* altNames haven't been given to copy */ byte extKeyUsageSet; word16 extKeyUsage; /* Key usage bitfield */ byte extExtKeyUsageSet; /* Extended Key Usage */ byte extExtKeyUsage; /* Extended Key usage bitfield */ #ifdef OPENSSL_EXTRA byte extBasicConstSet; byte extBasicConstCrit; byte extBasicConstPlSet; word32 pathLength; /* CA basic constraint path length, opt */ byte extSubjAltNameSet; byte extSubjAltNameCrit; byte extAuthKeyIdCrit; #ifndef <API key> byte <API key>; #endif /* <API key> */ byte extSubjKeyIdCrit; byte extKeyUsageCrit; byte extExtKeyUsageCrit; byte* extExtKeyUsageSrc; word32 extExtKeyUsageSz; word32 extExtKeyUsageCount; byte* extAuthKeyIdSrc; word32 extAuthKeyIdSz; byte* extSubjKeyIdSrc; word32 extSubjKeyIdSz; #endif #ifdef HAVE_ECC word32 pkCurveOID; /* Public Key's curve OID */ #endif /* HAVE_ECC */ byte* beforeDate; int beforeDateLen; byte* afterDate; int afterDateLen; #ifdef HAVE_PKCS7 byte* issuerRaw; /* pointer to issuer inside source */ int issuerRawLen; #endif #ifndef <API key> byte* subjectRaw; /* pointer to subject inside source */ int subjectRawLen; #endif #if defined(WOLFSSL_CERT_GEN) /* easy access to subject info for other sign */ char* subjectSN; int subjectSNLen; char subjectSNEnc; char* subjectC; int subjectCLen; char subjectCEnc; char* subjectL; int subjectLLen; char subjectLEnc; char* subjectST; int subjectSTLen; char subjectSTEnc; char* subjectO; int subjectOLen; char subjectOEnc; char* subjectOU; int subjectOULen; char subjectOUEnc; char* subjectEmail; int subjectEmailLen; #endif /* WOLFSSL_CERT_GEN */ #ifdef OPENSSL_EXTRA DecodedName issuerName; DecodedName subjectName; #endif /* OPENSSL_EXTRA */ #ifdef WOLFSSL_SEP int deviceTypeSz; byte* deviceType; int hwTypeSz; byte* hwType; int hwSerialNumSz; byte* hwSerialNum; #ifdef OPENSSL_EXTRA byte extCertPolicySet; byte extCertPolicyCrit; #endif /* OPENSSL_EXTRA */ #endif /* WOLFSSL_SEP */ #ifdef WOLFSSL_CERT_EXT char extCertPolicies[MAX_CERTPOL_NB][MAX_CERTPOL_SZ]; int extCertPoliciesNb; #endif /* WOLFSSL_CERT_EXT */ }; extern const char* BEGIN_CERT; extern const char* END_CERT; extern const char* BEGIN_CERT_REQ; extern const char* END_CERT_REQ; extern const char* BEGIN_DH_PARAM; extern const char* END_DH_PARAM; extern const char* BEGIN_X509_CRL; extern const char* END_X509_CRL; extern const char* BEGIN_RSA_PRIV; extern const char* END_RSA_PRIV; extern const char* BEGIN_PRIV_KEY; extern const char* END_PRIV_KEY; extern const char* BEGIN_ENC_PRIV_KEY; extern const char* END_ENC_PRIV_KEY; extern const char* BEGIN_EC_PRIV; extern const char* END_EC_PRIV; extern const char* BEGIN_DSA_PRIV; extern const char* END_DSA_PRIV; extern const char* BEGIN_PUB_KEY; extern const char* END_PUB_KEY; #ifdef NO_SHA #define SIGNER_DIGEST_SIZE SHA256_DIGEST_SIZE #else #define SIGNER_DIGEST_SIZE SHA_DIGEST_SIZE #endif /* CA Signers */ /* if change layout change PERSIST_CERT_CACHE functions too */ struct Signer { word32 pubKeySize; word32 keyOID; /* key type */ word16 keyUsage; byte* publicKey; int nameLen; char* name; /* common name */ #ifndef <API key> Base_entry* permittedNames; Base_entry* excludedNames; #endif /* <API key> */ byte subjectNameHash[SIGNER_DIGEST_SIZE]; /* sha hash of names in certificate */ #ifndef NO_SKID byte subjectKeyIdHash[SIGNER_DIGEST_SIZE]; /* sha hash of names in certificate */ #endif Signer* next; }; #ifdef <API key> /* used for having trusted peer certs rather then CA */ struct TrustedPeerCert { int nameLen; char* name; /* common name */ #ifndef <API key> Base_entry* permittedNames; Base_entry* excludedNames; #endif /* <API key> */ byte subjectNameHash[SIGNER_DIGEST_SIZE]; /* sha hash of names in certificate */ #ifndef NO_SKID byte subjectKeyIdHash[SIGNER_DIGEST_SIZE]; /* sha hash of names in certificate */ #endif word32 sigLen; byte* sig; struct TrustedPeerCert* next; }; #endif /* <API key> */ /* not for public consumption but may use for testing sometimes */ #ifdef WOLFSSL_TEST_CERT #define WOLFSSL_TEST_API WOLFSSL_API #else #define WOLFSSL_TEST_API WOLFSSL_LOCAL #endif WOLFSSL_TEST_API void FreeAltNames(DNS_entry*, void*); #ifndef <API key> WOLFSSL_TEST_API void FreeNameSubtrees(Base_entry*, void*); #endif /* <API key> */ WOLFSSL_TEST_API void InitDecodedCert(DecodedCert*, byte*, word32, void*); WOLFSSL_TEST_API void FreeDecodedCert(DecodedCert*); WOLFSSL_TEST_API int ParseCert(DecodedCert*, int type, int verify, void* cm); WOLFSSL_LOCAL int ParseCertRelative(DecodedCert*,int type,int verify,void* cm); WOLFSSL_LOCAL int DecodeToKey(DecodedCert*, int verify); WOLFSSL_LOCAL Signer* MakeSigner(void*); WOLFSSL_LOCAL void FreeSigner(Signer*, void*); WOLFSSL_LOCAL void FreeSignerTable(Signer**, int, void*); #ifdef <API key> WOLFSSL_LOCAL void FreeTrustedPeer(TrustedPeerCert*, void*); WOLFSSL_LOCAL void <API key>(TrustedPeerCert**, int, void*); #endif /* <API key> */ WOLFSSL_LOCAL int ToTraditional(byte* buffer, word32 length); WOLFSSL_LOCAL int ToTraditionalEnc(byte* buffer, word32 length,const char*,int); WOLFSSL_LOCAL int ValidateDate(const byte* date, byte format, int dateType); /* ASN.1 helper functions */ WOLFSSL_LOCAL int GetLength(const byte* input, word32* inOutIdx, int* len, word32 maxIdx); WOLFSSL_LOCAL int GetSequence(const byte* input, word32* inOutIdx, int* len, word32 maxIdx); WOLFSSL_LOCAL int GetSet(const byte* input, word32* inOutIdx, int* len, word32 maxIdx); WOLFSSL_LOCAL int GetMyVersion(const byte* input, word32* inOutIdx, int* version); WOLFSSL_LOCAL int GetInt(mp_int* mpi, const byte* input, word32* inOutIdx, word32 maxIdx); WOLFSSL_LOCAL int GetObjectId(const byte* input, word32* inOutIdx, word32* oid, word32 oidType, word32 maxIdx); WOLFSSL_LOCAL int GetAlgoId(const byte* input, word32* inOutIdx, word32* oid, word32 oidType, word32 maxIdx); WOLFSSL_LOCAL word32 SetLength(word32 length, byte* output); WOLFSSL_LOCAL word32 SetSequence(word32 len, byte* output); WOLFSSL_LOCAL word32 SetOctetString(word32 len, byte* output); WOLFSSL_LOCAL word32 SetImplicit(byte tag,byte number,word32 len,byte* output); WOLFSSL_LOCAL word32 SetExplicit(byte number, word32 len, byte* output); WOLFSSL_LOCAL word32 SetSet(word32 len, byte* output); WOLFSSL_LOCAL word32 SetAlgoID(int algoOID,byte* output,int type,int curveSz); WOLFSSL_LOCAL int SetMyVersion(word32 version, byte* output, int header); WOLFSSL_LOCAL int SetSerialNumber(const byte* sn, word32 snSz, byte* output); WOLFSSL_LOCAL int GetNameHash(const byte* source, word32* idx, byte* hash, int maxIdx); #ifdef HAVE_ECC /* ASN sig helpers */ WOLFSSL_LOCAL int StoreECC_DSA_Sig(byte* out, word32* outLen, mp_int* r, mp_int* s); WOLFSSL_LOCAL int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, mp_int* r, mp_int* s); #endif #ifdef WOLFSSL_CERT_GEN enum cert_enums { NAME_ENTRIES = 8, JOINT_LEN = 2, EMAIL_JOINT_LEN = 9, RSA_KEY = 10, NTRU_KEY = 11, ECC_KEY = 12 }; #ifndef <API key> #ifndef NO_FILESYSTEM /* forward from wolfSSL */ WOLFSSL_API int <API key>(const char* fileName,unsigned char* derBuf,int derSz); #define <API key> #endif #endif #endif /* WOLFSSL_CERT_GEN */ /* for pointer use */ typedef struct CertStatus CertStatus; #ifdef HAVE_OCSP enum <API key> { OCSP_SUCCESSFUL = 0, /* Response has valid confirmations */ <API key> = 1, OCSP_INTERNAL_ERROR = 2, /* Internal error in issuer */ OCSP_TRY_LATER = 3, /* Try again later */ OCSP_SIG_REQUIRED = 5, /* Must sign the request (4 is skipped) */ OCSP_UNAUTHROIZED = 6 /* Request unauthorized */ }; enum Ocsp_Cert_Status { CERT_GOOD = 0, CERT_REVOKED = 1, CERT_UNKNOWN = 2 }; enum Ocsp_Sums { OCSP_BASIC_OID = 117, OCSP_NONCE_OID = 118 }; typedef struct OcspRequest OcspRequest; typedef struct OcspResponse OcspResponse; struct CertStatus { CertStatus* next; byte serial[<API key>]; int serialSz; int status; byte thisDate[MAX_DATE_SIZE]; byte nextDate[MAX_DATE_SIZE]; byte thisDateFormat; byte nextDateFormat; byte* rawOcspResponse; word32 rawOcspResponseSz; }; struct OcspResponse { int responseStatus; /* return code from Responder */ byte* response; /* Pointer to beginning of OCSP Response */ word32 responseSz; /* length of the OCSP Response */ byte producedDate[MAX_DATE_SIZE]; /* Date at which this response was signed */ byte producedDateFormat; /* format of the producedDate */ byte* issuerHash; byte* issuerKeyHash; byte* cert; word32 certSz; byte* sig; /* Pointer to sig in source */ word32 sigSz; /* Length in octets for the sig */ word32 sigOID; /* OID for hash used for sig */ CertStatus* status; /* certificate status to fill out */ byte* nonce; /* pointer to nonce inside ASN.1 response */ int nonceSz; /* length of the nonce string */ byte* source; /* pointer to source buffer, not owned */ word32 maxIdx; /* max offset based on init size */ }; struct OcspRequest { byte issuerHash[KEYID_SIZE]; byte issuerKeyHash[KEYID_SIZE]; byte* serial; /* copy of the serial number in source cert */ int serialSz; byte* url; /* copy of the extAuthInfo in source cert */ int urlSz; byte nonce[MAX_OCSP_NONCE_SZ]; int nonceSz; }; WOLFSSL_LOCAL void InitOcspResponse(OcspResponse*, CertStatus*, byte*, word32); WOLFSSL_LOCAL int OcspResponseDecode(OcspResponse*, void*); WOLFSSL_LOCAL int InitOcspRequest(OcspRequest*, DecodedCert*, byte); WOLFSSL_LOCAL void FreeOcspRequest(OcspRequest*); WOLFSSL_LOCAL int EncodeOcspRequest(OcspRequest*, byte*, word32); WOLFSSL_LOCAL word32 <API key>(OcspRequest*, byte*, word32); WOLFSSL_LOCAL int CompareOcspReqResp(OcspRequest*, OcspResponse*); #endif /* HAVE_OCSP */ /* for pointer use */ typedef struct RevokedCert RevokedCert; #ifdef HAVE_CRL struct RevokedCert { byte serialNumber[<API key>]; int serialSz; RevokedCert* next; }; typedef struct DecodedCRL DecodedCRL; struct DecodedCRL { word32 certBegin; /* offset to start of cert */ word32 sigIndex; /* offset to start of signature */ word32 sigLength; /* length of signature */ word32 signatureOID; /* sum of algorithm object id */ byte* signature; /* pointer into raw source, not owned */ byte issuerHash[SIGNER_DIGEST_SIZE]; /* issuer hash */ byte crlHash[SIGNER_DIGEST_SIZE]; /* raw crl data hash */ byte lastDate[MAX_DATE_SIZE]; /* last date updated */ byte nextDate[MAX_DATE_SIZE]; /* next update date */ byte lastDateFormat; /* format of last date */ byte nextDateFormat; /* format of next date */ RevokedCert* certs; /* revoked cert list */ int totalCerts; /* number on list */ }; WOLFSSL_LOCAL void InitDecodedCRL(DecodedCRL*); WOLFSSL_LOCAL int ParseCRL(DecodedCRL*, const byte* buff, word32 sz, void* cm); WOLFSSL_LOCAL void FreeDecodedCRL(DecodedCRL*); #endif /* HAVE_CRL */ #ifdef __cplusplus } /* extern "C" */ #endif #endif /* !NO_ASN */ #endif /* WOLF_CRYPT_ASN_H */
#include <typedefs.h> #include <linuxver.h> #include <osl.h> #include <bcmutils.h> #include <dngl_stats.h> #include <dhd.h> #include <wlioctl.h> #include <wl_iw.h> #define WL_ERROR(x) printf x #define WL_TRACE(x) #ifdef CUSTOMER_HW_SAMSUNG extern void bcm_wlan_power_off(int); extern void bcm_wlan_power_on(int); extern void wlan_setup_power(int, int); #endif /* CUSTOMER_HW_SAMSUNG */ #ifdef CUSTOMER_HW extern void bcm_wlan_power_off(int); extern void bcm_wlan_power_on(int); #endif /* CUSTOMER_HW */ #ifdef CUSTOMER_HW2 int wifi_set_carddetect(int on); int wifi_set_power(int on, unsigned long msec); int wifi_get_irq_number(unsigned long *irq_flags_ptr); int wifi_get_mac_addr(unsigned char *buf); void *<API key>(char *ccode); #endif #if defined(OOB_INTR_ONLY) #if defined(BCMLXSDMMC) extern int sdioh_mmc_irq(int irq); #endif /* (BCMLXSDMMC) */ #ifdef CUSTOMER_HW3 #include <mach/gpio.h> #endif /* Customer specific Host GPIO defintion */ /* Customer specific Host GPIO defintion */ #ifdef CUSTOMER_HW_SAMSUNG static int dhd_oob_gpio_num = IRQ_EINT(20); #else static int dhd_oob_gpio_num = -1; /* GG 19 */ #endif module_param(dhd_oob_gpio_num, int, 0644); MODULE_PARM_DESC(dhd_oob_gpio_num, "DHD oob gpio number"); int <API key>(unsigned long *irq_flags_ptr) { int host_oob_irq = 0; #ifdef CUSTOMER_HW2 host_oob_irq = wifi_get_irq_number(irq_flags_ptr); #else /* for NOT CUSTOMER_HW2 */ #if defined(CUSTOM_OOB_GPIO_NUM) if (dhd_oob_gpio_num < 0) { dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM; } #endif if (dhd_oob_gpio_num < 0) { WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n", __FUNCTION__)); return (dhd_oob_gpio_num); } WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n", __FUNCTION__, dhd_oob_gpio_num)); #if defined CUSTOMER_HW host_oob_irq = MSM_GPIO_TO_INT(dhd_oob_gpio_num); #elif defined CUSTOMER_HW3 gpio_request(dhd_oob_gpio_num, "oob irq"); host_oob_irq = gpio_to_irq(dhd_oob_gpio_num); <API key>(dhd_oob_gpio_num); #elif defined CUSTOMER_HW_SAMSUNG host_oob_irq = dhd_oob_gpio_num; #endif /* CUSTOMER_HW */ #endif /* CUSTOMER_HW2 */ return (host_oob_irq); } #endif /* defined(OOB_INTR_ONLY) */ /* Customer function to control hw specific wlan gpios */ void <API key>(int onoff) { switch (onoff) { case WLAN_RESET_OFF: WL_TRACE(("%s: call customer specific GPIO to insert WLAN RESET\n", __FUNCTION__)); #ifdef CUSTOMER_HW_SAMSUNG //bcm_wlan_power_off(2); wlan_setup_power(0, 2); #endif /* CUSTOMER_HW */ #ifdef CUSTOMER_HW bcm_wlan_power_off(2); #endif /* CUSTOMER_HW */ #ifdef CUSTOMER_HW2 wifi_set_power(0, 0); #endif WL_ERROR(("=========== WLAN placed in RESET ========\n")); break; case WLAN_RESET_ON: WL_TRACE(("%s: callc customer specific GPIO to remove WLAN RESET\n", __FUNCTION__)); #ifdef CUSTOMER_HW_SAMSUNG //bcm_wlan_power_on(2); wlan_setup_power(1, 2); #endif /* CUSTOMER_HW */ #ifdef CUSTOMER_HW bcm_wlan_power_on(2); #endif /* CUSTOMER_HW */ #ifdef CUSTOMER_HW2 wifi_set_power(1, 0); #endif WL_ERROR(("=========== WLAN going back to live ========\n")); break; case WLAN_POWER_OFF: WL_TRACE(("%s: call customer specific GPIO to turn off WL_REG_ON\n", __FUNCTION__)); #ifdef CUSTOMER_HW_SAMSUNG //bcm_wlan_power_off(1); wlan_setup_power(0, 1); #endif /* CUSTOMER_HW */ #ifdef CUSTOMER_HW bcm_wlan_power_off(1); #endif /* CUSTOMER_HW */ break; case WLAN_POWER_ON: WL_TRACE(("%s: call customer specific GPIO to turn on WL_REG_ON\n", __FUNCTION__)); #ifdef CUSTOMER_HW_SAMSUNG //bcm_wlan_power_on(1); wlan_setup_power(1, 1); #endif /* CUSTOMER_HW */ #ifdef CUSTOMER_HW bcm_wlan_power_on(1); /* Lets customer power to get stable */ OSL_DELAY(50); #endif /* CUSTOMER_HW */ break; } } #ifdef <API key> /* Function to get custom MAC address */ int <API key>(unsigned char *buf) { int ret = 0; WL_TRACE(("%s Enter\n", __FUNCTION__)); if (!buf) return -EINVAL; /* Customer access to MAC address stored outside of DHD driver */ #ifdef CUSTOMER_HW2 ret = wifi_get_mac_addr(buf); #endif #ifdef EXAMPLE_GET_MAC /* EXAMPLE code */ { struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}}; bcopy((char *)&ea_example, buf, sizeof(struct ether_addr)); } #endif /* EXAMPLE_GET_MAC */ return ret; } #endif /* <API key> */ /* Customized Locale table : OPTIONAL feature */ const struct <API key> <API key>[] = { /* Table should be filled out based on custom platform regulatory requirement */ #ifdef EXAMPLE_TABLE {"", "XY", 4}, /* universal */ {"US", "US", 69}, /* input ISO "US" to : US regrev 69 */ {"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */ {"EU", "EU", 5}, /* European union countries */ {"AT", "EU", 5}, {"BE", "EU", 5}, {"BG", "EU", 5}, {"CY", "EU", 5}, {"CZ", "EU", 5}, {"DK", "EU", 5}, {"EE", "EU", 5}, {"FI", "EU", 5}, {"FR", "EU", 5}, {"DE", "EU", 5}, {"GR", "EU", 5}, {"HU", "EU", 5}, {"IE", "EU", 5}, {"IT", "EU", 5}, {"LV", "EU", 5}, {"LI", "EU", 5}, {"LT", "EU", 5}, {"LU", "EU", 5}, {"MT", "EU", 5}, {"NL", "EU", 5}, {"PL", "EU", 5}, {"PT", "EU", 5}, {"RO", "EU", 5}, {"SK", "EU", 5}, {"SI", "EU", 5}, {"ES", "EU", 5}, {"SE", "EU", 5}, {"GB", "EU", 5}, /* input ISO "GB" to : EU regrev 05 */ {"IL", "IL", 0}, {"CH", "CH", 0}, {"TR", "TR", 0}, {"NO", "NO", 0}, {"KR", "XY", 3}, {"AU", "XY", 3}, {"CN", "XY", 3}, /* input ISO "CN" to : XY regrev 03 */ {"TW", "XY", 3}, {"AR", "XY", 3}, {"MX", "XY", 3} #endif /* EXAMPLE_TABLE */ }; /* Customized Locale convertor * input : ISO 3166-1 country abbreviation * output: customized cspec */ void <API key>(char *country_iso_code, wl_country_t *cspec) { #ifdef CUSTOMER_HW2 struct <API key> *cloc_ptr; if (!cspec) return; cloc_ptr = <API key>(country_iso_code); if (cloc_ptr) { strlcpy(cspec->ccode, cloc_ptr->custom_locale, WLC_CNTRY_BUF_SZ); cspec->rev = cloc_ptr->custom_locale_rev; } return; #else int size, i; size = ARRAYSIZE(<API key>); if (cspec == 0) return; if (size == 0) return; for (i = 0; i < size; i++) { if (strcmp(country_iso_code, <API key>[i].iso_abbrev) == 0) { memcpy(cspec->ccode, <API key>[i].custom_locale, WLC_CNTRY_BUF_SZ); cspec->rev = <API key>[i].custom_locale_rev; return; } } memcpy(cspec->ccode, <API key>[0].custom_locale, WLC_CNTRY_BUF_SZ); cspec->rev = <API key>[0].custom_locale_rev; return; #endif }
// Test for method java.util.<API key>.getClass().getFields() // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, Inc., 51 Franklin Street, // Fifth Floor, Boston, MA 02110-1301 USA. // Tags: JDK1.5 package gnu.testlet.java.util.<API key>.classInfo; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.util.<API key>; import java.util.Map; import java.util.HashMap; /** * Test for method java.util.<API key>.getClass().getFields() */ public class getFields implements Testlet { /** * Runs the test using the specified harness. * * @param harness the test harness (<code>null</code> not permitted). */ public void test(TestHarness harness) { // map of fields which should exists Map<String, String> testedFields = null; // map of fields for (Open)JDK6 Map<String, String> testedFields_jdk6 = new HashMap<String, String>(); // map of fields for (Open)JDK7 Map<String, String> testedFields_jdk7 = new HashMap<String, String>(); // map for fields declared in (Open)JDK6 // map for fields declared in (Open)JDK7 // create instance of a class <API key> final Object o = new <API key>(42); // get a runtime class of an object "o" final Class c = o.getClass(); // get the right map containing field signatures testedFields = getJavaVersion() < 7 ? testedFields_jdk6 : testedFields_jdk7; // get all fields for this class java.lang.reflect.Field[] fields = c.getFields(); // expected number of fields final int <API key> = testedFields.size(); // basic check for a number of fields harness.check(fields.length, <API key>); } /** * Returns version of Java. The input could have the following form: "1.7.0_06" * and we are interested only in "7" in this case. * * @return Java version */ protected int getJavaVersion() { String javaVersionStr = System.getProperty("java.version"); String[] parts = javaVersionStr.split("\\."); return Integer.parseInt(parts[1]); } }
# Turn Off the Lights Browser Extension <img alt="Turn Off the Lights Browser Extension Logo" src="https://github.com/turnoffthelights/<API key>/blob/master/src/icons/icon48.png" align="left" style="padding: 0 10px 5px 0"> **Turn Off the Lights** is a popular browser extension that works on all major web browsers such as Google Chrome, Firefox, Opera, Safari, Yandex, Maxthon, Brave, Vivaldi, Cốc Cốc, and Microsoft Edge. ![Chrome Web Store](https://img.shields.io/chrome-web-store/d/<API key>.svg?color=#44cc12&style=flat-square) ![Chrome Web Store](https://img.shields.io/chrome-web-store/rating/<API key>?color=#44cc12&style=flat-square) ![Chrome Web Store](https://img.shields.io/chrome-web-store/v/<API key>.svg?color=#44cc12&style=flat-square) Project<br> [![CodeQL](https: [![Language grade: JavaScript](https: Using Turn Off the Lights to dims the web page and reduces the eye strain caused by the bright screen. And it will highlight the video player on that web page such as on YouTube. **[Join our growing community on Facebook](https: **[Join our growing Translators community on Crowdin](https: **[Please use and enjoy it, and if you can make a donation of any amount, I'd appreciate it immensely](https: <div style="text-align:center"> <img alt="Turn Off the Lights Browser extension Screenshot in Google Chrome" src="https: </div> ## Features * Turn the lights back on, by clicking on it * Support multiple video sites: YouTube, HTML5 video,... and more * Customize your YouTube: * Auto HD: Set videos to play in HD automatically. Users can select from highres > 8K > 5K> 4K > 1080p > 720p > 480p > 360p > 240p > 144p > default * Auto Wide: Automatically plays the video on the widest mode ,... and more * Easter Eggs: * Shortcut key: T -> Do you like a real movie theater feeling? * Option to make the screen dark when the user clicks on the play button * Option to turn on/off the fade in and fade out effects * Custom colors * Option to Flash Detection * Option to Show Dimness Level Bar * Option Eye Protection for when it's night. And with whitelist/blacklist filter * Option atmosphere lighting that shows a glow around the video player * Option to show the dark layer on the top of the window * Options to shortcut keys: * Ctrl + Shift + L to toggle the lights * Alt + F8 to restore the default opacity value * Alt + F9 to save the current opacity value * Alt + F10 to enable/disable the Eye Protection feature * Alt + (arrow up) to increase the opacity * Alt + (arrow down) to decrease the opacity * Alt + * to toggle the lights on all open tabs * Option Camera Motion * Option Speech Recognition * Option for Mouse Wheel Volume Control for each HTML5 video player * Option to add a filter to the current HTML5 video player (grayscale, sepia, invert, contrast, saturate, hue rotation and brightness) * Option to show the Audio Visualization effect on top of the current HTML5 video (Blocks, Frequency and Music Tunnel) * Option to loop the current HTML5 video player * Option to place the Night Mode switch to toggle YouTube in black or white theme. And with whitelist/blacklist filter * Time stamp: Activate the Night Mode within the chosen time * Blackout: Dims the web page and activates the Night Mode * Option to stop YouTube and HTML5 videos from automatically playing. ## Installation # Loading it in Chrome: 1. Open your Google Chrome web browser, browse to [chrome://extensions](chrome://extensions) 1. If you have already Turn Off the Lights Chrome extension installed, disable it 1. Check **Developer mode** in the top of the Extensions page 1. Click **Load unpacked extension...** 1. Choose the sub-directory **src** (where manifest.json resides) # Store hyperlinks: The Browser extension is available in the following stores: * [Google Chrome in the Chrome web store](https://chrome.google.com/webstore/detail/turn-off-the-lights/<API key>) * [Opera in the Opera Extension gallery](https://addons.opera.com/extensions/details/turn-off-the-lights/) * [Firefox in the Firefox Extension gallery](https://addons.mozilla.org/firefox/addon/turn-off-the-lights/) * [Safari in the Safari Extension gallery](https://itunes.apple.com/us/app/<API key>/id1273998507?ls=1&mt=12&at=1010lwtb) * Available for Yandex: See Yandex built-in extension * [Maxthon in the Maxthon Extension gallery](http://extension.maxthon.com/detail/index.php?view_id=1813) * [Microsoft Edge in the Windows Store](https://microsoftedge.microsoft.com/addons/detail/turn-off-the-lights/<API key>)
#include <apudrv.h> #include <_apudrv.h> #if defined (POOL_COMPONENT) #include <pooldefs.h> #endif /* if defined (POOL_COMPONENT) */ #if defined (MSGQ_COMPONENT) #include <msgqdefs.h> #endif /* if defined (MSGQ_COMPONENT) */ #include <cfgmap.h> #if defined (__cplusplus) EXTERN "C" { #endif /* defined (__cplusplus) */ EXTERN DSP_Interface ZSP800M_Interface ; CONST CFGMAP_Dsp <API key> [] = { { "ZSP800M", /* NAME : Name of the DSP */ &ZSP800M_Interface /* INTERFACE : DSP interface table */ } } ; EXTERN KFILE_Interface <API key> ; EXTERN KFILE_Interface KFILEDEF_Interface ; CONST CFGMAP_Loader <API key> [] = { { "BIN", NULL,//&BINFILE_Interface, &KFILEDEF_Interface } } ; #if (!defined (ONLY_PROC_COMPONENT)) EXTERN DRV_Interface SHMDRV_Interface ; CONST CFGMAP_LinkDrv <API key> [] = { { "SHMDRV", /* NAME : Name of the link driver */ &SHMDRV_Interface /* INTERFACE : Link driver interface table */ } } ; EXTERN FnIpsInit IPS_init ; EXTERN FnIpsExit IPS_exit ; #if defined (DDSP_DEBUG) EXTERN FnIpsDebug IPS_debug ; #endif /* if defined (DDSP_DEBUG) */ CONST CFGMAP_Ips <API key> [] = { { "IPS", /* NAME : Name of the IPS */ (FnIpsInit) &IPS_init, /* FXN_INIT : Init function for the IPS */ (FnIpsExit) &IPS_exit, /* FXN_EXIT : Exit function for the IPS */ #if defined (DDSP_DEBUG) (FnIpsDebug) &IPS_debug /* FXN_DEBUG : Debug function for the IPS */ #endif /* if defined (DDSP_DEBUG) */ } } ; #endif /* if (!defined (ONLY_PROC_COMPONENT)) */ #if defined (POOL_COMPONENT) EXTERN FnPoolInit SMAPOOL_init ; EXTERN FnPoolExit SMAPOOL_exit ; EXTERN POOL_Interface SMAPOOL_Interface ; #if defined (PCPY_LINK) EXTERN FnPoolInit BUFPOOL_init ; EXTERN FnPoolExit BUFPOOL_exit ; EXTERN POOL_Interface BUFPOOL_Interface ; #endif /* if defined (PCPY_LINK) */ CONST CFGMAP_Pool <API key> [] = { { "SMAPOOL", /* NAME : Name of the pool */ (FnPoolInit) &SMAPOOL_init, /* FXN_INIT : Init function for the pool */ (FnPoolExit) &SMAPOOL_exit, /* FXN_EXIT : Exit function for the pool */ &SMAPOOL_Interface /* INTERFACE : Pool interface table */ }, #if defined (PCPY_LINK) { "BUFPOOL", /* NAME : Name of the pool */ (FnPoolInit) &BUFPOOL_init, /* FXN_INIT : Init function for the pool */ (FnPoolExit) &BUFPOOL_exit, /* FXN_EXIT : Exit function for the pool */ &BUFPOOL_Interface /* INTERFACE : Pool interface table */ } #endif /* if defined (PCPY_LINK) */ } ; #endif /* if defined (POOL_COMPONENT) */ #if defined (CHNL_COMPONENT) EXTERN DATA_Interface ZCPYDATA_Interface ; CONST CFGMAP_DataDrv <API key> [] = { { "ZCPYDATA", /* NAME : Name of the data driver */ &ZCPYDATA_Interface /* INTERFACE : Data transfer interface table */ } } ; #endif /* if defined (CHNL_COMPONENT) */ #if defined (MSGQ_COMPONENT) EXTERN MQT_Interface ZCPYMQT_Interface ; CONST CFGMAP_Mqt <API key> [] = { { "ZCPYMQT", /* NAME : Name of the Message Queue Transport */ &ZCPYMQT_Interface /* INTERFACE : MQT Interface table */ } } ; #endif /* if defined (MSGQ_COMPONENT) */ CFGMAP_Object ZSP800MMAP_Config = { 1, /* NUMDSPS : Number of types of DSPs */ (CFGMAP_Dsp *) <API key>, /* DSPOBJECTS : Array of DSP configuration mapping objects */ 1, /* NUMLOADERS : Number of types of DSP executable loaders */ (CFGMAP_Loader *) <API key>, /* LOADERS : Array of DSP executable loader configuration mapping objects */ #if (!defined (ONLY_PROC_COMPONENT)) 1, /* NUMLINKDRVS : Number of types of link drivers */ (CFGMAP_LinkDrv *) <API key>, /* LINKDRVOBJECTS : Array of Link Driver configuration mapping objects */ 1, /* NUMIPS : Number of types of IPS */ (CFGMAP_Ips *) <API key>, /* IPSOBJECTS : Array of IPS configuration mapping objects */ #else 0, /* NUMLINKDRVS : Number of types of link drivers */ NULL, /* LINKDRVOBJECTS : Array of Link Driver configuration mapping objects */ 0, /* NUMIPS : Number of types of IPS */ NULL, /* IPSOBJECTS : Array of IPS configuration mapping objects */ #endif /* if (!defined (ONLY_PROC_COMPONENT)) */ #if defined (POOL_COMPONENT) 1, /* NUMPOOLS : Number of types of POOLs */ (CFGMAP_Pool *) <API key>, /* POOLOBJECTS : Array of POOL configuration mapping objects */ #endif /* if defined (POOL_COMPONENT) */ #if defined (CHNL_COMPONENT) 1, /* NUMDATADRIVERS : Number of types of Data drivers */ (CFGMAP_DataDrv *) <API key>, /* DATADRIVERS : Array of Data driver configuration mapping objects */ #endif /* if defined (CHNL_COMPONENT) */ #if defined (MSGQ_COMPONENT) 1, /* NUMMQTS : Number of types of MQTs */ (CFGMAP_Mqt *) <API key> /* MQTOBJECTS : Array of MQT configuration mapping objects */ #endif /* if defined (MSGQ_COMPONENT) */ } ; #if defined (__cplusplus) } #endif /* defined (__cplusplus) */
<?php $consumer_key = $_GET['1']; $consumer_secret = $_GET['2']; $oauth_access_token = $_GET['3']; $o<API key> = $_GET['4']; switch($_GET['url']) { case 'timeline': $rest = 'statuses/user_timeline' ; $params = Array('count' => $_GET['count'], 'include_rts' => $_GET['include_rts'], 'exclude_replies' => $_GET['exclude_replies'], 'screen_name' => $_GET['screen_name']); break; case 'search': $rest = "search/tweets"; $params = Array('q' => $_GET['q'], 'count' => $_GET['count'], 'include_rts' => $_GET['include_rts']); break; case 'list': $rest = "lists/statuses"; $params = Array('list_id' => $_GET['list_id'], 'count' => $_GET['count'], 'include_rts' => $_GET['include_rts']); break; default: $rest = 'statuses/user_timeline' ; $params = Array('count' => '20'); break; } $auth = new dcsnt_TwitterOAuth($consumer_key,$consumer_secret,$oauth_access_token,$o<API key>); $get = $auth->get( $rest, $params ); if( ! $get ) { echo 'An error occurs while reading the feed, please check your connection or settings'; } if( isset( $get->errors ) ) { // foreach( $get->errors as $key => $val ) echo $val; echo 'errors'; //print_r($get->errors); } else { echo $get; } /** * Twitter OAuth class */ class dcsnt_TwitterOAuth { /* Contains the last HTTP status code returned. */ public $http_code; /* Contains the last API call. */ public $url; /* Set up the API root URL. */ public $host = "https://api.twitter.com/1.1/"; /* Set timeout default. */ public $timeout = 30; /* Set connect timeout. */ public $connecttimeout = 30; /* Verify SSL Cert. */ public $ssl_verifypeer = FALSE; /* Respons format. */ public $format = 'json'; /* Decode returned json data. */ public $decode_json = false; /* Contains the last HTTP headers returned. */ public $http_info; /* Set the useragnet. */ public $useragent = 'TwitterOAuth v0.2.0-beta2'; /* Immediately retry the API call if the response was not successful. */ //public $retry = TRUE; /** * Set API URLS */ function accessTokenURL() { return 'https://api.twitter.com/oauth/access_token'; } function authenticateURL() { return 'https://api.twitter.com/oauth/authenticate'; } function authorizeURL() { return 'https://api.twitter.com/oauth/authorize'; } function requestTokenURL() { return 'https://api.twitter.com/oauth/request_token'; } /** * Debug helpers */ function lastStatusCode() { return $this->http_status; } function lastAPICall() { return $this->last_api_call; } /** * construct TwitterOAuth object */ function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) { $this->sha1_method = new dcsnt_O<API key>(); $this->consumer = new dcsnt_OAuthConsumer($consumer_key, $consumer_secret); if (!empty($oauth_token) && !empty($oauth_token_secret)) { $this->token = new dcsnt_OAuthConsumer($oauth_token, $oauth_token_secret); } else { $this->token = NULL; } } /** * Get a request_token from Twitter * * @returns a key/value array containing oauth_token and oauth_token_secret */ function getRequestToken($oauth_callback = NULL) { $parameters = array(); if (!empty($oauth_callback)) { $parameters['oauth_callback'] = $oauth_callback; } $request = $this->dcsnt_OAuthRequest($this->requestTokenURL(), 'GET', $parameters); $token = dcsnt_OAuthUtil::parse_parameters($request); $this->token = new dcsnt_OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']); return $token; } /** * Get the authorize URL * * @returns a string */ function getAuthorizeURL($token, $<API key> = TRUE) { if (is_array($token)) { $token = $token['oauth_token']; } if (empty($<API key>)) { return $this->authorizeURL() . "?oauth_token={$token}"; } else { return $this->authenticateURL() . "?oauth_token={$token}"; } } /** * Exchange request token and secret for an access token and * secret, to sign API calls. * * @returns array("oauth_token" => "the-access-token", * "oauth_token_secret" => "the-access-secret", * "user_id" => "9436992", * "screen_name" => "abraham") */ function getAccessToken($oauth_verifier = FALSE) { $parameters = array(); if (!empty($oauth_verifier)) { $parameters['oauth_verifier'] = $oauth_verifier; } $request = $this->dcsnt_OAuthRequest($this->accessTokenURL(), 'GET', $parameters); $token = dcsnt_OAuthUtil::parse_parameters($request); $this->token = new dcsnt_OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']); return $token; } /** * One time exchange of username and password for access token and secret. * * @returns array("oauth_token" => "the-access-token", * "oauth_token_secret" => "the-access-secret", * "user_id" => "9436992", * "screen_name" => "abraham", * "x_auth_expires" => "0") */ function getXAuthToken($username, $password) { $parameters = array(); $parameters['x_auth_username'] = $username; $parameters['x_auth_password'] = $password; $parameters['x_auth_mode'] = 'client_auth'; $request = $this->dcsnt_OAuthRequest($this->accessTokenURL(), 'POST', $parameters); $token = dcsnt_OAuthUtil::parse_parameters($request); $this->token = new dcsnt_OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']); return $token; } /** * GET wrapper for dcsnt_OAuthRequest. */ function get($url, $parameters = array()) { $response = $this->dcsnt_OAuthRequest($url, 'GET', $parameters); if ($this->format === 'json' && $this->decode_json) { return json_decode($response); } return $response; } /** * POST wrapper for dcsnt_OAuthRequest. */ function post($url, $parameters = array()) { $response = $this->dcsnt_OAuthRequest($url, 'POST', $parameters); if ($this->format === 'json' && $this->decode_json) { return json_decode($response); } return $response; } /** * DELETE wrapper for oAuthReqeust. */ function delete($url, $parameters = array()) { $response = $this->dcsnt_OAuthRequest($url, 'DELETE', $parameters); if ($this->format === 'json' && $this->decode_json) { return json_decode($response); } return $response; } /** * Format and sign an OAuth / API request */ function dcsnt_OAuthRequest($url, $method, $parameters) { if (strrpos($url, 'https: $url = "{$this->host}{$url}.{$this->format}"; } $request = dcsnt_OAuthRequest::<API key>($this->consumer, $this->token, $method, $url, $parameters); $request->sign_request($this->sha1_method, $this->consumer, $this->token); switch ($method) { case 'GET': return $this->http($request->to_url(), 'GET'); default: return $this->http($request-><API key>(), $method, $request->to_postdata()); } } /** * Make an HTTP request * * @return API results */ function http($url, $method, $postfields = NULL) { $this->http_info = array(); $ci = curl_init(); /* Curl settings */ curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent); curl_setopt($ci, <API key>, $this->connecttimeout); curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($ci, <API key>, TRUE); curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ci, <API key>, $this->ssl_verifypeer); curl_setopt($ci, <API key>, array($this, 'getHeader')); curl_setopt($ci, CURLOPT_HEADER, FALSE); switch ($method) { case 'POST': curl_setopt($ci, CURLOPT_POST, TRUE); if (!empty($postfields)) { curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } break; case 'DELETE': curl_setopt($ci, <API key>, 'DELETE'); if (!empty($postfields)) { $url = "{$url}?{$postfields}"; } } curl_setopt($ci, CURLOPT_URL, $url); $response = curl_exec($ci); $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE); $this->http_info = array_merge($this->http_info, curl_getinfo($ci)); $this->url = $url; curl_close ($ci); return $response; } /** * Get the header info to store. */ function getHeader($ch, $header) { $i = strpos($header, ':'); if (!empty($i)) { $key = str_replace('-', '_', strtolower(substr($header, 0, $i))); $value = trim(substr($header, $i + 2)); $this->http_header[$key] = $value; } return strlen($header); } } // vim: foldmethod=marker /* Generic exception class */ class <API key> extends Exception { // pass } class dcsnt_OAuthConsumer { public $key; public $secret; function __construct($key, $secret, $callback_url=NULL) { $this->key = $key; $this->secret = $secret; $this->callback_url = $callback_url; } function __toString() { return "OAuthConsumer[key=$this->key,secret=$this->secret]"; } } class dcsnt_OAuthToken { // access tokens and request tokens public $key; public $secret; /** * key = the token * secret = the token secret */ function __construct($key, $secret) { $this->key = $key; $this->secret = $secret; } /** * generates the basic string serialization of a token that a server * would respond to request_token and access_token calls with */ function to_string() { return "oauth_token=" . dcsnt_OAuthUtil::urlencode_rfc3986($this->key) . "&oauth_token_secret=" . dcsnt_OAuthUtil::urlencode_rfc3986($this->secret); } function __toString() { return $this->to_string(); } } /** * A class for implementing a Signature Method * See section 9 ("Signing Requests") in the spec */ abstract class <API key> { /** * Needs to return the name of the Signature Method (ie HMAC-SHA1) * @return string */ abstract public function get_name(); /** * Build up the signature * NOTE: The output of this function MUST NOT be urlencoded. * the encoding is handled in dcsnt_OAuthRequest when the final * request is serialized * @param dcsnt_OAuthRequest $request * @param OAuthConsumer $consumer * @param dcsnt_OAuthToken $token * @return string */ abstract public function build_signature($request, $consumer, $token); /** * Verifies that a given signature is correct * @param dcsnt_OAuthRequest $request * @param OAuthConsumer $consumer * @param dcsnt_OAuthToken $token * @param string $signature * @return bool */ public function check_signature($request, $consumer, $token, $signature) { $built = $this->build_signature($request, $consumer, $token); return $built == $signature; } } /** * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104] * where the Signature Base String is the text and the key is the concatenated values (each first * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&' * character (ASCII code 38) even if empty. * - Chapter 9.2 ("HMAC-SHA1") */ class dcsnt_O<API key> extends <API key> { function get_name() { return "HMAC-SHA1"; } public function build_signature($request, $consumer, $token) { $base_string = $request-><API key>(); $request->base_string = $base_string; $key_parts = array( $consumer->secret, ($token) ? $token->secret : "" ); $key_parts = dcsnt_OAuthUtil::urlencode_rfc3986($key_parts); $key = implode('&', $key_parts); return base64_encode(hash_hmac('sha1', $base_string, $key, true)); } } /** * The PLAINTEXT method does not provide any security protection and SHOULD only be used * over a secure channel such as HTTPS. It does not use the Signature Base String. * - Chapter 9.4 ("PLAINTEXT") */ class dcsnt_O<API key> extends <API key> { public function get_name() { return "PLAINTEXT"; } /** * oauth_signature is set to the concatenated encoded values of the Consumer Secret and * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is * empty. The result MUST be encoded again. * - Chapter 9.4.1 ("Generating Signatures") * * Please note that the second encoding MUST NOT happen in the SignatureMethod, as * dcsnt_OAuthRequest handles this! */ public function build_signature($request, $consumer, $token) { $key_parts = array( $consumer->secret, ($token) ? $token->secret : "" ); $key_parts = dcsnt_OAuthUtil::urlencode_rfc3986($key_parts); $key = implode('&', $key_parts); $request->base_string = $key; return $key; } } /** * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a * verified way to the Service Provider, in a manner which is beyond the scope of this * specification. * - Chapter 9.3 ("RSA-SHA1") */ abstract class dcsnt_O<API key> extends <API key> { public function get_name() { return "RSA-SHA1"; } // Up to the SP to implement this lookup of keys. Possible ideas are: // (1) do a lookup in a table of trusted certs keyed off of consumer // (2) fetch via http using a url provided by the requester // (3) some sort of specific discovery code based on request // Either way should return a string representation of the certificate protected abstract function fetch_public_cert(&$request); // Up to the SP to implement this lookup of keys. Possible ideas are: // (1) do a lookup in a table of trusted certs keyed off of consumer // Either way should return a string representation of the certificate protected abstract function fetch_private_cert(&$request); public function build_signature($request, $consumer, $token) { $base_string = $request-><API key>(); $request->base_string = $base_string; // Fetch the private key cert based on the request $cert = $this->fetch_private_cert($request); // Pull the private key ID from the certificate $privatekeyid = <API key>($cert); // Sign using the key $ok = openssl_sign($base_string, $signature, $privatekeyid); // Release the key resource openssl_free_key($privatekeyid); return base64_encode($signature); } public function check_signature($request, $consumer, $token, $signature) { $decoded_sig = base64_decode($signature); $base_string = $request-><API key>(); // Fetch the public key cert based on the request $cert = $this->fetch_public_cert($request); // Pull the public key ID from the certificate $publickeyid = <API key>($cert); // Check the computed signature against the one passed in the query $ok = openssl_verify($base_string, $decoded_sig, $publickeyid); // Release the key resource openssl_free_key($publickeyid); return $ok == 1; } } class dcsnt_OAuthRequest { private $parameters; private $http_method; private $http_url; // for debug purposes public $base_string; public static $version = '1.0'; public static $POST_INPUT = 'php://input'; function __construct($http_method, $http_url, $parameters=NULL) { @$parameters or $parameters = array(); $parameters = array_merge( dcsnt_OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters); $this->parameters = $parameters; $this->http_method = $http_method; $this->http_url = $http_url; } /** * attempt to build up a request from what was passed to the server */ public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) { $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") ? 'http' : 'https'; @$http_url or $http_url = $scheme . '://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; @$http_method or $http_method = $_SERVER['REQUEST_METHOD']; // We weren't handed any parameters, so let's find the ones relevant to // this request. // If you run XML-RPC or similar you should use this to provide your own // parsed parameter-list if (!$parameters) { // Find request headers $request_headers = dcsnt_OAuthUtil::get_headers(); // Parse the query-string to find GET parameters $parameters = dcsnt_OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']); // It's a POST request of the proper content-type, so parse POST // parameters and add those overriding any duplicates from GET if ($http_method == "POST" && @strstr($request_headers["Content-Type"], "application/<API key>") ) { $post_data = dcsnt_OAuthUtil::parse_parameters( file_get_contents(self::$POST_INPUT) ); $parameters = array_merge($parameters, $post_data); } // We have a <API key> with OAuth data. Parse the header // and add those overriding any duplicates from GET or POST if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") { $header_parameters = dcsnt_OAuthUtil::split_header( $request_headers['Authorization'] ); $parameters = array_merge($parameters, $header_parameters); } } return new dcsnt_OAuthRequest($http_method, $http_url, $parameters); } /** * pretty much a helper function to set up the request */ public static function <API key>($consumer, $token, $http_method, $http_url, $parameters=NULL) { @$parameters or $parameters = array(); $defaults = array("oauth_version" => dcsnt_OAuthRequest::$version, "oauth_nonce" => dcsnt_OAuthRequest::generate_nonce(), "oauth_timestamp" => dcsnt_OAuthRequest::generate_timestamp(), "oauth_consumer_key" => $consumer->key); if ($token) $defaults['oauth_token'] = $token->key; $parameters = array_merge($defaults, $parameters); return new dcsnt_OAuthRequest($http_method, $http_url, $parameters); } public function set_parameter($name, $value, $allow_duplicates = true) { if ($allow_duplicates && isset($this->parameters[$name])) { // We have already added parameter(s) with this name, so add to the list if (is_scalar($this->parameters[$name])) { // This is the first duplicate, so transform scalar (string) // into an array so we can add the duplicates $this->parameters[$name] = array($this->parameters[$name]); } $this->parameters[$name][] = $value; } else { $this->parameters[$name] = $value; } } public function get_parameter($name) { return isset($this->parameters[$name]) ? $this->parameters[$name] : null; } public function get_parameters() { return $this->parameters; } public function unset_parameter($name) { unset($this->parameters[$name]); } /** * The request parameters, sorted and concatenated into a normalized string. * @return string */ public function <API key>() { // Grab all parameters $params = $this->parameters; // Remove oauth_signature if present // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.") if (isset($params['oauth_signature'])) { unset($params['oauth_signature']); } return dcsnt_OAuthUtil::build_http_query($params); } /** * Returns the base string of this request * * The base string defined as the method, the url * and the parameters (normalized), each urlencoded * and the concated with &. */ public function <API key>() { $parts = array( $this-><API key>(), $this-><API key>(), $this-><API key>() ); $parts = dcsnt_OAuthUtil::urlencode_rfc3986($parts); return implode('&', $parts); } /** * just uppercases the http method */ public function <API key>() { return strtoupper($this->http_method); } /** * parses the url and rebuilds it to be * scheme://host/path */ public function <API key>() { $parts = parse_url($this->http_url); $port = @$parts['port']; $scheme = $parts['scheme']; $host = $parts['host']; $path = @$parts['path']; $port or $port = ($scheme == 'https') ? '443' : '80'; if (($scheme == 'https' && $port != '443') || ($scheme == 'http' && $port != '80')) { $host = "$host:$port"; } return "$scheme://$host$path"; } /** * builds a url usable for a GET request */ public function to_url() { $post_data = $this->to_postdata(); $out = $this-><API key>(); if ($post_data) { $out .= '?'.$post_data; } return $out; } /** * builds the data one would send in a POST request */ public function to_postdata() { return dcsnt_OAuthUtil::build_http_query($this->parameters); } /** * builds the Authorization: header */ public function to_header($realm=null) { $first = true; if($realm) { $out = 'Authorization: OAuth realm="' . dcsnt_OAuthUtil::urlencode_rfc3986($realm) . '"'; $first = false; } else $out = 'Authorization: OAuth'; $total = array(); foreach ($this->parameters as $k => $v) { if (substr($k, 0, 5) != "oauth") continue; if (is_array($v)) { throw new <API key>('Arrays not supported in headers'); } $out .= ($first) ? ' ' : ','; $out .= dcsnt_OAuthUtil::urlencode_rfc3986($k) . '="' . dcsnt_OAuthUtil::urlencode_rfc3986($v) . '"'; $first = false; } return $out; } public function __toString() { return $this->to_url(); } public function sign_request($signature_method, $consumer, $token) { $this->set_parameter( "o<API key>, $signature_method->get_name(), false ); $signature = $this->build_signature($signature_method, $consumer, $token); $this->set_parameter("oauth_signature", $signature, false); } public function build_signature($signature_method, $consumer, $token) { $signature = $signature_method->build_signature($this, $consumer, $token); return $signature; } /** * util function: current timestamp */ private static function generate_timestamp() { return time(); } /** * util function: current nonce */ private static function generate_nonce() { $mt = microtime(); $rand = mt_rand(); return md5($mt . $rand); // md5s look nicer than numbers } } class dcsnt_OAuthServer { protected $timestamp_threshold = 300; // in seconds, five minutes protected $version = '1.0'; // hi blaine protected $signature_methods = array(); protected $data_store; function __construct($data_store) { $this->data_store = $data_store; } public function <API key>($signature_method) { $this->signature_methods[$signature_method->get_name()] = $signature_method; } // high level functions /** * process a request_token request * returns the request token on success */ public function fetch_request_token(&$request) { $this->get_version($request); $consumer = $this->get_consumer($request); // no token required for the initial token request $token = NULL; $this->check_signature($request, $consumer, $token); // Rev A change $callback = $request->get_parameter('oauth_callback'); $new_token = $this->data_store->new_request_token($consumer, $callback); return $new_token; } /** * process an access_token request * returns the access token on success */ public function fetch_access_token(&$request) { $this->get_version($request); $consumer = $this->get_consumer($request); // requires authorized request token $token = $this->get_token($request, $consumer, "request"); $this->check_signature($request, $consumer, $token); // Rev A change $verifier = $request->get_parameter('oauth_verifier'); $new_token = $this->data_store->new_access_token($token, $consumer, $verifier); return $new_token; } /** * verify an api call, checks all the parameters */ public function verify_request(&$request) { $this->get_version($request); $consumer = $this->get_consumer($request); $token = $this->get_token($request, $consumer, "access"); $this->check_signature($request, $consumer, $token); return array($consumer, $token); } // Internals from here /** * version 1 */ private function get_version(&$request) { $version = $request->get_parameter("oauth_version"); if (!$version) { // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present. // Chapter 7.0 ("Accessing Protected Ressources") $version = '1.0'; } if ($version !== $this->version) { throw new <API key>("OAuth version '$version' not supported"); } return $version; } /** * figure out the signature with some defaults */ private function <API key>(&$request) { $signature_method = @$request->get_parameter("o<API key>); if (!$signature_method) { // According to chapter 7 ("Accessing Protected Ressources") the signature-method // parameter is required, and we can't just fallback to PLAINTEXT throw new <API key>('No signature method parameter. This parameter is required'); } if (!in_array($signature_method, array_keys($this->signature_methods))) { throw new <API key>( "Signature method '$signature_method' not supported " . "try one of the following: " . implode(", ", array_keys($this->signature_methods)) ); } return $this->signature_methods[$signature_method]; } /** * try to find the consumer for the provided request's consumer key */ private function get_consumer(&$request) { $consumer_key = @$request->get_parameter("oauth_consumer_key"); if (!$consumer_key) { throw new <API key>("Invalid consumer key"); } $consumer = $this->data_store->lookup_consumer($consumer_key); if (!$consumer) { throw new <API key>("Invalid consumer"); } return $consumer; } /** * try to find the token for the provided request's token key */ private function get_token(&$request, $consumer, $token_type="access") { $token_field = @$request->get_parameter('oauth_token'); $token = $this->data_store->lookup_token( $consumer, $token_type, $token_field ); if (!$token) { throw new <API key>("Invalid $token_type token: $token_field"); } return $token; } /** * all-in-one function to check the signature on a request * should guess the signature method appropriately */ private function check_signature(&$request, $consumer, $token) { // this should probably be in a different method $timestamp = @$request->get_parameter('oauth_timestamp'); $nonce = @$request->get_parameter('oauth_nonce'); $this->check_timestamp($timestamp); $this->check_nonce($consumer, $token, $nonce, $timestamp); $signature_method = $this-><API key>($request); $signature = $request->get_parameter('oauth_signature'); $valid_sig = $signature_method->check_signature( $request, $consumer, $token, $signature ); if (!$valid_sig) { throw new <API key>("Invalid signature"); } } /** * check that the timestamp is new enough */ private function check_timestamp($timestamp) { if( ! $timestamp ) throw new <API key>( 'Missing timestamp parameter. The parameter is required' ); // verify that timestamp is recentish $now = time(); if (abs($now - $timestamp) > $this->timestamp_threshold) { throw new <API key>( "Expired timestamp, yours $timestamp, ours $now" ); } } /** * check that the nonce is not repeated */ private function check_nonce($consumer, $token, $nonce, $timestamp) { if( ! $nonce ) throw new <API key>( 'Missing nonce parameter. The parameter is required' ); // verify that the nonce is uniqueish $found = $this->data_store->lookup_nonce( $consumer, $token, $nonce, $timestamp ); if ($found) { throw new <API key>("Nonce already used: $nonce"); } } } class <API key> { function lookup_consumer($consumer_key) { // implement me } function lookup_token($consumer, $token_type, $token) { // implement me } function lookup_nonce($consumer, $token, $nonce, $timestamp) { // implement me } function new_request_token($consumer, $callback = null) { // return a new token attached to this consumer } function new_access_token($token, $consumer, $verifier = null) { // return a new access token attached to this consumer // for the user associated with this token if the request token // is authorized // should also invalidate the request token } } class dcsnt_OAuthUtil { public static function urlencode_rfc3986($input) { if (is_array($input)) { return array_map(array('dcsnt_OAuthUtil', 'urlencode_rfc3986'), $input); } else if (is_scalar($input)) { return str_replace( '+', ' ', str_replace('%7E', '~', rawurlencode($input)) ); } else { return ''; } } // This decode function isn't taking into consideration the above // modifications to the encoding process. However, this method doesn't // seem to be used anywhere so leaving it as is. public static function urldecode_rfc3986($string) { return urldecode($string); } // Utility function for turning the Authorization: header into // parameters, has to do some unescaping // Can filter out any non-oauth parameters if needed (default behaviour) public static function split_header($header, $<API key> = true) { $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/'; $offset = 0; $params = array(); while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) { $match = $matches[0]; $header_name = $matches[2][0]; $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0]; if (preg_match('/^oauth_/', $header_name) || !$<API key>) { $params[$header_name] = dcsnt_OAuthUtil::urldecode_rfc3986($header_content); } $offset = $match[1] + strlen($match[0]); } if (isset($params['realm'])) { unset($params['realm']); } return $params; } // helper to try to sort out headers for people who aren't running apache public static function get_headers() { if (function_exists('<API key>')) { // we need this to get the actual Authorization: header // because apache tends to tell us it doesn't exist $headers = <API key>(); // sanitize the output of <API key> because // we always want the keys to be Cased-Like-This and arh() // returns the headers in the same case as they are in the // request $out = array(); foreach( $headers AS $key => $value ) { $key = str_replace( " ", "-", ucwords(strtolower(str_replace("-", " ", $key))) ); $out[$key] = $value; } } else { // otherwise we don't have apache and are just going to have to hope // that $_SERVER actually contains what we need $out = array(); if( isset($_SERVER['CONTENT_TYPE']) ) $out['Content-Type'] = $_SERVER['CONTENT_TYPE']; if( isset($_ENV['CONTENT_TYPE']) ) $out['Content-Type'] = $_ENV['CONTENT_TYPE']; foreach ($_SERVER as $key => $value) { if (substr($key, 0, 5) == "HTTP_") { // this is chaos, basically it is just there to capitalize the first // letter of every word that is not an initial HTTP and strip HTTP // code from przemek $key = str_replace( " ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))) ); $out[$key] = $value; } } } return $out; } // This function takes a input like a=b&a=c&d=e and returns the parsed // parameters like this // array('a' => array('b','c'), 'd' => 'e') public static function parse_parameters( $input ) { if (!isset($input) || !$input) return array(); $pairs = explode('&', $input); $parsed_parameters = array(); foreach ($pairs as $pair) { $split = explode('=', $pair, 2); $parameter = dcsnt_OAuthUtil::urldecode_rfc3986($split[0]); $value = isset($split[1]) ? dcsnt_OAuthUtil::urldecode_rfc3986($split[1]) : ''; if (isset($parsed_parameters[$parameter])) { // We have already recieved parameter(s) with this name, so add to the list // of parameters with this name if (is_scalar($parsed_parameters[$parameter])) { // This is the first duplicate, so transform scalar (string) into an array // so we can add the duplicates $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]); } $parsed_parameters[$parameter][] = $value; } else { $parsed_parameters[$parameter] = $value; } } return $parsed_parameters; } public static function build_http_query($params) { if (!$params) return ''; // Urlencode both keys and values $keys = dcsnt_OAuthUtil::urlencode_rfc3986(array_keys($params)); $values = dcsnt_OAuthUtil::urlencode_rfc3986(array_values($params)); $params = array_combine($keys, $values); // Parameters are sorted by name, using lexicographical byte value ordering. // Ref: Spec: 9.1.1 (1) uksort($params, 'strcmp'); $pairs = array(); foreach ($params as $parameter => $value) { if (is_array($value)) { // If two or more parameters share the same name, they are sorted by their value // Ref: Spec: 9.1.1 (1) natsort($value); foreach ($value as $duplicate_value) { $pairs[] = $parameter . '=' . $duplicate_value; } } else { $pairs[] = $parameter . '=' . $value; } } // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61) // Each name-value pair is separated by an '&' character (ASCII code 38) return implode('&', $pairs); } } ?>
#if !defined(<API key>) || defined(<API key>) #define <API key> #include <linux/tracepoint.h> #include <net/mac80211.h> #include "ieee80211_i.h" #undef TRACE_SYSTEM #define TRACE_SYSTEM mac80211 #define MAXNAME 32 #define LOCAL_ENTRY __array(char, wiphy_name, 32) #define LOCAL_ASSIGN strlcpy(__entry->wiphy_name, wiphy_name(local->hw.wiphy), MAXNAME) #define LOCAL_PR_FMT "%s" #define LOCAL_PR_ARG __entry->wiphy_name #define STA_ENTRY __array(char, sta_addr, ETH_ALEN) #define STA_ASSIGN (sta ? memcpy(__entry->sta_addr, sta->addr, ETH_ALEN) : memset(__entry->sta_addr, 0, ETH_ALEN)) #define STA_PR_FMT " sta:%pM" #define STA_PR_ARG __entry->sta_addr #define VIF_ENTRY __field(enum nl80211_iftype, vif_type) __field(void *, sdata) \ __field(bool, p2p) \ __string(vif_name, sdata->dev ? sdata->dev->name : "<nodev>") #define VIF_ASSIGN __entry->vif_type = sdata->vif.type; __entry->sdata = sdata; \ __entry->p2p = sdata->vif.p2p; \ __assign_str(vif_name, sdata->dev ? sdata->dev->name : "<nodev>") #define VIF_PR_FMT " vif:%s(%d%s)" #define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : "" /* * Tracing for driver callbacks. */ DECLARE_EVENT_CLASS(local_only_evt, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local), TP_STRUCT__entry( LOCAL_ENTRY ), TP_fast_assign( LOCAL_ASSIGN; ), TP_printk(LOCAL_PR_FMT, LOCAL_PR_ARG) ); DECLARE_EVENT_CLASS(<API key>, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY __array(char, addr, 6) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; memcpy(__entry->addr, sdata->vif.addr, 6); ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT " addr:%pM", LOCAL_PR_ARG, VIF_PR_ARG, __entry->addr ) ); DECLARE_EVENT_CLASS(local_u32_evt, TP_PROTO(struct ieee80211_local *local, u32 value), TP_ARGS(local, value), TP_STRUCT__entry( LOCAL_ENTRY __field(u32, value) ), TP_fast_assign( LOCAL_ASSIGN; __entry->value = value; ), TP_printk( LOCAL_PR_FMT " value:%d", LOCAL_PR_ARG, __entry->value ) ); DECLARE_EVENT_CLASS(local_sdata_evt, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT, LOCAL_PR_ARG, VIF_PR_ARG ) ); DEFINE_EVENT(local_only_evt, drv_return_void, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); TRACE_EVENT(drv_return_int, TP_PROTO(struct ieee80211_local *local, int ret), TP_ARGS(local, ret), TP_STRUCT__entry( LOCAL_ENTRY __field(int, ret) ), TP_fast_assign( LOCAL_ASSIGN; __entry->ret = ret; ), TP_printk(LOCAL_PR_FMT " - %d", LOCAL_PR_ARG, __entry->ret) ); TRACE_EVENT(drv_return_bool, TP_PROTO(struct ieee80211_local *local, bool ret), TP_ARGS(local, ret), TP_STRUCT__entry( LOCAL_ENTRY __field(bool, ret) ), TP_fast_assign( LOCAL_ASSIGN; __entry->ret = ret; ), TP_printk(LOCAL_PR_FMT " - %s", LOCAL_PR_ARG, (__entry->ret) ? "true" : "false") ); TRACE_EVENT(drv_return_u64, TP_PROTO(struct ieee80211_local *local, u64 ret), TP_ARGS(local, ret), TP_STRUCT__entry( LOCAL_ENTRY __field(u64, ret) ), TP_fast_assign( LOCAL_ASSIGN; __entry->ret = ret; ), TP_printk(LOCAL_PR_FMT " - %llu", LOCAL_PR_ARG, __entry->ret) ); DEFINE_EVENT(local_only_evt, drv_start, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); DEFINE_EVENT(local_only_evt, drv_suspend, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); DEFINE_EVENT(local_only_evt, drv_resume, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); TRACE_EVENT(drv_set_wakeup, TP_PROTO(struct ieee80211_local *local, bool enabled), TP_ARGS(local, enabled), TP_STRUCT__entry( LOCAL_ENTRY __field(bool, enabled) ), TP_fast_assign( LOCAL_ASSIGN; __entry->enabled = enabled; ), TP_printk(LOCAL_PR_FMT " enabled:%d", LOCAL_PR_ARG, __entry->enabled) ); DEFINE_EVENT(local_only_evt, drv_stop, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); DEFINE_EVENT(<API key>, drv_add_interface, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, enum nl80211_iftype type, bool p2p), TP_ARGS(local, sdata, type, p2p), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY __field(u32, new_type) __field(bool, new_p2p) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; __entry->new_type = type; __entry->new_p2p = p2p; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT " new type:%d%s", LOCAL_PR_ARG, VIF_PR_ARG, __entry->new_type, __entry->new_p2p ? "/p2p" : "" ) ); DEFINE_EVENT(<API key>, <API key>, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata) ); TRACE_EVENT(drv_config, TP_PROTO(struct ieee80211_local *local, u32 changed), TP_ARGS(local, changed), TP_STRUCT__entry( LOCAL_ENTRY __field(u32, changed) __field(u32, flags) __field(int, power_level) __field(int, dynamic_ps_timeout) __field(int, max_sleep_period) __field(u16, listen_interval) __field(u8, <API key>) __field(u8, <API key>) __field(int, center_freq) __field(int, channel_type) __field(int, smps) ), TP_fast_assign( LOCAL_ASSIGN; __entry->changed = changed; __entry->flags = local->hw.conf.flags; __entry->power_level = local->hw.conf.power_level; __entry->dynamic_ps_timeout = local->hw.conf.dynamic_ps_timeout; __entry->max_sleep_period = local->hw.conf.max_sleep_period; __entry->listen_interval = local->hw.conf.listen_interval; __entry-><API key> = local->hw.conf.<API key>; __entry-><API key> = local->hw.conf.<API key>; __entry->center_freq = local->hw.conf.channel->center_freq; __entry->channel_type = local->hw.conf.channel_type; __entry->smps = local->hw.conf.smps_mode; ), TP_printk( LOCAL_PR_FMT " ch:%#x freq:%d", LOCAL_PR_ARG, __entry->changed, __entry->center_freq ) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, struct ieee80211_bss_conf *info, u32 changed), TP_ARGS(local, sdata, info, changed), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY __field(bool, assoc) __field(u16, aid) __field(bool, cts) __field(bool, shortpre) __field(bool, shortslot) __field(u8, dtimper) __field(u16, bcnint) __field(u16, assoc_cap) __field(u64, timestamp) __field(u32, basic_rates) __field(u32, changed) __field(bool, enable_beacon) __field(u16, ht_operation_mode) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; __entry->changed = changed; __entry->aid = info->aid; __entry->assoc = info->assoc; __entry->shortpre = info->use_short_preamble; __entry->cts = info->use_cts_prot; __entry->shortslot = info->use_short_slot; __entry->dtimper = info->dtim_period; __entry->bcnint = info->beacon_int; __entry->assoc_cap = info->assoc_capability; __entry->timestamp = info->last_tsf; __entry->basic_rates = info->basic_rates; __entry->enable_beacon = info->enable_beacon; __entry->ht_operation_mode = info->ht_operation_mode; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT " changed:% LOCAL_PR_ARG, VIF_PR_ARG, __entry->changed ) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local, int mc_count), TP_ARGS(local, mc_count), TP_STRUCT__entry( LOCAL_ENTRY __field(int, mc_count) ), TP_fast_assign( LOCAL_ASSIGN; __entry->mc_count = mc_count; ), TP_printk( LOCAL_PR_FMT " prepare mc (%d)", LOCAL_PR_ARG, __entry->mc_count ) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local, unsigned int changed_flags, unsigned int *total_flags, u64 multicast), TP_ARGS(local, changed_flags, total_flags, multicast), TP_STRUCT__entry( LOCAL_ENTRY __field(unsigned int, changed) __field(unsigned int, total) __field(u64, multicast) ), TP_fast_assign( LOCAL_ASSIGN; __entry->changed = changed_flags; __entry->total = *total_flags; __entry->multicast = multicast; ), TP_printk( LOCAL_PR_FMT " changed:%#x total:%#x", LOCAL_PR_ARG, __entry->changed, __entry->total ) ); TRACE_EVENT(drv_set_tim, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sta *sta, bool set), TP_ARGS(local, sta, set), TP_STRUCT__entry( LOCAL_ENTRY STA_ENTRY __field(bool, set) ), TP_fast_assign( LOCAL_ASSIGN; STA_ASSIGN; __entry->set = set; ), TP_printk( LOCAL_PR_FMT STA_PR_FMT " set:%d", LOCAL_PR_ARG, STA_PR_FMT, __entry->set ) ); TRACE_EVENT(drv_set_key, TP_PROTO(struct ieee80211_local *local, enum set_key_cmd cmd, struct <API key> *sdata, struct ieee80211_sta *sta, struct ieee80211_key_conf *key), TP_ARGS(local, cmd, sdata, sta, key), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY STA_ENTRY __field(u32, cipher) __field(u8, hw_key_idx) __field(u8, flags) __field(s8, keyidx) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; STA_ASSIGN; __entry->cipher = key->cipher; __entry->flags = key->flags; __entry->keyidx = key->keyidx; __entry->hw_key_idx = key->hw_key_idx; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT, LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG ) ); TRACE_EVENT(drv_update_tkip_key, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, struct ieee80211_key_conf *conf, struct ieee80211_sta *sta, u32 iv32), TP_ARGS(local, sdata, conf, sta, iv32), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY STA_ENTRY __field(u32, iv32) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; STA_ASSIGN; __entry->iv32 = iv32; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " iv32:% LOCAL_PR_ARG,VIF_PR_ARG,STA_PR_ARG, __entry->iv32 ) ); DEFINE_EVENT(local_sdata_evt, drv_hw_scan, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata) ); DEFINE_EVENT(local_sdata_evt, drv_cancel_hw_scan, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata) ); DEFINE_EVENT(local_sdata_evt, <API key>, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata) ); DEFINE_EVENT(local_sdata_evt, drv_sched_scan_stop, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata) ); DEFINE_EVENT(local_only_evt, drv_sw_scan_start, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); DEFINE_EVENT(local_only_evt, <API key>, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); TRACE_EVENT(drv_get_stats, TP_PROTO(struct ieee80211_local *local, struct <API key> *stats, int ret), TP_ARGS(local, stats, ret), TP_STRUCT__entry( LOCAL_ENTRY __field(int, ret) __field(unsigned int, ackfail) __field(unsigned int, rtsfail) __field(unsigned int, fcserr) __field(unsigned int, rtssucc) ), TP_fast_assign( LOCAL_ASSIGN; __entry->ret = ret; __entry->ackfail = stats-><API key>; __entry->rtsfail = stats-><API key>; __entry->fcserr = stats->dot11FCSErrorCount; __entry->rtssucc = stats-><API key>; ), TP_printk( LOCAL_PR_FMT " ret:%d", LOCAL_PR_ARG, __entry->ret ) ); TRACE_EVENT(drv_get_tkip_seq, TP_PROTO(struct ieee80211_local *local, u8 hw_key_idx, u32 *iv32, u16 *iv16), TP_ARGS(local, hw_key_idx, iv32, iv16), TP_STRUCT__entry( LOCAL_ENTRY __field(u8, hw_key_idx) __field(u32, iv32) __field(u16, iv16) ), TP_fast_assign( LOCAL_ASSIGN; __entry->hw_key_idx = hw_key_idx; __entry->iv32 = *iv32; __entry->iv16 = *iv16; ), TP_printk( LOCAL_PR_FMT, LOCAL_PR_ARG ) ); DEFINE_EVENT(local_u32_evt, <API key>, TP_PROTO(struct ieee80211_local *local, u32 value), TP_ARGS(local, value) ); DEFINE_EVENT(local_u32_evt, <API key>, TP_PROTO(struct ieee80211_local *local, u32 value), TP_ARGS(local, value) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local, u8 value), TP_ARGS(local, value), TP_STRUCT__entry( LOCAL_ENTRY __field(u8, value) ), TP_fast_assign( LOCAL_ASSIGN; __entry->value = value; ), TP_printk( LOCAL_PR_FMT " value:%d", LOCAL_PR_ARG, __entry->value ) ); TRACE_EVENT(drv_sta_notify, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, enum sta_notify_cmd cmd, struct ieee80211_sta *sta), TP_ARGS(local, sdata, cmd, sta), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY STA_ENTRY __field(u32, cmd) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; STA_ASSIGN; __entry->cmd = cmd; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " cmd:%d", LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->cmd ) ); TRACE_EVENT(drv_sta_state, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, struct ieee80211_sta *sta, enum ieee80211_sta_state old_state, enum ieee80211_sta_state new_state), TP_ARGS(local, sdata, sta, old_state, new_state), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY STA_ENTRY __field(u32, old_state) __field(u32, new_state) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; STA_ASSIGN; __entry->old_state = old_state; __entry->new_state = new_state; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " state: %d->%d", LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->old_state, __entry->new_state ) ); TRACE_EVENT(drv_sta_rc_update, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, struct ieee80211_sta *sta, u32 changed), TP_ARGS(local, sdata, sta, changed), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY STA_ENTRY __field(u32, changed) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; STA_ASSIGN; __entry->changed = changed; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " changed: 0x%x", LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->changed ) ); TRACE_EVENT(drv_sta_add, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, struct ieee80211_sta *sta), TP_ARGS(local, sdata, sta), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY STA_ENTRY ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; STA_ASSIGN; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT, LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG ) ); TRACE_EVENT(drv_sta_remove, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, struct ieee80211_sta *sta), TP_ARGS(local, sdata, sta), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY STA_ENTRY ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; STA_ASSIGN; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT, LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG ) ); TRACE_EVENT(drv_conf_tx, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, u16 ac, const struct <API key> *params), TP_ARGS(local, sdata, ac, params), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY __field(u16, ac) __field(u16, txop) __field(u16, cw_min) __field(u16, cw_max) __field(u8, aifs) __field(bool, uapsd) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; __entry->ac = ac; __entry->txop = params->txop; __entry->cw_max = params->cw_max; __entry->cw_min = params->cw_min; __entry->aifs = params->aifs; __entry->uapsd = params->uapsd; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT " AC:%d", LOCAL_PR_ARG, VIF_PR_ARG, __entry->ac ) ); DEFINE_EVENT(local_sdata_evt, drv_get_tsf, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata) ); TRACE_EVENT(drv_set_tsf, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, u64 tsf), TP_ARGS(local, sdata, tsf), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY __field(u64, tsf) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; __entry->tsf = tsf; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT " tsf:%llu", LOCAL_PR_ARG, VIF_PR_ARG, (unsigned long long)__entry->tsf ) ); DEFINE_EVENT(local_sdata_evt, drv_reset_tsf, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata), TP_ARGS(local, sdata) ); DEFINE_EVENT(local_only_evt, drv_tx_last_beacon, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); TRACE_EVENT(drv_ampdu_action, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, enum <API key> action, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size), TP_ARGS(local, sdata, action, sta, tid, ssn, buf_size), TP_STRUCT__entry( LOCAL_ENTRY STA_ENTRY __field(u32, action) __field(u16, tid) __field(u16, ssn) __field(u8, buf_size) VIF_ENTRY ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; STA_ASSIGN; __entry->action = action; __entry->tid = tid; __entry->ssn = ssn ? *ssn : 0; __entry->buf_size = buf_size; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " action:%d tid:%d buf:%d", LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->action, __entry->tid, __entry->buf_size ) ); TRACE_EVENT(drv_get_survey, TP_PROTO(struct ieee80211_local *local, int idx, struct survey_info *survey), TP_ARGS(local, idx, survey), TP_STRUCT__entry( LOCAL_ENTRY __field(int, idx) ), TP_fast_assign( LOCAL_ASSIGN; __entry->idx = idx; ), TP_printk( LOCAL_PR_FMT " idx:%d", LOCAL_PR_ARG, __entry->idx ) ); TRACE_EVENT(drv_flush, TP_PROTO(struct ieee80211_local *local, bool drop), TP_ARGS(local, drop), TP_STRUCT__entry( LOCAL_ENTRY __field(bool, drop) ), TP_fast_assign( LOCAL_ASSIGN; __entry->drop = drop; ), TP_printk( LOCAL_PR_FMT " drop:%d", LOCAL_PR_ARG, __entry->drop ) ); TRACE_EVENT(drv_channel_switch, TP_PROTO(struct ieee80211_local *local, struct <API key> *ch_switch), TP_ARGS(local, ch_switch), TP_STRUCT__entry( LOCAL_ENTRY __field(u64, timestamp) __field(bool, block_tx) __field(u16, freq) __field(u8, count) ), TP_fast_assign( LOCAL_ASSIGN; __entry->timestamp = ch_switch->timestamp; __entry->block_tx = ch_switch->block_tx; __entry->freq = ch_switch->channel->center_freq; __entry->count = ch_switch->count; ), TP_printk( LOCAL_PR_FMT " new freq:%u count:%d", LOCAL_PR_ARG, __entry->freq, __entry->count ) ); TRACE_EVENT(drv_set_antenna, TP_PROTO(struct ieee80211_local *local, u32 tx_ant, u32 rx_ant, int ret), TP_ARGS(local, tx_ant, rx_ant, ret), TP_STRUCT__entry( LOCAL_ENTRY __field(u32, tx_ant) __field(u32, rx_ant) __field(int, ret) ), TP_fast_assign( LOCAL_ASSIGN; __entry->tx_ant = tx_ant; __entry->rx_ant = rx_ant; __entry->ret = ret; ), TP_printk( LOCAL_PR_FMT " tx_ant:%d rx_ant:%d ret:%d", LOCAL_PR_ARG, __entry->tx_ant, __entry->rx_ant, __entry->ret ) ); TRACE_EVENT(drv_get_antenna, TP_PROTO(struct ieee80211_local *local, u32 tx_ant, u32 rx_ant, int ret), TP_ARGS(local, tx_ant, rx_ant, ret), TP_STRUCT__entry( LOCAL_ENTRY __field(u32, tx_ant) __field(u32, rx_ant) __field(int, ret) ), TP_fast_assign( LOCAL_ASSIGN; __entry->tx_ant = tx_ant; __entry->rx_ant = rx_ant; __entry->ret = ret; ), TP_printk( LOCAL_PR_FMT " tx_ant:%d rx_ant:%d ret:%d", LOCAL_PR_ARG, __entry->tx_ant, __entry->rx_ant, __entry->ret ) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local, struct ieee80211_channel *chan, enum <API key> chantype, unsigned int duration), TP_ARGS(local, chan, chantype, duration), TP_STRUCT__entry( LOCAL_ENTRY __field(int, center_freq) __field(int, channel_type) __field(unsigned int, duration) ), TP_fast_assign( LOCAL_ASSIGN; __entry->center_freq = chan->center_freq; __entry->channel_type = chantype; __entry->duration = duration; ), TP_printk( LOCAL_PR_FMT " freq:%dMHz duration:%dms", LOCAL_PR_ARG, __entry->center_freq, __entry->duration ) ); DEFINE_EVENT(local_only_evt, <API key>, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); TRACE_EVENT(drv_offchannel_tx, TP_PROTO(struct ieee80211_local *local, struct sk_buff *skb, struct ieee80211_channel *chan, enum <API key> channel_type, unsigned int wait), TP_ARGS(local, skb, chan, channel_type, wait), TP_STRUCT__entry( LOCAL_ENTRY __field(int, center_freq) __field(int, channel_type) __field(unsigned int, wait) ), TP_fast_assign( LOCAL_ASSIGN; __entry->center_freq = chan->center_freq; __entry->channel_type = channel_type; __entry->wait = wait; ), TP_printk( LOCAL_PR_FMT " freq:%dMHz, wait:%dms", LOCAL_PR_ARG, __entry->center_freq, __entry->wait ) ); TRACE_EVENT(drv_set_ringparam, TP_PROTO(struct ieee80211_local *local, u32 tx, u32 rx), TP_ARGS(local, tx, rx), TP_STRUCT__entry( LOCAL_ENTRY __field(u32, tx) __field(u32, rx) ), TP_fast_assign( LOCAL_ASSIGN; __entry->tx = tx; __entry->rx = rx; ), TP_printk( LOCAL_PR_FMT " tx:%d rx %d", LOCAL_PR_ARG, __entry->tx, __entry->rx ) ); TRACE_EVENT(drv_get_ringparam, TP_PROTO(struct ieee80211_local *local, u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max), TP_ARGS(local, tx, tx_max, rx, rx_max), TP_STRUCT__entry( LOCAL_ENTRY __field(u32, tx) __field(u32, tx_max) __field(u32, rx) __field(u32, rx_max) ), TP_fast_assign( LOCAL_ASSIGN; __entry->tx = *tx; __entry->tx_max = *tx_max; __entry->rx = *rx; __entry->rx_max = *rx_max; ), TP_printk( LOCAL_PR_FMT " tx:%d tx_max %d rx %d rx_max %d", LOCAL_PR_ARG, __entry->tx, __entry->tx_max, __entry->rx, __entry->rx_max ) ); DEFINE_EVENT(local_only_evt, <API key>, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); DEFINE_EVENT(local_only_evt, <API key>, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, const struct <API key> *mask), TP_ARGS(local, sdata, mask), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY __field(u32, legacy_2g) __field(u32, legacy_5g) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; __entry->legacy_2g = mask->control[IEEE80211_BAND_2GHZ].legacy; __entry->legacy_5g = mask->control[IEEE80211_BAND_5GHZ].legacy; ), TP_printk( LOCAL_PR_FMT VIF_PR_FMT " 2G Mask:0x%x 5G Mask:0x%x", LOCAL_PR_ARG, VIF_PR_ARG, __entry->legacy_2g, __entry->legacy_5g ) ); TRACE_EVENT(drv_set_rekey_data, TP_PROTO(struct ieee80211_local *local, struct <API key> *sdata, struct <API key> *data), TP_ARGS(local, sdata, data), TP_STRUCT__entry( LOCAL_ENTRY VIF_ENTRY __array(u8, kek, NL80211_KEK_LEN) __array(u8, kck, NL80211_KCK_LEN) __array(u8, replay_ctr, <API key>) ), TP_fast_assign( LOCAL_ASSIGN; VIF_ASSIGN; memcpy(__entry->kek, data->kek, NL80211_KEK_LEN); memcpy(__entry->kck, data->kck, NL80211_KCK_LEN); memcpy(__entry->replay_ctr, data->replay_ctr, <API key>); ), TP_printk(LOCAL_PR_FMT VIF_PR_FMT, LOCAL_PR_ARG, VIF_PR_ARG) ); TRACE_EVENT(drv_rssi_callback, TP_PROTO(struct ieee80211_local *local, enum <API key> rssi_event), TP_ARGS(local, rssi_event), TP_STRUCT__entry( LOCAL_ENTRY __field(u32, rssi_event) ), TP_fast_assign( LOCAL_ASSIGN; __entry->rssi_event = rssi_event; ), TP_printk( LOCAL_PR_FMT " rssi_event:%d", LOCAL_PR_ARG, __entry->rssi_event ) ); DECLARE_EVENT_CLASS(release_evt, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sta *sta, u16 tids, int num_frames, enum <API key> reason, bool more_data), TP_ARGS(local, sta, tids, num_frames, reason, more_data), TP_STRUCT__entry( LOCAL_ENTRY STA_ENTRY __field(u16, tids) __field(int, num_frames) __field(int, reason) __field(bool, more_data) ), TP_fast_assign( LOCAL_ASSIGN; STA_ASSIGN; __entry->tids = tids; __entry->num_frames = num_frames; __entry->reason = reason; __entry->more_data = more_data; ), TP_printk( LOCAL_PR_FMT STA_PR_FMT " TIDs:0x%.4x frames:%d reason:%d more:%d", LOCAL_PR_ARG, STA_PR_ARG, __entry->tids, __entry->num_frames, __entry->reason, __entry->more_data ) ); DEFINE_EVENT(release_evt, <API key>, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sta *sta, u16 tids, int num_frames, enum <API key> reason, bool more_data), TP_ARGS(local, sta, tids, num_frames, reason, more_data) ); DEFINE_EVENT(release_evt, <API key>, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sta *sta, u16 tids, int num_frames, enum <API key> reason, bool more_data), TP_ARGS(local, sta, tids, num_frames, reason, more_data) ); /* * Tracing for API calls that drivers call. */ TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_sta *sta, u16 tid), TP_ARGS(sta, tid), TP_STRUCT__entry( STA_ENTRY __field(u16, tid) ), TP_fast_assign( STA_ASSIGN; __entry->tid = tid; ), TP_printk( STA_PR_FMT " tid:%d", STA_PR_ARG, __entry->tid ) ); TRACE_EVENT(api_start_tx_ba_cb, TP_PROTO(struct <API key> *sdata, const u8 *ra, u16 tid), TP_ARGS(sdata, ra, tid), TP_STRUCT__entry( VIF_ENTRY __array(u8, ra, ETH_ALEN) __field(u16, tid) ), TP_fast_assign( VIF_ASSIGN; memcpy(__entry->ra, ra, ETH_ALEN); __entry->tid = tid; ), TP_printk( VIF_PR_FMT " ra:%pM tid:%d", VIF_PR_ARG, __entry->ra, __entry->tid ) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_sta *sta, u16 tid), TP_ARGS(sta, tid), TP_STRUCT__entry( STA_ENTRY __field(u16, tid) ), TP_fast_assign( STA_ASSIGN; __entry->tid = tid; ), TP_printk( STA_PR_FMT " tid:%d", STA_PR_ARG, __entry->tid ) ); TRACE_EVENT(api_stop_tx_ba_cb, TP_PROTO(struct <API key> *sdata, const u8 *ra, u16 tid), TP_ARGS(sdata, ra, tid), TP_STRUCT__entry( VIF_ENTRY __array(u8, ra, ETH_ALEN) __field(u16, tid) ), TP_fast_assign( VIF_ASSIGN; memcpy(__entry->ra, ra, ETH_ALEN); __entry->tid = tid; ), TP_printk( VIF_PR_FMT " ra:%pM tid:%d", VIF_PR_ARG, __entry->ra, __entry->tid ) ); DEFINE_EVENT(local_only_evt, api_restart_hw, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); TRACE_EVENT(api_beacon_loss, TP_PROTO(struct <API key> *sdata), TP_ARGS(sdata), TP_STRUCT__entry( VIF_ENTRY ), TP_fast_assign( VIF_ASSIGN; ), TP_printk( VIF_PR_FMT, VIF_PR_ARG ) ); TRACE_EVENT(api_connection_loss, TP_PROTO(struct <API key> *sdata), TP_ARGS(sdata), TP_STRUCT__entry( VIF_ENTRY ), TP_fast_assign( VIF_ASSIGN; ), TP_printk( VIF_PR_FMT, VIF_PR_ARG ) ); TRACE_EVENT(api_cqm_rssi_notify, TP_PROTO(struct <API key> *sdata, enum <API key> rssi_event), TP_ARGS(sdata, rssi_event), TP_STRUCT__entry( VIF_ENTRY __field(u32, rssi_event) ), TP_fast_assign( VIF_ASSIGN; __entry->rssi_event = rssi_event; ), TP_printk( VIF_PR_FMT " event:%d", VIF_PR_ARG, __entry->rssi_event ) ); TRACE_EVENT(api_scan_completed, TP_PROTO(struct ieee80211_local *local, bool aborted), TP_ARGS(local, aborted), TP_STRUCT__entry( LOCAL_ENTRY __field(bool, aborted) ), TP_fast_assign( LOCAL_ASSIGN; __entry->aborted = aborted; ), TP_printk( LOCAL_PR_FMT " aborted:%d", LOCAL_PR_ARG, __entry->aborted ) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local), TP_STRUCT__entry( LOCAL_ENTRY ), TP_fast_assign( LOCAL_ASSIGN; ), TP_printk( LOCAL_PR_FMT, LOCAL_PR_ARG ) ); TRACE_EVENT(<API key>, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local), TP_STRUCT__entry( LOCAL_ENTRY ), TP_fast_assign( LOCAL_ASSIGN; ), TP_printk( LOCAL_PR_FMT, LOCAL_PR_ARG ) ); TRACE_EVENT(api_sta_block_awake, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sta *sta, bool block), TP_ARGS(local, sta, block), TP_STRUCT__entry( LOCAL_ENTRY STA_ENTRY __field(bool, block) ), TP_fast_assign( LOCAL_ASSIGN; STA_ASSIGN; __entry->block = block; ), TP_printk( LOCAL_PR_FMT STA_PR_FMT " block:%d", LOCAL_PR_ARG, STA_PR_FMT, __entry->block ) ); TRACE_EVENT(api_chswitch_done, TP_PROTO(struct <API key> *sdata, bool success), TP_ARGS(sdata, success), TP_STRUCT__entry( VIF_ENTRY __field(bool, success) ), TP_fast_assign( VIF_ASSIGN; __entry->success = success; ), TP_printk( VIF_PR_FMT " success=%d", VIF_PR_ARG, __entry->success ) ); DEFINE_EVENT(local_only_evt, <API key>, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); DEFINE_EVENT(local_only_evt, <API key>, TP_PROTO(struct ieee80211_local *local), TP_ARGS(local) ); TRACE_EVENT(<API key>, TP_PROTO(struct <API key> *sdata, const u8 *bssid, const u8 *replay_ctr), TP_ARGS(sdata, bssid, replay_ctr), TP_STRUCT__entry( VIF_ENTRY __array(u8, bssid, ETH_ALEN) __array(u8, replay_ctr, <API key>) ), TP_fast_assign( VIF_ASSIGN; memcpy(__entry->bssid, bssid, ETH_ALEN); memcpy(__entry->replay_ctr, replay_ctr, <API key>); ), TP_printk(VIF_PR_FMT, VIF_PR_ARG) ); TRACE_EVENT(<API key>, TP_PROTO(struct <API key> *sdata, int rssi_min_thold, int rssi_max_thold), TP_ARGS(sdata, rssi_min_thold, rssi_max_thold), TP_STRUCT__entry( VIF_ENTRY __field(int, rssi_min_thold) __field(int, rssi_max_thold) ), TP_fast_assign( VIF_ASSIGN; __entry->rssi_min_thold = rssi_min_thold; __entry->rssi_max_thold = rssi_max_thold; ), TP_printk( VIF_PR_FMT " rssi_min_thold =%d, rssi_max_thold = %d", VIF_PR_ARG, __entry->rssi_min_thold, __entry->rssi_max_thold ) ); TRACE_EVENT(api_eosp, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sta *sta), TP_ARGS(local, sta), TP_STRUCT__entry( LOCAL_ENTRY STA_ENTRY ), TP_fast_assign( LOCAL_ASSIGN; STA_ASSIGN; ), TP_printk( LOCAL_PR_FMT STA_PR_FMT, LOCAL_PR_ARG, STA_PR_FMT ) ); /* * Tracing for internal functions * (which may also be called in response to driver calls) */ TRACE_EVENT(wake_queue, TP_PROTO(struct ieee80211_local *local, u16 queue, enum queue_stop_reason reason), TP_ARGS(local, queue, reason), TP_STRUCT__entry( LOCAL_ENTRY __field(u16, queue) __field(u32, reason) ), TP_fast_assign( LOCAL_ASSIGN; __entry->queue = queue; __entry->reason = reason; ), TP_printk( LOCAL_PR_FMT " queue:%d, reason:%d", LOCAL_PR_ARG, __entry->queue, __entry->reason ) ); TRACE_EVENT(stop_queue, TP_PROTO(struct ieee80211_local *local, u16 queue, enum queue_stop_reason reason), TP_ARGS(local, queue, reason), TP_STRUCT__entry( LOCAL_ENTRY __field(u16, queue) __field(u32, reason) ), TP_fast_assign( LOCAL_ASSIGN; __entry->queue = queue; __entry->reason = reason; ), TP_printk( LOCAL_PR_FMT " queue:%d, reason:%d", LOCAL_PR_ARG, __entry->queue, __entry->reason ) ); #endif /* !<API key> || <API key> */ #undef TRACE_INCLUDE_PATH #define TRACE_INCLUDE_PATH . #undef TRACE_INCLUDE_FILE #define TRACE_INCLUDE_FILE driver-trace #include <trace/define_trace.h>
import win32pipe import win32console import win32process import time import win32con import codecs import ctypes user32 = ctypes.windll.user32 CONQUE_WINDOWS_VK = { '3' : win32con.VK_CANCEL, '8' : win32con.VK_BACK, '9' : win32con.VK_TAB, '12' : win32con.VK_CLEAR, '13' : win32con.VK_RETURN, '17' : win32con.VK_CONTROL, '20' : win32con.VK_CAPITAL, '27' : win32con.VK_ESCAPE, '28' : win32con.VK_CONVERT, '35' : win32con.VK_END, '36' : win32con.VK_HOME, '37' : win32con.VK_LEFT, '38' : win32con.VK_UP, '39' : win32con.VK_RIGHT, '40' : win32con.VK_DOWN, '45' : win32con.VK_INSERT, '46' : win32con.VK_DELETE, '47' : win32con.VK_HELP } def make_input_key(c, control_key_state=None): kc = win32console.PyINPUT_RECORDType (win32console.KEY_EVENT) kc.KeyDown = True kc.RepeatCount = 1 cnum = ord(c) if cnum == 3: pid_list = win32console.<API key>() win32console.<API key>(win32con.CTRL_C_EVENT, 0) return else: kc.Char = unicode(c) if str(cnum) in CONQUE_WINDOWS_VK: kc.VirtualKeyCode = CONQUE_WINDOWS_VK[str(cnum)] else: kc.VirtualKeyCode = ctypes.windll.user32.VkKeyScanA(cnum) #kc.VirtualKeyCode = ctypes.windll.user32.VkKeyScanA(cnum+96) #kc.ControlKeyState = win32con.LEFT_CTRL_PRESSED return kc #win32console.AttachConsole() coord = win32console.PyCOORDType con_stdout = win32console.GetStdHandle(win32console.STD_OUTPUT_HANDLE) con_stdin = win32console.GetStdHandle(win32console.STD_INPUT_HANDLE) flags = win32process.<API key> si = win32process.STARTUPINFO() si.dwFlags |= win32con.<API key> (handle1, handle2, i1, i2) = win32process.CreateProcess(None, "cmd.exe", None, None, 0, flags, None, '.', si) time.sleep(1) #size = con_stdout.<API key>()['Window'] # with codecs.open("log.txt", "w", "utf8") as f: # for i in xrange(0, size.Bottom): # f.write(con_stdout.<API key>(size.Right+1, coord(0, i))) # f.write("\n") import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) HOST = "127.0.0.1" PORT = 5554 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((HOST, PORT)) s.listen(1) (sc, scname) = s.accept() while True: msg = sc.recv(1) if ord(msg) == 0: break keys = [make_input_key(msg)] if keys: con_stdin.WriteConsoleInput(keys) win32process.TerminateProcess(handle1, 0)
class EventsController < <API key> before_filter :authorize_organizer, except: [:index, :show] def index @events_upcoming = Event.paginate(page: params[:page_upcoming], :per_page => 5).upcoming() @events_past = Event.paginate(page: params[:page_past], :per_page => 5).past() @events_past_count = Event.past().count end def show @event = Event.find(params[:id]) end def new @event = Event.new @event.date = Date.today end def edit @event = Event.find(params[:id]) end def create @event = Event.new(params[:event]) if @event.save flash[:success] = "Event was successfully created." redirect_to @event else render 'new' end end def update @event = Event.find(params[:id]) if @event.update_attributes(params[:event]) flash[:success] = "Event was successfully updated." redirect_to @event else render 'edit' end end def destroy @event = Event.find(params[:id]) @event.destroy flash[:success] = "Event was successfully deleted." redirect_to events_url end end
<?php global $woocommerce; ?> <?php $woocommerce->show_messages(); ?> <?php do_action('<API key>'); ?> <?php if (get_option('<API key>')=='yes') : ?> <div class="col2-set" id="customer_login"> <div class="col-1"> <?php endif; ?> <h2><?php _e('Login', 'sp'); ?></h2> <form method="post" class="login"> <p class="form-row form-row-first"> <label for="username"><?php _e('Username', 'sp'); ?> <span class="required">*</span></label> <input type="text" class="input-text" name="username" id="username" /> </p> <p class="form-row form-row-last"> <label for="password"><?php _e('Password', 'sp'); ?> <span class="required">*</span></label> <input class="input-text" type="password" name="password" id="password" /> </p> <div class="group"></div> <p class="form-row"> <?php $woocommerce->nonce_field('login', 'login') ?> <input type="submit" class="button" name="login" value="<?php _e('Login', 'sp'); ?>" /> <a class="lost_password" href="<?php echo esc_url( wp_lostpassword_url( home_url() ) ); ?>"><?php _e('Lost Password?', 'sp'); ?></a> </p> </form> <?php if (get_option('<API key>')=='yes') : ?> </div> <div class="col-2"> <h2><?php _e('Register', 'sp'); ?></h2> <form method="post" class="register"> <p class="form-row form-row-first"> <label for="reg_username"><?php _e('Username', 'sp'); ?> <span class="required">*</span></label> <input type="text" class="input-text" name="username" id="reg_username" value="<?php if (isset($_POST['username'])) echo esc_attr($_POST['username']); ?>" /> </p> <p class="form-row form-row-last"> <label for="reg_email"><?php _e('Email', 'sp'); ?> <span class="required">*</span></label> <input type="email" class="input-text" name="email" id="reg_email" value="<?php if (isset($_POST['email'])) echo esc_attr($_POST['email']); ?>" /> </p> <div class="group"></div> <p class="form-row form-row-first"> <label for="reg_password"><?php _e('Password', 'sp'); ?> <span class="required">*</span></label> <input type="password" class="input-text" name="password" id="reg_password" value="<?php if (isset($_POST['password'])) echo esc_attr($_POST['password']); ?>" /> </p> <p class="form-row form-row-last"> <label for="reg_password2"><?php _e('Re-enter password', 'sp'); ?> <span class="required">*</span></label> <input type="password" class="input-text" name="password2" id="reg_password2" value="<?php if (isset($_POST['password2'])) echo esc_attr($_POST['password2']); ?>" /> </p> <div class="group"></div> <!-- Spam Trap --> <div style="left:-999em; position:absolute;"><label for="trap">Anti-spam</label><input type="text" name="email_2" id="trap" /></div> <?php do_action( 'register_form' ); ?> <p class="form-row"> <?php $woocommerce->nonce_field('register', 'register') ?> <input type="submit" class="button" name="register" value="<?php _e('Register', 'sp'); ?>" /> </p> </form> </div> </div> <?php endif; ?> <?php do_action('<API key>'); ?>
$('#section').on('click', '[id$="Empty"]', function(event) { event.preventDefault(); var match = /(.+)Empty/.exec($(event.target).closest('.unwell').attr('id')); var id = match[1]; var emptyId = match[0]; $('#'+id).trigger('addrow'); $('#'+emptyId).addClass('hidden'); return false; }); $('#section').on('submit', 'form[name="formItem"]', function(e) { e.preventDefault(); var form = $(this), btn = form.find('.btn-primary'), valid = isFormValid(form); $('select[name$=".type"]:not(:disabled)').each(function(i,e){ if($(e).val() == "Select an option"){ valid = false; showPermanentError(form, "Please select a valid action."); } }); if (valid) { btn.button('loading'); resetAlert($('#section')); $.ajax({ type: 'POST', url: form.attr('action'), data: form.serialize() }).always(function() { btn.button('reset'); }).done(function(data, textStatus, jqXHR) { showSuccess(form, "Saved"); window.location.hash = "#config/portal_module/"+form.find('input[name="id"]').val()+"/read" }).fail(function(jqXHR) { $("body,html").animate({scrollTop:0}, 'fast'); var status_msg = getStatusMsg(jqXHR); showPermanentError(form, status_msg); }); } }); $('#section').on('click', '.<API key>', function(e){ e.preventDefault(); var button = $(e.target); button.button('loading'); $.ajax({ type: 'GET', url: button.attr('href'), }).always(function() { }).done(function(data, textStatus, jqXHR) { showSuccess(button.closest('.table'), "Deleted"); button.closest('tr').remove(); }).fail(function(jqXHR) { button.button('reset'); $("body,html").animate({scrollTop:0}, 'fast'); var status_msg = getStatusMsg(jqXHR); showPermanentError(button.closest('.table'), status_msg); }); return false; }); $('#section').on('click', '.expand', function(e){ e.preventDefault(); $(e.target).hide(function(){ $($(e.target).attr('data-expand')).slideDown(); }); return false; }); $('#section').on('change', '#actions select[name$=".type"]', function(event) { var type_input = $(event.currentTarget); <API key>(type_input,false); }); $('#section').on('click', '#actionsContainer a[href="#add"]', function(event) { setTimeout(<API key>, 3000); }); function <API key>() { $('select[name$=".type"]:not(:disabled)').each(function(i,e){ <API key>($(e),true); }); } function <API key>(type_input, keep) { var match_input = type_input.next(); var type_value = type_input.val(); var <API key> = '#' + type_value + "_action_match"; var <API key> = $(<API key>); if ( <API key>.length == 0 ) { <API key> = $('#<API key>'); } if ( <API key>.length ) { <API key>(match_input, <API key>, keep); if (type_value == "switch") { type_input.next().typeahead({ source: <API key>($('#section h2')), minLength: 2, items: 11, matcher: function(item) { return true; } }); } } }
#ifndef __MATRIXTV__ #define __MATRIXTV__ #include "BaseEffecTV.h" class MatrixTV : public BaseEffecTV { typedef BaseEffecTV super; protected: struct Blip { int mode; int y; int timer; int speed; }; int show_info; int mode; int pause; int mapW; int mapH; unsigned char* cmap; unsigned char* vmap; unsigned char* img; unsigned char* font; RGB32* palette; Blip* blips; virtual void intialize(bool reset); virtual int readConfig(); virtual int writeConfig(); public: MatrixTV(void); virtual ~MatrixTV(void); virtual const char* name(void); virtual const char* title(void); virtual const char** funcs(void); virtual int start(Utils* utils, int width, int height); virtual int stop(void); virtual int draw(YUV* src_yuv, RGB32* dst_rgb, char* dst_msg); virtual const char* event(int key_code); virtual const char* touch(int action, int x, int y); protected: RGB32 green(unsigned int v); int setPalette(void); int setPattern(void); void drawChar(RGB32* dst, unsigned char c, unsigned char v); void createImg(RGB32* src); void updateCharMap(void); void darkenColumn(int); void blipNone(int x); void blipFall(int x); void blipStop(int x); void blipSlide(int x); }; #endif // __MATRIXTV__
jQuery(function($){ $.supersized({ //Functionality slideshow : 1, //Slideshow on/off autoplay : 1, //Slideshow starts playing automatically start_slide : 1, //Start slide (0 is random) slide_interval : 4000, //Length between transitions slideshow_interval : 4000, //Length between transitions transition : 1, //0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left transition_speed : 500, //Speed of transition new_window : 1, //Image links open in new window/tab pause_hover : 0, //Pause slideshow on hover keyboard_nav : 1, //Keyboard navigation on/off performance : 1, //0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit) image_protect : 1, //Disables image dragging and right click with Javascript image_path : 'img/', //Default image path //Size & Position min_width : 0, //Min width allowed (in pixels) min_height : 0, //Min height allowed (in pixels) vertical_center : 1, //Vertically center background horizontal_center : 1, //Horizontally center background fit_portrait : 1, //Portrait images will not exceed browser height fit_landscape : 0, //Landscape images will not exceed browser width //Components navigation : 1, //Slideshow controls on/off <API key> : 1, //Thumbnail navigation slide_counter : 1, //Display slide numbers slide_captions : 1, //Slide caption (Pull from "title" in slides array) slides : (function(){ var ret = new Array(); for(var i in supersizedImgs){ ret.push({image: supersizedImgs[i]}); } return ret; })() }); });
#include <stdint.h> #include <string.h> #include <cbfs.h> #include <cbmem.h> #include <console/console.h> #include <arch/cpu.h> #include <cpu/x86/bist.h> #include <cpu/x86/msr.h> #include <cpu/x86/mtrr.h> #include <halt.h> #include <lib.h> #include <timestamp.h> #include <arch/io.h> #include <arch/stages.h> #include <device/pci_def.h> #include <cpu/x86/lapic.h> #include <cbfs.h> #include <romstage_handoff.h> #include <reset.h> #include <stage_cache.h> #include <vendorcode/google/chromeos/chromeos.h> #if <API key> #include <ec/google/chromeec/ec.h> #endif #include "haswell.h" #include "northbridge/intel/haswell/haswell.h" #include "northbridge/intel/haswell/raminit.h" #include "southbridge/intel/lynxpoint/pch.h" #include "southbridge/intel/lynxpoint/me.h" static inline void reset_system(void) { hard_reset(); halt(); } /* The cache-as-ram assembly file calls romstage_main() after setting up * cache-as-ram. romstage_main() will then call the mainboards's * <API key>() function. That function then calls * romstage_common() below. The reason for the back and forth is to provide * common entry point from cache-as-ram while still allowing for code sharing. * Because we can't use global variables the stack is used for allocations -- * thus the need to call back and forth. */ static inline u32 *stack_push(u32 *stack, u32 value) { stack = &stack[-1]; *stack = value; return stack; } /* Romstage needs quite a bit of stack for decompressing images since the lzma * lib keeps its state on the stack during romstage. */ #define <API key> 0x5000 static unsigned long choose_top_of_stack(void) { unsigned long stack_top; /* cbmem_add() does a find() before add(). */ stack_top = (unsigned long)cbmem_add(<API key>, <API key>); stack_top += <API key>; return stack_top; } /* <API key>() determines the stack to use after * cache-as-ram is torn down as well as the MTRR settings to use. */ static void *<API key>(void) { unsigned long top_of_stack; int num_mtrrs; u32 *slot; u32 mtrr_mask_upper; u32 top_of_ram; /* Top of stack needs to be aligned to a 4-byte boundary. */ top_of_stack = choose_top_of_stack() & ~3; slot = (void *)top_of_stack; num_mtrrs = 0; /* The upper bits of the MTRR mask need to set according to the number * of physical address bits. */ mtrr_mask_upper = (1 << ((cpuid_eax(0x80000008) & 0xff) - 32)) - 1; /* The order for each MTRR is value then base with upper 32-bits of * each value coming before the lower 32-bits. The reasoning for * this ordering is to create a stack layout like the following: * +0: Number of MTRRs * +4: MTRR base 0 31:0 * +8: MTRR base 0 63:32 * +12: MTRR mask 0 31:0 * +16: MTRR mask 0 63:32 * +20: MTRR base 1 31:0 * +24: MTRR base 1 63:32 * +28: MTRR mask 1 31:0 * +32: MTRR mask 1 63:32 */ /* Cache the ROM as WP just below 4GiB. */ slot = stack_push(slot, mtrr_mask_upper); /* upper mask */ slot = stack_push(slot, ~(CACHE_ROM_SIZE - 1) | MTRRphysMaskValid); slot = stack_push(slot, 0); /* upper base */ slot = stack_push(slot, ~(CACHE_ROM_SIZE - 1) | MTRR_TYPE_WRPROT); num_mtrrs++; /* Cache RAM as WB from 0 -> CONFIG_RAMTOP. */ slot = stack_push(slot, mtrr_mask_upper); /* upper mask */ slot = stack_push(slot, ~(CONFIG_RAMTOP - 1) | MTRRphysMaskValid); slot = stack_push(slot, 0); /* upper base */ slot = stack_push(slot, 0 | MTRR_TYPE_WRBACK); num_mtrrs++; top_of_ram = (uint32_t)cbmem_top(); /* Cache 8MiB below the top of ram. On haswell systems the top of * ram under 4GiB is the start of the TSEG region. It is required to * be 8MiB aligned. Set this area as cacheable so it can be used later * for ramstage before setting up the entire RAM as cacheable. */ slot = stack_push(slot, mtrr_mask_upper); /* upper mask */ slot = stack_push(slot, ~((8 << 20) - 1) | MTRRphysMaskValid); slot = stack_push(slot, 0); /* upper base */ slot = stack_push(slot, (top_of_ram - (8 << 20)) | MTRR_TYPE_WRBACK); num_mtrrs++; /* Cache 8MiB at the top of ram. Top of ram on haswell systems * is where the TSEG region resides. However, it is not restricted * to SMM mode until SMM has been relocated. By setting the region * to cacheable it provides faster access when relocating the SMM * handler as well as using the TSEG region for other purposes. */ slot = stack_push(slot, mtrr_mask_upper); /* upper mask */ slot = stack_push(slot, ~((8 << 20) - 1) | MTRRphysMaskValid); slot = stack_push(slot, 0); /* upper base */ slot = stack_push(slot, top_of_ram | MTRR_TYPE_WRBACK); num_mtrrs++; /* Save the number of MTRRs to setup. Return the stack location * pointing to the number of MTRRs. */ slot = stack_push(slot, num_mtrrs); return slot; } void * asmlinkage romstage_main(unsigned long bist) { int i; void *<API key>; const int num_guards = 4; const u32 stack_guard = 0xdeadbeef; u32 *stack_base = (void *)(<API key> + <API key> - <API key>); printk(BIOS_DEBUG, "Setting up stack guards.\n"); for (i = 0; i < num_guards; i++) stack_base[i] = stack_guard; <API key>(bist); /* Check the stack. */ for (i = 0; i < num_guards; i++) { if (stack_base[i] == stack_guard) continue; printk(BIOS_DEBUG, "Smashed stack detected in romstage!\n"); } /* Get the stack to use after cache-as-ram is torn down. */ <API key> = <API key>(); return <API key>; } void romstage_common(const struct romstage_params *params) { int boot_mode; int wake_from_s3; struct romstage_handoff *handoff; timestamp_init(<API key>()); timestamp_add_now(TS_START_ROMSTAGE); if (params->bist == 0) enable_lapic(); wake_from_s3 = early_pch_init(params->gpio_map, params->rcba_config); #if <API key> /* Ensure the EC is in the right mode for recovery */ <API key>(); #endif /* Halt if there was a built in self test failure */ report_bist_failure(params->bist); /* Perform some early chipset initialization required * before RAM initialization can work */ <API key>(HASWELL_MOBILE); printk(BIOS_DEBUG, "Back from <API key>()\n"); if (wake_from_s3) { #if <API key> printk(BIOS_DEBUG, "Resume from S3 detected.\n"); #else printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n"); wake_from_s3 = 0; #endif } /* There are hard coded assumptions of 2 meaning s3 wake. Normalize * the users of the 2 literal here based off wake_from_s3. */ boot_mode = wake_from_s3 ? 2 : 0; /* Prepare USB controller early in S3 resume */ if (wake_from_s3) enable_usb_bar(); post_code(0x3a); params->pei_data->boot_mode = boot_mode; timestamp_add_now(TS_BEFORE_INITRAM); <API key>(); if (params->copy_spd != NULL) params->copy_spd(params->pei_data); sdram_initialize(params->pei_data); timestamp_add_now(TS_AFTER_INITRAM); post_code(0x3b); <API key>(); quick_ram_check(); post_code(0x3e); if (!wake_from_s3) { <API key>(); <API key>(); /* Save data returned from MRC on non-S3 resumes. */ save_mrc_data(params->pei_data); } else { stage_cache_recover(); if (cbmem_initialize()) { #if <API key> /* Failed S3 resume, reset to come up cleanly */ reset_system(); #endif } } handoff = <API key>(); if (handoff != NULL) handoff->s3_resume = wake_from_s3; else printk(BIOS_DEBUG, "Romstage handoff structure not added!\n"); post_code(0x3f); #if CONFIG_CHROMEOS init_chromeos(boot_mode); #endif timestamp_add_now(TS_END_ROMSTAGE); } static inline void prepare_for_resume(struct romstage_handoff *handoff) { /* Only need to save memory when ramstage isn't relocatable. */ #if !<API key> #if <API key> /* Back up the OS-controlled memory where ramstage will be loaded. */ if (handoff != NULL && handoff->s3_resume) { void *src = (void *)CONFIG_RAMBASE; void *dest = cbmem_find(CBMEM_ID_RESUME); if (dest != NULL) memcpy(dest, src, HIGH_MEMORY_SAVE); } #endif #endif } void romstage_after_car(void) { struct romstage_handoff *handoff; handoff = <API key>(); prepare_for_resume(handoff); /* Load the ramstage. */ copy_and_run(); } #if IS_ENABLED(<API key>) void <API key>(void **base, size_t *size) { /* The ramstage cache lives in the TSEG region at RESERVED_SMM_OFFSET. * The top of ram is defined to be the TSEG base address. */ *size = RESERVED_SMM_SIZE; *base = (void *)((uint32_t)cbmem_top() + RESERVED_SMM_OFFSET); } void <API key>(void) { #if <API key> reset_system(); #endif } #endif
package com.mmm.product.domain; import java.io.Serializable; public class ShippingDetails implements Serializable{ private static final long serialVersionUID = <API key>; }
package org.jiserte.bioformats.readers.phylip; import org.jiserte.bioformats.readers.faults.<API key>; public class <API key> extends <API key> { public <API key>() { super(); this.setMessage("Sequences in the first block of data must have a description of 10 characters and then the sequence."); } }
namespace Tipshare { partial class Tipshare { <summary> Required designer variable. </summary> private System.ComponentModel.IContainer components = null; <summary> Clean up any resources being used. </summary> <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code <summary> Required method for Designer support - do not modify the contents of this method with the code editor. </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.gbAM = new System.Windows.Forms.GroupBox(); this.tbAMUnallocatedAdj = new System.Windows.Forms.TextBox(); this.<API key> = new System.Windows.Forms.Label(); this.tbAMUnallocatedSugg = new System.Windows.Forms.TextBox(); this.lblAMUnallocated = new System.Windows.Forms.Label(); this.lAMAdj = new System.Windows.Forms.Label(); this.lAMSugg = new System.Windows.Forms.Label(); this.lAMID = new System.Windows.Forms.Label(); this.lAMName = new System.Windows.Forms.Label(); this.gbControls = new System.Windows.Forms.GroupBox(); this.<API key> = new System.Windows.Forms.Button(); this.btnSettings = new System.Windows.Forms.Button(); this.btnReset = new System.Windows.Forms.Button(); this.btnSave = new System.Windows.Forms.Button(); this.lDate = new System.Windows.Forms.Label(); this.lDay = new System.Windows.Forms.Label(); this.bDayBack = new System.Windows.Forms.Button(); this.bDayForward = new System.Windows.Forms.Button(); this.gbPM = new System.Windows.Forms.GroupBox(); this.tbPMUnallocatedAdj = new System.Windows.Forms.TextBox(); this.<API key> = new System.Windows.Forms.Label(); this.tbPMUnallocatedSugg = new System.Windows.Forms.TextBox(); this.lblPMUnallocated = new System.Windows.Forms.Label(); this.lPMAdj = new System.Windows.Forms.Label(); this.lPMSugg = new System.Windows.Forms.Label(); this.lPMID = new System.Windows.Forms.Label(); this.lPMName = new System.Windows.Forms.Label(); this.msMenu = new System.Windows.Forms.MenuStrip(); this.mFile = new System.Windows.Forms.ToolStripMenuItem(); this.miJump = new System.Windows.Forms.ToolStripMenuItem(); this.miPrint = new System.Windows.Forms.ToolStripMenuItem(); this.miExit = new System.Windows.Forms.ToolStripMenuItem(); this.mAbout = new System.Windows.Forms.ToolStripMenuItem(); this.miHelp = new System.Windows.Forms.ToolStripMenuItem(); this.miAbout = new System.Windows.Forms.ToolStripMenuItem(); this.tTimer = new System.Windows.Forms.Timer(this.components); this.gbTotals = new System.Windows.Forms.GroupBox(); this.lTotalSugg = new System.Windows.Forms.Label(); this.lTotalAdj = new System.Windows.Forms.Label(); this.lLabTotSug = new System.Windows.Forms.Label(); this.lTotalAMSugg = new System.Windows.Forms.Label(); this.lTotalAMAdj = new System.Windows.Forms.Label(); this.lLabTotAMSugg = new System.Windows.Forms.Label(); this.lTotalPMSugg = new System.Windows.Forms.Label(); this.lTotalPMAdj = new System.Windows.Forms.Label(); this.lLabTotPMSugg = new System.Windows.Forms.Label(); this.gbAM.SuspendLayout(); this.gbControls.SuspendLayout(); this.gbPM.SuspendLayout(); this.msMenu.SuspendLayout(); this.gbTotals.SuspendLayout(); this.SuspendLayout(); // gbAM this.gbAM.Controls.Add(this.tbAMUnallocatedAdj); this.gbAM.Controls.Add(this.<API key>); this.gbAM.Controls.Add(this.tbAMUnallocatedSugg); this.gbAM.Controls.Add(this.lblAMUnallocated); this.gbAM.Controls.Add(this.lAMAdj); this.gbAM.Controls.Add(this.lAMSugg); this.gbAM.Controls.Add(this.lAMID); this.gbAM.Controls.Add(this.lAMName); this.gbAM.Location = new System.Drawing.Point(12, 27); this.gbAM.Name = "gbAM"; this.gbAM.Size = new System.Drawing.Size(318, 430); this.gbAM.TabIndex = 1; this.gbAM.TabStop = false; this.gbAM.Text = "AM Declarations"; // tbAMUnallocatedAdj this.tbAMUnallocatedAdj.Location = new System.Drawing.Point(277, 404); this.tbAMUnallocatedAdj.Name = "tbAMUnallocatedAdj"; this.tbAMUnallocatedAdj.ReadOnly = true; this.tbAMUnallocatedAdj.Size = new System.Drawing.Size(35, 20); this.tbAMUnallocatedAdj.TabIndex = 14; // <API key> this.<API key>.AutoSize = true; this.<API key>.Location = new System.Drawing.Point(167, 407); this.<API key>.Name = "<API key>"; this.<API key>.Size = new System.Drawing.Size(104, 13); this.<API key>.TabIndex = 13; this.<API key>.Text = "Current Unallocated:"; // tbAMUnallocatedSugg this.tbAMUnallocatedSugg.Location = new System.Drawing.Point(118, 404); this.tbAMUnallocatedSugg.Name = "tbAMUnallocatedSugg"; this.tbAMUnallocatedSugg.ReadOnly = true; this.tbAMUnallocatedSugg.Size = new System.Drawing.Size(35, 20); this.tbAMUnallocatedSugg.TabIndex = 12; // lblAMUnallocated this.lblAMUnallocated.AutoSize = true; this.lblAMUnallocated.Location = new System.Drawing.Point(6, 407); this.lblAMUnallocated.Name = "lblAMUnallocated"; this.lblAMUnallocated.Size = new System.Drawing.Size(106, 13); this.lblAMUnallocated.TabIndex = 10; this.lblAMUnallocated.Text = "Starting Unallocated:"; // lAMAdj this.lAMAdj.AutoSize = true; this.lAMAdj.Location = new System.Drawing.Point(276, 16); this.lAMAdj.Name = "lAMAdj"; this.lAMAdj.Size = new System.Drawing.Size(22, 13); this.lAMAdj.TabIndex = 9; this.lAMAdj.Text = "Adj"; // lAMSugg this.lAMSugg.AutoSize = true; this.lAMSugg.Location = new System.Drawing.Point(216, 16); this.lAMSugg.Name = "lAMSugg"; this.lAMSugg.Size = new System.Drawing.Size(32, 13); this.lAMSugg.TabIndex = 8; this.lAMSugg.Text = "Sugg"; // lAMID this.lAMID.AutoSize = true; this.lAMID.Location = new System.Drawing.Point(169, 16); this.lAMID.Name = "lAMID"; this.lAMID.Size = new System.Drawing.Size(18, 13); this.lAMID.TabIndex = 7; this.lAMID.Text = "ID"; // lAMName this.lAMName.AutoSize = true; this.lAMName.Location = new System.Drawing.Point(69, 16); this.lAMName.Name = "lAMName"; this.lAMName.Size = new System.Drawing.Size(35, 13); this.lAMName.TabIndex = 6; this.lAMName.Text = "Name"; // gbControls this.gbControls.Controls.Add(this.<API key>); this.gbControls.Controls.Add(this.btnSettings); this.gbControls.Controls.Add(this.btnReset); this.gbControls.Controls.Add(this.btnSave); this.gbControls.Controls.Add(this.lDate); this.gbControls.Controls.Add(this.lDay); this.gbControls.Controls.Add(this.bDayBack); this.gbControls.Controls.Add(this.bDayForward); this.gbControls.Location = new System.Drawing.Point(12, 518); this.gbControls.Name = "gbControls"; this.gbControls.Size = new System.Drawing.Size(648, 62); this.gbControls.TabIndex = 2; this.gbControls.TabStop = false; this.gbControls.Text = "Controls"; // <API key> this.<API key>.Enabled = false; this.<API key>.Location = new System.Drawing.Point(123, 19); this.<API key>.Name = "<API key>"; this.<API key>.Size = new System.Drawing.Size(111, 35); this.<API key>.TabIndex = 13; this.<API key>.Text = "Distribute Unallocated"; this.<API key>.<API key> = true; this.<API key>.Click += new System.EventHandler(this.<API key>); // btnSettings this.btnSettings.Location = new System.Drawing.Point(6, 19); this.btnSettings.Name = "btnSettings"; this.btnSettings.Size = new System.Drawing.Size(111, 35); this.btnSettings.TabIndex = 12; this.btnSettings.Text = "Advanced Settings"; this.btnSettings.<API key> = true; this.btnSettings.Click += new System.EventHandler(this.btnSettings_Click); // btnReset this.btnReset.Location = new System.Drawing.Point(414, 19); this.btnReset.Name = "btnReset"; this.btnReset.Size = new System.Drawing.Size(111, 35); this.btnReset.TabIndex = 11; this.btnReset.Text = "Reset Day"; this.btnReset.<API key> = true; this.btnReset.Click += new System.EventHandler(this.btnReset_Click); // btnSave this.btnSave.Location = new System.Drawing.Point(531, 19); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(111, 35); this.btnSave.TabIndex = 10; this.btnSave.Text = "SAVE"; this.btnSave.<API key> = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // lDate this.lDate.AutoSize = true; this.lDate.Location = new System.Drawing.Point(297, 19); this.lDate.Name = "lDate"; this.lDate.Size = new System.Drawing.Size(64, 13); this.lDate.TabIndex = 9; this.lDate.Text = "##DATE##"; // lDay this.lDay.AutoSize = true; this.lDay.Location = new System.Drawing.Point(308, 41); this.lDay.Name = "lDay"; this.lDay.Size = new System.Drawing.Size(26, 13); this.lDay.TabIndex = 8; this.lDay.Text = "Day"; // bDayBack this.bDayBack.Location = new System.Drawing.Point(263, 35); this.bDayBack.Name = "bDayBack"; this.bDayBack.Size = new System.Drawing.Size(39, 23); this.bDayBack.TabIndex = 1; this.bDayBack.Text = "<<"; this.bDayBack.<API key> = true; this.bDayBack.Click += new System.EventHandler(this.bDayBack_Click); // bDayForward this.bDayForward.Location = new System.Drawing.Point(340, 36); this.bDayForward.Name = "bDayForward"; this.bDayForward.Size = new System.Drawing.Size(39, 23); this.bDayForward.TabIndex = 0; this.bDayForward.Text = ">>"; this.bDayForward.<API key> = true; this.bDayForward.Click += new System.EventHandler(this.bDayForward_Click); // gbPM this.gbPM.Controls.Add(this.tbPMUnallocatedAdj); this.gbPM.Controls.Add(this.<API key>); this.gbPM.Controls.Add(this.tbPMUnallocatedSugg); this.gbPM.Controls.Add(this.lblPMUnallocated); this.gbPM.Controls.Add(this.lPMAdj); this.gbPM.Controls.Add(this.lPMSugg); this.gbPM.Controls.Add(this.lPMID); this.gbPM.Controls.Add(this.lPMName); this.gbPM.Location = new System.Drawing.Point(342, 27); this.gbPM.Name = "gbPM"; this.gbPM.Size = new System.Drawing.Size(318, 430); this.gbPM.TabIndex = 4; this.gbPM.TabStop = false; this.gbPM.Text = "PM Declarations"; // tbPMUnallocatedAdj this.tbPMUnallocatedAdj.Location = new System.Drawing.Point(277, 404); this.tbPMUnallocatedAdj.Name = "tbPMUnallocatedAdj"; this.tbPMUnallocatedAdj.ReadOnly = true; this.tbPMUnallocatedAdj.Size = new System.Drawing.Size(35, 20); this.tbPMUnallocatedAdj.TabIndex = 18; // <API key> this.<API key>.AutoSize = true; this.<API key>.Location = new System.Drawing.Point(167, 407); this.<API key>.Name = "<API key>"; this.<API key>.Size = new System.Drawing.Size(104, 13); this.<API key>.TabIndex = 17; this.<API key>.Text = "Current Unallocated:"; // tbPMUnallocatedSugg this.tbPMUnallocatedSugg.Location = new System.Drawing.Point(115, 404); this.tbPMUnallocatedSugg.Name = "tbPMUnallocatedSugg"; this.tbPMUnallocatedSugg.ReadOnly = true; this.tbPMUnallocatedSugg.Size = new System.Drawing.Size(35, 20); this.tbPMUnallocatedSugg.TabIndex = 15; // lblPMUnallocated this.lblPMUnallocated.AutoSize = true; this.lblPMUnallocated.Location = new System.Drawing.Point(6, 407); this.lblPMUnallocated.Name = "lblPMUnallocated"; this.lblPMUnallocated.Size = new System.Drawing.Size(106, 13); this.lblPMUnallocated.TabIndex = 14; this.lblPMUnallocated.Text = "Starting Unallocated:"; // lPMAdj this.lPMAdj.AutoSize = true; this.lPMAdj.Location = new System.Drawing.Point(276, 16); this.lPMAdj.Name = "lPMAdj"; this.lPMAdj.Size = new System.Drawing.Size(22, 13); this.lPMAdj.TabIndex = 13; this.lPMAdj.Text = "Adj"; // lPMSugg this.lPMSugg.AutoSize = true; this.lPMSugg.Location = new System.Drawing.Point(216, 16); this.lPMSugg.Name = "lPMSugg"; this.lPMSugg.Size = new System.Drawing.Size(32, 13); this.lPMSugg.TabIndex = 12; this.lPMSugg.Text = "Sugg"; // lPMID this.lPMID.AutoSize = true; this.lPMID.Location = new System.Drawing.Point(169, 16); this.lPMID.Name = "lPMID"; this.lPMID.Size = new System.Drawing.Size(18, 13); this.lPMID.TabIndex = 11; this.lPMID.Text = "ID"; // lPMName this.lPMName.AutoSize = true; this.lPMName.Location = new System.Drawing.Point(69, 16); this.lPMName.Name = "lPMName"; this.lPMName.Size = new System.Drawing.Size(35, 13); this.lPMName.TabIndex = 10; this.lPMName.Text = "Name"; // msMenu this.msMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mFile, this.mAbout}); this.msMenu.Location = new System.Drawing.Point(0, 0); this.msMenu.Name = "msMenu"; this.msMenu.Size = new System.Drawing.Size(672, 24); this.msMenu.TabIndex = 5; this.msMenu.Text = "MenuStrip"; // mFile this.mFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.miJump, this.miPrint, this.miExit}); this.mFile.Name = "mFile"; this.mFile.Size = new System.Drawing.Size(37, 20); this.mFile.Text = "File"; // miJump this.miJump.Name = "miJump"; this.miJump.Size = new System.Drawing.Size(148, 22); this.miJump.Text = "Jump to day..."; // miPrint this.miPrint.Name = "miPrint"; this.miPrint.Size = new System.Drawing.Size(148, 22); this.miPrint.Text = "Print Today"; this.miPrint.Click += new System.EventHandler(this.miPrint_Click); // miExit this.miExit.Name = "miExit"; this.miExit.Size = new System.Drawing.Size(148, 22); this.miExit.Text = "Exit"; this.miExit.Click += new System.EventHandler(this.miExit_Click); // mAbout this.mAbout.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.miHelp, this.miAbout}); this.mAbout.Name = "mAbout"; this.mAbout.Size = new System.Drawing.Size(52, 20); this.mAbout.Text = "About"; // miHelp this.miHelp.Name = "miHelp"; this.miHelp.Size = new System.Drawing.Size(107, 22); this.miHelp.Text = "Help"; this.miHelp.Click += new System.EventHandler(this.miHelp_Click); // miAbout this.miAbout.Name = "miAbout"; this.miAbout.Size = new System.Drawing.Size(107, 22); this.miAbout.Text = "About"; this.miAbout.Click += new System.EventHandler(this.miAbout_Click); // tTimer this.tTimer.Tick += new System.EventHandler(this.tTimer_Tick); // gbTotals this.gbTotals.Controls.Add(this.lTotalSugg); this.gbTotals.Controls.Add(this.lTotalAdj); this.gbTotals.Controls.Add(this.lLabTotSug); this.gbTotals.Controls.Add(this.lTotalAMSugg); this.gbTotals.Controls.Add(this.lTotalAMAdj); this.gbTotals.Controls.Add(this.lLabTotAMSugg); this.gbTotals.Controls.Add(this.lTotalPMSugg); this.gbTotals.Controls.Add(this.lTotalPMAdj); this.gbTotals.Controls.Add(this.lLabTotPMSugg); this.gbTotals.Location = new System.Drawing.Point(12, 463); this.gbTotals.Name = "gbTotals"; this.gbTotals.Size = new System.Drawing.Size(648, 49); this.gbTotals.TabIndex = 6; this.gbTotals.TabStop = false; this.gbTotals.Text = "Totals"; // lTotalSugg this.lTotalSugg.AutoSize = true; this.lTotalSugg.Location = new System.Drawing.Point(285, 29); this.lTotalSugg.Name = "lTotalSugg"; this.lTotalSugg.Size = new System.Drawing.Size(21, 13); this.lTotalSugg.TabIndex = 8; this.lTotalSugg.Text = " // lTotalAdj this.lTotalAdj.AutoSize = true; this.lTotalAdj.Location = new System.Drawing.Point(348, 29); this.lTotalAdj.Name = "lTotalAdj"; this.lTotalAdj.Size = new System.Drawing.Size(21, 13); this.lTotalAdj.TabIndex = 7; this.lTotalAdj.Text = " // lLabTotSug this.lLabTotSug.AutoSize = true; this.lLabTotSug.Location = new System.Drawing.Point(285, 16); this.lLabTotSug.Name = "lLabTotSug"; this.lLabTotSug.Size = new System.Drawing.Size(79, 13); this.lLabTotSug.TabIndex = 6; this.lLabTotSug.Text = "Total Sugg/Adj"; // lTotalAMSugg this.lTotalAMSugg.AutoSize = true; this.lTotalAMSugg.Location = new System.Drawing.Point(32, 29); this.lTotalAMSugg.Name = "lTotalAMSugg"; this.lTotalAMSugg.Size = new System.Drawing.Size(21, 13); this.lTotalAMSugg.TabIndex = 5; this.lTotalAMSugg.Text = " // lTotalAMAdj this.lTotalAMAdj.AutoSize = true; this.lTotalAMAdj.Location = new System.Drawing.Point(83, 29); this.lTotalAMAdj.Name = "lTotalAMAdj"; this.lTotalAMAdj.Size = new System.Drawing.Size(21, 13); this.lTotalAMAdj.TabIndex = 4; this.lTotalAMAdj.Text = " // lLabTotAMSugg this.lLabTotAMSugg.AutoSize = true; this.lLabTotAMSugg.Location = new System.Drawing.Point(19, 16); this.lLabTotAMSugg.Name = "lLabTotAMSugg"; this.lLabTotAMSugg.Size = new System.Drawing.Size(98, 13); this.lLabTotAMSugg.TabIndex = 3; this.lLabTotAMSugg.Text = "Total AM Sugg/Adj"; // lTotalPMSugg this.lTotalPMSugg.AutoSize = true; this.lTotalPMSugg.Location = new System.Drawing.Point(545, 29); this.lTotalPMSugg.Name = "lTotalPMSugg"; this.lTotalPMSugg.Size = new System.Drawing.Size(21, 13); this.lTotalPMSugg.TabIndex = 2; this.lTotalPMSugg.Text = " // lTotalPMAdj this.lTotalPMAdj.AutoSize = true; this.lTotalPMAdj.Location = new System.Drawing.Point(596, 29); this.lTotalPMAdj.Name = "lTotalPMAdj"; this.lTotalPMAdj.Size = new System.Drawing.Size(21, 13); this.lTotalPMAdj.TabIndex = 1; this.lTotalPMAdj.Text = " // lLabTotPMSugg this.lLabTotPMSugg.AutoSize = true; this.lLabTotPMSugg.Location = new System.Drawing.Point(530, 16); this.lLabTotPMSugg.Name = "lLabTotPMSugg"; this.lLabTotPMSugg.Size = new System.Drawing.Size(98, 13); this.lLabTotPMSugg.TabIndex = 0; this.lLabTotPMSugg.Text = "Total PM Sugg/Adj"; // Tipshare this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(672, 592); this.Controls.Add(this.gbTotals); this.Controls.Add(this.gbPM); this.Controls.Add(this.gbControls); this.Controls.Add(this.gbAM); this.Controls.Add(this.msMenu); this.MainMenuStrip = this.msMenu; this.Name = "Tipshare"; this.Text = "Tipshare##VERSION## - ##STORENAME##"; this.Load += new System.EventHandler(this.Tipshare_Load); this.gbAM.ResumeLayout(false); this.gbAM.PerformLayout(); this.gbControls.ResumeLayout(false); this.gbControls.PerformLayout(); this.gbPM.ResumeLayout(false); this.gbPM.PerformLayout(); this.msMenu.ResumeLayout(false); this.msMenu.PerformLayout(); this.gbTotals.ResumeLayout(false); this.gbTotals.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.GroupBox gbAM; private System.Windows.Forms.GroupBox gbControls; private System.Windows.Forms.GroupBox gbPM; private System.Windows.Forms.Button bDayBack; private System.Windows.Forms.Button bDayForward; private System.Windows.Forms.Label lAMName; private System.Windows.Forms.Label lAMAdj; private System.Windows.Forms.Label lAMSugg; private System.Windows.Forms.Label lAMID; private System.Windows.Forms.Label lDate; private System.Windows.Forms.Label lDay; private System.Windows.Forms.Button btnSave; private System.Windows.Forms.Button <API key>; private System.Windows.Forms.Button btnSettings; private System.Windows.Forms.Button btnReset; private System.Windows.Forms.Label lPMAdj; private System.Windows.Forms.Label lPMSugg; private System.Windows.Forms.Label lPMID; private System.Windows.Forms.Label lPMName; private System.Windows.Forms.MenuStrip msMenu; private System.Windows.Forms.ToolStripMenuItem mFile; private System.Windows.Forms.ToolStripMenuItem miJump; private System.Windows.Forms.ToolStripMenuItem miPrint; private System.Windows.Forms.ToolStripMenuItem miExit; private System.Windows.Forms.ToolStripMenuItem mAbout; private System.Windows.Forms.ToolStripMenuItem miHelp; private System.Windows.Forms.ToolStripMenuItem miAbout; private System.Windows.Forms.Timer tTimer; private System.Windows.Forms.GroupBox gbTotals; private System.Windows.Forms.Label lTotalPMAdj; private System.Windows.Forms.Label lLabTotPMSugg; private System.Windows.Forms.Label lTotalAMSugg; private System.Windows.Forms.Label lTotalAMAdj; private System.Windows.Forms.Label lLabTotAMSugg; private System.Windows.Forms.Label lTotalPMSugg; private System.Windows.Forms.Label lTotalSugg; private System.Windows.Forms.Label lTotalAdj; private System.Windows.Forms.Label lLabTotSug; private System.Windows.Forms.TextBox tbAMUnallocatedSugg; private System.Windows.Forms.Label lblAMUnallocated; private System.Windows.Forms.TextBox tbPMUnallocatedSugg; private System.Windows.Forms.Label lblPMUnallocated; private System.Windows.Forms.TextBox tbAMUnallocatedAdj; private System.Windows.Forms.Label <API key>; private System.Windows.Forms.TextBox tbPMUnallocatedAdj; private System.Windows.Forms.Label <API key>; } }
using SFML.Graphics; using SFML.Window; namespace LudumDare.ParticleSystem { public class Emitter { public Vector2f Position; public int ParticlesSpawnRate; public float Spread; public Color Color; } }
#include "SDL_config.h" #include "SDL_mouse.h" #include "../../events/SDL_events_c.h" #include "SDL_vglvideo.h" #include "SDL_vglmouse_c.h" struct WMcursor { int unused; }; void VGL_FreeWMCursor(_THIS, WMcursor *cursor) { return; } WMcursor *VGL_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) { return(NULL); } int VGL_ShowWMCursor(_THIS, WMcursor *cursor) { return(0); } void VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { <API key>(0, 0, x, y); }
#include <cmath> #include <QDebug> #include <QString> #include "common.h" #include "point.h" Point::Point(int x, int y) : x(x), y(y) { } Point::Point(const QPoint& p) : x(p.x()), y(p.y()) { } Point::Point() { } Point::Point(const QString& str, int ysize) { x = y = -1; int length = str.length(); if(length == 0) return; if(str[0].isLetter()) { char c = str[0].toAscii(); if(c >= 'a' && c <= 'z') x = c-'a'; else if(c >= 'A' && c <= 'Z') x = c-'A'; if(length>1) y = ysize - str.mid(1).toInt(); } else y = ysize - str.toInt(); } QString Point::row(int ysize) const { if (y != -1) return QString::number(ysize - y); else return QString(); } QString Point::numcol(int xsize) const { if (x != -1) return QString::number(xsize - x); else return QString(); } QString Point::col() const { if (x != -1) { if(x >= 26) return QChar(static_cast<char>(x - 26 + 'A')); else return QChar(static_cast<char>(x + 'a')); } else return QString(); } QString Point::alpharow() const { if (y != -1) { if(y >= 26) return QChar(static_cast<char>(y - 26 + 'A')); else return QChar(static_cast<char>(y + 'a')); } else return QString(); } QString Point::toString(int ysize) const { return col() + row(ysize); } Point Point::operator+(const Point& other) const { return Point(x + other.x, y + other.y); } Point Point::operator+=(const Point& other) { return *this = *this + other; } Point Point::operator-() const { return Point(-x, -y); } Point Point::operator-(const Point& other) const { return Point(x - other.x, y - other.y); } Point Point::operator*(int n) const { return Point(x * n, y * n); } Point Point::operator/(int n) const { return Point(x / n, y / n); } Point Point::div(int n) const { return Point(x >= 0 ? x / n : x / n - 1, y >= 0 ? y / n : y / n - 1); } bool Point::operator==(const Point& other) const { return x == other.x && y == other.y; } bool Point::operator!=(const Point& other) const { return !(*this == other); } bool Point::operator<(const Point& other) const { return y < other.y || (y == other.y && x < other.x); } bool Point::operator<=(const Point& other) const { return y <= other.y || (y == other.y && x <= other.x); } bool Point::resembles(const Point& other) const { return (other.x == -1 || x == other.x) && (other.y == -1 || y == other.y); } Point::operator QPoint() const { return QPoint(x,y); } Point Point::normalizeInfinity() const { return Point( <API key>(x), <API key>(y) ); } double Point::norm() const { return sqrt((double)(x*x + y*y)); } int Point::<API key>(int n) const { if (n == 0) return 0; else return n > 0 ? 1 : -1; } QDebug operator<<(QDebug dbg, const Point& p) { dbg << "(" << (p.x == -1 ? QString("?") : QString::number(p.x)) << ", " << (p.y == -1 ? QString("?") : QString::number(p.y)) << ")"; return dbg; }
<!DOCTYPE HTML PUBLIC "- <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_04) on Thu May 15 10:36:11 IDT 2014 --> <title>Painter (Codename One API)</title> <meta name="date" content="2014-05-15"> <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><! if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Painter (Codename One API)"; } </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <div class="topNav"><a name="navbar_top"> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-all.html">Index</a></li> <li><a href="../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../com/codename1/ui/MenuBar.html" title="class in com.codename1.ui"><span class="strong">Prev Class</span></a></li> <li><a href="../../../com/codename1/ui/PeerComponent.html" title="class in com.codename1.ui"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../index.html?com/codename1/ui/Painter.html" target="_top">Frames</a></li> <li><a href="Painter.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Constr&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Constr&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_top"> </a></div> <div class="header"> <div class="subTitle">com.codename1.ui</div> <h2 title="Interface Painter" class="title">Interface Painter</h2> </div> <div class="contentContainer"> <div class="description"> <ul class="blockList"> <li class="blockList"> <dl> <dt>All Known Implementing Classes:</dt> <dd><a href="../../../com/codename1/ui/painter/BackgroundPainter.html" title="class in com.codename1.ui.painter">BackgroundPainter</a>, <a href="../../../com/codename1/ui/util/GlassTutorial.html" title="class in com.codename1.ui.util">GlassTutorial</a>, <a href="../../../com/codename1/ui/painter/PainterChain.html" title="class in com.codename1.ui.painter">PainterChain</a>, <a href="../../../com/codename1/ui/animations/Timeline.html" title="class in com.codename1.ui.animations">Timeline</a></dd> </dl> <hr> <br> <pre>public interface <span class="strong">Painter</span></pre> <div class="block">Painter can be used to draw on components backgrounds. The use of such painter allows reuse of a background painters for various components. Note in order to view the painter drawing, component need to have some level of transparency.</div> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="method_summary"> </a> <h3>Method Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><strong><a href="../../../com/codename1/ui/Painter.html#paint(com.codename1.ui.Graphics, com.codename1.ui.geom.Rectangle)">paint</a></strong>(<a href="../../../com/codename1/ui/Graphics.html" title="class in com.codename1.ui">Graphics</a>&nbsp;g, <a href="../../../com/codename1/ui/geom/Rectangle.html" title="class in com.codename1.ui.geom">Rectangle</a>&nbsp;rect)</code> <div class="block">Draws inside the given rectangle clipping area.</div> </td> </tr> </table> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="method_detail"> </a> <h3>Method Detail</h3> <a name="paint(com.codename1.ui.Graphics, com.codename1.ui.geom.Rectangle)"> </a> <ul class="blockListLast"> <li class="blockList"> <h4>paint</h4> <pre>void&nbsp;paint(<a href="../../../com/codename1/ui/Graphics.html" title="class in com.codename1.ui">Graphics</a>&nbsp;g, <a href="../../../com/codename1/ui/geom/Rectangle.html" title="class in com.codename1.ui.geom">Rectangle</a>&nbsp;rect)</pre> <div class="block">Draws inside the given rectangle clipping area.</div> <dl><dt><span class="strong">Parameters:</span></dt><dd><code>g</code> - the <a href="../../../com/codename1/ui/Graphics.html" title="class in com.codename1.ui"><code>Graphics</code></a> object</dd><dd><code>rect</code> - the given rectangle cliping area</dd></dl> </li> </ul> </li> </ul> </li> </ul> </div> </div> <div class="bottomNav"><a name="navbar_bottom"> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="<API key>"> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-all.html">Index</a></li> <li><a href="../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../com/codename1/ui/MenuBar.html" title="class in com.codename1.ui"><span class="strong">Prev Class</span></a></li> <li><a href="../../../com/codename1/ui/PeerComponent.html" title="class in com.codename1.ui"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../index.html?com/codename1/ui/Painter.html" target="_top">Frames</a></li> <li><a href="Painter.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Constr&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Constr&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_bottom"> </a></div> </body> </html>
# class.upload by verot.net ## contributor github.com/paulds # v0.31 Download from verot.net/<API key>.htm This version is not PHP 5.3 compatible
package org.freeplane.core.resources.components; import javax.swing.JButton; import com.jgoodies.forms.builder.DefaultFormBuilder; public class ButtonProperty extends PropertyBean implements IPropertyControl { final JButton mButton; public ButtonProperty(final String name, JButton button) { super(name); mButton = button; } @Override public String getValue() { return ""; } public void appendToForm(final DefaultFormBuilder builder) { appendToForm(builder, mButton); } public void setEnabled(final boolean pEnabled) { mButton.setEnabled(pEnabled); super.setEnabled(pEnabled); } @Override public void setValue(final String value) { } public void setToolTipText(String text) { mButton.setToolTipText(text); } }
// logs.cpp // Rivendell web service portal -- Log services // This program is free software; you can redistribute it and/or modify // published by the Free Software Foundation. // This program is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // You should have received a copy of the GNU General Public // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <rdcreate_log.h> #include <rddb.h> #include <rdformpost.h> #include <rdweb.h> #include <rdsvc.h> #include <rduser.h> #include <rdlog.h> #include <rdlog_event.h> #include <rdlog_line.h> #include <rdconf.h> #include <rdescape_string.h> #include <rdxport.h> void Xport::AddLog() { QString log_name; QString service_name; // Get Arguments if(!xport_post->getValue("LOG_NAME",&log_name)) { XmlExit("Missing LOG_NAME",400,"logs.cpp",LINE_NUMBER); } if(!xport_post->getValue("SERVICE_NAME",&service_name)) { XmlExit("Missing SERVICE_NAME",400,"logs.cpp",LINE_NUMBER); } RDSvc *svc=new RDSvc(service_name); if(!svc->exists()) { XmlExit("No such service",404,"logs.cpp",LINE_NUMBER); } // Verify User Perms if(!xport_user->createLog()) { XmlExit("Unauthorized",404,"logs.cpp",LINE_NUMBER); } RDLog *log=new RDLog(log_name); if(!log->exists()) { delete log; log=new RDLog(log_name,true); if(!log->exists()) { delete log; XmlExit("Unable to create log",500,"logs.cpp",LINE_NUMBER); } log->setOriginUser(xport_user->name()); log->setDescription("[new log]"); log->setService(service_name); } delete log; RDCreateLogTable(RDLog::tableName(log_name)); XmlExit("OK",200,"logs.cpp",LINE_NUMBER); } void Xport::DeleteLog() { QString log_name; // Get Arguments if(!xport_post->getValue("LOG_NAME",&log_name)) { XmlExit("Missing LOG_NAME",400,"logs.cpp",LINE_NUMBER); } // Verify User Perms if(!xport_user->deleteLog()) { XmlExit("Unauthorized",404,"logs.cpp",LINE_NUMBER); } RDLog *log=new RDLog(log_name); if(log->exists()) { if(!log->remove(xport_station,xport_user,xport_config)) { delete log; XmlExit("Unable to delete log",500,"logs.cpp",LINE_NUMBER); } } delete log; XmlExit("OK",200,"logs.cpp",LINE_NUMBER); } void Xport::ListLogs() { QString sql; RDSqlQuery *q; RDLog *log; QString service_name=""; QString log_name=""; QString trackable; // Get Options xport_post->getValue("SERVICE_NAME",&service_name); xport_post->getValue("LOG_NAME",&log_name); xport_post->getValue("TRACKABLE",&trackable); // Generate Log List sql="select NAME from LOGS"; if((!service_name.isEmpty())||(!log_name.isEmpty())||(trackable=="1")) { sql+=" where"; if(!log_name.isEmpty()) { sql+=" (NAME=\""+RDEscapeString(log_name)+"\")&&"; } if(!service_name.isEmpty()) { sql+=" (SERVICE=\""+RDEscapeString(service_name)+"\")&&"; } if(trackable=="1") { sql+=" (SCHEDULED_TRACKS>0)&&"; } sql=sql.left(sql.length()-2); } sql+=" order by NAME"; q=new RDSqlQuery(sql); // Process Request printf("Content-type: application/xml\n"); printf("Status: 200\n\n"); printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); printf("<logList>\n"); while(q->next()) { log=new RDLog(q->value(0).toString()); printf("%s",(const char *)log->xml()); delete log; } printf("</logList>\n"); delete q; Exit(0); } void Xport::ListLog() { RDLog *log; QString name=""; // Get Options xport_post->getValue("NAME",&name); // Verify that log exists log=new RDLog(name); if(!log->exists()) { delete log; XmlExit("No such log",404,"logs.cpp",LINE_NUMBER); } // Generate Log Listing RDLogEvent *log_event=log->createLogEvent(); log_event->load(true); // Process Request printf("Content-type: application/xml\n"); printf("Status: 200\n\n"); printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); printf("%s\n",(const char *)log_event->xml()); Exit(0); } void Xport::SaveLog() { // Verify User Perms if((!xport_user->addtoLog())||(!xport_user->removefromLog())||(!xport_user->arrangeLog())) { XmlExit("No user privilege",404,"logs.cpp",LINE_NUMBER); } QString log_name; QString service_name; QString description; QDate purge_date; bool auto_refresh; QDate start_date; QDate end_date; int line_quantity; // Header Data if(!xport_post->getValue("LOG_NAME",&log_name)) { XmlExit("Missing LOG_NAME",400,"logs.cpp",LINE_NUMBER); } if(!xport_post->getValue("SERVICE_NAME",&service_name)) { XmlExit("Missing SERVICE_NAME",400,"logs.cpp",LINE_NUMBER); } if(!xport_post->getValue("DESCRIPTION",&description)) { XmlExit("Missing DESCRIPTION",400,"logs.cpp",LINE_NUMBER); } if(!xport_post->getValue("PURGE_DATE",&purge_date)) { XmlExit("Missing PURGE_DATE",400,"logs.cpp",LINE_NUMBER); } if(!xport_post->getValue("AUTO_REFRESH",&auto_refresh)) { XmlExit("Missing AUTO_REFRESH",400,"logs.cpp",LINE_NUMBER); } if(!xport_post->getValue("START_DATE",&start_date)) { XmlExit("Missing START_DATE",400,"logs.cpp",LINE_NUMBER); } if(!xport_post->getValue("END_DATE",&end_date)) { XmlExit("Missing END_DATE",400,"logs.cpp",LINE_NUMBER); } if(!xport_post->getValue("LINE_QUANTITY",&line_quantity)) { XmlExit("Missing LINE_QUANTITY",400,"logs.cpp",LINE_NUMBER); } // Logline Data RDLogEvent *logevt=new RDLogEvent(RDLog::tableName(log_name)); for(int i=0;i<line_quantity;i++) { logevt->insert(i,1); RDLogLine *ll=logevt->logLine(i); QString line=QString().sprintf("LINE%d",i); QString str; int integer1; int integer2; QDateTime datetime; QTime time; bool state; bool ok=false; if(!xport_post->getValue(line+"_ID",&integer1,&ok)) { XmlExit("Missing "+line+"_ID",400,"logs.cpp",LINE_NUMBER); } if(!ok) { XmlExit("Invalid "+line+"_ID",400,"logs.cpp",LINE_NUMBER); } ll->setId(integer1); if(!xport_post->getValue(line+"_TYPE",&integer1)) { XmlExit("Missing "+line+"_TYPE",400,"logs.cpp",LINE_NUMBER); } ll->setType((RDLogLine::Type)integer1); if(!xport_post->getValue(line+"_CART_NUMBER",&integer1)) { XmlExit("Missing "+line+"_CART_NUMBER",400,"logs.cpp",LINE_NUMBER); } ll->setCartNumber(integer1); if(!xport_post->getValue(line+"_TIME_TYPE",&integer2)) { XmlExit("Missing "+line+"_TIME_TYPE",400,"logs.cpp",LINE_NUMBER); } ll->setTimeType((RDLogLine::TimeType)integer2); if(!xport_post->getValue(line+"_START_TIME",&integer1)) { XmlExit("Missing "+line+"_START_TIME",400,"logs.cpp",LINE_NUMBER); } if(ll->timeType()==RDLogLine::Hard) { ll->setStartTime(RDLogLine::Logged,QTime().addMSecs(integer1)); } else { ll->setStartTime(RDLogLine::Predicted,QTime().addMSecs(integer1)); } if(!xport_post->getValue(line+"_GRACE_TIME",&integer1)) { XmlExit("Missing "+line+"_GRACE_TIME",400,"logs.cpp",LINE_NUMBER); } ll->setGraceTime(integer1); if(!xport_post->getValue(line+"_TRANS_TYPE",&str)) { XmlExit("Missing "+line+"_TRANS_TYPE",400,"logs.cpp",LINE_NUMBER); } integer1=-1; if(str.lower()=="play") { integer1=RDLogLine::Play; } if(str.lower()=="segue") { integer1=RDLogLine::Segue; } if(str.lower()=="stop") { integer1=RDLogLine::Stop; } if(integer1<0) { XmlExit("Invalid transition type in "+line+"_TRANS_TYPE",400, "logs.cpp",LINE_NUMBER); } ll->setTransType((RDLogLine::TransType)integer1); if(!xport_post->getValue(line+"_START_POINT",&integer1)) { XmlExit("Missing "+line+"_START_POINT",400,"logs.cpp",LINE_NUMBER); } ll->setStartPoint(integer1,RDLogLine::LogPointer); if(!xport_post->getValue(line+"_END_POINT",&integer1)) { XmlExit("Missing "+line+"_END_POINT",400,"logs.cpp",LINE_NUMBER); } ll->setEndPoint(integer1,RDLogLine::LogPointer); if(!xport_post->getValue(line+"_SEGUE_START_POINT",&integer1)) { XmlExit("Missing "+line+"_SEGUE_START_POINT",400,"logs.cpp",LINE_NUMBER); } ll->setSegueStartPoint(integer1,RDLogLine::LogPointer); if(!xport_post->getValue(line+"_SEGUE_END_POINT",&integer1)) { XmlExit("Missing "+line+"_SEGUE_END_POINT",400,"logs.cpp",LINE_NUMBER); } ll->setSegueEndPoint(integer1,RDLogLine::LogPointer); if(!xport_post->getValue(line+"_FADEUP_POINT",&integer1)) { XmlExit("Missing "+line+"_FADEUP_POINT",400,"logs.cpp",LINE_NUMBER); } ll->setFadeupPoint(integer1,RDLogLine::LogPointer); if(!xport_post->getValue(line+"_FADEUP_GAIN",&integer1)) { XmlExit("Missing "+line+"_FADEUP_GAIN",400,"logs.cpp",LINE_NUMBER); } ll->setFadeupGain(integer1); if(!xport_post->getValue(line+"_FADEDOWN_POINT",&integer1)) { XmlExit("Missing "+line+"_FADEDOWN_POINT",400,"logs.cpp",LINE_NUMBER); } ll->setFadedownPoint(integer1,RDLogLine::LogPointer); if(!xport_post->getValue(line+"_FADEDOWN_GAIN",&integer1)) { XmlExit("Missing "+line+"_FADEDOWN_GAIN",400,"logs.cpp",LINE_NUMBER); } ll->setFadedownGain(integer1); if(!xport_post->getValue(line+"_DUCK_UP_GAIN",&integer1)) { XmlExit("Missing "+line+"_DUCK_UP_GAIN",400,"logs.cpp",LINE_NUMBER); } ll->setDuckUpGain(integer1); if(!xport_post->getValue(line+"_DUCK_DOWN_GAIN",&integer1)) { XmlExit("Missing "+line+"_DUCK_DOWN_GAIN",400,"logs.cpp",LINE_NUMBER); } ll->setDuckDownGain(integer1); if(!xport_post->getValue(line+"_COMMENT",&str)) { XmlExit("Missing "+line+"_COMMENT",400,"logs.cpp",LINE_NUMBER); } ll->setMarkerComment(str); if(!xport_post->getValue(line+"_LABEL",&str)) { XmlExit("Missing "+line+"_LABEL",400,"logs.cpp",LINE_NUMBER); } ll->setMarkerLabel(str); if(!xport_post->getValue(line+"_ORIGIN_USER",&str)) { XmlExit("Missing "+line+"_ORIGIN_USER",400,"logs.cpp",LINE_NUMBER); } ll->setOriginUser(str); if(!xport_post->getValue(line+"_ORIGIN_DATETIME",&datetime)) { XmlExit("Missing "+line+"_ORIGIN_DATETIME",400,"logs.cpp",LINE_NUMBER); } ll->setOriginDateTime(datetime); if(!xport_post->getValue(line+"_EVENT_LENGTH",&integer1)) { XmlExit("Missing "+line+"_EVENT_LENGTH",400,"logs.cpp",LINE_NUMBER); } ll->setEventLength(integer1); if(!xport_post->getValue(line+"_LINK_EVENT_NAME",&str)) { XmlExit("Missing "+line+"_LINK_EVENT_NAME",400,"logs.cpp",LINE_NUMBER); } ll->setLinkEventName(str); if(!xport_post->getValue(line+"_LINK_START_TIME",&integer1)) { XmlExit("Missing "+line+"_LINK_START_TIME",400,"logs.cpp",LINE_NUMBER); } ll->setLinkStartTime(QTime().addMSecs(integer1)); if(!xport_post->getValue(line+"_LINK_LENGTH",&integer1)) { XmlExit("Missing "+line+"_LINK_LENGTH",400,"logs.cpp",LINE_NUMBER); } ll->setLinkLength(integer1); if(!xport_post->getValue(line+"_LINK_START_SLOP",&integer1)) { XmlExit("Missing "+line+"_LINK_START_SLOP",400,"logs.cpp",LINE_NUMBER); } ll->setLinkStartSlop(integer1); if(!xport_post->getValue(line+"_LINK_END_SLOP",&integer1)) { XmlExit("Missing "+line+"_LINK_END_SLOP",400,"logs.cpp",LINE_NUMBER); } ll->setLinkEndSlop(integer1); if(!xport_post->getValue(line+"_LINK_ID",&integer1)) { XmlExit("Missing "+line+"_LINK_ID",400,"logs.cpp",LINE_NUMBER); } ll->setLinkId(integer1); if(!xport_post->getValue(line+"_LINK_EMBEDDED",&state)) { XmlExit("Missing "+line+"_LINK_EMBEDDED",400,"logs.cpp",LINE_NUMBER); } ll->setLinkEmbedded(state); if(!xport_post->getValue(line+"_EXT_START_TIME",&time)) { XmlExit("Missing "+line+"_EXT_START_TIME",400,"logs.cpp",LINE_NUMBER); } ll->setExtStartTime(time); if(!xport_post->getValue(line+"_EXT_CART_NAME",&str)) { XmlExit("Missing "+line+"_EXT_CART_NAME",400,"logs.cpp",LINE_NUMBER); } ll->setExtCartName(str); if(!xport_post->getValue(line+"_EXT_DATA",&str)) { XmlExit("Missing "+line+"_EXT_DATA",400,"logs.cpp",LINE_NUMBER); } ll->setExtData(str); if(!xport_post->getValue(line+"_EXT_EVENT_ID",&str)) { XmlExit("Missing "+line+"_EXT_EVENT_ID",400,"logs.cpp",LINE_NUMBER); } ll->setExtEventId(str); if(!xport_post->getValue(line+"_EXT_ANNC_TYPE",&str)) { XmlExit("Missing "+line+"_EXT_ANNC_TYPE",400,"logs.cpp",LINE_NUMBER); } ll->setExtAnncType(str); } RDLog *log=new RDLog(log_name); if(!log->exists()) { XmlExit("No such log",404,"logs.cpp",LINE_NUMBER); } log->setService(service_name); log->setDescription(description); log->setPurgeDate(purge_date); log->setAutoRefresh(auto_refresh); log->setStartDate(start_date); log->setEndDate(end_date); log->setModifiedDatetime(QDateTime::currentDateTime()); logevt->save(); XmlExit(QString().sprintf("OK Saved %d events",logevt->size()), 200,"logs.cpp",LINE_NUMBER); }
// The layout borrows heavily from kmsearchpatternedit.cpp in kmail // which is authored by Marc Mutz <Marc@Mutz.com> under the GPL #include "filterdialog.h" #include "tellico_kernel.h" #include "document.h" #include "collection.h" #include "fieldcompletion.h" #include "gui/<API key>.h" #include "gui/filterrulewidget.h" #include "tellico_debug.h" #include <KLocalizedString> #include <KHelpClient> #include <QGroupBox> #include <QRadioButton> #include <QButtonGroup> #include <QLabel> #include <QApplication> #include <QFrame> #include <QVBoxLayout> #include <QPushButton> #include <QLineEdit> #include <QDialogButtonBox> using Tellico::FilterDialog; namespace { static const int FILTER_MIN_WIDTH = 600; } // modal dialog so I don't have to worry about updating stuff // don't show apply button if not saving, i.e. just modifying existing filter FilterDialog::FilterDialog(Mode mode_, QWidget* parent_) : QDialog(parent_), m_filter(nullptr), m_mode(mode_), m_saveFilter(nullptr) { setModal(true); setWindowTitle(mode_ == CreateFilter ? i18n("Advanced Filter") : i18n("Modify Filter")); QVBoxLayout* topLayout = new QVBoxLayout(); setLayout(topLayout); QDialogButtonBox* buttonBox; if(mode_ == CreateFilter) { buttonBox = new QDialogButtonBox(QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Apply); } else { buttonBox = new QDialogButtonBox(QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Cancel); } m_okButton = buttonBox->button(QDialogButtonBox::Ok); m_applyButton = buttonBox->button(QDialogButtonBox::Apply); connect(m_okButton, &QAbstractButton::clicked, this, &FilterDialog::slotOk); if(m_applyButton) { connect(m_applyButton, &QAbstractButton::clicked, this, &FilterDialog::slotApply); } connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(buttonBox, &QDialogButtonBox::helpRequested, this, &FilterDialog::slotHelp); QGroupBox* m_matchGroup = new QGroupBox(i18n("Filter Criteria"), this); QVBoxLayout* vlay = new QVBoxLayout(m_matchGroup); topLayout->addWidget(m_matchGroup); m_matchGroup->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); m_matchAll = new QRadioButton(i18n("Match a&ll of the following"), m_matchGroup); m_matchAny = new QRadioButton(i18n("Match an&y of the following"), m_matchGroup); m_matchAll->setChecked(true); vlay->addWidget(m_matchAll); vlay->addWidget(m_matchAny); QButtonGroup* bg = new QButtonGroup(m_matchGroup); bg->addButton(m_matchAll); bg->addButton(m_matchAny); #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) void (QButtonGroup::* buttonClicked)(int) = &QButtonGroup::buttonClicked; connect(bg, buttonClicked, this, &FilterDialog::slotFilterChanged); #else connect(bg, &QButtonGroup::idClicked, this, &FilterDialog::slotFilterChanged); #endif m_ruleLister = new <API key>(m_matchGroup); connect(m_ruleLister, &KWidgetLister::widgetRemoved, this, &FilterDialog::slotShrink); connect(m_ruleLister, &<API key>::signalModified, this, &FilterDialog::slotFilterChanged); m_ruleLister->setFocus(); vlay->addWidget(m_ruleLister); QHBoxLayout* blay = new QHBoxLayout(); topLayout->addLayout(blay); QLabel* lab = new QLabel(i18n("Filter name:"), this); blay->addWidget(lab); m_filterName = new QLineEdit(this); blay->addWidget(m_filterName); connect(m_filterName, &QLineEdit::textChanged, this, &FilterDialog::slotFilterChanged); // only when creating a new filter can it be saved if(m_mode == CreateFilter) { m_saveFilter = new QPushButton(QIcon::fromTheme(QStringLiteral("view-filter")), i18n("&Save Filter"), this); blay->addWidget(m_saveFilter); m_saveFilter->setEnabled(false); connect(m_saveFilter, &QAbstractButton::clicked, this, &FilterDialog::slotSaveFilter); m_applyButton->setEnabled(false); } m_okButton->setEnabled(false); // disable at start buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true); setMinimumWidth(qMax(minimumWidth(), FILTER_MIN_WIDTH)); topLayout->addWidget(buttonBox); } Tellico::FilterPtr FilterDialog::currentFilter(bool alwaysCreateNew_) { FilterPtr newFilter(new Filter(Filter::MatchAny)); if(m_matchAll->isChecked()) { newFilter->setMatch(Filter::MatchAll); } else { newFilter->setMatch(Filter::MatchAny); } foreach(QWidget* widget, m_ruleLister->widgetList()) { FilterRuleWidget* rw = static_cast<FilterRuleWidget*>(widget); FilterRule* rule = rw->rule(); if(rule && !rule->isEmpty()) { newFilter->append(rule); } else { delete rule; } } newFilter->setName(m_filterName->text()); if(!m_filter || !alwaysCreateNew_) { m_filter = newFilter; } return newFilter; } void FilterDialog::setFilter(Tellico::FilterPtr filter_) { if(!filter_) { slotClear(); return; } if(filter_->op() == Filter::MatchAll) { m_matchAll->setChecked(true); } else { m_matchAny->setChecked(true); } m_ruleLister->setFilter(filter_); m_filterName->setText(filter_->name()); m_filter = filter_; } void FilterDialog::slotOk() { slotApply(); accept(); } void FilterDialog::slotApply() { emit signalUpdateFilter(currentFilter()); } void FilterDialog::slotHelp() { KHelpClient::invokeHelp(QStringLiteral("filter-dialog")); } void FilterDialog::slotClear() { // myDebug(); m_matchAll->setChecked(true); m_ruleLister->reset(); m_filterName->clear(); } void FilterDialog::slotShrink() { updateGeometry(); QApplication::sendPostedEvents(); resize(width(), sizeHint().height()); } void FilterDialog::slotFilterChanged() { const bool hadFilter = m_filter && !m_filter->isEmpty(); const bool emptyFilter = currentFilter(true)->isEmpty(); // an empty filter can be ok if the filter was originally not empty const bool enableOk = !currentFilter()->isEmpty() || hadFilter; if(m_saveFilter) { m_saveFilter->setEnabled(!m_filterName->text().isEmpty() && !emptyFilter); if(m_applyButton) { m_applyButton->setEnabled(!emptyFilter); } } if(m_applyButton) { m_applyButton->setEnabled(enableOk); } m_okButton->setEnabled(enableOk); m_okButton->setDefault(enableOk); } void FilterDialog::slotSaveFilter() { // non-op if editing an existing filter if(m_mode != CreateFilter) { return; } // in this case, currentFilter() either creates a new filter or // updates the current one. If creating a new one, then I want to copy it const bool wasEmpty = !m_filter; FilterPtr filter(new Filter(*currentFilter())); if(wasEmpty) { m_filter = filter; } // this keeps the saving completely decoupled from the filter setting in the detailed view if(filter->isEmpty()) { m_filter = FilterPtr(); return; } Kernel::self()->addFilter(filter); }
#ifndef LMP_KSPACE_H #define LMP_KSPACE_H #include "pointers.h" // IWYU pragma: export #ifdef FFT_SINGLE typedef float FFT_SCALAR; #define MPI_FFT_SCALAR MPI_FLOAT #else typedef double FFT_SCALAR; #define MPI_FFT_SCALAR MPI_DOUBLE #endif namespace LAMMPS_NS { class KSpace : protected Pointers { friend class ThrOMP; friend class FixOMP; public: double energy; // accumulated energies double energy_1,energy_6; double virial[6]; // accumulated virial double *eatom,**vatom; // accumulated per-atom energy/virial double e2group; // accumulated group-group energy double f2group[3]; // accumulated group-group force int triclinic_support; // 1 if supports triclinic geometries int ewaldflag; // 1 if a Ewald solver int pppmflag; // 1 if a PPPM solver int msmflag; // 1 if a MSM solver int dispersionflag; // 1 if a LJ/dispersion solver int tip4pflag; // 1 if a TIP4P solver int dipoleflag; // 1 if a dipole solver int spinflag; // 1 if a spin solver int <API key>; int neighrequest_flag; // used to avoid obsolete construction // of neighbor lists int mixflag; // 1 if geometric mixing rules are enforced // for LJ coefficients int slabflag; int <API key>; // 1 if using MSM fast scalar pressure double slab_volfactor; int warn_nonneutral; // 0 = error if non-neutral system // 1 = warn once if non-neutral system // 2 = warn, but already warned int warn_nocharge; // 0 = already warned // 1 = warn if zero charge int order,order_6,order_allocated; double accuracy; // accuracy of KSpace solver (force units) double accuracy_absolute; // user-specified accuracy in force units double accuracy_relative; // user-specified dimensionless accuracy // accurary = acc_rel * two_charge_force double accuracy_real_6; // real space accuracy for // dispersion solver (force units) double accuracy_kspace_6; // reciprocal space accuracy for // dispersion solver (force units) int auto_disp_flag; // use automatic parameter generation for pppm/disp double two_charge_force; // force in user units of two point // charges separated by 1 Angstrom double g_ewald,g_ewald_6; int nx_pppm,ny_pppm,nz_pppm; // global FFT grid for Coulombics int nx_pppm_6,ny_pppm_6,nz_pppm_6; // global FFT grid for dispersion int nx_msm_max,ny_msm_max,nz_msm_max; int group_group_enable; // 1 if style supports group/group calculation // KOKKOS host/device flag and data masks ExecutionSpace execution_space; unsigned int datamask_read,datamask_modify; int copymode; int compute_flag; // 0 if skip compute() int fftbench; // 0 if skip FFT timing int collective_flag; // 1 if use MPI collectives for FFT/remap int stagger_flag; // 1 if using staggered PPPM grids double splittol; // tolerance for when to truncate splitting KSpace(class LAMMPS *); virtual ~KSpace(); void two_charge(); void triclinic_check(); void modify_params(int, char **); void *extract(const char *); void compute_dummy(int, int); // triclinic void x2lamdaT(double *, double *); void lamda2xT(double *, double *); void lamda2xvector(double *, double *); void kspacebbox(double, double *); // public so can be called by commands that change charge void qsum_qsq(int warning_flag = 1); // general child-class methods virtual void settings(int, char **) {}; virtual void init() = 0; virtual void setup() = 0; virtual void setup_grid() {}; virtual void compute(int, int) = 0; virtual void compute_group_group(int, int, int) {}; virtual void pack_forward(int, FFT_SCALAR *, int, int *) {}; virtual void unpack_forward(int, FFT_SCALAR *, int, int *) {}; virtual void pack_reverse(int, FFT_SCALAR *, int, int *) {}; virtual void unpack_reverse(int, FFT_SCALAR *, int, int *) {}; virtual int timing(int, double &, double &) {return 0;} virtual int timing_1d(int, double &) {return 0;} virtual int timing_3d(int, double &) {return 0;} virtual int modify_param(int, char **) {return 0;} virtual double memory_usage() {return 0.0;} double gamma(const double &rho) const { if (rho <= 1.0) { const int split_order = order/2; const double rho2 = rho*rho; double g = gcons[split_order][0]; double rho_n = rho2; for (int n = 1; n <= split_order; n++) { g += gcons[split_order][n]*rho_n; rho_n *= rho2; } return g; } else return (1.0/rho); } double dgamma(const double &rho) const { if (rho <= 1.0) { const int split_order = order/2; const double rho2 = rho*rho; double dg = dgcons[split_order][0]*rho; double rho_n = rho*rho2; for (int n = 1; n < split_order; n++) { dg += dgcons[split_order][n]*rho_n; rho_n *= rho2; } return dg; } else return (-1.0/rho/rho); } double **get_gcons() { return gcons; } double **get_dgcons() { return dgcons; } protected: int gridflag,gridflag_6; int gewaldflag,gewaldflag_6; int minorder,overlap_allowed; int adjust_cutoff_flag; int suffix_flag; // suffix compatibility flag bigint natoms_original; double scale,qqrd2e; double qsum,qsqsum,q2; double **gcons,**dgcons; // accumulated per-atom energy/virial int evflag,evflag_atom; int eflag_either,eflag_global,eflag_atom; int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; int kewaldflag; // 1 if kspace range set for Ewald sum int kx_ewald,ky_ewald,kz_ewald; // kspace settings for Ewald sum void pair_check(); void ev_init(int eflag, int vflag, int alloc = 1) { if (eflag||vflag) ev_setup(eflag, vflag, alloc); else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; } void ev_setup(int, int, int alloc = 1); double <API key>(double, double); }; } #endif
#include <cstddef> #include <string> #include <vector> #include <wx/chartype.h> #include <wx/defs.h> #include <wx/dynarray.h> #include <wx/event.h> #include <wx/frame.h> #include <wx/gdicmn.h> #include <wx/list.h> #include <wx/menu.h> #include <wx/menuitem.h> #include <wx/msgdlg.h> #include <wx/object.h> #include <wx/panel.h> #include <wx/rtti.h> #include <wx/sizer.h> #include <wx/statusbr.h> #include <wx/string.h> #include <wx/textdlg.h> #include <wx/toplevel.h> #include <wx/translation.h> #include <wx/window.h> #include <wx/windowid.h> #include <wx/aui/auibar.h> #include <wx/aui/auibook.h> #include <wx/aui/framemanager.h> #include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/MathUtil.h" #include "Common/StringUtil.h" #include "Common/Logging/ConsoleListener.h" #include "Core/ConfigManager.h" #include "DolphinWX/Frame.h" #include "DolphinWX/Globals.h" #include "DolphinWX/LogConfigWindow.h" #include "DolphinWX/LogWindow.h" #include "DolphinWX/WxUtils.h" #include "DolphinWX/Debugger/CodeWindow.h" // Aui events void CFrame::OnManagerResize(wxAuiManagerEvent& event) { if (!g_pCodeWindow && m_LogWindow && m_Mgr->GetPane("Pane 1").IsShown() && !m_Mgr->GetPane("Pane 1").IsFloating()) { m_LogWindow->x = m_Mgr->GetPane("Pane 1").rect.GetWidth(); m_LogWindow->y = m_Mgr->GetPane("Pane 1").rect.GetHeight(); m_LogWindow->winpos = m_Mgr->GetPane("Pane 1").dock_direction; } event.Skip(); } void CFrame::OnPaneClose(wxAuiManagerEvent& event) { event.Veto(); wxAuiNotebook * nb = (wxAuiNotebook*)event.pane->window; if (!nb) return; if (!g_pCodeWindow) { if (nb->GetPage(0)->GetId() == IDM_LOGWINDOW || nb->GetPage(0)->GetId() == IDM_LOGCONFIGWINDOW) { SConfig::GetInstance().<API key> = false; SConfig::GetInstance().<API key> = false; ToggleLogWindow(false); <API key>(false); } } else { if (GetNotebookCount() == 1) { wxMessageBox(_("At least one pane must remain open."), _("Notice"), wxOK, this); } else if (nb->GetPageCount() != 0 && !nb->GetPageText(0).IsSameAs("<>")) { wxMessageBox(_("You can't close panes that have pages in them."), _("Notice"), wxOK, this); } else { // Detach and delete the empty notebook event.pane->DestroyOnClose(true); m_Mgr->ClosePane(*event.pane); } } m_Mgr->Update(); } void CFrame::ToggleLogWindow(bool bShow) { if (!m_LogWindow) return; GetMenuBar()->FindItem(IDM_LOGWINDOW)->Check(bShow); if (bShow) { // Create a new log window if it doesn't exist. if (!m_LogWindow) { m_LogWindow = new CLogWindow(this, IDM_LOGWINDOW); } m_LogWindow->Enable(); DoAddPage(m_LogWindow, g_pCodeWindow ? g_pCodeWindow->iNbAffiliation[0] : 0, g_pCodeWindow ? bFloatWindow[0] : false); } else { // Hiding the log window, so disable it and remove it. m_LogWindow->Disable(); DoRemovePage(m_LogWindow, true); } // Hide or Show the pane if (!g_pCodeWindow) TogglePane(); } void CFrame::<API key>(bool bShow) { GetMenuBar()->FindItem(IDM_LOGCONFIGWINDOW)->Check(bShow); if (bShow) { if (!m_LogConfigWindow) m_LogConfigWindow = new LogConfigWindow(this, m_LogWindow, IDM_LOGCONFIGWINDOW); const int nbIndex = IDM_LOGCONFIGWINDOW - IDM_LOGWINDOW; DoAddPage(m_LogConfigWindow, g_pCodeWindow ? g_pCodeWindow->iNbAffiliation[nbIndex] : 0, g_pCodeWindow ? bFloatWindow[nbIndex] : false); } else { DoRemovePage(m_LogConfigWindow, false); m_LogConfigWindow = nullptr; } // Hide or Show the pane if (!g_pCodeWindow) TogglePane(); } void CFrame::OnToggleWindow(wxCommandEvent& event) { bool bShow = GetMenuBar()->IsChecked(event.GetId()); switch (event.GetId()) { case IDM_LOGWINDOW: if (!g_pCodeWindow) SConfig::GetInstance().<API key> = bShow; ToggleLogWindow(bShow); break; case IDM_LOGCONFIGWINDOW: if (!g_pCodeWindow) SConfig::GetInstance().<API key> = bShow; <API key>(bShow); break; case IDM_REGISTERWINDOW: g_pCodeWindow-><API key>(bShow); break; case IDM_WATCHWINDOW: g_pCodeWindow->ToggleWatchWindow(bShow); break; case <API key>: g_pCodeWindow-><API key>(bShow); break; case IDM_MEMORYWINDOW: g_pCodeWindow->ToggleMemoryWindow(bShow); break; case IDM_JITWINDOW: g_pCodeWindow->ToggleJitWindow(bShow); break; case IDM_SOUNDWINDOW: g_pCodeWindow->ToggleSoundWindow(bShow); break; case IDM_VIDEOWINDOW: g_pCodeWindow->ToggleVideoWindow(bShow); break; } } // Notebooks void CFrame::ClosePages() { ToggleLogWindow(false); <API key>(false); if (g_pCodeWindow) { g_pCodeWindow->ToggleCodeWindow(false); g_pCodeWindow-><API key>(false); g_pCodeWindow->ToggleWatchWindow(false); g_pCodeWindow-><API key>(false); g_pCodeWindow->ToggleMemoryWindow(false); g_pCodeWindow->ToggleJitWindow(false); g_pCodeWindow->ToggleSoundWindow(false); g_pCodeWindow->ToggleVideoWindow(false); } } void CFrame::<API key>(wxAuiNotebookEvent& event) { event.Skip(); if (!g_pCodeWindow) return; // Remove the blank page if any AddRemoveBlankPage(); // Update the notebook affiliation for (int i = IDM_LOGWINDOW; i <= IDM_CODEWINDOW; i++) { if (<API key>(i) >= 0) g_pCodeWindow->iNbAffiliation[i - IDM_LOGWINDOW] = <API key>(i); } } void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event) { // Override event event.Veto(); wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject(); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGWINDOW) ToggleLogWindow(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGCONFIGWINDOW) <API key>(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTERWINDOW) g_pCodeWindow-><API key>(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_WATCHWINDOW) g_pCodeWindow->ToggleWatchWindow(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == <API key>) g_pCodeWindow-><API key>(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_JITWINDOW) g_pCodeWindow->ToggleJitWindow(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_MEMORYWINDOW) g_pCodeWindow->ToggleMemoryWindow(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_SOUNDWINDOW) g_pCodeWindow->ToggleSoundWindow(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_VIDEOWINDOW) g_pCodeWindow->ToggleVideoWindow(false); } void CFrame::<API key>(wxCloseEvent& event) { ToggleFloatWindow(event.GetId() - <API key> + IDM_FLOAT_LOGWINDOW); } void CFrame::OnFloatingPageSize(wxSizeEvent& event) { event.Skip(); } void CFrame::OnFloatWindow(wxCommandEvent& event) { ToggleFloatWindow(event.GetId()); } void CFrame::ToggleFloatWindow(int Id) { wxWindowID WinId = Id - IDM_FLOAT_LOGWINDOW + IDM_LOGWINDOW; if (<API key>(WinId)) { DoFloatNotebookPage(WinId); bFloatWindow[WinId - IDM_LOGWINDOW] = true; } else { if (FindWindowById(WinId)) DoUnfloatPage(WinId - IDM_LOGWINDOW + <API key>); bFloatWindow[WinId - IDM_LOGWINDOW] = false; } } void CFrame::DoFloatNotebookPage(wxWindowID Id) { wxPanel *Win = (wxPanel*)FindWindowById(Id); if (!Win) return; for (int i = 0; i < GetNotebookCount(); i++) { wxAuiNotebook *nb = GetNotebookFromId(i); if (nb->GetPageIndex(Win) != wxNOT_FOUND) { nb->RemovePage(nb->GetPageIndex(Win)); // Create the parent frame and reparent the window CreateParentFrame(Win->GetId() + <API key> - IDM_LOGWINDOW, Win->GetName(), Win); if (nb->GetPageCount() == 0) AddRemoveBlankPage(); } } } void CFrame::DoUnfloatPage(int Id) { wxFrame * Win = (wxFrame*)FindWindowById(Id); if (!Win) return; wxWindow * Child = Win->GetChildren().Item(0)->GetData(); Child->Reparent(this); DoAddPage(Child, g_pCodeWindow->iNbAffiliation[Child->GetId() - IDM_LOGWINDOW], false); Win->Destroy(); } void CFrame::OnTab(wxAuiNotebookEvent& event) { event.Skip(); if (!g_pCodeWindow) return; // Create the popup menu wxMenu* MenuPopup = new wxMenu; wxMenuItem* Item = new wxMenuItem(MenuPopup, wxID_ANY, _("Select floating windows")); MenuPopup->Append(Item); Item->Enable(false); MenuPopup->Append(new wxMenuItem(MenuPopup)); for (int i = IDM_LOGWINDOW; i <= IDM_CODEWINDOW; i++) { wxWindow *Win = FindWindowById(i); if (Win && Win->IsEnabled()) { Item = new wxMenuItem(MenuPopup, i + IDM_FLOAT_LOGWINDOW - IDM_LOGWINDOW, Win->GetName(), "", wxITEM_CHECK); MenuPopup->Append(Item); Item->Check(!!FindWindowById(i + <API key> - IDM_LOGWINDOW)); } } // Line up our menu with the cursor wxPoint Pt = ::wxGetMousePosition(); Pt = ScreenToClient(Pt); // Show PopupMenu(MenuPopup, Pt); } void CFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& event) { event.Skip(); event.Allow(); } void CFrame::ShowResizePane() { if (!m_LogWindow) return; // Make sure the size is sane if (m_LogWindow->x > GetClientRect().GetWidth()) m_LogWindow->x = GetClientRect().GetWidth() / 2; if (m_LogWindow->y > GetClientRect().GetHeight()) m_LogWindow->y = GetClientRect().GetHeight() / 2; wxAuiPaneInfo &pane = m_Mgr->GetPane("Pane 1"); // Hide first otherwise a resize doesn't work pane.Hide(); m_Mgr->Update(); pane.BestSize(m_LogWindow->x, m_LogWindow->y) .MinSize(m_LogWindow->x, m_LogWindow->y) .Direction(m_LogWindow->winpos).Show(); m_Mgr->Update(); // Reset the minimum size of the pane pane.MinSize(-1, -1); m_Mgr->Update(); } void CFrame::TogglePane() { // Get the first notebook wxAuiNotebook * NB = nullptr; for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; } if (NB) { if (NB->GetPageCount() == 0) { m_Mgr->GetPane("Pane 1").Hide(); m_Mgr->Update(); } else { ShowResizePane(); } } } void CFrame::DoRemovePage(wxWindow *Win, bool bHide) { if (!Win) return; wxWindow *Parent = FindWindowById(Win->GetId() + <API key> - IDM_LOGWINDOW); if (Parent) { if (bHide) { Win->Hide(); Win->Reparent(this); } else { Win->Destroy(); } Parent->Destroy(); } else { for (int i = 0; i < GetNotebookCount(); i++) { int PageIndex = GetNotebookFromId(i)->GetPageIndex(Win); if (PageIndex != wxNOT_FOUND) { GetNotebookFromId(i)->RemovePage(PageIndex); if (bHide) { Win->Hide(); Win->Reparent(this); } else { Win->Destroy(); } } } } if (g_pCodeWindow) AddRemoveBlankPage(); } void CFrame::DoAddPage(wxWindow *Win, int i, bool Float) { if (!Win) return; // Ensure accessor remains within valid bounds. if (i < 0 || i > GetNotebookCount()-1) i = 0; // The page was already previously added, no need to add it again. if (Win && GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND) return; if (!Float) GetNotebookFromId(i)->AddPage(Win, Win->GetName(), true); else CreateParentFrame(Win->GetId() + <API key> - IDM_LOGWINDOW, Win->GetName(), Win); } void CFrame::<API key>() { // If the perspective submenu hasn't been created yet, return if (!m_SavedPerspectives) return; // Delete all saved perspective menu items while (m_SavedPerspectives->GetMenuItemCount() != 0) { // Delete the first menu item in the list (while there are menu items) m_SavedPerspectives->Delete(m_SavedPerspectives->FindItemByPosition(0)); } if (Perspectives.size() > 0) { for (u32 i = 0; i < Perspectives.size(); i++) { wxMenuItem* mItem = new wxMenuItem(m_SavedPerspectives, IDM_PERSPECTIVES_0 + i, StrToWxStr(Perspectives[i].Name), "", wxITEM_CHECK); m_SavedPerspectives->Append(mItem); if (i == ActivePerspective) { mItem->Check(true); } } } } void CFrame::OnPerspectiveMenu(wxCommandEvent& event) { ClearStatusBar(); switch (event.GetId()) { case <API key>: if (Perspectives.size() == 0) { wxMessageBox(_("Please create a perspective before saving"), _("Notice"), wxOK, this); return; } SaveIniPerspectives(); GetStatusBar()->SetStatusText(StrToWxStr(std::string ("Saved " + Perspectives[ActivePerspective].Name)), 0); break; case <API key>: AddPane(); break; case <API key>: m_bEdit = event.IsChecked(); TogglePaneStyle(m_bEdit, <API key>); break; case IDM_ADD_PERSPECTIVE: { wxTextEntryDialog dlg(this, _("Enter a name for the new perspective:"), _("Create new perspective")); wxString DefaultValue = wxString::Format(_("Perspective %d"), (int)(Perspectives.size() + 1)); dlg.SetValue(DefaultValue); int Return = 0; bool DlgOk = false; while (!DlgOk) { Return = dlg.ShowModal(); if (Return == wxID_CANCEL) { return; } else if (dlg.GetValue().Find(",") != -1) { wxMessageBox(_("The name cannot contain the character ','"), _("Notice"), wxOK, this); wxString Str = dlg.GetValue(); Str.Replace(",", "", true); dlg.SetValue(Str); } else if (dlg.GetValue().IsSameAs("")) { wxMessageBox(_("The name cannot be empty"), _("Notice"), wxOK, this); dlg.SetValue(DefaultValue); } else { DlgOk = true; } } SPerspectives Tmp; Tmp.Name = WxStrToStr(dlg.GetValue()); Tmp.Perspective = m_Mgr->SavePerspective(); ActivePerspective = (u32)Perspectives.size(); Perspectives.push_back(Tmp); <API key>(); <API key>(); } break; case IDM_TAB_SPLIT: m_bTabSplit = event.IsChecked(); ToggleNotebookStyle(m_bTabSplit, wxAUI_NB_TAB_SPLIT); break; case IDM_NO_DOCKING: m_bNoDocking = event.IsChecked(); TogglePaneStyle(m_bNoDocking, IDM_NO_DOCKING); break; } } void CFrame::TogglePaneStyle(bool On, int EventId) { wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes(); for (u32 i = 0; i < AllPanes.GetCount(); ++i) { wxAuiPaneInfo& Pane = AllPanes[i]; if (Pane.window->IsKindOf(CLASSINFO(wxAuiNotebook))) { // Default Pane.CloseButton(true); Pane.MaximizeButton(true); Pane.MinimizeButton(true); Pane.PinButton(true); Pane.Show(); switch (EventId) { case <API key>: Pane.CaptionVisible(On); Pane.Movable(On); Pane.Floatable(On); Pane.Dockable(On); break; } Pane.Dockable(!m_bNoDocking); } } m_Mgr->Update(); } void CFrame::ToggleNotebookStyle(bool On, long Style) { wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes(); for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i) { wxAuiPaneInfo& Pane = AllPanes[i]; if (Pane.window->IsKindOf(CLASSINFO(wxAuiNotebook))) { wxAuiNotebook* NB = (wxAuiNotebook*)Pane.window; if (On) NB->SetWindowStyleFlag(NB->GetWindowStyleFlag() | Style); else NB->SetWindowStyleFlag(NB->GetWindowStyleFlag() &~ Style); NB->Refresh(); } } } void CFrame::OnSelectPerspective(wxCommandEvent& event) { u32 _Selection = event.GetId() - IDM_PERSPECTIVES_0; if (Perspectives.size() <= _Selection) _Selection = 0; ActivePerspective = _Selection; DoLoadPerspective(); } void CFrame::SetPaneSize() { if (Perspectives.size() <= ActivePerspective) return; int iClientX = GetSize().GetX(); int iClientY = GetSize().GetY(); for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiToolBar))) { if (!m_Mgr->GetAllPanes()[i].IsOk()) return; if (Perspectives[ActivePerspective].Width.size() <= j || Perspectives[ActivePerspective].Height.size() <= j) continue; // Width and height of the active perspective u32 W = Perspectives[ActivePerspective].Width[j], H = Perspectives[ActivePerspective].Height[j]; // Check limits MathUtil::Clamp<u32>(&W, 5, 95); MathUtil::Clamp<u32>(&H, 5, 95); // Convert percentages to pixel lengths W = (W * iClientX) / 100; H = (H * iClientY) / 100; m_Mgr->GetAllPanes()[i].BestSize(W,H).MinSize(W,H); j++; } } m_Mgr->Update(); for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiToolBar))) { m_Mgr->GetAllPanes()[i].MinSize(-1,-1); } } } void CFrame::ReloadPanes() { // Close all pages ClosePages(); CloseAllNotebooks(); // Create new panes with notebooks for (u32 i = 0; i < Perspectives[ActivePerspective].Width.size() - 1; i++) { wxString PaneName = wxString::Format("Pane %i", i + 1); m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo().Hide() .CaptionVisible(m_bEdit).Dockable(!m_bNoDocking).Position(i) .Name(PaneName).Caption(PaneName)); } // Perspectives m_Mgr->LoadPerspective(Perspectives[ActivePerspective].Perspective, false); // Restore settings TogglePaneStyle(m_bNoDocking, IDM_NO_DOCKING); TogglePaneStyle(m_bEdit, <API key>); // Load GUI settings g_pCodeWindow->Load(); // Open notebook pages AddRemoveBlankPage(); g_pCodeWindow->OpenPages(); // Repopulate perspectives <API key>(); } void CFrame::DoLoadPerspective() { ReloadPanes(); // Restore the exact window sizes, which LoadPerspective doesn't always do SetPaneSize(); m_Mgr->Update(); } // Update the local perspectives array void CFrame::LoadIniPerspectives() { Perspectives.clear(); std::vector<std::string> VPerspectives; std::string _Perspectives; IniFile ini; ini.Load(File::GetUserPath(<API key>)); IniFile::Section* perspectives = ini.GetOrCreateSection("Perspectives"); perspectives->Get("Perspectives", &_Perspectives, "Perspective 1"); perspectives->Get("Active", &ActivePerspective, 0); SplitString(_Perspectives, ',', VPerspectives); for (auto& VPerspective : VPerspectives) { SPerspectives Tmp; std::string _Section, _Perspective, _Widths, _Heights; std::vector<std::string> _SWidth, _SHeight; Tmp.Name = VPerspective; // Don't save a blank perspective if (Tmp.Name.empty()) { continue; } _Section = StringFromFormat("P - %s", Tmp.Name.c_str()); IniFile::Section* perspec_section = ini.GetOrCreateSection(_Section); perspec_section->Get("Perspective", &_Perspective, "layout2|" "name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|" "name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|" "dock_size(5,0,0)=22|dock_size(4,0,0)=333|"); perspec_section->Get("Width", &_Widths, "70,25"); perspec_section->Get("Height", &_Heights, "80,80"); Tmp.Perspective = StrToWxStr(_Perspective); SplitString(_Widths, ',', _SWidth); SplitString(_Heights, ',', _SHeight); for (auto& Width : _SWidth) { int _Tmp; if (TryParse(Width, &_Tmp)) Tmp.Width.push_back(_Tmp); } for (auto& Height : _SHeight) { int _Tmp; if (TryParse(Height, &_Tmp)) Tmp.Height.push_back(_Tmp); } Perspectives.push_back(Tmp); } } void CFrame::<API key>() { SPerspectives *current = &Perspectives[ActivePerspective]; current->Perspective = m_Mgr->SavePerspective(); // Get client size int iClientX = GetSize().GetX(), iClientY = GetSize().GetY(); current->Width.clear(); current->Height.clear(); for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window-> IsKindOf(CLASSINFO(wxAuiToolBar))) { // Save width and height as a percentage of the client width and height current->Width.push_back( (m_Mgr->GetAllPanes()[i].window->GetClientSize().GetX() * 100) / iClientX); current->Height.push_back( (m_Mgr->GetAllPanes()[i].window->GetClientSize().GetY() * 100) / iClientY); } } } void CFrame::SaveIniPerspectives() { if (Perspectives.size() == 0) return; if (ActivePerspective >= Perspectives.size()) ActivePerspective = 0; // Turn off edit before saving TogglePaneStyle(false, <API key>); <API key>(); IniFile ini; ini.Load(File::GetUserPath(<API key>)); // Save perspective names std::string STmp = ""; for (auto& Perspective : Perspectives) { STmp += Perspective.Name + ","; } STmp = STmp.substr(0, STmp.length()-1); IniFile::Section* perspectives = ini.GetOrCreateSection("Perspectives"); perspectives->Set("Perspectives", STmp); perspectives->Set("Active", ActivePerspective); // Save the perspectives for (auto& Perspective : Perspectives) { std::string _Section = "P - " + Perspective.Name; IniFile::Section* perspec_section = ini.GetOrCreateSection(_Section); perspec_section->Set("Perspective", WxStrToStr(Perspective.Perspective)); std::string SWidth = "", SHeight = ""; for (u32 j = 0; j < Perspective.Width.size(); j++) { SWidth += StringFromFormat("%i,", Perspective.Width[j]); SHeight += StringFromFormat("%i,", Perspective.Height[j]); } // Remove the ending "," SWidth = SWidth.substr(0, SWidth.length()-1); SHeight = SHeight.substr(0, SHeight.length()-1); perspec_section->Set("Width", SWidth); perspec_section->Set("Height", SHeight); } ini.Save(File::GetUserPath(<API key>)); // Save notebook affiliations g_pCodeWindow->Save(); TogglePaneStyle(m_bEdit, <API key>); } void CFrame::AddPane() { int PaneNum = GetNotebookCount() + 1; wxString PaneName = wxString::Format("Pane %i", PaneNum); m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo() .CaptionVisible(m_bEdit).Dockable(!m_bNoDocking) .Name(PaneName).Caption(PaneName) .Position(GetNotebookCount())); AddRemoveBlankPage(); m_Mgr->Update(); } wxWindow * CFrame::<API key>(wxWindowID Id) { for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for (u32 j = 0; j < NB->GetPageCount(); j++) { if (NB->GetPage(j)->GetId() == Id) return NB->GetPage(j); } } return nullptr; } wxFrame* CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title, wxWindow* Child) { wxFrame* Frame = new wxFrame(this, Id, Title); Child->Reparent(Frame); wxBoxSizer* m_MainSizer = new wxBoxSizer(wxHORIZONTAL); m_MainSizer->Add(Child, 1, wxEXPAND); Frame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::<API key>, this); // Main sizer Frame->SetSizer(m_MainSizer); // Minimum frame size Frame->SetMinSize(wxSize(200, 200)); Frame->Show(); return Frame; } wxAuiNotebook* CFrame::CreateEmptyNotebook() { const long NOTEBOOK_STYLE = wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | <API key> | <API key> | <API key> | wxNO_BORDER; wxAuiNotebook* NB = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE); return NB; } void CFrame::AddRemoveBlankPage() { for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for (u32 j = 0; j < NB->GetPageCount(); j++) { if (NB->GetPageText(j).IsSameAs("<>") && NB->GetPageCount() > 1) NB->DeletePage(j); } if (NB->GetPageCount() == 0) NB->AddPage(new wxPanel(this, wxID_ANY), "<>", true); } } int CFrame::<API key>(wxWindowID Id) { for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for (u32 k = 0; k < NB->GetPageCount(); k++) { if (NB->GetPage(k)->GetId() == Id) return j; } j++; } return -1; } // Close all panes with notebooks void CFrame::CloseAllNotebooks() { wxAuiPaneInfoArray AllPanes = m_Mgr->GetAllPanes(); for (u32 i = 0; i < AllPanes.GetCount(); i++) { if (AllPanes[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) { AllPanes[i].DestroyOnClose(true); m_Mgr->ClosePane(AllPanes[i]); } } } int CFrame::GetNotebookCount() { int Ret = 0; for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) Ret++; } return Ret; } wxAuiNotebook * CFrame::GetNotebookFromId(u32 NBId) { for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; if (j == NBId) return (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; j++; } return nullptr; }
#include <stdlib.h> #include "core_commands2.h" #include "core_commands3.h" #include "core_commands4.h" #include "core_display.h" #include "core_helpers.h" #include "core_linalg1.h" #include "core_sto_rcl.h" #include "core_variables.h" /* Implementations of HP-42S built-in functions, part 4 */ int docmd_insr(arg_struct *arg) { vartype *m, *newx; vartype_realmatrix *rm; <API key> *cm; int4 rows, columns, i; int err, refcount; int interactive; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (m->type != TYPE_REALMATRIX && m->type != TYPE_COMPLEXMATRIX) return ERR_INVALID_TYPE; interactive = matedit_mode == 2 || matedit_mode == 3; if (interactive) { err = docmd_stoel(NULL); if (err != ERR_NONE) return err; } if (m->type == TYPE_REALMATRIX) { rm = (vartype_realmatrix *) m; rows = rm->rows; columns = rm->columns; refcount = rm->array->refcount; if (interactive) { newx = new_real(0); if (newx == NULL) return <API key>; } } else { cm = (<API key> *) m; rows = cm->rows; columns = cm->columns; refcount = cm->array->refcount; if (interactive) { newx = new_complex(0, 0); if (newx == NULL) return <API key>; } } if (matedit_i >= rows) matedit_i = rows - 1; if (matedit_j >= columns) matedit_j = columns - 1; if (refcount == 1) { /* We have this array to ourselves so we can modify it in place */ err = dimension_array_ref(m, rows + 1, columns); if (err != ERR_NONE) { if (interactive) free_vartype(newx); return err; } rows++; if (m->type == TYPE_REALMATRIX) { for (i = rows * columns - 1; i >= (matedit_i + 1) * columns; i rm->array->is_string[i] = rm->array->is_string[i - columns]; rm->array->data[i] = rm->array->data[i - columns]; } for (i = matedit_i * columns; i < (matedit_i + 1) * columns; i++) { rm->array->is_string[i] = 0; rm->array->data[i] = 0; } } else { for (i = 2 * rows * columns - 1; i >= 2 * (matedit_i + 1) * columns; i cm->array->data[i] = cm->array->data[i - 2 * columns]; for (i = 2 * matedit_i * columns; i < 2 * (matedit_i + 1) * columns; i++) cm->array->data[i] = 0; } } else { /* We're sharing this array. I don't use disentangle() because it * does not deal with resizing. */ int4 newsize = (rows + 1) * columns; if (m->type == TYPE_REALMATRIX) { realmatrix_data *array = (realmatrix_data *) malloc(sizeof(realmatrix_data)); if (array == NULL) { if (interactive) free_vartype(newx); return <API key>; } array->data = (phloat *) malloc(newsize * sizeof(phloat)); if (array->data == NULL) { if (interactive) free_vartype(newx); free(array); return <API key>; } array->is_string = (char *) malloc(newsize); if (array->is_string == NULL) { if (interactive) free_vartype(newx); free(array->data); free(array); return <API key>; } for (i = 0; i < matedit_i * columns; i++) { array->is_string[i] = rm->array->is_string[i]; array->data[i] = rm->array->data[i]; } for (i = matedit_i * columns; i < (matedit_i + 1) * columns; i++) { array->is_string[i] = 0; array->data[i] = 0; } for (i = (matedit_i + 1) * columns; i < newsize; i++) { array->is_string[i] = rm->array->is_string[i - columns]; array->data[i] = rm->array->data[i - columns]; } array->refcount = 1; rm->array->refcount rm->array = array; rm->rows++; } else { complexmatrix_data *array = (complexmatrix_data *) malloc(sizeof(complexmatrix_data)); if (array == NULL) { if (interactive) free_vartype(newx); return <API key>; } array->data = (phloat *) malloc(2 * newsize * sizeof(phloat)); if (array->data == NULL) { if (interactive) free_vartype(newx); free(array); return <API key>; } for (i = 0; i < 2 * matedit_i * columns; i++) array->data[i] = cm->array->data[i]; for (i = 2 * matedit_i * columns; i < 2 * (matedit_i + 1) * columns; i++) array->data[i] = 0; for (i = 2 * (matedit_i + 1) * columns; i < 2 * newsize; i++) array->data[i] = cm->array->data[i - 2 * columns]; array->refcount = 1; cm->array->refcount cm->array = array; cm->rows++; } } if (interactive) { free_vartype(reg_x); reg_x = newx; } <API key> = true; return ERR_NONE; } static void invrt_completion(int error, vartype *res) { if (error == ERR_NONE) unary_result(res); } int docmd_invrt(arg_struct *arg) { if (reg_x->type == TYPE_REAL || reg_x->type == TYPE_COMPLEX) return ERR_INVALID_TYPE; else if (reg_x->type == TYPE_STRING) return <API key>; else return linalg_inv(reg_x, invrt_completion); } int docmd_j_add(arg_struct *arg) { int4 rows, columns; int4 oldi = matedit_i; int4 oldj = matedit_j; int err = matedit_get_dim(&rows, &columns); if (err != ERR_NONE) return err; if (++matedit_j >= columns) { flags.f.matrix_edge_wrap = 1; matedit_j = 0; if (++matedit_i >= rows) { flags.f.matrix_end_wrap = 1; if (flags.f.grow) { if (matedit_mode == 2) err = dimension_array_ref(matedit_x, rows + 1, columns); else err = dimension_array(matedit_name, matedit_length, rows + 1, columns); if (err != ERR_NONE) { matedit_i = oldi; matedit_j = oldj; return err; } matedit_i = rows; } else matedit_i = 0; } else flags.f.matrix_end_wrap = 0; } else { flags.f.matrix_edge_wrap = 0; flags.f.matrix_end_wrap = 0; } return ERR_NONE; } int docmd_j_sub(arg_struct *arg) { int4 rows, columns; int err = matedit_get_dim(&rows, &columns); if (err != ERR_NONE) return err; if (--matedit_j < 0) { flags.f.matrix_edge_wrap = 1; matedit_j = columns - 1; if (--matedit_i < 0) { flags.f.matrix_end_wrap = 1; matedit_i = rows - 1; } else flags.f.matrix_end_wrap = 0; } else { flags.f.matrix_edge_wrap = 0; flags.f.matrix_end_wrap = 0; } return ERR_NONE; } static int mappable_ln_1_x(phloat x, phloat *y) { if (x <= -1) return ERR_INVALID_DATA; *y = log1p(x); return ERR_NONE; } int docmd_ln_1_x(arg_struct *arg) { if (reg_x->type == TYPE_REAL || reg_x->type == TYPE_REALMATRIX) { vartype *v; int err = map_unary(reg_x, &v, mappable_ln_1_x, NULL); if (err == ERR_NONE) unary_result(v); return err; } else if (reg_x->type == TYPE_STRING) return <API key>; else return ERR_INVALID_TYPE; } int docmd_old(arg_struct *arg) { return docmd_rclel(NULL); } int docmd_posa(arg_struct *arg) { int pos = -1; vartype *v; if (reg_x->type == TYPE_REAL) { phloat x = ((vartype_real *) reg_x)->x; char c; int i; if (x < 0) x = -x; if (x >= 256) return ERR_INVALID_DATA; c = to_char(x); for (i = 0; i < reg_alpha_length; i++) if (reg_alpha[i] == c) { pos = i; break; } } else if (reg_x->type == TYPE_STRING) { vartype_string *s = (vartype_string *) reg_x; if (s->length != 0) { int i, j; for (i = 0; i < reg_alpha_length - s->length; i++) { for (j = 0; j < s->length; j++) if (reg_alpha[i + j] != s->text[j]) goto notfound; pos = i; break; notfound:; } } } else return ERR_INVALID_TYPE; v = new_real(pos); if (v == NULL) return <API key>; unary_result(v); return ERR_NONE; } int docmd_putm(arg_struct *arg) { vartype *m; int4 i, j; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (m->type != TYPE_REALMATRIX && m->type != TYPE_COMPLEXMATRIX) /* Shouldn't happen, but could, as long as I don't * implement matrix locking */ return ERR_INVALID_TYPE; if (reg_x->type == TYPE_STRING) return <API key>; else if (reg_x->type == TYPE_REAL || reg_x->type == TYPE_COMPLEX) return ERR_INVALID_TYPE; if (m->type == TYPE_REALMATRIX) { vartype_realmatrix *src, *dst; if (reg_x->type == TYPE_COMPLEXMATRIX) return ERR_INVALID_TYPE; src = (vartype_realmatrix *) reg_x; dst = (vartype_realmatrix *) m; if (src->rows + matedit_i > dst->rows || src->columns + matedit_j > dst->columns) return ERR_DIMENSION_ERROR; if (!disentangle(m)) return <API key>; for (i = 0; i < src->rows; i++) for (j = 0; j < src->columns; j++) { int4 n1 = i * src->columns + j; int4 n2 = (i + matedit_i) * dst->columns + j + matedit_j; dst->array->is_string[n2] = src->array->is_string[n1]; dst->array->data[n2] = src->array->data[n1]; } return ERR_NONE; } else if (reg_x->type == TYPE_REALMATRIX) { vartype_realmatrix *src = (vartype_realmatrix *) reg_x; <API key> *dst = (<API key> *) m; if (src->rows + matedit_i > dst->rows || src->columns + matedit_j > dst->columns) return ERR_DIMENSION_ERROR; for (i = 0; i < src->rows * src->columns; i++) if (src->array->is_string[i]) return <API key>; if (!disentangle(m)) return <API key>; for (i = 0; i < src->rows; i++) for (j = 0; j < src->columns; j++) { int4 n1 = i * src->columns + j; int4 n2 = (i + matedit_i) * dst->columns + j + matedit_j; dst->array->data[n2 * 2] = src->array->data[n1]; dst->array->data[n2 * 2 + 1] = 0; } return ERR_NONE; } else { <API key> *src = (<API key> *) reg_x; <API key> *dst = (<API key> *) m; if (src->rows + matedit_i > dst->rows || src->columns + matedit_j > dst->columns) return ERR_DIMENSION_ERROR; if (!disentangle(m)) return <API key>; for (i = 0; i < src->rows; i++) for (j = 0; j < src->columns; j++) { int4 n1 = i * src->columns + j; int4 n2 = (i + matedit_i) * dst->columns + j + matedit_j; dst->array->data[n2 * 2] = src->array->data[n1 * 2]; dst->array->data[n2 * 2 + 1] = src->array->data[n1 * 2 + 1]; } return ERR_NONE; } } int docmd_rclel(arg_struct *arg) { vartype *m, *v; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (m->type == TYPE_REALMATRIX) { vartype_realmatrix *rm = (vartype_realmatrix *) m; int4 n = matedit_i * rm->columns + matedit_j; if (rm->array->is_string[n]) v = new_string(phloat_text(rm->array->data[n]), phloat_length(rm->array->data[n])); else v = new_real(rm->array->data[n]); } else if (m->type == TYPE_COMPLEXMATRIX) { <API key> *cm = (<API key> *) m; int4 n = matedit_i * cm->columns + matedit_j; v = new_complex(cm->array->data[2 * n], cm->array->data[2 * n + 1]); } else return ERR_INVALID_TYPE; if (v == NULL) return <API key>; recall_result(v); return ERR_NONE; } int docmd_rclij(arg_struct *arg) { vartype *i, *j; if (matedit_mode == 0) return ERR_NONEXISTENT; i = new_real(matedit_i + 1); j = new_real(matedit_j + 1); if (i == NULL || j == NULL) { free_vartype(i); free_vartype(j); return <API key>; } recall_two_results(j, i); return ERR_NONE; } int docmd_rnrm(arg_struct *arg) { if (reg_x->type == TYPE_REALMATRIX) { vartype *v; vartype_realmatrix *rm = (vartype_realmatrix *) reg_x; int4 size = rm->rows * rm->columns; int4 i, j; phloat max = 0; for (i = 0; i < size; i++) if (rm->array->is_string[i]) return <API key>; for (i = 0; i < rm->rows; i++) { phloat nrm = 0; for (j = 0; j < rm->columns; j++) { phloat x = rm->array->data[i * rm->columns + j]; if (x >= 0) nrm += x; else nrm -= x; } if (p_isinf(nrm)) { if (flags.f.range_error_ignore) max = POS_HUGE_PHLOAT; else return ERR_OUT_OF_RANGE; break; } if (nrm > max) max = nrm; } v = new_real(max); if (v == NULL) return <API key>; unary_result(v); return ERR_NONE; } else if (reg_x->type == TYPE_COMPLEXMATRIX) { vartype *v; <API key> *cm = (<API key> *) reg_x; int4 i, j; phloat max = 0; for (i = 0; i < cm->rows; i++) { phloat nrm = 0; for (j = 0; j < cm->columns; j++) { phloat re = cm->array->data[2 * (i * cm->columns + j)]; phloat im = cm->array->data[2 * (i * cm->columns + j) + 1]; nrm += hypot(re, im); } if (p_isinf(nrm)) { if (flags.f.range_error_ignore) max = POS_HUGE_PHLOAT; else return ERR_OUT_OF_RANGE; break; } if (nrm > max) max = nrm; } v = new_real(max); if (v == NULL) return <API key>; unary_result(v); return ERR_NONE; } else if (reg_x->type == TYPE_STRING) return <API key>; else return ERR_INVALID_TYPE; } int docmd_rsum(arg_struct *arg) { if (reg_x->type == TYPE_REALMATRIX) { vartype_realmatrix *rm = (vartype_realmatrix *) reg_x; vartype_realmatrix *res; int4 size = rm->rows * rm->columns; int4 i, j; for (i = 0; i < size; i++) if (rm->array->is_string[i]) return <API key>; res = (vartype_realmatrix *) new_realmatrix(rm->rows, 1); if (res == NULL) return <API key>; for (i = 0; i < rm->rows; i++) { phloat sum = 0; int inf; for (j = 0; j < rm->columns; j++) sum += rm->array->data[i * rm->columns + j]; if ((inf = p_isinf(sum)) != 0) { if (flags.f.range_error_ignore) sum = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else { free_vartype((vartype *) res); return ERR_OUT_OF_RANGE; } } res->array->data[i] = sum; } unary_result((vartype *) res); return ERR_NONE; } else if (reg_x->type == TYPE_COMPLEXMATRIX) { <API key> *cm = (<API key> *) reg_x; <API key> *res; int4 i, j; res = (<API key> *) new_complexmatrix(cm->rows, 1); if (res == NULL) return <API key>; for (i = 0; i < cm->rows; i++) { phloat sum_re = 0, sum_im = 0; int inf; for (j = 0; j < cm->columns; j++) { sum_re += cm->array->data[2 * (i * cm->columns + j)]; sum_im += cm->array->data[2 * (i * cm->columns + j) + 1]; } if ((inf = p_isinf(sum_re)) != 0) { if (flags.f.range_error_ignore) sum_re = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else { free_vartype((vartype *) res); return ERR_OUT_OF_RANGE; } } if ((inf = p_isinf(sum_im)) != 0) { if (flags.f.range_error_ignore) sum_im = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else { free_vartype((vartype *) res); return ERR_OUT_OF_RANGE; } } res->array->data[2 * i] = sum_re; res->array->data[2 * i + 1] = sum_im; } unary_result((vartype *) res); return ERR_NONE; } else if (reg_x->type == TYPE_STRING) return <API key>; else return ERR_INVALID_TYPE; } int docmd_swap_r(arg_struct *arg) { vartype *m; phloat xx, yy; int4 x, y, i; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (m->type != TYPE_REALMATRIX && m->type != TYPE_COMPLEXMATRIX) /* Should not happen, but could, as long as I don't implement * matrix locking. */ return ERR_INVALID_TYPE; if (reg_x->type == TYPE_STRING) return <API key>; if (reg_x->type != TYPE_REAL) return ERR_INVALID_TYPE; if (reg_y->type == TYPE_STRING) return <API key>; if (reg_y->type != TYPE_REAL) return ERR_INVALID_TYPE; xx = ((vartype_real *) reg_x)->x; if (xx <= -2147483648.0 || xx >= 2147483648.0) return ERR_DIMENSION_ERROR; x = to_int4(xx); if (x == 0) return ERR_DIMENSION_ERROR; if (x < 0) x = -x; x yy = ((vartype_real *) reg_y)->x; if (yy <= -2147483648.0 || yy >= 2147483648.0) return ERR_DIMENSION_ERROR; y = to_int4(yy); if (y == 0) return ERR_DIMENSION_ERROR; if (y < 0) y = -y; y if (m->type == TYPE_REALMATRIX) { vartype_realmatrix *rm = (vartype_realmatrix *) m; if (x > rm->rows || y > rm->rows) return ERR_DIMENSION_ERROR; else if (x == y) return ERR_NONE; if (!disentangle(m)) return <API key>; for (i = 0; i < rm->columns; i++) { int4 n1 = x * rm->columns + i; int4 n2 = y * rm->columns + i; char tempc = rm->array->is_string[n1]; phloat tempds = rm->array->data[n1]; rm->array->is_string[n1] = rm->array->is_string[n2]; rm->array->data[n1] = rm->array->data[n2]; rm->array->is_string[n2] = tempc; rm->array->data[n2] = tempds; } return ERR_NONE; } else /* m->type == TYPE_COMPLEXMATRIX */ { <API key> *cm = (<API key> *) m; if (x > cm->rows || y > cm->rows) return ERR_DIMENSION_ERROR; else if (x == y) return ERR_NONE; if (!disentangle(m)) return <API key>; for (i = 0; i < 2 * cm->columns; i++) { int4 n1 = x * 2 * cm->columns + i; int4 n2 = y * 2 * cm->columns + i; phloat tempd = cm->array->data[n1]; cm->array->data[n1] = cm->array->data[n2]; cm->array->data[n2] = tempd; } return ERR_NONE; } } static int mappable_sinh_r(phloat x, phloat *y) { int inf; *y = sinh(x); if ((inf = p_isinf(*y)) != 0) { if (flags.f.range_error_ignore) *y = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else return ERR_OUT_OF_RANGE; } return ERR_NONE; } static int mappable_sinh_c(phloat xre, phloat xim, phloat *yre, phloat *yim) { phloat sinhxre, coshxre; phloat sinxim, cosxim; int inf; sinhxre = sinh(xre); coshxre = cosh(xre); sincos(xim, &sinxim, &cosxim); *yre = sinhxre * cosxim; if ((inf = p_isinf(*yre)) != 0) { if (flags.f.range_error_ignore) *yre = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else return ERR_OUT_OF_RANGE; } *yim = coshxre * sinxim; if ((inf = p_isinf(*yim)) != 0) { if (flags.f.range_error_ignore) *yim = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else return ERR_OUT_OF_RANGE; } return ERR_NONE; } int docmd_sinh(arg_struct *arg) { if (reg_x->type != TYPE_STRING) { vartype *v; int err = map_unary(reg_x, &v, mappable_sinh_r, mappable_sinh_c); if (err == ERR_NONE) unary_result(v); return err; } else return <API key>; } int docmd_stoel(arg_struct *arg) { vartype *m; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (m->type != TYPE_REALMATRIX && m->type != TYPE_COMPLEXMATRIX) /* Should not happen, but could, as long as I don't implement * matrix locking. */ return ERR_INVALID_TYPE; if (!disentangle(m)) return <API key>; if (m->type == TYPE_REALMATRIX) { vartype_realmatrix *rm = (vartype_realmatrix *) m; int4 n = matedit_i * rm->columns + matedit_j; if (reg_x->type == TYPE_REAL) { rm->array->is_string[n] = 0; rm->array->data[n] = ((vartype_real *) reg_x)->x; return ERR_NONE; } else if (reg_x->type == TYPE_STRING) { vartype_string *s = (vartype_string *) reg_x; int i; rm->array->is_string[n] = 1; phloat_length(rm->array->data[n]) = s->length; for (i = 0; i < s->length; i++) phloat_text(rm->array->data[n])[i] = s->text[i]; return ERR_NONE; } else return ERR_INVALID_TYPE; } else /* m->type == TYPE_COMPLEXMATRIX */ { <API key> *cm = (<API key> *) m; int4 n = matedit_i * cm->columns + matedit_j; if (reg_x->type == TYPE_REAL) { cm->array->data[2 * n] = ((vartype_real *) reg_x)->x; cm->array->data[2 * n + 1] = 0; return ERR_NONE; } else if (reg_x->type == TYPE_COMPLEX) { vartype_complex *c = (vartype_complex *) reg_x; cm->array->data[2 * n] = c->re; cm->array->data[2 * n + 1] = c->im; return ERR_NONE; } else return ERR_INVALID_TYPE; } } int docmd_stoij(arg_struct *arg) { vartype *m; phloat x, y; int4 i, j; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (reg_x->type == TYPE_STRING) return <API key>; if (reg_x->type != TYPE_REAL) return ERR_INVALID_TYPE; if (reg_y->type == TYPE_STRING) return <API key>; if (reg_y->type != TYPE_REAL) return ERR_INVALID_TYPE; x = ((vartype_real *) reg_x)->x; if (x <= -2147483648.0 || x >= 2147483648.0) return ERR_DIMENSION_ERROR; j = to_int4(x); if (j < 0) j = -j; y = ((vartype_real *) reg_y)->x; if (y <= -2147483648.0 || y >= 2147483648.0) return ERR_DIMENSION_ERROR; i = to_int4(y); if (i < 0) i = -i; if (m->type == TYPE_REALMATRIX) { vartype_realmatrix *rm = (vartype_realmatrix *) m; if (i == 0 || i > rm->rows || j == 0 || j > rm->columns) return ERR_DIMENSION_ERROR; } else if (m->type == TYPE_COMPLEXMATRIX) { <API key> *cm = (<API key> *) m; if (i == 0 || i > cm->rows || j == 0 || j > cm->columns) return ERR_DIMENSION_ERROR; } else /* Should not happen, but could, as long as I don't implement * matrix locking. */ return ERR_INVALID_TYPE; matedit_i = i - 1; matedit_j = j - 1; return ERR_NONE; } static int mappable_tanh_r(phloat x, phloat *y) { *y = tanh(x); return ERR_NONE; } static int mappable_tanh_c(phloat xre, phloat xim, phloat *yre, phloat *yim) { phloat sinhxre, coshxre; phloat sinxim, cosxim; phloat re_sinh, re_cosh, im_sinh, im_cosh, abs_cosh; int inf; sinhxre = sinh(xre); coshxre = cosh(xre); sincos(xim, &sinxim, &cosxim); re_sinh = sinhxre * cosxim; im_sinh = coshxre * sinxim; re_cosh = coshxre * cosxim; im_cosh = sinhxre * sinxim; abs_cosh = hypot(re_cosh, im_cosh); if (abs_cosh == 0) { if (flags.f.range_error_ignore) { *yre = re_sinh * im_sinh + re_cosh * im_cosh > 0 ? POS_HUGE_PHLOAT : NEG_HUGE_PHLOAT; *yim = im_sinh * re_cosh - re_sinh * im_cosh > 0 ? POS_HUGE_PHLOAT : NEG_HUGE_PHLOAT; } else return ERR_OUT_OF_RANGE; } *yre = (re_sinh * re_cosh + im_sinh * im_cosh) / abs_cosh / abs_cosh; if ((inf = p_isinf(*yre)) != 0) { if (flags.f.range_error_ignore) *yre = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else return ERR_OUT_OF_RANGE; } *yim = (im_sinh * re_cosh - re_sinh * im_cosh) / abs_cosh / abs_cosh; if ((inf = p_isinf(*yim)) != 0) { if (flags.f.range_error_ignore) *yim = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else return ERR_OUT_OF_RANGE; } return ERR_NONE; } int docmd_tanh(arg_struct *arg) { if (reg_x->type != TYPE_STRING) { vartype *v; int err = map_unary(reg_x, &v, mappable_tanh_r, mappable_tanh_c); if (err == ERR_NONE) unary_result(v); return err; } else return <API key>; } int docmd_trans(arg_struct *arg) { if (reg_x->type == TYPE_REALMATRIX) { vartype_realmatrix *src = (vartype_realmatrix *) reg_x; vartype_realmatrix *dst; int4 rows = src->rows; int4 columns = src->columns; int4 i, j; dst = (vartype_realmatrix *) new_realmatrix(columns, rows); if (dst == NULL) return <API key>; for (i = 0; i < rows; i++) for (j = 0; j < columns; j++) { int4 n1 = i * columns + j; int4 n2 = j * rows + i; dst->array->is_string[n2] = src->array->is_string[n1]; dst->array->data[n2] = src->array->data[n1]; } unary_result((vartype *) dst); return ERR_NONE; } else if (reg_x->type == TYPE_COMPLEXMATRIX) { <API key> *src = (<API key> *) reg_x; <API key> *dst; int4 rows = src->rows; int4 columns = src->columns; int4 i, j; dst = (<API key> *) new_complexmatrix(columns, rows); if (dst == NULL) return <API key>; for (i = 0; i < rows; i++) for (j = 0; j < columns; j++) { int4 n1 = 2 * (i * columns + j); int4 n2 = 2 * (j * rows + i); dst->array->data[n2] = src->array->data[n1]; dst->array->data[n2 + 1] = src->array->data[n1 + 1]; } unary_result((vartype *) dst); return ERR_NONE; } else if (reg_x->type == TYPE_STRING) return <API key>; else return ERR_INVALID_TYPE; } int docmd_wrap(arg_struct *arg) { flags.f.grow = 0; return ERR_NONE; } int docmd_x_swap(arg_struct *arg) { vartype *v; int err = generic_rcl(arg, &v); if (err != ERR_NONE) return err; err = generic_sto(arg, 0); if (err != ERR_NONE) free_vartype(v); else { free_vartype(reg_x); reg_x = v; if (flags.f.trace_print && flags.f.printer_exists) docmd_prx(NULL); } return err; } #define DIR_LEFT 0 #define DIR_RIGHT 1 #define DIR_UP 2 #define DIR_DOWN 3 static int matedit_move(int direction) { vartype *m, *v; vartype_realmatrix *rm; <API key> *cm; int4 rows, columns, new_i, new_j, old_n, new_n; int edge_flag = 0; int end_flag = 0; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (m->type == TYPE_REALMATRIX) { rm = (vartype_realmatrix *) m; rows = rm->rows; columns = rm->columns; } else if (m->type == TYPE_COMPLEXMATRIX) { cm = (<API key> *) m; rows = cm->rows; columns = cm->columns; } else return ERR_INVALID_TYPE; if (!disentangle(m)) return <API key>; new_i = matedit_i; new_j = matedit_j; switch (direction) { case DIR_LEFT: if (--new_j < 0) { edge_flag = 1; new_j = columns - 1; if (--new_i < 0) { end_flag = 1; new_i = rows - 1; } } break; case DIR_RIGHT: if (++new_j >= columns) { edge_flag = 1; new_j = 0; if (++new_i >= rows) { end_flag = 1; if (flags.f.grow) { int err; if (matedit_mode == 2) err = dimension_array_ref(matedit_x, rows + 1, columns); else err = dimension_array(matedit_name, matedit_length, rows + 1, columns); if (err != ERR_NONE) return err; new_i = rows++; } else new_i = 0; } } break; case DIR_UP: if (--new_i < 0) { edge_flag = 1; new_i = rows - 1; if (--new_j < 0) { end_flag = 1; new_j = columns - 1; } } break; case DIR_DOWN: if (++new_i >= rows) { edge_flag = 1; new_i = 0; if (++new_j >= columns) { end_flag = 1; new_j = 0; } } break; } old_n = matedit_i * columns + matedit_j; new_n = new_i * columns + new_j; if (m->type == TYPE_REALMATRIX) { if (old_n != new_n) { if (rm->array->is_string[new_n]) v = new_string(phloat_text(rm->array->data[new_n]), phloat_length(rm->array->data[new_n])); else v = new_real(rm->array->data[new_n]); if (v == NULL) return <API key>; } if (reg_x->type == TYPE_REAL) { rm->array->is_string[old_n] = 0; rm->array->data[old_n] = ((vartype_real *) reg_x)->x; } else if (reg_x->type == TYPE_STRING) { vartype_string *s = (vartype_string *) reg_x; int i; rm->array->is_string[old_n] = 1; phloat_length(rm->array->data[old_n]) = s->length; for (i = 0; i < s->length; i++) phloat_text(rm->array->data[old_n])[i] = s->text[i]; } else { free_vartype(v); return ERR_INVALID_TYPE; } } else /* m->type == TYPE_COMPLEXMATRIX */ { if (old_n != new_n) { v = new_complex(cm->array->data[2 * new_n], cm->array->data[2 * new_n + 1]); if (v == NULL) return <API key>; } if (reg_x->type == TYPE_REAL) { cm->array->data[2 * old_n] = ((vartype_real *) reg_x)->x; cm->array->data[2 * old_n + 1] = 0; } else if (reg_x->type == TYPE_COMPLEX) { vartype_complex *c = (vartype_complex *) reg_x; cm->array->data[2 * old_n] = c->re; cm->array->data[2 * old_n + 1] = c->im; } else { free_vartype(v); return ERR_INVALID_TYPE; } } matedit_i = new_i; matedit_j = new_j; flags.f.matrix_edge_wrap = edge_flag; flags.f.matrix_end_wrap = end_flag; if (old_n != new_n) { free_vartype(reg_x); reg_x = v; } <API key> = true; if (flags.f.trace_print && flags.f.printer_enable) docmd_prx(NULL); return ERR_NONE; } int docmd_left(arg_struct *arg) { return matedit_move(DIR_LEFT); } int docmd_up(arg_struct *arg) { return matedit_move(DIR_UP); } int docmd_down(arg_struct *arg) { return matedit_move(DIR_DOWN); } int docmd_right(arg_struct *arg) { return matedit_move(DIR_RIGHT); } int docmd_percent_ch(arg_struct *arg) { phloat x, y, r; int inf; vartype *v; if (reg_x->type == TYPE_STRING) return <API key>; if (reg_x->type != TYPE_REAL) return ERR_INVALID_TYPE; if (reg_y->type == TYPE_STRING) return <API key>; if (reg_y->type != TYPE_REAL) return ERR_INVALID_TYPE; x = ((vartype_real *) reg_x)->x; y = ((vartype_real *) reg_y)->x; if (y == 0) return ERR_DIVIDE_BY_0; r = (x - y) / y * 100; if ((inf = p_isinf(r)) != 0) { if (flags.f.range_error_ignore) r = inf < 0 ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; else return ERR_OUT_OF_RANGE; } v = new_real(r); if (v == NULL) return <API key>; /* Binary function, but unary result, like % */ unary_result(v); return ERR_NONE; } static vartype *matx_v; static void matx_completion(int error, vartype *res) { if (error != ERR_NONE) { free_vartype(matx_v); return; } store_var("MATX", 4, res); <API key> = MENU_MATRIX_SIMQ; set_menu(MENULEVEL_APP, MENU_MATRIX_EDIT1); /* NOTE: no need to use set_menu_return_err() here, since the MAT[ABX] * commands can only be invoked from the SIMQ menu; the SIMQ menu * has no exit callback, so leaving it never fails. */ <API key>(1); if (res->type == TYPE_REALMATRIX) { vartype_realmatrix *m = (vartype_realmatrix *) res; vartype_real *v = (vartype_real *) matx_v; v->x = m->array->data[0]; } else { <API key> *m = (<API key> *) res; vartype_complex *v = (vartype_complex *) matx_v; v->re = m->array->data[0]; v->im = m->array->data[1]; } free_vartype(reg_x); reg_x = matx_v; matedit_mode = 3; matedit_length = 4; matedit_name[0] = 'M'; matedit_name[1] = 'A'; matedit_name[2] = 'T'; matedit_name[3] = 'X'; matedit_i = 0; matedit_j = 0; } static int matabx(int which) { vartype *mat, *v; switch (which) { case 0: mat = recall_var("MATA", 4); break; case 1: mat = recall_var("MATB", 4); break; case 2: { vartype *mata, *matb; mata = recall_var("MATA", 4); if (mata == NULL) return ERR_NONEXISTENT; if (mata->type != TYPE_REALMATRIX && mata->type != TYPE_COMPLEXMATRIX) return ERR_INVALID_TYPE; matb = recall_var("MATB", 4); if (matb == NULL) return ERR_NONEXISTENT; if (matb->type != TYPE_REALMATRIX && matb->type != TYPE_COMPLEXMATRIX) return ERR_INVALID_TYPE; if (mata->type == TYPE_REALMATRIX && matb->type == TYPE_REALMATRIX) matx_v = new_real(0); else matx_v = new_complex(0, 0); if (matx_v == NULL) return <API key>; return linalg_div(matb, mata, matx_completion); } } if (mat->type == TYPE_REALMATRIX) { vartype_realmatrix *rm = (vartype_realmatrix *) mat; if (rm->array->is_string[0]) v = new_string(phloat_text(rm->array->data[0]), phloat_length(rm->array->data[0])); else v = new_real(rm->array->data[0]); } else { <API key> *cm = (<API key> *) mat; v = new_complex(cm->array->data[0], cm->array->data[1]); } if (v == NULL) return <API key>; <API key> = MENU_MATRIX_SIMQ; set_menu(MENULEVEL_APP, MENU_MATRIX_EDIT1); /* NOTE: no need to use set_menu_return_err() here, since the MAT[ABX] * commands can only be invoked from the SIMQ menu; the SIMQ menu * has no exit callback, so leaving it never fails. */ <API key>(1); free_vartype(reg_x); reg_x = v; matedit_mode = 3; matedit_length = 4; matedit_name[0] = 'M'; matedit_name[1] = 'A'; matedit_name[2] = 'T'; matedit_name[3] = which == 0 ? 'A' : 'B'; matedit_i = 0; matedit_j = 0; return ERR_NONE; } int docmd_mata(arg_struct *arg) { return matabx(0); } int docmd_matb(arg_struct *arg) { return matabx(1); } int docmd_matx(arg_struct *arg) { return matabx(2); } int docmd_simq(arg_struct *arg) { vartype *m, *mata, *matb, *matx; int4 dim; int err; if (arg->type != ARGTYPE_NUM) return ERR_INVALID_TYPE; dim = arg->val.num; if (dim <= 0) return ERR_DIMENSION_ERROR; m = recall_var("MATA", 4); if (m != NULL && (m->type == TYPE_REALMATRIX || m->type == TYPE_COMPLEXMATRIX)) { mata = dup_vartype(m); if (mata == NULL) return <API key>; err = dimension_array_ref(mata, dim, dim); if (err != ERR_NONE) goto abort_and_free_a; } else { mata = new_realmatrix(dim, dim); if (mata == NULL) return <API key>; } m = recall_var("MATB", 4); if (m != NULL && (m->type == TYPE_REALMATRIX || m->type == TYPE_COMPLEXMATRIX)) { matb = dup_vartype(m); if (matb == NULL) { err = <API key>; goto abort_and_free_a; } err = dimension_array_ref(matb, dim, 1); if (err != ERR_NONE) goto abort_and_free_a_b; } else { matb = new_realmatrix(dim, 1); if (matb == NULL) { err = <API key>; goto abort_and_free_a; } } m = recall_var("MATX", 4); if (m != NULL && (m->type == TYPE_REALMATRIX || m->type == TYPE_COMPLEXMATRIX)) { matx = dup_vartype(m); if (matx == NULL) { err = <API key>; goto abort_and_free_a_b; } err = dimension_array_ref(matx, dim, 1); if (err != ERR_NONE) goto <API key>; } else { matx = new_realmatrix(dim, 1); if (matx == NULL) { err = <API key>; goto abort_and_free_a_b; } } err = set_menu_return_err(MENULEVEL_APP, MENU_MATRIX_SIMQ); if (err != ERR_NONE) { /* Didn't work; we're stuck in the matrix editor * waiting for the user to put something valid into X. * (Then again, how can anyone issue the SIMQ command if * they're in the matrix editor? SIMQ has the 'hidden' * command property. Oh, well, better safe than sorry...) */ <API key>: free_vartype(matx); abort_and_free_a_b: free_vartype(matb); abort_and_free_a: free_vartype(mata); return err; } store_var("MATX", 4, matx); store_var("MATB", 4, matb); store_var("MATA", 4, mata); return ERR_NONE; } static int max_min_helper(int do_max) { vartype *m; vartype_realmatrix *rm; phloat max_or_min_value = do_max ? NEG_HUGE_PHLOAT : POS_HUGE_PHLOAT; int4 i, max_or_min_index = 0; vartype *new_x, *new_y; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (m->type != TYPE_REALMATRIX) return ERR_INVALID_TYPE; rm = (vartype_realmatrix *) m; for (i = matedit_i; i < rm->rows; i++) { int4 index = i * rm->columns + matedit_j; phloat e; if (rm->array->is_string[index]) return <API key>; e = rm->array->data[index]; if (do_max ? e >= max_or_min_value : e <= max_or_min_value) { max_or_min_value = e; max_or_min_index = i; } } new_x = new_real(max_or_min_value); if (new_x == NULL) return <API key>; new_y = new_real(max_or_min_index + 1); if (new_y == NULL) { free_vartype(new_x); return <API key>; } recall_two_results(new_x, new_y); return ERR_NONE; } int docmd_max(arg_struct *arg) { return max_min_helper(1); } int docmd_min(arg_struct *arg) { return max_min_helper(0); } int docmd_find(arg_struct *arg) { vartype *m; if (reg_x->type == TYPE_REALMATRIX || reg_x->type == TYPE_COMPLEXMATRIX) return ERR_INVALID_TYPE; switch (matedit_mode) { case 0: return ERR_NONEXISTENT; case 1: case 3: m = recall_var(matedit_name, matedit_length); break; case 2: m = matedit_x; break; default: return ERR_INTERNAL_ERROR; } if (m == NULL) return ERR_NONEXISTENT; if (m->type == TYPE_REALMATRIX) { vartype_realmatrix *rm; int4 i, j, p = 0; if (reg_x->type == TYPE_COMPLEX) return ERR_NO; rm = (vartype_realmatrix *) m; if (reg_x->type == TYPE_REAL) { phloat d = ((vartype_real *) reg_x)->x; for (i = 0; i < rm->rows; i++) for (j = 0; j < rm->columns; j++) if (!rm->array->is_string[p] && rm->array->data[p] == d) { matedit_i = i; matedit_j = j; return ERR_YES; } else p++; } else /* reg_x->type == TYPE_STRING */ { vartype_string *s = (vartype_string *) reg_x; for (i = 0; i < rm->rows; i++) for (j = 0; j < rm->columns; j++) if (rm->array->is_string[p] && string_equals(s->text, s->length, phloat_text(rm->array->data[p]), phloat_length(rm->array->data[p]))) { matedit_i = i; matedit_j = j; return ERR_YES; } else p++; } } else /* m->type == TYPE_COMPLEXMATRIX */ { <API key> *cm; int4 i, j, p = 0; phloat re, im; if (reg_x->type != TYPE_COMPLEX) return ERR_NO; cm = (<API key> *) m; re = ((vartype_complex *) reg_x)->re; im = ((vartype_complex *) reg_x)->im; for (i = 0; i < cm->rows; i++) for (j = 0; j < cm->columns; j++) if (cm->array->data[p] == re && cm->array->data[p + 1] == im) { matedit_i = i; matedit_j = j; return ERR_YES; } else p += 2; } return ERR_NO; } int docmd_xrom(arg_struct *arg) { return ERR_NONEXISTENT; }
#ifndef _MPC8610_PCM_H #define _MPC8610_PCM_H struct ccsr_dma { u8 res0[0x100]; struct ccsr_dma_channel { __be32 mr; /* Mode register */ __be32 sr; /* Status register */ __be32 eclndar; /* Current link descriptor extended addr reg */ __be32 clndar; /* Current link descriptor address register */ __be32 satr; /* Source attributes register */ __be32 sar; /* Source address register */ __be32 datr; /* Destination attributes register */ __be32 dar; /* Destination address register */ __be32 bcr; /* Byte count register */ __be32 enlndar; /* Next link descriptor extended address reg */ __be32 nlndar; /* Next link descriptor address register */ u8 res1[4]; __be32 eclsdar; /* Current list descriptor extended addr reg */ __be32 clsdar; /* Current list descriptor address register */ __be32 enlsdar; /* Next list descriptor extended address reg */ __be32 nlsdar; /* Next list descriptor address register */ __be32 ssr; /* Source stride register */ __be32 dsr; /* Destination stride register */ u8 res2[0x38]; } channel[4]; __be32 dgsr; }; #define <API key> 0x0F000000 #define <API key> 24 #define <API key> 0x0F000000 #define CCSR_DMA_MR_BWC(x) \ ((ilog2(x) << <API key>) & <API key>) #define CCSR_DMA_MR_EMP_EN 0x00200000 #define CCSR_DMA_MR_EMS_EN 0x00040000 #define <API key> 0x00030000 #define CCSR_DMA_MR_DAHTS_1 0x00000000 #define CCSR_DMA_MR_DAHTS_2 0x00010000 #define CCSR_DMA_MR_DAHTS_4 0x00020000 #define CCSR_DMA_MR_DAHTS_8 0x00030000 #define <API key> 0x0000C000 #define CCSR_DMA_MR_SAHTS_1 0x00000000 #define CCSR_DMA_MR_SAHTS_2 0x00004000 #define CCSR_DMA_MR_SAHTS_4 0x00008000 #define CCSR_DMA_MR_SAHTS_8 0x0000C000 #define CCSR_DMA_MR_DAHE 0x00002000 #define CCSR_DMA_MR_SAHE 0x00001000 #define CCSR_DMA_MR_SRW 0x00000400 #define CCSR_DMA_MR_EOSIE 0x00000200 #define CCSR_DMA_MR_EOLNIE 0x00000100 #define CCSR_DMA_MR_EOLSIE 0x00000080 #define CCSR_DMA_MR_EIE 0x00000040 #define CCSR_DMA_MR_XFE 0x00000020 #define <API key> 0x00000010 #define CCSR_DMA_MR_CA 0x00000008 #define CCSR_DMA_MR_CTM 0x00000004 #define CCSR_DMA_MR_CC 0x00000002 #define CCSR_DMA_MR_CS 0x00000001 #define CCSR_DMA_SR_TE 0x00000080 #define CCSR_DMA_SR_CH 0x00000020 #define CCSR_DMA_SR_PE 0x00000010 #define CCSR_DMA_SR_EOLNI 0x00000008 #define CCSR_DMA_SR_CB 0x00000004 #define CCSR_DMA_SR_EOSI 0x00000002 #define CCSR_DMA_SR_EOLSI 0x00000001 /* ECLNDAR takes bits 32-36 of the CLNDAR register */ static inline u32 <API key>(u64 x) { return (x >> 32) & 0xf; } #define <API key>(x) ((x) & 0xFFFFFFFE) #define <API key> 0x00000008 /* SATR and DATR, combined */ #define CCSR_DMA_ATR_PBATMU 0x20000000 #define <API key> 0x00000000 #define <API key> 0x06000000 #define <API key> 0x08000000 #define <API key> 0x0C000000 #define <API key> 0x02000000 #define CCSR_DMA_ATR_SME 0x01000000 #define <API key> 0x00040000 #define CCSR_DMA_ATR_SNOOP 0x00050000 #define <API key> 0x0000000F /** * List Descriptor for extended chaining mode DMA operations. * * The CLSDAR register points to the first (in a linked-list) List * Descriptor. Each object must be aligned on a 32-byte boundary. Each * list descriptor points to a linked-list of link Descriptors. */ struct <API key> { __be64 next; /* Address of next list descriptor */ __be64 first_link; /* Address of first link descriptor */ __be32 source; /* Source stride */ __be32 dest; /* Destination stride */ u8 res[8]; /* Reserved */ } __attribute__ ((aligned(32), packed)); /** * Link Descriptor for basic and extended chaining mode DMA operations. * * A Link Descriptor points to a single DMA buffer. Each link descriptor * must be aligned on a 32-byte boundary. */ struct <API key> { __be32 source_attr; /* Programmed into SATR register */ __be32 source_addr; /* Programmed into SAR register */ __be32 dest_attr; /* Programmed into DATR register */ __be32 dest_addr; /* Programmed into DAR register */ __be64 next; /* Address of next link descriptor */ __be32 count; /* Byte count */ u8 res[4]; /* Reserved */ } __attribute__ ((aligned(32), packed)); <<<< HEAD ==== /* DMA information needed to create a snd_soc_dai object * * ssi_stx_phys: bus address of SSI STX register to use * ssi_srx_phys: bus address of SSI SRX register to use * dma[0]: points to the DMA channel to use for playback * dma[1]: points to the DMA channel to use for capture * dma_irq[0]: IRQ of the DMA channel to use for playback * dma_irq[1]: IRQ of the DMA channel to use for capture */ struct fsl_dma_info { dma_addr_t ssi_stx_phys; dma_addr_t ssi_srx_phys; struct ccsr_dma_channel __iomem *dma_channel[2]; unsigned int dma_irq[2]; }; extern struct snd_soc_platform fsl_soc_platform; int fsl_dma_configure(struct fsl_dma_info *dma_info); >>>> <SHA1-like> #endif
ALTER TABLE db_version CHANGE COLUMN <API key> <API key> bit; DELETE FROM mangos_string WHERE entry BETWEEN 1149 AND 1151; INSERT INTO mangos_string VALUES (1149,' (Pool %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1150,' (Event %i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1151,' (Pool %u Event %i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); DELETE FROM mangos_string WHERE entry in (515, 517, 1110, 1111, 1137); INSERT INTO mangos_string VALUES (515,'%d%s - |cffffffff|Hcreature:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -- <API key> (.list creature) (517,'%d%s, Entry %d - |cffffffff|Hgameobject:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -- <API key> (.gobject near) (1110,'%d%s - %s X:%f Y:%f Z:%f MapId:%d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -- <API key> (1111,'%d%s - %s X:%f Y:%f Z:%f MapId:%d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -- <API key> (1137,'%d%s - |cffffffff|Hgameobject:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); -- LANG_GO_LIST_CHAT (.list object)
#ifndef __SYSSDL_H__ #define __SYSSDL_H__ #ifdef __MACH__ #include <SDL/SDL.h> #else #include <SDL.h> #endif #include "system/display.h" #include "system/systhread.h" extern SDL_Surface * gSDLScreen; class SDLSystemDisplay: public SystemDisplay { protected: <API key> mSDLChar; byte * mSDLFrameBuffer; bool mChangingScreen; SDL_Surface * mSDLClientScreen; sys_mutex mRedrawMutex; SDL_Cursor * mVisibleCursor; SDL_Cursor * mInvisibleCursor; uint <API key>(uint bitsPerPixel); void dumpDisplayChar(const <API key> &chr); public: char * mTitle; <API key> mSDLChartemp; SDL_cond *mWaitcondition; bool mChangeResRet; uint32 mEventThreadID; SDLSystemDisplay(const char *title, const <API key> &chr, int redraw_ms); void finishMenu(); virtual void updateTitle(); virtual int toString(char *buf, int buflen) const; void toggleFullScreen(); virtual void displayShow(); virtual void <API key>(<API key> &aHostChar, const <API key> &aClientChar); virtual bool changeResolution(const <API key> &aCharacteristics); virtual bool <API key>(const <API key> &aCharacteristics); virtual void <API key>(Container &modes); virtual void setMouseGrab(bool enable); virtual void initCursor(); }; #endif
/*! \class BiQuad \brief STK biquad (two-pole, two-zero) filter class. This class implements a two-pole, two-zero digital filter. Methods are provided for creating a resonance or notch in the frequency response while maintaining a constant filter gain. by Perry R. Cook and Gary P. Scavone, 1995-2012. */ #include "BiQuad.h" #include <cmath> namespace stk { BiQuad :: BiQuad() : Filter() { b_.resize( 3, 0.0 ); a_.resize( 3, 0.0 ); b_[0] = 1.0; a_[0] = 1.0; inputs_.resize( 3, 1, 0.0 ); outputs_.resize( 3, 1, 0.0 ); Stk::addSampleRateAlert( this ); } BiQuad :: ~BiQuad() { Stk::<API key>( this ); } void BiQuad :: setCoefficients( StkFloat b0, StkFloat b1, StkFloat b2, StkFloat a1, StkFloat a2, bool clearState ) { b_[0] = b0; b_[1] = b1; b_[2] = b2; a_[1] = a1; a_[2] = a2; if ( clearState ) this->clear(); } void BiQuad :: sampleRateChanged( StkFloat newRate, StkFloat oldRate ) { if ( !<API key> ) { std::cerr << "BiQuad::sampleRateChanged: you may need to recompute filter coefficients!"; handleError( StkError::WARNING ); } } void BiQuad :: setResonance( StkFloat frequency, StkFloat radius, bool normalize ) { #if defined(_STK_DEBUG_) if ( frequency < 0.0 || frequency > 0.5 * Stk::sampleRate() ) { std::cerr << "BiQuad::setResonance: frequency argument (" << frequency << ") is out of range!"; handleError( StkError::WARNING ); return; } if ( radius < 0.0 || radius >= 1.0 ) { std::cerr << "BiQuad::setResonance: radius argument (" << radius << ") is out of range!"; handleError( StkError::WARNING ); return; } #endif a_[2] = radius * radius; a_[1] = -2.0 * radius * cos( TWO_PI * frequency / Stk::sampleRate() ); if ( normalize ) { // Use zeros at +- 1 and normalize the filter peak gain. b_[0] = 0.5 - 0.5 * a_[2]; b_[1] = 0.0; b_[2] = -b_[0]; } } void BiQuad :: setNotch( StkFloat frequency, StkFloat radius ) { #if defined(_STK_DEBUG_) if ( frequency < 0.0 || frequency > 0.5 * Stk::sampleRate() ) { std::cerr << "BiQuad::setNotch: frequency argument (" << frequency << ") is out of range!"; handleError( StkError::WARNING ); return; } if ( radius < 0.0 ) { std::cerr << "BiQuad::setNotch: radius argument (" << radius << ") is negative!"; handleError( StkError::WARNING ); return; } #endif // This method does not attempt to normalize the filter gain. b_[2] = radius * radius; b_[1] = (StkFloat) -2.0 * radius * cos( TWO_PI * (double) frequency / Stk::sampleRate() ); } void BiQuad :: setEqualGainZeroes( void ) { b_[0] = 1.0; b_[1] = 0.0; b_[2] = -1.0; } } // stk namespace
#include "mpqfile.h" #include <deque> #include <cstdio> #include "StormLib.h" MPQFile::MPQFile(HANDLE mpq, const char* filename, bool warnNoExist /*= true*/) : eof(false), buffer(0), pointer(0), size(0) { HANDLE file; if (!SFileOpenFileEx(mpq, filename, <API key>, &file)) { if (warnNoExist || GetLastError() != <API key>) fprintf(stderr, "Can't open %s, err=%u!\n", filename, GetLastError()); eof = true; return; } DWORD hi = 0; size = SFileGetFileSize(file, &hi); if (hi) { fprintf(stderr, "Can't open %s, size[hi] = %u!\n", filename, uint32(hi)); SFileCloseFile(file); eof = true; return; } if (size <= 1) { fprintf(stderr, "Can't open %s, size = %u!\n", filename, uint32(size)); SFileCloseFile(file); eof = true; return; } DWORD read = 0; buffer = new char[size]; if (!SFileReadFile(file, buffer, size, &read) || size != read) { fprintf(stderr, "Can't read %s, size=%u read=%u!\n", filename, uint32(size), uint32(read)); SFileCloseFile(file); eof = true; return; } SFileCloseFile(file); } size_t MPQFile::read(void* dest, size_t bytes) { if (eof) return 0; size_t rpos = pointer + bytes; if (rpos > size) { bytes = size - pointer; eof = true; } memcpy(dest, &(buffer[pointer]), bytes); pointer = rpos; return bytes; } void MPQFile::seek(int offset) { pointer = offset; eof = (pointer >= size); } void MPQFile::seekRelative(int offset) { pointer += offset; eof = (pointer >= size); } void MPQFile::close() { if (buffer) delete[] buffer; buffer = 0; eof = true; }
<div><p><br/></p></div><div class="container"> <div class="row"> <div id="index" class="col-md-3"> <div > <div class="panel panel-default"> <div class="panel-heading">Classes</div> <div class="panel-body"><a href="/docs/api/BB_Frame"><span class="indent" style="padding-left:14px;"><i class="icon-jsdoc icon-jsdoc-class"></i><span class="jsdoc-class-index">Frame</span></span></a></div> <div class="panel-body"><a href="/docs/api/BB_RecPlayer"><span class="indent" style="padding-left:14px;"><i class="icon-jsdoc icon-jsdoc-class"></i><span class="jsdoc-class-index">RecPlayer</span></span></a></div> <div class="panel-body"><a href="/docs/api/BB_Recording"><span class="indent" style="padding-left:14px;"><i class="icon-jsdoc icon-jsdoc-class"></i><span class="jsdoc-class-index">Recording</span></span></a></div> <div class="panel-body"><a href="/docs/api/BB_Session"><span class="indent" style="padding-left:14px;"><i class="icon-jsdoc icon-jsdoc-class"></i><span class="jsdoc-class-index">Session</span></span></a></div> <div class="panel-body"><a href="/docs/api/_global_"><span class="indent" style="padding-left:0px;"><i class="icon-jsdoc <API key>"></i><span class="jsdoc-class-index">_global_</span></span></a></div> </div> </div> </div> <div id="content" class="col-md-9"> <pre class="prettyprint linenums">goog.provide('BB.Session'); goog.require('BB.Frame'); goog.require('BB.Recording'); /** * * @param {string} backendUrl * @param {number=} fps * @param {string=} title * @param {string=} url * * @constructor */ BB.Session = function(backendUrl, fps, title, url) { /** @type {string} */ this.backendUrl = backendUrl; /** @type {number} */ this.fps = fps || 3; /** @type {number} */ this.TICK_MILLI = 1000 / this.fps; /** @type {string} */ this.title = title || BB.Session.getPageTitle(); /** @type {string} */ this.url = url || BB.Session.getPageUrl(); /** @type {Array.&lt;BB.Frame&gt;} */ this.frames = []; /** @type {boolean} */ this.active = false; /** @type {number} Pointer to setTimeout */ this.timer; /** @type {boolean} */ this.clicked = false; this.init(); }; /** * @private */ BB.Session.prototype.init = function(){ var self = this; document.addEventListener('mousemove', function(e) { BB.Session.mouse.x = e.clientX || e.pageX; BB.Session.mouse.y = e.clientY || e.pageY; }, false); document.addEventListener('click', function(e) { self.clicked = true; }, false); }; /** * Start recording a session */ BB.Session.prototype.start = function(){ if (!this.active) { this.active = true; this.tick(); } }; /** * Stop recording a session */ BB.Session.prototype.stop = function(){ clearTimeout(this.timer); this.active = false; }; /** * Captures the current frame * * @private */ BB.Session.prototype.tick = function(){ if (this.active) { var frame = new BB.Frame( BB.Frame.getCurrentWin(), BB.Frame.getCurrentScroll(), BB.Frame.getCurrentMouse(), this.clicked ); this.frames.push(frame); this.timer = setTimeout(this.tick.bind(this), this.TICK_MILLI); this.clicked = false; } }; /** * Send recording to backend server */ BB.Session.prototype.upload = function(){ var xhr = new XMLHttpRequest(); xhr.open('POST', '/save.php', true); xhr.setRequestHeader('Content-type', 'application/<API key>'); xhr.send('recording=' + this.toString()); }; /** * * @returns {string} */ BB.Session.getPageTitle = function() { var el = document.<API key>('title'); var title = 'Untitled document'; if (el.length &gt; 0) { title = el[0].textContent; } return title; }; /** * * @returns {string} */ BB.Session.getPageUrl = function(){ return window.location.href; }; /** * * @returns {string} */ BB.Session.prototype.toString = function(){ return JSON.stringify( new BB.Recording(this.title, this.url, BB.Frame.getClientRes(), this.fps, this.frames) ); }; /** * * @type {BB.mouse} */ BB.Session.mouse = { x: 0, y: 0 }; </div> </div> </div> <script type="text/javascript"> prettyPrint(); var i = 1; $('#source-code li').each(function() { $(this).attr({ id: 'line' + (i++) }); }); </script> </div></div>
import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.urlopen("http://192.168.11.5:8080/drinkcounter/get_datas/").read().split("\n") drinkers = [] for data_row in data: if data_row == '': continue fields = data_row.split('|') drinker = Drinker() drinker.id = int(fields[0]) drinker.name = fields[1] drinker.drinks = int(fields[2]) drinker.prom = float(fields[3]) drinker.idle = fields[4] drinkers.append(drinker) return drinkers def get_listbox_items(drinkers): items = [] for drinker in drinkers: items.append(unicode('%s, %d drinks, %s' % (drinker.name, drinker.drinks, drinker.idle))) return items appuifw.app.title = u"Alkoholilaskuri" app_lock = e32.Ao_lock() #Define the exit function def quit(): app_lock.signal() appuifw.app.exit_key_handler = quit drinkers = get_drinker_list() items = get_listbox_items(drinkers) #Define a function that is called when an item is selected def handle_selection(): selected_drinker = drinkers[lb.current()] urllib2.urlopen("http://192.168.11.5:8080/drinkcounter/add_drink/%d/" % (selected_drinker.id)) appuifw.note(u"A drink has been added to " + drinkers[lb.current()].name, 'info') new_drinkers = get_drinker_list() items = get_listbox_items(new_drinkers) lb.set_list(items, lb.current()) #Create an instance of Listbox and set it as the application's body lb = appuifw.Listbox(items, handle_selection) appuifw.app.body = lb app_lock.wait()
package com.mikesantiago.mariofighter; import static com.mikesantiago.mariofighter.GlobalVariables.PPM; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.BodyDef; import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; import com.badlogic.gdx.physics.box2d.Fixture; import com.badlogic.gdx.physics.box2d.FixtureDef; import com.badlogic.gdx.physics.box2d.PolygonShape; import com.badlogic.gdx.physics.box2d.World; import com.mikesantiago.mariofighter.assets.Animation; public class PlayerOne { public enum Direction { LEFT, RIGHT, STOP } private BodyDef playerBodyDef; private Body playerBody; private PolygonShape playerShape; private FixtureDef playerFixtureDef; private Fixture playerFixture; private boolean isMoving = false; private Direction currentDirection = Direction.RIGHT; private Animation animationRight; private Animation animationLeft; public boolean getMoving(){return isMoving;} public Direction getCurrentDirection(){return currentDirection;} public PlayerOne(World worldToCreateIn) { playerBodyDef = new BodyDef(); playerBodyDef.type = BodyType.DynamicBody; playerBodyDef.position.set(new Vector2(32f / PPM, 256f / PPM)); playerBody = worldToCreateIn.createBody(playerBodyDef); playerShape = new PolygonShape(); playerShape.setAsBox((32f / 2) / PPM, (36f / 2) / PPM); playerFixtureDef = new FixtureDef(); playerFixtureDef.shape = playerShape; playerFixtureDef.filter.categoryBits = GlobalVariables.PLAYER_BIT; playerFixtureDef.filter.maskBits = GlobalVariables.GROUND_BIT; playerFixture = playerBody.createFixture(playerFixtureDef); playerFixture.setUserData("body"); //create foot sensor { playerShape.setAsBox(2 / PPM, 2 / PPM, new Vector2(0, -32 / PPM), 0); playerFixtureDef.shape = playerShape; playerFixtureDef.filter.categoryBits = GlobalVariables.PLAYER_BIT; playerFixtureDef.filter.maskBits = GlobalVariables.GROUND_BIT; playerFixtureDef.isSensor = true; playerBody.createFixture(playerFixtureDef).setUserData("FOOT"); } CreateAnimation(); System.out.println("Player 1 created!"); } private void CreateAnimation() { float updateInterval = 1 / 20f; Texture tex = GlobalVariables.manager.GetTexture("mario"); TextureRegion[] sprites = TextureRegion.split(tex, 16, 28)[0]; if(animationRight == null) animationRight = new Animation(); animationRight.setFrames(sprites, updateInterval); if(animationLeft == null) animationLeft = new Animation(); TextureRegion[] leftSprites = TextureRegion.split(tex, 16, 28)[0]; for(TextureRegion tr : leftSprites) tr.flip(true, false); animationLeft.setFrames(leftSprites, updateInterval); sprWidth = sprites[0].getRegionWidth(); sprHeight = sprites[0].getRegionHeight(); } private int sprWidth, sprHeight; public void update(float dt) { if(this.isMoving) { animationRight.update(dt); animationLeft.update(dt); } } public void render(SpriteBatch sb) { if(!sb.isDrawing()) sb.begin(); sb.setProjectionMatrix(GlobalVariables.maincamera.combined); if(this.isMoving) { if(this.currentDirection == Direction.RIGHT) { sb.draw(animationRight.getFrame(), (playerBody.getPosition().x * PPM) - 16, (playerBody.getPosition().y * PPM) - 34, sprWidth * 2, sprHeight * 2); } else if(this.currentDirection == Direction.LEFT) { sb.draw(animationLeft.getFrame(), (playerBody.getPosition().x * PPM) - 16, (playerBody.getPosition().y * PPM) - 34, sprWidth * 2, sprHeight * 2); } } else { if(this.currentDirection == Direction.RIGHT) { sb.draw(animationRight.getFrame(0), (playerBody.getPosition().x * PPM) - 16, (playerBody.getPosition().y * PPM) - 34, sprWidth * 2, sprHeight * 2); } else if(this.currentDirection == Direction.LEFT) { sb.draw(animationLeft.getFrame(0), (playerBody.getPosition().x * PPM) - 16, (playerBody.getPosition().y * PPM) - 34, sprWidth * 2, sprHeight * 2); } } if(sb.isDrawing()) sb.end(); } public void setMoving(boolean a){this.isMoving = a;} public void setCurrentDirection(Direction a){currentDirection = a;} public BodyDef getPlayerBodyDef() { return playerBodyDef; } public void setPlayerBodyDef(BodyDef playerBodyDef) { this.playerBodyDef = playerBodyDef; } public Body getPlayerBody() { return playerBody; } public void setPlayerBody(Body playerBody) { this.playerBody = playerBody; } public PolygonShape getPlayerShape() { return playerShape; } public void setPlayerShape(PolygonShape playerShape) { this.playerShape = playerShape; } public FixtureDef getPlayerFixtureDef() { return playerFixtureDef; } public void setPlayerFixtureDef(FixtureDef playerFixtureDef) { this.playerFixtureDef = playerFixtureDef; } public Fixture getPlayerFixture() { return playerFixture; } public void setPlayerFixture(Fixture playerFixture) { this.playerFixture = playerFixture; } }
#include "exec/def-helper.h" #ifdef CONFIG_TCG_PLUGIN DEF_HELPER_FLAGS_4(tcg_plugin_pre_tb, 0, void, i64, i64, i64, i64) #endif DEF_HELPER_2(exception, noreturn, env, i32) DEF_HELPER_3(exception_cause, noreturn, env, i32, i32) DEF_HELPER_4(<API key>, noreturn, env, i32, i32, i32) DEF_HELPER_3(debug_exception, noreturn, env, i32, i32) DEF_HELPER_FLAGS_1(nsa, TCG_CALL_NO_RWG_SE, i32, i32) DEF_HELPER_FLAGS_1(nsau, TCG_CALL_NO_RWG_SE, i32, i32) DEF_HELPER_2(wsr_windowbase, void, env, i32) DEF_HELPER_4(entry, void, env, i32, i32, i32) DEF_HELPER_2(retw, i32, env, i32) DEF_HELPER_2(rotw, void, env, i32) DEF_HELPER_3(window_check, void, env, i32, i32) DEF_HELPER_1(restore_owb, void, env) DEF_HELPER_2(movsp, void, env, i32) DEF_HELPER_2(wsr_lbeg, void, env, i32) DEF_HELPER_2(wsr_lend, void, env, i32) DEF_HELPER_1(simcall, void, env) DEF_HELPER_1(dump_state, void, env) DEF_HELPER_3(waiti, void, env, i32, i32) DEF_HELPER_3(timer_irq, void, env, i32, i32) DEF_HELPER_2(advance_ccount, void, env, i32) DEF_HELPER_1(check_interrupts, void, env) DEF_HELPER_3(check_atomctl, void, env, i32, i32) DEF_HELPER_2(wsr_rasid, void, env, i32) DEF_HELPER_FLAGS_3(rtlb0, TCG_CALL_NO_RWG_SE, i32, env, i32, i32) DEF_HELPER_FLAGS_3(rtlb1, TCG_CALL_NO_RWG_SE, i32, env, i32, i32) DEF_HELPER_3(itlb, void, env, i32, i32) DEF_HELPER_3(ptlb, i32, env, i32, i32) DEF_HELPER_4(wtlb, void, env, i32, i32, i32) DEF_HELPER_2(wsr_ibreakenable, void, env, i32) DEF_HELPER_3(wsr_ibreaka, void, env, i32, i32) DEF_HELPER_3(wsr_dbreaka, void, env, i32, i32) DEF_HELPER_3(wsr_dbreakc, void, env, i32, i32) DEF_HELPER_2(wur_fcr, void, env, i32) DEF_HELPER_FLAGS_1(abs_s, TCG_CALL_NO_RWG_SE, f32, f32) DEF_HELPER_FLAGS_1(neg_s, TCG_CALL_NO_RWG_SE, f32, f32) DEF_HELPER_3(add_s, f32, env, f32, f32) DEF_HELPER_3(sub_s, f32, env, f32, f32) DEF_HELPER_3(mul_s, f32, env, f32, f32) DEF_HELPER_4(madd_s, f32, env, f32, f32, f32) DEF_HELPER_4(msub_s, f32, env, f32, f32, f32) DEF_HELPER_FLAGS_3(ftoi, TCG_CALL_NO_RWG_SE, i32, f32, i32, i32) DEF_HELPER_FLAGS_3(ftoui, TCG_CALL_NO_RWG_SE, i32, f32, i32, i32) DEF_HELPER_3(itof, f32, env, i32, i32) DEF_HELPER_3(uitof, f32, env, i32, i32) DEF_HELPER_4(un_s, void, env, i32, f32, f32) DEF_HELPER_4(oeq_s, void, env, i32, f32, f32) DEF_HELPER_4(ueq_s, void, env, i32, f32, f32) DEF_HELPER_4(olt_s, void, env, i32, f32, f32) DEF_HELPER_4(ult_s, void, env, i32, f32, f32) DEF_HELPER_4(ole_s, void, env, i32, f32, f32) DEF_HELPER_4(ule_s, void, env, i32, f32, f32) #include "exec/def-helper.h"
<?php class Request { public static function redirect($to) { header('Location: ' . Config::get('url') . $to); } public static function path() { return $_SERVER['REQUEST_URI']; } public static function method() { $method = $_SERVER['REQUEST_METHOD']; if($method === 'PUT') return 'put'; if($method === 'GET') return 'post'; if($method === 'GET') return 'get'; if($method === 'HEAD') return 'head'; if($method === 'DELETE') return 'delete'; if($method === 'OPTIONS') return 'options'; return false; } public static function isMethod($method) { if(self::method() === $method) { return true; } return false; } }
#include <linux/kernel.h> #include <linux/init.h> #include <linux/module.h> #include <linux/interrupt.h> #include <linux/gpio.h> #include <linux/slab.h> #include <linux/of_gpio.h> #include <linux/platform_device.h> #include <linux/irq.h> #include <media/rc-core.h> #include <media/gpio-ir-recv.h> #define GPIO_IR_DRIVER_NAME "gpio-rc-recv" #define GPIO_IR_DEVICE_NAME "gpio_ir_recv" struct gpio_rc_dev { struct rc_dev *rcdev; unsigned int gpio_nr; bool active_low; int can_sleep; }; #ifdef CONFIG_OF /* * Translate OpenFirmware node properties into platform_data */ static int <API key>(struct device *dev, struct <API key> *pdata) { struct device_node *np = dev->of_node; enum of_gpio_flags flags; int gpio; gpio = of_get_gpio_flags(np, 0, &flags); if (gpio < 0) { if (gpio != -EPROBE_DEFER) dev_err(dev, "Failed to get gpio flags (%d)\n", gpio); return gpio; } pdata->gpio_nr = gpio; pdata->active_low = (flags & OF_GPIO_ACTIVE_LOW); /* probe() takes care of map_name == NULL or allowed_protos == 0 */ pdata->map_name = of_get_property(np, "linux,rc-map-name", NULL); pdata->allowed_protos = 0; return 0; } static struct of_device_id <API key>[] = { { .compatible = "gpio-ir-receiver", }, { }, }; MODULE_DEVICE_TABLE(of, <API key>); #else /* !CONFIG_OF */ #define <API key>(dev, pdata) (-ENOSYS) #endif static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id) { struct gpio_rc_dev *gpio_dev = dev_id; unsigned int gval; int rc = 0; enum raw_event_type type = IR_SPACE; if (gpio_dev->can_sleep) gval = <API key>(gpio_dev->gpio_nr); else gval = gpio_get_value(gpio_dev->gpio_nr); if (gval < 0) goto err_get_value; if (gpio_dev->active_low) gval = !gval; if (gval == 1) type = IR_PULSE; rc = <API key>(gpio_dev->rcdev, type); if (rc < 0) goto err_get_value; ir_raw_event_handle(gpio_dev->rcdev); err_get_value: return IRQ_HANDLED; } static int gpio_ir_recv_probe(struct platform_device *pdev) { struct gpio_rc_dev *gpio_dev; struct rc_dev *rcdev; const struct <API key> *pdata = pdev->dev.platform_data; int rc; if (pdev->dev.of_node) { struct <API key> *dtpdata = devm_kzalloc(&pdev->dev, sizeof(*dtpdata), GFP_KERNEL); if (!dtpdata) return -ENOMEM; rc = <API key>(&pdev->dev, dtpdata); if (rc) return rc; pdata = dtpdata; } if (!pdata) return -EINVAL; if (pdata->gpio_nr < 0) return -EINVAL; gpio_dev = kzalloc(sizeof(struct gpio_rc_dev), GFP_KERNEL); if (!gpio_dev) return -ENOMEM; rcdev = rc_allocate_device(); if (!rcdev) { rc = -ENOMEM; goto err_allocate_device; } rcdev->priv = gpio_dev; rcdev->driver_type = RC_DRIVER_IR_RAW; rcdev->input_name = GPIO_IR_DEVICE_NAME; rcdev->input_phys = GPIO_IR_DEVICE_NAME "/input0"; rcdev->input_id.bustype = BUS_HOST; rcdev->input_id.vendor = 0x0001; rcdev->input_id.product = 0x0001; rcdev->input_id.version = 0x0100; rcdev->dev.parent = &pdev->dev; rcdev->driver_name = GPIO_IR_DRIVER_NAME; <<<< HEAD rcdev->map_name = RC_MAP_SAMSUNG_NECX; ==== if (pdata->allowed_protos) rcdev->allowed_protos = pdata->allowed_protos; else rcdev->allowed_protos = RC_BIT_ALL; rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY; >>>> common/android-3.10.y gpio_dev->rcdev = rcdev; gpio_dev->gpio_nr = pdata->gpio_nr; gpio_dev->active_low = pdata->active_low; rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv"); if (rc < 0) goto err_gpio_request; gpio_dev->can_sleep = gpio_cansleep(pdata->gpio_nr); rc = <API key>(pdata->gpio_nr); if (rc < 0) goto <API key>; rc = rc_register_device(rcdev); if (rc < 0) { dev_err(&pdev->dev, "failed to register rc device\n"); goto <API key>; } <API key>(pdev, gpio_dev); rc = <API key>(gpio_to_irq(pdata->gpio_nr), gpio_ir_recv_irq, <API key> | IRQF_TRIGGER_RISING, "gpio-ir-recv-irq", gpio_dev); if (rc < 0) goto err_request_irq; device_init_wakeup(&pdev->dev, pdata->can_wakeup); return 0; err_request_irq: <API key>(pdev, NULL); <API key>(rcdev); rcdev = NULL; <API key>: <API key>: gpio_free(pdata->gpio_nr); err_gpio_request: rc_free_device(rcdev); err_allocate_device: kfree(gpio_dev); return rc; } static int gpio_ir_recv_remove(struct platform_device *pdev) { struct gpio_rc_dev *gpio_dev = <API key>(pdev); free_irq(gpio_to_irq(gpio_dev->gpio_nr), gpio_dev); <API key>(pdev, NULL); <API key>(gpio_dev->rcdev); gpio_free(gpio_dev->gpio_nr); kfree(gpio_dev); return 0; } #ifdef CONFIG_PM static int <API key>(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct gpio_rc_dev *gpio_dev = <API key>(pdev); if (device_may_wakeup(dev)) enable_irq_wake(gpio_to_irq(gpio_dev->gpio_nr)); else disable_irq(gpio_to_irq(gpio_dev->gpio_nr)); return 0; } static int gpio_ir_recv_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct gpio_rc_dev *gpio_dev = <API key>(pdev); if (device_may_wakeup(dev)) disable_irq_wake(gpio_to_irq(gpio_dev->gpio_nr)); else enable_irq(gpio_to_irq(gpio_dev->gpio_nr)); return 0; } static const struct dev_pm_ops gpio_ir_recv_pm_ops = { .suspend = <API key>, .resume = gpio_ir_recv_resume, }; #endif static struct platform_driver gpio_ir_recv_driver = { .probe = gpio_ir_recv_probe, .remove = gpio_ir_recv_remove, .driver = { .name = GPIO_IR_DRIVER_NAME, .owner = THIS_MODULE, .of_match_table = of_match_ptr(<API key>), #ifdef CONFIG_PM .pm = &gpio_ir_recv_pm_ops, #endif }, }; <API key>(gpio_ir_recv_driver); MODULE_DESCRIPTION("GPIO IR Receiver driver"); MODULE_LICENSE("GPL v2");
package com.caucho.quercus.lib.spl; import com.caucho.quercus.env.Value; public interface OuterIterator extends Iterator { public Value getInnerIterator(); }
// This file is part of Libmoleculizer // Moleculizer is free software; you can redistribute it and/or modify // (at your option) any later version. // Moleculizer is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // along with Moleculizer; if not, write to the Free Software Foundation // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA // END HEADER // Larry Lok, Research Fellow, Molecular Sciences Institute, 2001 // Modifing Authors: #ifndef FND_DUMPSTREAM_H #define FND_DUMPSTREAM_H #include <fstream> #include <vector> #include "utl/xcpt.hh" #include "utl/autoVector.hh" #include "fnd/dumpable.hh" #include "fnd/dmpColumn.hh" namespace fnd { class dumpStream : public utl::autoVector<basicDmpColumn> { // Now that the output stream and everything else is passed to // the dumpables through a dumpArg, these are here mainly to // memory-manage the stream, to emphasize that this class is what // corresponds to a .dmp file, and to facilitate the construction // of dumpArg's through getOstream(), in particular. std::string fileName; std::ostream* pOs; std::ofstream* pFileStream; public: // Use a genuine file path, "-" for std::cout, "+" for std::cerr. dumpStream( const std::string& rFileName ) throw( utl::xcpt ); ~dumpStream( void ) { // This is null if the output stream not actually a file. delete pFileStream; } std::ostream& getOstream( void ) const { return *pOs; } // Returns the file name given at construction time, including // the special cases. const std::string& getFileName( void ) const { return fileName; } // Initializes output stream and writes column headers. void init( void ) throw( utl::xcpt ); // Writes a line in the output file. void doDump( void ); }; } #endif // FND_DUMPSTREAM_H
from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, \ ConfigEnableDisable, ConfigSubsection, ConfigBoolean, <API key>, ConfigNothing, NoSave from enigma import eAVSwitch, getDesktop from SystemInfo import SystemInfo from os import path as os_path class AVSwitch: def setInput(self, input): INPUT = { "ENCODER": 0, "SCART": 1, "AUX": 2 } eAVSwitch.getInstance().setInput(INPUT[input]) def setColorFormat(self, value): eAVSwitch.getInstance().setColorFormat(value) def setAspectRatio(self, value): eAVSwitch.getInstance().setAspectRatio(value) def setSystem(self, value): eAVSwitch.getInstance().setVideomode(value) def getOutputAspect(self): valstr = config.av.aspectratio.value if valstr in ("4_3_letterbox", "4_3_panscan"): return (4,3) elif valstr == "16_9": # auto ... 4:3 or 16:9 try: aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read() if aspect_str == "1": return (4,3) except IOError: pass elif valstr in ("16_9_always", "16_9_letterbox"): # 16:9 pass elif valstr in ("16_10_letterbox", "16_10_panscan"): # 16:10 return (16,10) return (16,9) def getFramebufferScale(self): aspect = self.getOutputAspect() fb_size = getDesktop(0).size() return (aspect[0] * fb_size.height(), aspect[1] * fb_size.width()) def <API key>(self): valstr = config.av.aspectratio.value if valstr == "4_3_letterbox": val = 0 elif valstr == "4_3_panscan": val = 1 elif valstr == "16_9": val = 2 elif valstr == "16_9_always": val = 3 elif valstr == "16_10_letterbox": val = 4 elif valstr == "16_10_panscan": val = 5 elif valstr == "16_9_letterbox": val = 6 return val def setAspectWSS(self, aspect=None): if not config.av.wss.value: value = 2 # auto(4:3_off) else: value = 1 # auto eAVSwitch.getInstance().setWSS(value) def InitAVSwitch(): config.av = ConfigSubsection() config.av.yuvenabled = ConfigBoolean(default=False) colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")} # when YUV is not enabled, don't let the user select it if config.av.yuvenabled.value: colorformat_choices["yuv"] = _("YPbPr") # ikseong config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="cvbs") config.av.aspectratio = ConfigSelection(choices={ "4_3_letterbox": _("4:3 Letterbox"), "4_3_panscan": _("4:3 PanScan"), "16_9": _("16:9"), "16_9_always": _("16:9 always"), "16_10_letterbox": _("16:10 Letterbox"), "16_10_panscan": _("16:10 PanScan"), "16_9_letterbox": _("16:9 Letterbox")}, default = "4_3_letterbox") config.av.aspect = ConfigSelection(choices={ "4_3": _("4:3"), "16_9": _("16:9"), "16_10": _("16:10"), "auto": _("Automatic")}, default = "auto") config.av.policy_169 = ConfigSelection(choices={ # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term. "letterbox": _("Letterbox"), # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term "panscan": _("Pan&Scan"), # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect) "scale": _("Just Scale")}, default = "letterbox") config.av.policy_43 = ConfigSelection(choices={ # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term. "pillarbox": _("Pillarbox"), # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term "panscan": _("Pan&Scan"), # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right) "nonlinear": _("Nonlinear"), # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect) "scale": _("Just Scale")}, default = "pillarbox") config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal") config.av.wss = ConfigEnableDisable(default = True) config.av.defaultac3 = ConfigYesNo(default = False) config.av.generalAC3delay = <API key>(-1000, 1000, 25, default = 0) config.av.generalPCMdelay = <API key>(-1000, 1000, 25, default = 0) config.av.vcrswitch = ConfigEnableDisable(default = False) iAVSwitch = AVSwitch() def setColorFormat(configElement): map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3} iAVSwitch.setColorFormat(map[configElement.value]) def setAspectRatio(configElement): map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6} iAVSwitch.setAspectRatio(map[configElement.value]) def setSystem(configElement): map = {"pal": 0, "ntsc": 1, "multinorm" : 2} iAVSwitch.setSystem(map[configElement.value]) def setWSS(configElement): iAVSwitch.setAspectWSS() # this will call the "setup-val" initial config.av.colorformat.addNotifier(setColorFormat) config.av.aspectratio.addNotifier(setAspectRatio) config.av.tvsystem.addNotifier(setSystem) config.av.wss.addNotifier(setWSS) iAVSwitch.setInput("ENCODER") # init on startup SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch() try: can_downmix = open("/proc/stb/audio/ac3_choices", "r").read()[:-1].find("downmix") != -1 except: can_downmix = False SystemInfo["CanDownmixAC3"] = can_downmix if can_downmix: def setAC3Downmix(configElement): open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough") config.av.downmix_ac3 = ConfigYesNo(default = True) config.av.downmix_ac3.addNotifier(setAC3Downmix) try: can_downmix_aac = open("/proc/stb/audio/aac_choices", "r").read()[:-1].find("downmix") != -1 except: can_downmix_aac = False SystemInfo["CanDownmixAAC"] = can_downmix_aac if can_downmix_aac: def setAACDownmix(configElement): open("/proc/stb/audio/aac", "w").write(configElement.value and "downmix" or "passthrough") config.av.downmix_aac = ConfigYesNo(default = True) config.av.downmix_aac.addNotifier(setAACDownmix) try: can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False except: can_osd_alpha = False SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha def setAlpha(config): open("/proc/stb/video/alpha", "w").write(str(config.value)) if can_osd_alpha: config.av.osd_alpha = ConfigSlider(default=255, limits=(0,255)) config.av.osd_alpha.addNotifier(setAlpha) if os_path.exists("/proc/stb/vmpeg/0/<API key>"): def setScaler_sharpness(config): myval = int(config.value) try: print "--> setting scaler_sharpness to: %0.8X" % myval open("/proc/stb/vmpeg/0/<API key>", "w").write("%0.8X" % myval) open("/proc/stb/vmpeg/0/pep_apply", "w").write("1") except IOError: print "couldn't write <API key>" config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26)) config.av.scaler_sharpness.addNotifier(setScaler_sharpness) else: config.av.scaler_sharpness = NoSave(ConfigNothing())
#include <linux/major.h> #include <linux/blkdev.h> #include <linux/module.h> #include <linux/init.h> #include <linux/sched.h> #include <linux/fs.h> #include <linux/bio.h> #include <linux/stat.h> #include <linux/errno.h> #include <linux/file.h> #include <linux/ioctl.h> #include <linux/mutex.h> #include <linux/compiler.h> #include <linux/err.h> #include <linux/kernel.h> #include <linux/slab.h> #include <net/sock.h> #include <linux/net.h> #include <linux/kthread.h> #include <asm/uaccess.h> #include <asm/types.h> #include <linux/nbd.h> #define NBD_MAGIC 0x68797548 #ifdef NDEBUG #define dprintk(flags, fmt...) #else /* NDEBUG */ #define dprintk(flags, fmt...) do { \ if (debugflags & (flags)) printk(KERN_DEBUG fmt); \ } while (0) #define DBG_IOCTL 0x0004 #define DBG_INIT 0x0010 #define DBG_EXIT 0x0020 #define DBG_BLKDEV 0x0100 #define DBG_RX 0x0200 #define DBG_TX 0x0400 static unsigned int debugflags; #endif /* NDEBUG */ static unsigned int nbds_max = 16; static struct nbd_device *nbd_dev; static int max_part; /* * Use just one lock (or at most 1 per NIC). Two arguments for this: * 1. Each NIC is essentially a synchronization point for all servers * accessed through that NIC so there's no need to have more locks * than NICs anyway. * 2. More locks lead to more "Dirty cache line bouncing" which will slow * down each lock to the point where they're actually slower than just * a single lock. * Thanks go to Jens Axboe and Al Viro for their LKML emails explaining this! */ static DEFINE_SPINLOCK(nbd_lock); #ifndef NDEBUG static const char *ioctl_cmd_to_ascii(int cmd) { switch (cmd) { case NBD_SET_SOCK: return "set-sock"; case NBD_SET_BLKSIZE: return "set-blksize"; case NBD_SET_SIZE: return "set-size"; case NBD_SET_TIMEOUT: return "set-timeout"; case NBD_SET_FLAGS: return "set-flags"; case NBD_DO_IT: return "do-it"; case NBD_CLEAR_SOCK: return "clear-sock"; case NBD_CLEAR_QUE: return "clear-que"; case NBD_PRINT_DEBUG: return "print-debug"; case NBD_SET_SIZE_BLOCKS: return "set-size-blocks"; case NBD_DISCONNECT: return "disconnect"; case BLKROSET: return "set-read-only"; case BLKFLSBUF: return "flush-buffer-cache"; } return "unknown"; } static const char *nbdcmd_to_ascii(int cmd) { switch (cmd) { case NBD_CMD_READ: return "read"; case NBD_CMD_WRITE: return "write"; case NBD_CMD_DISC: return "disconnect"; case NBD_CMD_FLUSH: return "flush"; case NBD_CMD_TRIM: return "trim/discard"; } return "invalid"; } #endif /* NDEBUG */ static void nbd_end_request(struct request *req) { int error = req->errors ? -EIO : 0; struct request_queue *q = req->q; unsigned long flags; dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->disk_name, req, error ? "failed" : "done"); spin_lock_irqsave(q->queue_lock, flags); <API key>(req, error); <API key>(q->queue_lock, flags); } static void sock_shutdown(struct nbd_device *nbd, int lock) { /* Forcibly shutdown the socket causing all listeners * to error * * FIXME: This code is duplicated from sys_shutdown, but * there should be a more generic interface rather than * calling socket ops directly here */ if (lock) mutex_lock(&nbd->tx_lock); if (nbd->sock) { dev_warn(disk_to_dev(nbd->disk), "shutting down socket\n"); <API key>(nbd->sock, SHUT_RDWR); nbd->sock = NULL; } if (lock) mutex_unlock(&nbd->tx_lock); } static void nbd_xmit_timeout(unsigned long arg) { struct task_struct *task = (struct task_struct *)arg; printk(KERN_WARNING "nbd: killing hung xmit (%s, pid: %d)\n", task->comm, task->pid); force_sig(SIGKILL, task); } /* * Send or receive packet. */ static int sock_xmit(struct nbd_device *nbd, int send, void *buf, int size, int msg_flags) { struct socket *sock = nbd->sock; int result; struct msghdr msg; struct kvec iov; sigset_t blocked, oldset; unsigned long pflags = current->flags; if (unlikely(!sock)) { dev_err(disk_to_dev(nbd->disk), "Attempted %s on closed socket in sock_xmit\n", (send ? "send" : "recv")); return -EINVAL; } /* Allow interception of SIGKILL only * Don't allow other signals to interrupt the transmission */ siginitsetinv(&blocked, sigmask(SIGKILL)); sigprocmask(SIG_SETMASK, &blocked, &oldset); current->flags |= PF_MEMALLOC; do { sock->sk->sk_allocation = GFP_NOIO | __GFP_MEMALLOC; iov.iov_base = buf; iov.iov_len = size; msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_control = NULL; msg.msg_controllen = 0; msg.msg_flags = msg_flags | MSG_NOSIGNAL; if (send) { struct timer_list ti; if (nbd->xmit_timeout) { init_timer(&ti); ti.function = nbd_xmit_timeout; ti.data = (unsigned long)current; ti.expires = jiffies + nbd->xmit_timeout; add_timer(&ti); } result = kernel_sendmsg(sock, &msg, &iov, 1, size); if (nbd->xmit_timeout) del_timer_sync(&ti); } else result = kernel_recvmsg(sock, &msg, &iov, 1, size, msg.msg_flags); if (signal_pending(current)) { siginfo_t info; printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n", task_pid_nr(current), current->comm, dequeue_signal_lock(current, &current->blocked, &info)); result = -EINTR; sock_shutdown(nbd, !send); break; } if (result <= 0) { if (result == 0) result = -EPIPE; /* short read */ break; } size -= result; buf += result; } while (size > 0); sigprocmask(SIG_SETMASK, &oldset, NULL); tsk_restore_flags(current, pflags, PF_MEMALLOC); return result; } static inline int sock_send_bvec(struct nbd_device *nbd, struct bio_vec *bvec, int flags) { int result; void *kaddr = kmap(bvec->bv_page); result = sock_xmit(nbd, 1, kaddr + bvec->bv_offset, bvec->bv_len, flags); kunmap(bvec->bv_page); return result; } /* always call with the tx_lock held */ static int nbd_send_req(struct nbd_device *nbd, struct request *req) { int result, flags; struct nbd_request request; unsigned long size = blk_rq_bytes(req); request.magic = htonl(NBD_REQUEST_MAGIC); request.type = htonl(nbd_cmd(req)); if (nbd_cmd(req) == NBD_CMD_FLUSH) { /* Other values are reserved for FLUSH requests. */ request.from = 0; request.len = 0; } else { request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9); request.len = htonl(size); } memcpy(request.handle, &req, sizeof(req)); dprintk(DBG_TX, "%s: request %p: sending control (%s@%llu,%uB)\n", nbd->disk->disk_name, req, nbdcmd_to_ascii(nbd_cmd(req)), (unsigned long long)blk_rq_pos(req) << 9, blk_rq_bytes(req)); result = sock_xmit(nbd, 1, &request, sizeof(request), (nbd_cmd(req) == NBD_CMD_WRITE) ? MSG_MORE : 0); if (result <= 0) { dev_err(disk_to_dev(nbd->disk), "Send control failed (result %d)\n", result); goto error_out; } if (nbd_cmd(req) == NBD_CMD_WRITE) { struct req_iterator iter; struct bio_vec bvec; /* * we are really probing at internals to determine * whether to set MSG_MORE or not... */ rq_for_each_segment(bvec, req, iter) { flags = 0; if (!rq_iter_last(bvec, iter)) flags = MSG_MORE; dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", nbd->disk->disk_name, req, bvec.bv_len); result = sock_send_bvec(nbd, &bvec, flags); if (result <= 0) { dev_err(disk_to_dev(nbd->disk), "Send data failed (result %d)\n", result); goto error_out; } } } return 0; error_out: return -EIO; } static struct request *nbd_find_request(struct nbd_device *nbd, struct request *xreq) { struct request *req, *tmp; int err; err = <API key>(nbd->active_wq, nbd->active_req != xreq); if (unlikely(err)) goto out; spin_lock(&nbd->queue_lock); <API key>(req, tmp, &nbd->queue_head, queuelist) { if (req != xreq) continue; list_del_init(&req->queuelist); spin_unlock(&nbd->queue_lock); return req; } spin_unlock(&nbd->queue_lock); err = -ENOENT; out: return ERR_PTR(err); } static inline int sock_recv_bvec(struct nbd_device *nbd, struct bio_vec *bvec) { int result; void *kaddr = kmap(bvec->bv_page); result = sock_xmit(nbd, 0, kaddr + bvec->bv_offset, bvec->bv_len, MSG_WAITALL); kunmap(bvec->bv_page); return result; } /* NULL returned = something went wrong, inform userspace */ static struct request *nbd_read_stat(struct nbd_device *nbd) { int result; struct nbd_reply reply; struct request *req; reply.magic = 0; result = sock_xmit(nbd, 0, &reply, sizeof(reply), MSG_WAITALL); if (result <= 0) { dev_err(disk_to_dev(nbd->disk), "Receive control failed (result %d)\n", result); goto harderror; } if (ntohl(reply.magic) != NBD_REPLY_MAGIC) { dev_err(disk_to_dev(nbd->disk), "Wrong magic (0x%lx)\n", (unsigned long)ntohl(reply.magic)); result = -EPROTO; goto harderror; } req = nbd_find_request(nbd, *(struct request **)reply.handle); if (IS_ERR(req)) { result = PTR_ERR(req); if (result != -ENOENT) goto harderror; dev_err(disk_to_dev(nbd->disk), "Unexpected reply (%p)\n", reply.handle); result = -EBADR; goto harderror; } if (ntohl(reply.error)) { dev_err(disk_to_dev(nbd->disk), "Other side returned error (%d)\n", ntohl(reply.error)); req->errors++; return req; } dprintk(DBG_RX, "%s: request %p: got reply\n", nbd->disk->disk_name, req); if (nbd_cmd(req) == NBD_CMD_READ) { struct req_iterator iter; struct bio_vec bvec; rq_for_each_segment(bvec, req, iter) { result = sock_recv_bvec(nbd, &bvec); if (result <= 0) { dev_err(disk_to_dev(nbd->disk), "Receive data failed (result %d)\n", result); req->errors++; return req; } dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", nbd->disk->disk_name, req, bvec.bv_len); } } return req; harderror: nbd->harderror = result; return NULL; } static ssize_t pid_show(struct device *dev, struct device_attribute *attr, char *buf) { struct gendisk *disk = dev_to_disk(dev); return sprintf(buf, "%ld\n", (long) ((struct nbd_device *)disk->private_data)->pid); } static struct device_attribute pid_attr = { .attr = { .name = "pid", .mode = S_IRUGO}, .show = pid_show, }; static int nbd_do_it(struct nbd_device *nbd) { struct request *req; int ret; BUG_ON(nbd->magic != NBD_MAGIC); sk_set_memalloc(nbd->sock->sk); nbd->pid = task_pid_nr(current); ret = device_create_file(disk_to_dev(nbd->disk), &pid_attr); if (ret) { dev_err(disk_to_dev(nbd->disk), "device_create_file failed!\n"); nbd->pid = 0; return ret; } while ((req = nbd_read_stat(nbd)) != NULL) nbd_end_request(req); device_remove_file(disk_to_dev(nbd->disk), &pid_attr); nbd->pid = 0; return 0; } static void nbd_clear_que(struct nbd_device *nbd) { struct request *req; BUG_ON(nbd->magic != NBD_MAGIC); /* * Because we have set nbd->sock to NULL under the tx_lock, all * modifications to the list must have completed by now. For * the same reason, the active_req must be NULL. * * As a consequence, we don't need to take the spin lock while * purging the list here. */ BUG_ON(nbd->sock); BUG_ON(nbd->active_req); while (!list_empty(&nbd->queue_head)) { req = list_entry(nbd->queue_head.next, struct request, queuelist); list_del_init(&req->queuelist); req->errors++; nbd_end_request(req); } while (!list_empty(&nbd->waiting_queue)) { req = list_entry(nbd->waiting_queue.next, struct request, queuelist); list_del_init(&req->queuelist); req->errors++; nbd_end_request(req); } } static void nbd_handle_req(struct nbd_device *nbd, struct request *req) { if (req->cmd_type != REQ_TYPE_FS) goto error_out; nbd_cmd(req) = NBD_CMD_READ; if (rq_data_dir(req) == WRITE) { if ((req->cmd_flags & REQ_DISCARD)) { WARN_ON(!(nbd->flags & NBD_FLAG_SEND_TRIM)); nbd_cmd(req) = NBD_CMD_TRIM; } else nbd_cmd(req) = NBD_CMD_WRITE; if (nbd->flags & NBD_FLAG_READ_ONLY) { dev_err(disk_to_dev(nbd->disk), "Write on read-only\n"); goto error_out; } } if (req->cmd_flags & REQ_FLUSH) { BUG_ON(unlikely(blk_rq_sectors(req))); nbd_cmd(req) = NBD_CMD_FLUSH; } req->errors = 0; mutex_lock(&nbd->tx_lock); if (unlikely(!nbd->sock)) { mutex_unlock(&nbd->tx_lock); dev_err(disk_to_dev(nbd->disk), "Attempted send on closed socket\n"); goto error_out; } nbd->active_req = req; if (nbd_send_req(nbd, req) != 0) { dev_err(disk_to_dev(nbd->disk), "Request send failed\n"); req->errors++; nbd_end_request(req); } else { spin_lock(&nbd->queue_lock); list_add_tail(&req->queuelist, &nbd->queue_head); spin_unlock(&nbd->queue_lock); } nbd->active_req = NULL; mutex_unlock(&nbd->tx_lock); wake_up_all(&nbd->active_wq); return; error_out: req->errors++; nbd_end_request(req); } static int nbd_thread(void *data) { struct nbd_device *nbd = data; struct request *req; set_user_nice(current, MIN_NICE); while (!kthread_should_stop() || !list_empty(&nbd->waiting_queue)) { /* wait for something to do */ <API key>(nbd->waiting_wq, kthread_should_stop() || !list_empty(&nbd->waiting_queue)); /* extract request */ if (list_empty(&nbd->waiting_queue)) continue; spin_lock_irq(&nbd->queue_lock); req = list_entry(nbd->waiting_queue.next, struct request, queuelist); list_del_init(&req->queuelist); spin_unlock_irq(&nbd->queue_lock); /* handle request */ nbd_handle_req(nbd, req); } return 0; } /* * We always wait for result of write, for now. It would be nice to make it optional * in future * if ((rq_data_dir(req) == WRITE) && (nbd->flags & NBD_WRITE_NOCHK)) * { printk( "Warning: Ignoring result!\n"); nbd_end_request( req ); } */ static void do_nbd_request(struct request_queue *q) __releases(q->queue_lock) __acquires(q->queue_lock) { struct request *req; while ((req = blk_fetch_request(q)) != NULL) { struct nbd_device *nbd; spin_unlock_irq(q->queue_lock); dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n", req->rq_disk->disk_name, req, req->cmd_type); nbd = req->rq_disk->private_data; BUG_ON(nbd->magic != NBD_MAGIC); if (unlikely(!nbd->sock)) { dev_err(disk_to_dev(nbd->disk), "Attempted send on closed socket\n"); req->errors++; nbd_end_request(req); spin_lock_irq(q->queue_lock); continue; } spin_lock_irq(&nbd->queue_lock); list_add_tail(&req->queuelist, &nbd->waiting_queue); spin_unlock_irq(&nbd->queue_lock); wake_up(&nbd->waiting_wq); spin_lock_irq(q->queue_lock); } } /* Must be called with tx_lock held */ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, unsigned int cmd, unsigned long arg) { switch (cmd) { case NBD_DISCONNECT: { struct request sreq; dev_info(disk_to_dev(nbd->disk), "NBD_DISCONNECT\n"); if (!nbd->sock) return -EINVAL; mutex_unlock(&nbd->tx_lock); fsync_bdev(bdev); mutex_lock(&nbd->tx_lock); blk_rq_init(NULL, &sreq); sreq.cmd_type = REQ_TYPE_SPECIAL; nbd_cmd(&sreq) = NBD_CMD_DISC; /* Check again after getting mutex back. */ if (!nbd->sock) return -EINVAL; nbd->disconnect = 1; nbd_send_req(nbd, &sreq); return 0; } case NBD_CLEAR_SOCK: { struct socket *sock = nbd->sock; nbd->sock = NULL; nbd_clear_que(nbd); BUG_ON(!list_empty(&nbd->queue_head)); BUG_ON(!list_empty(&nbd->waiting_queue)); kill_bdev(bdev); if (sock) sockfd_put(sock); return 0; } case NBD_SET_SOCK: { struct socket *sock; int err; if (nbd->sock) return -EBUSY; sock = sockfd_lookup(arg, &err); if (sock) { nbd->sock = sock; if (max_part > 0) bdev->bd_invalidated = 1; nbd->disconnect = 0; /* we're connected now */ return 0; } return -EINVAL; } case NBD_SET_BLKSIZE: nbd->blksize = arg; nbd->bytesize &= ~(nbd->blksize-1); bdev->bd_inode->i_size = nbd->bytesize; set_blocksize(bdev, nbd->blksize); set_capacity(nbd->disk, nbd->bytesize >> 9); return 0; case NBD_SET_SIZE: nbd->bytesize = arg & ~(nbd->blksize-1); bdev->bd_inode->i_size = nbd->bytesize; set_blocksize(bdev, nbd->blksize); set_capacity(nbd->disk, nbd->bytesize >> 9); return 0; case NBD_SET_TIMEOUT: nbd->xmit_timeout = arg * HZ; return 0; case NBD_SET_FLAGS: nbd->flags = arg; return 0; case NBD_SET_SIZE_BLOCKS: nbd->bytesize = ((u64) arg) * nbd->blksize; bdev->bd_inode->i_size = nbd->bytesize; set_blocksize(bdev, nbd->blksize); set_capacity(nbd->disk, nbd->bytesize >> 9); return 0; case NBD_DO_IT: { struct task_struct *thread; struct socket *sock; int error; if (nbd->pid) return -EBUSY; if (!nbd->sock) return -EINVAL; mutex_unlock(&nbd->tx_lock); if (nbd->flags & NBD_FLAG_READ_ONLY) set_device_ro(bdev, true); if (nbd->flags & NBD_FLAG_SEND_TRIM) <API key>(QUEUE_FLAG_DISCARD, nbd->disk->queue); if (nbd->flags & NBD_FLAG_SEND_FLUSH) blk_queue_flush(nbd->disk->queue, REQ_FLUSH); else blk_queue_flush(nbd->disk->queue, 0); thread = kthread_create(nbd_thread, nbd, "%s", nbd->disk->disk_name); if (IS_ERR(thread)) { mutex_lock(&nbd->tx_lock); return PTR_ERR(thread); } wake_up_process(thread); error = nbd_do_it(nbd); kthread_stop(thread); mutex_lock(&nbd->tx_lock); if (error) return error; sock_shutdown(nbd, 0); sock = nbd->sock; nbd->sock = NULL; nbd_clear_que(nbd); dev_warn(disk_to_dev(nbd->disk), "queue cleared\n"); kill_bdev(bdev); <API key>(QUEUE_FLAG_DISCARD, nbd->disk->queue); set_device_ro(bdev, false); if (sock) sockfd_put(sock); nbd->flags = 0; nbd->bytesize = 0; bdev->bd_inode->i_size = 0; set_capacity(nbd->disk, 0); if (max_part > 0) ioctl_by_bdev(bdev, BLKRRPART, 0); if (nbd->disconnect) /* user requested, ignore socket errors */ return 0; return nbd->harderror; } case NBD_CLEAR_QUE: /* * This is for compatibility only. The queue is always cleared * by NBD_DO_IT or NBD_CLEAR_SOCK. */ return 0; case NBD_PRINT_DEBUG: dev_info(disk_to_dev(nbd->disk), "next = %p, prev = %p, head = %p\n", nbd->queue_head.next, nbd->queue_head.prev, &nbd->queue_head); return 0; } return -ENOTTY; } static int nbd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { struct nbd_device *nbd = bdev->bd_disk->private_data; int error; if (!capable(CAP_SYS_ADMIN)) return -EPERM; BUG_ON(nbd->magic != NBD_MAGIC); /* Anyone capable of this syscall can do *real bad* things */ dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", nbd->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); mutex_lock(&nbd->tx_lock); error = __nbd_ioctl(bdev, nbd, cmd, arg); mutex_unlock(&nbd->tx_lock); return error; } static const struct <API key> nbd_fops = { .owner = THIS_MODULE, .ioctl = nbd_ioctl, }; /* * And here should be modules and kernel interface * (Just smiley confuses emacs :-) */ static int __init nbd_init(void) { int err = -ENOMEM; int i; int part_shift; BUILD_BUG_ON(sizeof(struct nbd_request) != 28); if (max_part < 0) { printk(KERN_ERR "nbd: max_part must be >= 0\n"); return -EINVAL; } nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL); if (!nbd_dev) return -ENOMEM; part_shift = 0; if (max_part > 0) { part_shift = fls(max_part); /* * Adjust max_part according to part_shift as it is exported * to user space so that user can know the max number of * partition kernel should be able to manage. * * Note that -1 is required because partition 0 is reserved * for the whole disk. */ max_part = (1UL << part_shift) - 1; } if ((1UL << part_shift) > DISK_MAX_PARTS) return -EINVAL; if (nbds_max > 1UL << (MINORBITS - part_shift)) return -EINVAL; for (i = 0; i < nbds_max; i++) { struct gendisk *disk = alloc_disk(1 << part_shift); if (!disk) goto out; nbd_dev[i].disk = disk; /* * The new linux 2.5 block layer implementation requires * every gendisk to have its very own request_queue struct. * These structs are big so we dynamically allocate them. */ disk->queue = blk_init_queue(do_nbd_request, &nbd_lock); if (!disk->queue) { put_disk(disk); goto out; } /* * Tell the block layer that we are not a rotational device */ <API key>(QUEUE_FLAG_NONROT, disk->queue); disk->queue->limits.discard_granularity = 512; disk->queue->limits.max_discard_sectors = UINT_MAX; disk->queue->limits.discard_zeroes_data = 0; <API key>(disk->queue, 65536); disk->queue->limits.max_sectors = 256; } if (register_blkdev(NBD_MAJOR, "nbd")) { err = -EIO; goto out; } printk(KERN_INFO "nbd: registered device at major %d\n", NBD_MAJOR); dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags); for (i = 0; i < nbds_max; i++) { struct gendisk *disk = nbd_dev[i].disk; nbd_dev[i].magic = NBD_MAGIC; INIT_LIST_HEAD(&nbd_dev[i].waiting_queue); spin_lock_init(&nbd_dev[i].queue_lock); INIT_LIST_HEAD(&nbd_dev[i].queue_head); mutex_init(&nbd_dev[i].tx_lock); init_waitqueue_head(&nbd_dev[i].active_wq); init_waitqueue_head(&nbd_dev[i].waiting_wq); nbd_dev[i].blksize = 1024; nbd_dev[i].bytesize = 0; disk->major = NBD_MAJOR; disk->first_minor = i << part_shift; disk->fops = &nbd_fops; disk->private_data = &nbd_dev[i]; sprintf(disk->disk_name, "nbd%d", i); set_capacity(disk, 0); add_disk(disk); } return 0; out: while (i blk_cleanup_queue(nbd_dev[i].disk->queue); put_disk(nbd_dev[i].disk); } kfree(nbd_dev); return err; } static void __exit nbd_cleanup(void) { int i; for (i = 0; i < nbds_max; i++) { struct gendisk *disk = nbd_dev[i].disk; nbd_dev[i].magic = 0; if (disk) { del_gendisk(disk); blk_cleanup_queue(disk->queue); put_disk(disk); } } unregister_blkdev(NBD_MAJOR, "nbd"); kfree(nbd_dev); printk(KERN_INFO "nbd: unregistered device at major %d\n", NBD_MAJOR); } module_init(nbd_init); module_exit(nbd_cleanup); MODULE_DESCRIPTION("Network Block Device"); MODULE_LICENSE("GPL"); module_param(nbds_max, int, 0444); MODULE_PARM_DESC(nbds_max, "number of network block devices to initialize (default: 16)"); module_param(max_part, int, 0444); MODULE_PARM_DESC(max_part, "number of partitions per device (default: 0)"); #ifndef NDEBUG module_param(debugflags, int, 0644); MODULE_PARM_DESC(debugflags, "flags for controlling debug output"); #endif
<?php namespace App\Test\Fixture; use Cake\TestSuite\Fixture\TestFixture; /** * <API key> * */ class <API key> extends TestFixture { /** * Fields * * @var array */ public $fields = [ 'id' => ['type' => 'integer', 'length' => 6, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], 'name' => ['type' => 'string', 'length' => 45, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], '_constraints' => [ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []], ], '_options' => [ 'engine' => 'InnoDB', 'collation' => 'utf8_hungarian_ci' ], ]; /** * Records * * @var array */ public $records = [ [ 'id' => 1, 'name' => 'Contactsoure 1' ], [ 'id' => 2, 'name' => 'Contactsoure 2' ], ]; }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!--NewPage <HTML> <HEAD> <!-- Generated by javadoc on Sat Aug 06 17:04:43 EDT 2005 --> <TITLE> Xalan-Java 2.7.0: Uses of Class org.apache.xpath.functions.FuncCurrent </TITLE> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"> </HEAD> <BODY BGCOLOR="white"> <A NAME="navbar_top"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../org/apache/xpath/functions/FuncCurrent.html"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html" TARGET="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="FuncCurrent.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> </TR> </TABLE> <HR> <CENTER> <H2> <B>Uses of Class<br>org.apache.xpath.functions.FuncCurrent</B></H2> </CENTER> No usage of org.apache.xpath.functions.FuncCurrent <P> <HR> <A NAME="navbar_bottom"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="<API key>"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../org/apache/xpath/functions/FuncCurrent.html"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html" TARGET="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="FuncCurrent.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> </TR> </TABLE> <HR> Copyright © 2005 Apache XML Project. All Rights Reserved. </BODY> </HTML>
#ifndef UTILITIES_H #define UTILITIES_H #include "edge.h" #include <cstring> #include "resume.h" #include <algorithm> #include <vector> #include "Hungarian.h" #include "BipartiteGraph.h" #include "Matrix.h" using namespace std; typedef vector<vector<string>> section; #include "pair_section.h" class PairSection; typedef vector<string> line; typedef vector<pair<int, PairSection>> evidence; //class Resume; namespace string_util { char tolower(char in){ if(in<='Z' && in>='A') return in-('Z'-'z'); return in; } string tolower(string s) { string ret=s; for(int i=0;i<s.length();i++) ret[i]=tolower(s[i]); return ret; } // trim from start std::string &Ltrim(std::string &s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace)))); return s; } // trim from end std::string &Rtrim(std::string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); return s; } // trim from both ends std::string strip(std::string s) { return Ltrim(Rtrim(s)); } bool IsPresent(vector<string> v, string s) { for(int i=0;i<v.size();i++) if(v[i]==s) return true; return false; } vector<string> <API key>(vector<string> stopwords, string teststr) { vector<string> bag; //string teststr("The quick brown fox:test1,test2'test3\"test4"); //teststr=string_util::tolower(teststr); char *teststr_c_str = (char *)teststr.c_str(); char *token_c_str = strtok(teststr_c_str, DELIM); while (token_c_str) { if(!string_util::IsPresent(stopwords,string(token_c_str))) bag.push_back(string(token_c_str)); //printf ("Token: %s\n", p); token_c_str = strtok(NULL, DELIM); } //cout<<"Line: "<<teststr<<" bag ="; //for(int i=0;i<bag.size();i++) cout<<bag[i]<<"_"; //cout<<endl; //cin>>teststr; //cin.get(); return bag; } } namespace resume_util { bool IsBegin(string s) { int pos=s.find("CS0"); if(pos==0) return true; return false; } bool IsSection(string s,string section) { int pos=s.find(section); int len = s.length(); //if(pos==0 ) return true; if(pos==0 && pos<len && len-pos-section.length()<=10) return true; return false; } bool IsSummary(string s) { if(IsSection(s,"summary") || IsSection(s,"professional summary") || IsSection(s,"summary of qualifications")) return true; return false; } bool IsSkills(string s) { if(IsSection(s,"skills") || IsSection(s,"technical skills") || IsSection(s,"business and technical skills")) return true; return false; } bool IsExperience(string s) { if(IsSection(s,"experience") || IsSection(s,"project experience") || IsSection(s,"work experience") || IsSection(s,"professional experience") || IsSection(s,"recent experience")) return true; return false; } bool IsEducation(string s) { if(IsSection(s,"education") ) return true; return false; } bool IsResponsibilities(string s) { if(IsSection(s,"responsibilities")) return true; return false; } bool IsEnvSection(string s,string section) { int pos=s.find(section); //cout<<s<<"\n"<<section<<"__"<<pos<<endl; if(pos==0 ) return true; return false; } bool IsEnvironment(string s) { if(IsEnvSection(s,"environment:") || IsEnvSection(s,"environment :") || IsEnvSection(s,"tools and technologies:") || IsEnvSection(s,"tools and technologies :") || IsEnvSection(s,"tools & technolgies:") || IsEnvSection(s,"tools & technolgies :")) return true; return false; } } namespace distance_util { int Jaccard(line v1, line v2) { sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end()); line inter; line uni; set_intersection(v1.begin(),v1.end(), v2.begin(),v2.end(), back_inserter(inter)); set_union(v1.begin(),v1.end(), v2.begin(),v2.end(), back_inserter(uni)); float num=(float)(inter.size()); float denom=(float)(uni.size()); if(num == 0 || denom == 0) return 0; return int((num/denom)*1000); } } namespace matching_util { double <API key>(const section& s1, const section & s2, vector<pair_line> &pl) { printf("ENTER\n"); size_t nrows = s1.size(); size_t ncols = s2.size(); //define a matrix Matrix matrix; matrix.resize(nrows); for(unsigned int i=0; i<nrows; i++) matrix[i].resize(ncols); // generate for(unsigned int i=0; i<nrows; i++) for(unsigned int j=0; j<ncols; j++){ matrix[i][j].SetWeight(distance_util::Jaccard(s1[i],s2[j])); } BipartiteGraph bg(matrix); Hungarian h(bg); h.HungarianAlgo(); BipartiteGraph* result = h.GetBG(); Matrix result_matrix = *(result->GetMatrix()); double sum=0; for(unsigned int i=0; i< result->GetNumAgents(); i++){ for(unsigned int j=0; j< result->GetNumTasks(); j++){ if(result->GetMatrix(i,j)->GetMatchedFlag()) { pl.push_back(pair_line(i,j,result_matrix[i][j].GetWeight())); sum += result_matrix[i][j].GetWeight(); } } } printf("score= %f\n",sum); return sum; } int SectionSimilarity(const section& s1, const section& s2, vector<pair_line> &pl) { int nrow= s1.size(); int ncol= s2.size(); if(nrow <= ncol) { return (int)<API key>(s1,s2,pl); } else { double val = <API key>(s2,s1,pl); for(int i=0;i<pl.size();i++) { int temp_u = pl[i].u; pl[i].u = pl[i].v; pl[i].v = temp_u; } return (int)val; } } template <typename T> std::vector<size_t> ordered(std::vector<T> const& values) { std::vector<size_t> indices(values.size()); for(int i=0;i<values.size();i++) indices[i] = i; //iota(begin(indices), end(indices), static_cast<size_t>(0)); std::sort( begin(indices), end(indices), [&](size_t a, size_t b) { return values[a] > values[b]; } ); return indices; } } #endif
// G:\quake2\baseq2\models/monsters/boss3/rider // This file generated by ModelGen - Do NOT Modify #define FRAME_attak101 0 #define FRAME_attak102 1 #define FRAME_attak103 2 #define FRAME_attak104 3 #define FRAME_attak105 4 #define FRAME_attak106 5 #define FRAME_attak107 6 #define FRAME_attak108 7 #define FRAME_attak109 8 #define FRAME_attak110 9 #define FRAME_attak111 10 #define FRAME_attak112 11 #define FRAME_attak113 12 #define FRAME_attak114 13 #define FRAME_attak115 14 #define FRAME_attak116 15 #define FRAME_attak117 16 #define FRAME_attak118 17 #define FRAME_attak201 18 #define FRAME_attak202 19 #define FRAME_attak203 20 #define FRAME_attak204 21 #define FRAME_attak205 22 #define FRAME_attak206 23 #define FRAME_attak207 24 #define FRAME_attak208 25 #define FRAME_attak209 26 #define FRAME_attak210 27 #define FRAME_attak211 28 #define FRAME_attak212 29 #define FRAME_attak213 30 #define FRAME_death01 31 #define FRAME_death02 32 #define FRAME_death03 33 #define FRAME_death04 34 #define FRAME_death05 35 #define FRAME_death06 36 #define FRAME_death07 37 #define FRAME_death08 38 #define FRAME_death09 39 #define FRAME_death10 40 #define FRAME_death11 41 #define FRAME_death12 42 #define FRAME_death13 43 #define FRAME_death14 44 #define FRAME_death15 45 #define FRAME_death16 46 #define FRAME_death17 47 #define FRAME_death18 48 #define FRAME_death19 49 #define FRAME_death20 50 #define FRAME_death21 51 #define FRAME_death22 52 #define FRAME_death23 53 #define FRAME_death24 54 #define FRAME_death25 55 #define FRAME_death26 56 #define FRAME_death27 57 #define FRAME_death28 58 #define FRAME_death29 59 #define FRAME_death30 60 #define FRAME_death31 61 #define FRAME_death32 62 #define FRAME_death33 63 #define FRAME_death34 64 #define FRAME_death35 65 #define FRAME_death36 66 #define FRAME_death37 67 #define FRAME_death38 68 #define FRAME_death39 69 #define FRAME_death40 70 #define FRAME_death41 71 #define FRAME_death42 72 #define FRAME_death43 73 #define FRAME_death44 74 #define FRAME_death45 75 #define FRAME_death46 76 #define FRAME_death47 77 #define FRAME_death48 78 #define FRAME_death49 79 #define FRAME_death50 80 #define FRAME_pain101 81 #define FRAME_pain102 82 #define FRAME_pain103 83 #define FRAME_pain201 84 #define FRAME_pain202 85 #define FRAME_pain203 86 #define FRAME_pain301 87 #define FRAME_pain302 88 #define FRAME_pain303 89 #define FRAME_pain304 90 #define FRAME_pain305 91 #define FRAME_pain306 92 #define FRAME_pain307 93 #define FRAME_pain308 94 #define FRAME_pain309 95 #define FRAME_pain310 96 #define FRAME_pain311 97 #define FRAME_pain312 98 #define FRAME_pain313 99 #define FRAME_pain314 100 #define FRAME_pain315 101 #define FRAME_pain316 102 #define FRAME_pain317 103 #define FRAME_pain318 104 #define FRAME_pain319 105 #define FRAME_pain320 106 #define FRAME_pain321 107 #define FRAME_pain322 108 #define FRAME_pain323 109 #define FRAME_pain324 110 #define FRAME_pain325 111 #define FRAME_stand01 112 #define FRAME_stand02 113 #define FRAME_stand03 114 #define FRAME_stand04 115 #define FRAME_stand05 116 #define FRAME_stand06 117 #define FRAME_stand07 118 #define FRAME_stand08 119 #define FRAME_stand09 120 #define FRAME_stand10 121 #define FRAME_stand11 122 #define FRAME_stand12 123 #define FRAME_stand13 124 #define FRAME_stand14 125 #define FRAME_stand15 126 #define FRAME_stand16 127 #define FRAME_stand17 128 #define FRAME_stand18 129 #define FRAME_stand19 130 #define FRAME_stand20 131 #define FRAME_stand21 132 #define FRAME_stand22 133 #define FRAME_stand23 134 #define FRAME_stand24 135 #define FRAME_stand25 136 #define FRAME_stand26 137 #define FRAME_stand27 138 #define FRAME_stand28 139 #define FRAME_stand29 140 #define FRAME_stand30 141 #define FRAME_stand31 142 #define FRAME_stand32 143 #define FRAME_stand33 144 #define FRAME_stand34 145 #define FRAME_stand35 146 #define FRAME_stand36 147 #define FRAME_stand37 148 #define FRAME_stand38 149 #define FRAME_stand39 150 #define FRAME_stand40 151 #define FRAME_stand41 152 #define FRAME_stand42 153 #define FRAME_stand43 154 #define FRAME_stand44 155 #define FRAME_stand45 156 #define FRAME_stand46 157 #define FRAME_stand47 158 #define FRAME_stand48 159 #define FRAME_stand49 160 #define FRAME_stand50 161 #define FRAME_stand51 162 #define FRAME_walk01 163 #define FRAME_walk02 164 #define FRAME_walk03 165 #define FRAME_walk04 166 #define FRAME_walk05 167 #define FRAME_walk06 168 #define FRAME_walk07 169 #define FRAME_walk08 170 #define FRAME_walk09 171 #define FRAME_walk10 172 #define FRAME_walk11 173 #define FRAME_walk12 174 #define FRAME_walk13 175 #define FRAME_walk14 176 #define FRAME_walk15 177 #define FRAME_walk16 178 #define FRAME_walk17 179 #define FRAME_walk18 180 #define FRAME_walk19 181 #define FRAME_walk20 182 #define FRAME_walk21 183 #define FRAME_walk22 184 #define FRAME_walk23 185 #define FRAME_walk24 186 #define FRAME_walk25 187 #define FRAME_active01 188 #define FRAME_active02 189 #define FRAME_active03 190 #define FRAME_active04 191 #define FRAME_active05 192 #define FRAME_active06 193 #define FRAME_active07 194 #define FRAME_active08 195 #define FRAME_active09 196 #define FRAME_active10 197 #define FRAME_active11 198 #define FRAME_active12 199 #define FRAME_active13 200 #define FRAME_attak301 201 #define FRAME_attak302 202 #define FRAME_attak303 203 #define FRAME_attak304 204 #define FRAME_attak305 205 #define FRAME_attak306 206 #define FRAME_attak307 207 #define FRAME_attak308 208 #define FRAME_attak401 209 #define FRAME_attak402 210 #define FRAME_attak403 211 #define FRAME_attak404 212 #define FRAME_attak405 213 #define FRAME_attak406 214 #define FRAME_attak407 215 #define FRAME_attak408 216 #define FRAME_attak409 217 #define FRAME_attak410 218 #define FRAME_attak411 219 #define FRAME_attak412 220 #define FRAME_attak413 221 #define FRAME_attak414 222 #define FRAME_attak415 223 #define FRAME_attak416 224 #define FRAME_attak417 225 #define FRAME_attak418 226 #define FRAME_attak419 227 #define FRAME_attak420 228 #define FRAME_attak421 229 #define FRAME_attak422 230 #define FRAME_attak423 231 #define FRAME_attak424 232 #define FRAME_attak425 233 #define FRAME_attak426 234 #define FRAME_attak501 235 #define FRAME_attak502 236 #define FRAME_attak503 237 #define FRAME_attak504 238 #define FRAME_attak505 239 #define FRAME_attak506 240 #define FRAME_attak507 241 #define FRAME_attak508 242 #define FRAME_attak509 243 #define FRAME_attak510 244 #define FRAME_attak511 245 #define FRAME_attak512 246 #define FRAME_attak513 247 #define FRAME_attak514 248 #define FRAME_attak515 249 #define FRAME_attak516 250 #define FRAME_death201 251 #define FRAME_death202 252 #define FRAME_death203 253 #define FRAME_death204 254 #define FRAME_death205 255 #define FRAME_death206 256 #define FRAME_death207 257 #define FRAME_death208 258 #define FRAME_death209 259 #define FRAME_death210 260 #define FRAME_death211 261 #define FRAME_death212 262 #define FRAME_death213 263 #define FRAME_death214 264 #define FRAME_death215 265 #define FRAME_death216 266 #define FRAME_death217 267 #define FRAME_death218 268 #define FRAME_death219 269 #define FRAME_death220 270 #define FRAME_death221 271 #define FRAME_death222 272 #define FRAME_death223 273 #define FRAME_death224 274 #define FRAME_death225 275 #define FRAME_death226 276 #define FRAME_death227 277 #define FRAME_death228 278 #define FRAME_death229 279 #define FRAME_death230 280 #define FRAME_death231 281 #define FRAME_death232 282 #define FRAME_death233 283 #define FRAME_death234 284 #define FRAME_death235 285 #define FRAME_death236 286 #define FRAME_death237 287 #define FRAME_death238 288 #define FRAME_death239 289 #define FRAME_death240 290 #define FRAME_death241 291 #define FRAME_death242 292 #define FRAME_death243 293 #define FRAME_death244 294 #define FRAME_death245 295 #define FRAME_death246 296 #define FRAME_death247 297 #define FRAME_death248 298 #define FRAME_death249 299 #define FRAME_death250 300 #define FRAME_death251 301 #define FRAME_death252 302 #define FRAME_death253 303 #define FRAME_death254 304 #define FRAME_death255 305 #define FRAME_death256 306 #define FRAME_death257 307 #define FRAME_death258 308 #define FRAME_death259 309 #define FRAME_death260 310 #define FRAME_death261 311 #define FRAME_death262 312 #define FRAME_death263 313 #define FRAME_death264 314 #define FRAME_death265 315 #define FRAME_death266 316 #define FRAME_death267 317 #define FRAME_death268 318 #define FRAME_death269 319 #define FRAME_death270 320 #define FRAME_death271 321 #define FRAME_death272 322 #define FRAME_death273 323 #define FRAME_death274 324 #define FRAME_death275 325 #define FRAME_death276 326 #define FRAME_death277 327 #define FRAME_death278 328 #define FRAME_death279 329 #define FRAME_death280 330 #define FRAME_death281 331 #define FRAME_death282 332 #define FRAME_death283 333 #define FRAME_death284 334 #define FRAME_death285 335 #define FRAME_death286 336 #define FRAME_death287 337 #define FRAME_death288 338 #define FRAME_death289 339 #define FRAME_death290 340 #define FRAME_death291 341 #define FRAME_death292 342 #define FRAME_death293 343 #define FRAME_death294 344 #define FRAME_death295 345 #define FRAME_death301 346 #define FRAME_death302 347 #define FRAME_death303 348 #define FRAME_death304 349 #define FRAME_death305 350 #define FRAME_death306 351 #define FRAME_death307 352 #define FRAME_death308 353 #define FRAME_death309 354 #define FRAME_death310 355 #define FRAME_death311 356 #define FRAME_death312 357 #define FRAME_death313 358 #define FRAME_death314 359 #define FRAME_death315 360 #define FRAME_death316 361 #define FRAME_death317 362 #define FRAME_death318 363 #define FRAME_death319 364 #define FRAME_death320 365 #define FRAME_jump01 366 #define FRAME_jump02 367 #define FRAME_jump03 368 #define FRAME_jump04 369 #define FRAME_jump05 370 #define FRAME_jump06 371 #define FRAME_jump07 372 #define FRAME_jump08 373 #define FRAME_jump09 374 #define FRAME_jump10 375 #define FRAME_jump11 376 #define FRAME_jump12 377 #define FRAME_jump13 378 #define FRAME_pain401 379 #define FRAME_pain402 380 #define FRAME_pain403 381 #define FRAME_pain404 382 #define FRAME_pain501 383 #define FRAME_pain502 384 #define FRAME_pain503 385 #define FRAME_pain504 386 #define FRAME_pain601 387 #define FRAME_pain602 388 #define FRAME_pain603 389 #define FRAME_pain604 390 #define FRAME_pain605 391 #define FRAME_pain606 392 #define FRAME_pain607 393 #define FRAME_pain608 394 #define FRAME_pain609 395 #define FRAME_pain610 396 #define FRAME_pain611 397 #define FRAME_pain612 398 #define FRAME_pain613 399 #define FRAME_pain614 400 #define FRAME_pain615 401 #define FRAME_pain616 402 #define FRAME_pain617 403 #define FRAME_pain618 404 #define FRAME_pain619 405 #define FRAME_pain620 406 #define FRAME_pain621 407 #define FRAME_pain622 408 #define FRAME_pain623 409 #define FRAME_pain624 410 #define FRAME_pain625 411 #define FRAME_pain626 412 #define FRAME_pain627 413 #define FRAME_stand201 414 #define FRAME_stand202 415 #define FRAME_stand203 416 #define FRAME_stand204 417 #define FRAME_stand205 418 #define FRAME_stand206 419 #define FRAME_stand207 420 #define FRAME_stand208 421 #define FRAME_stand209 422 #define FRAME_stand210 423 #define FRAME_stand211 424 #define FRAME_stand212 425 #define FRAME_stand213 426 #define FRAME_stand214 427 #define FRAME_stand215 428 #define FRAME_stand216 429 #define FRAME_stand217 430 #define FRAME_stand218 431 #define FRAME_stand219 432 #define FRAME_stand220 433 #define FRAME_stand221 434 #define FRAME_stand222 435 #define FRAME_stand223 436 #define FRAME_stand224 437 #define FRAME_stand225 438 #define FRAME_stand226 439 #define FRAME_stand227 440 #define FRAME_stand228 441 #define FRAME_stand229 442 #define FRAME_stand230 443 #define FRAME_stand231 444 #define FRAME_stand232 445 #define FRAME_stand233 446 #define FRAME_stand234 447 #define FRAME_stand235 448 #define FRAME_stand236 449 #define FRAME_stand237 450 #define FRAME_stand238 451 #define FRAME_stand239 452 #define FRAME_stand240 453 #define FRAME_stand241 454 #define FRAME_stand242 455 #define FRAME_stand243 456 #define FRAME_stand244 457 #define FRAME_stand245 458 #define FRAME_stand246 459 #define FRAME_stand247 460 #define FRAME_stand248 461 #define FRAME_stand249 462 #define FRAME_stand250 463 #define FRAME_stand251 464 #define FRAME_stand252 465 #define FRAME_stand253 466 #define FRAME_stand254 467 #define FRAME_stand255 468 #define FRAME_stand256 469 #define FRAME_stand257 470 #define FRAME_stand258 471 #define FRAME_stand259 472 #define FRAME_stand260 473 #define FRAME_walk201 474 #define FRAME_walk202 475 #define FRAME_walk203 476 #define FRAME_walk204 477 #define FRAME_walk205 478 #define FRAME_walk206 479 #define FRAME_walk207 480 #define FRAME_walk208 481 #define FRAME_walk209 482 #define FRAME_walk210 483 #define FRAME_walk211 484 #define FRAME_walk212 485 #define FRAME_walk213 486 #define FRAME_walk214 487 #define FRAME_walk215 488 #define FRAME_walk216 489 #define FRAME_walk217 490 #define MODEL_SCALE 1.000000
<?php /** * @file * general functions for mothership */ function mothership_id_safe($string, $vars = "default") { // Replace with dashes anything that isn't A-Z, numbers, dashes, or underscores. if($vars == "remove-numbers"){ $string = strtolower(preg_replace('/[^a-zA-Z_-]+/', '-', $string)); }else{ $string = strtolower(preg_replace('/[^a-zA-Z0-9_-]+/', '-', $string)); } // change the "_" to "-" $string = strtolower(str_replace('_', '-', $string)); // If the first character is not a-z, add 'n' in front. if (function_exists('ctype_lower')) { if (!ctype_lower($string{0})) { // Don't use ctype_alpha since its locale aware. $string = 'id' . $string; } } else { preg_match('/[a-z]+/', $string{0}, $matches); if (count($matches) == 0) { $string = 'id' . $string; } } return $string; } /* getting some of the userprofile data into a single function */ function <API key>($user){ if ($user->uid) { // global $user; // $profile = <API key>($user); //$user->profile_name //user picture if ($user->picture) { $userimage = '<img src="/' . $user->picture . '">'; print '<div class="profile-image">' . l($userimage, 'user/' . $user->uid, $options = array('html' => TRUE)) . '</div>'; } print '<ul class="profile">'; print '<li class="profile-name">' . l($user->name, 'user/' . $user->uid . '') . '</li>'; print '<li class="profile-edit">' . l(t('edit'), 'user/' . $user->uid . '/edit') . '</li>'; print '<li class="profile-logout">' . l(t('Sign out'), 'logout') . '</li>'; print '</ul>'; } } /* Quick & handy function for adding time ago */ function mothership_time_ago($timestamp,$granularity = 2, $langcode = NULL){ $difference = time() - $timestamp; $text = format_interval($difference, $granularity, $langcode) ." ". t("ago"); return $text; } /* return only the terms from a vocabulary in the node */ function <API key>($node, $vid){ $terms = <API key>($node, $vid, $key = 'tid'); // $vocabulary = <API key>($vid); // $content .='<div class="vocabulary">'.$vocabulary->name.'</div>'; $termslist = ''; if ($terms) { $content .= '<span class="terms">'; foreach ($terms as $term) { $termslist = $termslist . '<span class="term-icon-'. mothership_id_safe($term->name) .'">' . l($term->name, 'taxonomy/term/'.$term->tid) .'</span> | '; } //TODO make a better split option hardcoded is kinda sad ;) $content.= trim ($termslist," |").'</span>'; } return $content; }
#include <linux/delay.h> #include <linux/init.h> #include <linux/module.h> #include <linux/i2c.h> #include <linux/input.h> #include <linux/slab.h> #include <linux/gpio.h> #include <mach/gpio.h> #include <linux/irq.h> #include <linux/interrupt.h> #include <linux/timer.h> #include <linux/workqueue.h> #include <linux/byteorder/generic.h> #include <linux/bitops.h> #ifdef <API key> #include <linux/earlysuspend.h> #endif /* <API key> */ #include <linux/regulator/consumer.h> #include <mach/vreg.h> #include <linux/wakelock.h> #include <linux/input/mt.h> #define <API key> #include <linux/miscdevice.h> #include <linux/cyttsp.h> #ifdef <API key> #include <linux/issp_defs.h> #include <linux/issp_extern.h> #endif #include <linux/uaccess.h> uint32_t cyttsp_tsdebug1; module_param_named(tsdebug1, cyttsp_tsdebug1, uint, 0664); #if defined(CONFIG_EF33_BOARD) || defined(CONFIG_EF34_BOARD) #define FEATURE_TOUCH_KEY #endif /* EF33S gpio & resolution & key area*/ #define GPIO_TOUCH_RST 95 #define GPIO_TOUCH_CHG 61 #define GPIO_TOUCH_SDA 64 #define GPIO_TOUCH_SCL 65 #define GPIO_TOUCH_ID 93 #define IRQ_TOUCH_INT gpio_to_irq(GPIO_TOUCH_CHG) /* debug option */ //#define TOUCH_DBG_ENABLE #ifdef TOUCH_DBG_ENABLE #define dbg(fmt, args...) printk("[TOUCH]" fmt, ##args) #else #define dbg(fmt, args...) #endif #define dbg_func_in() dbg("[FUNC_IN] %s\n", __func__) #define dbg_func_out() dbg("[FUNC_OUT] %s\n", __func__) #define dbg_line() dbg("[LINE] %d(%s)\n", __LINE__, __func__) #define <API key> #ifdef FEATURE_TOUCH_KEY #define X_MAX 480 #define Y_MAX 800 #define NULL_KEY_AREA 840 #define MENU_KEY_MIN 40 #define MENU_KEY_MAX 140 #define HOME_KEY_MIN 210 #define HOME_KEY_MAX 280 #define BACK_KEY_MIN 360 #define BACK_KEY_MAX 460 #endif #ifdef <API key> #define <API key> 3 #endif #define TOUCH_MAX_NUM 4 #define SENSOR_X 12 #define SENSOR_Y 20 #define MAX_NODE SENSOR_X*SENSOR_Y #define CYTTSP_BASE_MIN 65 #define CYTTSP_BASE_MAX 135 #define CYTTSP_MUTEX_LOCK //ST_LIM /* abs settings */ /* abs value offsets */ #define CY_NUM_ABS_VAL 5 /* number of abs values per setting */ #define CY_SIGNAL_OST 0 #define CY_MIN_OST 1 #define CY_MAX_OST 2 #define CY_FUZZ_OST 3 #define CY_FLAT_OST 4 /* axis signal offsets */ #define CY_NUM_ABS_SET 5 /* number of abs signal sets */ #define CY_ABS_X_OST 0 #define CY_ABS_Y_OST 1 #define CY_ABS_P_OST 2 #define CY_ABS_W_OST 3 #define CY_ABS_ID_OST 4 #define CY_IGNORE_VALUE 0xFFFF /* mark unused signals as ignore */ #define HI_TRACKID(reg) ((reg & 0xF0) >> 4) #define LO_TRACKID(reg) ((reg & 0x0F) >> 0) /* Touch structure */ struct cyttsp_trk{ bool tch; int abs[CY_NUM_ABS_SET]; } ; int prev_touches=0; static struct <API key> g_xy_data; //static struct <API key> g_bl_data; //static struct <API key> g_sysinfo_data; //static struct <API key> g_wake_data; static const struct i2c_device_id cyttsp_id[] = { { CYTTSP_I2C_NAME, 0 }, { } }; /* CY TTSP I2C Driver private data */ struct cyttsp { struct i2c_client *client; struct input_dev *input; struct work_struct work; #ifdef <API key> struct work_struct work2; #endif #ifdef <API key> //struct work_struct work3; // N1037 20120312 for ICS struct delayed_work work3; #endif struct timer_list timer; struct mutex mutex; #ifdef CYTTSP_MUTEX_LOCK struct mutex lock_mutex; #endif char phys[32]; struct <API key> *platform_data; u8 num_prev_touch; u16 active_track[CYTTSP_NUM_TRACK_ID]; u16 prev_st_touch[<API key>]; u16 prev_mt_touch[<API key>]; u16 prev_mt_pos[<API key>][2]; struct cyttsp_trk prv_trk[CYTTSP_NUM_TRACK_ID]; atomic_t irq_enabled; struct early_suspend early_suspend; }; #ifdef <API key> static int <API key> = false; #endif #ifdef <API key> struct cyttsp *cyttsp_data = NULL; #endif /* To check touch chip */ static int Touch_Dbg_Enable =0; //static u16 prev_mt_pos[CYTTSP_NUM_TRACK_ID][2]; static struct wake_lock touch_wake_lock; typedef enum touch_status { TOUCH_POWERON, TOUCH_POWEROFF, TOUCH_UPDATE } touch_status; typedef enum { <API key> = 0, BATTERY_PLUGGED_AC = 1, BATTERY_PLUGGED_USB = 2, <API key> = 10 } CHARGER_MODE; typedef enum touch_ioctl { TOUCH_CHARGER_MODE = 701, <API key> = 1001, TOUCH_IOCTL_DO_KEY, <API key>, <API key> = 1007, <API key>, <API key> = 2005, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key> } touch_ioctl; static int Touch_Status =TOUCH_POWERON; static int Touch_ChagerMode = <API key>; static unsigned char bBlack=false; struct cyttsp *ts_temp; #if defined(CONFIG_APACHE_BOARD) struct delayed_work work_delay_firmware; #endif MODULE_DEVICE_TABLE(i2c, cyttsp_id); static void cyttsp_xy_worker(struct work_struct *work); #ifdef <API key> static void <API key>(struct work_struct *work2); #endif #ifdef <API key> void <API key>(struct work_struct *work3); #endif static irqreturn_t cyttsp_irq(int irq, void *handle); #if 0 static int cyttsp_inlist(u16 prev_track[], u8 curr_track_id, u8 *prev_loc, u8 num_touches); static int <API key>(u16 curr_track[], u8 *new_loc, u8 num_touches); #endif #ifdef <API key> //[BIH] ICS port... static int cyttsp_putbl(struct cyttsp *ts, int show, int show_status, int show_version, int show_cid); #endif// <API key> //[BIH] ICS port... static int __devinit cyttsp_probe(struct i2c_client *client, const struct i2c_device_id *id); static int __devexit cyttsp_remove(struct i2c_client *client); static int cyttsp_resume(struct i2c_client *client); static int cyttsp_suspend(struct i2c_client *client, pm_message_t message); #ifdef <API key> static long ts_fops_ioctl(struct file *filp,unsigned int cmd, unsigned long arg); static int ts_fops_open(struct inode *inode, struct file *filp); #endif #ifdef <API key> static void <API key>(struct early_suspend *handler); static void cyttsp_late_resume(struct early_suspend *handler); #endif /* <API key> */ static int pantech_auto_check(u8*); #ifdef <API key> static int <API key>(void); static int <API key>(void); #endif static int <API key>(void); void <API key>(u8 value); //test static struct i2c_driver cyttsp_driver = { .driver = { .name = CYTTSP_I2C_NAME, .owner = THIS_MODULE, }, .probe = cyttsp_probe, .remove = __devexit_p(cyttsp_remove), // .suspend = cyttsp_suspend, // .resume = cyttsp_resume, .id_table = cyttsp_id, }; MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Cypress TrueTouch(R) Standard touchscreen driver"); MODULE_AUTHOR("Cypress"); #ifdef <API key> struct cyttsp *sky_process_cmd_ts=NULL; static struct file_operations ts_fops = { .owner = THIS_MODULE, .open = ts_fops_open, // .release = ts_fops_close, .unlocked_ioctl = ts_fops_ioctl, }; static struct miscdevice touch_event = { .minor = MISC_DYNAMIC_MINOR, .name = "touch_fops", .fops = &ts_fops, }; static int ts_fops_open(struct inode *inode, struct file *filp) { //filp->private_data = cyttsp_data; return 0; } #if 1 //[BIH] ICS port... ioctl changed to unlocked_ioctl or compact_ioctl... //static DEFINE_MUTEX(cyttsp_mutex); static long ts_fops_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) #else static int ts_fops_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) #endif { void __user *argp = (void __user *)arg; if(cyttsp_data ==NULL) { cyttsp_debug("Null Device\n"); return 0; } cyttsp_debug("cmd = %d, argp = 0x%x\n", cmd, (unsigned int)argp); // printk("cmd = %d, argp = 0x%x\n", cmd, (unsigned int)argp); // mutex_lock(&cyttsp_mutex); switch (cmd) { case <API key>: break; case TOUCH_IOCTL_DO_KEY: if ( (int)argp == 0x20a ) input_report_key(cyttsp_data->input, 0xe3, 1); else if ( (int)argp == 0x20b ) input_report_key(cyttsp_data->input, 0xe4, 1); else input_report_key(cyttsp_data->input, (int)argp, 1); input_sync(cyttsp_data->input); if((int)argp == KEY_9) { printk("Enable Touch Debug!!\n"); Touch_Dbg_Enable = true; } else if((int)argp == KEY_8) { printk("Disable Touch Debug!!\n"); Touch_Dbg_Enable = false; } /* else if((int)argp == KEY_F2) { int ret = 0; printk("Start Touch Firmware update!!\n"); ret = <API key>(); } */ break; case <API key>: if ( (int)argp == 0x20a ) input_report_key(cyttsp_data->input, 0xe3, 0); else if ( (int)argp == 0x20b ) input_report_key(cyttsp_data->input, 0xe4, 0); else input_report_key(cyttsp_data->input, (int)argp, 0); input_sync(cyttsp_data->input); break; // +++ <API key> case <API key>: { int touchX=arg&0x0000FFFF; int touchY= (arg >> 16) & 0x0000FFFF; input_report_abs(cyttsp_data->input, ABS_MT_TOOL_TYPE , 1); input_report_abs(cyttsp_data->input, ABS_MT_TOUCH_MAJOR, CYTTSP_TOUCH); input_report_abs(cyttsp_data->input, ABS_MT_WIDTH_MAJOR, <API key>); input_report_abs(cyttsp_data->input, ABS_MT_POSITION_X, touchX); input_report_abs(cyttsp_data->input, ABS_MT_POSITION_Y, touchY); CYTTSP_MT_SYNC(cyttsp_data->input); input_sync(cyttsp_data->input); } break; case <API key>: { int touchX=arg&0x0000FFFF; int touchY= (arg >> 16) & 0x0000FFFF; input_report_abs(cyttsp_data->input, ABS_MT_TOOL_TYPE , 1); input_report_abs(cyttsp_data->input, ABS_MT_TOUCH_MAJOR, CYTTSP_NOTOUCH); input_report_abs(cyttsp_data->input, ABS_MT_WIDTH_MAJOR, <API key>); input_report_abs(cyttsp_data->input, ABS_MT_POSITION_X, touchX); input_report_abs(cyttsp_data->input, ABS_MT_POSITION_Y, touchY); CYTTSP_MT_SYNC(cyttsp_data->input); input_sync(cyttsp_data->input); } break; case <API key>: { int send_data; send_data = SENSOR_X; if (copy_to_user(argp, &send_data, sizeof(send_data))) return false; } break; case <API key>: { int send_data; send_data = SENSOR_Y; if (copy_to_user(argp, &send_data, sizeof(send_data))) return false; } break; case <API key>: { u8 send_byte[MAX_NODE]; //printk("<API key>!!\n"); disable_irq_nosync(ts_temp->client->irq); pantech_auto_check(send_byte); enable_irq(ts_temp->client->irq); if (copy_to_user(argp, send_byte, MAX_NODE)) return false; } break; #ifdef <API key> case <API key>: { int ret = 0; ret = <API key>(); if (copy_to_user(argp, &ret, sizeof(ret))) return false; } break; case <API key>: { int ret =0; if(bBlack == false) // White Model etc.. ret = <API key>; else // Black Model ret = <API key>; if (copy_to_user(argp, &ret, sizeof(ret))) return false; } break; case <API key>: { int ret = 0; ret = <API key>(); // if ret == 0 success, or not fail printk("<API key> ret : %d\n", ret); if (copy_to_user(argp, &ret, sizeof(ret))) return false; } break; #endif case TOUCH_CHARGER_MODE: printk("TOUCH_CHARGER_MODE Setting : %d\n", (int)arg); Touch_ChagerMode = arg; break; case <API key>: { int ret = 0; ret = <API key>(); if (copy_to_user(argp, &ret, sizeof(ret))) return false; } break; case <API key>: bBlack = arg; break; default: break; } // mutex_unlock(&cyttsp_mutex); return true; } #endif void <API key>(u8 value) { int rc = -1; u8 byte_data; struct cyttsp *ts = ts_temp; #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif rc = <API key>(ts->client, CYTTSP_REG_GEST_SET,sizeof(byte_data), &byte_data); //printk("<API key> : %02x\n", byte_data); byte_data = value; rc = <API key>(ts->client, CYTTSP_REG_GEST_SET, sizeof(byte_data), &byte_data); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif return; } static ssize_t cyttsp_irq_status(struct device *dev, struct device_attribute *attr, char *buf) { struct i2c_client *client = container_of(dev, struct i2c_client, dev); struct cyttsp *ts = i2c_get_clientdata(client); return sprintf(buf, "%u\n", atomic_read(&ts->irq_enabled)); } static ssize_t cyttsp_irq_enable(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct i2c_client *client = container_of(dev, struct i2c_client, dev); struct cyttsp *ts = i2c_get_clientdata(client); int err = 0; unsigned long value; /* struct qtm_obj_message *msg; */ if (size > 2) return -EINVAL; err = strict_strtoul(buf, 10, &value); if (err != 0) return err; switch (value) { case 0: if (atomic_cmpxchg(&ts->irq_enabled, 1, 0)) { pr_info("touch irq disabled!\n"); disable_irq_nosync(ts->client->irq); } err = size; break; case 1: if (!atomic_cmpxchg(&ts->irq_enabled, 0, 1)) { pr_info("touch irq enabled!\n"); /* msg = cyttsp_read_msg(ts); if (msg == NULL) pr_err("%s: Cannot read message\n", __func__); */ enable_irq(ts->client->irq); } err = size; break; default: pr_info("cyttsp_irq_enable failed -> irq_enabled = %d\n", atomic_read(&ts->irq_enabled)); err = -EINVAL; break; } return err; } static DEVICE_ATTR(irq_enable, 0664, cyttsp_irq_status, cyttsp_irq_enable); int pantech_ctl_update(int cmd, int value) { int rt = -1; struct regulator *vreg_touch, *vreg_touch_temp; switch(cmd) { case <API key>: if(value){ gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SCL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE); } else{ gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SCL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_DISABLE); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SCL, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE); } rt = 1; break; case <API key>: if(value){ gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SDA, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE); } else{ gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SDA, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_DISABLE); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SDA, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE); } rt = 1; break; case ISSP_IOCTL_SCLK: gpio_set_value(GPIO_TOUCH_SCL, value); rt = 1; break; case ISSP_IOCTL_DATA: gpio_set_value(GPIO_TOUCH_SDA, value); rt = 1; break; case ISSP_IOCTL_RESET: break; case ISSP_IOCTL_POWER: //printk("Touch Power: %d, cmd: %d\n", value, cmd); #if EF33S_BDVER_GE(WS20) || EF34K_BDVER_GE(WS20) vreg_touch = regulator_get(NULL, "8058_l11"); <API key>(vreg_touch, 1900000, 1900000); #else vreg_touch = regulator_get(NULL, "8058_lvs0"); #endif if(value) rt = regulator_enable(vreg_touch); else rt = regulator_disable(vreg_touch); regulator_put(vreg_touch); break; case <API key>: //printk("Touch Power All: %d, cmd: %d\n", value, cmd); vreg_touch_temp = regulator_get(NULL, "8058_l19"); #if EF33S_BDVER_GE(WS20) || EF34K_BDVER_GE(WS20) vreg_touch = regulator_get(NULL, "8058_l11"); <API key>(vreg_touch, 1900000, 1900000); #else vreg_touch = regulator_get(NULL, "8058_lvs0"); #endif <API key>(vreg_touch_temp, 3000000, 3000000); if(value) { rt = regulator_enable(vreg_touch); rt = regulator_enable(vreg_touch_temp); } else { rt = regulator_disable(vreg_touch); rt = regulator_disable(vreg_touch_temp); } regulator_put(vreg_touch); regulator_put(vreg_touch_temp); break; case <API key>: rt = gpio_get_value(GPIO_TOUCH_SDA); break; case ISSP_IOCTL_WAIT: udelay(value); break; case ISSP_IOCTL_INTR: gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_CHG, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE); gpio_set_value(GPIO_TOUCH_CHG, value); rt = 1; break; case ISSP_TEST_READ_SCL: rt = gpio_get_value(GPIO_TOUCH_SCL); break; case ISSP_TEST_READ_SDA: rt = gpio_get_value(GPIO_TOUCH_SDA); break; case <API key>: rt = gpio_get_value(GPIO_TOUCH_RST); break; case <API key>: gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_CHG, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SCL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_DISABLE); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SDA, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_DISABLE); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SDA, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SCL, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),GPIO_CFG_ENABLE); rt = 1; break; default: dbg("UNKNOWN CMD\n"); break; } return rt; } #ifdef <API key> void <API key>(struct work_struct *work3) { int retry_cnt = 3; u8 byte_data[4]; int rc = -1, check_update_pass = 0, curr_version =0; struct cyttsp *ts = ts_temp; // If phone enter a poweroff, Stop firmware update if(Touch_Status >= TOUCH_POWEROFF) return; #ifdef <API key> <API key> = false; #endif wake_lock(&touch_wake_lock); disable_irq(ts->client->irq); #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif do { rc = <API key>(ts->client, <API key>,sizeof(byte_data), (u8 *)&byte_data); udelay(2*1000); } while ((rc < CYTTSP_OPERATIONAL) && --retry_cnt); dbg("i2c communcation1 %s, byte_data = %d, %d, %d, %d\n", (rc < CYTTSP_OPERATIONAL) ? "FAIL" : "PASS",byte_data[0],byte_data[1],byte_data[2],byte_data[3]); if((int)byte_data[0] == 0 || rc < CYTTSP_OPERATIONAL) { dbg("Retry read firmware version!\n"); msleep(200); pantech_ctl_update(ISSP_IOCTL_POWER, 0); msleep(100); pantech_ctl_update(ISSP_IOCTL_POWER, 1); msleep(200); retry_cnt = 3; do { rc = <API key>(ts->client, <API key>,sizeof(byte_data), (u8 *)&byte_data); udelay(2*1000); } while ((rc < CYTTSP_OPERATIONAL) && --retry_cnt); } pantech_ctl_update(ISSP_IOCTL_INTR,0); #ifdef <API key> if(rc >= CYTTSP_OPERATIONAL) // read success bBlack = (int)byte_data[0] % 2; if(bBlack == false) // White Model etc.. curr_version = <API key>; else // Black Model curr_version = <API key>; #else curr_version = <API key>; #endif dbg("[Touch] Model Black Check: %d, Current Version: %d\n", bBlack, curr_version); if(((curr_version > byte_data[0]) && (byte_data[0] != 0)) || (rc < CYTTSP_OPERATIONAL)) { retry_cnt = 5; dbg("Start Firmware Update chip id: %d\n", byte_data[0]); do{ check_update_pass = touch_update_main(bBlack); udelay(2*1000); }while((check_update_pass != 0) && --retry_cnt); } #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif pantech_ctl_update(ISSP_IOCTL_INTR,1); pantech_ctl_update(<API key>,0); if(check_update_pass != 0) { msleep(200); pantech_ctl_update(ISSP_IOCTL_POWER, 0); msleep(100); pantech_ctl_update(ISSP_IOCTL_POWER, 1); msleep(100); cancel_work_sync(&ts->work); } dbg("<API key> end!!(check_update_pass = %d)\n",check_update_pass); enable_irq(ts->client->irq); #ifdef <API key> <API key> = true; #endif wake_unlock(&touch_wake_lock); return; } static int <API key>(void) { int rc = -1, retry_cnt = 3; u8 byte_data[4]; struct cyttsp *ts = ts_temp; if(Touch_Status >= TOUCH_POWEROFF) { pantech_ctl_update(<API key> , 1); pantech_ctl_update(ISSP_IOCTL_INTR, 1); pantech_ctl_update(<API key>, 0); msleep(300); // return false; } #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif do { rc = <API key>(ts->client, <API key>,sizeof(byte_data), (u8 *)&byte_data); udelay(2*1000); } while ((rc < CYTTSP_OPERATIONAL) && --retry_cnt); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif if(rc < CYTTSP_OPERATIONAL) { printk("Can't read Touch Firmware Version\n"); return 1; } printk("Touch Firmware Update Version : %d, Current Version: %d\n" , <API key>,(int)byte_data[0]); if(Touch_Status >= TOUCH_POWEROFF) { pantech_ctl_update(<API key> , 0); } return (int)byte_data[0]; // Need not } static int <API key>(int mode) { int rc = -1, retry_cnt = 3; u8 byte_data[4], send_byte = 0x00; struct cyttsp *ts = ts_temp; #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif do { rc = <API key>(ts->client, <API key>,sizeof(byte_data), (u8 *)&byte_data); udelay(2*1000); } while ((rc < CYTTSP_OPERATIONAL) && --retry_cnt); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif if(rc < CYTTSP_OPERATIONAL) { printk("Can't read Touch Charger Mode\n"); return 1; } if(Touch_Dbg_Enable) printk("Touch IC Charger Mode %02x\n" ,(int)byte_data[0]); if(mode > <API key>) // charger mode on { if((int)byte_data[0] != CYTTPS_CHARGER_MODE) { send_byte = CYTTPS_CHARGER_MODE; #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif rc = <API key>(ts->client, <API key>, sizeof(send_byte), &send_byte); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif } } else // charger mode off { if((int)byte_data[0] != 0x00) { send_byte = 0x00; #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif rc = <API key>(ts->client, <API key>, sizeof(send_byte), &send_byte); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif } } return 0; } static int <API key>(void) { struct cyttsp *ts = ts_temp; int check_update_pass = -1; // If phone enter a poweroff, Stop firmware update if(Touch_Status >= TOUCH_POWEROFF) { pantech_ctl_update(<API key> , 1); msleep(300); // return false; } #ifdef <API key> <API key> = false; #endif Touch_Status= TOUCH_UPDATE; wake_lock(&touch_wake_lock); disable_irq(ts->client->irq); pantech_ctl_update(ISSP_IOCTL_INTR,0); #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif check_update_pass = touch_update_main(bBlack); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif pantech_ctl_update(ISSP_IOCTL_INTR,1); pantech_ctl_update(<API key>,0); msleep(100); pantech_ctl_update(ISSP_IOCTL_POWER, 0); msleep(100); pantech_ctl_update(ISSP_IOCTL_POWER, 1); msleep(100); cancel_work_sync(&ts->work); enable_irq(ts->client->irq); #ifdef <API key> <API key> = true; #endif wake_unlock(&touch_wake_lock); Touch_Status= TOUCH_POWERON; return check_update_pass; } #endif /* The cyttsp_xy_worker function reads the XY coordinates and sends them to * the input layer. It is scheduled from the interrupt (or timer). */ #ifdef FEATURE_TOUCH_KEY #define CYTTSP_MENU_KEY 0x01 #define CYTTSP_BACK_KEY 0x02 #define CYTTSP_HOME_KEY 0x04 #define CYTTSP_NULL_KEY 0x08 static int key_status = 0x00; #endif #if 0//def <API key> static u16 pre_x_data; static u16 pre_y_data; static u16 delta_x; static u16 delta_y; #endif #ifdef <API key> void <API key>(struct work_struct *work2) { struct cyttsp *ts = container_of(work2,struct cyttsp,work2); int retry_cnt = 3; u8 new_heartbeart_data[4]; int rc = -1; static u8 old_heartbeat_data = 0xFF; memset((void*)new_heartbeart_data,0x00,sizeof(new_heartbeart_data)); if(<API key> == false) return; #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif do { /* Read Heartbeat Count */ rc = <API key>(ts->client, <API key>,sizeof(new_heartbeart_data), (u8 *)&new_heartbeart_data); } while ((rc < CYTTSP_OPERATIONAL) && --retry_cnt); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif if(Touch_Dbg_Enable) printk(" if(<API key> == false) return; if(rc < CYTTSP_OPERATIONAL || old_heartbeat_data == new_heartbeart_data[0]) { /* I2c error or Touch Chip's heartbeat value is not change */ disable_irq(ts->client->irq); pantech_ctl_update(ISSP_IOCTL_INTR,0); pantech_ctl_update(ISSP_IOCTL_POWER,0); msleep(200); pantech_ctl_update(ISSP_IOCTL_INTR,1); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_CHG, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),GPIO_CFG_ENABLE); enable_irq(ts->client->irq); pantech_ctl_update(ISSP_IOCTL_POWER,1); if(Touch_Dbg_Enable) printk("HeartBeat Fail old_data = %d, new_data = %d",old_heartbeat_data, new_heartbeart_data[0]); } if(!<API key>) old_heartbeat_data = 0xFF; // Set Charger Mode <API key>(Touch_ChagerMode); return; } #endif static bool cur_touchflag[TOUCH_MAX_NUM]; int touch_mask[TOUCH_MAX_NUM]; struct cyttsp_trk cur_trk[TOUCH_MAX_NUM]; void cyttsp_xy_worker(struct work_struct *work) { struct cyttsp *ts = container_of(work,struct cyttsp,work); int i; int retval = 0; u8 curr_touches = 0; u8 id = 0; // int t = 0; // int num_sent = 0; // int signal = 0; int tch = 0; #ifdef FEATURE_TOUCH_KEY int key_relese = true; #endif for (i=0;i<TOUCH_MAX_NUM;i++) { touch_mask[i] = -1; } if(Touch_Dbg_Enable) printk("[TOUCH] Start cyttsp_xy_worker\n"); if(Touch_Status >= TOUCH_POWEROFF) goto exit_xy_worker; /* get event data from CYTTSP device */ i = CYTTSP_NUM_RETRY; #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif do { retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(struct <API key>), (u8 *)&g_xy_data); } while ((retval < CYTTSP_OPERATIONAL) && --i); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif /* return immediately on failure to read device on the i2c bus */ if (retval < CYTTSP_OPERATIONAL) { cyttsp_debug("exit_xy_worker 1"); goto exit_xy_worker; } cyttsp_xdebug("TTSP worker start 2:\n"); if ((curr_touches = GET_NUM_TOUCHES(g_xy_data.tt_stat)) > <API key>) { /* if the number of fingers on the touch surface is more than the maximum * then there will be no new track information even for the orginal * touches. Therefore, ignore this touch event. */ cyttsp_debug("exit_xy_worker 2"); goto exit_xy_worker; } else if (IS_LARGE_AREA(g_xy_data.tt_stat)==1) { /* terminate all active tracks */ curr_touches = CYTTSP_NOTOUCH; cyttsp_debug("Large object detected. Terminating active tracks\n"); } #ifdef FEATURE_TOUCH_KEY for(i=0; i<curr_touches; i++) { int x =0, y=0; switch(i) { case 0: x = be16_to_cpu(g_xy_data.x1); y = be16_to_cpu(g_xy_data.y1); break; case 1: x = be16_to_cpu(g_xy_data.x2); y = be16_to_cpu(g_xy_data.y2); break; case 2: x = be16_to_cpu(g_xy_data.x3); y = be16_to_cpu(g_xy_data.y3); break; case 3: x = be16_to_cpu(g_xy_data.x4); y = be16_to_cpu(g_xy_data.y4); break; default: break; } if(y > Y_MAX) { key_relese = false; if(y < NULL_KEY_AREA && (!key_status || key_status == CYTTSP_NULL_KEY)) { key_status = CYTTSP_NULL_KEY; dbg("Down TOUCH NULL\n"); } else if((MENU_KEY_MIN < x && x < MENU_KEY_MAX) && (!key_status || key_status == CYTTSP_MENU_KEY)) { key_status = CYTTSP_MENU_KEY; input_report_key(ts->input, KEY_MENU, CYTTSP_TOUCH); dbg("Down TOUCH MENU\n"); input_sync(ts->input); } else if((HOME_KEY_MIN < x && x < HOME_KEY_MAX) && (!key_status || key_status == CYTTSP_HOME_KEY)) { key_status = CYTTSP_HOME_KEY; input_report_key(ts->input, KEY_HOMEPAGE, CYTTSP_TOUCH); dbg("Down TOUCH HOME\n"); input_sync(ts->input); } else if((BACK_KEY_MIN < x && x < BACK_KEY_MAX) && (!key_status || key_status == CYTTSP_BACK_KEY)) { key_status = CYTTSP_BACK_KEY; input_report_key(ts->input, KEY_BACK, CYTTSP_TOUCH); dbg("Down TOUCH BACK\n"); input_sync(ts->input); } else if(!key_status) key_status = CYTTSP_NULL_KEY; } } if(key_relese && (curr_touches < prev_touches) && key_status) { if(key_status == CYTTSP_MENU_KEY) input_report_key(ts->input, KEY_MENU, CYTTSP_NOTOUCH); if(key_status == CYTTSP_HOME_KEY) input_report_key(ts->input, KEY_HOMEPAGE, CYTTSP_NOTOUCH); if(key_status == CYTTSP_BACK_KEY) input_report_key(ts->input, KEY_BACK, CYTTSP_NOTOUCH); if(key_status != CYTTSP_NULL_KEY) input_sync(ts->input); dbg("Up Key: %02x\n", key_status); key_status = 0; } #endif /* send no events if there were no previous touches and no new touches */ if ((prev_touches == CYTTSP_NOTOUCH) && ((curr_touches == CYTTSP_NOTOUCH) || (curr_touches > <API key>))) { cyttsp_debug("exit_xy_worker 3"); goto exit_xy_worker; } cyttsp_debug("prev=%d curr=%d\n", prev_touches, curr_touches); dbg("cur#: %d, tch : 0x%x\n", curr_touches,tch); dbg("touch12_id : 0x%x, touch34_id : 0x%x\n", g_xy_data.touch12_id,g_xy_data.touch34_id); /* extract xy_data for all currently reported touches */ for (tch = 0; tch < curr_touches; tch++) { if (tch < 2) { id = (tch & 0x01) ? GET_TOUCH2_ID(g_xy_data.touch12_id) : //LO_TRACKID(*(ts->tch_map[tch].id)) : GET_TOUCH1_ID(g_xy_data.touch12_id); //HI_TRACKID(*(ts->tch_map[tch].id)); // touch_mask[id] = tch; if (tch == 0) { if(id < TOUCH_MAX_NUM){ cur_trk[id].tch = CYTTSP_TOUCH; cur_trk[id].abs[CY_ABS_X_OST] = be16_to_cpu(g_xy_data.x1); cur_trk[id].abs[CY_ABS_Y_OST] = be16_to_cpu(g_xy_data.y1); cur_trk[id].abs[CY_ABS_P_OST] = g_xy_data.z1; cur_trk[id].abs[CY_ABS_W_OST] = <API key>; cur_trk[id].abs[CY_ABS_ID_OST] = id; }else{ if(Touch_Dbg_Enable) printk("over Max touch ID id#: %d !!!\n", id); } } if (tch == 1) { if(id < TOUCH_MAX_NUM){ cur_trk[id].tch = CYTTSP_TOUCH; cur_trk[id].abs[CY_ABS_X_OST] = be16_to_cpu(g_xy_data.x2); cur_trk[id].abs[CY_ABS_Y_OST] = be16_to_cpu(g_xy_data.y2); cur_trk[id].abs[CY_ABS_P_OST] = g_xy_data.z2; cur_trk[id].abs[CY_ABS_W_OST] = <API key>; cur_trk[id].abs[CY_ABS_ID_OST] = id; }else{ if(Touch_Dbg_Enable) printk("over Max touch ID id#: %d !!!\n", id); } } } else { id = (tch & 0x01) ? GET_TOUCH4_ID(g_xy_data.touch34_id) : //LO_TRACKID(*(ts->tch_map[tch].id)) : GET_TOUCH3_ID(g_xy_data.touch34_id); //HI_TRACKID(*(ts->tch_map[tch].id)); if (tch == 2) { if(id < TOUCH_MAX_NUM){ cur_trk[id].tch = CYTTSP_TOUCH; cur_trk[id].abs[CY_ABS_X_OST] = be16_to_cpu(g_xy_data.x3); cur_trk[id].abs[CY_ABS_Y_OST] = be16_to_cpu(g_xy_data.y3); cur_trk[id].abs[CY_ABS_P_OST] = g_xy_data.z3; cur_trk[id].abs[CY_ABS_W_OST] = <API key>; cur_trk[id].abs[CY_ABS_ID_OST] = id; }else{ if(Touch_Dbg_Enable) printk("over Max touch ID id#: %d !!!\n", id); } } if (tch == 3) { if(id < TOUCH_MAX_NUM){ cur_trk[id].tch = CYTTSP_TOUCH; cur_trk[id].abs[CY_ABS_X_OST] = be16_to_cpu(g_xy_data.x4); cur_trk[id].abs[CY_ABS_Y_OST] = be16_to_cpu(g_xy_data.y4); cur_trk[id].abs[CY_ABS_P_OST] = g_xy_data.z4; cur_trk[id].abs[CY_ABS_W_OST] = <API key>; cur_trk[id].abs[CY_ABS_ID_OST] = id; }else{ if(Touch_Dbg_Enable) printk("over Max touch ID id#: %d !!!\n", id); } } } if(id < TOUCH_MAX_NUM){ touch_mask[id] = tch; }else{ if(Touch_Dbg_Enable) printk("over Max touch ID id#: %d !!!\n", id); } dbg("tch#: %d, ID: %d, Xpos: %d, Ypos: %d\n", tch, id, cur_trk[id].abs[CY_ABS_X_OST], cur_trk[id].abs[CY_ABS_Y_OST]); } // Release Event if ( curr_touches == 0 ) { dbg("Touch Released\n"); for (i=0; i < TOUCH_MAX_NUM; i++) { if (cur_touchflag[i] /*cur_trk[i].abs[CY_ABS_ID_OST] >= 0*/) { cur_trk[i].abs[CY_ABS_ID_OST] = -1; cur_touchflag[i] = 0; input_mt_slot(ts->input, i); input_report_abs(ts->input, ABS_MT_TRACKING_ID, cur_trk[i].abs[CY_ABS_ID_OST]); dbg("Touch Released 1, I : %d\n",i); } } } // Finger Touched else { dbg("Touch Pressed\n"); for (i=0; i<TOUCH_MAX_NUM; i++) { if ( touch_mask[i] < 0 ) // 1 case - the 1st finger : touched / the 2nd finger : released { #if 1 if ( cur_trk[i].abs[CY_ABS_ID_OST] >= 0 ) { cur_touchflag[cur_trk[i].abs[CY_ABS_ID_OST]] = 0; cur_trk[i].abs[CY_ABS_ID_OST] = -1; input_mt_slot(ts->input, i); input_report_abs(ts->input, ABS_MT_TRACKING_ID, cur_trk[i].abs[CY_ABS_ID_OST]); dbg("Touch Pressed 1\n"); } #endif } else { if(touch_mask[i] >= 0) // if finger is touched { input_mt_slot(ts->input, i); if ( (cur_touchflag[cur_trk[i].abs[CY_ABS_ID_OST]] == 0) ) { dbg("Touch Pressed 2-1 I:%d, touchflag : %d\n",i,cur_touchflag[i]); cur_touchflag[cur_trk[i].abs[CY_ABS_ID_OST]] = 1; //cur_trk[i].abs[CY_ABS_ID_OST] = input_mt_new_trkid(ts->input); input_report_abs(ts->input, ABS_MT_TRACKING_ID, cur_trk[i].abs[CY_ABS_ID_OST]); } // Move Event // input_report_abs(ts->input, ABS_MT_TRACKING_ID, cur_trk[i].abs[CY_ABS_ID_OST]); input_report_abs(ts->input, ABS_MT_POSITION_X, cur_trk[i].abs[CY_ABS_X_OST]); input_report_abs(ts->input, ABS_MT_POSITION_Y, cur_trk[i].abs[CY_ABS_Y_OST]); input_report_abs(ts->input, ABS_MT_PRESSURE, cur_trk[i].abs[CY_ABS_P_OST]); input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, 1); input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, cur_trk[i].abs[CY_ABS_P_OST]); dbg("Touch Pressed 2-2 I:%d, touchflag : %d\n",i,cur_touchflag[cur_trk[i].abs[CY_ABS_ID_OST]]); } } } } input_report_key(ts->input, BTN_TOUCH, (curr_touches>0)? 1:0 ); input_sync(ts->input); // update previous touch num prev_touches = curr_touches; goto exit_xy_worker; #if 0 /* provide input event signaling for each active touch */ for (id = 0, num_sent = 0; id < CYTTSP_NUM_TRACK_ID; id++) { if (cur_trk[id].tch) { t = cur_trk[id].abs[CY_ABS_ID_OST]; /* send 0 based track id's */ t -= 1; input_report_abs(ts->input, ABS_MT_TRACKING_ID, t); input_report_abs(ts->input, ABS_MT_POSITION_X, cur_trk[id].abs[CY_ABS_X_OST]); input_report_abs(ts->input, ABS_MT_POSITION_Y, cur_trk[id].abs[CY_ABS_Y_OST]); input_report_abs(ts->input, ABS_MT_PRESSURE, cur_trk[id].abs[CY_ABS_P_OST]); input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, cur_trk[id].abs[CY_ABS_W_OST]); num_sent++; input_mt_sync(ts->input); ts->prv_trk[id] = cur_trk[id]; ts->prv_trk[id].abs[CY_ABS_ID_OST] = t; #if 0 cyttsp_dbg(ts, CY_DBG_LVL_1, "%s: ID:%3d X:%3d Y:%3d " "Z:%3d W=%3d T=%3d\n", __func__, id, cur_trk[id].abs[CY_ABS_X_OST], cur_trk[id].abs[CY_ABS_Y_OST], cur_trk[id].abs[CY_ABS_P_OST], cur_trk[id].abs[CY_ABS_W_OST], t); #endif } else if ((ABS_MT_PRESSURE == ABS_MT_TOUCH_MAJOR) && ts->prv_trk[id].tch) { /* * pre-Gingerbread: * need to report last position with * and report that position with * no touch if the touch lifts off */ input_report_abs(ts->input, ABS_MT_TRACKING_ID, ts->prv_trk[id].abs[CY_ABS_ID_OST]); input_report_abs(ts->input, ABS_MT_POSITION_X, ts->prv_trk[id].abs[CY_ABS_X_OST]); input_report_abs(ts->input, ABS_MT_POSITION_Y, ts->prv_trk[id].abs[CY_ABS_Y_OST]); input_report_abs(ts->input, ABS_MT_PRESSURE, CYTTSP_NOTOUCH); input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, CYTTSP_NOTOUCH); num_sent++; input_mt_sync(ts->input); ts->prv_trk[id].tch = CYTTSP_NOTOUCH; #if 0 cyttsp_dbg(ts, CY_DBG_LVL_1, "%s: ID:%3d X:%3d Y:%3d " "Z:%3d W=%3d T=%3d liftoff\n", __func__, ts->prv_trk[id].abs[CY_ABS_ID_OST], ts->prv_trk[id].abs[CY_ABS_X_OST], ts->prv_trk[id].abs[CY_ABS_Y_OST], CYTTSP_NOTOUCH, CYTTSP_NOTOUCH, ts->prv_trk[id].abs[CY_ABS_ID_OST]); #endif } } if (num_sent == 0) { /* in case of 0-touch; all liftoff; Gingerbread+ */ input_mt_sync(ts->input); } input_sync(ts->input); // update previous touch num prev_touches = curr_touches; goto exit_xy_worker; #endif exit_xy_worker: if(ts->client->irq == 0) { /* restart event timer */ mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT); } else { /* re-enable the interrupt after processing */ enable_irq(ts->client->irq); } } return; } #if 0 static int cyttsp_inlist(u16 prev_track[], u8 curr_track_id, u8 *prev_loc, u8 num_touches) { u8 id =0; *prev_loc = CYTTSP_IGNORE_TOUCH; cyttsp_xdebug("IN p[%d]=%d c=%d n=%d loc=%d\n", \ id, prev_track[id], curr_track_id, num_touches, *prev_loc); for (id = 0, *prev_loc = CYTTSP_IGNORE_TOUCH; (id < num_touches); id++) { cyttsp_xdebug("p[%d]=%d c=%d n=%d loc=%d\n", \ id, prev_track[id], curr_track_id, num_touches, *prev_loc); if (prev_track[id] == curr_track_id) { *prev_loc = id; break; } } cyttsp_xdebug("OUT p[%d]=%d c=%d n=%d loc=%d\n", \ id, prev_track[id], curr_track_id, num_touches, *prev_loc); return ((*prev_loc < CYTTSP_NUM_TRACK_ID) ? true : false); } static int <API key>(u16 curr_track[], u8 *new_loc, u8 num_touches) { u8 id; for (id = 0, *new_loc = CYTTSP_IGNORE_TOUCH; (id < num_touches); id++) { if (curr_track[id] > CYTTSP_NUM_TRACK_ID) { *new_loc = id; break; } } return ((*new_loc < CYTTSP_NUM_TRACK_ID) ? true : false); } #endif /* Timer function used as dummy interrupt driver */ static void cyttsp_timer(unsigned long handle) { struct cyttsp *ts = (struct cyttsp *) handle; cyttsp_xdebug("TTSP Device timer event\n"); #ifdef <API key> /* schedule motion signal handling */ if(<API key>) { schedule_work(&ts->work2); mod_timer(&ts->timer, jiffies + <API key> * HZ); } #else /* schedule motion signal handling */ schedule_work(&ts->work); #endif return; } static irqreturn_t cyttsp_irq(int irq, void *handle) { struct cyttsp *ts = (struct cyttsp *) handle; cyttsp_xdebug("%s: Got IRQ\n", CYTTSP_I2C_NAME); if(Touch_Status >= TOUCH_POWEROFF) return IRQ_HANDLED; /* disable further interrupts until this interrupt is processed */ disable_irq_nosync(ts->client->irq); /* schedule motion signal handling */ schedule_work(&ts->work); return IRQ_HANDLED; } #ifdef <API key> //[BIH] ICS port... static int cyttsp_putbl(struct cyttsp *ts, int show, int show_status, int show_version, int show_cid) { int retval = CYTTSP_OPERATIONAL; int num_bytes = (show_status * 3) + (show_version * 6) + (show_cid * 3); if (show_cid) { num_bytes = sizeof(struct <API key>); } else if (show_version) { num_bytes = sizeof(struct <API key>) - 3; } else { num_bytes = sizeof(struct <API key>) - 9; } if (show) { #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif retval = <API key>(ts->client, CYTTSP_REG_BASE, num_bytes, (u8 *)&g_bl_data); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif if (show_status) { cyttsp_debug("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X\n", \ show, \ g_bl_data.bl_file, g_bl_data.bl_status, g_bl_data.bl_error, \ g_bl_data.blver_hi, g_bl_data.blver_lo, \ g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo); } if (show_version) { cyttsp_debug("BL%d: ttspver=0x%02X%02X appid=0x%02X%02X appver=0x%02X%02X\n", \ show, \ g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \ g_bl_data.appid_hi, g_bl_data.appid_lo, \ g_bl_data.appver_hi, g_bl_data.appver_lo); } if (show_cid) { cyttsp_debug("BL%d: cid=0x%02X%02X%02X\n", \ show, \ g_bl_data.cid_0, g_bl_data.cid_1, g_bl_data.cid_2); } mdelay(CYTTSP_DELAY_DFLT); } return retval; } #endif //<API key> //[BIH] ICS port... #ifdef <API key> #define CYTTSP_MAX_I2C_LEN 256 #define CYTTSP_MAX_TRY 10 #define CYTTSP_BL_PAGE_SIZE 16 #define CYTTSP_BL_NUM_PAGES 5 static int <API key>(struct i2c_client *client, u8 command, u8 length, const u8 *values) { int retval = CYTTSP_OPERATIONAL; u8 dataray[CYTTSP_MAX_I2C_LEN]; u8 try; dataray[0] = command; if (length) { memcpy(&dataray[1], values, length); } try = CYTTSP_MAX_TRY; do { retval = i2c_master_send(client, dataray, length+1); mdelay(CYTTSP_DELAY_DFLT*2); } while ((retval != length+1) && try return retval; } static int <API key>(struct cyttsp *ts, u8 command, u8 length, const u8 *values) { int retval = CYTTSP_OPERATIONAL; int block = 1; u8 dataray[CYTTSP_MAX_I2C_LEN]; /* first page already includes the bl page offset */ #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif retval = <API key>(ts->client, CYTTSP_REG_BASE, CYTTSP_BL_PAGE_SIZE+1, values); mdelay(10); values += CYTTSP_BL_PAGE_SIZE+1; length -= CYTTSP_BL_PAGE_SIZE+1; /* rem blocks require bl page offset stuffing */ while (length && (block < CYTTSP_BL_NUM_PAGES) && !(retval < CYTTSP_OPERATIONAL)) { dataray[0] = CYTTSP_BL_PAGE_SIZE*block; memcpy(&dataray[1], values, length >= CYTTSP_BL_PAGE_SIZE ? CYTTSP_BL_PAGE_SIZE : length); retval = <API key>(ts->client, CYTTSP_REG_BASE, length >= CYTTSP_BL_PAGE_SIZE ? CYTTSP_BL_PAGE_SIZE+1 : length+1, dataray); mdelay(10); values += CYTTSP_BL_PAGE_SIZE; length = length >= CYTTSP_BL_PAGE_SIZE ? length - CYTTSP_BL_PAGE_SIZE : 0; block++; } #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif return retval; } static int cyttsp_bootload_app(struct cyttsp *ts) { int retval = CYTTSP_OPERATIONAL; int i, tries; u8 host_reg; cyttsp_debug("load new firmware \n"); #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif /* reset TTSP Device back to bootloader mode */ host_reg = <API key>; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); /* wait for TTSP Device to complete reset back to bootloader */ // mdelay(CYTTSP_DELAY_DFLT); mdelay(1000); cyttsp_putbl(ts,3, true, true, true); cyttsp_debug("load file -- tts_ver=0x%02X%02X app_id=0x%02X%02X app_ver=0x%02X%02X\n", \ cyttsp_fw_tts_verh, cyttsp_fw_tts_verl, \ cyttsp_fw_app_idh, cyttsp_fw_app_idl, \ cyttsp_fw_app_verh, cyttsp_fw_app_verl); /* download new TTSP Application to the Bootloader * */ if (!(retval < CYTTSP_OPERATIONAL)) { i = 0; /* send bootload initiation command */ if (cyttsp_fw[i].Command == CYTTSP_BL_INIT_LOAD) { g_bl_data.bl_file = 0; g_bl_data.bl_status = 0; g_bl_data.bl_error = 0; retval = <API key>(ts->client, CYTTSP_REG_BASE, cyttsp_fw[i].Length, cyttsp_fw[i].Block); /* delay to allow bootloader to get ready for block writes */ i++; tries = 0; cyttsp_debug("wait init f=%02X, s=%02X, e=%02X t=%d\n",g_bl_data.bl_file, g_bl_data.bl_status, g_bl_data.bl_error, tries); do { mdelay(1000); cyttsp_putbl(ts,4, true, false, false); } while (g_bl_data.bl_status != 0x10 && g_bl_data.bl_status != 0x11 && tries++ < 10); /* send bootload firmware load blocks - * kernel limits transfers to I2C_SMBUS_BLOCK_MAX(32) bytes */ if (!(retval < CYTTSP_OPERATIONAL)) { while (cyttsp_fw[i].Command == CYTTSP_BL_WRITE_BLK) { retval = <API key>(ts, CYTTSP_REG_BASE, cyttsp_fw[i].Length, cyttsp_fw[i].Block); // if (cyttsp_fw[i].Address & 0x01) { // mdelay(CYTTSP_DELAY_DNLOAD); // else { // mdelay(CYTTSP_DELAY_DNLOAD); /* bootloader requires delay after odd block addresses */ mdelay(100); cyttsp_debug("BL DNLD Rec=% 3d Len=% 3d Addr=%04X\n", cyttsp_fw[i].Record, cyttsp_fw[i].Length, cyttsp_fw[i].Address); i++; if (retval < CYTTSP_OPERATIONAL) { cyttsp_debug("BL fail Rec=%3d retval=%d\n",cyttsp_fw[i-1].Record, retval); break; } else { /* reset TTSP I2C counter */ retval = <API key>(ts->client, CYTTSP_REG_BASE, 0, NULL); mdelay(10); /* set arg2 to non-0 to activate */ cyttsp_putbl(ts,5, true, false, false); } } if (!(retval < CYTTSP_OPERATIONAL)) { while (i < cyttsp_fw_records) { retval = <API key>(ts->client, CYTTSP_REG_BASE, cyttsp_fw[i].Length, cyttsp_fw[i].Block); i++; tries = 0; cyttsp_debug("wait init f=%02X, s=%02X, e=%02X t=%d\n",g_bl_data.bl_file, g_bl_data.bl_status, g_bl_data.bl_error, tries); do { mdelay(1000); cyttsp_putbl(ts,6, true, false, false); } while (g_bl_data.bl_status != 0x10 && g_bl_data.bl_status != 0x11 && tries++ < 10); cyttsp_putbl(ts,7, true, false, false); if (retval < CYTTSP_OPERATIONAL) { break; } } } } } } /* Do we need to reset TTSP Device back to bootloader mode?? */ host_reg = <API key>; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); /* wait for TTSP Device to complete reset back to bootloader */ mdelay(1000); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif /* set arg2 to non-0 to activate */ retval = cyttsp_putbl(ts, 8, true, true, true); return retval; } #else #if 0 static int cyttsp_bootload_app(struct cyttsp *ts) { cyttsp_debug("no-load new firmware \n"); return CYTTSP_OPERATIONAL; } #endif #endif /* <API key> */ #if 0 static int cyttsp_power_on(struct cyttsp *ts) { int retval = CYTTSP_OPERATIONAL; u8 host_reg; int tries; static u8 bl_cmd[] = { CYTTSP_BL_FILE0, CYTTSP_BL_CMD, CYTTSP_BL_EXIT, CYTTSP_BL_KEY0, CYTTSP_BL_KEY1, CYTTSP_BL_KEY2, CYTTSP_BL_KEY3, CYTTSP_BL_KEY4, CYTTSP_BL_KEY5, CYTTSP_BL_KEY6, CYTTSP_BL_KEY7}; cyttsp_debug("Power up \n"); /* check if the TTSP device has a bootloader installed */ host_reg = <API key>; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); tries = 0; do { mdelay(1000); /* set arg2 to non-0 to activate */ retval = cyttsp_putbl(ts, 1, true, true, true); cyttsp_info("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X R=%d\n", \ 101, \ g_bl_data.bl_file, g_bl_data.bl_status, g_bl_data.bl_error, \ g_bl_data.blver_hi, g_bl_data.blver_lo, \ g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo, retval); cyttsp_info("BL%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", \ 102, \ g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \ g_bl_data.appid_hi, g_bl_data.appid_lo, \ g_bl_data.appver_hi, g_bl_data.appver_lo); cyttsp_info("BL%d: c_id=%02X%02X%02X\n", \ 103, \ g_bl_data.cid_0, g_bl_data.cid_1, g_bl_data.cid_2); } while (!(retval < CYTTSP_OPERATIONAL) && !GET_BOOTLOADERMODE(g_bl_data.bl_status) && !(g_bl_data.bl_file == CYTTSP_OPERATE_MODE + <API key>) && tries++ < 10); /* is bootloader missing? */ if (!(retval < CYTTSP_OPERATIONAL)) { cyttsp_xdebug("Retval=%d Check if bootloader is missing...\n", retval); if (!GET_BOOTLOADERMODE(g_bl_data.bl_status)) { /* skip all bootloader and sys info and go straight to operational mode */ if (!(retval < CYTTSP_OPERATIONAL)) { cyttsp_xdebug("Bootloader is missing (retval = %d)\n", retval); host_reg = CYTTSP_OPERATE_MODE/* + <API key>*/; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); /* wait for TTSP Device to complete switch to Operational mode */ mdelay(1000); goto bypass; } } } /* take TTSP out of bootloader mode; go to TrueTouch operational mode */ if (!(retval < CYTTSP_OPERATIONAL)) { cyttsp_xdebug1("exit bootloader; go operational\n"); retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(bl_cmd), bl_cmd); tries = 0; do { mdelay(1000); cyttsp_putbl(ts,4, true, false, false); cyttsp_info("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X\n", \ 104, \ g_bl_data.bl_file, g_bl_data.bl_status, g_bl_data.bl_error, \ g_bl_data.blver_hi, g_bl_data.blver_lo, \ g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo); } while (GET_BOOTLOADERMODE(g_bl_data.bl_status) && tries++ < 10); } if (!(retval < CYTTSP_OPERATIONAL) && cyttsp_app_load()) { mdelay(1000); if (CYTTSP_DIFF(g_bl_data.ttspver_hi, cyttsp_tts_verh()) || CYTTSP_DIFF(g_bl_data.ttspver_lo, cyttsp_tts_verl()) || CYTTSP_DIFF(g_bl_data.appid_hi, cyttsp_app_idh()) || CYTTSP_DIFF(g_bl_data.appid_lo, cyttsp_app_idl()) || CYTTSP_DIFF(g_bl_data.appver_hi, cyttsp_app_verh()) || CYTTSP_DIFF(g_bl_data.appver_lo, cyttsp_app_verl()) || CYTTSP_DIFF(g_bl_data.cid_0, cyttsp_cid_0()) || CYTTSP_DIFF(g_bl_data.cid_1, cyttsp_cid_1()) || CYTTSP_DIFF(g_bl_data.cid_2, cyttsp_cid_2()) || <API key>()) { cyttsp_debug("blttsp=0x%02X%02X flttsp=0x%02X%02X force=%d\n", \ g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \ cyttsp_tts_verh(), cyttsp_tts_verl(), <API key>()); cyttsp_debug("blappid=0x%02X%02X flappid=0x%02X%02X\n", \ g_bl_data.appid_hi, g_bl_data.appid_lo, \ cyttsp_app_idh(), cyttsp_app_idl()); cyttsp_debug("blappver=0x%02X%02X flappver=0x%02X%02X\n", \ g_bl_data.appver_hi, g_bl_data.appver_lo, \ cyttsp_app_verh(), cyttsp_app_verl()); cyttsp_debug("blcid=0x%02X%02X%02X flcid=0x%02X%02X%02X\n", \ g_bl_data.cid_0, g_bl_data.cid_1, g_bl_data.cid_2, \ cyttsp_cid_0(), cyttsp_cid_1(), cyttsp_cid_2()); /* enter bootloader to load new app into TTSP Device */ retval = cyttsp_bootload_app(ts); /* take TTSP device out of bootloader mode; switch back to TrueTouch operational mode */ if (!(retval < CYTTSP_OPERATIONAL)) { retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(bl_cmd), bl_cmd); /* wait for TTSP Device to complete switch to Operational mode */ mdelay(1000); } } } bypass: /* switch to System Information mode to read versions and set interval registers */ if (!(retval < CYTTSP_OPERATIONAL)) { cyttsp_debug("switch to sysinfo mode \n"); host_reg = CYTTSP_SYSINFO_MODE; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); /* wait for TTSP Device to complete switch to SysInfo mode */ mdelay(1000); if (!(retval < CYTTSP_OPERATIONAL)) { retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(struct <API key>), (u8 *)&g_sysinfo_data); cyttsp_debug("SI2: hst_mode=0x%02X mfg_cmd=0x%02X mfg_stat=0x%02X\n", \ g_sysinfo_data.hst_mode, g_sysinfo_data.mfg_cmd, \ g_sysinfo_data.mfg_stat); cyttsp_debug("SI2: bl_ver=0x%02X%02X\n", \ g_sysinfo_data.bl_verh, g_sysinfo_data.bl_verl); cyttsp_debug("SI2: sysinfo act_int=0x%02X tch_tmout=0x%02X lp_int=0x%02X\n", \ g_sysinfo_data.act_intrvl, g_sysinfo_data.tch_tmout, \ g_sysinfo_data.lp_intrvl); cyttsp_info("SI%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", \ 102, \ g_sysinfo_data.tts_verh, g_sysinfo_data.tts_verl, \ g_sysinfo_data.app_idh, g_sysinfo_data.app_idl, \ g_sysinfo_data.app_verh, g_sysinfo_data.app_verl); cyttsp_info("SI%d: c_id=%02X%02X%02X\n", \ 103, \ g_sysinfo_data.cid[0], g_sysinfo_data.cid[1], g_sysinfo_data.cid[2]); if (!(retval < CYTTSP_OPERATIONAL) && (CYTTSP_DIFF(ts->platform_data->act_intrvl, <API key>) || CYTTSP_DIFF(ts->platform_data->tch_tmout, <API key>) || CYTTSP_DIFF(ts->platform_data->lp_intrvl, <API key>))) { if (!(retval < CYTTSP_OPERATIONAL)) { u8 intrvl_ray[sizeof(ts->platform_data->act_intrvl) + sizeof(ts->platform_data->tch_tmout) + sizeof(ts->platform_data->lp_intrvl)]; u8 i = 0; intrvl_ray[i++] = ts->platform_data->act_intrvl; intrvl_ray[i++] = ts->platform_data->tch_tmout; intrvl_ray[i++] = ts->platform_data->lp_intrvl; cyttsp_debug("SI2: platinfo act_intrvl=0x%02X tch_tmout=0x%02X lp_intrvl=0x%02X\n", \ ts->platform_data->act_intrvl, ts->platform_data->tch_tmout, \ ts->platform_data->lp_intrvl); // set intrvl registers retval = <API key>(ts->client, <API key>, sizeof(intrvl_ray), intrvl_ray); mdelay(<API key>); } } } /* switch back to Operational mode */ cyttsp_debug("switch back to operational mode \n"); if (!(retval < CYTTSP_OPERATIONAL)) { host_reg = CYTTSP_OPERATE_MODE/* + <API key>*/; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); /* wait for TTSP Device to complete switch to Operational mode */ mdelay(1000); } } /* init gesture setup; * this is required even if not using gestures * in order to set the active distance */ if (!(retval < CYTTSP_OPERATIONAL)) { u8 gesture_setup; cyttsp_debug("init gesture setup \n"); gesture_setup = ts->platform_data->gest_set; retval = <API key>(ts->client, CYTTSP_REG_GEST_SET, sizeof(gesture_setup), &gesture_setup); mdelay(CYTTSP_DELAY_DFLT); } if (!(retval < CYTTSP_OPERATIONAL)) { ts->platform_data->power_state = CYTTSP_ACTIVE_STATE; } else { ts->platform_data->power_state = CYTTSP_IDLE_STATE; } cyttsp_debug("Retval=%d Power state is %s\n", retval, (ts->platform_data->power_state == CYTTSP_ACTIVE_STATE) ? "ACTIVE" : "IDLE"); return retval; } #endif /* cyttsp_initialize: Driver Initialization. This function takes * care of the following tasks: * 1. Create and register an input device with input layer * 2. Take CYTTSP device out of bootloader mode; go operational * 3. Start any timers/Work queues. */ static int cyttsp_initialize(struct i2c_client *client, struct cyttsp *ts) { struct input_dev *input_device; int error = 0; int retval = CYTTSP_OPERATIONAL; u8 id; #ifdef <API key> cyttsp_data = ts; #endif /* Create the input device and register it. */ input_device = <API key>(); if (!input_device) { error = -ENOMEM; cyttsp_xdebug1("err input allocate device\n"); goto error_free_device; } if (!client) { error = ~ENODEV; cyttsp_xdebug1("err client is Null\n"); goto error_free_device; } if (!ts) { error = ~ENODEV; cyttsp_xdebug1("err context is Null\n"); goto error_free_device; } ts->input = input_device; input_device->name = CYTTSP_I2C_NAME; input_device->phys = ts->phys; input_device->dev.parent = &client->dev; set_bit(EV_SYN, input_device->evbit); set_bit(EV_KEY, input_device->evbit); set_bit(EV_ABS, input_device->evbit); set_bit(BTN_TOUCH, input_device->keybit); //set_bit(BTN_2, input_device->keybit); // N1037 20120321 fix #ifdef <API key> // +++ <API key> set_bit(KEY_MENU, input_device->keybit); set_bit(KEY_BACK, input_device->keybit); set_bit(KEY_POWER, input_device->keybit); set_bit(KEY_HOMEPAGE, input_device->keybit); set_bit(KEY_SEARCH, input_device->keybit); set_bit(KEY_0, input_device->keybit); set_bit(KEY_1, input_device->keybit); set_bit(KEY_2, input_device->keybit); set_bit(KEY_3, input_device->keybit); set_bit(KEY_4, input_device->keybit); set_bit(KEY_5, input_device->keybit); set_bit(KEY_6, input_device->keybit); set_bit(KEY_7, input_device->keybit); set_bit(KEY_8, input_device->keybit); set_bit(KEY_9, input_device->keybit); set_bit(0xe3, input_device->keybit); set_bit(0xe4, input_device->keybit); set_bit(KEY_LEFTSHIFT, input_device->keybit); set_bit(KEY_RIGHTSHIFT, input_device->keybit); set_bit(KEY_LEFT, input_device->keybit); set_bit(KEY_RIGHT, input_device->keybit); set_bit(KEY_UP, input_device->keybit); set_bit(KEY_DOWN, input_device->keybit); set_bit(KEY_ENTER, input_device->keybit); set_bit(KEY_SEND, input_device->keybit); set_bit(KEY_END, input_device->keybit); set_bit(KEY_VOLUMEUP, input_device->keybit); set_bit(KEY_VOLUMEDOWN, input_device->keybit); set_bit(KEY_CLEAR, input_device->keybit); set_bit(KEY_CAMERA, input_device->keybit); set_bit(KEY_DELETE, input_device->keybit); set_bit(KEY_WWW, input_device->keybit); #endif // <API key> // for ICS version - 0511 KJHW /* clear current touch tracking structures */ memset(cur_trk, 0, sizeof(cur_trk)); for (id = 0; id < TOUCH_MAX_NUM; id++) { cur_trk[id].abs[CY_ABS_ID_OST] = -1; cur_touchflag[id] = 0; } input_mt_init_slots(input_device, TOUCH_MAX_NUM); if (ts->platform_data->use_gestures) { set_bit(BTN_3, input_device->keybit); } <API key>(input_device, ABS_X, 0, ts->platform_data->maxx, 0, 0); <API key>(input_device, ABS_Y, 0, ts->platform_data->maxy, 0, 0); <API key>(input_device, ABS_TOOL_WIDTH, 0, <API key>, 0 ,0); <API key>(input_device, ABS_PRESSURE, 0, CYTTSP_MAXZ, 0, 0); <API key>(input_device, ABS_HAT0X, 0, ts->platform_data->maxx, 0, 0); <API key>(input_device, ABS_HAT0Y, 0, ts->platform_data->maxy, 0, 0); if (ts->platform_data->use_gestures) { <API key>(input_device, ABS_HAT1X, 0, CYTTSP_MAXZ, 0, 0); <API key>(input_device, ABS_HAT1Y, 0, CYTTSP_MAXZ, 0, 0); } if (ts->platform_data->use_mt) { <API key>(input_device, ABS_MT_POSITION_X, 0, ts->platform_data->maxx, 0, 0); <API key>(input_device, ABS_MT_POSITION_Y, 0, ts->platform_data->maxy, 0, 0); <API key>(input_device, ABS_MT_TOUCH_MAJOR, 0, CYTTSP_MAXZ, 0, 0); <API key>(input_device, ABS_MT_WIDTH_MAJOR, 0, <API key>, 0, 0); if (ts->platform_data->use_trk_id) { <API key>(input_device, ABS_MT_TRACKING_ID, 0, CYTTSP_NUM_TRACK_ID, 0, 0); } } // +++ <API key> <API key>(input_device, ABS_MT_TOOL_TYPE, 0, 1, 0, 0); cyttsp_info("%s: Register input device\n", CYTTSP_I2C_NAME); error = <API key>(input_device); if (error) { cyttsp_alert("%s: Failed to register input device\n", CYTTSP_I2C_NAME); retval = error; goto error_free_device; } else cyttsp_info("%s: Register input device success...\n", CYTTSP_I2C_NAME); /* Prepare our worker structure prior to setting up the timer/ISR */ INIT_WORK(&ts->work,cyttsp_xy_worker); #ifdef <API key> INIT_WORK(&ts->work2,<API key>); #endif #ifdef <API key> //INIT_WORK(&ts->work3,<API key>); // N1037 20120312 for ICS INIT_DELAYED_WORK(&ts->work3,<API key>); #endif /* Power on the chip and make sure that I/Os are set as specified * in the platform */ #if 0 retval = cyttsp_power_on(ts); if (retval < 0) { goto error_free_device; } #endif /* Timer or Interrupt setup */ if(ts->client->irq == 0) { cyttsp_info("Setting up timer\n"); setup_timer(&ts->timer, cyttsp_timer, (unsigned long) ts); mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT); } else { #ifdef <API key> <API key> = true; setup_timer(&ts->timer, cyttsp_timer, (unsigned long) ts); mod_timer(&ts->timer, jiffies + <API key> * 20 * HZ); #endif cyttsp_info("Setting up interrupt\n"); /* request_irq() will also call enable_irq() */ error = request_irq (client->irq,cyttsp_irq,<API key>, client->dev.driver->name,ts); if (error) { cyttsp_alert("error: could not request irq\n"); retval = error; goto error_free_irq; } } atomic_set(&ts->irq_enabled, 1); retval = device_create_file(&ts->client->dev, &dev_attr_irq_enable); if (retval < CYTTSP_OPERATIONAL) { cyttsp_alert("File device creation failed: %d\n", retval); retval = -ENODEV; goto error_free_irq; } cyttsp_info("%s: Successful registration\n", CYTTSP_I2C_NAME); goto success; error_free_irq: cyttsp_alert("Error: Failed to register IRQ handler\n"); free_irq(client->irq,ts); error_free_device: if (input_device) { input_free_device(input_device); } success: return retval; } static int pantech_auto_check(u8* return_byte) { u8 host_reg, byte_data[4], prev_data=0xff, byte_node1[MAX_NODE], byte_node2[MAX_NODE], send_byte[MAX_NODE]; int retval = CYTTSP_OPERATIONAL, retry_cnt = 100, i; struct cyttsp *ts = ts_temp; dbg("pantech_auto_check!! start\n"); // If phone enter a poweroff, Stop firmware update if(Touch_Status >= TOUCH_POWEROFF) return -1; #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif // Enter Test Mode host_reg = CYTTSP_TEST_MODE; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); msleep(100); // Read Raw counts or baseline byte_data[0] = 0x00; do { /* Read Count */ retval = <API key>(ts->client, CYTTSP_REG_MODE , sizeof(byte_data), (u8 *)&byte_data); msleep(10); } while (byte_data[0] == prev_data && --retry_cnt); prev_data = byte_data[0]; do { /* Read Count Must set a i2c.h I2C_SMBUS_BLOCK_MAX 32 -> I2C_SMBUS_BLOCK_MAX 256 */ retval = <API key>(ts->client, <API key> , sizeof(byte_node1), (u8 *)&byte_node1); msleep(10); } while (retval < CYTTSP_OPERATIONAL && --retry_cnt); // Read Raw counts or baseline host_reg = CYTTSP_T_TEST_MODE; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); msleep(100); byte_data[0] = 0x00; retry_cnt = 100; do { /* Read Count */ retval = <API key>(ts->client, CYTTSP_REG_MODE , sizeof(byte_data), (u8 *)&byte_data); msleep(10); } while (byte_data[0] == prev_data && --retry_cnt); prev_data = byte_data[0]; do { /* Read Count */ retval = <API key>(ts->client, <API key> , sizeof(byte_node2), (u8 *)&byte_node2); msleep(10); } while (retval < CYTTSP_OPERATIONAL && --retry_cnt); for(i=0; i<MAX_NODE; i++) { if(byte_node1[i] >= CYTTSP_BASE_MIN && byte_node1[i] <= CYTTSP_BASE_MAX && byte_node2[i] >= CYTTSP_BASE_MIN && byte_node2[i] <= CYTTSP_BASE_MAX) send_byte[i] = 0; else send_byte[i] = 1; // printk("Check Valid %d, byte_node1 %d, byte_node2 %d : %d\n", i , byte_node1[i], byte_node2[i], send_byte[i]); } // Retrun Operate Mode host_reg = CYTTSP_OPERATE_MODE; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif msleep(100); dbg("pantech_auto_check!! end\n"); for(i=0;i<MAX_NODE;i++) return_byte[i]=send_byte[i]; return 0; } static int <API key>(void) { u8 host_reg, byte_data[2]; int retval = CYTTSP_OPERATIONAL; struct cyttsp *ts = ts_temp; printk("<API key>!! start\n"); // If phone enter a poweroff, Stop firmware update if(Touch_Status >= TOUCH_POWEROFF) return -1; #ifdef CYTTSP_MUTEX_LOCK mutex_lock(&ts->lock_mutex); #endif // Enter system information Mode host_reg = CYTTSP_SYSINFO_MODE; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); msleep(100); // Start self test host_reg = 0x01; retval = <API key>(ts->client, <API key>, sizeof(host_reg), &host_reg); msleep(1000); // Read test result retval = <API key>(ts->client, <API key> , sizeof(byte_data), (u8 *)&byte_data); printk("0x18 test: %02x, 0x19 test: %02x\n", byte_data[0], byte_data[1]); // Retrun Operate Mode host_reg = CYTTSP_OPERATE_MODE; retval = <API key>(ts->client, CYTTSP_REG_BASE, sizeof(host_reg), &host_reg); #ifdef CYTTSP_MUTEX_LOCK mutex_unlock(&ts->lock_mutex); #endif msleep(100); printk("<API key>!! end\n"); if(byte_data[0] != 0) return CYTTSP_BIST_PROCESS; else if(byte_data[1] != 0xff) { if(!(byte_data[1] & 0x01)) return CYTTSP_OPEN_TEST; else if(!(byte_data[1] & 0x02)) return CYTTSP_SHORT_GND; else if(!(byte_data[1] & 0x04)) return CYTTSP_SHORT_VDD; else if(!(byte_data[1] & 0x08)) return CYTTSP_SHORT_PIN; else if(!(byte_data[1] & 0x10)) return CYTTSP_LOCAL_IDAC; else if(!(byte_data[1] & 0x20)) return CYTTSP_GLOBAL_IDAC; else if(!(byte_data[1] & 0x40)) return <API key>; else if(!(byte_data[1] & 0x80)) return CYTTSP_COMPLETE_BIT; } else return 0; return 0; } static void init_hw_setting(void) { int rc; struct regulator *vreg_touch, *vreg_power_1_8; gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_CHG, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_set_value(GPIO_TOUCH_CHG, 0); // Power On, AVDD vreg_touch = regulator_get(NULL, "8058_l19"); if (IS_ERR(vreg_touch)) { rc = PTR_ERR(vreg_touch); printk(KERN_ERR "%s: regulator get of %s failed (%d)\n", __func__, (char *) vreg_touch, rc); } rc = <API key>(vreg_touch, 3000000, 3000000); if (rc) { printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, rc); return; } rc = regulator_enable(vreg_touch); if (rc) { printk(KERN_ERR "%s: vreg enable failed (%d)\n",__func__, rc); return; } #if EF33S_BDVER_GE(WS20) || EF34K_BDVER_GE(WS20) vreg_power_1_8 = regulator_get(NULL, "8058_l11"); if (IS_ERR(vreg_power_1_8)) { rc = PTR_ERR(vreg_power_1_8); printk(KERN_ERR "%s: regulator get of %s failed (%d)\n", __func__, (char *) vreg_power_1_8, rc); } rc = <API key>(vreg_power_1_8, 1900000, 1900000); if (rc) { printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, rc); return; } rc = regulator_enable(vreg_power_1_8); if (rc) { printk(KERN_ERR "%s: vreg enable failed (%d)\n",__func__, rc); return; } #else // Power On DVDD vreg_power_1_8 = regulator_get(NULL, "8058_lvs0"); if (IS_ERR(vreg_power_1_8)) { rc = PTR_ERR(vreg_power_1_8); printk(KERN_ERR "%s: regulator get of %s failed (%d)\n", __func__, (char *) vreg_power_1_8, rc); } rc = regulator_enable(vreg_power_1_8); #endif gpio_set_value(GPIO_TOUCH_CHG, 1); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_CHG, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_ID, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE); gpio_set_value(GPIO_TOUCH_ID, 0); regulator_put(vreg_touch); regulator_put(vreg_power_1_8); msleep(100); Touch_Status = TOUCH_POWERON; } /* I2C driver probe function */ static int __devinit cyttsp_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct cyttsp *ts; int error; int retval = CYTTSP_OPERATIONAL; #ifdef <API key> int rc; #endif cyttsp_info("Start Probe\n"); /* allocate and clear memory */ ts = kzalloc (sizeof(struct cyttsp),GFP_KERNEL); if (ts == NULL) { cyttsp_xdebug1("err kzalloc for cyttsp\n"); retval = -ENOMEM; } init_hw_setting(); if (!(retval < CYTTSP_OPERATIONAL)) { /* register driver_data */ ts->client = client; ts->platform_data = client->dev.platform_data; i2c_set_clientdata(client,ts); ts->client->irq = IRQ_TOUCH_INT; error = cyttsp_initialize(client, ts); if (error) { cyttsp_xdebug1("err cyttsp_initialize\n"); if (ts != NULL) { /* deallocate memory */ kfree(ts); } /* i2c_del_driver(&cyttsp_driver); */ retval = -ENODEV; } else { cyttsp_openlog(); } } #ifdef <API key> if (!(retval < CYTTSP_OPERATIONAL)) { ts->early_suspend.level = <API key> + 1; ts->early_suspend.suspend = <API key>; ts->early_suspend.resume = cyttsp_late_resume; <API key>(&ts->early_suspend); } #endif /* <API key> */ #ifdef <API key> rc = misc_register(&touch_event); if (rc) { pr_err("::::::::: can''t register touch_fops\n"); } #endif cyttsp_info("Start Probe %s\n", (retval < CYTTSP_OPERATIONAL) ? "FAIL" : "PASS"); ts_temp = ts; #ifdef CYTTSP_MUTEX_LOCK mutex_init(&ts->lock_mutex); #endif #ifdef <API key> #if defined(CONFIG_APACHE_BOARD) schedule_work(&ts->work3); // INIT_DELAYED_WORK(&work_delay_firmware,<API key>); // <API key>(&work_delay_firmware, msecs_to_jiffies(30000)); #elif defined(CONFIG_EF33_BOARD) || defined(CONFIG_EF34_BOARD) #if EF33S_BDVER_GE(WS20) || EF34K_BDVER_GE(WS20) //schedule_work(&ts->work3); // N1037 20120312 for ICS <API key>(&ts->work3, msecs_to_jiffies(3000)); #endif #else schedule_work(&ts->work3); #endif #endif wake_lock_init(&touch_wake_lock, WAKE_LOCK_SUSPEND, "touch"); return retval; } /* Function to manage power-on resume */ static int cyttsp_resume(struct i2c_client *client) { struct cyttsp *ts; int ret=0; int retval = CYTTSP_OPERATIONAL; dbg("Wake Up\n"); ts = (struct cyttsp *) i2c_get_clientdata(client); if(ts == NULL) return retval; pantech_ctl_update(<API key> , 1); pantech_ctl_update(ISSP_IOCTL_INTR, 1); pantech_ctl_update(<API key>, 0); Touch_Status = TOUCH_POWERON; // for ICS version - 0511 KJHW input_mt_init_slots(ts->input, TOUCH_MAX_NUM); msleep(100); ret = request_irq (client->irq,cyttsp_irq,<API key>, client->dev.driver->name,ts); #ifdef <API key> mod_timer(&ts->timer, jiffies + <API key> * HZ); <API key> = true; #endif /* re-enable the interrupt after resuming */ // enable_irq(ts->client->irq); cyttsp_debug("Wake Up %s\n", (retval < CYTTSP_OPERATIONAL) ? "FAIL" : "PASS" ); return retval; } /* Function to manage low power suspend */ static int cyttsp_suspend(struct i2c_client *client, pm_message_t message) { struct cyttsp *ts; int retval = CYTTSP_OPERATIONAL, id =0; dbg("Enter Sleep\n"); ts = (struct cyttsp *) i2c_get_clientdata(client); if(ts == NULL) return retval; /* disable worker */ disable_irq_nosync(ts->client->irq); #ifdef <API key> <API key> = false; retval = cancel_work_sync(&ts->work2); del_timer(&ts->timer); #endif #ifdef <API key> // cancel_work_sync(&ts->work3); #endif Touch_Status = TOUCH_POWEROFF; retval = cancel_work_sync(&ts->work); pantech_ctl_update(<API key>, 0); free_irq(client->irq,ts); pantech_ctl_update(<API key>, 1); pantech_ctl_update(<API key>, 1); pantech_ctl_update(ISSP_IOCTL_INTR, 0); pantech_ctl_update(ISSP_IOCTL_SCLK, 0); pantech_ctl_update(ISSP_IOCTL_DATA, 0); // for ICS version - 0511 KJHW for (id = 0; id < TOUCH_MAX_NUM; id++) { cur_trk[id].abs[CY_ABS_ID_OST] = -1; cur_touchflag[id] = 0; input_mt_slot(ts->input, id); input_report_abs(ts->input, ABS_MT_TRACKING_ID, cur_trk[id].abs[CY_ABS_ID_OST]); input_report_key(ts->input, BTN_TOUCH, 0 ); input_sync(ts->input); } // for ICS version - 0511 KJHW <API key>(ts->input); return retval; } /* registered in driver struct */ static int __devexit cyttsp_remove(struct i2c_client *client) { struct cyttsp *ts; int err; cyttsp_alert("Unregister\n"); /* clientdata registered on probe */ ts = i2c_get_clientdata(client); device_remove_file(&ts->client->dev, &dev_attr_irq_enable); /* Start cleaning up by removing any delayed work and the timer */ if (cancel_delayed_work((struct delayed_work *)&ts->work)<0) { cyttsp_alert("error: could not remove work from workqueue\n"); } /* free up timer or irq */ if(ts->client->irq == 0) { err = del_timer(&ts->timer); if (err < 0) { cyttsp_alert("error: failed to delete timer\n"); } } else { #ifdef <API key> <API key> = false; del_timer(&ts->timer); #endif free_irq(client->irq,ts); } /* housekeeping */ if (ts != NULL) { kfree(ts); } /* clientdata registered on probe */ cyttsp_alert("Leaving\n"); return 0; } #ifdef <API key> static void <API key>(struct early_suspend *handler) { struct cyttsp *ts; ts = container_of(handler, struct cyttsp, early_suspend); cyttsp_suspend(ts->client, PMSG_SUSPEND); } static void cyttsp_late_resume(struct early_suspend *handler) { struct cyttsp *ts; ts = container_of(handler, struct cyttsp, early_suspend); cyttsp_resume(ts->client); } #endif /* <API key> */ static int cyttsp_init(void) { int ret; cyttsp_info("Cypress TrueTouch(R) Standard Product I2C Touchscreen Driver (Built %s @ %s)\n",__DATE__,__TIME__); ret = i2c_add_driver(&cyttsp_driver); return ret; } static void cyttsp_exit(void) { return i2c_del_driver(&cyttsp_driver); } module_init(cyttsp_init); module_exit(cyttsp_exit);
<?php header("<API key>: *"); header("Content-Type: application/json; charset=UTF-8"); global $DB; global $USER; // Require config.php file for database connection // 1 require_once('/home/libecour/public_html/moodle/config.php'); // Get quiz number // 2 $quiz = $_GET['quiz']; // Create connection - MySQLi (object-oriented) // 3 $conn = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); // Check connection - MySQLi (object-oriented) // 4 if ($conn->connect_error) { die("Connection to the database failed: " . $conn->connect_error . "<br>"); } // Set character set to UTF8 // 5 mysqli_set_charset($conn,"utf8"); // Check if user is connected // 6 if ($USER->id != 0) { // Select Statement - MySQLi (object-oriented) // 7 $sql = "SELECT id FROM <API key> WHERE userid = $USER->id" ; $result = $conn->query($sql); // Get learner profile id // 8 if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $learnerprofileid = $row['id']; } // free result set // 9 $result->free(); // Select Statement - MySQLi (object-oriented) // 10 $sql = "SELECT abilitylevel FROM <API key> WHERE learnerprofileid = $learnerprofileid AND libethemeid = 2" ; $result = $conn->query($sql); // Get ability level if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $abilitylevel = $row['abilitylevel']; // free result set // 11 $result->free(); // Insert rows in <API key> table // 12 $sql = "INSERT INTO <API key> (learnerprofileid, libethemeid, quiz, abilitylevel, timelogged) VALUES ($learnerprofileid, 2, $quiz, '$abilitylevel', NULL)"; $conn->query($sql); } } // Close database connection // 13 $conn->close();
#!/usr/bin/perl use strict; my $head = "download:"; my $output; open ( RULES, $ARGV[0] ) or die; while ( <RULES> ) { chomp; if ( ! m/^#/ and ! m/^\s*$/ ) { @_ = split ( /;/, $_ ); my $file = $_[0]; $head .= " \$(archivedir)/" . $file; $output .= "\$(archivedir)/" . $file . ":\n\tfalse || "; $output .= "mkdir -p \$(archivedir) && ( \\\n\t"; shift @_; foreach ( @_ ) { if ( $_ =~ m { $output .= "wget -c --passive-ftp --<API key> -P \$(archivedir) " . $_ . "/" . $file . " || \\\n\t"; } elsif ( $_ =~ m#^(http|https)://# ) { $output .= "wget -t 2 -T 10 -c --<API key> -P \$(archivedir) " . $_ . "/" . $file . " || \\\n\t"; } } $output .= "wget -c --<API key> -P \$(archivedir) http: $output .= "\n\t\@touch \$\@"; $output .= "\n\n"; } } close ( RULES ); print $head . "\n\n" . $output . "\n";
layout: default title: (#TBD) Method Java (1) (caller) invoke C2 JIT Compiler [Up](no3059lvH.html) [Top](../index.html) # (#TBD) Method Java (1) (caller) invoke C2 JIT Compiler #Under Construction
#include "<API key>.h" #include <android/log.h> #include <android/asset_manager.h> #include <android/asset_manager_jni.h> #include <signal.h> #include <assert.h> #include "audioplayer.h" #include "AudioStreamSession.h" #include "SenderSession.h" #include "ReceiverSession.h" #include "decoder.h" #include "jrtplib/rtpsourcedata.h" #define debugLog(...) __android_log_print(ANDROID_LOG_DEBUG, "AudioCore", __VA_ARGS__) //#define debugLog(...) printf(__VA_ARGS__) #ifdef RTP_SUPPORT_THREAD void thread_exit_handler(int sig) { debugLog("this signal is %d \n", sig); pthread_exit(0); } #endif // Global audiostream manager AudioStreamSession *audioSession; void <API key>(JNIEnv *env, jobject thiz, jint samplesPerSec, jint framesPerBuffer) { <API key>((uint32_t) samplesPerSec, (uint32_t) framesPerBuffer); #ifdef RTP_SUPPORT_THREAD // Workaround to kill threads since pthread_cancel is not supported // See jthread.cpp struct sigaction actions; memset(&actions, 0, sizeof(actions)); sigemptyset(&actions.sa_mask); actions.sa_flags = 0; actions.sa_handler = thread_exit_handler; sigaction(SIGUSR1, &actions, NULL); #endif } void <API key>(JNIEnv *env, jobject thiz) { if (audioSession) audioSession->Stop(); if (audioSession) delete audioSession; audioplayer_cleanup(); } void <API key> (JNIEnv *env, jobject thiz, jint portbase, jobject assetManager, jstring jPath) { AAssetManager *mgr = <API key>(env, assetManager); const char *path = env->GetStringUTFChars(jPath, 0); // Open the asset from the assets/ folder AAsset *asset = AAssetManager_open(mgr, path, AASSET_MODE_UNKNOWN); env-><API key>(jPath, path); if (NULL == asset) { debugLog("_ASSET_NOT_FOUND_"); return; } off_t outStart, fileSize; int fd = <API key>(asset, &outStart, &fileSize); assert(0 <= fd); debugLog("Audio file offset: %ld, size: %ld", outStart, fileSize); AMediaExtractor *extr = <API key>(fd, outStart, fileSize); audioSession = SenderSession::StartStreaming((uint16_t) portbase, extr); AAsset_close(asset); } void <API key> (JNIEnv *env, jobject thiz, jint portbase, jstring jPath) { const char *path = env->GetStringUTFChars(jPath, 0); AMediaExtractor *extr = <API key>(path); env-><API key>(jPath, path); audioSession = SenderSession::StartStreaming((uint16_t) portbase, extr); } /* * Class: <API key> * Method: startReceiving * Signature: (Ljava/lang/String;I)V */ void <API key>(JNIEnv *env, jobject thiz, jstring jHost, jint portbase) { const char *host = env->GetStringUTFChars(jHost, 0); audioSession = ReceiverSession::StartReceiving(host, (uint16_t) portbase); env-><API key>(jHost, host); } /* * Class: <API key> * Method: stop * Signature: ()V */ void <API key>(JNIEnv *env, jobject thiz) { if (audioSession) audioSession->Stop(); <API key>(); } void <API key>(JNIEnv *env, jobject thiz, jlong latencyMs) { if (latencyMs >= 0) <API key>((int64_t)latencyMs * 1000); } /* * Class: <API key> * Method: getRtpSourceCount * Signature: ()I */ jobjectArray <API key> (JNIEnv *env, jobject thiz) { if (audioSession == NULL) return NULL; int i = 0; if (audioSession->GotoFirstSource()) do { jrtplib::RTPSourceData *source = audioSession-><API key>(); if (source == nullptr || source->IsOwnSSRC()) continue; i++; } while (audioSession->GotoNextSource()); if (i == 0) return NULL; jclass clzz = env->FindClass("de/rwth_aachen/comsys/audiosync/AudioDestination"); jmethodID init = env->GetMethodID(clzz, "<init>", "()V"); jfieldID nameID = env->GetFieldID(clzz, "name", "Ljava/lang/String;"); jfieldID jitterID = env->GetFieldID(clzz, "jitter", "I"); jfieldID timeOffsetID = env->GetFieldID(clzz, "timeOffset", "I"); jfieldID packetsLostID = env->GetFieldID(clzz, "packetsLost", "I"); jobjectArray ret = env->NewObjectArray(i, clzz, NULL); i = 0; if (audioSession->GotoFirstSource()) { do { jrtplib::RTPSourceData *source = audioSession-><API key>(); if (source != nullptr && !source->IsOwnSSRC()) { jrtplib::RTPSourceData *sourceData = audioSession-><API key>(); size_t nameLen = 0; uint8_t *nameChars = sourceData->SDES_GetName(&nameLen); char chars[256] = {0}; memcpy(chars, nameChars, nameLen); jobject dest = env->NewObject(clzz, init); env->SetObjectField(dest, nameID, env->NewStringUTF(chars)); env->SetIntField(dest, jitterID, (jint) sourceData->INF_GetJitter()); env->SetIntField(dest, timeOffsetID, (jint)sourceData-><API key>()); env->SetIntField(dest, packetsLostID, (jint) sourceData->RR_GetPacketsLost()); env-><API key>(ret, i, dest); i++; } } while (audioSession->GotoNextSource()); } return ret; } /* * Return current presentation time in milliseconds */ jlong <API key> (JNIEnv *, jobject) { if (audioSession != NULL && audioSession->IsRunning()) return (jlong)(audioSession-><API key>() / 1000); return -1; } jboolean <API key> (JNIEnv *, jobject) { bool a = audioSession != NULL && audioSession->IsRunning(); return (jboolean) (a ? JNI_TRUE : JNI_FALSE); } jboolean <API key>(JNIEnv *, jobject) { if (audioSession != NULL && audioSession->IsSender()) { return (jboolean) (audioSession->IsRunning()); } return JNI_FALSE; } void <API key> (JNIEnv *, jobject) { if (audioSession != NULL && audioSession->IsSender()) { SenderSession *sender = (SenderSession *)audioSession; // TODO } }
<?php /** * This file is for debugging and app development purposes only. * Should not be used for front-end features. * Possible purposes are: * -- you want to test the functionality of the methods you created from another registered class. * -- or you may want to test the effective of such algorithms. * */ # Begin coding below ?>
package cz.vutbr.fit.xfekia00; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.LinkedList; /** * jedno vykonanie skriptu sa uklada ako polozka historie * @author Filip Fekiac */ public class HistoryItem { private final String usedDatabase; // pouzity databazovy system private final LinkedList<String[][]> resultList; // vysledky dopytov private final LinkedList<String[]> resultHeader; // hlavicky dopytov private final LinkedList<String> resultCaption; // jednotlive dopyty private final Calendar date; public HistoryItem(String _usedDB) { usedDatabase = _usedDB; resultList = new LinkedList<>(); resultHeader = new LinkedList<>(); resultCaption = new LinkedList<>(); date = Calendar.getInstance(); } public void addResultItem(int pos, String[][] _item) { resultList.add(pos, _item); } public void addHeaderItem(int pos, String[] _item) { resultHeader.add(pos, _item); } public void addCaptionItem(int pos, String _item) { resultCaption.add(pos, _item); } public String getUsedDatabase() { return usedDatabase; } public LinkedList<String[][]> getResultList() { return resultList; } public LinkedList<String[]> getResultHeader() { return resultHeader; } public LinkedList<String> getResultCaption() { return resultCaption; } @Override public String toString() { SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy"); return format.format(date.getTime()) + " " + usedDatabase; } }
/* Notes: This module communicates with the graphics API. The API can be any graphics API, e.g OpenGL, DirectX, SDL, GDI, etc; as long as the functions listed in this header are implemented. */ #ifndef __RENDERER_H__ #define __RENDERER_H__ #include "filesystem.h" #include "platform.h" #include "texture_manager.h" #include "font_manager.h" #ifdef _WIN32 #define OPENGL_DLL_NAME "opengl32.dll" #elif __unix__ #define OPENGL_DLL_NAME "libGL.so.1" #else #error "Define OPENGL_DLL_NAME" #endif typedef enum { rserr_ok, <API key>, rserr_invalid_mode, rserr_unknown } rserr_t; int <API key>; int R_Init( void *hinstance, void *hWnd ); void R_Shutdown( void ); void R_BeginRegistration( const char *model ); void R_EndRegistration( void ); void R_BeginFrame( void ); void R_EndFrame( void ); void R_AppActivate( _boolean active ); void R_SwapBuffers( int ); void R_SetPalette( const unsigned char *palette); void R_DeleteTexture( unsigned int texnum ); _boolean R_UploadTexture( texture_t *tex, PW8 data ); void R_SetGL2D( void ); void R_Draw_Pic( int x, int y, const char *name ); void R_Draw_StretchPic( int x, int y, int w, int h, const char *name ); void R_Draw_Character( int x, int y, int num, font_t *myfont ); void R_Draw_Tile( int x, int y, int w, int h, const char *name ); void R_Draw_Fill( int x, int y, int w, int h, colour3_t c ); void R_Draw_Line( int nXStart, int nYStart, int nXEnd, int nYEnd, int width, colour3_t c ); #endif /* __RENDERER_H__ */
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class <API key> extends CI_DB { var $dbdriver = 'postgre'; var $_escape_char = '"'; // clause and character used for LIKE escape sequences var $_like_escape_str = " ESCAPE '%s' "; var $_like_escape_chr = '!'; /** * The syntax to count rows is slightly different across different * database engines, so this string appears in each driver and is * used for the count_all() and count_all_results() functions. */ var $_count_string = "SELECT COUNT(*) AS "; var $_random_keyword = ' RANDOM()'; // database specific random keyword /** * Connection String * * @access private * @return string */ function _connect_string() { $components = array( 'hostname' => 'host', 'port' => 'port', 'database' => 'dbname', 'username' => 'user', 'password' => 'password' ); $connect_string = ""; foreach ($components as $key => $val) { if (isset($this->$key) && $this->$key != '') { $connect_string .= " $val=".$this->$key; } } return trim($connect_string); } /** * Non-persistent database connection * * @access private called by the base class * @return resource */ function db_connect() { return @pg_connect($this->_connect_string()); } /** * Persistent database connection * * @access private called by the base class * @return resource */ function db_pconnect() { return @pg_pconnect($this->_connect_string()); } /** * Reconnect * * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * * @access public * @return void */ function reconnect() { if (pg_ping($this->conn_id) === FALSE) { $this->conn_id = FALSE; } } /** * Select the database * * @access private called by the base class * @return resource */ function db_select() { // Not needed for Postgre so we'll return TRUE return TRUE; } /** * Set client character set * * @access public * @param string * @param string * @return resource */ function db_set_charset($charset, $collation) { // @todo - add support if needed return TRUE; } /** * Version number query string * * @access public * @return string */ function _version() { return "SELECT version() AS ver"; } /** * Execute the query * * @access private called by the base class * @param string an SQL query * @return resource */ function _execute($sql) { $sql = $this->_prep_query($sql); return @pg_query($this->conn_id, $sql); } /** * Prep the query * * If needed, each database adapter can prep the query string * * @access private called by execute() * @param string an SQL query * @return string */ function _prep_query($sql) { return $sql; } /** * Begin Transaction * * @access public * @return bool */ function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { return TRUE; } // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { return TRUE; } // Reset the transaction failure flag. // If the $test_mode flag is set to TRUE transactions will be rolled back // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; return @pg_exec($this->conn_id, "begin"); } /** * Commit Transaction * * @access public * @return bool */ function trans_commit() { if ( ! $this->trans_enabled) { return TRUE; } // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { return TRUE; } return @pg_exec($this->conn_id, "commit"); } /** * Rollback Transaction * * @access public * @return bool */ function trans_rollback() { if ( ! $this->trans_enabled) { return TRUE; } // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { return TRUE; } return @pg_exec($this->conn_id, "rollback"); } /** * Escape String * * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ function escape_str($str, $like = FALSE) { if (is_array($str)) { foreach ($str as $key => $val) { $str[$key] = $this->escape_str($val, $like); } return $str; } $str = pg_escape_string($str); // escape LIKE condition wildcards if ($like === TRUE) { $str = str_replace( array('%', '_', $this->_like_escape_chr), array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), $str); } return $str; } /** * Affected Rows * * @access public * @return integer */ function affected_rows() { return @pg_affected_rows($this->result_id); } /** * Insert ID * * @access public * @return integer */ function insert_id() { $v = $this->_version(); $v = $v['server']; $table = func_num_args() > 0 ? func_get_arg(0) : NULL; $column = func_num_args() > 1 ? func_get_arg(1) : NULL; if ($table == NULL && $v >= '8.1') { $sql='SELECT LASTVAL() as ins_id'; } elseif ($table != NULL && $column != NULL && $v >= '8.0') { $sql = sprintf("SELECT <API key>('%s','%s') as seq", $table, $column); $query = $this->query($sql); $row = $query->row(); $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq); } elseif ($table != NULL) { // seq_name passed in table parameter $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table); } else { return pg_last_oid($this->result_id); } $query = $this->query($sql); $row = $query->row(); return $row->ins_id; } /** * "Count All" query * * Generates a platform-specific query string that counts all records in * the specified database * * @access public * @param string * @return string */ function count_all($table = '') { if ($table == '') { return 0; } $query = $this->query($this->_count_string . $this-><API key>('numrows') . " FROM " . $this-><API key>($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { return 0; } $row = $query->row(); $this->_reset_select(); return (int) $row->numrows; } /** * Show table query * * Generates a platform-specific query string so that the table names can be fetched * * @access private * @param boolean * @return string */ function _list_tables($prefix_limit = FALSE) { $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; if ($prefix_limit !== FALSE AND $this->dbprefix != '') { $sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } return $sql; } /** * Show column query * * Generates a platform-specific query string so that the column names can be fetched * * @access public * @param string the table name * @return string */ function _list_columns($table = '') { return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'"; } /** * Field data query * * Generates a platform-specific query so that the column data can be retrieved * * @access public * @param string the table name * @return object */ function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } /** * The error message string * * @access private * @return string */ function _error_message() { return pg_last_error($this->conn_id); } /** * The error message number * * @access private * @return integer */ function _error_number() { return ''; } /** * Escape the SQL Identifiers * * This function escapes column and table names * * @access private * @param string * @return string */ function _escape_identifiers($item) { if ($this->_escape_char == '') { return $item; } foreach ($this-><API key> as $id) { if (strpos($item, '.'.$id) !== FALSE) { $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } } if (strpos($item, '.') !== FALSE) { $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; } else { $str = $this->_escape_char.$item.$this->_escape_char; } // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } /** * From Tables * * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * * @access public * @param type * @return type */ function _from_tables($tables) { if ( ! is_array($tables)) { $tables = array($tables); } return implode(', ', $tables); } /** * Insert statement * * Generates a platform-specific insert string from the supplied data * * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } /** * Insert_batch statement * * Generates a platform-specific insert string from the supplied data * * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ function _insert_batch($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); } /** * Update statement * * Generates a platform-specific update string from the supplied data * * @access public * @param string the table name * @param array the update data * @param array the where clause * @param array the orderby clause * @param array the limit clause * @return string */ function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; $sql .= $orderby.$limit; return $sql; } /** * Truncate statement * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * * @access public * @param string the table name * @return string */ function _truncate($table) { return "TRUNCATE ".$table; } /** * Delete statement * * Generates a platform-specific delete string from the supplied data * * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; if (count($where) > 0 OR count($like) > 0) { $conditions = "\nWHERE "; $conditions .= implode("\n", $this->ar_where); if (count($where) > 0 && count($like) > 0) { $conditions .= " AND "; } $conditions .= implode("\n", $like); } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; return "DELETE FROM ".$table.$conditions.$limit; } /** * Limit string * * Generates a platform-specific LIMIT clause * * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ function _limit($sql, $limit, $offset) { $sql .= "LIMIT ".$limit; if ($offset > 0) { $sql .= " OFFSET ".$offset; } return $sql; } /** * Close DB Connection * * @access public * @param resource * @return void */ function _close($conn_id) { @pg_close($conn_id); } } /* End of file postgre_driver.php */ /* Location: ./system/database/drivers/postgre/postgre_driver.php */
/*** ESSENTIAL STYLES ***/ .sf-menu, .sf-menu * { margin: 0; padding: 0; list-style: none; } .sf-menu { line-height: 1.0; } .sf-menu ul { position: absolute; top: -999em; width: 10em; /* left offset of submenus need to match (see below) */ } .sf-menu ul li { width: 100%; } .sf-menu li:hover { visibility: inherit; /* fixes IE7 'sticky bug' */ } .sf-menu li { float: left; position: relative; } .sf-menu a { display: block; position: relative; } .sf-menu li:hover ul, .sf-menu li.sfHover ul { left: 0; top: 2.5em; /* match top ul list item height */ z-index: 9999; } ul.sf-menu li:hover li ul, ul.sf-menu li.sfHover li ul { top: -999em; } ul.sf-menu li li:hover ul, ul.sf-menu li li.sfHover ul { left: 13.5em; /* match ul width */ top: 0; } ul.sf-menu li li:hover li ul, ul.sf-menu li li.sfHover li ul { top: -999em; } ul.sf-menu li li li:hover ul, ul.sf-menu li li li.sfHover ul { left: 10em; /* match ul width */ top: 0; } /*** DEMO SKIN ***/ .sf-menu { float: left; margin-bottom: 1px; } .sf-menu a { padding: .75em 1em; text-decoration:none; } .sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/ color: #bbbbbb; /*font-weight: bold;*/ } .sf-menu li { } .sf-menu li li { background: url("img/sub-menu-center.png") repeat-y transparent; float: left; } .sf-menu .sub-menu { margin-top: -26px; padding-top: 17px; <API key>: 4px; <API key>: 4px; z-index: 99999; } .sf-menu .sub-menu li{} .sf-menu .sub-menu li a{ color: #4e4d4c!important; margin: 5px 15px 5px 16px; padding-bottom: 10px; border-bottom: 1px solid rgba(153, 153, 153, 0.28); } .sf-menu .sub-menu li:last-child a {border: none} .sf-menu .sub-menu li:first-child a {margin-top: 10px} .sf-menu .sub-menu li:last-child { <API key>: 6px; <API key>: 6px; border-bottom: 1px solid rgba(0, 0, 0, 0.21); } .sf-menu .sub-menu-last ul li a{ border-bottom: 1px solid #e9e8e8!important; padding: 0.7em 0; width: 94%; } .sf-menu .sub-menu-last ul li a.sub-sub-menu-last{border-bottom:0px solid #fff!important;} .sf-menu li li li {} .sf-menu li:hover, .sf-menu li.sfHover, .sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active { color: #fff; outline: 0; } .sf-menu .sub-menu a:hover{ color:#ff6825!important; outline: 0; background: none!important; } .sf-menu .sub-menu li:hover{} /*** arrows **/ .sf-menu a.sf-with-ul { min-width: 1px; /* trigger IE7 hasLayout so spans position accurately */ } .sf-sub-indicator { position: absolute; display: block; right: .75em; top: 1.05em; /* IE6 only */ width: 10px; height: 10px; text-indent: -999em; overflow: hidden; } a > .sf-sub-indicator { /* give all except IE6 the correct values */ top: .8em; background-position: 0 -100px; /* use translucent arrow for modern browsers*/ } /* apply hovers to modern browsers */ a:focus > .sf-sub-indicator, a:hover > .sf-sub-indicator, a:active > .sf-sub-indicator, li:hover > a > .sf-sub-indicator, li.sfHover > a > .sf-sub-indicator { background-position: -10px -100px; /* arrow hovers for modern browsers*/ } /* point right for anchors in subs */ .sf-menu ul .sf-sub-indicator { background-position: -10px 0; } .sf-menu ul a > .sf-sub-indicator { background-position: 0 0; } /* apply hovers to modern browsers */ .sf-menu ul a:focus > .sf-sub-indicator, .sf-menu ul a:hover > .sf-sub-indicator, .sf-menu ul a:active > .sf-sub-indicator, .sf-menu ul li:hover > a > .sf-sub-indicator, .sf-menu ul li.sfHover > a > .sf-sub-indicator { background-position: -10px 0; /* arrow hovers for modern browsers*/ } /*** shadows for all but IE6 ***/ .sf-shadow ul { margin: 5px 0 0 0; } .sf-shadow ul.sf-shadow-off { background: transparent; } /*--- TOP, BOTTOM SUB-MENU --*/ .sub-menu-top{ background: url("img/sub-menu-top.png") no-repeat transparent; float: left; height: 3px; width: 191px; } .sub-menu-bottom{ background: url("img/sub-menu-bottom.png") no-repeat transparent; float: left; height: 8px; width: 191px; }
#include <acpi/acpi.h> #include "accommon.h" #include "acnamesp.h" #include "acresrc.h" #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rsutils") u8 <API key>(u16 mask, u8 * list) { u8 i; u8 bit_count; ACPI_FUNCTION_ENTRY(); /* Decode the mask bits */ for (i = 0, bit_count = 0; mask; i++) { if (mask & 0x0001) { list[bit_count] = i; bit_count++; } mask >>= 1; } return (bit_count); } u16 <API key>(u8 * list, u8 count) { u32 i; u16 mask; ACPI_FUNCTION_ENTRY(); /* Encode the list into a single bitmask */ for (i = 0, mask = 0; i < count; i++) { mask |= (0x1 << list[i]); } return mask; } void acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) { u32 i; ACPI_FUNCTION_ENTRY(); /* One move per item */ for (i = 0; i < item_count; i++) { switch (move_type) { /* * For the 8-bit case, we can perform the move all at once * since there are no alignment or endian issues */ case ACPI_RSC_MOVE8: ACPI_MEMCPY(destination, source, item_count); return; /* * 16-, 32-, and 64-bit cases must use the move macros that perform * endian conversion and/or accomodate hardware that cannot perform * misaligned memory transfers */ case ACPI_RSC_MOVE16: ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i], &ACPI_CAST_PTR(u16, source)[i]); break; case ACPI_RSC_MOVE32: ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i], &ACPI_CAST_PTR(u32, source)[i]); break; case ACPI_RSC_MOVE64: ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i], &ACPI_CAST_PTR(u64, source)[i]); break; default: return; } } } void <API key>(acpi_rsdesc_size total_length, union aml_resource *aml) { acpi_rs_length resource_length; ACPI_FUNCTION_ENTRY(); /* Length is the total descriptor length minus the header length */ resource_length = (acpi_rs_length) (total_length - <API key>(aml)); /* Length is stored differently for large and small descriptors */ if (aml->small_header.descriptor_type & <API key>) { /* Large descriptor -- bytes 1-2 contain the 16-bit length */ ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, &resource_length); } else { /* Small descriptor -- bits 2:0 of byte 0 contain the length */ aml->small_header.descriptor_type = (u8) /* Clear any existing length, preserving descriptor type bits */ ((aml->small_header. descriptor_type & ~<API key>) | resource_length); } } void <API key>(u8 descriptor_type, acpi_rsdesc_size total_length, union aml_resource *aml) { ACPI_FUNCTION_ENTRY(); /* Set the Resource Type */ aml->small_header.descriptor_type = descriptor_type; /* Set the Resource Length */ <API key>(total_length, aml); } static u16 acpi_rs_strcpy(char *destination, char *source) { u16 i; ACPI_FUNCTION_ENTRY(); for (i = 0; source[i]; i++) { destination[i] = source[i]; } destination[i] = 0; /* Return string length including the NULL terminator */ return ((u16) (i + 1)); } acpi_rs_length <API key>(acpi_rs_length resource_length, acpi_rs_length minimum_length, struct <API key> * resource_source, union aml_resource * aml, char *string_ptr) { acpi_rsdesc_size total_length; u8 *aml_resource_source; ACPI_FUNCTION_ENTRY(); total_length = resource_length + sizeof(struct <API key>); aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length); /* * resource_source is present if the length of the descriptor is longer than * the minimum length. * * Note: Some resource descriptors will have an additional null, so * we add 1 to the minimum length. */ if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) { /* Get the <API key> */ resource_source->index = aml_resource_source[0]; resource_source->string_ptr = string_ptr; if (!string_ptr) { /* * String destination pointer is not specified; Set the String * pointer to the end of the current resource_source structure. */ resource_source->string_ptr = ACPI_ADD_PTR(char, resource_source, sizeof(struct <API key>)); } /* * In order for the Resource length to be a multiple of the native * word, calculate the length of the string (+1 for NULL terminator) * and expand to the next word multiple. * * Zero the entire area of the buffer. */ total_length = (u32) ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + 1; total_length = (u32) <API key>(total_length); ACPI_MEMSET(resource_source->string_ptr, 0, total_length); /* Copy the resource_source string to the destination */ resource_source->string_length = acpi_rs_strcpy(resource_source->string_ptr, ACPI_CAST_PTR(char, &aml_resource_source[1])); return ((acpi_rs_length) total_length); } /* resource_source is not present */ resource_source->index = 0; resource_source->string_length = 0; resource_source->string_ptr = NULL; return (0); } acpi_rsdesc_size <API key>(union aml_resource * aml, acpi_rs_length minimum_length, struct <API key> * resource_source) { u8 *aml_resource_source; acpi_rsdesc_size descriptor_length; ACPI_FUNCTION_ENTRY(); descriptor_length = minimum_length; /* Non-zero string length indicates presence of a resource_source */ if (resource_source->string_length) { /* Point to the end of the AML descriptor */ aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length); /* Copy the <API key> */ aml_resource_source[0] = (u8) resource_source->index; /* Copy the resource_source string */ ACPI_STRCPY(ACPI_CAST_PTR(char, &aml_resource_source[1]), resource_source->string_ptr); /* * Add the length of the string (+ 1 for null terminator) to the * final descriptor length */ descriptor_length += ((acpi_rsdesc_size) resource_source->string_length + 1); } /* Return the new total length of the AML descriptor */ return (descriptor_length); } acpi_status <API key>(struct acpi_namespace_node * node, struct acpi_buffer * ret_buffer) { union acpi_operand_object *obj_desc; acpi_status status; ACPI_FUNCTION_TRACE(<API key>); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ status = <API key>(node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &obj_desc); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Create a resource linked list from the byte stream buffer that comes * back from the _CRS method execution. */ status = <API key>(obj_desc, ret_buffer); /* On exit, we must delete the object returned by evaluate_object */ <API key>(obj_desc); return_ACPI_STATUS(status); } acpi_status <API key>(struct acpi_namespace_node *node, struct acpi_buffer *ret_buffer) { union acpi_operand_object *obj_desc; acpi_status status; ACPI_FUNCTION_TRACE(<API key>); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ status = <API key>(node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &obj_desc); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Make the call to create a resource linked list from the * byte stream buffer that comes back from the _CRS method * execution. */ status = <API key>(obj_desc, ret_buffer); /* On exit, we must delete the object returned by evaluate_object */ <API key>(obj_desc); return_ACPI_STATUS(status); } #ifdef ACPI_FUTURE_USAGE acpi_status <API key>(struct acpi_namespace_node *node, struct acpi_buffer *ret_buffer) { union acpi_operand_object *obj_desc; acpi_status status; ACPI_FUNCTION_TRACE(<API key>); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ status = <API key>(node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &obj_desc); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Make the call to create a resource linked list from the * byte stream buffer that comes back from the _CRS method * execution. */ status = <API key>(obj_desc, ret_buffer); /* On exit, we must delete the object returned by evaluate_object */ <API key>(obj_desc); return_ACPI_STATUS(status); } #endif /* ACPI_FUTURE_USAGE */ acpi_status <API key>(acpi_handle handle, char *path, struct acpi_buffer *ret_buffer) { union acpi_operand_object *obj_desc; acpi_status status; ACPI_FUNCTION_TRACE(rs_get_method_data); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ status = <API key>(handle, path, ACPI_BTYPE_BUFFER, &obj_desc); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Make the call to create a resource linked list from the * byte stream buffer that comes back from the method * execution. */ status = <API key>(obj_desc, ret_buffer); /* On exit, we must delete the object returned by evaluate_object */ <API key>(obj_desc); return_ACPI_STATUS(status); } acpi_status <API key>(struct acpi_namespace_node *node, struct acpi_buffer *in_buffer) { struct acpi_evaluate_info *info; union acpi_operand_object *args[2]; acpi_status status; struct acpi_buffer buffer; ACPI_FUNCTION_TRACE(<API key>); /* Allocate and initialize the evaluation information block */ info = <API key>(sizeof(struct acpi_evaluate_info)); if (!info) { return_ACPI_STATUS(AE_NO_MEMORY); } info->prefix_node = node; info->pathname = METHOD_NAME__SRS; info->parameters = args; info->flags = <API key>; /* * The in_buffer parameter will point to a linked list of * resource parameters. It needs to be formatted into a * byte stream to be sent in as an input parameter to _SRS * * Convert the linked list into a byte stream */ buffer.length = <API key>; status = <API key>(in_buffer->pointer, &buffer); if (ACPI_FAILURE(status)) { goto cleanup; } /* Create and initialize the method parameter object */ args[0] = <API key>(ACPI_TYPE_BUFFER); if (!args[0]) { /* * Must free the buffer allocated above (otherwise it is freed * later) */ ACPI_FREE(buffer.pointer); status = AE_NO_MEMORY; goto cleanup; } args[0]->buffer.length = (u32) buffer.length; args[0]->buffer.pointer = buffer.pointer; args[0]->common.flags = AOPOBJ_DATA_VALID; args[1] = NULL; /* Execute the method, no return value is expected */ status = acpi_ns_evaluate(info); /* Clean up and return the status from acpi_ns_evaluate */ <API key>(args[0]); cleanup: ACPI_FREE(info); return_ACPI_STATUS(status); }
#include <linux/interrupt.h> #include <linux/i2c.h> #include <linux/slab.h> #include <linux/irq.h> #include <linux/miscdevice.h> #include <asm/uaccess.h> #include <linux/delay.h> #include <linux/input.h> #include <linux/workqueue.h> #include <linux/kobject.h> #include <linux/earlysuspend.h> #include <linux/platform_device.h> #include <asm/atomic.h> #include <cust_acc.h> #include <linux/hwmsensor.h> #include <linux/hwmsen_dev.h> #include <linux/sensors_io.h> #include "lis3dh.h" #include <linux/hwmsen_helper.h> #include <mach/mt_devs.h> #include <mach/mt_typedefs.h> #include <mach/mt_gpio.h> #include <mach/mt_pm_ldo.h> #define POWER_NONE_MACRO MT65XX_POWER_NONE //#define I2C_DRIVERID_LIS3DH 345 #define DEBUG 1 #define <API key> /*apply low pass filter on output*/ #define LIS3DH_AXIS_X 0 #define LIS3DH_AXIS_Y 1 #define LIS3DH_AXIS_Z 2 #define LIS3DH_AXES_NUM 3 #define LIS3DH_DATA_LEN 6 #define LIS3DH_DEV_NAME "LIS3DH" static const struct i2c_device_id lis3dh_i2c_id[] = {{LIS3DH_DEV_NAME,0},{}}; /*the adapter id will be available in customization*/ static struct i2c_board_info __initdata i2c_LIS3DH={ I2C_BOARD_INFO("LIS3DH", (0x32>>1))}; //static unsigned short lis3dh_force[] = {0x00, <API key>, I2C_CLIENT_END, I2C_CLIENT_END}; //static const unsigned short *const lis3dh_forces[] = { lis3dh_force, NULL }; //static struct <API key> lis3dh_addr_data = { .forces = lis3dh_forces,}; static int lis3dh_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id); static int lis3dh_i2c_remove(struct i2c_client *client); //static int lis3dh_i2c_detect(struct i2c_client *client, int kind, struct i2c_board_info *info); static int lis3dh_local_init(void); static int lis3dh_remove(void); static int lis3dh_init_flag =0; // 0<==>OK -1 <==> fail typedef enum { ADX_TRC_FILTER = 0x01, ADX_TRC_RAWDATA = 0x02, ADX_TRC_IOCTL = 0x04, ADX_TRC_CALI = 0X08, ADX_TRC_INFO = 0X10, } ADX_TRC; struct scale_factor{ u8 whole; u8 fraction; }; struct data_resolution { struct scale_factor scalefactor; int sensitivity; }; #define C_MAX_FIR_LENGTH (32) struct data_filter { s16 raw[C_MAX_FIR_LENGTH][LIS3DH_AXES_NUM]; int sum[LIS3DH_AXES_NUM]; int num; int idx; }; static struct sensor_init_info lis3dh_init_info = { .name = "lis3dh", .init = lis3dh_local_init, .uninit = lis3dh_remove, }; struct lis3dh_i2c_data { struct i2c_client *client; struct acc_hw *hw; struct hwmsen_convert cvt; /*misc*/ struct data_resolution *reso; atomic_t trace; atomic_t suspend; atomic_t selftest; atomic_t filter; s16 cali_sw[LIS3DH_AXES_NUM+1]; /*data*/ s8 offset[LIS3DH_AXES_NUM+1]; /*+1: for 4-byte alignment*/ s16 data[LIS3DH_AXES_NUM+1]; #if defined(<API key>) atomic_t firlen; atomic_t fir_en; struct data_filter fir; #endif /*early suspend*/ #if defined(<API key>) struct early_suspend early_drv; #endif }; static struct i2c_driver lis3dh_i2c_driver = { .driver = { // .owner = THIS_MODULE, .name = LIS3DH_DEV_NAME, }, .probe = lis3dh_i2c_probe, .remove = lis3dh_i2c_remove, // .detect = lis3dh_i2c_detect, #if !defined(<API key>) .suspend = lis3dh_suspend, .resume = lis3dh_resume, #endif .id_table = lis3dh_i2c_id, // .address_data = &lis3dh_addr_data, }; static struct i2c_client *lis3dh_i2c_client = NULL; //static struct platform_driver <API key>; static struct lis3dh_i2c_data *obj_i2c_data = NULL; static bool sensor_power = false; static GSENSOR_VECTOR3D gsensor_gain, gsensor_offset; //static char selftestRes[10] = {0}; #define GSE_TAG "[Gsensor] " #define GSE_FUN(f) printk(KERN_INFO GSE_TAG"%s\n", __FUNCTION__) #define GSE_ERR(fmt, args...) printk(KERN_ERR GSE_TAG"%s %d : "fmt, __FUNCTION__, __LINE__, ##args) #define GSE_LOG(fmt, args...) printk(KERN_INFO GSE_TAG fmt, ##args) static struct data_resolution <API key>[] = { /* combination by {FULL_RES,RANGE}*/ {{ 1, 0}, 1024}, // dataformat +/-2g in 12-bit resolution; { 1, 0} = 1.0 = (2*2*1000)/(2^12); 1024 = (2^12)/(2*2) {{ 1, 9}, 512}, // dataformat +/-4g in 12-bit resolution; { 1, 9} = 1.9 = (2*4*1000)/(2^12); 512 = (2^12)/(2*4) {{ 3, 9}, 256}, // dataformat +/-8g in 12-bit resolution; { 1, 0} = 1.0 = (2*8*1000)/(2^12); 1024 = (2^12)/(2*8) }; static struct data_resolution <API key> = {{15, 6}, 64}; /* static int hwmsen_read_byte_sr(struct i2c_client *client, u8 addr, u8 *data) { u8 buf; int ret = 0; client->addr = client->addr& I2C_MASK_FLAG | I2C_WR_FLAG |I2C_RS_FLAG; buf = addr; ret = i2c_master_send(client, (const char*)&buf, 1<<8 | 1); //ret = i2c_master_send(client, (const char*)&buf, 1); if (ret < 0) { GSE_ERR("send command error!!\n"); return -EFAULT; } *data = buf; client->addr = client->addr& I2C_MASK_FLAG; return 0; } */ static void dumpReg(struct i2c_client *client) { int i=0; u8 addr = 0x20; u8 regdata=0; for(i=0; i<3 ; i++) { //dump all hwmsen_read_byte(client,addr,&regdata); GSE_LOG("Reg addr=%x regdata=%x\n",addr,regdata); addr++; } } static void LIS3DH_power(struct acc_hw *hw, unsigned int on) { static unsigned int power_on = 0; if(hw->power_id != POWER_NONE_MACRO) // have externel LDO { GSE_LOG("power %s\n", on ? "on" : "off"); if(power_on == on) // power status not change { GSE_LOG("ignore power control: %d\n", on); } else if(on) // power on { if(!hwPowerOn(hw->power_id, hw->power_vol, "LIS3DH")) { GSE_ERR("power on fails!!\n"); } } else // power off { if (!hwPowerDown(hw->power_id, "LIS3DH")) { GSE_ERR("power off fail!!\n"); } } } power_on = on; } static int <API key>(struct lis3dh_i2c_data *obj) { int err = 0; u8 dat, reso; err = hwmsen_read_byte(obj->client, LIS3DH_REG_CTL_REG4, &dat); if(err) { GSE_ERR("write data format fail!!\n"); return err; } /*the data_reso is combined by 3 bits: {FULL_RES, DATA_RANGE}*/ reso = (dat & 0x30)<<4; if(reso >= 0x3) reso = 0x2; if(reso < sizeof(<API key>)/sizeof(<API key>[0])) { obj->reso = &<API key>[reso]; return 0; } else { return -EINVAL; } } static int LIS3DH_ReadData(struct i2c_client *client, s16 data[LIS3DH_AXES_NUM]) { struct lis3dh_i2c_data *priv = i2c_get_clientdata(client); // u8 addr = LIS3DH_REG_DATAX0; u8 buf[LIS3DH_DATA_LEN] = {0}; int err = 0; if(NULL == client) { err = -EINVAL; } else { if(hwmsen_read_block(client, LIS3DH_REG_OUT_X, buf, 0x01)) { GSE_ERR("read G sensor data register err!\n"); return -1; } if(hwmsen_read_block(client, LIS3DH_REG_OUT_X+1, &buf[1], 0x01)) { GSE_ERR("read G sensor data register err!\n"); return -1; } data[LIS3DH_AXIS_X] = (s16)((buf[0]+(buf[1]<<8))>>4); if(hwmsen_read_block(client, LIS3DH_REG_OUT_Y, &buf[2], 0x01)) { GSE_ERR("read G sensor data register err!\n"); return -1; } if(hwmsen_read_block(client, LIS3DH_REG_OUT_Y+1, &buf[3], 0x01)) { GSE_ERR("read G sensor data register err!\n"); return -1; } data[LIS3DH_AXIS_Y] = (s16)((s16)(buf[2] +( buf[3]<<8))>>4); if(hwmsen_read_block(client, LIS3DH_REG_OUT_Z, &buf[4], 0x01)) { GSE_ERR("read G sensor data register err!\n"); return -1; } if(hwmsen_read_block(client, LIS3DH_REG_OUT_Z+1, &buf[5], 0x01)) { GSE_ERR("read G sensor data register err!\n"); return -1; } data[LIS3DH_AXIS_Z] =(s16)((buf[4]+(buf[5]<<8))>>4); //GSE_LOG("[%08X %08X %08X %08x %08x %08x]\n",buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]); data[LIS3DH_AXIS_X] &= 0xfff; data[LIS3DH_AXIS_Y] &= 0xfff; data[LIS3DH_AXIS_Z] &= 0xfff; if(atomic_read(&priv->trace) & ADX_TRC_RAWDATA) { GSE_LOG("[%08X %08X %08X] => [%5d %5d %5d]\n", data[LIS3DH_AXIS_X], data[LIS3DH_AXIS_Y], data[LIS3DH_AXIS_Z], data[LIS3DH_AXIS_X], data[LIS3DH_AXIS_Y], data[LIS3DH_AXIS_Z]); } if(data[LIS3DH_AXIS_X]&0x800) { data[LIS3DH_AXIS_X] = ~data[LIS3DH_AXIS_X]; data[LIS3DH_AXIS_X] &= 0xfff; data[LIS3DH_AXIS_X]+=1; data[LIS3DH_AXIS_X] = -data[LIS3DH_AXIS_X]; } if(data[LIS3DH_AXIS_Y]&0x800) { data[LIS3DH_AXIS_Y] = ~data[LIS3DH_AXIS_Y]; data[LIS3DH_AXIS_Y] &= 0xfff; data[LIS3DH_AXIS_Y]+=1; data[LIS3DH_AXIS_Y] = -data[LIS3DH_AXIS_Y]; } if(data[LIS3DH_AXIS_Z]&0x800) { data[LIS3DH_AXIS_Z] = ~data[LIS3DH_AXIS_Z]; data[LIS3DH_AXIS_Z] &= 0xfff; data[LIS3DH_AXIS_Z]+=1; data[LIS3DH_AXIS_Z] = -data[LIS3DH_AXIS_Z]; } if(atomic_read(&priv->trace) & ADX_TRC_RAWDATA) { GSE_LOG("[%08X %08X %08X] => [%5d %5d %5d] after\n", data[LIS3DH_AXIS_X], data[LIS3DH_AXIS_Y], data[LIS3DH_AXIS_Z], data[LIS3DH_AXIS_X], data[LIS3DH_AXIS_Y], data[LIS3DH_AXIS_Z]); } #ifdef <API key> if(atomic_read(&priv->filter)) { if(atomic_read(&priv->fir_en) && !atomic_read(&priv->suspend)) { int idx, firlen = atomic_read(&priv->firlen); if(priv->fir.num < firlen) { priv->fir.raw[priv->fir.num][LIS3DH_AXIS_X] = data[LIS3DH_AXIS_X]; priv->fir.raw[priv->fir.num][LIS3DH_AXIS_Y] = data[LIS3DH_AXIS_Y]; priv->fir.raw[priv->fir.num][LIS3DH_AXIS_Z] = data[LIS3DH_AXIS_Z]; priv->fir.sum[LIS3DH_AXIS_X] += data[LIS3DH_AXIS_X]; priv->fir.sum[LIS3DH_AXIS_Y] += data[LIS3DH_AXIS_Y]; priv->fir.sum[LIS3DH_AXIS_Z] += data[LIS3DH_AXIS_Z]; if(atomic_read(&priv->trace) & ADX_TRC_FILTER) { GSE_LOG("add [%2d] [%5d %5d %5d] => [%5d %5d %5d]\n", priv->fir.num, priv->fir.raw[priv->fir.num][LIS3DH_AXIS_X], priv->fir.raw[priv->fir.num][LIS3DH_AXIS_Y], priv->fir.raw[priv->fir.num][LIS3DH_AXIS_Z], priv->fir.sum[LIS3DH_AXIS_X], priv->fir.sum[LIS3DH_AXIS_Y], priv->fir.sum[LIS3DH_AXIS_Z]); } priv->fir.num++; priv->fir.idx++; } else { idx = priv->fir.idx % firlen; priv->fir.sum[LIS3DH_AXIS_X] -= priv->fir.raw[idx][LIS3DH_AXIS_X]; priv->fir.sum[LIS3DH_AXIS_Y] -= priv->fir.raw[idx][LIS3DH_AXIS_Y]; priv->fir.sum[LIS3DH_AXIS_Z] -= priv->fir.raw[idx][LIS3DH_AXIS_Z]; priv->fir.raw[idx][LIS3DH_AXIS_X] = data[LIS3DH_AXIS_X]; priv->fir.raw[idx][LIS3DH_AXIS_Y] = data[LIS3DH_AXIS_Y]; priv->fir.raw[idx][LIS3DH_AXIS_Z] = data[LIS3DH_AXIS_Z]; priv->fir.sum[LIS3DH_AXIS_X] += data[LIS3DH_AXIS_X]; priv->fir.sum[LIS3DH_AXIS_Y] += data[LIS3DH_AXIS_Y]; priv->fir.sum[LIS3DH_AXIS_Z] += data[LIS3DH_AXIS_Z]; priv->fir.idx++; data[LIS3DH_AXIS_X] = priv->fir.sum[LIS3DH_AXIS_X]/firlen; data[LIS3DH_AXIS_Y] = priv->fir.sum[LIS3DH_AXIS_Y]/firlen; data[LIS3DH_AXIS_Z] = priv->fir.sum[LIS3DH_AXIS_Z]/firlen; if(atomic_read(&priv->trace) & ADX_TRC_FILTER) { GSE_LOG("add [%2d] [%5d %5d %5d] => [%5d %5d %5d] : [%5d %5d %5d]\n", idx, priv->fir.raw[idx][LIS3DH_AXIS_X], priv->fir.raw[idx][LIS3DH_AXIS_Y], priv->fir.raw[idx][LIS3DH_AXIS_Z], priv->fir.sum[LIS3DH_AXIS_X], priv->fir.sum[LIS3DH_AXIS_Y], priv->fir.sum[LIS3DH_AXIS_Z], data[LIS3DH_AXIS_X], data[LIS3DH_AXIS_Y], data[LIS3DH_AXIS_Z]); } } } } #endif } return err; } /* static int LIS3DH_ReadOffset(struct i2c_client *client, s8 ofs[LIS3DH_AXES_NUM]) { int err; return err; } */ static int <API key>(struct i2c_client *client) { struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); memset(obj->cali_sw, 0x00, sizeof(obj->cali_sw)); return 0; } static int <API key>(struct i2c_client *client, int dat[LIS3DH_AXES_NUM]) { struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); dat[obj->cvt.map[LIS3DH_AXIS_X]] = obj->cvt.sign[LIS3DH_AXIS_X]*obj->cali_sw[LIS3DH_AXIS_X]; dat[obj->cvt.map[LIS3DH_AXIS_Y]] = obj->cvt.sign[LIS3DH_AXIS_Y]*obj->cali_sw[LIS3DH_AXIS_Y]; dat[obj->cvt.map[LIS3DH_AXIS_Z]] = obj->cvt.sign[LIS3DH_AXIS_Z]*obj->cali_sw[LIS3DH_AXIS_Z]; return 0; } /* static int <API key>(struct i2c_client *client, int act[LIS3DH_AXES_NUM], int raw[LIS3DH_AXES_NUM]) { struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); int err; int mul; if(err = LIS3DH_ReadOffset(client, obj->offset)) { GSE_ERR("read offset fail, %d\n", err); return err; } mul = obj->reso->sensitivity/<API key>.sensitivity; raw[LIS3DH_AXIS_X] = obj->offset[LIS3DH_AXIS_X]*mul + obj->cali_sw[LIS3DH_AXIS_X]; raw[LIS3DH_AXIS_Y] = obj->offset[LIS3DH_AXIS_Y]*mul + obj->cali_sw[LIS3DH_AXIS_Y]; raw[LIS3DH_AXIS_Z] = obj->offset[LIS3DH_AXIS_Z]*mul + obj->cali_sw[LIS3DH_AXIS_Z]; act[obj->cvt.map[LIS3DH_AXIS_X]] = obj->cvt.sign[LIS3DH_AXIS_X]*raw[LIS3DH_AXIS_X]; act[obj->cvt.map[LIS3DH_AXIS_Y]] = obj->cvt.sign[LIS3DH_AXIS_Y]*raw[LIS3DH_AXIS_Y]; act[obj->cvt.map[LIS3DH_AXIS_Z]] = obj->cvt.sign[LIS3DH_AXIS_Z]*raw[LIS3DH_AXIS_Z]; return 0; } */ static int <API key>(struct i2c_client *client, int dat[LIS3DH_AXES_NUM]) { struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); int err = 0; // int cali[LIS3DH_AXES_NUM]; GSE_FUN(); if(!obj || ! dat) { GSE_ERR("null ptr!!\n"); return -EINVAL; } else { s16 cali[LIS3DH_AXES_NUM]; cali[obj->cvt.map[LIS3DH_AXIS_X]] = obj->cvt.sign[LIS3DH_AXIS_X]*obj->cali_sw[LIS3DH_AXIS_X]; cali[obj->cvt.map[LIS3DH_AXIS_Y]] = obj->cvt.sign[LIS3DH_AXIS_Y]*obj->cali_sw[LIS3DH_AXIS_Y]; cali[obj->cvt.map[LIS3DH_AXIS_Z]] = obj->cvt.sign[LIS3DH_AXIS_Z]*obj->cali_sw[LIS3DH_AXIS_Z]; cali[LIS3DH_AXIS_X] += dat[LIS3DH_AXIS_X]; cali[LIS3DH_AXIS_Y] += dat[LIS3DH_AXIS_Y]; cali[LIS3DH_AXIS_Z] += dat[LIS3DH_AXIS_Z]; obj->cali_sw[LIS3DH_AXIS_X] += obj->cvt.sign[LIS3DH_AXIS_X]*dat[obj->cvt.map[LIS3DH_AXIS_X]]; obj->cali_sw[LIS3DH_AXIS_Y] += obj->cvt.sign[LIS3DH_AXIS_Y]*dat[obj->cvt.map[LIS3DH_AXIS_Y]]; obj->cali_sw[LIS3DH_AXIS_Z] += obj->cvt.sign[LIS3DH_AXIS_Z]*dat[obj->cvt.map[LIS3DH_AXIS_Z]]; } return err; } #if 0 static int <API key>(struct i2c_client *client) { u8 databuf[10]; int res = 0; /* memset(databuf, 0, sizeof(u8)*10); databuf[0] = LIS3DH_REG_DEVID; res = i2c_master_send(client, databuf, 0x1); if(res <= 0) { goto <API key>; } udelay(500); databuf[0] = 0x0; res = i2c_master_recv(client, databuf, 0x01); if(res <= 0) { goto <API key>; } if(databuf[0]!=LIS3DH_FIXED_DEVID) { return <API key>; } <API key>: if (res <= 0) { return LIS3DH_ERR_I2C; } */ return LIS3DH_SUCCESS; } #endif static int LIS3DH_SetPowerMode(struct i2c_client *client, bool enable) { u8 databuf[2]; int res = 0; u8 addr = LIS3DH_REG_CTL_REG1; struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); if(enable == sensor_power) { GSE_LOG("Sensor power status is newest!\n"); return LIS3DH_SUCCESS; } if(hwmsen_read_byte(client, addr, &databuf[0])) { GSE_ERR("read power ctl register err!\n"); return LIS3DH_ERR_I2C; } databuf[0] &= ~LIS3DH_MEASURE_MODE; if(enable == TRUE) { databuf[0] &= ~LIS3DH_MEASURE_MODE; } else { databuf[0] |= LIS3DH_MEASURE_MODE; } databuf[1] = databuf[0]; databuf[0] = LIS3DH_REG_CTL_REG1; res = i2c_master_send(client, databuf, 0x2); if(res <= 0) { GSE_LOG("set power mode failed!\n"); return LIS3DH_ERR_I2C; } else if(atomic_read(&obj->trace) & ADX_TRC_INFO) { GSE_LOG("set power mode ok %d!\n", databuf[1]); } sensor_power = enable; return LIS3DH_SUCCESS; } static int <API key>(struct i2c_client *client, u8 dataformat) { struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); u8 databuf[10]; u8 addr = LIS3DH_REG_CTL_REG4; int res = 0; memset(databuf, 0, sizeof(u8)*10); if(hwmsen_read_byte(client, addr, &databuf[0])) { GSE_ERR("read reg_ctl_reg1 register err!\n"); return LIS3DH_ERR_I2C; } databuf[0] &= ~0x30; databuf[0] |=dataformat; databuf[1] = databuf[0]; databuf[0] = LIS3DH_REG_CTL_REG4; res = i2c_master_send(client, databuf, 0x2); if(res <= 0) { return LIS3DH_ERR_I2C; } return <API key>(obj); } static int LIS3DH_SetBWRate(struct i2c_client *client, u8 bwrate) { u8 databuf[10]; u8 addr = LIS3DH_REG_CTL_REG1; int res = 0; memset(databuf, 0, sizeof(u8)*10); if(hwmsen_read_byte(client, addr, &databuf[0])) { GSE_ERR("read reg_ctl_reg1 register err!\n"); return LIS3DH_ERR_I2C; } databuf[0] &= ~0xF0; databuf[0] |= bwrate; databuf[1] = databuf[0]; databuf[0] = LIS3DH_REG_CTL_REG1; res = i2c_master_send(client, databuf, 0x2); if(res <= 0) { return LIS3DH_ERR_I2C; } return LIS3DH_SUCCESS; } //enalbe data ready interrupt static int LIS3DH_SetIntEnable(struct i2c_client *client, u8 intenable) { u8 databuf[10]; u8 addr = LIS3DH_REG_CTL_REG3; int res = 0; memset(databuf, 0, sizeof(u8)*10); if(hwmsen_read_byte(client, addr, &databuf[0])) { GSE_ERR("read reg_ctl_reg1 register err!\n"); return LIS3DH_ERR_I2C; } databuf[0] = 0x00; databuf[1] = databuf[0]; databuf[0] = LIS3DH_REG_CTL_REG3; res = i2c_master_send(client, databuf, 0x2); if(res <= 0) { return LIS3DH_ERR_I2C; } return LIS3DH_SUCCESS; } static int LIS3DH_Init(struct i2c_client *client, int reset_cali) { struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); int res = 0; /* res = <API key>(client); if(res != LIS3DH_SUCCESS) { return res; } */ // first clear reg1 res = hwmsen_write_byte(client,LIS3DH_REG_CTL_REG1,0x07); if(res != LIS3DH_SUCCESS) { return res; } res = LIS3DH_SetPowerMode(client, false); if(res != LIS3DH_SUCCESS) { return res; } res = LIS3DH_SetBWRate(client, LIS3DH_BW_100HZ);//400 or 100 no other choice if(res != LIS3DH_SUCCESS ) { return res; } res = <API key>(client, LIS3DH_RANGE_2G);//8g or 2G no oher choise if(res != LIS3DH_SUCCESS) { return res; } gsensor_gain.x = gsensor_gain.y = gsensor_gain.z = obj->reso->sensitivity; res = LIS3DH_SetIntEnable(client, false); if(res != LIS3DH_SUCCESS) { return res; } if(0 != reset_cali) { //reset calibration only in power on res = <API key>(client); if(res != LIS3DH_SUCCESS) { return res; } } #ifdef <API key> memset(&obj->fir, 0x00, sizeof(obj->fir)); #endif return LIS3DH_SUCCESS; } static int LIS3DH_ReadChipInfo(struct i2c_client *client, char *buf, int bufsize) { u8 databuf[10]; memset(databuf, 0, sizeof(u8)*10); if((NULL == buf)||(bufsize<=30)) { return -1; } if(NULL == client) { *buf = 0; return -2; } sprintf(buf, "LIS3DH Chip"); return 0; } static int <API key>(struct i2c_client *client, char *buf, int bufsize) { struct lis3dh_i2c_data *obj = (struct lis3dh_i2c_data*)i2c_get_clientdata(client); u8 databuf[20]; int acc[LIS3DH_AXES_NUM]; int res = 0; memset(databuf, 0, sizeof(u8)*10); if(NULL == buf) { return -1; } if(NULL == client) { *buf = 0; return -2; } if(sensor_power == FALSE) { res = LIS3DH_SetPowerMode(client, true); if(res) { GSE_ERR("Power on lis3dh error %d!\n", res); } msleep(20); } if((res = LIS3DH_ReadData(client, obj->data))) { GSE_ERR("I2C error: ret value=%d", res); return -3; } else { obj->data[LIS3DH_AXIS_X] += obj->cali_sw[LIS3DH_AXIS_X]; obj->data[LIS3DH_AXIS_Y] += obj->cali_sw[LIS3DH_AXIS_Y]; obj->data[LIS3DH_AXIS_Z] += obj->cali_sw[LIS3DH_AXIS_Z]; /*remap coordinate*/ acc[obj->cvt.map[LIS3DH_AXIS_X]] = obj->cvt.sign[LIS3DH_AXIS_X]*obj->data[LIS3DH_AXIS_X]; acc[obj->cvt.map[LIS3DH_AXIS_Y]] = obj->cvt.sign[LIS3DH_AXIS_Y]*obj->data[LIS3DH_AXIS_Y]; acc[obj->cvt.map[LIS3DH_AXIS_Z]] = obj->cvt.sign[LIS3DH_AXIS_Z]*obj->data[LIS3DH_AXIS_Z]; //GSE_LOG("Mapped gsensor data: %d, %d, %d!\n", acc[LIS3DH_AXIS_X], acc[LIS3DH_AXIS_Y], acc[LIS3DH_AXIS_Z]); //Out put the mg acc[LIS3DH_AXIS_X] = acc[LIS3DH_AXIS_X] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; acc[LIS3DH_AXIS_Y] = acc[LIS3DH_AXIS_Y] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; acc[LIS3DH_AXIS_Z] = acc[LIS3DH_AXIS_Z] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; sprintf(buf, "%04x %04x %04x", acc[LIS3DH_AXIS_X], acc[LIS3DH_AXIS_Y], acc[LIS3DH_AXIS_Z]); if(atomic_read(&obj->trace) & ADX_TRC_IOCTL)//atomic_read(&obj->trace) & ADX_TRC_IOCTL { GSE_LOG("gsensor data: %s!\n", buf); dumpReg(client); } } return 0; } static int LIS3DH_ReadRawData(struct i2c_client *client, char *buf) { struct lis3dh_i2c_data *obj = (struct lis3dh_i2c_data*)i2c_get_clientdata(client); int res = 0; if (!buf || !client) { return EINVAL; } if((res = LIS3DH_ReadData(client, obj->data))) { GSE_ERR("I2C error: ret value=%d", res); return EIO; } else { sprintf(buf, "%04x %04x %04x", obj->data[LIS3DH_AXIS_X], obj->data[LIS3DH_AXIS_Y], obj->data[LIS3DH_AXIS_Z]); } return 0; } static ssize_t show_chipinfo_value(struct device_driver *ddri, char *buf) { struct i2c_client *client = lis3dh_i2c_client; char strbuf[LIS3DH_BUFSIZE]; if(NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } LIS3DH_ReadChipInfo(client, strbuf, LIS3DH_BUFSIZE); return snprintf(buf, PAGE_SIZE, "%s\n", strbuf); } static ssize_t <API key>(struct device_driver *ddri, char *buf) { struct i2c_client *client = lis3dh_i2c_client; char strbuf[LIS3DH_BUFSIZE]; if(NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } <API key>(client, strbuf, LIS3DH_BUFSIZE); return snprintf(buf, PAGE_SIZE, "%s\n", strbuf); } static ssize_t show_cali_value(struct device_driver *ddri, char *buf) { struct i2c_client *client = lis3dh_i2c_client; struct lis3dh_i2c_data *obj; int err, len = 0, mul; int tmp[LIS3DH_AXES_NUM]; if(NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } obj = i2c_get_clientdata(client); if((err = <API key>(client, tmp))) { return -EINVAL; } else { mul = obj->reso->sensitivity/<API key>.sensitivity; len += snprintf(buf+len, PAGE_SIZE-len, "[HW ][%d] (%+3d, %+3d, %+3d) : (0x%02X, 0x%02X, 0x%02X)\n", mul, obj->offset[LIS3DH_AXIS_X], obj->offset[LIS3DH_AXIS_Y], obj->offset[LIS3DH_AXIS_Z], obj->offset[LIS3DH_AXIS_X], obj->offset[LIS3DH_AXIS_Y], obj->offset[LIS3DH_AXIS_Z]); len += snprintf(buf+len, PAGE_SIZE-len, "[SW ][%d] (%+3d, %+3d, %+3d)\n", 1, obj->cali_sw[LIS3DH_AXIS_X], obj->cali_sw[LIS3DH_AXIS_Y], obj->cali_sw[LIS3DH_AXIS_Z]); len += snprintf(buf+len, PAGE_SIZE-len, "[ALL] (%+3d, %+3d, %+3d) : (%+3d, %+3d, %+3d)\n", obj->offset[LIS3DH_AXIS_X]*mul + obj->cali_sw[LIS3DH_AXIS_X], obj->offset[LIS3DH_AXIS_Y]*mul + obj->cali_sw[LIS3DH_AXIS_Y], obj->offset[LIS3DH_AXIS_Z]*mul + obj->cali_sw[LIS3DH_AXIS_Z], tmp[LIS3DH_AXIS_X], tmp[LIS3DH_AXIS_Y], tmp[LIS3DH_AXIS_Z]); return len; } } static ssize_t store_cali_value(struct device_driver *ddri, const char *buf, size_t count) { struct i2c_client *client = lis3dh_i2c_client; int err, x, y, z; int dat[LIS3DH_AXES_NUM]; if(!strncmp(buf, "rst", 3)) { if((err = <API key>(client))) { GSE_ERR("reset offset err = %d\n", err); } } else if(3 == sscanf(buf, "0x%02X 0x%02X 0x%02X", &x, &y, &z)) { dat[LIS3DH_AXIS_X] = x; dat[LIS3DH_AXIS_Y] = y; dat[LIS3DH_AXIS_Z] = z; if((err = <API key>(client, dat))) { GSE_ERR("write calibration err = %d\n", err); } } else { GSE_ERR("invalid format\n"); } return count; } static ssize_t show_power_status(struct device_driver *ddri, char *buf) { struct i2c_client *client = lis3dh_i2c_client; struct lis3dh_i2c_data *obj; u8 data; if(NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } obj = i2c_get_clientdata(client); hwmsen_read_byte(client,LIS3DH_REG_CTL_REG1,&data); data &= 0x08; data = data>>3; return snprintf(buf, PAGE_SIZE, "%x\n", data); } static ssize_t show_firlen_value(struct device_driver *ddri, char *buf) { #ifdef <API key> struct i2c_client *client = lis3dh_i2c_client; struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); if(atomic_read(&obj->firlen)) { int idx, len = atomic_read(&obj->firlen); GSE_LOG("len = %2d, idx = %2d\n", obj->fir.num, obj->fir.idx); for(idx = 0; idx < len; idx++) { GSE_LOG("[%5d %5d %5d]\n", obj->fir.raw[idx][LIS3DH_AXIS_X], obj->fir.raw[idx][LIS3DH_AXIS_Y], obj->fir.raw[idx][LIS3DH_AXIS_Z]); } GSE_LOG("sum = [%5d %5d %5d]\n", obj->fir.sum[LIS3DH_AXIS_X], obj->fir.sum[LIS3DH_AXIS_Y], obj->fir.sum[LIS3DH_AXIS_Z]); GSE_LOG("avg = [%5d %5d %5d]\n", obj->fir.sum[LIS3DH_AXIS_X]/len, obj->fir.sum[LIS3DH_AXIS_Y]/len, obj->fir.sum[LIS3DH_AXIS_Z]/len); } return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&obj->firlen)); #else return snprintf(buf, PAGE_SIZE, "not support\n"); #endif } static ssize_t store_firlen_value(struct device_driver *ddri, const char *buf, size_t count) { #ifdef <API key> struct i2c_client *client = lis3dh_i2c_client; struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); int firlen; if(1 != sscanf(buf, "%d", &firlen)) { GSE_ERR("invallid format\n"); } else if(firlen > C_MAX_FIR_LENGTH) { GSE_ERR("exceeds maximum filter length\n"); } else { atomic_set(&obj->firlen, firlen); if(0 == firlen)//yucong fix build warning { atomic_set(&obj->fir_en, 0); } else { memset(&obj->fir, 0x00, sizeof(obj->fir)); atomic_set(&obj->fir_en, 1); } } #endif return count; } static ssize_t show_trace_value(struct device_driver *ddri, char *buf) { ssize_t res; struct lis3dh_i2c_data *obj = obj_i2c_data; if (obj == NULL) { GSE_ERR("i2c_data obj is null!!\n"); return 0; } res = snprintf(buf, PAGE_SIZE, "0x%04X\n", atomic_read(&obj->trace)); return res; } static ssize_t store_trace_value(struct device_driver *ddri, const char *buf, size_t count) { struct lis3dh_i2c_data *obj = obj_i2c_data; int trace; if (obj == NULL) { GSE_ERR("i2c_data obj is null!!\n"); return 0; } if(1 == sscanf(buf, "0x%x", &trace)) { atomic_set(&obj->trace, trace); } else { GSE_ERR("invalid content: '%s', length = %d\n", buf, count); } return count; } static ssize_t show_status_value(struct device_driver *ddri, char *buf) { ssize_t len = 0; struct lis3dh_i2c_data *obj = obj_i2c_data; if (obj == NULL) { GSE_ERR("i2c_data obj is null!!\n"); return 0; } if(obj->hw) { len += snprintf(buf+len, PAGE_SIZE-len, "CUST: %d %d (%d %d)\n", obj->hw->i2c_num, obj->hw->direction, obj->hw->power_id, obj->hw->power_vol); } else { len += snprintf(buf+len, PAGE_SIZE-len, "CUST: NULL\n"); } return len; } static DRIVER_ATTR(chipinfo, S_IRUGO, show_chipinfo_value, NULL); static DRIVER_ATTR(sensordata, S_IRUGO, <API key>, NULL); static DRIVER_ATTR(cali, S_IWUSR | S_IRUGO, show_cali_value, store_cali_value); static DRIVER_ATTR(power, S_IRUGO, show_power_status, NULL); static DRIVER_ATTR(firlen, S_IWUSR | S_IRUGO, show_firlen_value, store_firlen_value); static DRIVER_ATTR(trace, S_IWUSR | S_IRUGO, show_trace_value, store_trace_value); static DRIVER_ATTR(status, S_IRUGO, show_status_value, NULL); static struct driver_attribute *lis3dh_attr_list[] = { &<API key>, /*chip information*/ &<API key>, /*dump sensor data*/ &driver_attr_cali, /*show calibration data*/ &driver_attr_power, /*show power reg*/ &driver_attr_firlen, /*filter length: 0: disable, others: enable*/ &driver_attr_trace, /*trace log*/ &driver_attr_status, }; static int lis3dh_create_attr(struct device_driver *driver) { int idx, err = 0; int num = (int)(sizeof(lis3dh_attr_list)/sizeof(lis3dh_attr_list[0])); if (driver == NULL) { return -EINVAL; } for(idx = 0; idx < num; idx++) { if((err = driver_create_file(driver, lis3dh_attr_list[idx]))) { GSE_ERR("driver_create_file (%s) = %d\n", lis3dh_attr_list[idx]->attr.name, err); break; } } return err; } static int lis3dh_delete_attr(struct device_driver *driver) { int idx ,err = 0; int num = (int)(sizeof(lis3dh_attr_list)/sizeof(lis3dh_attr_list[0])); if(driver == NULL) { return -EINVAL; } for(idx = 0; idx < num; idx++) { driver_remove_file(driver, lis3dh_attr_list[idx]); } return err; } int lis3dh_operate(void* self, uint32_t command, void* buff_in, int size_in, void* buff_out, int size_out, int* actualout) { int err = 0; int value, sample_delay; struct lis3dh_i2c_data *priv = (struct lis3dh_i2c_data*)self; hwm_sensor_data* gsensor_data; char buff[LIS3DH_BUFSIZE]; //GSE_FUN(f); switch (command) { case SENSOR_DELAY: if((buff_in == NULL) || (size_in < sizeof(int))) { GSE_ERR("Set delay parameter error!\n"); err = -EINVAL; } else { value = *(int *)buff_in; if(value <= 5) { sample_delay = LIS3DH_BW_200HZ; } else if(value <= 10) { sample_delay = ~LIS3DH_BW_100HZ; } else { sample_delay = ~LIS3DH_BW_50HZ; } err = LIS3DH_SetBWRate(priv->client, sample_delay); if(err != LIS3DH_SUCCESS ) //0x2C->BW=100Hz { GSE_ERR("Set delay parameter error!\n"); } if(value >= 50) { atomic_set(&priv->filter, 0); } else { priv->fir.num = 0; priv->fir.idx = 0; priv->fir.sum[LIS3DH_AXIS_X] = 0; priv->fir.sum[LIS3DH_AXIS_Y] = 0; priv->fir.sum[LIS3DH_AXIS_Z] = 0; atomic_set(&priv->filter, 1); } } break; case SENSOR_ENABLE: if((buff_in == NULL) || (size_in < sizeof(int))) { GSE_ERR("Enable sensor parameter error!\n"); err = -EINVAL; } else { value = *(int *)buff_in; GSE_LOG("enable value=%d, sensor_power =%d\n",value,sensor_power); if(((value == 0) && (sensor_power == false)) ||((value == 1) && (sensor_power == true))) { GSE_LOG("Gsensor device have updated!\n"); } else { err = LIS3DH_SetPowerMode( priv->client, !sensor_power); } } break; case SENSOR_GET_DATA: if((buff_out == NULL) || (size_out< sizeof(hwm_sensor_data))) { GSE_ERR("get sensor data parameter error!\n"); err = -EINVAL; } else { gsensor_data = (hwm_sensor_data *)buff_out; <API key>(priv->client, buff, LIS3DH_BUFSIZE); sscanf(buff, "%x %x %x", &gsensor_data->values[0], &gsensor_data->values[1], &gsensor_data->values[2]); gsensor_data->status = <API key>; gsensor_data->value_divide = 1000; } break; default: GSE_ERR("gsensor operate function no this parameter %d!\n", command); err = -1; break; } return err; } static int lis3dh_open(struct inode *inode, struct file *file) { file->private_data = lis3dh_i2c_client; if(file->private_data == NULL) { GSE_ERR("null pointer!!\n"); return -EINVAL; } return nonseekable_open(inode, file); } static int lis3dh_release(struct inode *inode, struct file *file) { file->private_data = NULL; return 0; } //static int lis3dh_ioctl(struct inode *inode, struct file *file, unsigned int cmd, // unsigned long arg) static long <API key>(struct file *file, unsigned int cmd, unsigned long arg) { struct i2c_client *client = (struct i2c_client*)file->private_data; struct lis3dh_i2c_data *obj = (struct lis3dh_i2c_data*)i2c_get_clientdata(client); char strbuf[LIS3DH_BUFSIZE]; void __user *data; SENSOR_DATA sensor_data; long err = 0; int cali[3]; //GSE_FUN(f); if(_IOC_DIR(cmd) & _IOC_READ) { err = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd)); } else if(_IOC_DIR(cmd) & _IOC_WRITE) { err = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd)); } if(err) { GSE_ERR("access error: %08X, (%2d, %2d)\n", cmd, _IOC_DIR(cmd), _IOC_SIZE(cmd)); return -EFAULT; } switch(cmd) { case GSENSOR_IOCTL_INIT: LIS3DH_Init(client, 0); break; case <API key>: data = (void __user *) arg; if(data == NULL) { err = -EINVAL; break; } LIS3DH_ReadChipInfo(client, strbuf, LIS3DH_BUFSIZE); if(copy_to_user(data, strbuf, strlen(strbuf)+1)) { err = -EFAULT; break; } break; case <API key>: data = (void __user *) arg; if(data == NULL) { err = -EINVAL; break; } <API key>(client, strbuf, LIS3DH_BUFSIZE); if(copy_to_user(data, strbuf, strlen(strbuf)+1)) { err = -EFAULT; break; } break; case <API key>: data = (void __user *) arg; if(data == NULL) { err = -EINVAL; break; } if(copy_to_user(data, &gsensor_gain, sizeof(GSENSOR_VECTOR3D))) { err = -EFAULT; break; } break; case <API key>: data = (void __user *) arg; if(data == NULL) { err = -EINVAL; break; } if(copy_to_user(data, &gsensor_offset, sizeof(GSENSOR_VECTOR3D))) { err = -EFAULT; break; } break; case <API key>: data = (void __user *) arg; if(data == NULL) { err = -EINVAL; break; } LIS3DH_ReadRawData(client, strbuf); if(copy_to_user(data, &strbuf, strlen(strbuf)+1)) { err = -EFAULT; break; } break; case <API key>: data = (void __user*)arg; if(data == NULL) { err = -EINVAL; break; } if(copy_from_user(&sensor_data, data, sizeof(sensor_data))) { err = -EFAULT; break; } if(atomic_read(&obj->suspend)) { GSE_ERR("Perform calibration in suspend state!!\n"); err = -EINVAL; } else { cali[LIS3DH_AXIS_X] = sensor_data.x * obj->reso->sensitivity / GRAVITY_EARTH_1000; cali[LIS3DH_AXIS_Y] = sensor_data.y * obj->reso->sensitivity / GRAVITY_EARTH_1000; cali[LIS3DH_AXIS_Z] = sensor_data.z * obj->reso->sensitivity / GRAVITY_EARTH_1000; err = <API key>(client, cali); } break; case <API key>: err = <API key>(client); break; case <API key>: data = (void __user*)arg; if(data == NULL) { err = -EINVAL; break; } if((err = <API key>(client, cali))) { break; } sensor_data.x = cali[LIS3DH_AXIS_X] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; sensor_data.y = cali[LIS3DH_AXIS_Y] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; sensor_data.z = cali[LIS3DH_AXIS_Z] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; if(copy_to_user(data, &sensor_data, sizeof(sensor_data))) { err = -EFAULT; break; } break; default: GSE_ERR("unknown IOCTL: 0x%08x\n", cmd); err = -ENOIOCTLCMD; break; } return err; } static struct file_operations lis3dh_fops = { .owner = THIS_MODULE, .open = lis3dh_open, .release = lis3dh_release, //.ioctl = lis3dh_ioctl, .unlocked_ioctl = <API key>, }; static struct miscdevice lis3dh_device = { .minor = MISC_DYNAMIC_MINOR, .name = "gsensor", .fops = &lis3dh_fops, }; #ifndef <API key> static int lis3dh_suspend(struct i2c_client *client, pm_message_t msg) { struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); int err = 0; u8 dat; GSE_FUN(); if(msg.event == PM_EVENT_SUSPEND) { if(obj == NULL) { GSE_ERR("null pointer!!\n"); return -EINVAL; } //read old data if ((err = hwmsen_read_byte(client, LIS3DH_REG_CTL_REG1, &dat))) { GSE_ERR("write data format fail!!\n"); return err; } dat = dat&0b10111111; atomic_set(&obj->suspend, 1); if(err = hwmsen_write_byte(client, LIS3DH_REG_CTL_REG1, dat)) { GSE_ERR("write power control fail!!\n"); return err; } LIS3DH_power(obj->hw, 0); } return err; } static int lis3dh_resume(struct i2c_client *client) { struct lis3dh_i2c_data *obj = i2c_get_clientdata(client); //int err; GSE_FUN(); if(obj == NULL) { GSE_ERR("null pointer!!\n"); return -EINVAL; } LIS3DH_power(obj->hw, 1); #if 0 mdelay(30);//yucong add for fix g sensor resume issue if(err = LIS3DH_Init(client, 0)) { GSE_ERR("initialize client fail!!\n"); return err; } #endif atomic_set(&obj->suspend, 0); return 0; } #else /*<API key> is defined*/ static void <API key>(struct early_suspend *h) { struct lis3dh_i2c_data *obj = container_of(h, struct lis3dh_i2c_data, early_drv); int err; GSE_FUN(); if(obj == NULL) { GSE_ERR("null pointer!!\n"); return; } atomic_set(&obj->suspend, 1); /* if(err = hwmsen_write_byte(obj->client, <API key>, 0x00)) { GSE_ERR("write power control fail!!\n"); return; } */ if((err = LIS3DH_SetPowerMode(obj->client, false))) { GSE_ERR("write power control fail!!\n"); return; } sensor_power = false; LIS3DH_power(obj->hw, 0); } static void lis3dh_late_resume(struct early_suspend *h) { struct lis3dh_i2c_data *obj = container_of(h, struct lis3dh_i2c_data, early_drv); //int err; GSE_FUN(); if(obj == NULL) { GSE_ERR("null pointer!!\n"); return; } LIS3DH_power(obj->hw, 1); #if 0 mdelay(30);//yucong add for fix g sensor resume issue if((err = LIS3DH_Init(obj->client, 0))) { GSE_ERR("initialize client fail!!\n"); return; } #endif atomic_set(&obj->suspend, 0); } #endif /*<API key>*/ /* static int lis3dh_i2c_detect(struct i2c_client *client, int kind, struct i2c_board_info *info) { strcpy(info->type, LIS3DH_DEV_NAME); return 0; } */ static int lis3dh_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_client *new_client; struct lis3dh_i2c_data *obj; struct hwmsen_object sobj; int err = 0; GSE_FUN(); if(!(obj = kzalloc(sizeof(*obj), GFP_KERNEL))) { err = -ENOMEM; goto exit; } memset(obj, 0, sizeof(struct lis3dh_i2c_data)); obj->hw = <API key>(); if((err = hwmsen_get_convert(obj->hw->direction, &obj->cvt))) { GSE_ERR("invalid direction: %d\n", obj->hw->direction); goto exit; } obj_i2c_data = obj; obj->client = client; new_client = obj->client; i2c_set_clientdata(new_client,obj); atomic_set(&obj->trace, 0); atomic_set(&obj->suspend, 0); #ifdef <API key> if(obj->hw->firlen > C_MAX_FIR_LENGTH) { atomic_set(&obj->firlen, C_MAX_FIR_LENGTH); } else { atomic_set(&obj->firlen, obj->hw->firlen); } if(atomic_read(&obj->firlen) > 0) { atomic_set(&obj->fir_en, 1); } #endif lis3dh_i2c_client = new_client; if((err = LIS3DH_Init(new_client, 1))) { goto exit_init_failed; } if((err = misc_register(&lis3dh_device))) { GSE_ERR("lis3dh_device register failed\n"); goto <API key>; } if((err = lis3dh_create_attr(&(lis3dh_init_info.platform_diver_addr->driver)))) { GSE_ERR("create attribute err = %d\n", err); goto <API key>; } sobj.self = obj; sobj.polling = 1; sobj.sensor_operate = lis3dh_operate; if((err = hwmsen_attach(ID_ACCELEROMETER, &sobj))) { GSE_ERR("attach fail = %d\n", err); goto exit_kfree; } #ifdef <API key> obj->early_drv.level = <API key> - 1, obj->early_drv.suspend = <API key>, obj->early_drv.resume = lis3dh_late_resume, <API key>(&obj->early_drv); #endif GSE_LOG("%s: OK\n", __func__); lis3dh_init_flag = 0; return 0; <API key>: misc_deregister(&lis3dh_device); <API key>: exit_init_failed: //i2c_detach_client(new_client); exit_kfree: kfree(obj); exit: GSE_ERR("%s: err = %d\n", __func__, err); lis3dh_init_flag = -1; return err; } static int lis3dh_i2c_remove(struct i2c_client *client) { int err = 0; if((err = lis3dh_delete_attr(&(lis3dh_init_info.platform_diver_addr->driver)))) { GSE_ERR("lis3dh_delete_attr fail: %d\n", err); } if((err = misc_deregister(&lis3dh_device))) { GSE_ERR("misc_deregister fail: %d\n", err); } if((err = hwmsen_detach(ID_ACCELEROMETER))) lis3dh_i2c_client = NULL; <API key>(client); kfree(i2c_get_clientdata(client)); return 0; } #if 0 static int lis3dh_probe(struct platform_device *pdev) { struct acc_hw *hw = get_cust_acc_hw(); GSE_FUN(); LIS3DH_power(hw, 1); //lis3dh_force[0] = hw->i2c_num; if(i2c_add_driver(&lis3dh_i2c_driver)) { GSE_ERR("add driver error\n"); return -1; } return 0; } static int lis3dh_remove(struct platform_device *pdev) { struct acc_hw *hw = get_cust_acc_hw(); GSE_FUN(); LIS3DH_power(hw, 0); i2c_del_driver(&lis3dh_i2c_driver); return 0; } static struct platform_driver <API key> = { .probe = lis3dh_probe, .remove = lis3dh_remove, .driver = { .name = "gsensor", .owner = THIS_MODULE, } }; #endif static int lis3dh_remove(void) { struct acc_hw *hw = <API key>(); GSE_FUN(); LIS3DH_power(hw, 0); i2c_del_driver(&lis3dh_i2c_driver); return 0; } static int lis3dh_local_init(void) { struct acc_hw *hw = <API key>(); GSE_FUN(); LIS3DH_power(hw, 1); if(i2c_add_driver(&lis3dh_i2c_driver)) { GSE_ERR("add driver error\n"); return -1; } if(-1 == lis3dh_init_flag) { return -1; } return 0; } static int __init lis3dh_init(void) { GSE_FUN(); <API key>(0, &i2c_LIS3DH, 1); hwmsen_gsensor_add(&lis3dh_init_info); #if 0 if(<API key>(&<API key>)) { GSE_ERR("failed to register driver"); return -ENODEV; } #endif return 0; } static void __exit lis3dh_exit(void) { GSE_FUN(); //<API key>(&<API key>); } module_init(lis3dh_init); module_exit(lis3dh_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("LIS3DH I2C driver"); MODULE_AUTHOR("Chunlei.Wang@mediatek.com");
import sys import time import logging from socketio import socketio_manage from socketio.mixins import BroadcastMixin from socketio.namespace import BaseNamespace from DataAggregation.webdata_aggregator import <API key> logger = logging.getLogger(__name__) std_out_logger = logging.StreamHandler(sys.stdout) logger.addHandler(std_out_logger) def broadcast_msg(server, ns_name, event, *args): pkt = dict(type="event", name=event, args=args, endpoint=ns_name) for sessid, socket in server.sockets.iteritems(): socket.send_packet(pkt) def workshops_monitor(server): sizes = [] workshops = <API key>() for w in workshops: tmp = [w.workshopName, w.q.qsize()] sizes.append(tmp) broadcast_msg(server, '', "sizes", tmp) while True: logger.info("Participants viewing frontend:" + str(len(server.sockets))) workshops_available = [] curr_workshops = <API key>() for w in curr_workshops: workshops_available.append([w.workshopName, w.q.qsize()]) wq = filter(lambda x: x[0] == w.workshopName, sizes)[0] if wq[1] != w.q.qsize(): wq[1] = w.q.qsize() logging.info("client_updater: New update being pushed to clients: " + str(wq)) broadcast_msg(server, '', 'sizes', wq) logger.info("Workshops available:" + str(workshops_available)) time.sleep(1) class RequestHandlerApp(object): def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith('/socket.io'): socketio_manage(environ, {'': QueueStatusHandler}) class QueueStatusHandler(BaseNamespace, BroadcastMixin): def on_connect(self): sizes = [] workshops = <API key>() for w in workshops: tmp = [w.workshopName, w.q.qsize()] sizes.append(tmp) self.emit('sizes', tmp)