answer
stringlengths
15
1.25M
<?php function login_user ($user, $pswd) { $ldaphost = "<fqdn of ldap host"; $ldapdomain = "<some ldap domain>"; $ldap_user_group = "<ldap group that can access>"; $ldap = ldap_connect($ldaphost, 389) or die("Could not connect to AD!"); ldap_set_option($ldap, <API key>, 3); ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); // verify user and password if($bd = @ldap_bind($ldap, "$user@$ldapdomain", $pswd)) { // valid // check for proper group $dn = "dc=1dc, dc=com"; $attrs = array("memberof"); $filter = "sAMAccountName=$user"; $result = ldap_search($ldap, $dn, $filter, $attrs) or exit ("Unable to search LDAP server"); $entries = ldap_get_entries($ldap, $result); ldap_unbind($ldap); // check group foreach($entries[0]['memberof'] as $ldapgrp) { if (strpos($ldapgrp, $ldap_user_group)) $access = 1; } if ($access !=0) { // session variables $_SESSION['user'] = $user; $_SESSION['pswd'] = $pswd; $_SESSION['access'] = $access; return true; } else { // deny return false; } } else { // bad juju return false; } } ?>
#include <iostream> #include "LinkedList.h" #include <assert.h> using namespace std; void LinkedList::printAllLLElements(void) { SinglyLinkedList *temp; if(head == NULL) { cout << endl << "No elements."<< endl; return; } temp = head; do { cout << temp->data << endl; temp = temp->next; } while (NULL != temp); } LinkedList::LinkedList(void) { head = NULL; } /** * @brief ...Adds element at the end of the list. * * @param data ... * @return STATUS */ STATUS LinkedList::appendNode(int data) { //create new node SinglyLinkedList *newNode = new SinglyLinkedList(); newNode->data = data; newNode->next = NULL; if(head == NULL) { head = newNode; return SUCCESS; } else { //find last node SinglyLinkedList *lastNodePtr = findLastNode(); if(lastNodePtr == NULL) { //weird, both head and last node are null. return FAILURE; } else { lastNodePtr->next = newNode; return SUCCESS; } } } /** * * @param data * @return */ STATUS LinkedList::addNodeAtHead(int data) { //create new node SinglyLinkedList *newNode = new SinglyLinkedList(); newNode->data = data; newNode->next = head; head = newNode; return SUCCESS; } /** * @brief ... * * @param prevNode ... * @param data ... * @return STATUS */ STATUS LinkedList::addNodeAfter(SinglyLinkedList *prevNode, int data) { if(NULL == prevNode ) { return FAILURE; } //create new node SinglyLinkedList *newNode = new SinglyLinkedList(); newNode->data = data; newNode->next = prevNode->next; prevNode->next = newNode; return SUCCESS; } /** * * @param nodePtr * @return */ STATUS LinkedList::deleteNode(SinglyLinkedList *nodePtr) { int bFound = 0; if(NULL == head) { return FAILURE; } SinglyLinkedList *temp = head, *prev; if(head == nodePtr) { head = head->next; delete(temp); return SUCCESS; } while(temp != nodePtr && temp != NULL) { prev = temp; temp = temp->next; bFound++; } if(bFound) { prev->next = temp->next; delete(temp); return SUCCESS; } return FAILURE; } /** * * @param key * @return */ STATUS LinkedList::deleteNodeWithKey(int key) { if(NULL == head) { return FAILURE; } SinglyLinkedList *temp=head, *prev; int bFound = 0; if(head->data == key) { head = head->next; delete(temp); return SUCCESS; } while(NULL != temp && bFound == 0) { prev = temp; temp = temp->next; if(temp->data == key) { bFound++;// can be used for deleting all key nodes. //need to take care of integer wrap-around for a very large linked list. cout << "Found: "<< temp->data; prev->next = temp->next; delete(temp); } } if(bFound == 0) { return FAILURE; } else { return SUCCESS; } } /** * * @return */ SinglyLinkedList* LinkedList::findLastNode() { if(head == NULL) { return NULL; } SinglyLinkedList *temp = head; while(temp->next != NULL) { temp = temp->next; } return temp; } LinkedList::~LinkedList(void) { emptyTheList(); head = NULL; cout <<"Done" <<endl; } /** * Assumes there's no loop within the linked List. */ void LinkedList::emptyTheList(void) { SinglyLinkedList *temp = head; //first break the loop detectLoop(TRUE); while(head != NULL) { head = head->next; delete temp; temp = head; } } /** * * @return */ SinglyLinkedList* LinkedList::getHead() { return head; } /** * return data at nth Node. N (index) starts at 0. * @param index * @return */ int LinkedList::getNthNode(int index) { int count = 0; SinglyLinkedList *temp = head; while(count < index && temp != NULL) { temp = temp->next; count++; } //cout <<"Count::"<< count<<endl; if(count == index && temp != NULL) { return temp->data; } assert(0); } /** * return pointer to nth Node. N (index) starts at 0. * @param index * @return */ SinglyLinkedList* LinkedList::getNthNodeRef(int index) { int count = 0; SinglyLinkedList *temp = head; while(count < index && temp != NULL) { temp = temp->next; count++; } //cout <<"Count::"<< count<<endl; if(count == index && temp != NULL) { return temp; } assert(0); } /** * Function to get the middle of the linked list * */ void LinkedList::printMiddle() { if(head == NULL) { return; } SinglyLinkedList *slowPtr = head, *fastPtr=head; if(head->next != NULL) { //2 or more elements. fastPtr = head->next->next; slowPtr = slowPtr->next; } else { //only 1 elements in the list. print 1st and exit. cout << slowPtr->data <<endl; return; } //slowPtr = slowPtr->next; while(fastPtr !=NULL) { if(fastPtr->next != NULL) { fastPtr = fastPtr->next->next; slowPtr = slowPtr->next; } } cout << slowPtr->data; } /** * Counts the no. of occurences of a node * (search_for) in a linked list (head) * @param search_for * @return */ int LinkedList::countOccurrences( int search_for) { SinglyLinkedList* current = head; int count = 0; while (current != NULL) { if (current->data == search_for) count++; current = current->next; } return count; } /** * FLoyd's Cycle Algorithm: Detects point of loop too. * @param bBreakTheLoop: if TRUE, break the loop and * point the loop node to NULL. * @return */ int LinkedList::detectLoop(int bBreakTheLoop = FALSE) { SinglyLinkedList *slowPtr = head, *fastPtr = head; while(fastPtr != NULL && fastPtr->next != NULL && slowPtr) { fastPtr = fastPtr->next->next; slowPtr = slowPtr->next; if(slowPtr == fastPtr) { if(bBreakTheLoop) { slowPtr->next = NULL; } return TRUE; } } return FALSE; } /** * Function to reverse the linked list Note that this * function may change the head * @param head_ref: pass head to reverse entire list. */ void LinkedList::reverse(SinglyLinkedList** head_ref) { SinglyLinkedList* prev = NULL; SinglyLinkedList* current = *head_ref; cout << "New list Before:\n" <<endl; while(current != NULL) { cout << "Original list: " << current->data << endl; current = current->next; } current = *head_ref; SinglyLinkedList* next; while (current != NULL) { next = current->next; cout << "courr data:" <<current->data << " next:"<< endl; current->next = prev; prev = current; current = next; } *head_ref = prev; //print list after reversing current = *head_ref; cout << "New list After: \n" <<endl; while(current != NULL) { cout << "Reversed list: " << current->data << endl; current = current->next; } } /** * * @param head1 * @param head2 */ BOOL LinkedList::compareLists(SinglyLinkedList *head1, SinglyLinkedList *head2) { SinglyLinkedList *temp1=head1, *temp2=head2; while(temp1 && temp2) { if(temp1->data == temp2->data) { temp1 = temp1->next; temp2 = temp2->next; } else { return FALSE; } } /* Both are empty reurn 1*/ if (temp1 == NULL && temp2 == NULL) return TRUE; /* Will reach here when one is NULL and other is not */ return FALSE; } /** * * @param nodeData */ void LinkedList::sortedInsert(int nodeData) { SinglyLinkedList *temp, *newNode = new SinglyLinkedList; newNode->data = nodeData; if(head == NULL || head->data > nodeData) { newNode->next = head; head = newNode; } else { temp = head; while(temp->next && temp->next->data < nodeData) { temp = temp->next; } newNode->next = temp->next; temp->next = newNode; } } /** * Assumes there's no loop in the Linked list. * @return */ int LinkedList::countNodes() { SinglyLinkedList *temp = head; int count = 0; while(temp != NULL) { count++; temp = temp->next; } return count; } /** * @brief ...Helper fn to update the head of the linked list object. Caller fn needs to * take care to delete any nodes not accessible from this new head. * * @param newHead ...Pointer to new head. Must not be NULL. * @return STATUS */ STATUS LinkedList::updateHead(SinglyLinkedList *newHead) { STATUS retVal = FAILURE; this->head = newHead; retVal = SUCCESS; return retVal; } /** * @brief ...new LL from 2 sorted lists. Source lists are not modified. * * @param head1 ...head of source list 1. * @param head2 ...head of source list 2. */ LinkedList::LinkedList(SinglyLinkedList *head1, SinglyLinkedList *head2) { SinglyLinkedList *temp1 = head1, *temp2 = head2; while(temp1 || temp2) { if(temp1 && temp2) { if(temp1->data < temp2->data) { appendNode(temp1->data); temp1 = temp1->next; } else { appendNode(temp2->data); temp2 = temp2->next; } } else if(temp1) { appendNode(temp1->data); temp1 = temp1->next; } else { appendNode(temp2->data); temp2 = temp2->next; } } } BOOL LinkedList::operator==( LinkedList& otherList){ SinglyLinkedList* t1=head; const SinglyLinkedList* t2 = otherList.getHead(); BOOL retVal = TRUE; while(t1 && t2){ if(t1->data == t2->data){ t1 = t1->next; t2 = t2->next; }else{ cout << "Data mismatch"<<endl; retVal = FALSE; break; } } if((t1 && !t2) || (t2 && !t1)) { //if either list has extra elements retVal = FALSE; cout << "Length mismatch"<<endl; } return retVal; }
/* * $Id: hbsha1.c 9724 2012-10-02 10:36:35Z andijahja $ */ #include "hbapi.h" #include "sha1.h" HB_FUNC( HB_SHA1 ) { sha1_byte digest[ SHA1_DIGEST_LENGTH ]; SHA_CTX ctx; hb_SHA1_Init( &ctx ); #if ULONG_MAX > UINT_MAX { const char * buffer = hb_parcx( 1 ); ULONG nCount = hb_parclen( 1 ); ULONG nDone = 0; while( nCount ) { UINT uiChunk; if( nCount > ( ULONG ) UINT_MAX ) { uiChunk = UINT_MAX; nCount -= ( ULONG ) uiChunk; } else { uiChunk = ( UINT ) nCount; nCount = 0; } hb_SHA1_Update( &ctx, buffer + nDone, uiChunk ); nDone += ( ULONG ) uiChunk; } } #else hb_SHA1_Update( &ctx, hb_parcx( 1 ), ( UINT ) hb_parclen( 1 ) ); #endif hb_SHA1_Final( digest, &ctx ); if( ! hb_parl( 2 ) ) { char hex[ ( sizeof( digest ) * 2 ) + 1 ]; hb_strtohex( ( char * ) digest, sizeof( digest ), hex ); hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 ); } else hb_retclen( ( char * ) digest, sizeof( digest ) ); }
from django.apps import AppConfig class DataimportConfig(AppConfig): name = "intranet.apps.dataimport"
<!DOCTYPE HTML PUBLIC "- <!--NewPage <HTML> <HEAD> <!-- Generated by javadoc (build 1.5.0_08) on Tue Jun 03 16:15:26 GMT-05:00 2008 --> <TITLE> Uses of Class soot.dava.toolkits.base.AST.transformations.<API key> (Soot API) </TITLE> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { parent.document.title="Uses of Class soot.dava.toolkits.base.AST.transformations.<API key> (Soot API)"; } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <A NAME="navbar_top"></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <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="../../../../../../../soot/dava/toolkits/base/AST/transformations/<API key>.html" title="class in soot.dava.toolkits.base.AST.transformations"><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?soot/dava/toolkits/base/AST/transformations//<API key>.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="<API key>.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <HR> <CENTER> <H2> <B>Uses of Class<br>soot.dava.toolkits.base.AST.transformations.<API key></B></H2> </CENTER> No usage of soot.dava.toolkits.base.AST.transformations.<API key> <P> <HR> <A NAME="navbar_bottom"></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="<API key>"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <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="../../../../../../../soot/dava/toolkits/base/AST/transformations/<API key>.html" title="class in soot.dava.toolkits.base.AST.transformations"><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?soot/dava/toolkits/base/AST/transformations//<API key>.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="<API key>.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <HR> </BODY> </HTML>
#ifndef H_PCM_AUDIO #define H_PCM_AUDIO #include "pes.h" // General defines of start codes etc. #define PCM_ENDIAN_LITTLE 0 #define PCM_ENDIAN_BIG 1 #define <API key> 1 Exploded copy of the pcm audio frame header. typedef struct <API key> { } <API key>; typedef struct <API key> { unsigned int CompressionCode; unsigned int ChannelCount; unsigned int SampleRate; unsigned int BytesPerSecond; unsigned int BlockAlign; unsigned int BitsPerSample; unsigned int DataEndianness; } <API key>; #define <API key> "<API key>" #define <API key> {<API key>, BufferDataTypeBase, <API key>, 4, 0, true, true, sizeof(<API key>)} Meta-data unique to Pcm audio. typedef struct <API key> { The bit rate of the frame unsigned int BitRate; Size of the compressed frame (in bytes) unsigned int FrameSize; } <API key>; #define <API key> "<API key>" #define <API key> {<API key>, BufferDataTypeBase, <API key>, 4, 0, true, true, sizeof(<API key>)} #endif /* H_PCM_AUDIO_ */
// Fanart.h #if !defined(FANART_H_) #define FANART_H_ #include "StdString.h" #include <vector> #pragma once /brief CFanart is the core of fanart support and contains all fanart data for a specific show CFanart stores all data related to all available fanarts for a given TV show and provides functions required to manipulate and access that data. In order to provide an interface between the fanart data and the XBMC database, all data is stored internally it its own form, as well as packed into an XML formatted CStdString stored in the member variable m_xml. Information on multiple fanarts for a given show is stored, but XBMC only cares about the very first fanart stored. These interfaces provide a means to access the data in that first fanart record, as well as to set which fanart is the first record. Externally, all XBMC needs to care about is getting and setting that first record. Everything else is maintained internally by CFanart. This point is key to using the interface properly. class CFanart { public: Standard constructor doesn't need to do anything CFanart(); Takes the internal fanart data and packs it into an XML formatted string in m_xml \sa m_xml void Pack(); Takes the XML formatted string m_xml and unpacks the fanart data contained into the internal data \return A boolean indicating success or failure \sa m_xml bool Unpack(); Retrieves the fanart full res image URL \param index - index of image to retrieve (defaults to 0) \return A CStdString containing the full URL to the full resolution fanart image CStdString GetImageURL(unsigned int index = 0) const; Retrieves the fanart preview image URL, or full res image URL if that doesn't exist \param index - index of image to retrieve (defaults to 0) \return A CStdString containing the full URL to the full resolution fanart image CStdString GetPreviewURL(unsigned int index = 0) const; Used to return a specified fanart theme color value \param index: 0 based index of the color to retrieve. A fanart theme contains 3 colors, indices 0-2, arranged from darkest to lightest. const CStdString GetColor(unsigned int index) const; Sets a particular fanart to be the "primary" fanart, or in other words, sets which fanart is actually used by XBMC This is the one of the only instances in the public interface where there is any hint that more than one fanart exists, but its by neccesity. \param index: 0 based index of which fanart to set as the primary fanart \return A boolean value indicating success or failure. This should only return false if the specified index is not a valid fanart bool SetPrimaryFanart(unsigned int index); Returns how many fanarts are stored \return An integer indicating how many fanarts are stored in the class. Fanart indices are 0 to (GetNumFanarts() - 1) unsigned int GetNumFanarts(); m_xml contains an XML formatted string which is all fanart packed into one string. This string is the "interface" as it were to the XBMC database, and MUST be kept in sync with the rest of the class. Therefore anytime this string is changed, the change should be followed up by a call to CFanart::UnPack(). This XML formaytted string is also the interface used to pass the fanart data from the scraper to CFanart. CStdString m_xml; private: static const unsigned int max_fanart_colors; Parse various color formats as returned by the sites scraped into a format we recognize Supported Formats: * The TVDB RGB Int Triplets, pipe seperate with leading/trailing pipes "|68,69,59|69,70,58|78,78,68|" * XBMC ARGB Hexadecimal string comma seperated "FFFFFFFF,DDDDDDDD,AAAAAAAA" \param colorsIn: CStdString containing a string of colors in some format to be converted \param colorsOut: XBMC ARGB Hexadecimal string comma seperated "FFFFFFFF,DDDDDDDD,AAAAAAAA" \return boolean indicating success or failure. bool ParseColors(const CStdString &colorsIn, CStdString &colorsOut); struct SFanartData { CStdString strImage; CStdString strResolution; CStdString strColors; CStdString strPreview; }; std::vector that stores all our fanart data std::vector<SFanartData> m_fanart; CStdString m_url; }; #endif
f = open("log.adv2", "w") def init(): pass def disp(text): """ use: to display text and to log what is displayed How to: disp(text to display) """ f.write("DISPLAY: " + text) print text def askq(quest): """ use: to ask a question and log it How to: var_to_set = askq(question to ask) """ feedback = raw_input (quest) f.write("QUESTION: " + quest + " With answer: " + feedback) def log(logid, logdisp): f.write (logid + ": " + logdisp) def stop(): import shutil shutil.rmtree("save") disp("The system will stop NOW")
<html> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="assets/stylesheet-sa.css" /> </head> <body> <div class='intro_bhashya' id='MK_C01_I10'>इति । </div> <div class='verse' id='MK_C01_V12' type='mantra'> <div class='versetext'>अमात्रश्चतुर्थोऽव्यवहार्यः प्रपञ्चोपशमः शिवोऽद्वैत एवमोङ्कार आत्मैव संविशत्यात्मनात्मानं य एवं वेद ॥ १२ ॥ </div> <div class='bhashya' id='MK_C01_V12_B01'>अमात्रः मात्रा यस्य न सन्ति, सः अमात्रः ओङ्कारः चतुर्थः तुरीयः आत्मैव केवलः अभिधानाभिधेयरूपयोर्वाङ्मनसयोः क्षीणत्वात् अव्यवहार्यः ; प्रपञ्चोपशमः शिवः अद्वैतः संवृत्तः एवं यथोक्तविज्ञानवता प्रयुक्त ओङ्कारस्त्रिमात्रस्त्रिपाद आत्मैव ; संविशति आत्मना स्वेनैव स्वं पारमार्थिकमात्मानम् , य एवं वेद ; परमार्थदर्शनात् ब्रह्मवित् तृतीयं बीजभावं दग्ध्वा आत्मानं प्रविष्ट इति न पुनर्जायते, तुरीयस्याबीजत्वात् । न हि रज्जुसर्पयोर्विवेके रज्ज्वां प्रविष्टः सर्पः बुद्धिसंस्कारात्पुनः पूर्ववत्तद्विवेकिनामुत्थास्यति । मन्दमध्यमधियां तु प्रतिपन्नसाधकभावानां सन्मार्गगामिनां संन्यासिनां मात्राणां पादानां च क्लृप्तसामान्यविदां यथावदुपास्यमान ओङ्कारो ब्रह्मप्रतिपत्तये आलम्बनीभवति । तथा च वक्ष्यति — <span class='qt'><a href='Mandukya_id.html </div> </body> </html>
<?php namespace Joomla\CMS\MVC\Model; \defined('JPATH_PLATFORM') or die; use Joomla\CMS\Cache\<API key>; use Joomla\CMS\Cache\Controller\CallbackController; use Joomla\CMS\Cache\Exception\<API key>; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Extension\ComponentInterface; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Factory\LegacyFactory; use Joomla\CMS\MVC\Factory\<API key>; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\MVC\Factory\<API key>; use Joomla\CMS\Table\Table; use Joomla\Database\DatabaseQuery; use Joomla\Utilities\ArrayHelper; /** * Base class for a database aware Joomla Model * * Acts as a Factory class for application specific objects and provides many supporting API functions. * * @since 2.5.5 */ abstract class BaseDatabaseModel extends BaseModel implements <API key> { use DatabaseAwareTrait; use <API key>; /** * The URL option for the component. * * @var string * @since 3.0 */ protected $option = null; /** * The event to trigger when cleaning cache. * * @var string * @since 3.0 */ protected $event_clean_cache = null; /** * Constructor * * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). * @param MVCFactoryInterface $factory The factory. * * @since 3.0 * @throws \Exception */ public function __construct($config = array(), MVCFactoryInterface $factory = null) { parent::__construct($config); // Guess the option from the class name (Option)Model(View). if (empty($this->option)) { $r = null; if (!preg_match('/(.*)Model/i', \get_class($this), $r)) { throw new \Exception(Text::_('<API key>'), 500); } $this->option = ComponentHelper::getComponentName($this, $r[1]); } $this->setDbo(\array_key_exists('dbo', $config) ? $config['dbo'] : Factory::getDbo()); // Set the default view search path if (\array_key_exists('table_path', $config)) { $this->addTablePath($config['table_path']); } // @<API key> elseif (\defined('<API key>')) { $this->addTablePath(<API key> . '/tables'); $this->addTablePath(<API key> . '/table'); } // @<API key> // Set the clean cache event if (isset($config['event_clean_cache'])) { $this->event_clean_cache = $config['event_clean_cache']; } elseif (empty($this->event_clean_cache)) { $this->event_clean_cache = 'onContentCleanCache'; } if ($factory) { $this->setMVCFactory($factory); return; } $component = Factory::getApplication()->bootComponent($this->option); if ($component instanceof <API key>) { $this->setMVCFactory($component->getMVCFactory()); } } /** * Gets an array of objects from the results of database query. * * @param string $query The query. * @param integer $limitstart Offset. * @param integer $limit The number of records. * * @return object[] An array of results. * * @since 3.0 * @throws \RuntimeException */ protected function _getList($query, $limitstart = 0, $limit = 0) { if (\is_string($query)) { $query = $this->getDbo()->getQuery(true)->setQuery($query); } $query->setLimit($limit, $limitstart); $this->getDbo()->setQuery($query); return $this->getDbo()->loadObjectList(); } /** * Returns a record count for the query. * * Note: Current implementation of this method assumes that getListQuery() returns a set of unique rows, * thus it uses SELECT COUNT(*) to count the rows. In cases that getListQuery() uses DISTINCT * then either this method must be overriden by a custom implementation at the derived Model Class * or a GROUP BY clause should be used to make the set unique. * * @param DatabaseQuery|string $query The query. * * @return integer Number of rows for query. * * @since 3.0 */ protected function _getListCount($query) { // Use fast COUNT(*) on DatabaseQuery objects if there is no GROUP BY or HAVING clause: if ($query instanceof DatabaseQuery && $query->type == 'select' && $query->group === null && $query->merge === null && $query->querySet === null && $query->having === null) { $query = clone $query; $query->clear('select')->clear('order')->clear('limit')->clear('offset')->select('COUNT(*)'); $this->getDbo()->setQuery($query); return (int) $this->getDbo()->loadResult(); } // Otherwise fall back to inefficient way of counting all results. // Remove the limit and offset part if it's a DatabaseQuery object if ($query instanceof DatabaseQuery) { $query = clone $query; $query->clear('limit')->clear('offset'); } $this->getDbo()->setQuery($query); $this->getDbo()->execute(); return (int) $this->getDbo()->getNumRows(); } /** * Method to load and return a table object. * * @param string $name The name of the view * @param string $prefix The class prefix. Optional. * @param array $config Configuration settings to pass to Table::getInstance * * @return Table|boolean Table object or boolean false if failed * * @since 3.0 * @see \JTable::getInstance() */ protected function _createTable($name, $prefix = 'Table', $config = array()) { // Make sure we are returning a DBO object if (!\array_key_exists('dbo', $config)) { $config['dbo'] = $this->getDbo(); } return $this->getMVCFactory()->createTable($name, $prefix, $config); } /** * Method to get a table object, load it if necessary. * * @param string $name The table name. Optional. * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * * @return Table A Table object * * @since 3.0 * @throws \Exception */ public function getTable($name = '', $prefix = '', $options = array()) { if (empty($name)) { $name = $this->getName(); } // We need this ugly code to deal with non-namespaced MVC code if (empty($prefix) && $this->getMVCFactory() instanceof LegacyFactory) { $prefix = 'Table'; } if ($table = $this->_createTable($name, $prefix, $options)) { return $table; } throw new \Exception(Text::sprintf('<API key>', $name), 0); } /** * Method to load a row for editing from the version history table. * * @param integer $version_id Key to the version history table. * @param Table &$table Content table object being loaded. * * @return boolean False on failure or error, true otherwise. * * @since 3.2 */ public function loadHistory($version_id, Table &$table) { // Only attempt to check the row in if it exists, otherwise do an early exit. if (!$version_id) { return false; } // Get an instance of the row to checkout. $historyTable = Table::getInstance('Contenthistory'); if (!$historyTable->load($version_id)) { $this->setError($historyTable->getError()); return false; } $rowArray = ArrayHelper::fromObject(json_decode($historyTable->version_data)); $typeId = Table::getInstance('Contenttype')->getTypeId($this->typeAlias); if ($historyTable->ucm_type_id != $typeId) { $this->setError(Text::_('<API key>')); $key = $table->getKeyName(); if (isset($rowArray[$key])) { $table->checkIn($rowArray[$key]); } return false; } $this->setState('save_date', $historyTable->save_date); $this->setState('version_note', $historyTable->version_note); return $table->bind($rowArray); } /** * Method to check if the given record is checked out by the current user * * @param \stdClass $item The record to check * * @return bool */ public function isCheckedOut($item) { $table = $this->getTable(); $checkedOutField = $table->getColumnAlias('checked_out'); if (property_exists($item, $checkedOutField) && $item->{$checkedOutField} != Factory::getUser()->id) { return true; } return false; } /** * Clean the cache * * @param string $group The cache group * * @return void * * @since 3.0 */ protected function cleanCache($group = null) { $app = Factory::getApplication(); $options = [ 'defaultgroup' => $group ?: ($this->option ?? $app->input->get('option')), 'cachebase' => $app->get('cache_path', JPATH_CACHE), 'result' => true, ]; try { /** @var CallbackController $cache */ $cache = Factory::getContainer()->get(<API key>::class)-><API key>('callback', $options); $cache->clean(); } catch (<API key> $exception) { $options['result'] = false; } // Trigger the onContentCleanCache event. $app->triggerEvent($this->event_clean_cache, $options); } /** * Boots the component with the given name. * * @param string $component The component name, eg. com_content. * * @return ComponentInterface The service container * * @since 4.0.0 */ protected function bootComponent($component): ComponentInterface { return Factory::getApplication()->bootComponent($component); } }
package extension; import java.util.Hashtable; import java.io.*; public class <API key> extends ObjectInputStream { static private Hashtable renamedClassMap; public <API key>(InputStream si) throws IOException, <API key> { super(si); } protected Class resolveClass(ObjectStreamClass v) throws IOException, <API key> { if (renamedClassMap != null) { // System.out.println("resolveClass(" + v.getName() + ")"); Class newClass = (Class)renamedClassMap.get(v.getName()); if (newClass != null) { v = ObjectStreamClass.lookup(newClass); } } return super.resolveClass(v); } static public void addRenamedClassName(String oldName, String newName) throws <API key> { Class cl = null; if (renamedClassMap == null) renamedClassMap = new Hashtable(10); if (newName.startsWith("[L")) { // System.out.println("Array processing"); Class componentType = Class.forName(newName.substring(2)); //System.out.println("ComponentType=" + componentType.getName()); Object dummy = java.lang.reflect.Array.newInstance(componentType, 3); cl = dummy.getClass(); // System.out.println("Class=" + cl.getName()); } else cl = Class.forName(newName); //System.out.println("oldName=" + oldName + // " newName=" + cl.getName()); renamedClassMap.put(oldName, cl); } }
#include <iostream> using namespace std; struct Node { int inf; Node *next; }*start,*newptr,*save,*ptr,*rear; Node* Create_New_Node(int n) { newptr=new Node; newptr->inf=n; newptr->next=NULL; return newptr; } void Insert_End(Node *np) { if(start==NULL) start=rear=np; else { rear->next=np; rear=np; } } void display(Node *np) { while(np!=NULL) { cout<<np->inf<<"->"; np=np->next; } cout<<"!!!"; } int main() { start=NULL; int n; char ch='y'; while(ch=='y'||ch=='Y') { cout<<"Enter information for new node: "; cin>>n; ptr=Create_New_Node(n); Insert_End(ptr); display(start); cout<<"\nWant to enter more (y/n) : "; cin>>ch; } return 0; }
package com.mypcr.function; import java.awt.FileDialog; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import javax.swing.JFrame; import javax.swing.JOptionPane; import com.hidapi.HidClassLoader; import com.mypcr.beans.Action; public class Functions { private static boolean isMac = false; private static String pcrPath = null; static{ String os = System.getProperty("os.name", "win").toLowerCase(); if( os.indexOf("win") != -1 ){ isMac = false; }else if( os.indexOf("mac") != -1 ){ isMac = true; } File[] files = File.listRoots(); if( !isMac) pcrPath = files[0].getAbsolutePath() + "\\mPCR"; else{ String classPath = System.getProperty("java.class.path"); String[] tempPath = classPath.split("/"); for(int i=0; i<tempPath.length-1; ++i){ pcrPath += tempPath[i] + "/"; } pcrPath += "mPCR"; } } public static String <API key>() { String save_path = pcrPath; File file = new File(save_path); file.mkdir(); if( !isMac ) save_path += "\\recent_protocol.txt"; else save_path += "/recent_protocol.txt"; File RecentFile = new File(save_path); BufferedReader in = null; try { in = new BufferedReader(new FileReader(RecentFile)); String input = in.readLine(); in.close(); return input; } catch (IOException e) { return null; } } public static void Save_RecentProtocol(String protocol_path) { String save_path = pcrPath; File file = new File(save_path); file.mkdir(); if( !isMac ) save_path += "\\recent_protocol.txt"; else save_path += "/recent_protocol.txt"; File RecentFile = new File(save_path); BufferedReader in = null; PrintWriter out = null; try { in = new BufferedReader(new FileReader(RecentFile)); in.close(); out = new PrintWriter(new FileWriter(RecentFile)); out.println(protocol_path); out.close(); } catch (IOException e) { try { in = null; RecentFile.createNewFile(); Save_RecentProtocol(protocol_path); }catch(IOException e2){} } } public static Action[] ReadProtocolbyPath( String path ) throws Exception { BufferedReader in = null; ArrayList<String> inData = new ArrayList<String>(); String tempData = null; // 130326 YJ // try in = new BufferedReader(new InputStreamReader(new FileInputStream( path ))); while( (tempData = in.readLine()) != null ) { inData.add( tempData ); } // }catch(Exception e) // e.printStackTrace(); // }finally // try in.close(); // }catch(IOException e) // e.printStackTrace(); String start = inData.get(0); String end = inData.get(inData.size()-1); int actionCount = inData.size()-2; Action[] actions = new Action[actionCount]; if( !start.contains("%PCR%") ) return null; if( !end.contains("%END") ) return null; String token = "\\\\"; if( isMac ) token = "/"; String[] tokens = path.split(token); for(int i=1; i<inData.size()-1; i++) { String[] datas = inData.get(i).split("\t{1,}| {1,}"); actions[i-1] = new Action(tokens[tokens.length-1]); int j=0; for( String temp : datas ) { actions[i-1].set(j++, temp); } } return actions; } public static Action[] <API key>( JFrame parent ) { FileDialog fileDialog = new FileDialog(parent, "Select protocol file", FileDialog.LOAD); fileDialog.setFile("*.txt"); fileDialog.setVisible(true); String dir = fileDialog.getDirectory(); String file = fileDialog.getFile(); String path = dir + file; if( dir == null ) { Action[] action = new Action[1]; action[0] = new Action(); return action; } BufferedReader in = null; ArrayList<String> inData = new ArrayList<String>(); String tempData = null; try { in = new BufferedReader(new InputStreamReader(new FileInputStream( path ))); while( (tempData = in.readLine()) != null ) { inData.add( tempData ); } }catch(Exception e) { e.printStackTrace(); }finally { try { in.close(); }catch(IOException e) { e.printStackTrace(); } } String start = inData.get(0); String end = inData.get(inData.size()-1); int actionCount = inData.size()-2; Action[] actions = new Action[actionCount]; if( !start.contains("%PCR%") ) return null; if( !end.contains("%END") ) return null; for(int i=1; i<inData.size()-1; i++) { String[] datas = inData.get(i).split("\t{1,}| {1,}"); actions[i-1] = new Action(file); int j=0; for( String temp : datas ) { actions[i-1].set(j++, temp); } } if( actions[0].getLabel() != null ) Save_RecentProtocol(path); return actions; } }
<?php // Setting a base path. Easy change if the code is going to be incorporated into a theme, use get_bloginfo('theme_directory') instead $base = WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "" ,plugin_basename(__FILE__)); define('base', $base); // Setting up the Admin Page and SalsaPress options require_once('utils/crypt.php'); require_once('utils/classes.php'); require_once('utils/functions.php'); require_once('utils/shortcode.php'); require_once('utils/ajax.php'); // Admin Menus require_once('admin/admin_menu.php'); require_once('admin/manage_caching.php'); // Embedder require_once('admin/embed.php'); // Widgets require_once('widgets/coming_events.php'); require_once('widgets/signup_page.php'); require_once('widgets/event_form.php'); // Setting the defaults when activating the plugin <API key>(__FILE__, 'salsapress_defaults'); add_action('wp_enqueue_scripts', 'enque_salsapress'); add_action('admin_init', '<API key>' ); function <API key>(){ add_action('media_buttons', '<API key>', 20); add_action('<API key>', '<API key>'); add_action('<API key>', '<API key>'); add_action('<API key>', '<API key>'); } function enque_salsapress() { //Enqueing external scripts and styles wp_enqueue_script( 'SalsaPress', base.'utils/SalsaPress.js',array( 'jquery' ), '1.0', true ); wp_enqueue_style( 'SalsaPress', base.'utils/SalsaPress.css','', '0.5', 'all' ); localize_scripts(); } function localize_scripts() { wp_localize_script( 'SalsaPress', 'SalsaPressVars', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'SalsaAjax' => wp_create_nonce( '<API key>' ), '<API key>' => base ) ); } ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!--Converted with LaTeX2HTML 2002-2-1 (1.71) original version by: Nikos Drakos, CBLU, University of Leeds * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others <HTML> <HEAD> <TITLE>IMAP Folders</TITLE> <META NAME="description" CONTENT="IMAP Folders"> <META NAME="keywords" CONTENT="asterisk"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <LINK REL="STYLESHEET" HREF="asterisk.css"> <LINK REL="next" HREF="node236.html"> <LINK REL="previous" HREF="node234.html"> <LINK REL="up" HREF="node230.html"> <LINK REL="next" HREF="node236.html"> </HEAD> <BODY > <DIV CLASS="navigation"><!--Navigation Panel <A NAME="tex2html3714" HREF="node236.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html3710" HREF="node230.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html3704" HREF="node234.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html3712" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="/usr/share/latex2html/icons/contents.png"></A> <BR> <B> Next:</B> <A NAME="tex2html3715" HREF="node236.html">Separate vs. Shared Email</A> <B> Up:</B> <A NAME="tex2html3711" HREF="node230.html">IMAP Storage</A> <B> Previous:</B> <A NAME="tex2html3705" HREF="node234.html">Modify voicemail.conf</A> &nbsp; <B> <A NAME="tex2html3713" HREF="node1.html">Contents</A></B> <BR> <BR></DIV> <!--End of Navigation Panel <H2><A NAME="<API key>"> IMAP Folders</A> </H2> <P> Besides INBOX, users should create "Old", "Work", "Family" and "Friends" IMAP folders at the same level of hierarchy as the INBOX. These will be used as alternate folders for storing voicemail messages to mimic the behavior of the current (file-based) voicemail system. <P> <BR><HR> <ADDRESS> Russell Bryant 2008-10-08 </ADDRESS> </BODY> </HTML>
#include "Platform.h" #ifdef WINDOWS #include "JavaVirtualMachine.h" #include "WindowsPlatform.h" #include "Package.h" #include "Helpers.h" #include "PlatformString.h" #include "Macros.h" #include <map> #include <vector> #include <regex> class Registry { private: HKEY FKey; HKEY FOpenKey; bool FOpen; public: Registry(HKEY Key) { FOpen = false; FKey = Key; } ~Registry() { Close(); } void Close() { if (FOpen == true) { RegCloseKey(FOpenKey); } } bool Open(TString SubKey) { bool result = false; Close(); if (RegOpenKeyEx(FKey, SubKey.data(), 0, KEY_READ, &FOpenKey) == ERROR_SUCCESS) { result = true; } return result; } std::list<TString> GetKeys() { std::list<TString> result; DWORD count; if (RegQueryInfoKey(FOpenKey, NULL, NULL, NULL, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { DWORD length = 255; DynamicBuffer<TCHAR> buffer(length); for (unsigned int index = 0; index < count; index++) { buffer.Zero(); DWORD status = RegEnumValue(FOpenKey, index, buffer.GetData(), &length, NULL, NULL, NULL, NULL); while (status == ERROR_MORE_DATA) { length = length * 2; buffer.Resize(length); status = RegEnumValue(FOpenKey, index, buffer.GetData(), &length, NULL, NULL, NULL, NULL); } if (status == ERROR_SUCCESS) { TString value = buffer.GetData(); result.push_back(value); } } } return result; } TString ReadString(TString Name) { TString result; DWORD length; DWORD dwRet; DynamicBuffer<wchar_t> buffer(0); length = 0; dwRet = RegQueryValueEx(FOpenKey, Name.data(), NULL, NULL, NULL, &length); if (dwRet == ERROR_MORE_DATA || dwRet == 0) { buffer.Resize(length + 1); dwRet = RegQueryValueEx(FOpenKey, Name.data(), NULL, NULL, (LPBYTE)buffer.GetData(), &length); result = buffer.GetData(); } return result; } }; WindowsPlatform::WindowsPlatform(void) : Platform(), GenericPlatform() { FMainThread = ::GetCurrentThreadId(); } WindowsPlatform::~WindowsPlatform(void) { } TCHAR* WindowsPlatform::<API key>(TCHAR* Source, bool &release) { // Not Implemented. return NULL; } TCHAR* WindowsPlatform::<API key>(TCHAR* Source, bool &release) { // Not Implemented. return NULL; } void WindowsPlatform::SetCurrentDirectory(TString Value) { _wchdir(Value.data()); } TString WindowsPlatform::<API key>() { TString filename = GetModuleFileName(); return FilePath::ExtractFilePath(filename); } TString WindowsPlatform::GetAppDataDirectory() { TString result; TCHAR path[MAX_PATH]; if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path) == S_OK) { result = path; } return result; } #define BUFFER_SIZE 256 // try to find current Java Home from registry // HKLM\Software\JavaSoft\Java Runtime Environment\CurrentVersion // HKLM\Software\JavaSoft\Java Runtime Environment\[CurrentVersion]\JavaHome // note that this has been changed in JDK9 to // HKLM\Software\JavaSoft\JRE\CurrentVersion // HKLM\Software\JavaSoft\JRE\[CurrentVersion]\JavaHome // return non-empty string as path if found // return empty string otherwise TString <API key>(TString javaRuntimeSubkey) { Registry registry(HKEY_LOCAL_MACHINE); TString result; if (registry.Open(javaRuntimeSubkey)) { TString version = registry.ReadString(_T("CurrentVersion")); if (!version.empty()) { if (registry.Open(javaRuntimeSubkey + TString(_T("\\")) + TString(version))) { TString javaHome = registry.ReadString(_T("JavaHome")); if (FilePath::DirectoryExists(javaHome)) { result = javaHome; } } } } return result; } TString WindowsPlatform::GetSystemJRE() { if (GetAppCDSState() != cdsDisabled) { //TODO throw exception return _T(""); } TString result; result = <API key>(_T("SOFTWARE\\JavaSoft\\JRE")); if (!result.empty()) { return result; } result = <API key>(_T("SOFTWARE\\JavaSoft\\Java Runtime Environment")); if (!result.empty()) { return result; } return result; } void WindowsPlatform::ShowMessage(TString title, TString description) { MessageBox(NULL, description.data(), !title.empty() ? title.data() : description.data(), MB_ICONERROR | MB_OK); } void WindowsPlatform::ShowMessage(TString description) { TString appname = GetModuleFileName(); appname = FilePath::ExtractFileName(appname); MessageBox(NULL, description.data(), appname.data(), MB_ICONERROR | MB_OK); } MessageResponse WindowsPlatform::ShowResponseMessage(TString title, TString description) { MessageResponse result = mrCancel; if (::MessageBox(NULL, description.data(), title.data(), MB_OKCANCEL) == IDOK) { result = mrOK; } return result; } //MessageResponse WindowsPlatform::ShowResponseMessage(TString description) { // TString appname = GetModuleFileName(); // appname = FilePath::ExtractFileName(appname); // return ShowResponseMessage(appname, description); TString WindowsPlatform::<API key>(TString RuntimePath) { TString result = FilePath::<API key>(RuntimePath) + _T("jre\\bin\\jli.dll"); if (FilePath::FileExists(result) == false) { result = FilePath::<API key>(RuntimePath) + _T("bin\\jli.dll"); } return result; } TString WindowsPlatform::<API key>() { TString result; TString jvmPath = GetSystemJRE(); if (jvmPath.empty() == false) { result = <API key>(jvmPath); } return result; } <API key>* WindowsPlatform::GetConfigFile(TString FileName) { IniFile *result = new IniFile(); if (result->LoadFromFile(FileName) == false) { // New property file format was not found, attempt to load old property file format. Helpers::LoadOldConfigFile(FileName, result); } return result; } TString WindowsPlatform::GetModuleFileName() { TString result; DynamicBuffer<wchar_t> buffer(MAX_PATH); ::GetModuleFileName(NULL, buffer.GetData(), buffer.GetSize()); while (<API key> == GetLastError()) { buffer.Resize(buffer.GetSize() * 2); ::GetModuleFileName(NULL, buffer.GetData(), buffer.GetSize()); } result = buffer.GetData(); return result; } Module WindowsPlatform::LoadLibrary(TString FileName) { return ::LoadLibrary(FileName.data()); } void WindowsPlatform::FreeLibrary(Module AModule) { ::FreeLibrary((HMODULE)AModule); } Procedure WindowsPlatform::GetProcAddress(Module AModule, std::string MethodName) { return ::GetProcAddress((HMODULE)AModule, MethodName.c_str()); } bool WindowsPlatform::IsMainThread() { bool result = (FMainThread == ::GetCurrentThreadId()); return result; } TPlatformNumber WindowsPlatform::GetMemorySize() { SYSTEM_INFO si; GetSystemInfo(&si); size_t result = (size_t)si.<API key>; result = result / 1048576; // Convert from bytes to megabytes. return result; } std::vector<TString> WindowsPlatform::GetLibraryImports(const TString FileName) { std::vector<TString> result; WindowsLibrary library(FileName); result = library.GetImports(); return result; } std::vector<TString> FilterList(std::vector<TString> &Items, std::wregex Pattern) { std::vector<TString> result; for (std::vector<TString>::iterator it = Items.begin(); it != Items.end(); ++it) { TString item = *it; std::wsmatch match; if (std::regex_search(item, match, Pattern)) { result.push_back(item); } } return result; } std::vector<TString> WindowsPlatform::<API key>(std::vector<TString> Imports) { std::vector<TString> result; Package& package = Package::GetInstance(); Macros& macros = Macros::GetInstance(); TString runtimeDir = macros.ExpandMacros(package.<API key>()); std::vector<TString> filelist = FilterList(Imports, std::wregex(_T("MSVCR.*.DLL"), std::regex_constants::icase)); for (std::vector<TString>::iterator it = filelist.begin(); it != filelist.end(); ++it) { TString filename = *it; TString msvcr100FileName = FilePath::<API key>(runtimeDir) + _T("jre\\bin\\") + filename; if (FilePath::FileExists(msvcr100FileName) == true) { result.push_back(msvcr100FileName); break; } else { msvcr100FileName = FilePath::<API key>(runtimeDir) + _T("bin\\") + filename; if (FilePath::FileExists(msvcr100FileName) == true) { result.push_back(msvcr100FileName); break; } } } return result; } Process* WindowsPlatform::CreateProcess() { return new WindowsProcess(); } #ifdef DEBUG bool WindowsPlatform::<API key>() { bool result = false; if (IsDebuggerPresent() == TRUE) { result = true; } return result; } int WindowsPlatform::GetProcessID() { int pid = GetProcessId(GetCurrentProcess()); return pid; } #endif //DEBUG <API key>::<API key>(void) : JavaUserPreferences() { } <API key>::~<API key>(void) { } // Java Preferences API encodes it's strings, so we need to match what Java does to work with Java. // CAVEAT: Java also does unicode encoding which this doesn't do yet. Should be sufficient for jvm args. // See WindowsPreferences.java toWindowsName() TString <API key>(TString Value) { TString result; TCHAR* p = (TCHAR*)Value.c_str(); TCHAR c = *p; while (c != 0) { switch (c) { case '\\': result += _T(" break; case '/': result += '\\'; break; default: if ((c >= 'A') && (c <= 'Z')) { result += '/'; result += c; } else result += c; break; } p++; c = *p; } return result; } // Java Preferences API encodes it's strings, so we need to match what Java does to work with Java. // CAVEAT: Java also does unicode encoding which this doesn't do yet. Should be sufficient for jvm args. // See WindowsPreferences.java toJavaName() TString <API key>(TString Value) { TString result; for (size_t index = 0; index < Value.length(); index++) { TCHAR c = Value[index]; switch (c) { case '/': if ((index + 1) < Value.length()) { index++; TCHAR nextc = Value[index]; if (nextc >= 'A' && nextc <= 'Z') { result += nextc; } else if (nextc == '/') { result += '\\'; } } break; case '\\': result += '/'; break; default: result += c; break; } } return result; } bool <API key>::Load(TString Appid) { bool result = false; TString lappid = Helpers::ConvertIdToFilePath(Appid); lappid = <API key>(Appid); TString registryKey = TString(_T("SOFTWARE\\JavaSoft\\Prefs\\")) + lappid + TString(_T("\\/J/V/M/User/Options")); Registry registry(HKEY_CURRENT_USER); if (registry.Open(registryKey) == true) { std::list<TString> keys = registry.GetKeys(); OrderedMap<TString, TString> mapOfKeysAndValues; for (std::list<TString>::const_iterator iterator = keys.begin(); iterator != keys.end(); iterator++) { TString key = *iterator; TString value = registry.ReadString(key); key = <API key>(key); value = <API key>(value); if (key.empty() == false) { mapOfKeysAndValues.Append(key, value); result = true; } } FMap = mapOfKeysAndValues; } return result; } FileHandle::FileHandle(std::wstring FileName) { FHandle = ::CreateFile(FileName.data(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, <API key>, 0); } FileHandle::~FileHandle() { if (IsValid() == true) { ::CloseHandle(FHandle); } } bool FileHandle::IsValid() { return FHandle != <API key>; } HANDLE FileHandle::GetHandle() { return FHandle; } FileMappingHandle::FileMappingHandle(HANDLE FileHandle) { FHandle = ::CreateFileMapping(FileHandle, NULL, PAGE_READONLY, 0, 0, NULL); } bool FileMappingHandle::IsValid() { return FHandle != NULL; } FileMappingHandle::~FileMappingHandle() { if (IsValid() == true) { ::CloseHandle(FHandle); } } HANDLE FileMappingHandle::GetHandle() { return FHandle; } FileData::FileData(HANDLE Handle) { FBaseAddress = ::MapViewOfFile(Handle, FILE_MAP_READ, 0, 0, 0); } FileData::~FileData() { if (IsValid() == true) { ::UnmapViewOfFile(FBaseAddress); } } bool FileData::IsValid() { return FBaseAddress != NULL; } LPVOID FileData::GetBaseAddress() { return FBaseAddress; } WindowsLibrary::WindowsLibrary(std::wstring FileName) { FFileName = FileName; } std::vector<TString> WindowsLibrary::GetImports() { std::vector<TString> result; FileHandle library(FFileName); if (library.IsValid() == true) { FileMappingHandle mapping(library.GetHandle()); if (mapping.IsValid() == true) { FileData fileData(mapping.GetHandle()); if (fileData.IsValid() == true) { PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)fileData.GetBaseAddress(); PIMAGE_FILE_HEADER pImgFileHdr = (PIMAGE_FILE_HEADER)fileData.GetBaseAddress(); if (dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { result = DumpPEFile(dosHeader); } } } } return result; } // Given an RVA, look up the section header that encloses it and return a // pointer to its <API key> <API key> WindowsLibrary::<API key>(DWORD rva, PIMAGE_NT_HEADERS pNTHeader) { <API key> result = 0; <API key> section = IMAGE_FIRST_SECTION(pNTHeader); for (unsigned index = 0; index < pNTHeader->FileHeader.NumberOfSections; index++, section++) { // Is the RVA is within this section? if ((rva >= section->VirtualAddress) && (rva < (section->VirtualAddress + section->Misc.VirtualSize))) { result = section; } } return result; } LPVOID WindowsLibrary::GetPtrFromRVA(DWORD rva, PIMAGE_NT_HEADERS pNTHeader, DWORD imageBase) { LPVOID result = 0; <API key> pSectionHdr = <API key>(rva, pNTHeader); if (pSectionHdr != NULL) { INT delta = (INT)(pSectionHdr-><API key>->PointerToRawData); result = (PVOID)(imageBase + rva - delta); } return result; } std::vector<TString> WindowsLibrary::GetImportsSection(DWORD base, PIMAGE_NT_HEADERS pNTHeader) { std::vector<TString> result; // Look up where the imports section is located. Normally in the .idata section, // but not necessarily so. Therefore, grab the RVA from the data dir. DWORD importsStartRVA = pNTHeader->OptionalHeader.DataDirectory[<API key>].VirtualAddress; if (importsStartRVA != NULL) { // Get the <API key> that contains the imports. This is // usually the .idata section, but doesn't have to be. <API key> pSection = <API key>(importsStartRVA, pNTHeader); if (pSection != NULL) { <API key> importDesc = (<API key>)GetPtrFromRVA(importsStartRVA, pNTHeader,base); if (importDesc != NULL) { while (true) { // See if we've reached an empty <API key> if ((importDesc->TimeDateStamp == 0) && (importDesc->Name == 0)) break; std::string filename = (char*)GetPtrFromRVA(importDesc->Name, pNTHeader, base); result.push_back(PlatformString(filename)); importDesc++; // advance to next <API key> } } } } return result; } std::vector<TString> WindowsLibrary::DumpPEFile(PIMAGE_DOS_HEADER dosHeader) { std::vector<TString> result; PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((DWORD)(dosHeader) + (DWORD)(dosHeader->e_lfanew)); // Verify that the e_lfanew field gave us a reasonable // pointer and the PE signature. // TODO: To really fix JDK-8131321 this condition needs to be changed. There is a matching change // in JavaVirtualMachine.cpp that also needs to be changed. if (pNTHeader->Signature == IMAGE_NT_SIGNATURE) { DWORD base = (DWORD)dosHeader; result = GetImportsSection(base, pNTHeader); } return result; } #include <TlHelp32.h> WindowsJob::WindowsJob() { FHandle = NULL; } WindowsJob::~WindowsJob() { if (FHandle != NULL) { CloseHandle(FHandle); } } HANDLE WindowsJob::GetHandle() { if (FHandle == NULL) { FHandle = CreateJobObject(NULL, NULL); // GLOBAL if (FHandle == NULL) { ::MessageBox( 0, _T("Could not create job object"), _T("TEST"), MB_OK); } else { <API key> jeli = { 0 }; // Configure all child processes associated with the job to terminate when the jeli.<API key>.LimitFlags = <API key>; if (0 == <API key>(FHandle, <API key>, &jeli, sizeof(jeli))) { ::MessageBox( 0, _T("Could not <API key>"), _T("TEST"), MB_OK); } } } return FHandle; } // Initialize static member of WindowsProcess WindowsJob WindowsProcess::FJob; WindowsProcess::WindowsProcess() : Process() { FRunning = false; } WindowsProcess::~WindowsProcess() { Terminate(); } void WindowsProcess::Cleanup() { CloseHandle(FProcessInfo.hProcess); CloseHandle(FProcessInfo.hThread); } bool WindowsProcess::IsRunning() { bool result = false; HANDLE handle = ::<API key>(TH32CS_SNAPALL, 0); PROCESSENTRY32 process = { 0 }; process.dwSize = sizeof(process); if (::Process32First(handle, &process)) { do { if (process.th32ProcessID == FProcessInfo.dwProcessId) { result = true; break; } } while (::Process32Next(handle, &process)); } CloseHandle(handle); return result; } bool WindowsProcess::Terminate() { bool result = false; if (IsRunning() == true && FRunning == true) { FRunning = false; } return result; } bool WindowsProcess::Execute(const TString Application, const std::vector<TString> Arguments, bool AWait) { bool result = false; if (FRunning == false) { FRunning = true; STARTUPINFO startupInfo; ZeroMemory(&startupInfo, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); ZeroMemory(&FProcessInfo, sizeof(FProcessInfo)); TString command = Application; for (std::vector<TString>::const_iterator iterator = Arguments.begin(); iterator != Arguments.end(); iterator++) { command += TString(_T(" ")) + *iterator; } if (::CreateProcess(Application.data(), (wchar_t*)command.data(), NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &FProcessInfo) == FALSE) { TString message = PlatformString::Format(_T("Error: Unable to create process %s"), Application.data()); throw Exception(message); } else { if (FJob.GetHandle() != NULL) { if (::<API key>(FJob.GetHandle(), FProcessInfo.hProcess) == 0) { // Failed to assign process to job. It doesn't prevent anything from continuing so continue. } } // Wait until child process exits. if (AWait == true) { Wait(); // Close process and thread handles. Cleanup(); } } } return result; } bool WindowsProcess::Wait() { bool result = false; WaitForSingleObject(FProcessInfo.hProcess, INFINITE); return result; } TProcessID WindowsProcess::GetProcessID() { return FProcessInfo.dwProcessId; } bool WindowsProcess::ReadOutput() { bool result = false; //TODO implement return result; } void WindowsProcess::SetInput(TString Value) { //TODO implement } std::list<TString> WindowsProcess::GetOutput() { ReadOutput(); return Process::GetOutput(); } #endif //WINDOWS
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class <API key> extends CI_Model { public function __construct() { parent::__construct(); $this->load->database(); } //data is expected to be an array of adventure_id, session public function insert($data) { if(!$data) $data = array("number_sent" => 0); $this->db->insert('suggest_emails', $data); return $this->db->insert_id(); } public function update($id,$data) { return $this->db->where('id', $id)->update('suggest_emails', $data); } public function get_last() { $this->db->order_by('last_sent', 'desc')->limit(1); $result = $this->db->get('suggest_emails'); $result = $result->row_array(); return $result['last_sent']; } } ?>
<?php /* core/modules/system/templates/form.html.twig */ class <API key> extends Twig_Template { public function __construct(Twig_Environment $env) { parent::__construct($env); $this->parent = false; $this->blocks = array( ); } protected function doDisplay(array $context, array $blocks = array()) { $tags = array(); $filters = array(); $functions = array(); try { $this->env->getExtension('sandbox')->checkSecurity( array(), array(), array() ); } catch (<API key> $e) { $e->setTemplateFile($this->getTemplateName()); if ($e instanceof <API key> && isset($tags[$e->getTagName()])) { $e->setTemplateLine($tags[$e->getTagName()]); } elseif ($e instanceof <API key> && isset($filters[$e->getFilterName()])) { $e->setTemplateLine($filters[$e->getFilterName()]); } elseif ($e instanceof <API key> && isset($functions[$e->getFunctionName()])) { $e->setTemplateLine($functions[$e->getFunctionName()]); } throw $e; } // line 15 echo "<form"; echo $this->env->getExtension('sandbox')-><API key>($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["attributes"]) ? $context["attributes"] : null), "html", null, true)); echo "> "; // line 16 echo $this->env->getExtension('sandbox')-><API key>($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["children"]) ? $context["children"] : null), "html", null, true)); echo " </form> "; } public function getTemplateName() { return "core/modules/system/templates/form.html.twig"; } public function isTraitable() { return false; } public function getDebugInfo() { return array ( 48 => 16, 43 => 15,); } } /* * @file*/ /* * Default theme implementation for a 'form' element.*/ /* * Available variables*/ /* * - attributes: A list of HTML attributes for the wrapper element.*/ /* * - children: The child elements of the form.*/ /* * @see <API key>()*/ /* * @ingroup themeable*/ /* <form{{ attributes }}>*/ /* {{ children }}*/ /* </form>*/
#ifndef _GRID_H_ #define _GRID_H_ #include "monome.h" #include "state.h" #define SG ss->grid #define GB ss->grid.button[i] #define GBC ss->grid.button[i].common #define GF ss->grid.fader[i] #define GFC ss->grid.fader[i].common #define GXY ss->grid.xypad[i] #define GXYC ss->grid.xypad[i].common typedef enum { GRID_MODE_OFF = 0, GRID_MODE_EDIT, GRID_MODE_FULL, GRID_MODE_LAST } screen_grid_mode; extern void <API key>(u8 control, u8 mode, scene_state_t *ss); extern void <API key>(scene_state_t *ss); extern void grid_refresh(scene_state_t *ss); extern void grid_screen_refresh(scene_state_t *ss, screen_grid_mode mode, u8 page, u8 ctrl, u8 x1, u8 y1, u8 x2, u8 y2); extern void grid_process_key(scene_state_t *ss, u8 x, u8 y, u8 z, u8 emulated); extern void <API key>(scene_state_t *ss); extern void <API key>(void); #endif
class CmsController < <API key> def show # find page by url and section params @section = Section::find_sub_section params[:sections] @page = Page.<API key> params[:url], true, :conditions => get_conditions(@section) # if page is not found, find section by url param and then page if !@page unless @section @section = Section.find_by_url params[:url] else @section = @section.children.find_by_url params[:url] end @page = Page.<API key> params[:url], true, :conditions => get_conditions(@section) end @page = @page_404 unless @page @blocks = @page.blocks if @page end private # if section exists, find page that belongs to the given section # either, find page that does not belong to a section def get_conditions(section) if section conditions = ["section_id = ?", section.id] else conditions = ["section_id IS NULL"] end return conditions end end
#ifndef <API key> #define <API key> #include <net/net_namespace.h> #include <linux/netfilter/nf_conntrack_common.h> #include <linux/netfilter/<API key>.h> #include <net/netfilter/nf_conntrack.h> #include <net/netfilter/nf_conntrack_extend.h> struct nf_conn_counter { u_int64_t packets; u_int64_t bytes; }; static inline struct nf_conn_counter *nf_conn_acct_find(const struct nf_conn *ct) { return nf_ct_ext_find(ct, NF_CT_EXT_ACCT); } static inline struct nf_conn_counter *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp) { struct net *net = nf_ct_net(ct); struct nf_conn_counter *acct; if (!net->ct.sysctl_acct) return NULL; acct = nf_ct_ext_add(ct, NF_CT_EXT_ACCT, gfp); if (!acct) pr_debug("failed to add accounting extension area"); return acct; }; extern unsigned int seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir); <<<< HEAD /* Check if connection tracking accounting is enabled */ static inline bool nf_ct_acct_enabled(struct net *net) { return net->ct.sysctl_acct != 0; } /* Enable/disable connection tracking accounting */ static inline void nf_ct_set_acct(struct net *net, bool enable) { net->ct.sysctl_acct = enable; } ==== >>>> <SHA1-like> extern int <API key>(struct net *net); extern void <API key>(struct net *net); #endif /* <API key> */
<?php /** * Shop breadcrumb * * @author WooThemes * @package WooCommerce/Templates * @version 2.3.0 * @see <API key>() */ if (!defined('ABSPATH')) { exit; } if ($breadcrumb) { echo $wrap_before; foreach ($breadcrumb as $key => $crumb) { echo $before; if (!empty($crumb[1]) && sizeof($breadcrumb) !== $key + 1) { if ($crumb[0] === 'Accueil') { $glyph = 'glyphicon-home'; } else { $glyph = '<API key>'; } echo '<a itemprop="url" title="' . esc_html($crumb[0]) . '" href="' . esc_url($crumb[1]) . '">'; echo '<small><span class="glyphicon ' . $glyph . '"></span>'; echo '</small><span itemprop="title"> ' . esc_html($crumb[0]) . '</span>'; echo '</a>'; } else { echo '<small><span class="glyphicon <API key>"></span>'; echo '</small><span itemprop="title"> ' . esc_html($crumb[0]) . '</span>'; } echo $after; if (sizeof($breadcrumb) !== $key + 1) { echo $delimiter; } } echo $wrap_after; }
package org.josejuansanchez.playground.controllers; import android.content.Context; import android.os.Vibrator; import org.josejuansanchez.playground.MainActivity; import org.josejuansanchez.playground.model.Message; public class VibrateController { public final static String TAG = "VibrateController"; private MainActivity mContext; public VibrateController(MainActivity mContext) { this.mContext = mContext; } public void vibrate(Message message) { Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(message.getMilliseconds()); } }
#include "converters.h" template <typename I, typename O> size_t resampler<I, O>::convert(const void* buf, size_t len) { I* const in = (I*)_buffer; O* const out = (O*)buf; size_t idx = 0; unsigned int error = 0; const size_t samples = len/sizeof(I); for (size_t j=0; j<samples; j+=channels) { for (unsigned int c=0; c<channels; c++) { const I val = in[idx+c]; out[j+c] = _quantizer->get(val+(I)(((unsigned int)(in[idx+c+channels]-val)*error)>>16), c); } error += _rate; while (error >= 0x10000) { error -= 0x10000; idx += channels; } } const size_t l = bufferSize/sizeof(I); qDebug() << "resamplerDecimal idx: " << static_cast<int>(idx) << "; l: " << static_cast<int>(l); _data = (l < idx) ? (l-idx)*sizeof(I) : 0; for (size_t j=idx; j<l; j+=channels) { for (unsigned int c=0; c<channels; c++) in[c] = in[j+c]; } return samples * sizeof(O); } template size_t resampler<unsigned char, unsigned char>::convert(const void* buf, const size_t len); template size_t resampler<short, short>::convert(const void* buf, const size_t len); template size_t resampler<int, unsigned char>::convert(const void* buf, const size_t len); template size_t resampler<int, short>::convert(const void* buf, const size_t len); template size_t resampler<float, unsigned char>::convert(const void* buf, const size_t len); template size_t resampler<float, short>::convert(const void* buf, const size_t len); template size_t resampler<float, float>::convert(const void* buf, const size_t len); template <typename I, typename O> size_t converterDecimal<I, O>::convert(const void* buf, size_t len) { I* const in = (I*)_buffer; O* const out = (O*)buf; const size_t samples = len/sizeof(I); for (size_t j=0; j<samples; j+=channels) { for (unsigned int c=0; c<channels; c++) { out[j+c] = _quantizer->get(in[j+c], c); } } return samples * sizeof(O); } template size_t converterDecimal<int, unsigned char>::convert(const void* buf, const size_t len); template size_t converterDecimal<int, short>::convert(const void* buf, const size_t len); template size_t converterDecimal<float, unsigned char>::convert(const void* buf, const size_t len); template size_t converterDecimal<float, short>::convert(const void* buf, const size_t len);
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8" /> <meta name="robots" content="all" /> <meta name="author" content="w3school.com.cn" /> <link rel="stylesheet" type="text/css" href="../c5.css" /> <title>HTML &lt;b&gt; </title> </head> <body class="html" id="tags"> <div id="wrapper"> <div id="header"> <a href="../index-2.html" title="w3school " style="float:left;">w3school </a> <div id="ad_head"> <script type="text/javascript"><! google_ad_client = "<API key>"; /* 728x90, 08-12-1 */ google_ad_slot = "7423315034"; google_ad_width = 728; google_ad_height = 90; </script> <script type="text/javascript" src="../../pagead2.googlesyndication.com/pagead/f.txt"> </script> </div> </div> <div id="navfirst"> <ul id="menu"> <li id="h"><a href="../h.html" title="HTML ">HTML </a></li> <li id="b"><a href="../b.html" title=""></a></li> <li id="s"><a href="../s.html" title=""></a></li> <li id="d"><a href="../d.html" title="ASP.NET ">ASP.NET </a></li> <li id="x"><a href="../x.html" title="XML ">XML </a></li> <li id="ws"><a href="../ws.html" title="Web Services ">Web Services </a></li> <li id="w"><a href="../w.html" title=""></a></li> </ul> </div> <div id="navsecond"> <div id="course"><h2></h2> <ul> <li><a href="index.html" title="HTML 4.01 / XHTML 1.0 "></a></li> <li><a href="html_ref_byfunc.asp" title="HTML 4.01 / XHTML 1.0 "></a></li> <li><a href="<API key>.html" title="HTML ">HTML </a></li> <li><a href="<API key>.html" title="HTML ">HTML </a></li> <li><a href="<API key>.html" title="HTML Audio/Video DOM ">HTML /</a></li> <li><a href="html_ref_canvas.html" title="HTML Canvas ">HTML </a></li> <li><a href="html_ref_dtd.asp" title="HTML DTD">HTML </a></li> <li><a href="html_ref_colornames.html" title="HTML ">HTML </a></li> <li><a href="<API key>.html" title="HTML ">HTML </a></li> <li><a href="html_ref_ascii.html" title="HTML 7 ASCII ">HTML ASCII</a></li> <li><a href="html_ref_entities.html" title="HTML ISO-8859-1 ">HTML ISO-8859-1</a></li> <li><a href="html_ref_symbols.html" title="HTML ">HTML </a></li> <li><a href="html_ref_urlencode.html" title="HTML URL ">HTML URL </a></li> <li><a href="<API key>.html" title="HTML ">HTML </a></li> <li><a href="<API key>.html" title="HTTP ">HTTP </a></li> <li><a href="<API key>.html" title="HTTP GET POST">HTTP </a></li> </ul> <h2>HTML </h2> <ul> <li><a href="tag_comment.html" title="HTML &lt;!--&gt; ">&lt;!--&gt;</a></li> <li><a href="tag_doctype.html" title="HTML &lt;!DOCTYPE&gt; ">&lt;!DOCTYPE&gt;</a></li> <li><a href="tag_a.asp" title="HTML &lt;a&gt; ">&lt;a&gt;</a></li> <li><a href="tag_abbr.html" title="HTML &lt;abbr&gt; ">&lt;abbr&gt;</a></li> <li><a href="tag_acronym.asp" title="HTML &lt;acronym&gt; ">&lt;acronym&gt;</a></li> <li><a href="tag_address.html" title="HTML &lt;address&gt; ">&lt;address&gt;</a></li> <li><a href="tag_applet.html" title="HTML &lt;applet&gt; ">&lt;applet&gt;</a></li> <li><a href="tag_area.html" title="HTML &lt;area&gt; ">&lt;area&gt;</a></li> <li><a href="tag_article.html" title="HTML &lt;article&gt; ">&lt;article&gt;</a></li> <li><a href="tag_aside.html" title="HTML &lt;aside&gt; ">&lt;aside&gt;</a></li> <li><a href="tag_audio.html" title="HTML &lt;audio&gt; ">&lt;audio&gt;</a></li> <li class="currentLink"><a href="tag_b.html" title="HTML &lt;b&gt; ">&lt;b&gt;</a></li> <li><a href="tag_base.html" title="HTML &lt;base&gt; ">&lt;base&gt;</a></li> <li><a href="tag_basefont.html" title="HTML &lt;basefont&gt; ">&lt;basefont&gt;</a></li> <li><a href="tag_bdi.html" title="HTML &lt;bdi&gt; ">&lt;bdi&gt;</a></li> <li><a href="tag_bdo.html" title="HTML &lt;bdo&gt; ">&lt;bdo&gt;</a></li> <li><a href="tag_big.html" title="HTML &lt;big&gt; ">&lt;big&gt;</a></li> <li><a href="tag_blockquote.html" title="HTML &lt;blockquote&gt; ">&lt;blockquote&gt;</a></li> <li><a href="tag_body.html" title="HTML &lt;body&gt; ">&lt;body&gt;</a></li> <li><a href="tag_br.html" title="HTML &lt;br&gt; ">&lt;br&gt;</a></li> <li><a href="tag_button.html" title="HTML &lt;button&gt; ">&lt;button&gt;</a></li> <li><a href="tag_canvas.html" title="HTML &lt;canvas&gt; ">&lt;canvas&gt;</a></li> <li><a href="tag_caption.html" title="HTML &lt;caption&gt; ">&lt;caption&gt;</a></li> <li><a href="tag_center.asp" title="HTML &lt;center&gt; ">&lt;center&gt;</a></li> <li><a href="tag_cite.html" title="HTML &lt;cite&gt; ">&lt;cite&gt;</a></li> <li><a href="tag_phrase_elements.html" title="HTML &lt;code&gt; ">&lt;code&gt;</a></li> <li><a href="tag_col.html" title="HTML &lt;col&gt; ">&lt;col&gt;</a></li> <li><a href="tag_colgroup.html" title="HTML &lt;colgroup&gt; ">&lt;colgroup&gt;</a></li> <li><a href="tag_command.html" title="HTML &lt;command&gt; ">&lt;command&gt;</a></li> <li><a href="tag_datalist.html" title="HTML &lt;datalist&gt; ">&lt;datalist&gt;</a></li> <li><a href="tag_dd.html" title="HTML &lt;dd&gt; ">&lt;dd&gt;</a></li> <li><a href="tag_del.html" title="HTML &lt;del&gt; ">&lt;del&gt;</a></li> <li><a href="tag_details.asp" title="HTML &lt;details&gt; ">&lt;details&gt;</a></li> <li><a href="tag_phrase_elements.html" title="HTML &lt;dfn&gt; ">&lt;dfn&gt;</a></li> <li><a href="tag_dialog.html" title="HTML &lt;dialog&gt; ">&lt;dialog&gt;</a></li> <li><a href="tag_dir.html" title="HTML &lt;dir&gt; ">&lt;dir&gt;</a></li> <li><a href="tag_div.html" title="HTML &lt;div&gt; ">&lt;div&gt;</a></li> <li><a href="tag_dl.html" title="HTML &lt;dl&gt; ">&lt;dl&gt;</a></li> <li><a href="tag_dt.html" title="HTML &lt;dt&gt; ">&lt;dt&gt;</a></li> <li><a href="tag_phrase_elements.html" title="HTML &lt;em&gt; ">&lt;em&gt;</a></li> <li><a href="tag_embed.asp" title="HTML &lt;embed&gt; ">&lt;embed&gt;</a></li> <li><a href="tag_fieldset.html" title="HTML &lt;fieldset&gt; ">&lt;fieldset&gt;</a></li> <li><a href="tag_figcaption.html" title="HTML &lt;figcaption&gt; ">&lt;figcaption&gt;</a></li> <li><a href="tag_figure.html" title="HTML &lt;figure&gt; ">&lt;figure&gt;</a></li> <li><a href="tag_font.html" title="HTML &lt;font&gt; ">&lt;font&gt;</a></li> <li><a href="tag_footer.html" title="HTML &lt;footer&gt; ">&lt;footer&gt;</a></li> <li><a href="tag_form.html" title="HTML &lt;form&gt; ">&lt;form&gt;</a></li> <li><a href="tag_frame.asp" title="HTML &lt;frame&gt; ">&lt;frame&gt;</a></li> <li><a href="tag_frameset.html" title="HTML &lt;frameset&gt; ">&lt;frameset&gt;</a></li> <li><a href="tag_hn.html" title="HTML &lt;h1&gt; - &lt;h6&gt; ">&lt;h1&gt; - &lt;h6&gt;</a></li> <li><a href="tag_head.html" title="HTML &lt;head&gt; ">&lt;head&gt;</a></li> <li><a href="tag_header.html" title="HTML &lt;header&gt; ">&lt;header&gt;</a></li> <li><a href="tag_hr.asp" title="HTML &lt;hr&gt; ">&lt;hr&gt;</a></li> <li><a href="tag_html.html" title="HTML &lt;html&gt; ">&lt;html&gt;</a></li> <li><a href="tag_i.html" title="HTML &lt;i&gt; ">&lt;i&gt;</a></li> <li><a href="tag_iframe.html" title="HTML &lt;iframe&gt; ">&lt;iframe&gt;</a></li> <li><a href="tag_img.html" title="HTML &lt;img&gt; ">&lt;img&gt;</a></li> <li><a href="tag_input.html" title="HTML &lt;input&gt; ">&lt;input&gt;</a></li> <li><a href="tag_ins.html" title="HTML &lt;ins&gt; ">&lt;ins&gt;</a></li> <li><a href="tag_phrase_elements.html" title="HTML &lt;kbd&gt; ">&lt;kbd&gt;</a></li> <li><a href="tag_keygen.html" title="HTML &lt;keygen&gt; ">&lt;keygen&gt;</a></li> <li><a href="tag_label.html" title="HTML &lt;label&gt; ">&lt;label&gt;</a></li> <li><a href="tag_legend.html" title="HTML &lt;legend&gt; ">&lt;legend&gt;</a></li> <li><a href="tag_li.asp" title="HTML &lt;li&gt; ">&lt;li&gt;</a></li> <li><a href="tag_link.html" title="HTML &lt;link&gt; ">&lt;link&gt;</a></li> <li><a href="tag_main.html" title="HTML &lt;main&gt; ">&lt;main&gt;</a></li> <li><a href="tag_map.html" title="HTML &lt;map&gt; ">&lt;map&gt;</a></li> <li><a href="tag_mark.html" title="HTML &lt;mark&gt; ">&lt;mark&gt;</a></li> <li><a href="tag_menu.html" title="HTML &lt;menu&gt; ">&lt;menu&gt;</a></li> <li><a href="tag_menuitem.html" title="HTML &lt;menuitem&gt; ">&lt;menuitem&gt;</a></li> <li><a href="tag_meta.html" title="HTML &lt;meta&gt; ">&lt;meta&gt;</a></li> <li><a href="tag_meter.html" title="HTML &lt;meter&gt; ">&lt;meter&gt;</a></li> <li><a href="tag_nav.html" title="HTML &lt;nav&gt; ">&lt;nav&gt;</a></li> <li><a href="tag_noframes.html" title="HTML &lt;noframes&gt; ">&lt;noframes&gt;</a></li> <li><a href="tag_noscript.html" title="HTML &lt;noscript&gt; ">&lt;noscript&gt;</a></li> <li><a href="tag_object.html" title="HTML &lt;object&gt; ">&lt;object&gt;</a></li> <li><a href="tag_ol.html" title="HTML &lt;ol&gt; ">&lt;ol&gt;</a></li> <li><a href="tag_optgroup.html" title="HTML &lt;optgroup&gt; ">&lt;optgroup&gt;</a></li> <li><a href="tag_option.html" title="HTML &lt;option&gt; ">&lt;option&gt;</a></li> <li><a href="tag_output.html" title="HTML &lt;output&gt; ">&lt;output&gt;</a></li> <li><a href="tag_p.html" title="HTML &lt;p&gt; ">&lt;p&gt;</a></li> <li><a href="tag_param.html" title="HTML &lt;param&gt; ">&lt;param&gt;</a></li> <li><a href="tag_pre.asp" title="HTML &lt;pre&gt; ">&lt;pre&gt;</a></li> <li><a href="tag_progress.html" title="HTML &lt;progress&gt; ">&lt;progress&gt;</a></li> <li><a href="tag_q.html" title="HTML &lt;q&gt; ">&lt;q&gt;</a></li> <li><a href="tag_rp.html" title="HTML &lt;rp&gt; ">&lt;rp&gt;</a></li> <li><a href="tag_rt.html" title="HTML &lt;rt&gt; ">&lt;rt&gt;</a></li> <li><a href="tag_ruby.html" title="HTML &lt;ruby&gt; ">&lt;ruby&gt;</a></li> <li><a href="tag_s.html" title="HTML &lt;s&gt; ">&lt;s&gt;</a></li> <li><a href="tag_phrase_elements.html" title="HTML &lt;samp&gt; ">&lt;samp&gt;</a></li> <li><a href="tag_script.html" title="HTML &lt;script&gt; ">&lt;script&gt;</a></li> <li><a href="tag_section.html" title="HTML &lt;section&gt; ">&lt;section&gt;</a></li> <li><a href="tag_select.html" title="HTML &lt;select&gt; ">&lt;select&gt;</a></li> <li><a href="tag_small.html" title="HTML &lt;small&gt; ">&lt;small&gt;</a></li> <li><a href="tag_source.html" title="HTML &lt;source&gt; ">&lt;source&gt;</a></li> <li><a href="tag_span.html" title="HTML &lt;span&gt; ">&lt;span&gt;</a></li> <li><a href="tag_strike.html" title="HTML &lt;strike&gt; ">&lt;strike&gt;</a></li> <li><a href="tag_phrase_elements.html" title="HTML &lt;strong&gt; ">&lt;strong&gt;</a></li> <li><a href="tag_style.html" title="HTML &lt;style&gt; ">&lt;style&gt;</a></li> <li><a href="tag_sub.html" title="HTML &lt;sub&gt; ">&lt;sub&gt;</a></li> <li><a href="tag_summary.asp" title="HTML &lt;summary&gt; ">&lt;summary&gt;</a></li> <li><a href="tag_sup.html" title="HTML &lt;sup&gt; ">&lt;sup&gt;</a></li> <li><a href="tag_table.html" title="HTML &lt;table&gt; ">&lt;table&gt;</a></li> <li><a href="tag_tbody.html" title="HTML &lt;tbody&gt; ">&lt;tbody&gt;</a></li> <li><a href="tag_td.html" title="HTML &lt;td&gt; ">&lt;td&gt;</a></li> <li><a href="tag_textarea.html" title="HTML &lt;textarea&gt; ">&lt;textarea&gt;</a></li> <li><a href="tag_tfoot.html" title="HTML &lt;tfoot&gt; ">&lt;tfoot&gt;</a></li> <li><a href="tag_th.html" title="HTML &lt;th&gt; ">&lt;th&gt;</a></li> <li><a href="tag_thead.html" title="HTML &lt;thead&gt; ">&lt;thead&gt;</a></li> <li><a href="tag_time.html" title="HTML &lt;time&gt; ">&lt;time&gt;</a></li> <li><a href="tag_title.html" title="HTML &lt;title&gt; ">&lt;title&gt;</a></li> <li><a href="tag_tr.html" title="HTML &lt;tr&gt; ">&lt;tr&gt;</a></li> <li><a href="tag_track.html" title="HTML &lt;track&gt; ">&lt;track&gt;</a></li> <li><a href="tag_tt.html" title="HTML &lt;tt&gt; ">&lt;tt&gt;</a></li> <li><a href="tag_u.html" title="HTML &lt;u&gt; ">&lt;u&gt;</a></li> <li><a href="tag_ul.html" title="HTML &lt;ul&gt; ">&lt;ul&gt;</a></li> <li><a href="tag_phrase_elements.html" title="HTML &lt;var&gt; ">&lt;var&gt;</a></li> <li><a href="tag_video.html" title="HTML &lt;video&gt; ">&lt;video&gt;</a></li> <li><a href="tag_wbr.html" title="HTML &lt;wbr&gt; ">&lt;wbr&gt;</a></li> </ul> </div><div id="selected"> <h2></h2> <ul> <li><a href="../site/index.html" title=""></a></li> <li><a href="../w3c/index.html" title=" (W3C)"> (W3C)</a></li> <li><a href="../browsers/index.html" title=""></a></li> <li><a href="../quality/index.html" title=""></a></li> <li><a href="../semweb/index.html" title=""></a></li> <li><a href="../careers/index.asp" title=""></a></li> <li><a href="../hosting/index.html" title=""></a></li> </ul> <h2><a href="../about/index.html" title=" W3School" id="link_about"> W3School</a></h2> <h2><a href="../about/about_helping.html" title=" W3School" id="link_help"> W3School</a></h2> </div> </div> <div id="maincontent"> <h1>HTML &lt;b&gt; </h1> <div> <h2></h2> <pre>&lt;p&gt; - &lt;b&gt;&lt;/b&gt;&lt;/p&gt;</pre> <p class="tiy"><a target="_blank" href="../tiy/t0efb.html?f=html_b"></a></p> </div> <div> <h2></h2> <table class="dataintable browsersupport"> <tr> <th>IE</th> <th>Firefox</th> <th>Chrome</th> <th>Safari</th> <th>Opera</th> </tr> <tr> <td class="bsIE"></td> <td class="bsFirefox"></td> <td class="bsChrome"></td> <td class="bsSafari"></td> <td class="bsOpera"></td> </tr> </table> <p> &lt;b&gt; </p> </div> <div> <h2></h2> <p>&lt;b&gt; </p> </div> <div> <h2>HTML 4.01 HTML5 </h2> <p></p> </div> <div> <h2></h2> <p class="note"><span></span> HTML5 &lt;b&gt; HTML5 <a href="tag_hn.html" title="HTML &lt;h1&gt; - &lt;h6&gt; ">&lt;h1&gt; - &lt;h6&gt;</a> <a href="tag_phrase_elements.html" title="HTML &lt;em&gt; ">&lt;em&gt;</a> <a href="tag_phrase_elements.html" title="HTML &lt;strong&gt; ">&lt;strong&gt;</a> &lt;mark&gt; /</p> <p class="tip"><span></span> CSS &quot;<a href="../cssref/pr_font_weight.html" title="CSS font-weight ">font-weight</a>&quot; </p> </div> <div> <h2></h2> <p>&lt;b&gt; <a href="<API key>.html">HTML </a></p> </div> <div> <h2></h2> <p>&lt;b&gt; <a href="<API key>.html">HTML </a></p> </div> </div> <!-- maincontent end --> <div id="sidebar"> <div id="searchui"> <form method="get" id="searchform" action="http: <p><label for="searched_content">Search:</label></p> <p><input type="hidden" name="sitesearch" value="w3school.com.cn" /></p> <p> <input type="text" name="as_q" class="box" id="searched_content" title="" /> <input type="submit" value="Go" class="button" title="" /> </p> </form> </div> <div id="tools"> <h5 id="tools_reference"><a href="index.html">HTML </a></h5> <h5 id="tools_example"><a href="../example/html_examples.html">HTML </a></h5> <h5 id="tools_quiz"><a href="../html/html_quiz.html">HTML </a></h5> </div> <div id="ad"> <script type="text/javascript"><! google_ad_client = "<API key>"; /* sidebar-160x600 */ google_ad_slot = "3772569310"; google_ad_width = 160; google_ad_height = 600; </script> <script type="text/javascript" src="../../pagead2.googlesyndication.com/pagead/f.txt"> </script> </div> </div> <div id="footer"> <p> W3School W3School </p> <p> <a href="../about/about_use.html" title=""></a><a href="../about/about_privacy.html" title=""></a> <a href="http: <a href="http: </p> </div> </div> <!-- wrapper end --> </body> </html>
<!DOCTYPE html> <html> <head> <title>Tryit Editor v2.1 - Show PHP</title> <link rel="stylesheet" href="../trycss.css"> <!--[if lt IE 8]> <style> .textarea, .iframe {height:800px;} #iframeSource, #iframeResult {height:700px;} </style> <![endif] <script> (function(i,s,o,g,r,a,m){i['<API key>']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.<API key>(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','../../www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-3855518-1', 'auto'); ga('require', 'displayfeatures'); ga('send', 'pageview'); </script> <script type='text/javascript'> var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; (function() { var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; var useSSL = 'https:' == document.location.protocol; gads.src = (useSSL ? 'https:' : 'http:') + ' var node = document.<API key>('script')[0]; node.parentNode.insertBefore(gads, node); })(); </script> <script type='text/javascript'> googletag.cmd.push(function() { googletag.defineSlot('/16833175/TryitLeaderboard', [[728, 90], [970, 90]], '<API key>').addService(googletag.pubads()); googletag.pubads().setTargeting("content","tryphp"); googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); </script> </head> <body> <div style="position:relative;width:100%;margin-top:0px;margin-bottom:0px;"> <div style="width:974px;height:94px;position:relative;margin:0px;margin-left:auto;margin-right:auto;margin-top:5px;margin-bottom:5px;padding:0px;overflow:hidden;"> <!-- TryitLeaderboard --> <div id='<API key>' style='width:970px; height:90px;'> <script type='text/javascript'> googletag.cmd.push(function() { googletag.display('<API key>'); }); </script> </div> <div style="clear:both"></div> </div> </div> <div class="container"> <div class="textareacontainer"> <div class="textarea"> <div class="headerText">PHP Source:</div> <div class="iframewrapper"> <iframe id="iframeSource" frameborder="0" src="showphpcode2ce4.html?source=<API key>"></iframe> </div> </div> </div> <div class="iframecontainer"> <div class="iframe"> <div class="headerText">Result:</div> <div class="iframewrapper"> <iframe id="iframeResult" frameborder="0" src="<API key>.html"></iframe> </div> <div class="footerText">Show PHP - &copy; <a href="../index.html">w3schools.com</a></div> </div> </div> </div> </body> </html>
/* line 2, ../scss/neat/grid/_grid.scss */ * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } @font-face { font-family: 'oswaldregular'; src: url("../fonts/oswald_emdash/<API key>.eot"); src: url("../fonts/oswald_emdash/<API key>.eot?#iefix") format("embedded-opentype"), url("../fonts/oswald_emdash/<API key>.woff") format("woff"), url("../fonts/oswald_emdash/<API key>.ttf") format("truetype"), url("../fonts/oswald_emdash/<API key>.svg#oswaldregular") format("svg"); font-weight: normal; font-style: normal; } @font-face { font-family: 'pt-serif'; src: url("../fonts/pt-serif/<API key>.woff2") format("woff2"), url("../fonts/pt-serif/<API key>.woff") format("woff"); font-weight: normal; font-style: normal; } @font-face { font-family: 'pt-serif-bold'; src: url("../fonts/pt-serif/<API key>.woff2") format("woff2"), url("../fonts/pt-serif/<API key>.woff") format("woff"); font-weight: normal; font-style: normal; } @font-face { font-family: 'pt-serif-italic'; src: url("../fonts/pt-serif/<API key>.woff2") format("woff2"), url("../fonts/pt-serif/<API key>.woff") format("woff"); font-weight: normal; font-style: normal; } /* line 2, ../scss/placeholders/_story.scss */ .hero--cover.hero--story { height: 100vh; max-height: none; margin-top: -10.4rem; padding-top: 10.4rem; padding-bottom: 0; background-origin: content-box; } /* line 10, ../scss/placeholders/_story.scss */ .hero--cover.hero--story .container { max-width: none; } /* line 13, ../scss/placeholders/_story.scss */ .hero--cover.hero--story .container .<API key> { width: 100%; height: 100%; } /* line 17, ../scss/placeholders/_story.scss */ .hero--cover.hero--story .container .<API key>.video-container iframe, .hero--cover.hero--story .container .<API key>.video-container object, .hero--cover.hero--story .container .<API key>.video-container embed { position: static; top: 0; left: 0; width: 100%; height: 100vh; margin-top: -104px; padding-top: 104px; } /* line 31, ../scss/placeholders/_story.scss */ .hero--cover.hero--image.hero--story { background-size: cover; background-position: center; background-repeat: no-repeat; } /* line 36, ../scss/placeholders/_story.scss */ .hero--cover.hero--image.hero--story .hero-read { position: absolute; right: 0; bottom: 0; left: 0; text-align: center; } /* line 43, ../scss/placeholders/_story.scss */ .hero--cover.hero--image.hero--story .hero-read .hero-read-link { display: inline-block; font-family: "oswaldregular", Arial, sans-serif; font-size: 2.0rem; color: #fff; background: #dd322c; text-transform: uppercase; padding: 1.0rem 1.5rem; text-rendering: optimizeLegibility; -<API key>: antialiased; -<API key>: grayscale; -webkit-transition: padding 0.25s ease-out; -moz-transition: padding 0.25s ease-out; transition: padding 0.25s ease-out; } /* line 58, ../scss/placeholders/_story.scss */ .hero--cover.hero--image.hero--story .hero-read .hero-read-link:hover { padding: 1.5rem 1.5rem; } /* line 62, ../scss/placeholders/_story.scss */ .hero--cover.hero--image.hero--story .hero-read .hero-read-link:after { content: "\25be"; position: relative; top: -2px; margin-left: 1rem; } /* line 74, ../scss/placeholders/_story.scss */ .story__main-column .hero--cover.hero--story { padding-bottom: 0; height: auto; max-height: none; } /* line 79, ../scss/placeholders/_story.scss */ .story__main-column .hero--cover.hero--story img { max-width: 100%; display: block; } /* line 86, ../scss/placeholders/_story.scss */ .<API key> .hero--cover.hero--story { padding-bottom: 0; height: auto; max-height: none; } /* line 91, ../scss/placeholders/_story.scss */ .<API key> .hero--cover.hero--story img { max-width: 100%; display: block; } /** * buttons */ /* line 4, ../scss/partials/desktop-small/_buttons.scss */ .btn--solid { font-size: 1.76rem; } /* line 9, ../scss/partials/desktop-small/_buttons.scss */ .btn.btn--take-action { font-size: 1.74rem; } /** * components */ /* line 19, ../scss/partials/desktop-small/_buttons.scss */ .indicator.indicator--module:before { font-size: 5.8rem; } /* line 25, ../scss/partials/desktop-small/_buttons.scss */ .google_top_posts { width: 100%; } /* module */ /* line 31, ../scss/partials/desktop-small/_buttons.scss */ .module.module--sidebar { width: 100%; } /* line 36, ../scss/partials/desktop-small/_buttons.scss */ .module.module--list.module--horizontal { margin: 5rem 0; } /* line 39, ../scss/partials/desktop-small/_buttons.scss */ .module.module--list.module--horizontal .story-list li { margin-right: 4%; } /* author */ /* line 2, ../scss/partials/desktop-small/_components.scss */ .author-box { margin-bottom: 7.2rem; } /* line 6, ../scss/partials/desktop-small/_components.scss */ .author__a { float: none; } /* line 10, ../scss/partials/desktop-small/_components.scss */ .author__b { margin-top: 2.2rem; padding-left: 0; text-align: center; } /** * forms */ /* line 5, ../scss/partials/desktop-small/_forms.scss */ .form-element .text-input { padding: 1.15rem 1.4rem; } /** * headings */ /* line 4, ../scss/partials/desktop-small/_headings.scss */ .hd-b { font-size: 2.8rem; } /* line 8, ../scss/partials/desktop-small/_headings.scss */ .hd-d { font-size: 2.8rem; } /* line 12, ../scss/partials/desktop-small/_headings.scss */ .hd-f { font-size: 4.4rem; padding: 0.5rem; line-height: 1.66; } /* line 18, ../scss/partials/desktop-small/_headings.scss */ .hd-l { font-size: 2.6rem; } /** * homepage */ /* hero */ /* line 10, ../scss/partials/desktop-small/_homepage.scss */ .hero--homepage.hero--grid .hero__entry.hero__entry--1:before { margin-right: 2px; } /* line 14, ../scss/partials/desktop-small/_homepage.scss */ .hero--homepage.hero--grid .hero__entry.hero__entry--1 .story__hed { margin-bottom: 3.4rem; } /* line 18, ../scss/partials/desktop-small/_homepage.scss */ .hero--homepage.hero--grid .hero__entry.hero__entry--1 .support-cause--hero { margin-bottom: 3.2rem; } /* line 25, ../scss/partials/desktop-small/_homepage.scss */ .hero--homepage.hero--grid .hero__entry.hero__entry--2.hero__entry--2:before { margin-bottom: 2px; } /* line 31, ../scss/partials/desktop-small/_homepage.scss */ .hero--homepage.hero--grid .hero__entry .story--hero { padding: 2.4rem 4.4rem; } /* line 34, ../scss/partials/desktop-small/_homepage.scss */ .hero--homepage.hero--grid .hero__entry .story--hero .story_dek { font-size: 1.8rem; } /* river */ /* line 45, ../scss/partials/desktop-small/_homepage.scss */ .river--one-col .story-teases .story--tease { margin-bottom: 0rem; } /* line 49, ../scss/partials/desktop-small/_homepage.scss */ .river--one-col .story-teases .story--tease:last-child { margin-bottom: 3.4rem; } /* line 53, ../scss/partials/desktop-small/_homepage.scss */ .river--one-col .story-teases .story--tease:hover { background-color: transparent; box-shadow: none; } /* line 57, ../scss/partials/desktop-small/_homepage.scss */ .river--one-col .story-teases .story--tease .support-cause { display: none; } /** * story */ /* sticky */ /* line 10, ../scss/partials/desktop-small/_story.scss */ .<API key> { width: 14.6rem; } /* line 16, ../scss/partials/desktop-small/_story.scss */ .module.take-action .take-action__a, .module.take-action .take-action__b { width: 100%; float: none; padding: none; } /* line 23, ../scss/partials/desktop-small/_story.scss */ .module.take-action .take-action__a { margin-bottom: 1.2rem; } /* line 27, ../scss/partials/desktop-small/_story.scss */ .module.take-action .module.take-action .take-action__a + .take-action__b { padding-left: 3.4rem; } /* line 31, ../scss/partials/desktop-small/_story.scss */ .module.take-action .<API key> { max-width: 22rem; } /** * structure */ /* line 4, ../scss/partials/desktop-small/_structure.scss */ .container { max-width: 98.4rem; padding: 0 2rem; } /* line 8, ../scss/partials/desktop-small/_structure.scss */ .container.container--flex { width: auto; display: block; display: -webkit-box; display: -webkit-flex; display: flex; } /* line 18, ../scss/partials/desktop-small/_structure.scss */ #page-wrapper { min-width: 768px; width: 100%; } /* line 23, ../scss/partials/desktop-small/_structure.scss */ .story__sticky { -webkit-box-flex: 1; width: auto; min-width: 14.6rem; max-width: 15.63786%; } /* line 30, ../scss/partials/desktop-small/_structure.scss */ .story__main-column { -webkit-box-flex: 1; width: auto; max-width: 49.38272%; float: none; padding-left: 2rem; } /* line 38, ../scss/partials/desktop-small/_structure.scss */ .<API key> { -webkit-box-flex: 1; width: auto; float: none; padding-left: 2rem; } /* line 45, ../scss/partials/desktop-small/_structure.scss */ .sidebar { -webkit-box-flex: 1; padding-left: 2rem; width: auto; min-width: 32rem; max-width: 32.51029%; } /* line 54, ../scss/partials/desktop-small/_structure.scss */ .hero .hero-information .<API key> { margin-left: 0; width: 100%; } /* line 59, ../scss/partials/desktop-small/_structure.scss */ .hero .hero-information .<API key> { margin-left: 0; } /* line 63, ../scss/partials/desktop-small/_structure.scss */ .hero .hero-information .<API key> { float: right; } /* line 67, ../scss/partials/desktop-small/_structure.scss */ .hero .hero-information .<API key> { margin-left: 0; } /* line 71, ../scss/partials/desktop-small/_structure.scss */ .hero .hero-information .<API key> { float: right; } /* line 76, ../scss/partials/desktop-small/_structure.scss */ .river .story-teases { -webkit-box-flex: 1; width: auto; min-height: 25px; } /* line 81, ../scss/partials/desktop-small/_structure.scss */ .river .story-teases:last-child { margin-right: 1.23457%; } /* line 88, ../scss/partials/desktop-small/_structure.scss */ .river.river--one-col .story-teases .story__feature { width: 50%; } /* line 95, ../scss/partials/desktop-small/_structure.scss */ .module.module--list.module--horizontal .story-list li { margin-right: 3.82%; } /* line 99, ../scss/partials/desktop-small/_structure.scss */ .footer-links { position: absolute; bottom: 3rem; right: 0; max-width: 41.5rem; margin-top: 0; } /* line 108, ../scss/partials/desktop-small/_structure.scss */ .<API key> { display: block; float: none; margin-right: 2.35765%; } /*# sourceMappingURL=desktop-small.css.map */
<?php /** * @file * @brief Tests for Scan model */ namespace Fossology\UI\Api\Test\Models { use Mockery as M; use Fossology\UI\Api\Models\Analysis; use Fossology\UI\Api\Models\ScanOptions; use Fossology\UI\Api\Models\Reuser; use Fossology\UI\Api\Models\Decider; use Fossology\Lib\Dao\UserDao; use Fossology\Lib\Auth\Auth; use Symfony\Component\HttpFoundation\Request; /** * @class ScanOptionsTest * @brief Tests for ScanOption model */ class ScanOptionsTest extends \PHPUnit\Framework\TestCase { /** * @var \Mockery\MockInterface $functions * Public function mock */ public static $functions; /** * @var AgentAdder $agentAdderMock * Mock object of overloaded AgentAdder class */ private $agentAdderMock; /** * @var UserDao $userDao * UserDao mock */ private $userDao; /** * @brief Setup test objects * @see <API key>::setUp() */ public function setUp() : void { global $container; $container = M::mock('ContainerBuilder'); $this->agentAdderMock = M::mock('overload:\AgentAdder'); $this->userDao = M::mock(UserDao::class); $container->shouldReceive('get')->withArgs(["dao.user"]) ->andReturn($this->userDao); $container->shouldReceive('get')->andReturn(null); self::$functions = M::mock(\stdClass::class); self::$functions->shouldReceive('<API key>') ->withArgs([2, Auth::PERM_WRITE])->andReturn([ ['upload_pk' => 2], ['upload_pk' => 3], ['upload_pk' => 4] ]); self::$functions->shouldReceive('register_plugin') ->with(\Hamcrest\Matchers::identicalTo( new ScanOptions(null, null, null))); } /** * Prepare request for scan * @param Request $request * @param array $reuserOpts * @param array $deciderOpts * @return Request */ private function prepareRequest($request, $reuserOpts, $deciderOpts) { if (!empty($reuserOpts)) { $reuserSelector = $reuserOpts['upload'] . "," . $reuserOpts['group']; $request->request->set('uploadToReuse', $reuserSelector); if (key_exists('rules', $reuserOpts)) { $request->request->set('reuseMode', $reuserOpts['rules']); } } if (!empty($deciderOpts)) { $request->request->set('deciderRules', $deciderOpts); if (in_array('nomosInMonk', $deciderOpts)) { $request->request->set('Check_agent_nomos', 1); } } return $request; } /** * @test * -# Test for ScanOptions::scheduleAgents() * -# Prepare Request and call ScanOptions::scheduleAgents() * -# Function should call AgentAdder::scheduleAgents() */ public function testScheduleAgents() { $reuseUploadId = 2; $uploadId = 4; $folderId = 2; $groupId = 2; $groupName = "fossy"; $agentsToAdd = ['agent_nomos', 'agent_ojo', 'agent_monk']; $reuserOpts = [ 'upload' => $reuseUploadId, 'group' => $groupId, 'rules' => [] ]; $deciderOpts = [ 'nomosInMonk', 'ojoNoContradiction' ]; $request = new Request(); $request = $this->prepareRequest($request, $reuserOpts, $deciderOpts); $analysis = new Analysis(); $analysis->setUsingString("nomos,ojo,monk"); $reuse = new Reuser($reuseUploadId, $groupName); $decider = new Decider(); $decider->setOjoDecider(true); $decider->setNomosMonk(true); $scanOption = new ScanOptions($analysis, $reuse, $decider); $this->userDao->shouldReceive('getGroupIdByName') ->withArgs([$groupName])->andReturn($groupId); $this->agentAdderMock->shouldReceive('scheduleAgents') ->once() ->andReturn(25); $scanOption->scheduleAgents($folderId, $uploadId); } } } namespace Fossology\UI\Api\Models { function register_plugin($obj) { return \Fossology\Ui\Api\Test\Models\ScanOptionsTest::$functions ->register_plugin($obj); } function <API key>($parentFolder, $perm) { return \Fossology\Ui\Api\Test\Models\ScanOptionsTest::$functions -><API key>($parentFolder, $perm); } }
require.config({ baseUrl: './scripts', paths: { 'angular': 'vendor/angular/angular', 'angular-route': 'vendor/angular-route/angular-route' }, shim: { 'angular': { exports: 'angular' }, 'angular-route': { deps: ['angular'] } }, deps: ['./bootstrap', 'angular', 'angular-route'] })
package guitetris; import java.io.File; import java.io.IOException; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.Line; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineEvent.Type; import javax.sound.sampled.LineListener; import javax.sound.sampled.<API key>; public class Audio { private static Thread CurrentClip; /** * Reproduce un archivo en bucle entre las posiciones dadas. * * @param filePath Ruta al archivo. * @param start Frame de inicio de bucle. * @param end Frame final del bucle. */ public static void PlayClipLoop(String filePath, int start, int end) { PlayClipLoop clip = new PlayClipLoop(filePath, start, end); CurrentClip = clip; clip.start(); } /** * Para la reproducir del audio. */ public static void Stop() { if (CurrentClip != null && CurrentClip.isAlive()) { CurrentClip.interrupt(); CurrentClip = null; } } /** * Hebra encargada de reproducir en bucle un audio. */ private static class PlayClipLoop extends Thread { private final File clipFile; private final int start; private final int end; private AudioListener listener; private Line line; /** * Crea una nueva instancia de la hebra. * * @param filePath Ruta al archivo. * @param start Frame de inicio del bucle. * @param end Frame de fin de bucle. */ public PlayClipLoop(String filePath, int start, int end) { this.clipFile = new File(filePath); this.start = start; this.end = end; } @Override public void run() { this.listener = new AudioListener(); try (AudioInputStream audioInStr = AudioSystem.getAudioInputStream(clipFile)) { try (Clip clip = AudioSystem.getClip()) { this.line = clip; clip.addLineListener(listener); clip.open(audioInStr); clip.setLoopPoints(start, end); clip.loop(Clip.LOOP_CONTINUOUSLY); listener.waitUntilDone(); } catch (Exception ex) { System.err.println(ex.getMessage()); } } catch (IOException | <API key> | <API key> ex) { System.err.println(ex.getMessage()); } } @Override public void interrupt() { if (this.line != null && this.line.isOpen() && this.listener != null) this.listener.update( new LineEvent(this.line, Type.STOP, AudioSystem.NOT_SPECIFIED) ); super.interrupt(); } } private static class AudioListener implements LineListener { private boolean done = false; @Override public synchronized void update(LineEvent event) { Type eventType = event.getType(); if (eventType == Type.STOP || eventType == Type.CLOSE) { done = true; notifyAll(); } } public synchronized void waitUntilDone() throws <API key> { while (!done) { wait(); } } } }
package com.clustercontrol.jobmanagement.bean; /** * <BR> * * @version 1.0.0 * @since 1.0.0 */ public class RunStatusConstant { public static final int START = 0; public static final int END = 1; public static final int ERROR = 2; }
#ifndef <API key> #define <API key> // How to specify (and save memory!!) // that this matrix is symmetric? struct <API key> { union { struct { double xx; double yx; double zx; double xy; double yy; double zy; double xz; double yz; double zz; } data; double mem[9]; }; char *type; }; struct <API key> { union { struct { double ww; double xw; double yw; double zw; double wx; double xx; double yx; double zx; double wy; double xy; double yy; double zy; double wz; double xz; double yz; double zz; } data; double mem[16]; }; char *type; }; struct <API key> { union { struct { double xw; double yw; double zw; double xx; double yx; double zx; double xy; double yy; double zy; double xz; double yz; double zz; } data; double mem[12]; }; char *type; }; struct <API key>{ union { struct { double x_to_x; double y_to_x; double z_to_x; double x_to_y; double y_to_y; double z_to_y; double x_to_z; double y_to_z; double z_to_z; } data; double mem[9]; }; char *type; }; struct <API key>{ union { struct { double w_to_w; double x_to_w; double y_to_w; double z_to_w; double w_to_x; double x_to_x; double y_to_x; double z_to_x; double w_to_y; double x_to_y; double y_to_y; double z_to_y; double w_to_z; double x_to_z; double y_to_z; double z_to_z; } data; double mem[16]; }; char *type; }; struct <API key>{ union { struct { double x_to_w; double x_to_x; double x_to_y; double x_to_z; double y_to_w; double y_to_x; double y_to_y; double y_to_z; double z_to_w; double z_to_x; double z_to_y; double z_to_z; } data; double mem[12]; }; char *type; }; struct <API key>{ union { struct { double w_to_x; double w_to_y; double w_to_z; double x_to_x; double x_to_y; double x_to_z; double y_to_x; double y_to_y; double y_to_z; double z_to_x; double z_to_y; double z_to_z; } data; double mem[12]; }; char *type; }; #endif
#include "<API key>.h" #include "gtk_roccat_helper.h" #include "i18n-lib.h" // TODO add toggle handler // TODO make labels clickable #define <API key>(klass) (<API key>((klass), <API key>, <API key>)) #define <API key>(klass) (<API key>((klass), <API key>)) #define <API key>(obj) (<API key>((obj), <API key>, <API key>)) struct <API key> { GSList *radios; guint mask; }; enum { PROP_0, PROP_VALUE, PROP_MASK, }; enum { <API key> = 4, }; static gchar const * const value_key = "Value"; G_DEFINE_TYPE(<API key>, <API key>, GTK_TYPE_TABLE); guint <API key>(<API key> *selector) { return selector->priv->mask; } static void <API key>(<API key> *selector, guint value) { selector->priv->mask = value; } guint <API key>(<API key> *selector) { GtkWidget *active; active = <API key>(selector->priv->radios); if (active) return GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(active), value_key)); else return <API key>; } void <API key>(<API key> *selector, guint new_value) { GSList *element; guint value; for (element = selector->priv->radios; element; element = g_slist_next(element)) { value = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(element->data), value_key)); <API key>(GTK_TOGGLE_BUTTON(element->data), value == new_value); } } static GObject *<API key>(GType gtype, guint n_properties, <API key> *properties) { <API key> *priv; GObject *obj; GtkTable *table; GtkWidget *radio; guint i; guint column_number; struct { guint value; gchar *title; } radios[<API key>] = { {<API key>, "125"}, {<API key>, "250"}, {<API key>, "500"}, {<API key>, "1000"}, }; obj = G_OBJECT_CLASS(<API key>)->constructor(gtype, n_properties, properties); table = GTK_TABLE(obj); priv = <API key>(obj)->priv; priv->radios = NULL; column_number = 0; for (i = 0; i < <API key>; ++i) { if (radios[i].value & priv->mask) { radio = <API key>(priv->radios); g_object_set_data(G_OBJECT(radio), value_key, GUINT_TO_POINTER(radios[i].value)); priv->radios = <API key>(GTK_RADIO_BUTTON(radio)); gtk_table_attach(table, radio, column_number, column_number + 1, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); gtk_table_attach(table, gtk_label_new(radios[i].title), column_number, column_number + 1, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); ++column_number; } } return obj; } GtkWidget *<API key>(guint mask) { <API key> *selector; selector = g_object_new(<API key>, "mask", mask, NULL); return GTK_WIDGET(selector); } static void <API key>(GObject *object, guint prop_id, GValue const *value, GParamSpec *pspec) { <API key> *selector = <API key>(object); switch(prop_id) { case PROP_VALUE: <API key>(selector, g_value_get_uint(value)); break; case PROP_MASK: <API key>(selector, g_value_get_uint(value)); break; default: <API key>(object, prop_id, pspec); } } static void <API key>(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { <API key> *selector = <API key>(object); switch(prop_id) { case PROP_VALUE: g_value_set_uint(value, <API key>(selector)); break; case PROP_MASK: g_value_set_uint(value, <API key>(selector)); break; default: <API key>(object, prop_id, pspec); } } static void <API key>(<API key> *selector) { selector->priv = <API key>(selector); } static void <API key>(<API key> *klass) { GObjectClass *gobject_class; gobject_class = (GObjectClass *)klass; gobject_class->constructor = <API key>; gobject_class->set_property = <API key>; gobject_class->get_property = <API key>; <API key>(klass, sizeof(<API key>)); <API key>(gobject_class, PROP_VALUE, g_param_spec_uint("value", "value", "Reads or sets value", <API key>, <API key>, <API key>, G_PARAM_READWRITE)); <API key>(gobject_class, PROP_MASK, g_param_spec_uint("mask", "mask", "Reads or sets mask", <API key>, <API key>, <API key>, G_PARAM_READWRITE | <API key>)); }
#!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/indirector/file_bucket_file/rest' describe Puppet::FileBucketFile::Rest do it "should be a sublcass of Puppet::Indirector::REST" do Puppet::FileBucketFile::Rest.superclass.should equal(Puppet::Indirector::REST) end end
// $Id: globals.h 5721 2008-08-06 12:01:52Z wansti $ // SuperTux // Tobias Glaesser <tobi.web@gmx.de> // Ingo Ruhnke <grumbel@gmx.de> // This program is free software; you can redistribute it and/or // as published by the Free Software Foundation; either version 2 // This program is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_GLOBALS_H #define SUPERTUX_GLOBALS_H #include <string> #include <SDL.h> #include "text.h" #include "menu.h" #include "mousecursor.h" #ifdef GP2X #define GP2X_BUTTON_UP (0) #define GP2X_BUTTON_DOWN (4) #define GP2X_BUTTON_LEFT (2) #define GP2X_BUTTON_RIGHT (6) #define GP2X_BUTTON_UPLEFT (1) #define GP2X_BUTTON_UPRIGHT (7) #define <API key> (3) #define <API key> (5) #define GP2X_BUTTON_CLICK (18) #define GP2X_BUTTON_A (12) #define GP2X_BUTTON_B (13) #define GP2X_BUTTON_X (15) #define GP2X_BUTTON_Y (14) #define GP2X_BUTTON_L (10) #define GP2X_BUTTON_R (11) #define GP2X_BUTTON_START (8) #define GP2X_BUTTON_SELECT (9) #define GP2X_BUTTON_VOLUP (16) #define GP2X_BUTTON_VOLDOWN (17) #endif extern std::string datadir; struct JoystickKeymap { #ifndef GP2X int a_button; int b_button; int start_button; int x_axis; int y_axis; int dead_zone; JoystickKeymap(); #else int a_button; int b_button; int start_button; int up_button; int down_button; int left_button; int right_button; int volup_button; int voldown_button; JoystickKeymap(); #endif }; extern JoystickKeymap joystick_keymap; extern SDL_Surface * screen; extern Text* black_text; extern Text* gold_text; extern Text* silver_text; extern Text* white_text; extern Text* white_small_text; extern Text* white_big_text; extern Text* blue_text; extern Text* red_text; extern Text* green_text; extern Text* yellow_nums; extern MouseCursor * mouse_cursor; extern bool use_gl; extern bool use_joystick; extern bool use_fullscreen; extern bool debug_mode; extern bool show_fps; extern bool show_mouse; /** The number of the joystick that will be use in the game */ extern int joystick_num; extern char* level_startup_file; extern bool <API key>; /* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */ extern char* st_dir; extern char* st_save_dir; extern float game_speed; extern SDL_Joystick * js; int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false); #endif /* SUPERTUX_GLOBALS_H */
import pytest @pytest.fixture def create_repo(remote, token): repo = remote.new_repo(token) remote.modify_repo(repo, "name", "testrepo0", token) remote.modify_repo(repo, "mirror", "http: remote.modify_repo(repo, "mirror_locally", False, token) remote.save_repo(repo, token) @pytest.fixture def remove_repo(remote, token): """ Removes the Repository "testrepo0" which can be created with create_repo. :param remote: The xmlrpc object to connect to. :param token: The token to authenticate against the remote object. """ yield remote.remove_repo("testrepo0", token) @pytest.mark.usefixtures("cobbler_xmlrpc_base") class TestRepo: @pytest.mark.usefixtures("remove_repo") def test_create_repo(self, remote, token): """ Test: create/edit a repo object """ # Arrange --> Nothing to arrange # Act & Assert repo = remote.new_repo(token) assert remote.modify_repo(repo, "name", "testrepo0", token) assert remote.modify_repo(repo, "mirror", "http: assert remote.modify_repo(repo, "mirror_locally", False, token) assert remote.save_repo(repo, token) def test_get_repos(self, remote): """ Test: Get repos """ # Arrange --> Nothing to do # Act result = remote.get_repos() # Assert assert result == [] @pytest.mark.usefixtures("create_repo", "remove_repo") def test_get_repo(self, remote, token): """ Test: Get a repo object """ # Arrange --> Done in fixture # Act repo = remote.get_repo("testrepo0") # Assert assert repo.get("name") == "testrepo0" @pytest.mark.usefixtures("create_repo", "remove_repo") def test_find_repo(self, remote, token): """ Test: find a repo object """ # Arrange --> Done in fixture # Act result = remote.find_repo({"name": "testrepo0"}, token) # Assert assert result @pytest.mark.usefixtures("create_repo", "remove_repo") def test_copy_repo(self, remote, token): """ Test: copy a repo object """ # Arrange --> Done in fixture # Act repo = remote.get_item_handle("repo", "testrepo0", token) # Assert assert remote.copy_repo(repo, "testrepocopy", token) # Cleanup remote.remove_repo("testrepocopy", token) @pytest.mark.usefixtures("create_repo") def test_rename_repo(self, remote, token): """ Test: rename a repo object """ # Arrange # Act repo = remote.get_item_handle("repo", "testrepo0", token) result = remote.rename_repo(repo, "testrepo1", token) # Assert assert result # Cleanup remote.remove_repo("testrepo1", token) @pytest.mark.usefixtures("create_repo") def test_remove_repo(self, remote, token): """ Test: remove a repo object """ # Arrange --> Done in fixture # Act result = remote.remove_repo("testrepo0", token) # Assert assert result
#include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "../port/error.h" /* * real time clock and non-volatile ram */ enum { Paddr= 0x70, /* address port */ Pdata= 0x71, /* data port */ Seconds= 0x00, Minutes= 0x02, Hours= 0x04, Mday= 0x07, Month= 0x08, Year= 0x09, Status= 0x0A, Nvoff= 128, /* where usable nvram lives */ Nvsize= 256, Nbcd= 6, }; typedef struct Rtc Rtc; struct Rtc { int sec; int min; int hour; int mday; int mon; int year; }; enum{ Qdir = 0, Qrtc, Qnvram, }; Dirtab rtcdir[]={ ".", {Qdir, 0, QTDIR}, 0, 0555, "nvram", {Qnvram, 0}, Nvsize, 0664, "rtc", {Qrtc, 0}, 0, 0664, }; static ulong rtc2sec(Rtc*); static void sec2rtc(ulong, Rtc*); void rtcinit(void) { if(ioalloc(Paddr, 2, 0, "rtc/nvr") < 0) panic("rtcinit: ioalloc failed"); } static Chan* rtcattach(char* spec) { return devattach('r', spec); } static Walkqid* rtcwalk(Chan* c, Chan *nc, char** name, int nname) { return devwalk(c, nc, name, nname, rtcdir, nelem(rtcdir), devgen); } static long rtcstat(Chan* c, uchar* dp, long n) { return devstat(c, dp, n, rtcdir, nelem(rtcdir), devgen); } static Chan* rtcopen(Chan* c, int omode) { omode = openmode(omode); switch((ulong)c->qid.path){ case Qrtc: if(strcmp(up->user, eve)!=0 && omode!=OREAD) error(Eperm); break; case Qnvram: if(strcmp(up->user, eve)!=0) error(Eperm); } return devopen(c, omode, rtcdir, nelem(rtcdir), devgen); } static void rtcclose(Chan*) { } #define GETBCD(o) ((bcdclock[o]&0xf) + 10*(bcdclock[o]>>4)) static long rtcextract(void) { uchar bcdclock[Nbcd]; Rtc rtc; int i; /* don't do the read until the clock is no longer busy */ for(i = 0; i < 10000; i++){ outb(Paddr, Status); if(inb(Pdata) & 0x80) continue; /* read clock values */ outb(Paddr, Seconds); bcdclock[0] = inb(Pdata); outb(Paddr, Minutes); bcdclock[1] = inb(Pdata); outb(Paddr, Hours); bcdclock[2] = inb(Pdata); outb(Paddr, Mday); bcdclock[3] = inb(Pdata); outb(Paddr, Month); bcdclock[4] = inb(Pdata); outb(Paddr, Year); bcdclock[5] = inb(Pdata); outb(Paddr, Status); if((inb(Pdata) & 0x80) == 0) break; } /* * convert from BCD */ rtc.sec = GETBCD(0); rtc.min = GETBCD(1); rtc.hour = GETBCD(2); rtc.mday = GETBCD(3); rtc.mon = GETBCD(4); rtc.year = GETBCD(5); /* * the world starts jan 1 1970 */ if(rtc.year < 70) rtc.year += 2000; else rtc.year += 1900; return rtc2sec(&rtc); } static Lock nvrtlock; long rtctime(void) { int i; long t, ot; ilock(&nvrtlock); /* loop till we get two reads in a row the same */ t = rtcextract(); for(i = 0; i < 100; i++){ ot = rtcextract(); if(ot == t) break; } iunlock(&nvrtlock); if(i == 100) print("we are boofheads\n"); return t; } static long rtcread(Chan* c, void* buf, long n, vlong off) { ulong t; char *a, *start; ulong offset = off; if(c->qid.type & QTDIR) return devdirread(c, buf, n, rtcdir, nelem(rtcdir), devgen); switch((ulong)c->qid.path){ case Qrtc: t = rtctime(); n = readnum(offset, buf, n, t, 12); return n; case Qnvram: if(n == 0) return 0; if(n > Nvsize) n = Nvsize; a = start = smalloc(n); ilock(&nvrtlock); for(t = offset; t < offset + n; t++){ if(t >= Nvsize) break; outb(Paddr, Nvoff+t); *a++ = inb(Pdata); } iunlock(&nvrtlock); if(waserror()){ free(start); nexterror(); } memmove(buf, start, t - offset); poperror(); free(start); return t - offset; } error(Ebadarg); return 0; } #define PUTBCD(n,o) bcdclock[o] = (n % 10) | (((n / 10) % 10)<<4) static long rtcwrite(Chan* c, void* buf, long n, vlong off) { int t; char *a, *start; Rtc rtc; ulong secs; uchar bcdclock[Nbcd]; char *cp, *ep; ulong offset = off; if(offset!=0) error(Ebadarg); switch((ulong)c->qid.path){ case Qrtc: /* * read the time */ cp = ep = buf; ep += n; while(cp < ep){ if(*cp>='0' && *cp<='9') break; cp++; } secs = strtoul(cp, 0, 0); /* * convert to bcd */ sec2rtc(secs, &rtc); PUTBCD(rtc.sec, 0); PUTBCD(rtc.min, 1); PUTBCD(rtc.hour, 2); PUTBCD(rtc.mday, 3); PUTBCD(rtc.mon, 4); PUTBCD(rtc.year, 5); /* * write the clock */ ilock(&nvrtlock); outb(Paddr, Seconds); outb(Pdata, bcdclock[0]); outb(Paddr, Minutes); outb(Pdata, bcdclock[1]); outb(Paddr, Hours); outb(Pdata, bcdclock[2]); outb(Paddr, Mday); outb(Pdata, bcdclock[3]); outb(Paddr, Month); outb(Pdata, bcdclock[4]); outb(Paddr, Year); outb(Pdata, bcdclock[5]); iunlock(&nvrtlock); return n; case Qnvram: if(n == 0) return 0; if(n > Nvsize) n = Nvsize; start = a = smalloc(n); if(waserror()){ free(start); nexterror(); } memmove(a, buf, n); poperror(); ilock(&nvrtlock); for(t = offset; t < offset + n; t++){ if(t >= Nvsize) break; outb(Paddr, Nvoff+t); outb(Pdata, *a++); } iunlock(&nvrtlock); free(start); return t - offset; } error(Ebadarg); return 0; } Dev rtcdevtab = { 'r', "rtc", devreset, rtcinit, devshutdown, rtcattach, rtcwalk, rtcstat, rtcopen, devcreate, rtcclose, rtcread, devbread, rtcwrite, devbwrite, devremove, devwstat, }; #define SEC2MIN 60L #define SEC2HOUR (60L*SEC2MIN) #define SEC2DAY (24L*SEC2HOUR) /* * days per month plus days/year */ static int dmsize[] = { 365, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static int ldmsize[] = { 366, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; /* * return the days/month for the given year */ static int* yrsize(int y) { if((y%4) == 0 && ((y%100) != 0 || (y%400) == 0)) return ldmsize; else return dmsize; } /* * compute seconds since Jan 1 1970 */ static ulong rtc2sec(Rtc *rtc) { ulong secs; int i; int *d2m; secs = 0; /* * seconds per year */ for(i = 1970; i < rtc->year; i++){ d2m = yrsize(i); secs += d2m[0] * SEC2DAY; } /* * seconds per month */ d2m = yrsize(rtc->year); for(i = 1; i < rtc->mon; i++) secs += d2m[i] * SEC2DAY; secs += (rtc->mday-1) * SEC2DAY; secs += rtc->hour * SEC2HOUR; secs += rtc->min * SEC2MIN; secs += rtc->sec; return secs; } /* * compute rtc from seconds since Jan 1 1970 */ static void sec2rtc(ulong secs, Rtc *rtc) { int d; long hms, day; int *d2m; /* * break initial number into days */ hms = secs % SEC2DAY; day = secs / SEC2DAY; if(hms < 0) { hms += SEC2DAY; day -= 1; } /* * generate hours:minutes:seconds */ rtc->sec = hms % 60; d = hms / 60; rtc->min = d % 60; d /= 60; rtc->hour = d; /* * year number */ if(day >= 0) for(d = 1970; day >= *yrsize(d); d++) day -= *yrsize(d); else for (d = 1970; day < 0; d day += *yrsize(d-1); rtc->year = d; /* * generate month */ d2m = yrsize(rtc->year); for(d = 1; day >= d2m[d]; d++) day -= d2m[d]; rtc->mday = day + 1; rtc->mon = d; return; } uchar nvramread(int addr) { uchar data; ilock(&nvrtlock); outb(Paddr, addr); data = inb(Pdata); iunlock(&nvrtlock); return data; } void nvramwrite(int addr, uchar data) { ilock(&nvrtlock); outb(Paddr, addr); outb(Pdata, data); iunlock(&nvrtlock); }
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Projekt_BD { public class Pacjent { [Key] public Guid IdPacjenta { get; set; } public String Imie { get; set; } public DateTime DataUrodzenie { get; set; } public String MiejsceUrodzenia { get; set; } public String Plec { get; set; } public String NrTelefonu { get; set; } public String Mail { get; set; } } }
<?php defined('_JEXEC') or die('Restricted access'); require_once ( JPATH_ROOT .'/components/com_community/models/models.php'); //CFactory::load( 'tables' , 'activity' ); class <API key> extends JCCModel { public function __construct() { parent::__construct(); } /** * Return an object with a single activity item */ public function getActivity($activityId) { $act = JTable::getInstance( 'Activity' , 'CTable' ); $act->load($activityId); return $act; } /** * Retrieves the activity content for specific activity * @deprecated since 2.2 * @return string **/ public function getActivityContent( $activityId ) { $act = $this->getActivity($activityId); return $act->content; } /** * Retrieves the activity stream for specific activity * @deprecated since 2.2 **/ public function getActivityStream( $activityId ) { return $this->getActivity($activityId); } /** * Add new data to the stream * @deprecated since 2.2 */ public function add($actor, $target, $title, $content, $appname = '', $cid=0, $params='', $points = 1, $access = 0){ jimport('joomla.utilities.date'); $table = JTable::getInstance( 'Activity' , 'CTable' ); $table->actor = $actor; $table->target = $target; $table->title = $title; $table->content = $content; $table->app = $appname; $table->cid = $cid; $table->points = $points; $table->access = $access; $table->location = ''; $table->params = $params; return $table->store(); } /** * For photo upload, we should delete all aggregated photo upload activity, * instead of just 1 photo uplaod activity */ public function hide($userId , $activityId ) { $db = $this->getDBO(); // 1st we compare if the activity stream author match the userId. If yes, // archive the record. if not, insert into hide table. $activity = $this->getActivityStream($activityId); if(! empty($activity)) { $query = 'SELECT ' . $db->quoteName('id') .' FROM ' . $db->quoteName('#<API key>'); $query .= ' WHERE ' . $db->quoteName('app') .' = ' . $db->Quote($activity->app); $query .= ' AND ' . $db->quoteName('cid') .' = ' . $db->Quote($activity->cid); $query .= ' AND ' . $db->quoteName('title') .' = ' . $db->Quote($activity->title); $query .= ' AND DATEDIFF( created, ' . $db->Quote($activity->created) . ' )=0'; $db->setQuery($query); $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } $rows = $db->loadColumn(); if(!empty($rows)) { foreach($rows as $key=>$value) { $obj = new stdClass(); $obj->user_id = $userId; $obj->activity_id = $value; $db->insertObject('#<API key>' , $obj); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } } } } return true; } public function countActivities ($userid='', $friends='', $afterDate = null, $maxEntries=0 , $respectPrivacy = true , $actidRange = null , $displayArchived = true, $actid=null, $groupid = null, $eventid = null ) { $db = $this->getDBO(); $sql = $this->_buildQuery( array ( 'userid' => $userid, 'friends' => $friends, 'afterDate' => $afterDate, 'maxEntries' => 1, // avoid returning too many data 'respectPrivacy' => $respectPrivacy, 'actidRange' => $actidRange, 'displayArchived' =>$displayArchived, 'actid' => $actid, 'groupid' => $groupid, 'eventid' => $eventid, /* Specific query format */ 'returnCount' => true )); $sql = CString::str_ireplace('a.*', ' SQL_CALC_FOUND_ROWS a.* ', $sql); $db->setQuery( $sql ); $db->Query(); //echo $db->getQuery(); exit; $db->setQuery("SELECT FOUND_ROWS()"); $result = $db->loadResult(); return $result; } /** * Return rows of activities */ public function getActivities($userid='', $friends='', $afterDate = null, $maxEntries=20 , $respectPrivacy = true , $actidRange = null , $displayArchived = true, $actid=null , $groupid = null, $eventid = null){ $db = $this->getDBO(); // Oversampling, to cater for aggregated activities //$maxEntries = ($maxEntries < 0) ? 0 : $maxEntries; //$maxEntries = $maxEntries*8; $sql = $this->_buildQuery( array ( 'userid' => $userid, 'friends' => $friends, 'afterDate' => $afterDate, 'maxEntries' => $maxEntries, 'respectPrivacy' => $respectPrivacy, 'actidRange' => $actidRange, 'displayArchived' =>$displayArchived, 'actid' => $actid, 'groupid' => $groupid, 'eventid' => $eventid, )); $db->setQuery( $sql ); //echo $maxEntries; // echo $db->getQuery(); $result = $db->loadObjectList(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } $activities = $this-><API key>($result); // This is probably not necessary unset($likesResult); unset($commentsResult); //$cache->store($activities, $cacheid,array('activities')); return $activities; } /** * Build master query * @param array $filters condition * @return string part of query */ private function _buildQuery($filters) { $db = $this->getDBO(); $my = CFactory::getUser(); $todayDate = new JDate(); $orWhere = array(); $andWhere = array( ' 1 ' ); $onActor = ''; //default the 1st condition here so that if the date is null, it wont give sql error. /* Disabled on 2.6 to take all activities including the archived one. if( !$displayArchived ) { $andWhere[] = $db->quoteName('archived')."=0"; } */ if(!empty($filters['userid'])){ $orWhere[] = '(a.' . $db->quoteName('actor') .'=' . $db->Quote($filters['userid']) .')'; //@since 2.6, show friends activities even its not related to the current user(me-and-friends fpage) if($filters['userid'] != $my->id){ $onActor .= ' AND ((a.' . $db->quoteName('actor') .'='. $db->Quote($filters['userid']) .') OR (a.' . $db->quoteName('target') .'='. $db->Quote($filters['userid']).'))'; } //@since 2.8 also search within actors column $orWhere[] = '( (a.' . $db->quoteName('actor') .'=' . $db->Quote( 0 ) .') AND (a.' . $db->quoteName('actors') .' LIKE \'%{"id":"' . $filters['userid'] .'"}%\') )'; } if(!empty($filters['friends']) && implode(',',$filters['friends']) != '') { $orWhere[] = '(a.' . $db->quoteName('actor') .' IN ('.implode(',',$filters['friends']). '))'; $orWhere[] = '(a.' . $db->quoteName('target') .' IN ('.implode(',',$filters['friends']). '))'; //actor are friends, clear the on Actor condition $onActor .= ''; } if(!empty($filters['userid'])) $orWhere[] = '(a.' . $db->quoteName('target') .'=' . $db->Quote($filters['userid']).')'; if(!empty($afterDate)) $andWhere[] = '(a.' . $db->quoteName('created') .' between '.$db->Quote($afterDate->toSql()).' and '.$db->Quote($todayDate->toSql()).')' ; // Make sure it is an integer (singed and unsigned) $filters['actidRange'] = intval($filters['actidRange']); // If idrange is positive, return items older than the given id if( !is_null( $filters['actidRange']) && $filters['actidRange'] > 0) { $exclusionQuery = ' a.id < '.$filters['actidRange'].' '; $andWhere[] = $exclusionQuery; } // // If idrange is negative, return items older than the given id if( !is_null( $filters['actidRange']) && $filters['actidRange'] < 0) { //$exclusionQuery = ' a.id = '. abs($filters['actidRange']).' '; $exclusionQuery = ' a.id > '. abs($filters['actidRange']).' '; $andWhere[] = $exclusionQuery; } if( !is_null( $filters['actid']) && $filters['actid'] > 0) { $andWhere[] = ' ( a.id = '. (int)$filters['actid'].' ) '; } // Limit to a particular group if( !is_null( $filters['groupid']) && $filters['groupid'] > 0) { $andWhere[] = ' ( a.groupid = '. (int)$filters['groupid'].' ) '; } // Limit to a particular event if( !is_null( $filters['eventid']) && $filters['eventid'] > 0) { $andWhere[] = ' ( a.eventid = '. (int)$filters['eventid'].' ) '; } // Admin can see all groups if( ! COwnerHelper::isCommunityAdmin($my->id) ){ $groupIds = empty($my->_groups) ? "''" : $my->_groups; if(!empty($groupIds)){ $andWhere[] = '( (a.' . $db->quoteName('group_access') .'=' . $db->Quote(0).')' .' OR ' .' (a.' . $db->quoteName('groupid') .' IN (' . $groupIds .' ) )' .' OR (a.' . $db->quoteName('groupid') .'=' . $db->Quote(0).'))'; } else { // Only show public groups $andWhere[] = ' (a.' . $db->quoteName('group_access') .'=' . $db->Quote(0).')'; } } // Admin can see everything if( ! COwnerHelper::isCommunityAdmin($my->id) ){ $eventIds = empty($my->_events) ? "''" : $my->_events; if(!empty($groupIds)){ $andWhere[] = '( (a.' . $db->quoteName('event_access') .'=' . $db->Quote(0).')' .' OR ' .' (a.' . $db->quoteName('eventid') .' IN (' . $eventIds .' ) ) ' .' OR (a.' . $db->quoteName('eventid') .'=' . $db->Quote(0).') )'; } else { // Only show public events $andWhere[] = ' (a.' . $db->quoteName('event_access') .'=' . $db->Quote(0).')'; } } if( $filters['respectPrivacy'] ) { // Add friends limits, but admin should be able to see all // @todo: should use global admin code check instead if($my->id == 0){ // for guest, it is enough to just test access <= 0 //$andWhere[] = "(a.`access` <= 10)"; $andWhere[] = "(a.". $db->quoteName('access')." <= 10)"; } elseif( ! COwnerHelper::isCommunityAdmin($my->id) ){ $orWherePrivacy = array(); $orWherePrivacy[] = '((a.' . $db->quoteName('access') .' = 0) ' . $onActor .')'; $orWherePrivacy[] = '((a.' . $db->quoteName('access') .' = 10) ' . $onActor .')'; $orWherePrivacy[] = '((a.' . $db->quoteName('access') .' = 20) AND ( '.$db->Quote($my->id) .' != 0) ' . $onActor .')'; if($my->id != 0) { $orWherePrivacy[] = '((a.' . $db->quoteName('access') .' = ' . $db->Quote(40).') AND (a.' . $db->quoteName('actor') .' = ' . $db->Quote($my->id).') ' . $onActor .')'; $orWherePrivacy[] = '((a.' . $db->quoteName('access') .' = ' . $db->Quote(30).') AND ((a.' . $db->quoteName('actor') .'IN (SELECT c.' . $db->quoteName('connect_to') .' FROM ' . $db->quoteName('#<API key>') .' as c' .' WHERE c.' . $db->quoteName('connect_from') .' = ' . $db->Quote($my->id) .' AND c.' . $db->quoteName('status') .' = ' . $db->Quote(1) .' ) ) OR (a.' . $db->quoteName('actor') .' = ' . $db->Quote($my->id).') )' . $onActor .' )'; } $OrPrivacy = implode(' OR ', $orWherePrivacy); // If groupid is specified, no need to check the privacy // really $andWhere[] = "(a." . $db->quoteName('groupid') . " OR (".$OrPrivacy."))"; } } if(!empty($filters['userid'])) { //get the list of acitivity id in archieve table 1st. $subQuery = 'SELECT GROUP_CONCAT(DISTINCT b.' . $db->quoteName('activity_id') .') as activity_id FROM ' . $db->quoteName('#<API key>') .' as b WHERE b.' . $db->quoteName('user_id') .' = '. $db->Quote($filters['userid']); $db->setQuery($subQuery); $subResult = $db->loadColumn(); $subString = (empty($subResult)) ? array() : explode(',', $subResult[0]); $idlist = array(); //cleanup empty values while(!empty($subString)){ $str = array_shift($subString); if(!empty($str)) $idlist[] = $str; unset($str); } $subString = implode(',', $idlist); if( ! empty($subString)) $andWhere[] = 'a.' . $db->quoteName('id') .' NOT IN ('.$subString.')'; } // If current user is blocked by a user he should not see the activity of the user // who block him. (of course, if the user data is public, he can see it anyway!) /* if($my->id != 0){ $andWhere[] = "a.`actor` NOT IN (SELECT `userid` FROM #<API key> WHERE `blocked_userid`='{$my->id}')"; } */ $whereOr = implode(' OR ', $orWhere); $whereAnd = implode(' AND ', $andWhere); // Actors can also be your friends // We load 100 activities to cater for aggregated content $date = CTimeHelper::getDate(); //we need to compare where both date with offset so that the day diff correctly. // Have limit? $maxEntries = ''; if(!empty($filters['maxEntries'])) { $maxEntries = ' LIMIT ' . $filters['maxEntries']; } // Azrul Code start // 1. Get all the ids of the activities $sql = 'SELECT a.* ' /* .' TO_DAYS('.$db->Quote($date->toSql(true)).') - TO_DAYS( DATE_ADD(a.' . $db->quoteName('created').', INTERVAL '.$date->getOffset(true).' HOUR ) ) as _daydiff' */ .' FROM ' . $db->quoteName('#<API key>') .' as a ' .' WHERE ' .' ( '. $whereOr .' ) AND ' . $whereAnd .' GROUP BY a.' . $db->quoteName('id') .' ORDER BY a.' . $db->quoteName('created') .' DESC, a. ' . $db->quoteName('id') .' DESC' . $maxEntries; // Remove the bracket if it is not needed $sql = CString::str_ireplace('WHERE ( ) AND', ' WHERE ', $sql); return $sql; } /** * Given rows of activities, return activities with the likes and comment data * @param array $result * */ public function <API key>($result) { $db = $this->getDBO(); // 2. Get the ids of the comments and likes we will query $comments = array(); $likes = array(); if(!empty($result)) { foreach($result as $row) { if(!empty($row->comment_type)) { if($row->comment_type == 'photos') { $comments['albums'][] = $row->cid; } else { $comments[$row->comment_type][] = $row->comment_id; } } if(!empty($row->like_type)) $likes[$row->like_type][] = $row->like_id; } } // 3. Query the comments $commentsResult = array(); if(!empty($result)) { $cond = array(); foreach( $comments as $lk => $lv ) { // Make every uid unique $lv = array_unique($lv); if( !empty($lv)) { $cond[] = ' ( ' .' a.' . $db->quoteName('type') . '=' . $db->Quote($lk) .' AND ' .' a.' . $db->quoteName('contentid') . ' IN (' . implode( ',' , $lv ) . ') ' .' ) '; } } if(!empty($cond)){ $sql = 'SELECT a.* ' .' FROM ' . $db->quoteName('#__community_wall') .' as a ' .' WHERE ' . implode( ' OR ' , $cond ) .' ORDER BY '.$db->quoteName('id') . ' DESC '; $db->setQuery( $sql ); $resultComments = $db->loadObjectList(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } foreach($resultComments as $comment) { $key = $comment->type . '-' . $comment->contentid; if(!isset($commentsResult[$key])) { $commentsResult[$key] = $comment; $commentsResult[$key]->_comment_count = 0; } $commentsResult[$key]->_comment_count++; } } } // 4. Query the likes $likesResult = array(); if(!empty($result)) { $cond = array(); foreach( $likes as $lk => $lv ) { // Make every uid unique $lv = array_unique($lv); if( !empty($lv)) { $cond[] = ' ( ' .' a.' . $db->quoteName('element') . '=' . $db->Quote($lk) .' AND ' .' a.' . $db->quoteName('uid') . ' IN (' . implode( ',' , $lv ) . ') ' .' ) '; } } if(!empty($cond)){ $sql = 'SELECT a.* ' .' FROM ' . $db->quoteName('#__community_likes') .' as a ' .' WHERE ' . implode( ' OR ' , $cond ) ; $db->setQuery( $sql ); $resultLikes = $db->loadObjectList(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } foreach($resultLikes as $like) { $likesResult[$like->element . '-' . $like->uid] = $like->like; } } } // 4. Merge data $activities = array(); if(!empty($result)) { foreach($result as $row) { // Merge Like data if(array_key_exists($row->like_type . '-' . $row->like_id, $likesResult) ) { $row->_likes = $likesResult[$row->like_type . '-' . $row->like_id]; } else { $row->_likes = ''; } if($row->comment_type == 'photos') { $row->comment_id = $row->cid; $row->comment_type = 'albums'; } // Merge comment data if( array_key_exists($row->comment_type . '-' . $row->comment_id, $commentsResult) ) { $data = $commentsResult[$row->comment_type . '-' . $row->comment_id]; $row->_comment_last_id = $data->id; $row->_comment_last_by = $data->post_by; $row->_comment_date = $data->date; $row->_comment_count = $data->_comment_count; $row->_comment_last = isset($data->comment) ? $data->comment : null; } else { $row->_comment_last_id = ''; $row->_comment_last_by = ''; $row->_comment_date = ''; $row->_comment_count = 0; $row->_comment_last = ''; } // Create table object $act = JTable::getInstance( 'Activity' , 'CTable' ); $act->bind($row); $activities[] = $act; } } return $activities; } /** * Return all activities by the given apps * * @param mixed $appname string or array of string */ public function getAppActivities( $options ) { $my = CFactory::getUser(); // Default options $default = array( 'app' => '', 'cid' => '', 'groupid' => '', 'eventid' => '', 'limit' => 100 , 'respectPrivacy' => true , 'exclusions' => null , 'displayArchived' => false, 'createdAfter' => null ); $options = array_merge($default, $options); extract($options); $db = $this->getDBO(); // If $appname is not an array, flatten it if(is_string($app)){ $app = array($app); } $app = "'" . implode("','", $app) . "'"; // Double the number of limit to allow for aggregator $limit = ($limit < 0) ? 0 : $limit; $limit = $limit*2; $displayArchived = $displayArchived ? 1 : 0; //$appsWhere = $db->quoteName('archived') .'=' . $db->Quote( $displayArchived ) . ' AND ' . $db->quoteName('app').' IN (' . $app . ')'; // Quote not needed here $appsWhere = $db->quoteName('app').' IN (' . $app . ')'; // Quote not needed here if($cid != null) $appsWhere .= ' AND ' . $db->quoteName('cid') .'=' . $db->Quote($cid); if($groupid != null){ $appsWhere .= ' AND (' . $db->quoteName('groupid') .' = ' . $db->Quote($groupid) .' )'; } if($eventid != null) $appsWhere .= ' AND ' . $db->quoteName('eventid') .'=' . $db->Quote($eventid); if( !is_null( $exclusions) && $exclusions > 0) { $appsWhere .= ' AND a.id < '.$exclusions.' '; } if($createdAfter != null) { $date = new JDate($createdAfter); $createdAfter = $date->format('%Y-%m-%d'); $appsWhere .= ' AND date_format(a.' . $db->quoteName('created') .',' . $db->Quote('%Y-%m-%d') .') >= '. $db->Quote($createdAfter).' '; } // Actors can also be your friends $date = CTimeHelper::getDate(); //we need to compare where both date with offset so that the day diff correctly. $sql = 'SELECT a.* , (DAY( ' . $db->Quote($date->toSql(true)).' ) - DAY( DATE_ADD(a.' . $db->quoteName('created') .',INTERVAL '.$date->getOffset().' HOUR ) )) as ' . $db->Quote('_daydiff') .' FROM ' . $db->quoteName('#<API key>') .' as a ' .' WHERE ' . $appsWhere .' ORDER BY ' . $db->quoteName('created') .' DESC ' .' LIMIT ' . $limit ; $db->setQuery( $sql ); $result = $db->loadObjectList(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } $activities = $this-><API key>($result); return $activities; } /** * Remove any recently changed activities */ public function removeRecent($actor, $title, $app, $timeDiff){ } /* * Remove One Photo Activity * As it's tricky to remove the activity since there's no photo id in the * activity data. Here we get all the activities of 5 seconds within the * activity creation time, then we try to match the photo id in the activity * params, and also the thumbnail in the activity content field. When all * fails, we fallback to removeOneActivity() */ public function <API key>( $app, $uniqueId, $datetime, $photoId, $thumbnail ) { $db = JFactory::getDBO(); $query = 'SELECT * FROM ' . $db->quoteName( '#<API key>' ) . ' ' . 'WHERE ' . $db->quoteName( 'app' ) . '=' . $db->Quote( $app ) . ' ' . 'AND ' . $db->quoteName( 'cid' ) . '=' . $db->Quote( $uniqueId ) . ' ' . 'AND ( ' . $db->quoteName( 'created' ) . ' BETWEEN ' . $db->Quote( $datetime ) . ' ' . 'AND ( ADDTIME(' . $db->Quote($datetime) . ', ' . $db->Quote('00:00:05') . ' ) ) ) ' ; $db->setQuery($query); $result = $db->loadObjectList(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } $activityId = null; $handler = new CParameter(null); // the activity data contains photoid and the photo thumbnail // which can be useful for us to find the correct activity id foreach ($result as $activity) { $handler->loadINI($activity->params); if ($handler->getValue('photoid')==$photoId) { $activityId = $activity->id; break; } if ( JString::strpos($activity->content, $thumbnail)!== false ) { $activityId = $activity->id; break; } } if (is_null($activityId)) { return $this->removeOneActivity($app, $uniqueId); } $query = 'DELETE FROM ' . $db->quoteName( '#<API key>' ) . ' ' . 'WHERE ' . $db->quoteName( 'id' ) . '=' . $db->Quote( $activityId ) . ' ' . 'LIMIT 1 ' ; $db->setQuery( $query ); $status = $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } return $status; } public function removeOneActivity( $app , $uniqueId ) { $db = $this->getDBO(); $query = 'DELETE FROM ' . $db->quoteName( '#<API key>' ) . ' ' . 'WHERE ' . $db->quoteName( 'app' ) . '=' . $db->Quote( $app ) . ' ' . 'AND ' . $db->quoteName( 'cid' ) . '=' . $db->Quote( $uniqueId ) . ' ' . 'LIMIT 1 ' ; $db->setQuery( $query ); $status = $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } return $status; } //Remove Discussion via params function removeDiscussion($app,$uniqueId,$paramName,$paramValue){ $db = $this->getDBO(); $query = 'DELETE FROM ' . $db->quoteName( '#<API key>' ) . ' ' . 'WHERE ' . $db->quoteName( 'app' ) . '=' . $db->Quote( $app ) . ' ' . 'AND ' . $db->quoteName( 'cid' ) . '=' . $db->Quote( $uniqueId ) . ' ' . 'AND ' . $db->quoteName( 'params' ) . ' LIKE '.$db->Quote('%'.$paramName .'='.$paramValue.'%') ; $db->setQuery( $query ); $status = $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } return $status; } public function removeActivity( $app , $uniqueId ) { $db = $this->getDBO(); $query = 'DELETE FROM ' . $db->quoteName( '#<API key>' ) . ' ' . 'WHERE ' . $db->quoteName( 'app' ) . '=' . $db->Quote( $app ) . ' ' . 'AND ' . $db->quoteName( 'cid' ) . '=' . $db->Quote( $uniqueId ) ; $db->setQuery( $query ); $status = $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } return $status; } public function removeGroupActivity($ids) { $db = $this->getDBO(); $app = '"groups","groups.bulletin","groups.discussion","groups.wall"'; $query = 'DELETE FROM ' . $db->quoteName( '#<API key>' ) . ' ' . 'WHERE ' . $db->quoteName( 'app' ) . 'IN ('.$app.') ' . 'AND ' . $db->quoteName( 'cid' ) . 'IN ('.$ids.')'; $db->setQuery( $query ); $status = $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } return $status; } /** * Return the actor id by a given activity id */ public function getActivityOwner($uniqueId){ $db = $this->getDBO(); $sql = 'SELECT ' . $db->quoteName('actor') .' FROM ' . $db->quoteName('#<API key>') .' WHERE ' . $db->quoteName('id') .'=' . $db->Quote($uniqueId); $db->setQuery( $sql ); $result = $db->loadResult(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } // @todo: write a plugin that return the html part of the whole system return $result; } /** * Return the number of total activity by a given user */ public function getActivityCount($userid) { $db = $this->getDBO(); $sql = 'SELECT SUM(' . $db->quoteName('points') .') FROM ' . $db->quoteName('#<API key>') .' WHERE ' . $db->quoteName('actor') .'=' . $db->Quote($userid); $db->setQuery( $sql ); $result = $db->loadResult(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } // @todo: write a plugin that return the html part of the whole system return $result; } /** * Retrieves total number of activities throughout the site. * * @return int $total Total number of activities. **/ public function getTotalActivities( $andWhere = array() ){ $db = JFactory::getDBO(); $andWhere[] = ' 1 '; $whereAnd = implode(' AND ', $andWhere); $query = 'SELECT COUNT(1) FROM ' . $db->quoteName('#<API key>') . ' WHERE ' . $whereAnd; $db->setQuery( $query ); $total = $db->loadResult(); return $total; } /** * Update acitivy stream access * * @param <type> $access * @param <type> $previousAccess * @param <type> $actorId * @param <type> $app * @param <type> $cid * @return <type> * */ public function updatePermission($access, $previousAccess , $actorId, $app = '' , $cid = '') { $db = $this->getDBO(); $query = 'UPDATE ' . $db->quoteName('#<API key>') .' SET ' . $db->quoteName('access') .' = ' . $db->Quote($access); $query .= ' WHERE ' . $db->quoteName('actor') .' = ' . $db->Quote($actorId); if( $previousAccess != null && $previousAccess > $access ) { $query .= ' AND ' . $db->quoteName('access') .' <' . $db->Quote( $access ); } if( !empty( $app ) ) { $query .= ' AND ' . $db->quoteName('app') .' = ' . $db->Quote($app); } if(! empty($cid)) { $query .= ' AND ' . $db->quoteName('cid') .' = ' . $db->Quote($cid); } $db->setQuery( $query ); $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } return $this; } public function <API key>($access, $previousAccess = null, $cid, $app) { // if (is_array($cid)) {} $db = $this->getDBO(); $query = 'UPDATE ' . $db->quoteName('#<API key>') .' SET ' . $db->quoteName('access') .' = ' . $db->Quote($access); $query .= ' WHERE ' . $db->quoteName('cid') .' IN (' . $db->Quote($cid) . ')'; $query .= ' AND ' . $db->quoteName('app') .' = ' . $db->Quote($app); if( $previousAccess != null && $previousAccess > $access ) { $query .= ' AND ' . $db->quoteName('access') .' <' . $db->Quote( $access ); } $db->setQuery( $query ); $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } return $this; } /** * Generic activity update code * * @param array $condition * @param array $update * @return <API key> */ public function update($condition, $update) { $db = $this->getDBO(); $where = array(); foreach($condition as $key => $val) { $where[] = $db->quoteName($key) .'=' . $db->Quote($val); } $where = implode(' AND ', $where); $set = array(); foreach($update as $key => $val) { $set[] = ' '. $db->quoteName($key) .'=' . $db->Quote($val); } $set = implode(', ', $set); $query = 'UPDATE ' . $db->quoteName('#<API key>') .' SET '. $set . ' WHERE '. $where; $db->setQuery( $query ); $db->query(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } return $this; } }
<?php // if($_GET['reportpost'] == $post->ID) { app_report_post($post->ID); $reported = true;} ?> <script type='text/javascript'> // <![CDATA[ /* setup the form validation */ jQuery(document).ready(function ($) { $('#mainform').validate({ errorClass: 'invalid' }); }); </script> <div class="content"> <div class="content_botbg"> <div class="content_res"> <div id="breadcrumb"> <?php if ( function_exists('cp_breadcrumb') ) cp_breadcrumb(); ?> </div> <!-- <div style="width: 105px; height:16px; text-align: right; float: left; font-size:11px; margin-top:-10px; padding:0 10px 5px 5px;"> --> <?php // if($reported) : ?> <!-- <span id="reportedPost"><?php _e( 'Post Was Reported', APP_TD ); ?></span> --> <?php // else : ?> <!-- <a id="reportPost" href="?reportpost=<?php echo $post->ID; ?>"><?php _e( 'Report This Post', APP_TD ); ?></a> --> <?php // endif; ?> <!-- </div> --> <div class="clr"></div> <div class="content_left"> <?php <API key>(); ?> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php <API key>(); ?> <?php <API key>( $post->ID ); //records the page hit ?> <div class="shadowblock_out <?php if ( is_sticky() ) echo 'featured'; ?>"> <div class="shadowblock"> <?php <API key>(); ?> <h1 class="single-listing"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1> <div class="clr"></div> <?php <API key>(); ?> <div class="pad5 dotted"></div> <div class="bigright" <?php if(get_option($GLOBALS['app_abbr'].'_ad_images') == 'no') echo 'style="float:none;"'; ?>> <ul> <?php // grab the category id for the functions below $cat_id = <API key>( $post->ID, APP_TAX_CAT, 'term_id' ); // check to see if ad is legacy or not if ( get_post_meta( $post->ID, 'expires', true ) ) { ?> <li><span><?php _e( 'Location:', APP_TD ); ?></span> <?php echo get_post_meta( $post->ID, 'location', true ); ?></li> <li><span><?php _e( 'Phone:', APP_TD ); ?></span> <?php echo get_post_meta( $post->ID, 'phone', true ); ?></li> <?php if ( get_post_meta( $post->ID, 'cp_adURL', true ) ) ?> <li><span><?php _e( 'URL:', APP_TD ); ?></span> <?php echo <API key>( get_post_meta( $post->ID, 'cp_adURL', true ) ); ?></li> <li><span><?php _e( 'Listed:', APP_TD ); ?></span> <?php the_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ) ?></li> <! <li><span><?php _e( 'Expires:', APP_TD ); ?></span> <?php echo cp_timeleft( strtotime( get_post_meta( $post->ID, 'expires', true ) ) ); ?></li> <?php } else { if ( get_post_meta($post->ID, 'cp_ad_sold', true) == 'yes' ) : ?> <li id="cp_sold"><span><?php _e( 'This item has been sold', APP_TD ); ?></span></li> <?php endif; ?> <?php // 3.0+ display the custom fields instead (but not text areas) cp_get_ad_details( $post->ID, $cat_id ); ?> <li id="cp_listed"><span><?php _e( 'Listed:', APP_TD ); ?></span> <?php the_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ) ?></li> <?php if ( get_post_meta($post->ID, 'cp_sys_expire_date', true) ) ?> <li id="cp_expires"><span><?php _e( 'Expires:', APP_TD ); ?></span> <?php echo cp_timeleft( strtotime( get_post_meta( $post->ID, 'cp_sys_expire_date', true) ) ); ?></li> <?php } // end legacy check ?> </ul> </div><!-- /bigright --> <?php if ( get_option( 'cp_ad_images' ) == 'yes' ) : ?> <div class="bigleft"> <div id="main-pic"> <?php cp_get_image_url(); ?> <div class="clr"></div> </div> <div id="thumbs-pic"> <?php <API key>( $post->ID, 'thumbnail', $post->post_title, -1 ); ?> <div class="clr"></div> </div> </div><!-- /bigleft --> <?php endif; ?> <div class="clr"></div> <?php <API key>(); ?> <div class="single-main"> <?php // 3.0+ display text areas in content area before content. cp_get_ad_details( $post->ID, $cat_id, 'content' ); ?> <h3 class="description-area"><?php _e( 'Description', APP_TD ); ?></h3> <?php the_content(); ?> </div> <?php <API key>(); ?> </div><!-- /shadowblock --> </div><!-- /shadowblock_out --> <?php <API key>(); ?> <?php endwhile; ?> <?php <API key>(); ?> <?php else: ?> <?php appthemes_loop_else(); ?> <?php endif; ?> <div class="clr"></div> <?php <API key>(); ?> <?php wp_reset_query(); ?> <div class="clr"></div> <?php comments_template( '/comments-ad_listing.php' ); ?> </div><!-- /content_left --> <?php get_sidebar( 'ad' ); ?> <div class="clr"></div> </div><!-- /content_res --> </div><!-- /content_botbg --> </div><!-- /content -->
// QtLobby released under the GPLv3, see COPYING for details. #include "Downloader.h" #include "IDownloader.h" #include <QUrl> #include <QDebug> #include <QApplication> #include <QTimer> #include <QMutex> #include "Settings.h" #include <iostream> #define MAX_TRIES 10 enum dltype { DLTYPE_RAPID = 0, DLTYPE_HTTP = 1, DLTYPE_PLASMA = 2, }; QMutex prdownloader_mutex; dltype searchFunc(IDownload::category icat, QString name, std::list<IDownload*>& searchres ) { std::string searchname = name.toStdString(); prdownloader_mutex.lock(); rapidDownload->search(searchres, searchname.c_str(), icat); dltype t = DLTYPE_RAPID; if (searchres.empty()) { t = DLTYPE_HTTP; httpDownload->search(searchres, searchname.c_str(), icat); if (searchres.empty()) { t = DLTYPE_PLASMA; plasmaDownload->search(searchres, searchname.c_str(), icat); } } std::cout << "t=" << t << std::endl; prdownloader_mutex.unlock(); } bool Downloader::addDepends(std::list< IDownload* >& dls) { std::list<IDownload*>::iterator it; for (it = dls.begin(); it != dls.end(); ++it) { if ((*it)->depend.empty()) { continue; } std::list<std::string>::iterator stit; for (stit = (*it)->depend.begin(); stit != (*it)->depend.end(); ++stit) { std::list<IDownload*> depends; const std::string& depend = (*stit); searchFunc(IDownload::CAT_GAMES,QString::fromStdString(depend),depends); dls.merge(depends); depends.clear(); searchFunc(IDownload::CAT_MAPS,QString::fromStdString(depend),depends); dls.merge(depends); } } return true; } /** Ctor. Gets resource name and resource type */ int Downloader::init = 0; Downloader::Downloader(QString name, bool map, QObject* parent) : QObject(parent) { m_resourceName = name; m_map = map; m_manager = 0; m_received = 0; m_downloading = false; m_getFromJobjol = false; if ( !init ) { qRegisterMetaType< QList<IDownload*> >("QList<IDownload*>"); init = 1; } //qDebug() << "ctor, name=" + name; } Downloader::~Downloader() { if(m_manager) delete m_manager; } /** main function. */ void Downloader::start() { m_downloading = false; //qDebug() << "run, name=" + m_resourceName; /* m_manager = new <API key>(this); m_resolve.setUrl(resolverUrl.arg(m_map ? "map" : "mod").arg(m_resourceName)); m_reply = m_manager->get(m_resolve); connect(m_reply, SIGNAL(finished()), this, SLOT(onResolverFinished())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));*/ emit stateChanged(m_resourceName, tr("Resolving filename")); SearchThread * th = new SearchThread(this,m_map ? IDownload::CAT_MAPS : IDownload::CAT_GAMES ,m_resourceName); /*int count = 0;//DownloadSearch(DL_ANY,CAT_MAP,m_resourceName); if ( count == 0 ) { emit stateChanged(m_resourceName, tr("Error: ") + tr("Cannot find requested map")); emit finished(m_resourceName, false); return; }*/ connect(th,SIGNAL(searchCompleted(QList<IDownload*>,int)),this,SLOT(onResolverFinished(QList<IDownload*>,int))); connect(th,SIGNAL(finished()),th,SLOT(deleteLater())); th->start(); /* for (int i=0; i<count; i++) { DownloadAdd(i); }*/ } void SearchThread::run() { std::list<IDownload*> res; dltype t = searchFunc(m_cat,m_name,res); emit searchCompleted(QList<IDownload*>::fromStdList(res),(int)t); } SearchThread::SearchThread(QObject* parent, IDownload::category category, QString name): QThread(parent) , m_name(name) , m_cat(category) { } /** Slot for getting resource filename from resource name via Mirko's gateway */ void Downloader::onResolverFinished(QList< IDownload* > searchres,int t) { if ( searchres.empty() ) { emit stateChanged(m_resourceName, tr("Error: ") + tr("Cannot find requested map")); emit finished(m_resourceName, false); return; } std::cout << "Ok download " << m_resourceName.toStdString() << " " << searchres.size() << std::endl; DownloadThread * dth = new DownloadThread(searchres,t,this); connect(dth,SIGNAL(downloadFinished(bool)),this,SLOT(onDownloadFinished(bool))); connect(dth,SIGNAL(progressReport(qint64,qint64)),this,SLOT(onDownloadProgress(qint64,qint64))); connect(dth,SIGNAL(finished()),dth,SLOT(deleteLater())); dth->start(); /* QString result = m_reply->readAll().trimmed(); if(result.isEmpty()) { emit stateChanged(m_resourceName, tr("File not found")); emit finished(m_resourceName, false); return; } m_jobjolId = result.split(",").takeFirst().toInt(); m_fileName =result.split(",").takeLast(); //qDebug() << "onResolverFinished, filename=" + m_fileName; QString url; if(m_map) { url = mirrorListUrl.arg(m_fileName, "maps"); m_jobjolUrl = jobjol.arg(2).arg(m_fileName); } else { url = mirrorListUrl.arg(m_fileName, "mods"); m_jobjolUrl = jobjol.arg(5).arg(m_fileName); } m_mirrorList.setUrl(url); m_mirrorList.setRawHeader("Referer", mirrorListReferer.arg(m_jobjolId).toAscii()); m_reply = m_manager->get(m_mirrorList); connect(m_reply, SIGNAL(finished()), this, SLOT(<API key>())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError))); emit stateChanged(m_resourceName, tr("Retrieving mirror list"));*/ } DownloadThread::DownloadThread(QList< IDownload* > searchres, int t, QObject* parent): QThread(parent) , m_searchres(searchres), m_t(t) { m_progress_timer = new QTimer(this); m_progress_timer->setSingleShot(false); m_progress_timer->setInterval(500); connect(m_progress_timer,SIGNAL(timeout()),this,SLOT(reportProgress())); m_progress_timer->start(); } void DownloadThread::reportProgress() { qint64 totalsize = 0.0; qint64 downloaded_size = 0.0; for ( QList<IDownload*>::iterator it = m_searchres.begin(); it != m_searchres.end(); it++ ) { totalsize += (*it)->size; downloaded_size += (*it)->getProgress();//hopefully piece.size will not change during download } if ( totalsize != 0 && downloaded_size >= 0 && totalsize >= 0 && downloaded_size <= totalsize) emit progressReport(downloaded_size,totalsize); } void DownloadThread::run() { std::list<IDownload*> dl = m_searchres.toStdList(); bool result = true; Downloader::addDepends(dl); prdownloader_mutex.lock(); for ( std::list<IDownload*>::iterator it = dl.begin(); it != dl.end(); it++ ) { if ( (*it)->dltype == IDownload::TYP_RAPID ) result = rapidDownload->download(*it); if ( (*it)->dltype == IDownload::TYP_HTTP ) result = httpDownload->download(*it); if ( m_t == DLTYPE_PLASMA ) result = plasmaDownload->download(*it); } prdownloader_mutex.unlock(); std::cout << "DLTHREAD: Finished " << result << std::endl; emit downloadFinished(result); IDownloader::freeResult(dl); } /** Slot for getting mirror list from jobjol.nl */ void Downloader::<API key>() { } /** Slot for getting size of a file. It aborts connection as soon as we got it */ void Downloader::onFileSizeFinished() { } /** Slot for getting requested resource */ void Downloader::onFetchFinished() { } /** This method opens target file */ void Downloader::openFile() { } /** This method starts multisegmented download */ void Downloader::download() { } /** Slot for processing completed segment */ void Downloader::onDownloadFinished(bool success) { if ( success ) { emit stateChanged(m_resourceName, tr("Finished")); emit finished(m_resourceName, true); }else{ emit stateChanged(m_resourceName, tr("Failed")); emit finished(m_resourceName, true); } } /** Slot for getting jobjol cookies for download */ void Downloader::<API key>() { } /** Slot for processing completed request to jobjol.nl */ void Downloader::onJobjolFinished() { } /** Informing the world about how we are doing */ void Downloader::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) { emit downloadProgress(m_resourceName, bytesReceived, bytesTotal); } /** Gives the startpoint and number of bytes to download for downloading for each host. @param hostSpeed is a list of speeds in Bytes/s @param fileSize is the size of the file to download @return is a list of start position and number of Bytes to download from each host (might be 0 for skipping that host). */ /*QVector<QVector<int> > Downloader::getChunkRanges( QVector<int> hostSpeed, int fileSize ) { int maxSpeed = 0, sumSpeed = 0; QVector<float> fractions; foreach( int speed, hostSpeed ) { fractions.append((float) speed); maxSpeed = qMax( maxSpeed, speed ); sumSpeed += speed; } float sumFraction =0; for( int i = 0; i < fractions.size(); i++ ) { fractions[i] = fractions[i]/sumSpeed; // get if( hostSpeed.at(i) == maxSpeed ) fractions[i] *= 1.2; // give the fastest a little bit more than it's proportional part if( hostSpeed.at(i) < maxSpeed*0.2 ) fractions[i] = 0; // don't download from too slow servers sumFraction += fractions[i]; } QVector<QVector<int> > ret; int currentPos = 0; foreach( float fraction, fractions ) { QVector<int> entry; int startPos = currentPos; int bytes = (int) qRound(fraction/sumFraction*fileSize); currentPos += bytes; entry.append(startPos); entry.append(bytes); ret.append(entry); } ret.last()[1] += fileSize - currentPos; // due to round some bytes might be left, assign to last one return ret; }*/ /** Timer event for speed and ETA estimation */ void Downloader::timerEvent(QTimerEvent* ) { /* static quint64 lastReceived = 0; quint64 delta = m_received - lastReceived; int speed = qRound(delta/((float)timerInterval/1000)); int eta = 0; if(m_fileSize) eta = qRound((m_fileSize - m_received)/speed); emit speedEtaChanged(m_resourceName, speed,eta); lastReceived = m_received;*/ } void Downloader::onError(QNetworkReply::NetworkError /*code*/) { /* QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); QString url = reply->url().toString(); if(m_retriesPerUrl.contains(url)) m_retriesPerUrl[url] = 0; else m_retriesPerUrl[url]++; qCritical() << tr("Failed to fetch %1. Error: %2").arg(url).arg(reply->errorString()); if(m_retriesPerUrl[url] < MAX_TRIES) { m_manager->get(reply->request()); qCritical() << "Retry #" + QString::number(m_retriesPerUrl[url]); } else { qCritical() << "Max retries reached. Fetch failed completely."; emit stateChanged(m_resourceName, tr("Error: ") + reply->errorString()); emit finished(m_resourceName, false); }*/ }
# THOR base dir import logging import glob import os import sys # dump a few things into the THOR namespace from .xray import * # list all the files included in THOR
<!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>SteelBreeze Reference Manual: Member List</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">SteelBreeze Reference Manual &#160;<span id="projectnumber">2.0.2</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="pages.html"><span>Related&#160;Pages</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class&#160;List</span></a></li> <li><a href="classes.html"><span>Class&#160;Index</span></a></li> <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li> <li><a href="functions.html"><span>Class&#160;Members</span></a></li> </ul> </div> </div> <div class="header"> <div class="headertitle"> <div class="title">SBDBHLRecZ3 Member List</div> </div> </div> <div class="contents"> This is the complete list of members for <a class="el" href="classSBDBHLRecZ3.html">SBDBHLRecZ3</a>, including all inherited members.<table> <tr class="memlist"><td><a class="el" href="classSBDBHLRecZ3.html#<API key>">dump</a>(QTextStream &amp;s)</td><td><a class="el" href="classSBDBHLRecZ3.html">SBDBHLRecZ3</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="<API key>.html#<API key>">isAlter</a>()</td><td><a class="el" href="<API key>.html">SBDBHLRecPrefixed</a></td><td><code> [inline, virtual]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">isOk</a>()</td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">isOK</a></td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [protected]</code></td></tr> <tr class="memlist"><td><a class="el" href="<API key>.html#<API key>">isP</a>()</td><td><a class="el" href="<API key>.html">SBDBHLRecPrefixed</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="<API key>.html#<API key>">isPrefixParsed</a>(SBDS_dbh &amp;)</td><td><a class="el" href="<API key>.html">SBDBHLRecPrefixed</a></td><td><code> [virtual]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">length</a>()</td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">Length</a></td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [protected]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">LogRec</a></td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [protected]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">operator&gt;&gt;</a>(SBDS_dbh &amp;, SBDBHPhysRec &amp;)</td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [friend]</code></td></tr> <tr class="memlist"><td><a class="el" href="<API key>.html#<API key>">P</a></td><td><a class="el" href="<API key>.html">SBDBHLRecPrefixed</a></td><td><code> [protected]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHLRecZ3.html#<API key>">P1</a></td><td><a class="el" href="classSBDBHLRecZ3.html">SBDBHLRecZ3</a></td><td><code> [protected]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHLRecZ3.html#<API key>">p1</a>()</td><td><a class="el" href="classSBDBHLRecZ3.html">SBDBHLRecZ3</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHLRecZ3.html#<API key>">parseLR</a>(SBDS_dbh &amp;s)</td><td><a class="el" href="classSBDBHLRecZ3.html">SBDBHLRecZ3</a></td><td><code> [inline, virtual]</code></td></tr> <tr class="memlist"><td><a class="el" href="<API key>.html#<API key>">Prefix</a></td><td><a class="el" href="<API key>.html">SBDBHLRecPrefixed</a></td><td><code> [protected]</code></td></tr> <tr class="memlist"><td><a class="el" href="<API key>.html#<API key>">SBDBHLRecPrefixed</a>(char P_[2])</td><td><a class="el" href="<API key>.html">SBDBHLRecPrefixed</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHLRecZ3.html#<API key>">SBDBHLRecZ3</a>()</td><td><a class="el" href="classSBDBHLRecZ3.html">SBDBHLRecZ3</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">SBDBHPhysRec</a>()</td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">type</a>()</td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [inline, virtual]</code></td></tr> <tr class="memlist"><td><a class="el" href="classSBDBHPhysRec.html#<API key>">~SBDBHPhysRec</a>()</td><td><a class="el" href="classSBDBHPhysRec.html">SBDBHPhysRec</a></td><td><code> [inline, virtual]</code></td></tr> </table></div> <hr class="footer"/><address class="footer"><small> Generated on Mon May 14 2012 13:21:52 for SteelBreeze Reference Manual by & <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.7.5.1 </small></address> </body> </html>
#include <openbeacon.h> #ifdef ENABLE_PN532_RFID #include "pn532.h" #include "rfid.h" void rfid_reset (unsigned char reset) { GPIOSetValue (PN532_RESET_PORT, PN532_RESET_PIN, reset ? 1 : 0); } static void rfid_cs (unsigned char cs) { GPIOSetValue (PN532_CS_PORT, PN532_CS_PIN, cs ? 1 : 0); } static void rfid_tx (unsigned char data) { spi_txrx ((SPI_CS_PN532 ^ SPI_CS_MODE_SKIP_TX) | <API key> | <API key>, &data, sizeof (data), NULL, 0); } static unsigned char rfid_rx (void) { unsigned char data; spi_txrx ((SPI_CS_PN532 ^ SPI_CS_MODE_SKIP_TX) | <API key> | <API key>, NULL, 0, &data, sizeof (data)); return data; } int rfid_read (void *data, unsigned char size) { int res; unsigned char *p, c, pkt_size, crc, prev, t; /* wait 100ms max till PN532 response is ready */ t = 0; while (GPIOGetValue (PN532_IRQ_PORT, PN532_IRQ_PIN)) { if (t++ > 10) return -8; pmu_wait_ms (10); } debug ("RI: "); /* enable chip select */ rfid_cs (0); /* read from FIFO command */ rfid_tx (0x03); /* default result */ res = -9; /* find preamble */ t = 0; prev = rfid_rx (); while ((!(((c = rfid_rx ()) == 0xFF) && (prev == 0x00))) && (t < PN532_FIFO_SIZE)) { prev = c; t++; } if (t >= PN532_FIFO_SIZE) res = -3; else { /* read packet size */ pkt_size = rfid_rx (); /* special treatment for NACK and ACK */ if ((pkt_size == 0x00) || (pkt_size == 0xFF)) { /* verify if second length byte is inverted */ if (rfid_rx () != (unsigned char) (~pkt_size)) res = -2; else { /* eat Postamble */ rfid_rx (); /* -1 for NACK, 0 for ACK */ res = pkt_size ? -1 : 0; } } else { /* verify packet size against LCS */ if (((pkt_size + rfid_rx ()) & 0xFF) != 0) res = -4; else { /* remove TFI from packet size */ pkt_size /* verify if packet fits into buffer */ if (pkt_size > size) res = -5; else { /* remember actual packet size */ size = pkt_size; /* verify TFI */ if ((crc = rfid_rx ()) != 0xD5) res = -6; else { /* read packet */ p = (unsigned char *) data; while (pkt_size { /* read data */ c = rfid_rx (); debug (" %02X", c); /* maintain crc */ crc += c; /* save payload */ if (p) *p++ = c; } /* add DCS to CRC */ crc += rfid_rx (); /* verify CRC */ if (crc) res = -7; else { /* eat Postamble */ rfid_rx (); /* return actual size as result */ res = size; } } } } } } rfid_cs (1); debug (" [%i]\n", res); /* everything fine */ return res; } int rfid_write (const void *data, int len) { int i; static const unsigned char preamble[] = { 0x01, 0x00, 0x00, 0xFF }; const unsigned char *p = preamble; unsigned char tfi = 0xD4, c; if (!data) len = 0xFF; debug ("TI: "); /* enable chip select */ rfid_cs (0); p = preamble; /* Praeamble */ for (i = 0; i < (int) sizeof (preamble); i++) rfid_tx (*p++); rfid_tx (len + 1); /* LEN */ rfid_tx (0x100 - (len + 1)); /* LCS */ rfid_tx (tfi); /* TFI */ /* PDn */ p = (const unsigned char *) data; while (len { c = *p++; debug (" %02X", c); rfid_tx (c); tfi += c; } rfid_tx (0x100 - tfi); /* DCS */ rfid_rx (); /* Postamble */ /* release chip select */ rfid_cs (1); debug ("\n"); /* check for ack */ return rfid_read (NULL, 0); } int rfid_execute (void *data, unsigned int isize, unsigned int osize) { int res; if ((res = rfid_write (data, isize)) < 0) return res; else return rfid_read (data, osize); } int rfid_write_register (unsigned short address, unsigned char data) { unsigned char cmd[4]; /* write register */ cmd[0] = <API key>; /* high byte of address */ cmd[1] = address >> 8; /* low byte of address */ cmd[2] = address & 0xFF; /* data value */ cmd[3] = data; return rfid_execute (&cmd, sizeof (cmd), sizeof (data)); } int rfid_read_register (unsigned short address) { int res; unsigned char cmd[3]; /* write register */ cmd[0] = <API key>; /* high byte of address */ cmd[1] = address >> 8; /* low byte of address */ cmd[2] = address & 0xFF; if ((res = rfid_execute (&cmd, sizeof (cmd), sizeof (cmd))) > 1) return cmd[1]; else return res; } int rfid_mask_register (unsigned short address, unsigned char data, unsigned char mask) { int res; if ((res = rfid_read_register (address)) < 0) return res; else return rfid_write_register (address, (((unsigned char) res) & (~mask)) | (data & mask)); } void rfid_init (void) { /* Initialize RESET line */ GPIOSetDir (PN532_RESET_PORT, PN532_RESET_PIN, 1); /* reset PN532 */ GPIOSetValue (PN532_RESET_PORT, PN532_RESET_PIN, 0); /* initialize PN532 IRQ line */ GPIOSetDir (PN532_IRQ_PORT, PN532_IRQ_PIN, 0); /* init RFID SPI interface */ spi_init (); spi_init_pin (SPI_CS_PN532); /* release reset line after 400ms */ pmu_wait_ms (400); GPIOSetValue (PN532_RESET_PORT, PN532_RESET_PIN, 1); /* wait for PN532 to boot */ pmu_wait_ms (100); } #endif /*ENABLE_PN532_RFID */
<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><link rel='stylesheet' type='text/css' href='../tononkira.css' /></head><body><ul class="hira-fihirana-list"><li style="color: red;"><b>Fihirana Vaovao</b> <i>p. 145</i></li></ul>Asandrato any aminao ny fanahiko, Ray ô.</body></html>
<!doctype html public "- <html> <head> <title>PHPXRef 0.7.1 : Unnamed Project : Detail view of _user_avatar.form.php</title> <link rel="stylesheet" href="../../../sample.css" type="text/css"> <link rel="stylesheet" href="../../../sample-print.css" type="text/css" media="print"> <style id="hilight" type="text/css"></style> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000" link="#801800" vlink="#300540" alink="#ffffff"> <table class="pagetitle" width="100%"> <tr> <td valign="top" class="pagetitle"> [ <a href="../../../index.html">Index</a> ] </td> <td align="right" class="pagetitle"> <h2 style="margin-bottom: 0px">PHP Cross Reference of Unnamed Project</h2> </td> </tr> </table> <!-- Generated by PHPXref 0.7.1 at Sat Nov 21 22:13:19 2015 --> <script src="../../../phpxref.js" type="text/javascript"></script> <script language="JavaScript" type="text/javascript"> <! ext='.html'; relbase='../../../'; subdir='inc/users/views'; filename='_user_avatar.form.php.html'; cookiekey='phpxref'; handleNavFrame(relbase, subdir, filename); </script> <script language="JavaScript" type="text/javascript"> if (gwGetCookie('xrefnav')=='off') document.write('<p class="navlinks">[ <a href="javascript:navOn()">Show Explorer<\/a> ]<\/p>'); else document.write('<p class="navlinks">[ <a href="javascript:navOff()">Hide Explorer<\/a> ]<\/p>'); </script> <noscript> <p class="navlinks"> [ <a href="../../../nav.html" target="_top">Show Explorer</a> ] [ <a href="index.html" target="_top">Hide Navbar</a> ] </p> </noscript> <script language="JavaScript" type="text/javascript"> <! document.writeln('<table align="right" class="searchbox-link"><tr><td><a class="searchbox-link" href="javascript:void(0)" onMouseOver="showSearchBox()">Search</a><br>'); document.writeln('<table border="0" cellspacing="0" cellpadding="0" class="searchbox" id="searchbox">'); document.writeln('<tr><td class="searchbox-title">'); document.writeln('<a class="searchbox-title" href="javascript:showSearchPopup()">Search History +</a>'); document.writeln('<\/td><\/tr>'); document.writeln('<tr><td class="searchbox-body" id="searchbox-body">'); document.writeln('<form name="search" style="margin:0px; padding:0px" onSubmit=\'return jump()\'>'); document.writeln('<a class="searchbox-body" href="../../../_classes/index.html">Class<\/a>: '); document.writeln('<input type="text" size=10 value="" name="classname"><br>'); document.writeln('<a id="funcsearchlink" class="searchbox-body" href="../../../_functions/index.html">Function<\/a>: '); document.writeln('<input type="text" size=10 value="" name="funcname"><br>'); document.writeln('<a class="searchbox-body" href="../../../_variables/index.html">Variable<\/a>: '); document.writeln('<input type="text" size=10 value="" name="varname"><br>'); document.writeln('<a class="searchbox-body" href="../../../_constants/index.html">Constant<\/a>: '); document.writeln('<input type="text" size=10 value="" name="constname"><br>'); document.writeln('<a class="searchbox-body" href="../../../_tables/index.html">Table<\/a>: '); document.writeln('<input type="text" size=10 value="" name="tablename"><br>'); document.writeln('<input type="submit" class="searchbox-button" value="Search">'); document.writeln('<\/form>'); document.writeln('<\/td><\/tr><\/table>'); document.writeln('<\/td><\/tr><\/table>'); </script> <div id="search-popup" class="searchpopup"><p id="searchpopup-title" class="searchpopup-title">title</p><div id="searchpopup-body" class="searchpopup-body">Body</div><p class="searchpopup-close"><a href="javascript:gwCloseActive()">[close]</a></p></div> <h2 class="details-heading"><a href="./index.html">/inc/users/views/</a> -> <a href="_user_avatar.form.php.source.html">_user_avatar.form.php</a> (summary)</h2> <div class="details-summary"> <p class="viewlinks">[<a href="_user_avatar.form.php.source.html">Source view</a>] [<a href="javascript:window.print();">Print</a>] [<a href="../../../_stats.html">Project Stats</a>]</p> <p><b>(no description)</b></p> <table> <tr><td align="right">File Size: </td><td>271 lines (10 kb)</td></tr> <tr><td align="right">Included or required:</td><td>0 times</td></tr> <tr><td align="right" valign="top">Referenced: </td><td>0 times</td></tr> <tr><td align="right" valign="top">Includes or requires: </td><td>0 files</td></tr> </table> </div> <br><div class="details-funclist"> </div> <!-- A link to the phpxref site in your customized footer file is appreciated ;-) --> <br><hr> <table width="100%"> <tr><td>Generated: Sat Nov 21 22:13:19 2015</td> <td align="right"><i>Cross-referenced by <a href="http://phpxref.sourceforge.net/">PHPXref 0.7.1</a></i></td> </tr> </table> </body></html>
package com.dtr.oas.service; import java.util.List; import com.dtr.oas.exception.<API key>; import com.dtr.oas.exception.<API key>; import com.dtr.oas.model.Strategy; public interface StrategyService { public void addStrategy(Strategy strategy) throws <API key>; public Strategy getStrategy(int id) throws <API key>; public void updateStrategy(Strategy strategy) throws <API key>, <API key>; public void deleteStrategy(int id) throws <API key>; public List<Strategy> getStrategies(); }
#ifndef __SHARED_PARSER_H__ #define __SHARED_PARSER_H__ struct include_file_buffer { int line; char *config_file; char *config_save; }; void include_file(FILE *f, char *name); void save_parse_context(struct include_file_buffer *buffer, FILE *f, char *name); void <API key>(struct include_file_buffer *buffer); int check_uniq(const char *what, const char *fmt, ...); int check_upr(const char *what, const char *fmt, ...); #endif
start javaw -Djava.library.path=../lib -classpath ./;<API key>.jar;../lib/NativeFmodEx.jar org.jouvieje.FmodEx.Examples.PlayList
#!/bin/bash # mak _ramsize="512" diskfile="ffs.img" _rebuild="0" _debug="0" _curses="" _logtofile="stdio" _test="0" _test_arg="" _vga="-vga std" _power="-device isa-debug-exit,iobase=0xf4,iosize=0x04" _kvm="-no-kvm" if [ ! -e "kernel" ]; then _rebuild="1" fi _test_arg_need="0" for arg in $@ do if [ "$_test_arg_need" == "1" ]; then _test_arg="$_test_arg $arg" _test_arg_need="0" elif [ "$arg" == "rebuild" ]; then _rebuild="1" elif [ "$arg" == "debug" ]; then _debug="1" elif [ "$arg" == "curses" ]; then _curses="-curses" _vga="" elif [ "$arg" == "kvm" ]; then _kvm="-enable-kvm" elif [ "$arg" == "" ]; then _rebuild="0" _debug="0" elif [ "$arg" == "logtofile" ]; then _logtofile="file:krn.log" elif [ "$arg" == "test" ]; then _test="1" _test_arg_need="1" else echo "usage:" echo "./run.sh param1 param2 param2 ..." echo "param:" echo -e "\t rebuild: rebuild project before running" echo -e "\t debug: wait for gdb before running" echo -e "\t curses: use current console as vm console instead of opening a new window" echo -e "\t logtofile: write kernel log to file \"krn.log\" instead of stdio" echo -e "\t testall: run all tests" echo -e "\t test verbos: run with debug information" exit fi done if [ "$_curses" == "-curses" ]; then _logtofile="file:krn.log" fi if [ "$_rebuild" == "1" ]; then make fi echo "begin enum" if [ "$_debug" == "0" ]; then if [ "$_test" == "1" ]; then qemu-system-i386 $_curses -m $_ramsize -hda "$diskfile" -kernel kernel -append "test $_test_arg" -serial $_logtofile $_vga $_power $_kvm else qemu-system-i386 $_curses -m $_ramsize -hda "$diskfile" -kernel kernel -serial $_logtofile $_vga $_power $_kvm fi else if [ "$_test" == "1" ]; then qemu-system-i386 $_curses -no-reboot -m $_ramsize -hda "$diskfile" -kernel kernel -append "test $_test_arg" -serial $_logtofile $_vga $_power $_kvm -gdb tcp::8888 -S else qemu-system-i386 $_curses -no-reboot -m $_ramsize -hda "$diskfile" -kernel kernel -serial $_logtofile $_vga $_power $_kvm -gdb tcp::8888 -S fi fi
<?php namespace oat\taoRevision\model; use common_Exception; use common_Logger; use oat\generis\model\fileReference\<API key>; use oat\generis\model\GenerisRdf; use oat\generis\model\OntologyAwareTrait; use oat\generis\model\OntologyRdfs; use oat\oatbox\filesystem\Directory; use oat\oatbox\filesystem\File; use oat\oatbox\filesystem\FileSystemService; use oat\oatbox\service\ConfigurableService; use <API key> as TriplesCollection; use <API key> as Resource; use <API key> as Triple; use <API key> as Model; use oat\taoMediaManager\model\fileManagement\<API key>; use oat\taoMediaManager\model\MediaService; /** * Class <API key> * @package oat\taoRevision\model */ class <API key> extends ConfigurableService { use OntologyAwareTrait; public const SERVICE_ID = 'taoRevision/triples'; /** * @return <API key> */ protected function <API key>() { return $this->getServiceLocator()->get(<API key>::SERVICE_ID); } /** * @param Triple $triple */ public function <API key>(Triple $triple) { if (!$this->isFileReference($triple)) { return; } $referencer = $this-><API key>(); $this->serializeAsset($triple); $source = $referencer->unserialize($triple->object); if ($source instanceof Directory) { $source->deleteSelf(); } elseif ($source instanceof File) { $source->delete(); } $referencer->cleanUp($triple->object); } /** * @param Resource $resource * @param Model|null $model */ public function deleteTriplesFor(Resource $resource, Model $model = null) { $triples = $model ? $model->getRdfsInterface()-><API key>()->getRdfTriples($resource) : $resource->getRdfTriples(); foreach ($triples as $triple) { $this-><API key>($triple); } $resource->delete(); } /** * @param TriplesCollection $triples * @param array $<API key> * * @return array * @throws common_Exception */ public function cloneTriples(TriplesCollection $triples, array $<API key> = []) { $clones = []; foreach ($triples as $original) { $triple = clone $original; if ($this->isFileReference($triple)) { $targetFileSystem = $<API key>[$triple->predicate] ?? null; $this->serializeAsset($triple); $triple->object = $this->cloneFile($triple->object, $targetFileSystem); } $clones[] = $triple; } return $clones; } /** * @param $fileUri * @param null $targetFileSystemId * * @return string * @throws \common_Exception * @throws \<API key> */ protected function cloneFile($fileUri, $targetFileSystemId = null) { $referencer = $this-><API key>(); $flySystemService = $this->getServiceLocator()->get(FileSystemService::SERVICE_ID); $source = $referencer->unserialize($fileUri); $targetFileSystemId = !$targetFileSystemId ? $source->getFileSystemId() : $targetFileSystemId; $destinationPath = $flySystemService->getDirectory($targetFileSystemId)->getDirectory(uniqid('', true)); if ($source instanceof Directory) { common_Logger::i('clone directory ' . $fileUri); foreach ($source->getFlyIterator(Directory::ITERATOR_FILE | Directory::ITERATOR_RECURSIVE) as $file) { $destinationPath->getFile($source->getRelPath($file))->write($file->readStream()); } $destination = $destinationPath; } elseif ($source instanceof File) { common_Logger::i('clone file ' . $fileUri); $destination = $destinationPath->getFile($source->getBasename()); $destination->write($source->readStream()); } return $referencer->serialize($destination); } /** * @param TriplesCollection $triples * * @return array */ public function <API key>(TriplesCollection $triples) { $map = []; foreach ($triples as $triple) { if ($this->isFileReference($triple)) { $this->serializeAsset($triple); $source = $this-><API key>()->unserialize($triple->object); $map[$triple->predicate] = $source->getFileSystemId(); } } return $map; } /** * @param Triple $triple * * @return bool */ protected function isFileReference(Triple $triple) { $property = $this->getProperty($triple->predicate); $range = $property->getRange(); $uri = $property->getUri(); if ($uri == MediaService::PROPERTY_LINK) { return true; } if ($range === null) { return false; } switch ($range->getUri()) { case GenerisRdf::CLASS_GENERIS_FILE: return true; case OntologyRdfs::RDFS_RESOURCE: $object = $this->getResource($triple->object); return $object->hasType($this->getClass(GenerisRdf::CLASS_GENERIS_FILE)); default: return false; } } private function serializeAsset(Triple $triple): void { $this-><API key>()->serialize($triple); } private function <API key>(): <API key> { return $this->getServiceLocator()->get(<API key>::class); } }
#pragma once #include "MapStrToID.h" #include "ScriptParser.h" #include <vector> using namespace std; class CCfgFileLoader { public: struct Session { std::string strName; CMapStrToIDMgr m_wordsMgr; std::vector<CScriptWords2*> m_vectorWords; }; public: CCfgFileLoader(void); ~CCfgFileLoader(void); BOOL LoadFromFile( const char* pszFilename ); BOOL LoadEncryptFile(const char* pszFilename ); int ReadLine( char* pchLine, char szBuffer[], int nBufferSize ); BOOL LoadFileFromMemory( BYTE* pbyBuffer, int nBufferSize ); CScriptWords2* GetWords( const char* pszName ); BOOL OpenSession( const char* pszSessionName ); BOOL OpenSession( int i ); CMapStrToIDMgr* GetSessionMgr(){ return &m_sessionMgr; } const char* GetStringValue( const char* pszName ); BOOL GetStringValue( const char* pszName, const char* pszDefault, char szBuffer[], int nBufferSize ); int GetIntValue( const char* pszName ); float GetFloatValue( const char* pszName ); BOOL HasKey( const char* pszName ); const char* GetLineStringValue( int nLine ); const char* GetLineKeyName( int nLine ); int GetSessionCount(){ return m_sessions.size(); } int GetWordCount(); int <API key>(); const char* <API key>(); protected: std::vector<CScriptWords2*> m_vectorWords; Session* m_pCurrentSession; CMapStrToIDMgr m_sessionMgr; std::vector<Session*> m_sessions; };
#include <linux/serial_core.h> #include <asm/io.h> #include <asm/gpio.h> #if defined(CONFIG_H83007) || defined(CONFIG_H83068) #include <asm/regs306x.h> #endif #if defined(CONFIG_H8S2678) #include <asm/regs267x.h> #endif #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) # define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ # define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ #elif defined(<API key>) # define SCIF0 0xA4400000 # define SCIF2 0xA4410000 # define SCSMR_Ir 0xA44A0000 # define IRDA_SCIF SCIF0 # define SCPCR 0xA4000116 # define SCPDR 0xA4000136 /* Set the clock source, * SCIF2 (0xA4410000) -> External clock, SCK pin used as clock input * SCIF0 (0xA4400000) -> Internal clock, SCK pin as serial clock output */ # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 #elif defined(<API key>) || \ defined(<API key>) # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ #define SCIF_ORER 0x0200 /* overrun error bit */ #elif defined(<API key>) # define SCSPTR1 0xFFE0001C /* 8 bit SCIF */ # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) # define SCSPTR1 0xffe0001c /* 8 bit SCI */ # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \ 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \ 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ ) #elif defined(<API key>) # define SCSPTR0 0xfe600024 /* 16 bit SCIF */ # define SCSPTR1 0xfe610024 /* 16 bit SCIF */ # define SCSPTR2 0xfe620024 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) || defined(<API key>) # define SCSPTR0 0xA4400000 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* overrun error bit */ # define PACR 0xa4050100 # define PBCR 0xa4050102 # define SCSCR_INIT(port) 0x3B #elif defined(<API key>) # define SCSPTR0 0xffe00010 /* 16 bit SCIF */ # define SCSPTR1 0xffe10010 /* 16 bit SCIF */ # define SCSPTR2 0xffe20010 /* 16 bit SCIF */ # define SCSPTR3 0xffe30010 /* 16 bit SCIF */ # define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */ #elif defined(<API key>) # define PADR 0xA4050120 # define PSDR 0xA405013e # define PWDR 0xA4050166 # define PSCR 0xA405011E # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) # define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */ # define SCSPTR0 SCPDR0 # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) # define SCSPTR0 0xa4050160 # define SCSPTR1 0xa405013e # define SCSPTR2 0xa4050160 # define SCSPTR3 0xa405013e # define SCSPTR4 0xa4050128 # define SCSPTR5 0xa4050128 # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) || defined(<API key>) # define SCIF_BASE_ADDR 0x01030000 # define SCIF_ADDR_SH5 <API key>+SCIF_BASE_ADDR # define SCIF_PTR2_OFFS 0x0000020 # define SCIF_LSR2_OFFS 0x0000024 # define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ # define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, TE=1,RE=1,REIE=1 */ #elif defined(CONFIG_H83007) || defined(CONFIG_H83068) # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) #elif defined(CONFIG_H8S2678) # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) #elif defined(<API key>) # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ # define SCSPTR1 0xffe08024 /* 16 bit SCIF */ # define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */ # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) # define SCSPTR0 0xff923020 /* 16 bit SCIF */ # define SCSPTR1 0xff924020 /* 16 bit SCIF */ # define SCSPTR2 0xff925020 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */ #elif defined(<API key>) # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ # define SCSPTR1 0xffe10024 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* Overrun error bit */ # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) # define SCSPTR0 0xffea0024 /* 16 bit SCIF */ # define SCSPTR1 0xffeb0024 /* 16 bit SCIF */ # define SCSPTR2 0xffec0024 /* 16 bit SCIF */ # define SCSPTR3 0xffed0024 /* 16 bit SCIF */ # define SCSPTR4 0xffee0024 /* 16 bit SCIF */ # define SCSPTR5 0xffef0024 /* 16 bit SCIF */ # define SCIF_OPER 0x0001 /* Overrun error bit */ # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) # define SCSPTR0 0xfffe8020 /* 16 bit SCIF */ # define SCSPTR1 0xfffe8820 /* 16 bit SCIF */ # define SCSPTR2 0xfffe9020 /* 16 bit SCIF */ # define SCSPTR3 0xfffe9820 /* 16 bit SCIF */ # if defined(<API key>) # define SCSPTR4 0xfffeA020 /* 16 bit SCIF */ # define SCSPTR5 0xfffeA820 /* 16 bit SCIF */ # define SCSPTR6 0xfffeB020 /* 16 bit SCIF */ # define SCSPTR7 0xfffeB820 /* 16 bit SCIF */ # endif # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) # define SCSPTR0 0xf8400020 /* 16 bit SCIF */ # define SCSPTR1 0xf8410020 /* 16 bit SCIF */ # define SCSPTR2 0xf8420020 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* overrun error bit */ # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #elif defined(<API key>) # define SCSPTR0 0xffc30020 /* 16 bit SCIF */ # define SCSPTR1 0xffc40020 /* 16 bit SCIF */ # define SCSPTR2 0xffc50020 /* 16 bit SCIF */ # define SCSPTR3 0xffc60020 /* 16 bit SCIF */ # define SCIF_ORER 0x0001 /* Overrun error bit */ # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ #else # error CPU subtype not defined #endif /* SCSCR */ #define SCI_CTRL_FLAGS_TIE 0x80 /* all */ #define SCI_CTRL_FLAGS_RIE 0x40 /* all */ #define SCI_CTRL_FLAGS_TE 0x20 /* all */ #define SCI_CTRL_FLAGS_RE 0x10 /* all */ #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ #else #define SCI_CTRL_FLAGS_REIE 0 #endif /* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ /* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ /* SCI_CTRL_FLAGS_CKE1 0x02 * all */ /* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */ /* SCxSR SCI */ #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER) /* SCxSR SCIF */ #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) # define SCIF_ORER 0x0200 # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) # define SCIF_RFDC_MASK 0x007f # define SCIF_TXROOM_MAX 64 #elif defined(<API key>) # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK ) # define SCIF_RFDC_MASK 0x007f # define SCIF_TXROOM_MAX 64 /* SH7763 SCIF2 support */ # define SCIF2_RFDC_MASK 0x001f # define SCIF2_TXROOM_MAX 16 #else # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) # define SCIF_RFDC_MASK 0x001f # define SCIF_TXROOM_MAX 16 #endif #ifndef SCIF_ORER #define SCIF_ORER 0x0000 #endif #define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) #define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS) #define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF) #define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE) #define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER) #define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) #define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) #define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER) #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3) #else # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc) # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073) # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df) # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3) #endif /* SCFCR */ #define SCFCR_RFRST 0x0002 #define SCFCR_TFRST 0x0004 #define SCFCR_TCRST 0x4000 #define SCFCR_MCE 0x0008 #define SCI_MAJOR 204 #define SCI_MINOR_START 8 /* Generic serial flags */ #define SCI_RX_THROTTLE 0x0000001 #define SCI_MAGIC 0xbabeface /* * Events are used to schedule things to happen at timer-interrupt * time, instead of at rs interrupt time. */ #define <API key> 0 #define SCI_IN(size, offset) \ if ((size) == 8) { \ return ioread8(port->membase + (offset)); \ } else { \ return ioread16(port->membase + (offset)); \ } #define SCI_OUT(size, offset, value) \ if ((size) == 8) { \ iowrite8(value, port->membase + (offset)); \ } else if ((size) == 16) { \ iowrite16(value, port->membase + (offset)); \ } #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ static inline unsigned int sci_##name##_in(struct uart_port *port) \ { \ if (port->type == PORT_SCIF) { \ SCI_IN(scif_size, scif_offset) \ } else { /* PORT_SCI or PORT_SCIFA */ \ SCI_IN(sci_size, sci_offset); \ } \ } \ static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ { \ if (port->type == PORT_SCIF) { \ SCI_OUT(scif_size, scif_offset, value) \ } else { /* PORT_SCI or PORT_SCIFA */ \ SCI_OUT(sci_size, sci_offset, value); \ } \ } #define CPU_SCIF_FNS(name, scif_offset, scif_size) \ static inline unsigned int sci_##name##_in(struct uart_port *port) \ { \ SCI_IN(scif_size, scif_offset); \ } \ static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ { \ SCI_OUT(scif_size, scif_offset, value); \ } #define CPU_SCI_FNS(name, sci_offset, sci_size) \ static inline unsigned int sci_##name##_in(struct uart_port* port) \ { \ SCI_IN(sci_size, sci_offset); \ } \ static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \ { \ SCI_OUT(sci_size, sci_offset, value); \ } #ifdef CONFIG_CPU_SH3 #if defined(<API key>) || defined(<API key>) #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ h8_sci_offset, h8_sci_size) \ CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) #elif defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) #define SCIF_FNS(name, scif_offset, scif_size) \ CPU_SCIF_FNS(name, scif_offset, scif_size) #else #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ h8_sci_offset, h8_sci_size) \ CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size) #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size) #endif #elif defined(__H8300H__) || defined(__H8300S__) #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ h8_sci_offset, h8_sci_size) \ CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size) #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) #elif defined(<API key>) #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \ CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \ CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) #else #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ h8_sci_offset, h8_sci_size) \ CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) #endif #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) SCIF_FNS(SCSMR, 0x00, 16) SCIF_FNS(SCBRR, 0x04, 8) SCIF_FNS(SCSCR, 0x08, 16) SCIF_FNS(SCTDSR, 0x0c, 8) SCIF_FNS(SCFER, 0x10, 16) SCIF_FNS(SCxSR, 0x14, 16) SCIF_FNS(SCFCR, 0x18, 16) SCIF_FNS(SCFDR, 0x1c, 16) SCIF_FNS(SCxTDR, 0x20, 8) SCIF_FNS(SCxRDR, 0x24, 8) SCIF_FNS(SCLSR, 0x24, 16) #elif defined(<API key>) SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16) SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8) SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16) SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8) SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16) SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8) SCIF_FNS(SCTDSR, 0x0c, 8) SCIF_FNS(SCFER, 0x10, 16) SCIF_FNS(SCFCR, 0x18, 16) SCIF_FNS(SCFDR, 0x1c, 16) SCIF_FNS(SCLSR, 0x24, 16) #else /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/ /* name off sz off sz off sz off sz off sz*/ SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8) SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8) SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8) SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8) SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) SCIF_FNS(SCLSR, 0, 0, 0x28, 16) #elif defined(<API key>) SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16) SCIF_FNS(SCLSR2, 0, 0, 0x24, 16) SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) SCIF_FNS(SCLSR, 0, 0, 0x28, 16) #else SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) #if defined(<API key>) SCIF_FNS(SCSPTR, 0, 0, 0, 0) #else SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) #endif SCIF_FNS(SCLSR, 0, 0, 0x24, 16) #endif #endif #define sci_in(port, reg) sci_##reg##_in(port) #define sci_out(port, reg, value) sci_##reg##_out(port, value) /* H8/300 series SCI pins assignment */ #if defined(__H8300H__) || defined(__H8300S__) static const struct __attribute__((packed)) { int port; /* GPIO port no */ unsigned short rx,tx; /* GPIO bit no */ } h8300_sci_pins[] = { #if defined(CONFIG_H83007) || defined(CONFIG_H83068) { /* SCI0 */ .port = H8300_GPIO_P9, .rx = H8300_GPIO_B2, .tx = H8300_GPIO_B0, }, { /* SCI1 */ .port = H8300_GPIO_P9, .rx = H8300_GPIO_B3, .tx = H8300_GPIO_B1, }, { /* SCI2 */ .port = H8300_GPIO_PB, .rx = H8300_GPIO_B7, .tx = H8300_GPIO_B6, } #elif defined(CONFIG_H8S2678) { /* SCI0 */ .port = H8300_GPIO_P3, .rx = H8300_GPIO_B2, .tx = H8300_GPIO_B0, }, { /* SCI1 */ .port = H8300_GPIO_P3, .rx = H8300_GPIO_B3, .tx = H8300_GPIO_B1, }, { /* SCI2 */ .port = H8300_GPIO_P5, .rx = H8300_GPIO_B1, .tx = H8300_GPIO_B0, } #endif }; #endif #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xfffffe80) return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCI */ if (port->mapbase == 0xa4000150) return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xa4000140) return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == SCIF0) return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */ if (port->mapbase == SCIF2) return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) || defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { return sci_in(port,SCxSR)&0x0010 ? 1 : 0; } #elif defined(<API key>) || \ defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xa4430000) return sci_in(port, SCxSR) & 0x0003 ? 1 : 0; else if (port->mapbase == 0xa4438000) return sci_in(port, SCxSR) & 0x0003 ? 1 : 0; return 1; } #elif defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffe00000) return ctrl_inb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */ if (port->mapbase == 0xffe80000) return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffe80000) return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xfe600000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xfe610000) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xfe620000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffe00000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffe10000) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffe20000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffe30000) return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffe00000) return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffe00000) return ctrl_inb(PSDR) & 0x02 ? 1 : 0; /* SCIF0 */ if (port->mapbase == 0xffe10000) return ctrl_inb(PADR) & 0x40 ? 1 : 0; /* SCIF1 */ if (port->mapbase == 0xffe20000) return ctrl_inb(PWDR) & 0x04 ? 1 : 0; /* SCIF2 */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffe00000) return ctrl_inb(SCSPTR0) & 0x0008 ? 1 : 0; /* SCIF0 */ if (port->mapbase == 0xffe10000) return ctrl_inb(SCSPTR1) & 0x0020 ? 1 : 0; /* SCIF1 */ if (port->mapbase == 0xffe20000) return ctrl_inb(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF2 */ if (port->mapbase == 0xa4e30000) return ctrl_inb(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF3 */ if (port->mapbase == 0xa4e40000) return ctrl_inb(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF4 */ if (port->mapbase == 0xa4e50000) return ctrl_inb(SCSPTR5) & 0x0008 ? 1 : 0; /* SCIF5 */ return 1; } #elif defined(<API key>) || defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { return sci_in(port, SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */ } #elif defined(__H8300H__) || defined(__H8300S__) static inline int sci_rxd_in(struct uart_port *port) { int ch = (port->mapbase - SMR0) >> 3; return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffe00000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffe08000) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffe10000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF/IRDA */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xff923000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xff924000) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xff925000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffe00000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffe10000) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffea0000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffeb0000) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffec0000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffed0000) return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffee0000) return ctrl_inw(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffef0000) return ctrl_inw(SCSPTR5) & 0x0001 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xfffe8000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xfffe8800) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xfffe9000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xfffe9800) return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ #if defined(<API key>) if (port->mapbase == 0xfffeA000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xfffeA800) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xfffeB000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xfffeB800) return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ #endif return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xf8400000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xf8410000) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xf8420000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ return 1; } #elif defined(<API key>) static inline int sci_rxd_in(struct uart_port *port) { if (port->mapbase == 0xffc30000) return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffc40000) return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffc50000) return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ if (port->mapbase == 0xffc60000) return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ return 1; } #endif /* * Values for the BitRate Register (SCBRR) * * The values are actually divisors for a frequency which can * be internal to the SH3 (14.7456MHz) or derived from an external * clock source. This driver assumes the internal clock is used; * to support using an external clock source, config options or * possibly command-line options would need to be added. * * Also, to support speeds below 2400 (why?) the lower 2 bits of * the SCSMR register would also need to be set to non-zero values. * * -- Greg Banks 27Feb2000 * * Answer: The SCBRR register is only eight bits, and the value in * it gets larger with lower baud rates. At around 2400 (depending on * the peripherial module clock) you run out of bits. However the * lower two bits of SCSMR allow the module clock to be divided down, * scaling the value which is needed in SCBRR. * * -- Stuart Menefy - 23 May 2000 * * I meant, why would anyone bother with bitrates below 2400. * * -- Greg Banks - 7Jul2000 * * You "speedist"! How will I use my 110bps ASR-33 teletype with paper * tape reader as a console! * * -- Mitch Davis - 15 Jul 2000 */ #if defined(<API key>) || \ defined(<API key>) #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) #elif defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) #elif defined(<API key>) static inline int scbrr_calc(struct uart_port *port, int bps, int clk) { if (port->type == PORT_SCIF) return (clk+16*bps)/(32*bps)-1; else return ((clk*2)+16*bps)/(16*bps)-1; } #define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk) #elif defined(__H8300H__) || defined(__H8300S__) #define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1) #else /* Generic SH */ #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) #endif
<?php defined( '_JEXEC' ) or die( 'Unauthorized Access' ); // Import parent view FD::import( 'site:/views/views' ); class <API key> extends EasySocialSiteView { /** * Retrieves groups * * @since 1.0 * @access public * @param Array An array of groups */ public function getGroups( $groups = array() , $pagination = null , $featuredGroups = array() ) { $ajax = FD::ajax(); if( $this->hasErrors() ) { return $ajax->reject( $this->getMessage() ); } // Determines if we should add the category header $categoryId = JRequest::getInt( 'categoryId' ); $category = false; $theme = FD::themes(); if( $categoryId ) { $category = FD::table( 'GroupCategory' ); $category->load( $categoryId ); } // Filter $filter = JRequest::getVar( 'filter' ); $theme->set( 'activeCategory' , $category ); $theme->set( 'filter' , $filter ); $theme->set( 'pagination' , $pagination ); $theme->set( 'featuredGroups' , $featuredGroups ); $theme->set( 'groups' , $groups ); // Retrieve items from the template $content = $theme->output( 'site/groups/default.items' ); return $ajax->resolve( $content ); } /** * Responsible to output the application contents. * * @since 1.0 * @access public * @param SocialAppTable The application ORM. */ public function getAppContents( $app ) { $ajax = FD::ajax(); // If there's an error throw it back to the caller. if( $this->hasErrors() ) { return $ajax->reject( $this->getMessage() ); } // Get the current logged in user. $groupId = JRequest::getInt( 'groupId' ); $group = FD::group( $groupId ); // Load the library. $lib = FD::getInstance( 'Apps' ); $contents = $lib->renderView( <API key> , 'groups' , $app , array( 'groupId' => $group->id ) ); // Return the contents return $ajax->resolve( $contents ); } /** * Displays the invite friend form * * @since 1.0 * @access public * @param string * @return */ public function inviteFriends() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); $my = FD::user(); // Get a list of friends that are already in this group $model = FD::model('Groups'); $friends = $model->getFriendsInGroup( $group->id , array( 'userId' => $my->id ) ); $exclusion = array(); if ($friends) { foreach ($friends as $friend) { $exclusion[] = $friend->id; } } $theme = FD::themes(); $theme->set('exclusion', $exclusion); $theme->set('group', $group); $contents = $theme->output( 'site/groups/dialog.invite' ); return $ajax->resolve( $contents ); } /** * Displays the confirmation dialog to set a group as featured * * @since 1.0 * @access public * @param string * @return */ public function setFeatured() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); $theme = FD::themes(); $theme->set( 'group' , $group ); $contents = $theme->output( 'site/groups/dialog.featured' ); return $ajax->resolve( $contents ); } /** * Displays the confirmation dialog to set a group as featured * * @since 1.0 * @access public * @param string * @return */ public function removeFeatured() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); $theme = FD::themes(); $theme->set( 'group' , $group ); $contents = $theme->output( 'site/groups/dialog.unfeature' ); return $ajax->resolve( $contents ); } /** * Displays the respond to invitation dialog * * @since 1.0 * @access public * @param string * @return */ public function respondInvitation() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); // Get the current user. $my = FD::user(); // Load the member $member = FD::table( 'GroupMember' ); $member->load( array( 'cluster_id' => $group->id , 'uid' => $my->id ) ); // Get the invitor $invitor = FD::user( $member->invited_by ); $theme = FD::themes(); $theme->set( 'group' , $group ); $theme->set( 'invitor' , $invitor ); $contents = $theme->output( 'site/groups/dialog.respond' ); return $ajax->resolve( $contents ); } /** * Displays the confirmation to delete a group * * @since 1.2 * @access public * @param string * @return */ public function confirmDelete() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); $theme = FD::themes(); $theme->set( 'group' , $group ); $contents = $theme->output( 'site/groups/dialog.delete' ); return $ajax->resolve( $contents ); } /** * Displays the confirmation to delete a group * * @since 1.2 * @access public * @param string * @return */ public function <API key>() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); $theme = FD::themes(); $theme->set( 'group' , $group ); $contents = $theme->output( 'site/groups/dialog.unpublish' ); return $ajax->resolve( $contents ); } /** * Displays the confirmation to withdraw application * * @since 1.2 * @access public * @param string * @return */ public function confirmWithdraw() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); $theme = FD::themes(); $theme->set( 'group' , $group ); $contents = $theme->output( 'site/groups/dialog.withdraw' ); return $ajax->resolve( $contents ); } /** * Displays the confirmation to approve user application * * @since 1.2 * @access public * @param string * @return */ public function confirmApprove() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); // Get the user id $userId = JRequest::getInt( 'userId' ); $user = FD::user( $userId ); $theme = FD::themes(); $theme->set( 'group' , $group ); $theme->set( 'user' , $user ); $contents = $theme->output( 'site/groups/dialog.approve' ); return $ajax->resolve( $contents ); } /** * Displays the confirmation to remove user from group * * @since 1.2 * @access public * @param string * @return */ public function confirmRemoveMember() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); // Get the user id $userId = JRequest::getInt( 'userId' ); $user = FD::user( $userId ); $theme = FD::themes(); $theme->set( 'group' , $group ); $theme->set( 'user' , $user ); $contents = $theme->output( 'site/groups/dialog.remove.member' ); return $ajax->resolve( $contents ); } /** * Displays the confirmation to reject user application * * @since 1.2 * @access public * @param string * @return */ public function confirmReject() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); // Get the user id $userId = JRequest::getInt( 'userId' ); $user = FD::user( $userId ); $theme = FD::themes(); $theme->set( 'group' , $group ); $theme->set( 'user' , $user ); $contents = $theme->output( 'site/groups/dialog.reject' ); return $ajax->resolve( $contents ); } /** * Displays the join group exceeded notice * * @since 1.2 * @access public * @param string * @return */ public function exceededJoin() { $ajax = FD::ajax(); $my = FD::user(); $allowed = $my->getAccess()->get( 'groups.join' ); $theme = FD::themes(); $theme->set( 'allowed' , $allowed ); $contents = $theme->output( 'site/groups/dialog.join.exceeded' ); return $ajax->resolve( $contents ); } /** * Displays the join group dialog * * @since 1.2 * @access public * @param string * @return */ public function joinGroup() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); if( !$id || !$group ) { return $ajax->reject(); } $theme = FD::themes(); $theme->set( 'group' , $group ); // Check if the group is open or closed if( $group->isClosed() ) { $contents = $theme->output( 'site/groups/dialog.join.closed' ); } if( $group->isOpen() ) { $contents = $theme->output( 'site/groups/dialog.join.open' ); } return $ajax->resolve( $contents ); } /** * Post process after a user is made an admin * * @since 1.2 * @access public */ public function makeAdmin() { $ajax = FD::ajax(); if( $this->hasErrors() ) { return $ajax->reject( $this->getMessage() ); } return $ajax->resolve(); } /** * Displays the make admin confirmation dialog * * @since 1.0 * @access public * @param string * @return */ public function confirmRevokeAdmin() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $user = FD::user($id); $theme = FD::themes(); $theme->set( 'user' , $user ); // Check if the group is open or closed $contents = $theme->output( 'site/groups/dialog.revoke.admin' ); return $ajax->resolve( $contents ); } /** * Displays the make admin confirmation dialog * * @since 1.0 * @access public * @param string * @return */ public function confirmMakeAdmin() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $user = FD::user( $id ); $theme = FD::themes(); $theme->set( 'user' , $user ); // Check if the group is open or closed $contents = $theme->output( 'site/groups/dialog.admin' ); return $ajax->resolve( $contents ); } /** * Displays the join group dialog * * @since 1.0 * @access public * @param string * @return */ public function confirmLeaveGroup() { // Only logged in users are allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get the group id from request $id = JRequest::getInt( 'id' ); // Load up the group $group = FD::group( $id ); $theme = FD::themes(); $theme->set( 'group' , $group ); // Check if the group is open or closed $contents = $theme->output( 'site/groups/dialog.leave' ); return $ajax->resolve( $contents ); } public function getStream( $stream = null ) { $ajax = FD::ajax(); if( $this->hasErrors() ) { return $ajax->reject( $this->getMessage() ); } $contents = $stream->html(); return $ajax->resolve( $contents ); } /** * Displays the stream filter form * * @since 1.2 * @access public * @param string * @return */ public function getFilter( $filter, $groupId ) { $ajax = FD::ajax(); $group = FD::group( $groupId ); $theme = FD::themes(); $theme->set( 'controller' , 'groups' ); $theme->set( 'filter' , $filter ); $theme->set( 'uid' , $group->id ); $contents = $theme->output( 'site/stream/form.edit' ); return $ajax->resolve( $contents ); } /** * post processing for quicky adding group filter. * * @since 1.2 * @access public * @param string * @return */ public function addFilter( $filter, $groupId ) { $ajax = FD::ajax(); FD::requireLogin(); $theme = FD::themes(); $group = FD::group( $groupId ); $theme->set( 'filter' , $filter ); $theme->set( 'group' , $group ); $theme->set( 'filterId' , '0' ); $content = $theme->output( 'site/groups/item.filter' ); return $ajax->resolve( $content, JText::_( '<API key>' ) ); } /** * post processing after group filter get deleted. * * @since 1.2 * @access public * @param string * @return */ public function deleteFilter( $groupId ) { $ajax = FD::ajax(); FD::requireLogin(); FD::info()->set( $this->getMessage() ); $group = FD::group( $groupId ); $url = FRoute::groups( array( 'layout' => 'item' , 'id' => $group->getAlias() ), false ); return $ajax->redirect( $url ); } public function initInfo($steps = null) { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } return $ajax->resolve($steps); } public function getInfo($fields = null) { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } $theme = FD::themes(); $theme->set('fields', $fields); $contents = $theme->output('site/groups/item.info'); return $ajax->resolve($contents); } }
package com.android.W3T.app; import android.app.Activity; import android.app.PendingIntent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter.<API key>; import android.os.Bundle; import android.view.KeyEvent; import android.widget.Toast; import android.nfc.NdefMessage; import android.nfc.NdefRecord; import android.nfc.NfcAdapter; import com.android.W3T.app.nfc.*; public class NfcConnecting extends Activity { private NfcAdapter mAdapter; private PendingIntent mPendingIntent; private IntentFilter[] mFilters; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Just showing a message in the center of the screen setContentView(R.layout.nfc_connecting); } @Override public void onResume() { super.onResume(); } @Override public void onPause() { super.onPause(); finish(); } @Override public void onNewIntent(Intent intent) { // This is called to check where the PendingIntent is going. Toast.makeText(this, "NfcConnecting onNewIntent", Toast.LENGTH_SHORT).show(); } // @Override // // Deal with any key press event // public boolean onKeyUp (int keyCode, KeyEvent event) { // switch (keyCode) { // case KeyEvent.KEYCODE_MENU: // final Intent tag_intent = new Intent(NfcConnecting.this, TagView.class); // // Every tag view activity should be called only once. // tag_intent.addFlags(Intent.<API key>); // startActivity(tag_intent); // break; // default: // break; // return super.onKeyUp(keyCode, event); }
# This file is part of WhatWeb and may be subject to # web site for more information on licensing and terms of use. Plugin.define do name "TangoCMS" authors [ "Brendan Coles <bcoles@gmail.com>", # 2011-07-27 ] version "0.1" description "TangoCMS is an open source (GNU/GPL 2.1) PHP Content Management System (CMS)." website "http://tangocms.org/" # ShodanHQ results as at 2011-07-27 # # 75 for <API key> # Google results as at 2011-07-27 # # 154 for "Powered by TangoCMS" # Dorks # dorks [ '"Powered by TangoCMS"' ] # Matches # matches [ # Powered by text { :regexp=>/Powered by <a href="http:\/\/(www\.)?tangocms\.org" title="(Open Source CMS|TangoCMS)">TangoCMS<\/a>\./ }, # Login input { :text=>'<input type="checkbox" id="sessionRemember" name="session[remember]" value="1" checked="checked"> <label class="horizontal" for="sessionRemember">Remember me?</label>' }, ] # Passive # passive do m=[] # <API key> Cookie # <API key> is the md5 hash for "/" m << { :name=>"<API key> Cookie" } if @headers["set-cookie"] =~ /<API key>=[^;^\s]+;/ # Return passive matches m end end
<?php !defined('IN_HDWIKI') && exit('Access Denied'); class control extends base{ function control(& $get,& $post){ $this->base( & $get,& $post); $this->load("doc"); $this->load("category"); $this->load("user"); $this->load("usergroup"); $this->load("synonym"); $this->load("attachment"); $this->load("comment"); $this->load("innerlink"); $this->load("search"); } function doview() { $this->_anti_copy(); $this->load("reference"); if(!is_numeric(@$this->get[2])){ $this->message($this->view->lang['parameterError'],'index.php',0); } $doc=$this->db->fetch_by_field('doc','did',$this->get[2]); if(!(bool)$doc){ $this->message($this->view->lang['docNotExist'],'index.php',0); }elseif($synonym=$_ENV['synonym']->get_synonym_by_src(addslashes($doc['title']))){ $this->view->assign('synonymdoc',$synonym['srctitle']); $this->get[2]=$synonym['destdid']; $this->doview(); exit; }elseif($doc['visible']=='0' &&!$this->checkable('doc-audit') && $doc['lasteditorid']!= $this->user['uid']){ if($doc['editions']>0){ $doc=$_ENV['doc']->get_lastdoc($this->get[2],$doc['lastedit']); if(!$doc){ $this->message($this->view->lang['viewDocTip4'],'index.php',0); } }else{ $this->message($this->view->lang['viewDocTip4'],'index.php',0); } }elseif(@$this->get[3]=="locked"&&$doc['locked']==1){ $this->view->assign('locked','1'); } $_ENV['doc']->update_field('views',1,$doc['did'],0); $this->view->vars['setting']['seo_keywords']=$doc['tag']; $this->view->vars['setting']['seo_description']=$doc['summary']; $doc['tag']=$_ENV['doc']->spilttags($doc['tag']); $doc['rawtitle']=$doc['title']; $editors=$_ENV['usergroup']->get_userstar( array($doc['authorid'],$doc['lasteditorid']) ); //eval($this->plugin['ucenter']['hooks']['doc_user_image']); UC_OPEN && $_ENV['ucenter']->doc_user_image($editors,$doc); $author=$editors[$doc['author']]; $author?$this->view->assign('author',$author) :$this->view->assign('author_removed',1); if ($doc['lasteditorid'] > 0 && $doc['time'] < $doc['lastedit']){ $lasteditor = $editors[$doc['lasteditor']]; $lasteditor ? $this->view->assign('lasteditor',$lasteditor) :$this->view->assign('lasteditor_removed',1); } $doc['lastedit']=date('Y-m-d',$doc['lastedit']); $navigation= $_ENV['doc']->get_cids_by_did($doc['did']); if(!empty($this->setting['random_open'])){ $this->load('anticopy'); $_ENV['anticopy']->add_randomstr($doc['content']); } $doc['content']=$_ENV['innerlink']->get($doc['did'], $doc['content']); $doc['sectionlist']=$_ENV['doc']->splithtml($doc['content']); $doc['doctitle'] = $doc['title']; $doc['title'] = addslashes($doc['title']); $sectionlist=$_ENV['doc']->getsections($doc['sectionlist']); $editlock['locked']=$_ENV['doc']->iseditlocked($doc['did']); if($editlock['locked']){ $editlock['user']=$this->db->fetch_by_field('user','uid',$editlock['locked']); } //eval($this->plugin['hdapi']['hooks']['uniontitle']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ $this->view->assign("doclink",1); $uniontitle = $_ENV["hdapi"]-><API key>($doc["did"]); $uniontitle = is_array($uniontitle)?$uniontitle["docdeclaration"]:""; $this->view->assign("uniontitle",$uniontitle); } //adv start $this->load('adv'); $categorys=array(); foreach($navigation as $category){ $categorys[]=$category['cid']; } $advlist=$_ENV['adv']->adv_doc_filter($this->advertisement,$categorys); if($advlist){ $this->view->assign('advlist',$advlist); } //adv end if($this->setting['attachment_open']){ $attachment=$_ENV['attachment']->get_attachment('did',$doc['did'],0); $this->view->assign('attachment',$attachment); } $synonyms=$_ENV['synonym']->get_synonym_by_dest('',$doc['title']); $referencelist = ($this->setting['base_isreferences'] === '0')? array() :$_ENV['reference']->getall($doc['did']); $doc['title']=htmlspecialchars(stripslashes($doc['title'])); $doc['doctitle']=$doc['title']; $relatelist = array(); $relatelist = $_ENV['doc']->get_related_doc($doc['did']); if(!count($relatelist)){ if($this->setting['isrelate']){ $relatelist = array_unique(explode(';',$this->setting['relateddoc'])); } } $neighbor=$_ENV['doc']->get_neighbor($this->get[2]); $coin_download = isset($this->setting['coin_download'])?$this->setting['coin_download']:10; //nav $nav = $_ENV['doc']->get_nav($this->get[2]); $this->load('pic'); $pic_list = $_ENV['pic']->get_pic_by_did($this->get[2]); $pic_str = ''; if(!empty($pic_list)){ foreach($pic_list as $v) { $pic_str .= WIKI_URL.'/'.$v['attachment'].'|'; } $pic_str = trim($pic_str, '|'); } $doc['pic_str'] = $pic_str; $doc['qq_title'] = $doc['title'].":".$doc['summary']; $doc['qq_title'] = strip_tags($doc['qq_title']); $doc['qq_title'] = str_replace(array("\r\n", '\r', '\n', '"'), '', $doc['qq_title']); $tem_strlen = string::hstrlen($doc['qq_title']); if(100< $tem_strlen) { $doc['qq_title'] = string::substring($doc['qq_title'], 0, 99).'...'; } $this->view->assign('docletter',$doc['letter']); $this->view->assign('neighbor',$neighbor); $this->view->assign('relatelist',$relatelist); $this->view->assign('userid',$this->user['uid']); $this->view->assign('groupid',$this->user['groupid']); $this->view->assign('synonyms',$synonyms); $this->view->assign('doc',$doc); $this->view->assign("attachment_type", implode("|",$_ENV['attachment']->get_attachment_type())); $this->view->assign('reference_add',$this->checkable('reference-add')); $this->view->assign('attach_download',$this->checkable('attachment-download')); $this->view->assign('audit', ($this->checkable('admin_doc-audit') || $this->checkable('doc-audit'))); $this->view->assign('relate', ($this->checkable('doc-getrelateddoc') && $this->checkable('doc-addrelatedoc'))); $this->view->assign('synonym_audit',$this->checkable('synonym-savesynonym')); $this->view->assign('attachment_upload',$this->checkable('attachment-upload')); $this->view->assign('attachment_remove',$this->checkable('attachment-remove')); $this->view->assign('comment_add',$this->checkable('comment-add')); $this->view->assign('doc_edit',$this->checkable('doc-edit')); $this->view->assign('doc_editletter',$this->checkable('doc-editletter')); $this->view->assign('navtitle',$doc['doctitle'].'-'); $this->view->assign("searchtext",$doc['title']); $this->view->assign('editlock',$editlock); $this->view->assign('sectionlist',$sectionlist); $this->view->assign('navigation',$navigation); $this->view->assign("referencelist", $referencelist); $this->view->assign("coin", $this->user['credit1']); $this->view->assign("coin_download", $coin_download); $this->view->assign("nav", $nav); //$this->view->display('viewdoc'); $_ENV['block']->view('viewdoc'); } function docreate(){ if(4 != $this->user['groupid'] && ($this->time-$this->user['regtime'] < $this->setting['forbidden_edit_time']*60)){ $this->message($this->view->lang['editTimeLimit1'].$this->setting['forbidden_edit_time'].$this->view->lang['editTimeLimit2'],'BACK',0); } if($this->setting['verify_doc'] == -1) { if($this->setting['max_newdocs'] != 0 && $this->user['newdocs'] >= $this->setting['max_newdocs']) { $this->message(',', 'BACK', 0); } } if(!isset($this->post['create_submit'])){ if('0' === $this->user['checkup']){ $this->message($this->view->lang['createDocTip17'],'BACK',0); } if(isset($this->post['title'])){ $this->view->assign('title',htmlspecialchars(stripslashes($this->post['title']))); } if(@is_numeric($this->get[2])){ $category=$_ENV['category']->get_category($this->get[2]); $this->view->assign("category",$category); } $this->view->assign('navtitle',$this->view->lang['createDoc']."-"); $this->view->display('createdoc'); }else if(!isset($this->post['publishsubmit'])){ if(trim($this->post['title'])=="" ){ $this->message($this->view->lang['createDocTip1'],'BACK',0); } if($synonym=$_ENV['synonym']->get_synonym_by_src($this->post['title'])){ $this->view->assign('synonymdoc',$synonym['srctitle']); $this->get[2]=$synonym['destdid']; $this->doview(); exit; } if($_ENV['doc']->have_danger_word($this->post['title'])){ $this->message($this->view->lang['docHaveDanerWord'],'BACK',0); } if(!(bool)$_ENV['category']->vilid_category($this->post['category'])){ $this->message($this->view->lang['categoryNotExist'],'BACK',0); } $title=string::substring(string::stripscript($_ENV['doc']->replace_danger_word(trim($this->post['title']))),0,80); if(!(bool)$title){ $this->message($this->view->lang['createDocTip16'],'BACK',0); } $data=$this->db->fetch_by_field('doc','title',$title); if((bool)$data){ $this->header('doc-view-'.$data['did']); } $doc['title']=htmlspecialchars($title); $doc['cid']=$this->post['category']; $doc['did']=$_ENV['doc']->add_doc_placeholder($doc); $this->view->assign("savetime",60000); $this->view->assign("filter_external",$this->setting['filter_external']); //eval($this->plugin['hdapi']['hooks']['readcontent']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ if($_ENV["hdapi"]->islock($doc["title"])){ $doc["locked"]=1; $this->message("","BACK",0); }else{ $_ENV["hdapi"]->lock($doc["title"]); $content=$_ENV["hdapi"]->get_content($doc["title"]); if(is_string($content) && !empty($content)){$doc["content"]=$content;} } } $this->view->assign('navtitle',"$title-".$this->view->lang['createDoc']."-"); $this->view->assign("page_action","create"); $this->view->assign("attachment_open",$this->setting['attachment_open']); //$this->view->assign("attachment_type","['".implode("','",$_ENV['attachment']->get_attachment_type())."']"); $this->view->assign('attachment_size',$this->setting['attachment_size']); $doc['title']=stripcslashes($doc['title']); eval($this->plugin['doctemplate']['hooks']['doctemplate']); $this->view->assign('doc',$doc); $this->view->assign("<API key>", ($this->setting['checkcode']!=3 && $this->setting['<API key>'])); $this->view->assign('g_img_big',$this->setting['img_width_big']); $this->view->assign('g_img_small',$this->setting['img_width_small']); //$this->view->display('editor'); $_ENV['block']->view('editor'); }else{ if($this->setting['checkcode']!=3 && $this->setting['<API key>'] && strtolower($this->post['code'])!=$_ENV['user']->get_code()){ $this->message($this->view->lang['codeError'],'BACK',0); } if(@trim($this->post['content'])==''||@trim($this->post['title'])==''){ $this->message($this->view->lang['contentIsNull'],'BACK',0); } $doc['title']=string::substring(string::stripscript($_ENV['doc']->replace_danger_word(trim($this->post['title']))),0,80); $_doc=$this->db->fetch_by_field('doc','title',$doc['title']); if((bool)$_doc && !empty($_doc['content'])){ $this->message($this->view->lang['createDocTip5'],'BACK',0); } if(!(bool)$_ENV['category']->vilid_category($this->post['category'])){ $this->message($this->view->lang['categoryNotExist'],'BACK',0); } if(@!(bool)$this->post['summary']){ $doc['summary']=trim(strip_tags($_ENV['doc']->replace_danger_word($this->post['summary']))); } $doc['did']=$this->post['did']; $doc['letter']=string::getfirstletter($this->post['title']); $doc['category']=$this->post['category']; //$doc['tags']=$_ENV['doc']->jointags($this->post['tags']); $doc['tags']=$this->post['tags']; $doc['tags']=$_ENV['doc']->replace_danger_word($doc['tags']); $doc['content']=string::stripscript($_ENV['doc']->replace_danger_word($this->post['content'])); $doc['content']= $this->setting['auto_picture']?$_ENV['doc']->auto_picture($doc['content'],$doc['did']):$doc['content']; $doc['summary']=trim(strip_tags($_ENV['doc']->replace_danger_word($this->post['summary']))); $doc['summary']=(bool)$doc['summary']?$doc['summary']:$doc['content']; $doc['summary']=trim(string::convercharacter(string::substring(strip_tags($doc['summary']),0,100))); $doc['images']=util::getimagesnum($doc['content']); $doc['time']=$this->time; $doc['words']=string::hstrlen($doc['content']); $doc['visible']=$this->setting['verify_doc'] != 0 ? '0' : '1'; if(strpos($this->user['regulars'], 'doc-immunity') === false && 4 != $this->user['groupid']) { if(!$_ENV['doc']-><API key>($this->user['uid'])) { if($this->setting['save_spam']) { $doc['visible'] = 0; } else { $this->message(sprintf($this->view->lang['submit_interval_msg'], $this->setting['submit_min_interval']),"BACK",0); } } if(!$_ENV['doc']->check_eng_pcnt($doc['content']) || !$_ENV['doc']->check_extlink_pcnt($doc['content'])) { if($this->setting['save_spam']) { $doc['visible'] = 0; } else { $this->message($this->view->lang['spam_msg'],"BACK",0); } } } if(strpos($this->user['regulars'], 'doc-immunity') !== false || 4 == $this->user['groupid'] || !$this->setting['verify_doc'] || ($this->setting['verify_doc'] == -1 && $this->user['newdocs'] == -1)){ $doc['visible'] = 1; } if($this->setting['verify_doc'] == -1) { if($this->user['newdocs'] != -1) { $_ENV['user']->update_newdocs($this->user['uid'], +1); } } if($doc['visible'] == 1){ $_ENV['user']->add_credit($this->user['uid'],'doc-create',$this->setting['credit_create'],$this->setting['coin_create']); } /*foreach($this->post['tags'] as $search_tags){ $doc['search_tags'] .=string::convert_to_unicode($search_tags).";"; }*/ $did=$_ENV['doc']->add_doc($doc); $_ENV['user']->update_field('creates',$this->user['creates']+1,$this->user['uid']); //$_ENV['category']-><API key>($this->post['category']); //,doc.class.php->add_doc_placeholder()->add_doc_category() //$message=$_ENV['attachment']->upload_attachment($did); $_ENV['innerlink']->update($doc['title'], $did); $_ENV['doc']->unset_editlock($doc['did'],$this->user['uid']); $this->load('noticemail'); $_ENV['noticemail']->doc_create($doc); //eval($this->plugin["ucenter"]["hooks"]["create_feed"]); UC_OPEN && $_ENV['ucenter']->create_feed($doc,$did); //eval($this->plugin['hdapi']['hooks']['postcontent']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ $_ENV["hdapi"]->post_content($doc["title"],$doc["content"]); } if(1 == $this->setting['cloud_search'] && 1 == $doc['visible'] ) { $_ENV['search']->cloud_change(array('dids'=>$did,'mode'=>'1')); } if((bool)$message){ $this->message($message,$this->setting['seo_prefix']."doc-view-".$did.$this->setting['seo_suffix'],0); }else{ $msg=$this->view->lang['docPublishSuccess']; if($this->setting['<API key>']){$msg.="<script>$.get('index.php?<API key>-'+$did);</script>";} $this->message($msg, $this->setting['seo_prefix']."doc-view-".$did.$this->setting['seo_suffix'], 0); } } } function doverify(){ $ajaxtitle=trim($this->post['title']); if (WIKI_CHARSET == 'GBK'){$ajaxtitle = string::hiconv($ajaxtitle);} $title=string::substring(string::stripscript($ajaxtitle),0,80); if($_ENV['doc']->have_danger_word($title)){ $this->message("-1","",2); } if($ajaxtitle!=string::stripscript($ajaxtitle)){ $this->message("-2","",2); } if($synonym=$_ENV['synonym']->get_synonym_by_src($ajaxtitle)){ $this->message($synonym[destdid]." ".$synonym[desttitle],"",2); } $data=$this->db->fetch_by_field('doc','title',$title); if(!(bool)$data){ $this->message("1","",2); }else{ $this->message("0","",2); } } function doedit(){ $this->_anti_copy(); if(isset($this->post['predoctitle'])){ $title = $this->post['predoctitle']; $content=string::stripscript($_ENV['doc']->replace_danger_word($this->post['content'])); $this->view->assign("content",stripslashes($content)); $this->view->assign("title",$title); //$this->view->display("previewdoc"); $_ENV['block']->view('previewdoc'); return; } if(isset($this->post['tagtext'])){ $tags = $this->post['tagtext']; if(string::hstrtoupper(WIKI_CHARSET)=='GBK'){ $tags=string::hiconv($tags,'gbk','utf-8'); } $tags = trim(strip_tags($_ENV['doc']->replace_danger_word($tags))); $did = $this->post['did']; if(!is_numeric($did)){ exit($this->view->lang['parameterError']); } $_ENV['doc']->update_field('tag',$tags,$did); echo 'OK'; return; } if('0' === $this->user['checkup']){ $this->message($this->view->lang['createDocTip17'],'BACK',0); } if(4 != $this->user['groupid'] && ($this->time-$this->user['regtime'] < $this->setting['forbidden_edit_time']*60)){ $this->message($this->view->lang['editTimeLimit1'].$this->setting['forbidden_edit_time'].$this->view->lang['editTimeLimit2'],'BACK',0); } @$did=isset($this->get[2])?$this->get[2]:$this->post['did']; if(!is_numeric($did)){ $this->message($this->view->lang['parameterError'],'index.php',0); } $doc=$this->db->fetch_by_field('doc','did',$did); if(!(bool)$doc){ $this->message($this->view->lang['docNotExist'],'index.php',0); } if($doc['visible']=='0'&&!$this->checkable('doc-audit') && $doc['lasteditorid']!= $this->user['uid']){ $this->message($this->view->lang['viewDocTip4'],'index.php',0); } $increase_edition = true; if($this->setting['verify_doc'] == -1) { if($this->user['newdocs'] != -1) { if(!$_ENV['doc']->user_edited($this->user['uid'], $doc['did'])) { if($this->setting['max_newdocs'] != 0 && $this->user['newdocs'] >= $this->setting['max_newdocs']) { $this->message(',', 'BACK', 0); } } else { $increase_edition = false; } } } if(!isset($this->post['publishsubmit'])){ $this->load("reference"); $editlockuid=$_ENV['doc']->iseditlocked($did); if($editlockuid!=0&&$editlockuid!=$this->user['uid']){ $this->message($this->view->lang['viewDocTip5'].$this->view->lang['viewDocTip6'],'BACK',0); } //eval($this->plugin['hdapi']['hooks']['readcontent']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ if($_ENV["hdapi"]->islock($doc["title"])){ $doc["locked"]=1; $this->message("","BACK",0); }else{ $_ENV["hdapi"]->lock($doc["title"]); $content=$_ENV["hdapi"]->get_content($doc["title"]); if(is_string($content) && !empty($content)){$doc["content"]=$content;} } } if($doc['locked']){ $this->header("doc-view-".$doc['did']."-locked"); } $this->view->assign("savetime",60000); $ramus=isset($this->get[3])?$this->get[3]:''; $autosave=$_ENV['doc']->is_autosave($this->user['uid'],$doc['did']); if((bool)$autosave){ $doc['content']=$autosave['content']; $doc['autosavetime']=$this->date($autosave['time']); } $referencelist = $_ENV['reference']->getall($doc['did']); //$doc['tag']=$_ENV['doc']->spilttags($doc['tag']); //$attachment=$_ENV['attachment']->get_attachment('did',$doc['did'],0); //$this->view->assign('attachment',$attachment); $this->view->assign('navtitle',$doc['title'].'-'.$this->view->lang['editDoc'].'-'); $this->view->assign("page_action","edit"); //$this->view->assign("attachment_power",$this->checkable('attachment-remove')); //$this->view->assign("attachment_type","['".implode("','",$_ENV['attachment']->get_attachment_type())."']"); $this->view->assign("filter_external",$this->setting['filter_external']); $doc = str_replace("&", "&amp;", $doc); $doc['title']=htmlspecialchars(stripslashes($doc['title'])); $this->view->assign("doc",$doc); $this->view->assign("referencelist", $referencelist); $this->view->assign("<API key>", ($this->setting['checkcode']!=3 && $this->setting['<API key>'])); $this->view->assign('g_img_big',$this->setting['img_width_big']); $this->view->assign('g_img_small',$this->setting['img_width_small']); //$this->view->display("editor"); $_ENV['block']->view('editor'); }else{ if($this->setting['checkcode']!=3 && $this->setting['<API key>'] && strtolower($this->post['code'])!=$_ENV['user']->get_code()){ $this->message($this->view->lang['codeError'],'BACK',0); } if(trim($this->post['content'])==""){ $this->message($this->view->lang['contentIsNull'],'BACK',0); } //$doc['tags']=$_ENV['doc']->jointags($this->post['tags']); $doc['tags']=$this->post['tags']; $doc['tags']=$_ENV['doc']->replace_danger_word($doc['tags']); $doc['content']=string::stripscript($_ENV['doc']->replace_danger_word($this->post['content'])); $doc['content']= $this->setting['auto_picture']?$_ENV['doc']->auto_picture($doc['content'], $did):$doc['content']; $doc['summary']=trim(strip_tags($_ENV['doc']->replace_danger_word($this->post['summary']))); $doc['summary']=(bool)$doc['summary']?$doc['summary']:$doc['content']; $doc['summary'] =trim(string::convercharacter(string::substring(strip_tags($doc['summary']),0,100))); $doc['time']=$this->time; $doc['reason']=htmlspecialchars(trim(implode(',',$this->post['editreason'])," \t\n,")); /*foreach($this->post['tags'] as $search_tags){ $doc['search_tags'] .=string::convert_to_unicode($search_tags).";"; }*/ if (0 == $doc['visible'] && $this->user['uid'] == $doc['lasteditorid'] && $this->user['type'] == 2){ if(!$this->setting['save_spam']) { if (!$_ENV['doc']-><API key>($this->user['uid'])) { $this->message(sprintf($this->view->lang['submit_interval_msg'], $this->setting['submit_min_interval']),"BACK",0); } if(!$_ENV['doc']->check_eng_pcnt($doc['content']) || !$_ENV['doc']->check_extlink_pcnt($doc['content'])) { $this->message($this->view->lang['spam_msg'],"BACK",0); } } $_ENV['doc']->edit_unaudit_doc($doc); $_ENV['doc']->unset_editlock($doc['did'],$this->user['uid']); if( $this->setting['verify_doc'] == -1 && $this->user['newdocs'] != -1 && $increase_edition) { $_ENV['user']->update_newdocs($this->user['uid'], +1); //newdocs +1 } $this->message($this->view->lang['docPublishSuccess'],$this->setting['seo_prefix']."doc-view-".$doc['did'].$this->setting['seo_suffix'],0); } if( strpos($this->user['regulars'], 'doc-audit') !== false || strpos($this->user['regulars'], 'doc-immunity') !== false || (empty($this->user['regulars']) && $this->user['type'] == 1) || ($this->setting['verify_doc'] == -1 && $this->user['newdocs'] == -1) ){ $doc['visible'] = 1; }else{ $doc['visible']=$this->setting['verify_doc']?'0':'1'; if(!$_ENV['doc']-><API key>($this->user['uid'])) { if($this->setting['save_spam']) { $doc['visible'] = 0; } else { $this->message(sprintf($this->view->lang['submit_interval_msg'], $this->setting['submit_min_interval']),"BACK",0); } } if(!$_ENV['doc']->check_eng_pcnt($doc['content']) || !$_ENV['doc']->check_extlink_pcnt($doc['content'])) { if($this->setting['save_spam']) { $doc['visible'] = 0; } else { $this->message($this->view->lang['spam_msg'],"BACK",0); } } } if( $this->setting['verify_doc'] == -1 && $this->user['newdocs'] != -1 && $increase_edition) { $_ENV['user']->update_newdocs($this->user['uid'], +1); //newdocs +1 } $_ENV['doc']->edit_doc($doc,"1", $increase_edition); $_ENV['doc']->unset_editlock($doc['did'],$this->user['uid']); if($doc['visible']==1 && $_ENV['doc']->is_addcredit($doc['did'],$this->user['uid'])){ $_ENV['user']->add_credit($this->user['uid'],'doc-edit',$this->setting['credit_edit'],$this->setting['coin_edit']); } $_ENV['user']->update_field('edits',$this->user['edits']+1,$this->user['uid']); $_ENV['doc']->del_autosave('',$this->user['uid'],$doc['did']); /* $_ENV['attachment']->update_desc($this->post['attachment_id'],$this->post['attachment_desc']); if($this->checkable('attachment-remove')){ $attachmentlist=$_ENV['attachment']->get_attachment('did',$doc['did'],0); for($i=0;$i<count($attachmentlist);$i++){ if($attachmentlist[$i]['isimage']=="0"&&!in_array($attachmentlist[$i]['id'],(array)$this->post['attachment_id'])){ @unlink($attachmentlist[$i]['attachment']); $remove_attachid[]=$attachmentlist[$i]['id']; } } $_ENV['attachment']->remove($remove_attachid); } $message=$_ENV['attachment']->upload_attachment($doc['did']); */ $this->load('noticemail'); $_ENV['noticemail']->doc_edit($doc); //eval($this->plugin["ucenter"]["hooks"]["edit_feed"]); UC_OPEN && $_ENV['ucenter']->edit_feed($doc); //eval($this->plugin['hdapi']['hooks']['postcontent']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ $_ENV["hdapi"]->post_content($doc["title"],$doc["content"]); } if(1 == $this->setting['cloud_search']) { $_ENV['search']->cloud_change(array('dids'=>$did,'mode'=>'2')); } if((bool)$message){ $this->message($message,$this->setting['seo_prefix']."doc-view-".$doc['did'].$this->setting['seo_suffix'],0); }else{ $msg=$this->view->lang['docPublishSuccess']; if($this->setting['<API key>']){$msg.="<script>$.get('index.php?<API key>-'+$did);</script>";} $this->message($msg, $this->setting['seo_prefix']."doc-view-".$doc['did'].$this->setting['seo_suffix'],0); } } } function doeditsection(){ $this->_anti_copy(); if(4 != $this->user['groupid'] && ($this->time-$this->user['regtime'] < $this->setting['forbidden_edit_time']*60)){ $this->message($this->view->lang['editTimeLimit1'].$this->setting['forbidden_edit_time'].$this->view->lang['editTimeLimit2'],'BACK',0); } if('0' === $this->user['checkup']){ $this->message($this->view->lang['createDocTip17'],'BACK',0); } @$did=isset($this->get[2])?$this->get[2]:$this->post['did']; @$id=isset($this->get[3])?$this->get[3]:$this->post['section_id']; if(!is_numeric($did)||!is_numeric($id)){ $this->message($this->view->lang['parameterError'],'index.php',0); } $doc=$this->db->fetch_by_field('doc','did',$did); //eval($this->plugin['hdapi']['hooks']['readcontent']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ if($_ENV["hdapi"]->islock($doc["title"])){ $doc["locked"]=1; $this->message("","BACK",0); }else{ $_ENV["hdapi"]->lock($doc["title"]); $content=$_ENV["hdapi"]->get_content($doc["title"]); if(is_string($content) && !empty($content)){$doc["content"]=$content;} } } if(!(bool)$doc){ $this->message($this->view->lang['docNotExist'],'index.php',0); } if($doc['visible']=='0'&&!$this->checkable('admin_doc-audit')){ $this->message($this->view->lang['viewDocTip4'],'index.php',0); } if(!isset($this->post['publishsubmit'])){ $editlockuid=$_ENV['doc']->iseditlocked($did); if($editlockuid!=0&&$editlockuid!=$this->user['uid']){ $this->message($this->view->lang['viewDocTip5'].$this->view->lang['viewDocTip6'],'BACK',0); } if($doc['locked']){ $this->header("doc-view-".$doc['did']."-locked"); } $array_section=$_ENV['doc']->splithtml($doc['content']); if(!isset($array_section[$id+1]['value'])){ $this->header('doc-edit-'.$did); } //$doc['tag']=$_ENV['doc']->spilttags($doc['tag']); $doc['content']=$array_section[$id+1]['value']; $this->view->assign("savetime",60000); $ramus=isset($this->get[4])?$this->get[4]:''; $autosave=$_ENV['doc']->is_autosave($this->user['uid'],$doc['did']); if((bool)$autosave){ if($ramus){ $doc['content']=$autosave['content']; }else{ $autosave['content']=str_replace(array("\r\n","\r","\n"),"",addslashes($autosave['content'])); $autosave['showtime']=$this->date($autosave['time']); $this->view->assign("autosave",$autosave); } } $doc['content']= $this->setting['auto_picture']?$_ENV['doc']->auto_picture($doc['content'],$did):$doc['content']; $doc['title']=$doc['title']."-".$array_section[$id]['value']; $doc['section_id']=$id; $this->view->assign('navtitle',$doc['title'].'-'.$this->view->lang['editionEdit'].'-'); $this->view->assign("page_action","editsection"); $doc = str_replace("&", "&amp;", $doc); $doc['title']=htmlspecialchars(stripslashes($doc['title'])); $this->view->assign("doc",$doc); $this->view->assign("<API key>", ($this->setting['checkcode']!=3 && $this->setting['<API key>'])); $this->view->assign('g_img_big',$this->setting['img_width_big']); $this->view->assign('g_img_small',$this->setting['img_width_small']); //$this->view->display("editor"); $_ENV['block']->view('editor'); }else{ if($this->setting['checkcode']!=3 && $this->setting['<API key>'] && strtolower($this->post['code'])!=$_ENV['user']->get_code()){ $this->message($this->view->lang['codeError'],'BACK',0); } if(trim($this->post['content'])==""){ $this->message($this->view->lang['contentIsNull'],'BACK',0); } $tem=$_ENV['doc']->splithtml($doc['content']); $tem[$id+1]['value']=$_ENV['doc']->replace_danger_word(stripcslashes($this->post['content'])); $doc['content']=string::haddslashes(string::stripscript($_ENV['doc']->joinhtml($tem)),1); //$doc['tags']=$_ENV['doc']->jointags($this->post['tags']); $doc['tags']=$this->post['tags']; $doc['tags']=$_ENV['doc']->replace_danger_word($doc['tags']); $doc['summary']=trim(strip_tags($_ENV['doc']->replace_danger_word($this->post['summary']))); $doc['summary']=(bool)$doc['summary']?$doc['summary']:$doc['content']; $doc['summary'] =trim(string::convercharacter(string::substring(strip_tags($doc['summary']),0,100))); $doc['images']=util::getimagesnum($doc['content']); $doc['time']=$this->time; $doc['visible']=$this->setting['verify_doc']?'0':'1'; $doc['words']=string::hstrlen($doc['content']); $doc['reason']=htmlspecialchars(trim(implode(',',$this->post['editreason']),' \t\n,')); /*foreach($this->post['tags'] as $search_tags){ $doc['search_tags'] .=string::convert_to_unicode($search_tags).";"; } */ if(!$_ENV['doc']-><API key>($this->user['uid'])) { if($this->setting['save_spam']) { $doc['visible'] = 0; } else { $this->message(sprintf($this->view->lang['submit_interval_msg'], $this->setting['submit_min_interval']),"BACK",0); } } if(!$_ENV['doc']->check_eng_pcnt($doc['content']) || !$_ENV['doc']->check_extlink_pcnt($doc['content'])) { if($this->setting['save_spam']) { $doc['visible'] = 0; } else { $this->message($this->view->lang['spam_msg'],"BACK",0); } } $_ENV['doc']->edit_doc($doc,"2"); $_ENV['doc']->unset_editlock($doc['did'],$this->user['uid']); if($doc['visible']==1 && $_ENV['doc']->is_addcredit($doc['did'],$this->user['uid'])){ $_ENV['user']->add_credit($this->user['uid'],'doc-edit',$this->setting['credit_edit'],$this->setting['coin_edit']); } $_ENV['user']->update_field('edits',$this->user['edits']+1,$this->user['uid']); $_ENV['doc']->del_autosave('',$this->user['uid'],$doc['did']); $this->load('noticemail'); $_ENV['noticemail']->doc_edit($doc); //eval($this->plugin['hdapi']['hooks']['postcontent']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ $_ENV["hdapi"]->post_content($doc["title"],$doc["content"]); } //#clode# if(1 == $this->setting['cloud_search']) { $_ENV['search']->cloud_change(array('dids'=>$did,'mode'=>'2')); } $msg=$this->view->lang['docPublishSuccess']; if($this->setting['<API key>']){$msg.="<script>$.get('index.php?<API key>-'+$did);</script>";} $this->message($msg, $this->setting['seo_prefix']."doc-view-".$doc['did'].$this->setting['seo_suffix'],0); } } function dorefresheditlock(){ $_ENV['doc']->refresheditlock($this->get[2],$this->user['uid']); //eval($this->plugin['hdapi']['hooks']['refreshlock']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ $tmp = $_ENV["hdapi"]->get_doc_title_by_id(intval($this->get[2])); $title = $tmp["title"]; $_ENV["hdapi"]->refresh_lock($title); } } function dounseteditlock(){ $did = $this->get[2]; $action = $this->get[3]; $_ENV['doc']->unset_editlock($did, $this->user['uid']); if ($action == 'create'){ $_ENV['doc']->uncreate($did); $this->header('doc-create'); }else{ //eval($this->plugin['hdapi']['hooks']['unlockdoc']); $this->load("hdapi"); if($this->setting['site_nick'] && $this->setting["hdapi_bklm"]){ $tmp = $_ENV["hdapi"]->get_doc_title_by_id(intval($this->get[2])); $title = $tmp["title"]; $_ENV["hdapi"]->un_lock($title); } $this->header("doc-view-".$this->get[2]); } } function doinnerlink(){ $len=strlen('doc-innerlink-'); $title=str_replace("+",urlencode("+"),substr($_SERVER['QUERY_STRING'],$len)); $title=string::haddslashes(string::hiconv(trim(urldecode($title))),1); if($this->setting['seo_suffix']){ $title=str_replace($this->setting['seo_suffix'],'',$title); } $doc=$this->db->fetch_by_field('doc','title',$title); $this->view->assign("docrewrite","1"); if(!(bool)$doc){ $doc=$_ENV['synonym']->get_synonym_by_src($title); if($doc){ $this->view->assign('synonymdoc',$doc['srctitle']); $this->get[2]=$doc['destdid']; $this->doview(); exit; }else{ $this->view->assign("search_tip_switch", $this->setting['search_tip_switch']); $this->view->assign("searchtext",stripslashes($title)); $this->view->assign("searchword",urlencode(string::hiconv($title,'utf-8'))); $this->view->assign("title",$title); $this->view->display("notexist"); } }else{ $this->get[2]=$doc['did']; $this->doview(); } } function dosummary(){ $count=count($this->get); @$title=$this->get[2]; for($i=3;$i<$count;$i++){ $title .='-'.$this->get[$i]; } $title=trim($title); $title2 = $title; $title=urldecode($title); if(string::hstrtoupper(WIKI_CHARSET)=='GBK'){ $title=string::hiconv($title,$to='gbk',$from='utf-8'); } $doc=$this->db->fetch_by_field('doc','title',addslashes($title)); if((bool)$doc){ $doc['image']=util::getfirstimg($doc['content']); $doc['url']=WIKI_URL."/".$this->setting['seo_prefix']."doc-view-".$doc['did'].$this->setting['seo_suffix']; $doc_exists=1; }else{ $url = 'http: $data = util::hfopen($url); $doc_exists=1; if($data && stripos($data,'<flag>true</flag>') && preg_match_all("/<\!\[CDATA\[(.*)\]\]>/", $data, $matches)){ $summary = $matches[1][1]; $image = $matches[1][2]; if ($summary == 'null') $summary = ''; if ($image == 'null') $image = ''; $doc = array( 'image'=>$image, 'url'=>'http: 'summary'=>$summary ); }else{ $doc_exists=0; } } $this->view->assign("doc_exists",$doc_exists); $this->view->assign("doc",$doc); $this->view->assign("encode",WIKI_CHARSET); $this->view->assign("title",$title); //$this->view->display('hdmomo'); $_ENV['block']->view('hdmomo'); } function dosandbox(){ $did = $this->setting['sandbox_id']; $maxid = $_ENV['doc']->get_maxid(); if (!is_numeric($did) || $did < 1 || $did > $maxid){ $did = $maxid; } if($did){ $this->header('doc-edit-'.$did); }else{ $this->message($this->view->lang['sandboxTip1'],'index.php',0); } } function dosetfocus(){ if(@!is_numeric($this->post['did']) || @!is_numeric($this->post['doctype'])){ $this->message("-1","",2); }elseif(@$this->post['visible']!="1"){ $this->message("-2","",2); }elseif($_ENV['doc']->set_focus_doc(array($this->post['did']),$this->post['doctype'])){ $this->cache->removecache('data_'.$GLOBALS['theme'].'_index'); $this->message("1","",2); }else{ $this->message("0","",2); } } function doremovefocus(){ if(@!is_numeric($this->post['did'])){ $this->message("-1","",2); }elseif(@$this->post['visible']!="1"){ $this->message("-2","",2); }elseif($_ENV['doc']->remove_focus(array($this->post['did']))){ $this->cache->removecache('data_'.$GLOBALS['theme'].'_index'); $this->message("1","",2); }else{ $this->message("0","",2); } } function dogetcategroytree(){ $all_category=$_ENV['category']->get_category_cache(); $categorytree=$_ENV['category']->get_categrory_tree($all_category); $this->message($categorytree,"",2); } function dochangename(){ $ajaxtitle = trim($this->post['newname']); if(string::hstrtoupper(WIKI_CHARSET)=='GBK'){ $ajaxtitle=string::hiconv($ajaxtitle,'gbk','utf-8','true'); } $title=string::substring(string::stripscript($_ENV['doc']->replace_danger_word(trim($ajaxtitle))),0,80); if(@!is_numeric($this->post['did'])){ $this->message("-1","",2); }elseif($ajaxtitle!=string::stripscript($ajaxtitle)){ $this->message("-3","",2); }elseif(!$title){ $this->message("-4","",2); }elseif(@(bool)$this->db->fetch_by_field('doc','title',$title)){ $this->message("-2","",2); }elseif($_ENV['doc']->change_name($this->post['did'],$title)){ $_ENV['synonym']->synonym_change_doc($this->post['did'],$title); if(1 == $this->setting['cloud_search']) { $_ENV['search']->cloud_change(array('dids'=>$this->post['did'],'mode'=>'2')); } $this->message("1","",2); }else{ $this->message("0","",2); } } function dochangecategory(){ if(@is_numeric($this->post['did'])&&$_ENV['category']->vilid_category($this->post['newcategory'])){ if($_ENV['doc']->change_category($this->post['did'],$this->post['newcategory'])){ $categorys = $_ENV['category']->get_category($this->post['newcategory'], 2); foreach($categorys as $category){ @$result .="<a href=\"".$this->setting['seo_prefix']."category-view-{$category['cid']}".$this->setting['seo_suffix']."\" > {$category['name']} </a>&nbsp;&nbsp;"; } $this->message($result,"",2); } }else{ $this->message("0","",2); } } function dolock(){ if(@is_numeric($this->post['did'])&&(bool)$_ENV['doc']->lock(array($this->post['did']))){ $this->message("1","",2); }else{ $this->message("0","",2); } } function dounlock(){ if(@is_numeric($this->post['did'])&&(bool)$_ENV['doc']->lock( array($this->post['did']),0)){ $this->message("1","",2); }else{ $this->message("0","",2); } } function doaudit(){ if(@is_numeric($this->post['did'])&&(bool)$_ENV['doc']->audit_doc(array($this->post['did']))){ $this->message("1","",2); }else{ $this->message("0","",2); } } function doremove(){ if(@!is_numeric($this->get[2])){ $this->message($this->view->lang['parameterError'],'BACK',0); }else{ $_ENV['doc']->remove_doc(array($this->get[2])); if(1 == $this->setting['cloud_search']) { $_ENV['search']->cloud_change(array('dids'=>$this->get[2],'mode'=>'0')); } $this->header("list"); } } function dorandom(){ $did=$_ENV['doc']->get_random(); if(0==$did){ $this->header(); }else{ $this->header('doc-view-'.$did); } } function dovote(){ if(@is_numeric($this->post['did'])){ $did=$this->post['did']; $uid=$this->user['uid']; @$hdvote = $this->hgetcookie("vote_{$uid}_{$did}"); if(!isset($hdvote)){ $_ENV['doc']->update_field('votes',1,$did,0); $this->hsetcookie("vote_{$uid}_{$did}", $did); $this->message('1','',2); } } $this->message('0','',2); } function doautosave(){ $did=isset($this->get[2])?$this->get[2]:$this->post['did']; $id=isset($this->post['id'])?$this->post['id']:-1; $notfirst=isset($this->post['notfirst'])?$this->post['notfirst']:0; $savecontent=isset($this->post['savecontent'])?$this->post['savecontent']:''; if (WIKI_CHARSET == 'GBK'){$savecontent = string::hiconv($savecontent);} if($savecontent!==''){ $_ENV['doc']->update_autosave($this->user['uid'],$did,$savecontent,$id,$notfirst); } $this->message('sucess','',2); } function dodelsave(){ $aid=isset($this->get[2])?$this->get[2]:''; if(empty($aid)){ $aid=$this->post['checkid']; $num=count($aid); if($num>0){ $aids=''; for($i=0;$i<$num;$i++){ $aids.=$aid[$i].','; } $aids=substr($aids,0,-1); $_ENV['doc']->del_autosave($aids); $this->message($this->view->lang['saveDelSucess'],'index.php?doc-managesave',0); }else{ $did=isset($this->post['did'])?$this->post['did']:''; if(is_numeric($did)){ $_ENV['doc']->del_autosave('',$this->user['uid'],$did); }else{ $this->message('fail','',2); } } }else{ $_ENV['doc']->del_autosave($aid); } $this->message('sucess','',2); } function domanagesave(){ $page = max(1, intval($this->get[2])); $num = isset($this->setting['list_prepage'])?$this->setting['list_prepage']:20; $start_limit = ($page - 1) * $num; $count=$_ENV['doc']->get_autosave_number($this->user['uid']); $savelist=$_ENV['doc']->get_autosave_by_uid($this->user['uid'],$start_limit,$num); $departstr=$this->multi($count, $num, $page,"doc-managesave"); $this->view->assign('departstr',$departstr); $this->view->assign('savelist',$savelist); $this->view->assign('count',$count); $this->view->display('managesave'); } function dogetrelateddoc(){ $did = trim($this->post['did']); $relateddoc=$_ENV['doc']->get_related_doc($did); $doclist = json_encode($relateddoc); $this->message($doclist,"",2); } function doaddrelatedoc(){ $did = trim($this->post['did']); if(is_numeric($did)){ $relate = trim($this->post['relatename']); $title = htmlspecialchars(trim($this->post['title'])); if(string::hstrtoupper(WIKI_CHARSET)=='GBK'){ $relate=string::hiconv($relate,'gbk','utf-8'); $title=string::hiconv($title,'gbk','utf-8'); } $list=array(); if($relate){ $list = array_unique(explode(';',$relate)); foreach($list as $key => $relatename){ $relatename = htmlspecialchars($relatename); if($_ENV['doc']->have_danger_word($relatename)){ unset($list[$key]); $this->message("2","",2); } } } $_ENV['doc']->add_relate_title($did,$title,$list); $this->message("1","",2); } } function docooperate(){ $coopdoc = array(); $cooperatedocs = explode(';',$this->setting['cooperatedoc']); $counts = count($cooperatedocs); for($i=0;$i<$counts;$i++){ if($cooperatedocs[$i]==''){ unset($cooperatedocs[$i]); }else{ $coopdoc[$i]['shorttitle'] = (string::hstrlen($cooperatedocs[$i])>4)?string::substring($cooperatedocs[$i],0,4)."...":$cooperatedocs[$i]; $coopdoc[$i]['title'] = $cooperatedocs[$i]; } } $this->view->assign('coopdoc',$coopdoc); //$this->view->display('cooperate'); $_ENV['block']->view('cooperate'); } function hdgetcat(){ $evaljs = ''; $did=intval($this->post['did']); $cats = $_ENV['doc']->get_cids_by_did($did); if($cats){ foreach($cats as $cat){ $cat['name'] = string::haddslashes($cat['name'],1); $evaljs .= "catevalue.scids.push(".$cat['cid'].");catevalue.scnames.push('".string::haddslashes($cat['name'])."');"; } } $this->message($evaljs,'',2); } function doeditletter(){ $first_letter = trim($this->post['first_letter']); if(preg_match("/^[a-zA-Z]$/i" , $first_letter)){ $did = intval($this->post['did']); $doc=$this->db->fetch_by_field('doc','did',$did,'letter'); if($_ENV['doc']->change_letter($did,$first_letter)){ $this->cache->removecache('list_'.strtolower($first_letter).'_0'); $this->cache->removecache('list_'.strtolower($doc['letter']).'_0'); $this->message("1","",2); } }else{ $this->message("-1","",2); } } function _anti_copy() { if(!empty($this->setting['check_useragent'])) { $this->load('anticopy'); if(!$_ENV['anticopy']->check_useragent()){ $this->message('','',0); } } if(!empty($this->setting['check_visitrate'])) { $this->load('anticopy'); $_ENV['anticopy']->check_visitrate(); } } } ?>
#ifndef ASTNODE_H_ #define ASTNODE_H_ #ifdef __cplusplus extern "C" { #endif #include <antlr3.h> #include <astsymboltypes.h> #ifdef __cplusplus class ASTScope; typedef ASTScope* pASTScope; #else struct ASTScope; typedef struct ASTScope* pASTScope; #endif // Keep in sync with const char* node_type_names[] !!! enum ASTNodeType { nt_undefined = 0, <API key>, <API key>, <API key>, <API key>, nt_and_expression, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, nt_cast_expression, <API key>, <API key>, <API key>, nt_constant_char, <API key>, nt_constant_float, nt_constant_int, nt_constant_string, <API key>, nt_declaration, <API key>, <API key>, nt_declarator, <API key>, <API key>, <API key>, nt_enum_specifier, nt_enumerator, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, nt_init_declarator, nt_initializer, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, nt_lvalue, <API key>, <API key>, <API key>, nt_pointer, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, nt_shift_expression, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, nt_type_id, nt_type_name, nt_type_qualifier, nt_type_specifier, <API key>, <API key>, <API key>, <API key>, <API key>, nt_unary_expression, nt_size }; struct ASTNode; struct ASTNodeList { struct ASTNode* item; struct ASTNodeList* next; }; typedef struct ASTNodeList* pASTNodeList; struct ASTTokenList { <API key> item; struct ASTTokenList* next; }; typedef struct ASTTokenList* pASTTokenList; struct ASTNode { enum ASTNodeType type; struct ASTNode* parent; pASTScope scope; pASTScope childrenScope; <API key> start; <API key> stop; union Children { struct { struct ASTNode* function_definition; struct ASTNode* declaration; struct ASTNode* assembler_statement; } <API key>; struct { struct ASTNode* <API key>; struct ASTNode* declarator; struct ASTNode* compound_statement; } function_definition; struct { ANTLR3_BOOLEAN isTypedef; struct ASTNode* <API key>; struct ASTNodeList* <API key>; } declaration; struct { struct ASTNodeList* <API key>; } <API key>; struct { struct ASTNode* declarator; struct ASTNode* initializer; } init_declarator; struct { <API key> token; } <API key>; struct { struct ASTTokenList* builtin_type_list; struct ASTNode* <API key>; struct ASTNode* <API key>; struct ASTNode* enum_specifier; struct ASTNode* type_id; } type_specifier; struct { struct ASTNode* <API key>; struct ASTNode* <API key>; } <API key>; struct { <API key> identifier; } type_id; struct { struct ASTNode* struct_or_union; <API key> identifier; struct ASTNodeList* <API key>; ANTLR3_BOOLEAN isDefinition; } <API key>; struct { struct ASTNodeList* <API key>; struct ASTNodeList* <API key>; } struct_declaration; struct { struct ASTNode* declarator; struct ASTNode* constant_expression; } struct_declarator; struct { <API key> identifier; struct ASTNodeList* enumerator_list; } enum_specifier; struct { <API key> identifier; struct ASTNode* constant_expression; } enumerator; struct { <API key> token; } type_qualifier; struct { struct ASTNode* pointer; struct ASTNode* direct_declarator; ANTLR3_BOOLEAN isFuncDeclarator; } declarator; struct { <API key> identifier; struct ASTNode* declarator; struct ASTNodeList* <API key>; } direct_declarator; struct { struct ASTNode* constant_expression; struct ASTNode* parameter_type_list; struct ASTTokenList* identifier_list; } declarator_suffix; struct { struct ASTTokenList* type_qualifier_list; struct ASTNode* pointer; } pointer; struct { struct ASTNodeList* parameter_list; ANTLR3_BOOLEAN openArgs; } parameter_type_list; struct { struct ASTNode* <API key>; struct ASTNodeList* declarator_list; } <API key>; struct { struct ASTNodeList* <API key>; struct ASTNode* abstract_declarator; } type_name; struct { struct ASTNode* pointer; struct ASTNode* <API key>; } abstract_declarator; struct { struct ASTNode* abstract_declarator; struct ASTNodeList* <API key>; } <API key>; struct { struct ASTNode* constant_expression; struct ASTNode* parameter_type_list; } <API key>; struct { struct ASTNode* <API key>; struct ASTNodeList* initializer_list; } initializer; struct { struct ASTNode* cast_expression; struct ASTNode* initializer; struct ASTNode* type_name; struct ASTNode* unary_expression; } cast_expression; struct { struct ASTNode* postfix_expression; struct ASTNode* unary_expression; <API key> unary_operator; struct ASTNode* cast_expression; struct ASTNode* builtin_function; } unary_expression; struct { struct ASTNode* unary_expression; struct ASTNode* type_name; } <API key>; struct { struct ASTNode* constant_expression; struct ASTNode* <API key>; struct ASTNode* <API key>; } <API key>; struct { struct ASTNode* unary_expression; } <API key>; struct { struct ASTNode* <API key>; struct ASTNode* constant; } <API key>; struct { struct ASTNode* <API key>; } <API key>; struct { struct ASTNode* <API key>; struct ASTNode* constant; } <API key>; struct { struct ASTNode* type_name; struct ASTNode* postfix_expression; } <API key>; struct { struct ASTNode* <API key>; struct ASTNode* <API key>; struct ASTNode* <API key>; } <API key>; struct { struct ASTNode* constant; } <API key>; struct { struct ASTNode* type_name1; struct ASTNode* type_name2; } <API key>; struct { struct ASTNode* <API key>; struct ASTNode* <API key>; struct ASTNode* type_name; } <API key>; struct { struct ASTNode* unary_expression; struct ASTNode* type_name; } <API key>; struct { struct ASTNode* primary_expression; struct ASTNodeList* <API key>; } postfix_expression; struct { struct ASTNodeList* expression; struct ASTNodeList* <API key>; <API key> identifier; } <API key>; struct { <API key> identifier; struct ASTNode* constant; struct ASTNodeList* expression; struct ASTNode* <API key>; } primary_expression; struct { <API key> literal; struct ASTTokenList* string_token_list; } constant; struct { struct ASTNode* <API key>; } constant_expression; struct { struct ASTNode* lvalue; struct ASTNodeList* <API key>; pANTLR3_COMMON_<API key>; struct ASTNode* <API key>; struct ASTNode* initializer; struct ASTNode* <API key>; } <API key>; struct { struct ASTNode* <API key>; struct ASTNode* <API key>; <API key> identifier; } <API key>; struct { struct ASTNode* type_name; struct ASTNode* lvalue; struct ASTNode* unary_expression; } lvalue; struct { struct ASTNode* <API key>; struct ASTNodeList* expression; struct ASTNode* <API key>; } <API key>; struct { <API key> op; struct ASTNode* left; struct ASTNode* right; } binary_expression; struct { <API key> identifier; struct ASTNode* constant_expression; struct ASTNode* <API key>; struct ASTNode* statement; } labeled_statement; struct { struct ASTNodeList* <API key>; } compound_statement; struct { struct ASTNodeList* <API key>; } <API key>; struct { struct ASTNodeList* expression; } <API key>; struct { struct ASTNodeList* expression; struct ASTNode* statement; struct ASTNode* statement_else; } selection_statement; struct { pASTNodeList <API key>; } expression; struct { struct ASTNode* <API key>; struct ASTNode* <API key>; struct ASTNodeList* expression; struct ASTNode* statement; } iteration_statement; struct { struct ASTNode* unary_expression; struct ASTNode* initializer; } jump_statement; struct { struct ASTTokenList* type_qualifier_list; struct ASTTokenList* instructions; struct ASTNodeList* <API key>; struct ASTNodeList* <API key>; } assembler_statement; struct { <API key> alias; struct ASTTokenList* constraint_list; struct ASTNode* <API key>; } assembler_parameter; } u; }; typedef struct ASTNode* pASTNode; const char* <API key>(const struct ASTNode* node); const char* <API key>(int type); #ifdef __cplusplus } #endif #endif /* ASTNODE_H_ */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Random glossary entry block &mdash; mooclms 2.6.1 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var <API key> = { URL_ROOT: './', VERSION: '2.6.1', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="mooclms 2.6.1 documentation" href="index.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li><a href="index.html">mooclms 2.6.1 documentation</a> &raquo;</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="<API key>"> <span id="id1"></span><h1>Random glossary entry block<a class="headerlink" href=" <p>The random glossary block can be used to display random entries from a glossary, which usually take the form of dictionary style definitions. However the flexibility of Moodle&#8217;s HTML editor allow users to adapt this block for other purposes such as &#8216;Quote of the Day&#8217; or a random picture gallery that changes each time the page is refreshed.</p> <p>Before using the random glossary entry block you have to configure it using the edit icon. There you will have a number of fields to complete.</p> <img alt="_images/<API key>.png" src="_images/<API key>.png" /> <div class="section" id="title"> <h2>Title<a class="headerlink" href=" <p>Here you will write the title of that block. The default is Random Glossary Entry.</p> </div> <div class="section" id="<API key>"> <h2>Take entries from this glossary<a class="headerlink" href=" <p>This allows you to choose from which glossary the entries in this block will be chosen.</p> <p>Global glossaries are also available, (thus allowing a glossary from a course to be displayed in a block on the front page for example)</p> </div> <div class="section" id="<API key>"> <h2>Days before a new entry is chosen<a class="headerlink" href=" <p>This sets the number of days for how long that a given entry is displayed. If set to &#8220;0,&#8221; a new entry displays every time the page is refreshed.</p> </div> <div class="section" id="<API key>"> <h2>How a new entry is chosen<a class="headerlink" href=" <p>You have four options: <em>Last modified entry</em> will always display the entry that was last modified, and <em>Random entry</em> will choose a new one at random every time. The option <em>Next entry</em> will cycle through the entries in order. This option is especially useful when a number of days is also chosen, allowing you to make a Quote of the week or a Tip of the day that everyone sees.</p> <p><em>Alphabetical</em> will display the entries in strict alphabetical order.</p> </div> <div class="section" id="<API key>"> <h2>Show concept (heading) for each entry<a class="headerlink" href=" <p>Enabling that option will show headings for each entry that appears in the block.</p> </div> <div class="section" id="links"> <h2>Links<a class="headerlink" href=" <p>You can display links to actions of the glossary this block is associated with. The block will only display links to actions which are enabled for that glossary. You can type texts to appear for whichever of the three options: <em>Users can add entries to the glossary</em>, <em>Users can view the glossary but not add entries</em> or <em>Users cannot edit or view the glossary</em>.</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="<API key>"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Random glossary entry block</a><ul> <li><a class="reference internal" href="#title">Title</a></li> <li><a class="reference internal" href="#<API key>">Take entries from this glossary</a></li> <li><a class="reference internal" href="#<API key>">Days before a new entry is chosen</a></li> <li><a class="reference internal" href="#<API key>">How a new entry is chosen</a></li> <li><a class="reference internal" href="#<API key>">Show concept (heading) for each entry</a></li> <li><a class="reference internal" href="#links">Links</a></li> </ul> </li> </ul> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/<API key>.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li><a href="index.html">mooclms 2.6.1 documentation</a> &raquo;</li> </ul> </div> <div class="footer"> &copy; Copyright 2014, Sakshi. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.1. </div> </body> </html>
package wusc.edu.pay.service.test; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.<API key>; import org.springframework.test.context.junit4.<API key>; import wusc.edu.pay.common.enums.BankAccountTypeEnum; import wusc.edu.pay.facade.remit.entity.<API key>; import wusc.edu.pay.facade.remit.entity.SettlRequestParam; import wusc.edu.pay.facade.remit.enums.TradeSourcesEnum; import wusc.edu.pay.facade.remit.exceptions.RemitBizException; import wusc.edu.pay.facade.remit.service.RemitRequestFacade; @RunWith(<API key>.class) @<API key>(locations={"classpath:spring/spring-context.xml"}) public class TsLocalRemitTs { @Autowired private RemitRequestFacade remitRequestFacade; /** * * @throws RemitBizException * @throws SQLException * @since 1.0 */ @Test public void testRemitRequest() throws RemitBizException, SQLException{ <API key> pb = new <API key>(); List<SettlRequestParam> settReqeustList = new ArrayList(); pb.setTotalAmount(50d); pb.setTotalNum(1); for(int i = 0 ; i < 1 ; i++){ SettlRequestParam testMerchant = new SettlRequestParam(); testMerchant.setTradeSource(TradeSourcesEnum.MEMBER_CASH.getValue()); testMerchant.setTradeType(TradeSourcesEnum.MEMBER_CASH.getValue()); testMerchant.setRequestNo(System.currentTimeMillis()+"") ; testMerchant.setIsUrgent(1) ; testMerchant.setBankAccountName("2200003220"); testMerchant.setBankAccountNo("600033029"); testMerchant.setBankName(""); testMerchant.setBankChannelNo("102659000491"); testMerchant.setAmount(50d); testMerchant.setUserNo("888000000000000"); testMerchant.setAccountNo("<API key>"); testMerchant.setProvince(""); testMerchant.setCity(""); testMerchant.setBankAccountType(BankAccountTypeEnum.PUBLIC_ACCOUNTS.getValue()); settReqeustList.add(testMerchant); } pb.setSettReqeustList(settReqeustList); //remitRequestFacade.<API key>(pb); } }
#! /bin/bash _cryptotools_opts () { local cur prev opts COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD - 1]} CIPHERS="caesar-shift affine-shift vigenere keyword" case "$prev" in "ciphers") COMPREPLY=($(compgen -W "-d $CIPHERS" -- $cur)) ;; "-d") COMPREPLY=($(compgen -W "$CIPHERS" -- $cur)) ;; "analysis") COMPREPLY=($(compgen -W "<API key> <API key> vigenere-cracker column-analysis" -- $cur)) ;; *) COMPREPLY=($(compgen -W "ciphers analysis -i -f -h --help" -- $cur)) ;; esac; return 0; } DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) alias ct="python $DIR/ct.py" complete -F _cryptotools_opts ct
/* * * fdlist.c maintain lists of certain important fds * * * */ #include "fdlist.h" #include "client.h" /* struct Client */ #include "ircd.h" /* GlobalSetOptions */ #include "s_bsd.h" /* highest_fd */ #include "config.h" /* option settings */ #include "umodes.h" #include <string.h> #include <assert.h> unsigned char GlobalFDList[MAXCONNECTIONS + 1]; void fdlist_init(void) { static int initialized = 0; assert(0 == initialized); if (!initialized) { memset(GlobalFDList, 0, sizeof(GlobalFDList)); initialized = 1; } } void fdlist_add(int fd, unsigned char mask) { assert(fd < MAXCONNECTIONS + 1); GlobalFDList[fd] |= mask; } void fdlist_delete(int fd, unsigned char mask) { assert(fd < MAXCONNECTIONS + 1); GlobalFDList[fd] &= ~mask; } #ifndef NO_PRIORITY #ifdef CLIENT_SERVER #define BUSY_CLIENT(x) \ (((x)->priority < 55) || (!GlobalSetOptions.lifesux && ((x)->priority < 75))) #else #define BUSY_CLIENT(x) \ (((x)->priority < 40) || (!GlobalSetOptions.lifesux && ((x)->priority < 60))) #endif #define FDLISTCHKFREQ 2 /* * This is a pretty expensive routine -- it loops through * all the fd's, and finds the active clients (and servers * and opers) and places them on the "busy client" list */ void fdlist_check(time_t now) { struct Client* cptr; int i; for (i = 0; i < MAXCONNECTIONS; i++) { if (!(cptr = local[i])) continue; if (IsAlwaysBusy(cptr)) GlobalFDList[i] |= FDL_BUSY; if (IsServer(cptr) || IsAlwaysBusy(cptr)) continue; GlobalFDList[i] &= ~FDL_BUSY; if (cptr->receiveM == cptr->lastrecvM) { cptr->priority += 2; /* lower a bit */ if (90 < cptr->priority) cptr->priority = 90; else if (BUSY_CLIENT(cptr)) { GlobalFDList[i] |= FDL_BUSY; } continue; } else { cptr->lastrecvM = cptr->receiveM; cptr->priority -= 30; /* active client */ if (cptr->priority < 0) { cptr->priority = 0; GlobalFDList[i] |= FDL_BUSY; } else if (BUSY_CLIENT(cptr)) { GlobalFDList[i] |= FDL_BUSY; } } } } #endif
#include <fstream> CPoint GetDesktopSize(void); void PrintTimeStamp(std::ofstream stream); CString TimeStampString();
# SMPanes Panes and widgets for displaying information (e.g. messages and sensor data) on a SmartMatrix-based display
package org.cnv.shr.sync; import java.io.IOException; import java.net.<API key>; import java.util.Iterator; import org.cnv.shr.db.h2.DbPaths2; import org.cnv.shr.mdl.PathElement; import org.cnv.shr.mdl.RemoteDirectory; import org.cnv.shr.mdl.RemoteFile; import org.cnv.shr.mdl.SharedFile; import org.cnv.shr.msg.PathList; import org.cnv.shr.msg.PathListChild; import org.cnv.shr.util.<API key>; public class RemoteFileSource implements FileSource { private <API key> sync; private PathElement pathElement; private RemoteFile remoteFile; public RemoteFileSource(RemoteDirectory r, <API key> queue) throws <API key>, IOException { this.sync = queue; this.pathElement = DbPaths2.getRoot(r); } private RemoteFileSource(<API key> s, RemoteFile f) { sync = s; remoteFile = f; pathElement = f.getPath(); } private RemoteFileSource(<API key> s, PathElement p, String name, boolean directory) { sync = s; pathElement = DbPaths2.addPathTo(p.getRoot(), p, name, directory); } <API key> getQueue() { return sync; } public String toString() { return pathElement.getFullPath(); } @Override public boolean stillExists() { // We have no way of checking... return true; } @Override public FileSourceIterator listFiles() throws IOException, <API key> { if (remoteFile != null) { return FileSource.NULL_ITERATOR; } PathList directoryList = sync.getDirectoryList(pathElement); if (directoryList == null) { return FileSource.NULL_ITERATOR; } final Iterator<String> subDirs = directoryList.getSubDirs().iterator(); final Iterator<PathListChild> children = directoryList.getChildren().iterator(); return new FileSourceIterator() { boolean onFiles; // really means off files... @Override public boolean hasNext() { if (children.hasNext()) { return true; } onFiles = true; return subDirs.hasNext(); } @Override public RemoteFileSource next() { if (onFiles) { return new RemoteFileSource(sync, pathElement, subDirs.next(), false); } return new RemoteFileSource(sync, children.next().create()); } @Override public void remove() {} @Override public void close() throws IOException {} }; } @Override public String getName() { return pathElement.getUnbrokenName(); } @Override public boolean isDirectory() { return remoteFile == null; } @Override public boolean isFile() { return remoteFile != null; } @Override public String getCanonicalPath() { return pathElement.getFullPath(); } @Override public long getFileSize() { return remoteFile.getFileSize(); } @Override public SharedFile create(PathElement element) throws IOException, <API key> { return remoteFile; } }
package com.ihaoxue.library.imagezoom.utils; import java.io.IOException; import android.content.<API key>; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.media.ExifInterface; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore.Images; public class ExifUtils { public static final String[] EXIF_TAGS = { "FNumber", ExifInterface.TAG_DATETIME, "ExposureTime", ExifInterface.TAG_FLASH, ExifInterface.TAG_FOCAL_LENGTH, "GPSAltitude", "GPSAltitudeRef", ExifInterface.TAG_GPS_DATESTAMP, ExifInterface.TAG_GPS_LATITUDE, ExifInterface.<API key>, ExifInterface.TAG_GPS_LONGITUDE, ExifInterface.<API key>, ExifInterface.<API key>, ExifInterface.TAG_GPS_TIMESTAMP, ExifInterface.TAG_IMAGE_LENGTH, ExifInterface.TAG_IMAGE_WIDTH, "ISOSpeedRatings", ExifInterface.TAG_MAKE, ExifInterface.TAG_MODEL, ExifInterface.TAG_WHITE_BALANCE, }; /** * Return the rotation of the passed image file * * @param filepath * image absolute file path * @return image orientation */ public static int getExifOrientation( final String filepath ) { if ( null == filepath ) return 0; ExifInterface exif = null; try { exif = new ExifInterface( filepath ); } catch ( IOException e ) { return 0; } return getExifOrientation( exif ); } public static int getExifOrientation( final ExifInterface exif ) { int degree = 0; if ( exif != null ) { final int orientation = exif.getAttributeInt( ExifInterface.TAG_ORIENTATION, -1 ); if ( orientation != -1 ) { switch ( orientation ) { case ExifInterface.<API key>: degree = 90; break; case ExifInterface.<API key>: degree = 180; break; case ExifInterface.<API key>: degree = 270; break; } } } return degree; } /** * Load the exif tags into the passed Bundle * * @param filepath * @param out * @return true if exif tags are loaded correctly */ public static boolean loadAttributes( final String filepath, Bundle out ) { ExifInterface e; try { e = new ExifInterface( filepath ); } catch ( IOException e1 ) { e1.printStackTrace(); return false; } for ( String tag : EXIF_TAGS ) { out.putString( tag, e.getAttribute( tag ) ); } return true; } /** * Store the exif attributes in the passed image file using the TAGS stored in the passed bundle * * @param filepath * @param bundle * @return true if success */ public static boolean saveAttributes( final String filepath, Bundle bundle ) { ExifInterface exif; try { exif = new ExifInterface( filepath ); } catch ( IOException e ) { e.printStackTrace(); return false; } for ( String tag : EXIF_TAGS ) { if ( bundle.containsKey( tag ) ) { exif.setAttribute( tag, bundle.getString( tag ) ); } } try { exif.saveAttributes(); } catch ( IOException e ) { e.printStackTrace(); return false; } return true; } /** * Return the string representation of the given orientation * * @param orientation * @return */ public static String getExifOrientation( int orientation ) { switch ( orientation ) { case 0: return String.valueOf( ExifInterface.ORIENTATION_NORMAL ); case 90: return String.valueOf( ExifInterface.<API key> ); case 180: return String.valueOf( ExifInterface.<API key> ); case 270: return String.valueOf( ExifInterface.<API key> ); default: throw new AssertionError( "invalid: " + orientation ); } } /** * Try to get the exif orientation of the passed image uri * * @param context * @param uri * @return */ public static int getExifOrientation( Context context, Uri uri ) { final String scheme = uri.getScheme(); <API key> provider = null; if ( scheme == null || ContentResolver.SCHEME_FILE.equals( scheme ) ) { return getExifOrientation( uri.getPath() ); } else if ( scheme.equals( ContentResolver.SCHEME_CONTENT ) ) { try { provider = context.getContentResolver().<API key>( uri ); } catch ( SecurityException e ) { return 0; } if ( provider != null ) { Cursor result; try { result = provider.query( uri, new String[] { Images.ImageColumns.ORIENTATION, Images.ImageColumns.DATA }, null, null, null ); } catch ( Exception e ) { e.printStackTrace(); return 0; } if ( result == null ) { return 0; } int <API key> = result.getColumnIndex( Images.ImageColumns.ORIENTATION ); int dataColumnIndex = result.getColumnIndex( Images.ImageColumns.DATA ); try { if ( result.getCount() > 0 ) { result.moveToFirst(); int rotation = 0; if ( <API key> > -1 ) { rotation = result.getInt( <API key> ); } if ( dataColumnIndex > -1 ) { String path = result.getString( dataColumnIndex ); rotation |= getExifOrientation( path ); } return rotation; } } finally { result.close(); } } } return 0; } }
<?php namespace AmapBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * PointLivraison */ class PointLivraison { /** * @var integer */ private $id; /** * @var string */ private $adresse; /** * @var string */ private $nomPointLivraison; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set adresse * * @param string $adresse * @return PointLivraison */ public function setAdresse($adresse) { $this->adresse = $adresse; return $this; } /** * Get adresse * * @return string */ public function getAdresse() { return $this->adresse; } /** * Set nomPointLivraison * * @param string $nomPointLivraison * @return PointLivraison */ public function <API key>($nomPointLivraison) { $this->nomPointLivraison = $nomPointLivraison; return $this; } /** * Get nomPointLivraison * * @return string */ public function <API key>() { return $this->nomPointLivraison; } }
using OpenTK.Audio.OpenAL; using System; using System.IO; namespace bucklespring.net { public class WavData : IDisposable { public Int32 Channels { get; private set; } public Int32 BitsPerSample { get; private set; } public Int32 SampleRate { get; private set; } public Byte[] SoundData { get; private set; } public ALFormat SoundFormat { get { switch (Channels) { case 1: return BitsPerSample == 8 ? ALFormat.Mono8 : ALFormat.Mono16; case 2: return BitsPerSample == 8 ? ALFormat.Stereo8 : ALFormat.Stereo16; default: throw new <API key>("The specified sound format is not supported."); } } } public WavData(String fileName) { Load(fileName); } private void Load(String fileName) { Stream stream = File.Open(fileName, FileMode.Open); if (stream == null) throw new <API key>("Invalid file"); using (BinaryReader reader = new BinaryReader(stream)) { // Parse RIFF header String signature = new String(reader.ReadChars(4)); if (signature != "RIFF") throw new <API key>("Not a wav file"); reader.ReadInt32(); // Riff Chunk Size String format = new String(reader.ReadChars(4)); if (format != "WAVE") throw new <API key>("Not a wav file"); // WAVE header String formatSignature = new String(reader.ReadChars(4)); if (formatSignature != "fmt ") throw new <API key>("Wav format not supported"); reader.ReadInt32(); // Format chunk size reader.ReadInt16(); // Audio format Channels = reader.ReadInt16(); SampleRate = reader.ReadInt32(); reader.ReadInt32(); // byte rate reader.ReadInt16(); // block align BitsPerSample = reader.ReadInt16(); string dataSignature = new string(reader.ReadChars(4)); if (dataSignature != "data") throw new <API key>("Wav has unexpected signature"); reader.ReadInt32(); //Data chunk size SoundData = reader.ReadBytes((Int32)reader.BaseStream.Length); } } public void Dispose() { SoundData = null; } } }
#include "globals.h" elength_t psy_align(linesize_t linepos_start); elength_t psy_binclude(linesize_t linepos_start); elength_t psy_dsb(linesize_t linepos_start); elength_t psy_regsize(linesize_t linepos_start, int reg); elength_t psy_cpu(linesize_t linepos_start); elength_t readData(linesize_t linepos_start, TERMSIZE maxSize, bool lPetMode); elength_t psy_debug(void); bool PetMode; const psyopc_s psyopc[24] = { { "db", 2, PSY_DB }, { "dw", 2, PSY_DW }, { "dt", 2, PSY_TEXT }, { "dp", 2, PSY_PET }, { "ds", 2, PSY_SCR }, { "setpet", 6, PSY_SETPET }, { "setscr", 6, PSY_SETSCR }, { "dsb", 3, PSY_DSB }, { "align", 5, PSY_ALIGN }, { "(", 1, PSY_BLOCKSTART }, { ")", 1, PSY_BLOCKEND }, { "binclude", 8, PSY_BINCLUDE }, { "segment", 7, PSY_SEGMENT }, { "pseudopc", 8, PSY_PSEUDOPC }, { "realpc", 6, PSY_REALPC }, { "asize", 5, PSY_ASIZE }, { "xysize", 6, PSY_XYSIZE }, { "cpu", 3, PSY_CPU }, { "debugcmd", 8, PSY_DEBUGCMD }, /* some aliases */ { "byte", 4, PSY_DB }, { "word", 4, PSY_DW }, { "text", 4, PSY_TEXT }, { "pet", 3, PSY_PET }, { "scr", 3, PSY_SCR } }; /* Set Pet/Screen Mode to the default */ void reset_TextMode(void) { PetMode = true; } elength_t pass_psyopc(void) { lineelement_t *lelem; elength_t elength = { true, { true, 0 }}; VARIABLE datavar; linesize_t linepos_start; localdepth_t newindex; seglistsize_t segidx; char *cstr; length_t undefSegmentLength = { false, 0 }; linepos_start = pp_getPos(); if( (lelem=(lineelement_t*)pp_get())==NULL ) return elength; switch( lelem->data.psyopc ) { case PSY_DSB: elength = psy_dsb(linepos_start); break; case PSY_DB: elength = readData(linepos_start, TS_1BYTE, PetMode); break; case PSY_DW: elength = readData(linepos_start, TS_2BYTE, PetMode); break; case PSY_ALIGN: elength = psy_align(linepos_start); break; case PSY_TEXT: elength = readData(linepos_start, TS_nBYTE, PetMode); break; case PSY_PET: elength = readData(linepos_start, TS_nBYTE, true); break; case PSY_SCR: elength = readData(linepos_start, TS_nBYTE, false); break; case PSY_SETPET: lelem->typ = LE_SETCODE; lelem->data.code = PetMode = true; elength.err = false; break; case PSY_SETSCR: lelem->typ = LE_SETCODE; lelem->data.code = PetMode = false; elength.err = false; break; case PSY_BLOCKSTART: pp_delItems(linepos_start, pp_getPos()); if( (newindex=localDive())==(localdepth_t)-1 ) return elength; lelem->typ=LE_LOCALBLOCK; lelem->data.blockidx=newindex; elength.err = false; break; case PSY_BLOCKEND: pp_delItems(linepos_start, pp_getPos()); if( (newindex=localUp())==(localdepth_t)-1 ) { error(<API key>); return elength; } lelem->typ=LE_LOCALBLOCK; lelem->data.blockidx=newindex; elength.err = false; break; case PSY_BINCLUDE: elength = psy_binclude(linepos_start); break; case PSY_SEGMENT: if( !read_term(TS_STRING,&datavar, false) ) { error(EM_NoSegmentName); return elength; } if( !datavar.defined ) { /* no undef segments yet */ error(<API key>); return elength; } if( (segidx=segment_findSegment(datavar.valt.value.str))==((seglistsize_t)-1) ) { /* no unknown segments yet */ if( (cstr=string2cstr(datavar.valt.value.str))!=NULL ) { error(EM_UndefSegment_s, cstr); free(cstr); } else { error(EM_UndefSegment_s, "?"); } free(datavar.valt.value.str); return elength; } free(datavar.valt.value.str); pp_delItems(linepos_start, pp_getPos()); lelem->typ = LE_SEGMENTENTER; lelem->data.segmentidx = segidx; <API key>(segidx); elength.err = false; break; case PSY_PSEUDOPC: if( !read_term(TS_2BYTE,&datavar, false) ) { error(<API key>); return elength; } if( datavar.defined ) { pp_delItems(linepos_start, pp_getPos()); lelem->typ = LE_PHASE; lelem->data.phasepc = datavar.valt.value.num; elength.err = !segment_phase( datavar.valt.value.num ); } else { /* var not defined -> enter new phase and undefine pc */ elength.err = !segment_phase(0); segment_addLength(undefSegmentLength); } break; case PSY_REALPC: pp_delItems(linepos_start, pp_getPos()); lelem->typ = LE_DEPHASE; elength.err = !segment_dephase(); break; case PSY_ASIZE: elength = psy_regsize(linepos_start, 0); break; case PSY_XYSIZE: elength = psy_regsize(linepos_start, 1); break; case PSY_CPU: elength = psy_cpu(linepos_start); break; case PSY_DEBUGCMD: elength = psy_debug(); break; }; return elength; } elength_t psy_align(linesize_t linepos_start) { elength_t elength = { true, { true, 0 }}; VARIABLE align_mask, dsb_byte; lineelement_t *lelem; linesize_t linepos_end; lineelement_t nlelem; uint16_t dsb_len; /* set default byte for fill */ dsb_byte.valt.typ = VALTYP_NUM; dsb_byte.defined = true; dsb_byte.valt.value.num = 0; dsb_len = 0; if( !read_term(TS_2BYTE,&align_mask, false) ) { error(EM_AlignWithoutArg); return elength; } lelem = (lineelement_t*)pp_peek(); if( lelem==NULL ) { return elength; } if( lelem->typ==LE_OPERAND && lelem->data.op==OP_Comma ) { if( !pp_skip() ) return elength; if( !read_term(TS_1BYTE,&dsb_byte, false) ) { error(EM_AlignWithoutArg); return elength; } } linepos_end = pp_getPos(); if( align_mask.defined && dsb_byte.defined && segment_isPCDefined() ) { pp_delItems(linepos_start, linepos_end); if( (dsb_len=segment_getPC()%align_mask.valt.value.num)!=0 ) { dsb_len = align_mask.valt.value.num-dsb_len; nlelem.typ = BE_DSB; nlelem.data.dsb.length = dsb_len; nlelem.data.dsb.fillbyte = dsb_byte.valt.value.num; pp_replaceItem(linepos_start, &nlelem); } } else allBytesResolved = false; elength.len.len = dsb_len; elength.err=false; return elength; } elength_t psy_binclude(linesize_t linepos_start) { elength_t elength = { true, { true, 0 }}; const lineelement_t *lelem2; stringsize_t *filename, *fnameclone; VARIABLE binc_offs = { true, false, true, false, (seglistsize_t)-1, { VALTYP_NUM, 0, { 0 }}}; VARIABLE binc_len = { false, false, false, false, (seglistsize_t)-1, { VALTYP_NUM, 0, { 0 }}}; bool lendef = false; int bincfile; struct stat statbuf; off_t filesize; lineelement_t nlelem; char *cfname; lelem2 = pp_get(); if( lelem2->typ!=LE_STRING ) { error(EM_MissingFilename); return elength; } filename = lelem2->data.str; lelem2 = pp_peek(); if( lelem2==NULL ) { return elength; } if( lelem2->typ==LE_OPERAND && lelem2->data.op==OP_Comma ) { if( !pp_skip() ) { return elength; } if( !read_term(TS_4BYTE,&binc_offs, false) ) { error(EM_NoArgAfterComma); return elength; } lelem2 = pp_peek(); if( lelem2==NULL ) { return elength; } if( lelem2->typ==LE_OPERAND && lelem2->data.op==OP_Comma ) { if( !pp_skip() ) { return elength; } if( !read_term(TS_2BYTE,&binc_len, false) ) { error(EM_NoArgAfterComma); return elength; } lendef=true; } } if( binc_offs.defined && ( !lendef || ( lendef && binc_len.defined ) ) ) { fnameclone = stringClone(filename); pp_delItems(linepos_start, pp_getPos()); if( (cfname=string2cstr(fnameclone))==NULL ) { free(fnameclone); return elength; } /* Open the file for reading */ if( (bincfile=filelist_ropen( fnameclone ))==-1 ) { error(EM_FileNotFound_s, cfname); free( cfname ); free( fnameclone ); return elength; } free( fnameclone ); /* Get Filesize */ if( fstat(bincfile, &statbuf)==0 && S_ISREG(statbuf.st_mode) ) { filesize=statbuf.st_size; } else { error(EM_FileNotFound_s, cfname); free( cfname ); close(bincfile); return elength; } /* Test for valid parameters. */ if( (off_t)binc_offs.valt.value.num>=filesize ) { error(EM_OffsExcFilelen); free( cfname ); close(bincfile); return elength; } if( lendef && (off_t)(binc_offs.valt.value.num+binc_len.valt.value.num)>filesize ) { error(EM_LenExcFilelen); free( cfname ); close(bincfile); return elength; } else if( !lendef && (binc_len.valt.value.num=filesize-binc_offs.valt.value.num)>0x10000 ) { warning(WM_BIncOver64k); binc_len.valt.value.num = 0x10000; } /* Allocate buffer for data and length info */ nlelem.typ = BE_nBYTE; nlelem.data.b_nbyte = (stringsize_t*)malloc(binc_len.valt.value.num+sizeof(stringsize_t)); if( nlelem.data.b_nbyte==NULL ) { systemError(EM_OutOfMemory); free( cfname ); close(bincfile); return elength; } *(nlelem.data.b_nbyte) = binc_len.valt.value.num; /* seek to the desired position */ if( binc_offs.valt.value.num!=0 && lseek(bincfile, binc_offs.valt.value.num, SEEK_SET)==((off_t)-1) ) { error(EM_ReadError_s, cfname); free( cfname ); close(bincfile); free(nlelem.data.b_nbyte); return elength; } /* read in the data */ if( readFile(bincfile, (char*)(nlelem.data.b_nbyte+1), binc_len.valt.value.num)==false ) { error(EM_ReadError_s, cfname); free( cfname ); close(bincfile); free(nlelem.data.b_nbyte); return elength; } pp_replaceItem(linepos_start, &nlelem); close(bincfile); free( cfname ); /* the length is set now */ binc_len.defined = true; } elength.len.defined = binc_len.defined; elength.len.len = binc_len.valt.value.num; elength.err=false; return elength; } elength_t psy_dsb(linesize_t linepos_start) { elength_t elength = { true, { true, 0 }}; VARIABLE dsb_len, dsb_byte; lineelement_t *lelem; linesize_t linepos_end; lineelement_t nlelem; /* set default byte for fill */ dsb_byte.valt.typ = VALTYP_NUM; dsb_byte.defined = true; dsb_byte.valt.value.num = 0; if( !read_term(TS_2BYTE,&dsb_len, false) ) { error(EM_DSBWithoutArg); return elength; } lelem = (lineelement_t*)pp_peek(); if( lelem==NULL ) { return elength; } if( lelem->typ==LE_OPERAND && lelem->data.op==OP_Comma ) { if( !pp_skip() ) return elength; if( !read_term(TS_1BYTE,&dsb_byte, false) ) { error(EM_DSBWithoutArg); return elength; } } linepos_end = pp_getPos(); if( dsb_len.defined && dsb_byte.defined ) { pp_delItems(linepos_start, linepos_end); nlelem.typ = BE_DSB; nlelem.data.dsb.length = dsb_len.valt.value.num; nlelem.data.dsb.fillbyte = dsb_byte.valt.value.num; pp_replaceItem(linepos_start, &nlelem); } else allBytesResolved = false; elength.len.defined = dsb_len.defined; elength.len.len = dsb_len.valt.value.num; elength.err=false; return elength; } /* * Read in Data Elements and translate the Strings with the * CharPage cp. That is a 256 byte array with: * cp[_pc_char_] = _c64_char_ * Of course also other mappings than pc->c64 can be done * with this. */ /* * Sooo for now just scr/pet */ elength_t readData(linesize_t linepos_start, TERMSIZE maxSize, bool lPetMode) { const lineelement_t *lelem; bool neot = true; bool oPetMode; VARIABLE datavar; elength_t elen = { true, { true, 0 }}; oPetMode = PetMode; PetMode = lPetMode; do { /* delete '.text' or ',' */ pp_delItems(linepos_start, pp_getPos()); if( !read_term(maxSize,&datavar, true) ) { error(EM_NoArgAfterComma); PetMode = oPetMode; return elen; } if( datavar.defined ) { switch( datavar.valt.typ ) { case VALTYP_NUM: switch( maxSize ) { case TS_1BYTE: elen.len.len += 1; break; case TS_2BYTE: elen.len.len += 2; break; case TS_3BYTE: elen.len.len += 3; break; case TS_4BYTE: elen.len.len += 4; break; case TS_nBYTE: case TS_FLEX: elen.len.len += datavar.valt.byteSize; break; case TS_RBYTE: case TS_RLBYTE: case TS_STRING: /* should never happen */ assert( false ); }; break; case VALTYP_STR: /* it's a String, set the length */ elen.len.len += *datavar.valt.value.str; break; } deleteVariable( &datavar ); } else { allBytesResolved = false; /* The term is undefined, but for fixed sizes we can get the length */ switch( maxSize ) { case TS_RBYTE: case TS_1BYTE: elen.len.len += 1; break; case TS_RLBYTE: case TS_2BYTE: elen.len.len += 2; break; case TS_3BYTE: elen.len.len += 3; break; case TS_4BYTE: elen.len.len += 4; break; case TS_nBYTE: case TS_FLEX: case TS_STRING: elen.len.defined = false; break; }; } linepos_start = pp_getPos(); lelem = pp_peek(); if( lelem==NULL ) { return elen; } if( lelem->typ==LE_OPERAND && lelem->data.op==OP_Comma ) { if( !pp_skip() ) { PetMode = oPetMode; return elen; } } else neot = false; } while( neot ); PetMode = oPetMode; elen.err = false; return elen; } elength_t psy_regsize(linesize_t linepos_start, int reg) { elength_t elen = { true, { true, 0 }}; VARIABLE datavar; lineelement_t nlelem; /* read in argument */ if( !read_term(TS_1BYTE,&datavar, false) ) { error(<API key>); } /* * the argument must be defined (i.e. no preuse) and * it must be final. Non final vars depend on the pc * in a code segment wthout fixed pc address. */ else if( !datavar.defined || !datavar.final ) { error(<API key>); } /* test argument, must be 8 or 16, 16 is only allowed for 65816 cpus */ else if( datavar.valt.value.num!=8 && datavar.valt.value.num!=16 ) { error(<API key>, datavar.valt.value.num); } else if( datavar.valt.value.num==16 && getCurrentCpu()!=CPUTYPE_65816 ) { error(<API key>, getCurrentCpuName()); } else { pp_delItems(linepos_start, pp_getPos()); nlelem.data.regsize = (uint8_t)datavar.valt.value.num; if( reg==0 ) { nlelem.typ = LE_ASIZE; setRegisterSize_A(nlelem.data.regsize); } else { nlelem.typ = LE_XYSIZE; setRegisterSize_XY(nlelem.data.regsize); } pp_replaceItem(linepos_start, &nlelem); elen.err = false; } return elen; } elength_t psy_cpu(linesize_t linepos_start) { elength_t elen = { true, { true, 0 }}; VARIABLE datavar; lineelement_t nlelem; char *cpuName; CPUTYPE cpuType; /* read in argument */ if( !read_term(TS_STRING,&datavar, false) ) { error(EM_CpuWithoutArg); } /* * the argument must be defined (i.e. no preuse) and * it must be final. Non final vars depend on the pc * in a code segment wthout fixed pc address. */ else if( !datavar.defined || !datavar.final ) { deleteVariable( &datavar ); error(<API key>); } /* convert hstring to cstring (for easy compare) */ else if( (cpuName=string2cstr(datavar.valt.value.str))!=NULL ) { /* compare the cpu name with the known types */ cpuType = getCpuIdx(cpuName); if( cpuType==CPUTYPE_UNKNOWN ) { error(EM_UnknownCpuType_s, cpuName); } else { pp_delItems(linepos_start, pp_getPos()); nlelem.typ = LE_CPUTYPE; nlelem.data.cputype = cpuType; pp_replaceItem(linepos_start, &nlelem); setCpuType(cpuType); elen.err = false; } free(cpuName); deleteVariable( &datavar ); } return elen; } /* * This Command is just for debugging * to execute some code at a special line in a sourcefile */ elength_t psy_debug(void) { elength_t elen = { true, { true, 0 }}; printf("DebugCmd: PC "); if( segment_isPCDefined() ) printf("$%04x\n", segment_getPC() ); else printf("undefined\n"); elen.err = false; return elen; }
ActiveAdmin.register Contato do # See permitted parameters documentation: # permit_params :list, :of, :attributes, :on, :model # permit_params do # permitted = [:permitted, :attributes] # permitted << :other if resource.something? # permitted # end end
//Anything above this #include will be ignored by the compiler #include "qcommon/exe_headers.h" // this include must remain at the top of every CPP file #include "client.h" #include "FxScheduler.h" vec3_t WHITE = {1.0f, 1.0f, 1.0f}; struct SEffectList { CEffect *mEffect; int mKillTime; bool mPortal; }; #define PI 3.14159f SEffectList effectList[MAX_EFFECTS]; SEffectList *nextValidEffect; SFxHelper theFxHelper; int activeFx = 0; int drawnFx; qboolean fxInitialized = qfalse; // FX_Free // Frees all FX bool FX_Free( bool templates ) { for ( int i = 0; i < MAX_EFFECTS; i++ ) { if ( effectList[i].mEffect ) { delete effectList[i].mEffect; } effectList[i].mEffect = 0; } activeFx = 0; theFxScheduler.Clean( templates ); return true; } // FX_Stop // Frees all active FX but leaves the templates void FX_Stop( void ) { for ( int i = 0; i < MAX_EFFECTS; i++ ) { if ( effectList[i].mEffect ) { delete effectList[i].mEffect; } effectList[i].mEffect = 0; } activeFx = 0; theFxScheduler.Clean(false); } // FX_Init // Preps system for use int FX_Init( refdef_t* refdef ) { // FX_Free( true ); if ( fxInitialized == qfalse ) { fxInitialized = qtrue; for ( int i = 0; i < MAX_EFFECTS; i++ ) { effectList[i].mEffect = 0; } } nextValidEffect = &effectList[0]; #ifdef _DEBUG fx_freeze = Cvar_Get("fx_freeze", "0", CVAR_CHEAT); #endif fx_debug = Cvar_Get("fx_debug", "0", CVAR_TEMP); fx_countScale = Cvar_Get("fx_countScale", "1", CVAR_ARCHIVE); fx_nearCull = Cvar_Get("fx_nearCull", "16", CVAR_ARCHIVE); theFxHelper.ReInit(refdef); return true; } void FX_SetRefDef(refdef_t *refdef) { theFxHelper.refdef = refdef; } // FX_FreeMember static void FX_FreeMember( SEffectList *obj ) { obj->mEffect->Die(); delete obj->mEffect; obj->mEffect = 0; // May as well mark this to be used next nextValidEffect = obj; activeFx } // FX_GetValidEffect // Finds an unused effect slot // Note - in the editor, this function may return NULL, indicating that all // effects are being stopped. static SEffectList *FX_GetValidEffect() { if ( nextValidEffect->mEffect == 0 ) { return nextValidEffect; } int i; SEffectList *ef; // Blah..plow through the list till we find something that is currently untainted for ( i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++ ) { if ( ef->mEffect == 0 ) { return ef; } } // report the error. #ifndef FINAL_BUILD theFxHelper.Print( "FX system out of effects\n" ); #endif // Hmmm.. just trashing the first effect in the list is a poor approach FX_FreeMember( &effectList[0] ); // Recursive call return nextValidEffect; } // FX_Add // Adds all fx to the view void FX_Add( bool portal ) { int i; SEffectList *ef; drawnFx = 0; int numFx = activeFx; //but stop when there can't be any more left! for ( i = 0, ef = effectList; i < MAX_EFFECTS && numFx; i++, ef++ ) { if ( ef->mEffect != 0) { --numFx; if (portal != ef->mPortal) { continue; //this one does not render in this scene } // Effect is active if ( theFxHelper.mTime > ef->mKillTime ) { // Clean up old effects, calling any death effects as needed // this flag just has to be cleared otherwise death effects might not happen correctly ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT ); FX_FreeMember( ef ); } else { if ( ef->mEffect->Update() == false ) { // We've been marked for death FX_FreeMember( ef ); continue; } } } } if ( fx_debug->integer && !portal) { theFxHelper.Print( "Active FX: %i\n", activeFx ); theFxHelper.Print( "Drawn FX: %i\n", drawnFx ); theFxHelper.Print( "Scheduled FX: %i\n", theFxScheduler.NumScheduledFx() ); } } // FX_AddPrimitive // Note - in the editor, this function may change *pEffect to NULL, indicating that // all effects are being stopped. extern bool gEffectsInPortal; //from FXScheduler.cpp so i don't have to pass it in on EVERY FX_ADD* void FX_AddPrimitive( CEffect **pEffect, int killTime ) { SEffectList *item = FX_GetValidEffect(); item->mEffect = *pEffect; item->mKillTime = theFxHelper.mTime + killTime; item->mPortal = gEffectsInPortal; //global set in AddScheduledEffects activeFx++; // Stash these in the primitive so it has easy access to the vals (*pEffect)->SetTimeStart( theFxHelper.mTime ); (*pEffect)->SetTimeEnd( theFxHelper.mTime + killTime ); } // FX_AddParticle CParticle *FX_AddParticle( vec3_t org, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, float rotation, float rotationDelta, vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags = 0, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/, CGhoul2Info_v *ghoul2, int entNum, int modelNum, int boltNum ) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding effects when the system is paused return 0; } CParticle *fx = new CParticle; if ( fx ) { if (flags&FX_RELATIVE && ghoul2 != NULL) { fx->SetOrigin1( NULL ); fx->SetOrgOffset( org ); fx->SetBoltinfo( ghoul2, entNum, modelNum, boltNum ); } else { fx->SetOrigin1( org ); } fx->SetOrigin1( org ); fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetVel( vel ); fx->SetAccel( accel ); fx->SetRGBStart( sRGB ); fx->SetRGBEnd( eRGB ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetFlags( flags ); fx->SetShader( shader ); fx->SetRotation( rotation ); fx->SetRotationDelta( rotationDelta ); fx->SetElasticity( elasticity ); fx->SetMin( min ); fx->SetMax( max ); fx->SetDeathFxID( deathID ); fx->SetImpactFxID( impactID ); fx->Init(); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // FX_AddLine CLine *FX_AddLine( vec3_t start, vec3_t end, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, int killTime, qhandle_t shader, int flags = 0, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/, CGhoul2Info_v *ghoul2, int entNum, int modelNum, int boltNum) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding new effects when the system is paused return 0; } CLine *fx = new CLine; if ( fx ) { if (flags&FX_RELATIVE && ghoul2 != NULL) { fx->SetOrigin1( NULL ); fx->SetOrgOffset( start ); //offset from bolt pos fx->SetVel( end ); //vel is the vector offset from bolt+orgOffset fx->SetBoltinfo( ghoul2, entNum, modelNum, boltNum ); } else { fx->SetOrigin1( start ); fx->SetOrigin2( end ); } fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetRGBStart( sRGB ); fx->SetRGBEnd( eRGB ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetShader( shader ); fx->SetFlags( flags ); fx->SetSTScale( 1.0f, 1.0f ); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // FX_AddElectricity CElectricity *FX_AddElectricity( vec3_t start, vec3_t end, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, float chaos, int killTime, qhandle_t shader, int flags = 0, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/, CGhoul2Info_v *ghoul2, int entNum, int modelNum, int boltNum ) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding new effects when the system is paused return 0; } CElectricity *fx = new CElectricity; if ( fx ) { if (flags&FX_RELATIVE && ghoul2 != NULL) { fx->SetOrigin1( NULL ); fx->SetOrgOffset( start );//offset fx->SetVel( end ); //vel is the vector offset from bolt+orgOffset fx->SetBoltinfo( ghoul2, entNum, modelNum, boltNum ); } else { fx->SetOrigin1( start ); fx->SetOrigin2( end ); } fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetRGBStart( sRGB ); fx->SetRGBEnd( eRGB ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetShader( shader ); fx->SetFlags( flags ); fx->SetChaos( chaos ); fx->SetSTScale( 1.0f, 1.0f ); FX_AddPrimitive( (CEffect**)&fx, killTime ); // in the editor, fx may now be NULL? if ( fx ) { fx->Initialize(); } } return fx; } // FX_AddTail CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags = 0, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/, CGhoul2Info_v *ghoul2, int entNum, int modelNum, int boltNum ) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding effects when the system is paused return 0; } CTail *fx = new CTail; if ( fx ) { if (flags&FX_RELATIVE && ghoul2 != NULL) { fx->SetOrigin1( NULL ); fx->SetOrgOffset( org ); fx->SetBoltinfo( ghoul2, entNum, modelNum, boltNum ); } else { fx->SetOrigin1( org ); } fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetVel( vel ); fx->SetAccel( accel ); fx->SetRGBStart( sRGB ); fx->SetRGBEnd( eRGB ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetLengthStart( length1 ); fx->SetLengthEnd( length2 ); if (( flags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_WAVE ) { fx->SetLengthParm( lengthParm * PI * 0.001f ); } else if ( flags & FX_LENGTH_PARM_MASK ) { fx->SetLengthParm( lengthParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetFlags( flags ); fx->SetShader( shader ); fx->SetElasticity( elasticity ); fx->SetMin( min ); fx->SetMax( max ); fx->SetSTScale( 1.0f, 1.0f ); fx->SetDeathFxID( deathID ); fx->SetImpactFxID( impactID ); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // FX_AddCylinder CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, float size1s, float size1e, float size1Parm, float size2s, float size2e, float size2Parm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, int killTime, qhandle_t shader, int flags, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/, CGhoul2Info_v *ghoul2, int entNum, int modelNum, int boltNum, qboolean traceEnd) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding new effects when the system is paused return 0; } CCylinder *fx = new CCylinder; if ( fx ) { if (flags&FX_RELATIVE && ghoul2 != NULL) { fx->SetOrigin1( NULL ); fx->SetOrgOffset( start );//offset fx->SetBoltinfo( ghoul2, entNum, modelNum, boltNum ); } else { fx->SetOrigin1( start ); } fx->SetTraceEnd(traceEnd); fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetOrigin1( start ); fx->SetNormal( normal ); fx->SetRGBStart( rgb1 ); fx->SetRGBEnd( rgb2 ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1s ); fx->SetSizeEnd( size1e ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( size1Parm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( size1Parm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSize2Start( size2s ); fx->SetSize2End( size2e ); if (( flags & FX_SIZE2_PARM_MASK ) == FX_SIZE2_WAVE ) { fx->SetSize2Parm( size2Parm * PI * 0.001f ); } else if ( flags & FX_SIZE2_PARM_MASK ) { fx->SetSize2Parm( size2Parm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetLengthStart( length1 ); fx->SetLengthEnd( length2 ); if (( flags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_WAVE ) { fx->SetLengthParm( lengthParm * PI * 0.001f ); } else if ( flags & FX_LENGTH_PARM_MASK ) { fx->SetLengthParm( lengthParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetShader( shader ); fx->SetFlags( flags ); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // FX_AddEmitter CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, vec3_t angs, vec3_t deltaAngs, vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int emitterID, float density, float variance, int killTime, qhandle_t model, int flags = 0, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/, CGhoul2Info_v *ghoul2, int entNum, int modelNum, int boltNum ) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding effects when the system is paused return 0; } CEmitter *fx = new CEmitter; if ( fx ) { if (flags&FX_RELATIVE && ghoul2 != NULL) { assert(0);//not done // fx->SetBoltinfo( ghoul2, entNum, modelNum, boltNum ); } fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetOrigin1( org ); fx->SetVel( vel ); fx->SetAccel( accel ); fx->SetRGBStart( rgb1 ); fx->SetRGBEnd( rgb2 ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAngles( angs ); fx->SetAngleDelta( deltaAngs ); fx->SetFlags( flags ); fx->SetModel( model ); fx->SetElasticity( elasticity ); fx->SetMin( min ); fx->SetMax( max ); fx->SetDeathFxID( deathID ); fx->SetImpactFxID( impactID ); fx->SetEmitterFxID( emitterID ); fx->SetDensity( density ); fx->SetVariance( variance ); fx->SetOldTime( theFxHelper.mTime ); fx->SetLastOrg( org ); fx->SetLastVel( vel ); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // FX_AddLight CLight *FX_AddLight( vec3_t org, float size1, float size2, float sizeParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, int killTime, int flags = 0, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/, CGhoul2Info_v *ghoul2, int entNum, int modelNum, int boltNum) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding effects when the system is paused return 0; } CLight *fx = new CLight; if ( fx ) { if (flags&FX_RELATIVE && ghoul2 != NULL) { fx->SetOrigin1( NULL ); fx->SetOrgOffset( org );//offset fx->SetBoltinfo( ghoul2, entNum, modelNum, boltNum ); } else { fx->SetOrigin1( org ); } fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetRGBStart( rgb1 ); fx->SetRGBEnd( rgb2 ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetFlags( flags ); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // <API key> COrientedParticle *<API key>( vec3_t org, vec3_t norm, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, float rotation, float rotationDelta, vec3_t min, vec3_t max, float bounce, int deathID, int impactID, int killTime, qhandle_t shader, int flags = 0, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/, CGhoul2Info_v *ghoul2, int entNum, int modelNum, int boltNum ) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding effects when the system is paused return 0; } COrientedParticle *fx = new COrientedParticle; if ( fx ) { if (flags&FX_RELATIVE && ghoul2 != NULL) { fx->SetOrigin1( NULL ); fx->SetOrgOffset( org );//offset fx->SetBoltinfo( ghoul2, entNum, modelNum, boltNum ); } else { fx->SetOrigin1( org ); } fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetOrigin1( org ); fx->SetNormal( norm ); fx->SetVel( vel ); fx->SetAccel( accel ); fx->SetRGBStart( rgb1 ); fx->SetRGBEnd( rgb2 ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetFlags( flags ); fx->SetShader( shader ); fx->SetRotation( rotation ); fx->SetRotationDelta( rotationDelta ); fx->SetElasticity( bounce ); fx->SetMin( min ); fx->SetMax( max ); fx->SetDeathFxID( deathID ); fx->SetImpactFxID( impactID ); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // FX_AddPoly CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts, vec3_t vel, vec3_t accel, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, vec3_t rotationDelta, float bounce, int motionDelay, int killTime, qhandle_t shader, int flags ) { if ( theFxHelper.mFrameTime < 1 || !verts ) { // disallow adding effects when the system is paused or the user doesn't pass in a vert array return 0; } CPoly *fx = new CPoly; if ( fx ) { // Do a cheesy copy of the verts and texture coords into our own structure for ( int i = 0; i < numVerts; i++ ) { VectorCopy( verts[i], fx->mOrg[i] ); Vector2Copy( st[i], fx->mST[i] ); } fx->SetVel( vel ); fx->SetAccel( accel ); fx->SetRGBStart( rgb1 ); fx->SetRGBEnd( rgb2 ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetFlags( flags ); fx->SetShader( shader ); fx->SetRot( rotationDelta ); fx->SetElasticity( bounce ); fx->SetMotionTimeStamp( motionDelay ); fx->SetNumVerts( numVerts ); // Now that we've set our data up, let's process it into a useful format fx->PolyInit(); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // FX_AddFlash CFlash *FX_AddFlash( vec3_t origin, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, int killTime, qhandle_t shader, int flags, EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/ ) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding new effects when the system is paused return 0; } if (!shader) { //yeah..this is bad, I guess, but SP seems to handle it by not drawing the flash, so I will too. assert(shader); return 0; } CFlash *fx = new CFlash; if ( fx ) { fx->SetMatImpactFX(matImpactFX); fx->SetMatImpactParm(fxParm); fx->SetOrigin1( origin ); fx->SetRGBStart( sRGB ); fx->SetRGBEnd( eRGB ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetShader( shader ); fx->SetFlags( flags ); // fx->SetSTScale( 1.0f, 1.0f ); fx->Init(); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; } // FX_AddBezier CBezier *FX_AddBezier( vec3_t start, vec3_t end, vec3_t control1, vec3_t control1Vel, vec3_t control2, vec3_t control2Vel, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, int killTime, qhandle_t shader, int flags ) { if ( theFxHelper.mFrameTime < 1 ) { // disallow adding new effects when the system is paused return 0; } CBezier *fx = new CBezier; if ( fx ) { fx->SetOrigin1( start ); fx->SetOrigin2( end ); fx->SetControlPoints( control1, control2 ); fx->SetControlVel( control1Vel, control2Vel ); fx->SetRGBStart( sRGB ); fx->SetRGBEnd( eRGB ); if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE ) { fx->SetRGBParm( rgbParm * PI * 0.001f ); } else if ( flags & FX_RGB_PARM_MASK ) { // rgbParm should be a value from 0-100.. fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetAlphaStart( alpha1 ); fx->SetAlphaEnd( alpha2 ); if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE ) { fx->SetAlphaParm( alphaParm * PI * 0.001f ); } else if ( flags & FX_ALPHA_PARM_MASK ) { fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetSizeStart( size1 ); fx->SetSizeEnd( size2 ); if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE ) { fx->SetSizeParm( sizeParm * PI * 0.001f ); } else if ( flags & FX_SIZE_PARM_MASK ) { fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime ); } fx->SetShader( shader ); fx->SetFlags( flags ); fx->SetSTScale( 1.0f, 1.0f ); FX_AddPrimitive( (CEffect**)&fx, killTime ); } return fx; }
<?php /** * Set the content width based on the theme's design and stylesheet. * * Used to set the width of images and content. Should be equal to the width the theme * is designed for, generally via the style.css stylesheet. */ if ( ! isset( $content_width ) ) $content_width = 640; /** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */ add_action( 'after_setup_theme', 'twentyten_setup' ); if ( ! function_exists( 'twentyten_setup' ) ): /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which runs * before the init hook. The init hook is too late for some features, such as indicating * support post thumbnails. * * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's * functions.php file. * * @uses add_theme_support() To add support for post thumbnails and automatic feed links. * @uses register_nav_menus() To add support for navigation menus. * @uses <API key>() To add support for a custom background. * @uses add_editor_style() To style the visual editor. * @uses <API key>() For translation/localization support. * @uses <API key>() To add support for a custom header. * @uses <API key>() To register the default custom header images provided with the theme. * @uses <API key>() To set a custom post thumbnail size. * * @since Twenty Ten 1.0 */ function twentyten_setup() { // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); // Add default posts and comments RSS feed links to head add_theme_support( '<API key>' ); // Make theme available for translation // Translations can be filed in the /languages/ directory <API key>( 'twentyten', TEMPLATEPATH . '/languages' ); $locale = get_locale(); $locale_file = TEMPLATEPATH . "/languages/$locale.php"; if ( is_readable( $locale_file ) ) require_once( $locale_file ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => __( 'Primary Navigation', 'twentyten' ), ) ); // This theme allows users to set a custom background <API key>(); // Your changeable header business starts here if ( ! defined( 'HEADER_TEXTCOLOR' ) ) define( 'HEADER_TEXTCOLOR', '' ); // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI. if ( ! defined( 'HEADER_IMAGE' ) ) define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' ); // The height and width of your custom header. You can hook into the theme's own filters to change these values. // Add a filter to <API key> and <API key> to change these values. define( 'HEADER_IMAGE_WIDTH', apply_filters( '<API key>', 940 ) ); define( 'HEADER_IMAGE_HEIGHT', apply_filters( '<API key>', 198 ) ); // We'll be using post thumbnails for custom header images on posts and pages. // We want them to be 940 pixels wide by 198 pixels tall. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. <API key>( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Don't support text inside the header image. if ( ! defined( 'NO_HEADER_TEXT' ) ) define( 'NO_HEADER_TEXT', true ); // Add a way for the custom header to be styled in the admin panel that controls // custom headers. See <API key>(), below. <API key>( '', '<API key>' ); // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. <API key>( array( 'berries' => array( 'url' => '%s/images/headers/berries.jpg', 'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Berries', 'twentyten' ) ), 'cherryblossom' => array( 'url' => '%s/images/headers/cherryblossoms.jpg', 'thumbnail_url' => '%s/images/headers/<API key>.jpg', /* translators: header image description */ 'description' => __( 'Cherry Blossoms', 'twentyten' ) ), 'concave' => array( 'url' => '%s/images/headers/concave.jpg', 'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Concave', 'twentyten' ) ), 'fern' => array( 'url' => '%s/images/headers/fern.jpg', 'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Fern', 'twentyten' ) ), 'forestfloor' => array( 'url' => '%s/images/headers/forestfloor.jpg', 'thumbnail_url' => '%s/images/headers/<API key>.jpg', /* translators: header image description */ 'description' => __( 'Forest Floor', 'twentyten' ) ), 'inkwell' => array( 'url' => '%s/images/headers/inkwell.jpg', 'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Inkwell', 'twentyten' ) ), 'path' => array( 'url' => '%s/images/headers/path.jpg', 'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Path', 'twentyten' ) ), 'sunset' => array( 'url' => '%s/images/headers/sunset.jpg', 'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Sunset', 'twentyten' ) ) ) ); } endif; if ( ! function_exists( '<API key>' ) ) : /** * Styles the header image displayed on the Appearance > Header admin panel. * * Referenced via <API key>() in twentyten_setup(). * * @since Twenty Ten 1.0 */ function <API key>() { ?> <style type="text/css"> /* Shows the same border as on front end */ #headimg { border-bottom: 1px solid #000; border-top: 4px solid #000; } /* If NO_HEADER_TEXT is false, you would style the text with these selectors: #headimg #name { } #headimg #desc { } */ </style> <?php } endif; /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. * * To override this in a child theme, remove the filter and optionally add * your own function tied to the wp_page_menu_args filter hook. * * @since Twenty Ten 1.0 */ function <API key>( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', '<API key>' ); /** * Sets the post excerpt length to 40 characters. * * To override this length in a child theme, remove the filter and add your own * function tied to the excerpt_length filter hook. * * @since Twenty Ten 1.0 * @return int */ function <API key>( $length ) { return 40; } add_filter( 'excerpt_length', '<API key>' ); /** * Returns a "Continue Reading" link for excerpts * * @since Twenty Ten 1.0 * @return string "Continue Reading" link */ function <API key>() { return ' <a href="'. get_permalink() . '">' . __( '<span class="meta-nav"><!--&rarr;--></span>', 'twentyten' ) . '</a>'; } /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and <API key>(). * * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. * * @since Twenty Ten 1.0 * @return string An ellipsis */ function <API key>( $more ) { return ' &hellip;' . <API key>(); } add_filter( 'excerpt_more', '<API key>' ); /** * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. * * @since Twenty Ten 1.0 * @return string Excerpt with a pretty "Continue Reading" link */ function <API key>( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= <API key>(); } return $output; } add_filter( 'get_the_excerpt', '<API key>' ); /** * Remove inline styles printed when the gallery shortcode is used. * * Galleries are styled by the theme in Twenty Ten's style.css. This is just * a simple filter call that tells WordPress to not use the default styles. * * @since Twenty Ten 1.2 */ add_filter( '<API key>', '__return_false' ); /** * Deprecated way to remove inline styles printed when the gallery shortcode is used. * * This function is no longer needed or used. Use the <API key> * filter instead, as seen above. * * @since Twenty Ten 1.0 * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1 * * @return string The gallery style filter, with the styles themselves removed. */ function <API key>( $css ) { return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css ); } // Backwards compatibility with WordPress 3.0. if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) ) add_filter( 'gallery_style', '<API key>' ); if ( ! function_exists( 'twentyten_comment' ) ) : /** * Template for comments and pingbacks. * * To override this walker in a child theme without modifying the comments template * simply create your own twentyten_comment(), and that function will be used instead. * * Used as a callback by wp_list_comments() for displaying the comments. * * @since Twenty Ten 1.0 */ function twentyten_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '' : ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> <div id="comment-<?php comment_ID(); ?>"> <div class="comment-author col-xs-12 col-md-3 vcard"> <?php echo get_avatar( $comment, 90 ); ?> <?php printf( __( '%s <span class="says">disse:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', <API key>() ) ); ?> </div><!-- .comment-author .vcard --> <?php if ( $comment->comment_approved == '0' ) : ?> <em class="<API key>"><?php _e( 'Seu comentário está aguardando aprovação.', 'twentyten' ); ?></em> <br /> <?php endif; ?> <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> <?php /* translators: 1: date, 2: time */ printf( __( '%1$s em %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Editar)', 'twentyten' ), ' ' ); ?> </div><!-- .comment-meta .commentmetadata --> <div class="comment-body"><?php comment_text(); ?></div> <div class="reply"> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> </div><!-- .reply --> </div><!-- #comment-## --> <?php break; case 'pingback' : case 'trackback' : ?> <li class="post pingback"> <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author(); ?><?php edit_comment_link( __( '(Editar)', 'twentyten' ), ' ' ); ?></p> <?php break; endswitch; } endif; /** * Register widgetized areas, including two sidebars and four widget-ready columns in the footer. * * To override <API key>() in a child theme, remove the action hook and add your own * function tied to the init hook. * * @since Twenty Ten 1.0 * @uses register_sidebar */ function <API key>() { if ( function_exists('register_sidebar') ){ register_sidebar(array( 'name' => 'posts-blog', 'before_widget' => '<article class="artigo">', 'after_widget' => '</article>', 'before_title' => '', 'after_title' => '', )); } // Area 1, located at the top of the sidebar. register_sidebar( array( 'name' => 'index-pages', 'before_widget' => '<div class="col-md-4 column"><article class="grid_4 alpha"><div class="box text-center">', 'after_widget' => '</div></article></div>', 'before_title' => '<h2 class="titulo-artigo">', 'after_title' => '</h2>', ) ); /*// Area 2, located below the Primary Widget Area in the sidebar. Empty by default. register_sidebar( array( 'name' => __( 'Secondary Widget Area', 'twentyten' ), 'id' => '<API key>', 'description' => __( 'The secondary widget area', 'twentyten' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); // Area 3, located in the footer. Empty by default. register_sidebar( array( 'name' => __( 'First Footer Widget Area', 'twentyten' ), 'id' => '<API key>', 'description' => __( 'The first footer widget area', 'twentyten' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); // Area 4, located in the footer. Empty by default. register_sidebar( array( 'name' => __( 'Second Footer Widget Area', 'twentyten' ), 'id' => '<API key>', 'description' => __( 'The second footer widget area', 'twentyten' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); // Area 5, located in the footer. Empty by default. register_sidebar( array( 'name' => __( 'Third Footer Widget Area', 'twentyten' ), 'id' => '<API key>', 'description' => __( 'The third footer widget area', 'twentyten' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); // Area 6, located in the footer. Empty by default. register_sidebar( array( 'name' => __( 'Fourth Footer Widget Area', 'twentyten' ), 'id' => '<API key>', 'description' => __( 'The fourth footer widget area', 'twentyten' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); //add more widget areas. if ( function_exists('register_sidebar') ){ register_sidebar(array( 'name' => 'categoria-historico', 'before_widget' => '<div id="widget-category">', 'after_widget' => '</div>', 'before_title' => '', 'after_title' => '', ));*/ } /** Register sidebars by running <API key>() on the widgets_init hook. */ add_action( 'widgets_init', '<API key>' ); /** * Removes the default styles that are packaged with the Recent Comments widget. * * To override this in a child theme, remove the filter and optionally add your own * function tied to the widgets_init action hook. * * This function uses a filter (<API key>) new in WordPress 3.1 * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles, * but they won't have any effect on the widget in default Twenty Ten styling. * * @since Twenty Ten 1.0 */ function <API key>() { add_filter( '<API key>', '__return_false' ); } add_action( 'widgets_init', '<API key>' ); if ( ! function_exists( 'twentyten_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. * * @since Twenty Ten 1.0 */ function twentyten_posted_on() { printf( __( '<span class="%1$s">Postado em</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ), 'meta-prep meta-prep-author', sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>', get_permalink(), esc_attr( get_the_time() ), get_the_date() ), sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>', <API key>( get_the_author_meta( 'ID' ) ), sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ), get_the_author() ) ); } endif; if ( ! function_exists( 'twentyten_posted_in' ) ) : /** * Prints HTML with meta information for the current post (category, tags and permalink). * * @since Twenty Ten 1.0 */ function twentyten_posted_in() { // Retrieves tag list of current post, separated by commas. $tag_list = get_the_tag_list( '', ', ' ); if ( $tag_list ) { $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); } elseif ( <API key>( get_post_type(), 'category' ) ) { $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); } else { $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); } // Prints the string, replacing the placeholders. printf( $posted_in, <API key>( ', ' ), $tag_list, get_permalink(), the_title_attribute( 'echo=0' ) ); } endif; //Imagem Destacada if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); /*<API key>( 650, 250, true ); // Tamanho da largura das imagens.*/ } // HABILITA EXCERPT EM PAGINAS add_action( 'init', 'add_pages_excerpts' ); function add_pages_excerpts() { <API key>( 'page', 'excerpt' ); } //Imagem Destacada if ( function_exists( 'add_image_size' ) ) { add_image_size( 'slider-1600-350', 1600, 350, true); // (cropped) } function string_limit_words($string, $word_limit) { $words = explode(' ', $string, ($word_limit + 1)); if(count($words) > $word_limit) array_pop($words); return implode(' ', $words); } //Imagem Destacada if ( function_exists( 'add_image_size' ) ) { add_image_size( 'thumb-400-400', 400, 400, true ); // (cropped) add_image_size( 'thumb-90-90', 90, 90, true ); // (cropped) add_image_size( 'thumb-275-175', 275, 175, true ); // (cropped) } // Adiciona classe ao gravatar add_filter('get_avatar','add_gravatar_class'); function add_gravatar_class($class) { $class = str_replace("class='avatar", "class='avatar img-circle img-responsive center-block", $class); return $class; } add_filter('comment_reply_link', '<API key>'); function <API key>($class){ $class = str_replace("class='comment-reply-link", "class='comment-reply-link btn btn-reply pull-right", $class); return $class; } /** Removes link to comment author website */ function author_link(){ global $comment; $comment_ID = $comment->user_id; $author = get_comment_author( $comment_ID ); $url = <API key>( $comment_ID ); if ( empty( $url ) || 'http://' == $url ) $return = $author; else $return = "$author"; return $return; } add_filter('<API key>', 'author_link'); // Custom Comment function mytheme_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; extract($args, EXTR_SKIP); if ( 'div' == $args['style'] ) { $tag = 'div'; $add_below = 'comment'; } else { $tag = 'li'; $add_below = 'div-comment'; } ?> <<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>"> <?php if ( 'div' != $args['style'] ) : ?> <div id="div-comment-<?php comment_ID() ?>" class="comment-body"> <?php endif; ?> <div class="comment-author vcard col-md-2 text-center"> <?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?> <?php printf( __( '<strong><cite class="fn">%s</cite></strong><br> <span class="says">disse:</span>'), <API key>() ); ?> </div> <div class="comment-meta commentmetadata col-md-10"> <?php if ( $comment->comment_approved == '0' ) : ?> <em class="<API key> bg-warning">Seu coment&aacute;rio est&aacute; aguardando modera&ccedil;&atilde;o!</em> <?php endif; ?> <?php /* translators: 1: date, 2: time */ comment_text(); printf( __('<small>Postado em %1$s as %2$s</small>'), get_comment_date(), get_comment_time() ); ?><?php edit_comment_link( __( '(Edit)' ), ' ', '' ); ?> </div> <div class="reply"> <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> <div class="clear"></div> </div> <?php if ( 'div' != $args['style'] ) : ?> </div> <?php endif; ?> <?php } /* HABILITA NAVBAR BOOTSTRAP NO WORDPRESS*/ class BS3_Walker_Nav_Menu extends Walker_Nav_Menu { /** * Traverse elements to create list from elements. * * Display one element if the element doesn't have any children otherwise, * display the element and its children. Will only traverse up to the max * depth and no ignore elements under that depth. It is possible to set the * max depth to include all depths, see walk() method. * * This method shouldn't be called directly, use the walk() method instead. * * @since 2.5.0 * * @param object $element Data object * @param array $children_elements List of elements to continue traversing. * @param int $max_depth Max depth to traverse. * @param int $depth Depth of current element. * @param array $args * @param string $output Passed by reference. Used to append additional content. * @return null Null on failure with no changes to parameters. */ function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { $id_field = $this->db_fields['id']; if ( isset( $args[0] ) && is_object( $args[0] ) ) { $args[0]->has_children = ! empty( $children_elements[$element->$id_field] ); } return parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } /** * @see Walker::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param int $current_page Menu item ID. * @param object $args */ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { if ( is_object($args) && !empty($args->has_children) ) { $link_after = $args->link_after; $args->link_after = ' <b class="caret"></b>'; } parent::start_el($output, $item, $depth, $args, $id); if ( is_object($args) && !empty($args->has_children) ) $args->link_after = $link_after; } /** * @see Walker::start_lvl() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param int $depth Depth of page. Used for padding. */ function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<ul class=\"dropdown-menu list-unstyled\">\n"; } } add_filter('<API key>', function($atts, $item, $args) { if ( $args->has_children ) { $atts['data-toggle'] = 'dropdown'; $atts['class'] = 'dropdown-toggle'; } return $atts; }, 10, 3);
<?php ?> <div class="centerColumn" id="<API key>"> <h1><?php echo HEADING_TITLE; ?></h1> <?php if ($accountHasHistory === true) { foreach ($accountHistory as $history) { ?> <div class="review_box"> <div class="product_info_left"> <span class="title"><?php echo TEXT_ORDER_NUMBER . $history['orders_id']; ?></span> <div class="notice forward"><?php echo TEXT_ORDER_STATUS . $history['orders_status_name']; ?></div> <br class="clearBoth" /> <div class="content back"><?php echo '<strong>' . TEXT_ORDER_DATE . '</strong> ' . zen_date_long($history['date_purchased']) . '<br /><strong>' . $history['order_type'] . '</strong> ' . <API key>($history['order_name']); ?></div> <div class="content"><?php echo '<strong>' . TEXT_ORDER_PRODUCTS . '</strong> ' . $history['product_count'] . '<br /><strong>' . TEXT_ORDER_COST . '</strong> ' . strip_tags($history['order_total']); ?></div> <div class="content forward change_add"><?php echo '<a href="' . zen_href_link(<API key>, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'order_id=' . $history['orders_id'], 'SSL') . '">' . zen_image_button(<API key>, <API key>) . '</a>'; ?></div> <br class="clearBoth" /> </div> </div> <?php } ?> <div class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $history_split->display_links(<API key>, <API key>(array('page', 'info', 'x', 'y', 'main_page'))); ?></div> <div class="navSplitPagesResult"><?php echo $history_split->display_count(<API key>); ?></div> <?php } else { ?> <div class="centerColumn" id="<API key>"> <?php echo TEXT_NO_PURCHASES; ?> </div> <?php } ?> <div class="buttonRow forward change_add"><?php echo '<a href="' . zen_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div> </div>
/* * Notebook: * - hugetlb needs more code * - kcore/oldmem/vmcore/mem/kmem check for hwpoison pages * - pass bad pages to kdump next kernel */ #include <linux/kernel.h> #include <linux/mm.h> #include <linux/page-flags.h> #include <linux/kernel-page-flags.h> #include <linux/sched.h> #include <linux/ksm.h> #include <linux/rmap.h> #include <linux/export.h> #include <linux/pagemap.h> #include <linux/swap.h> #include <linux/backing-dev.h> #include <linux/migrate.h> #include <linux/page-isolation.h> #include <linux/suspend.h> #include <linux/slab.h> #include <linux/swapops.h> #include <linux/hugetlb.h> #include <linux/memory_hotplug.h> #include <linux/mm_inline.h> #include <linux/kfifo.h> #include "internal.h" int <API key> __read_mostly = 0; int <API key> __read_mostly = 1; atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); #if defined(<API key>) || defined(<API key>) u32 <API key> = 0; u32 <API key> = ~0U; u32 <API key> = ~0U; u64 <API key>; u64 <API key>; EXPORT_SYMBOL_GPL(<API key>); EXPORT_SYMBOL_GPL(<API key>); EXPORT_SYMBOL_GPL(<API key>); EXPORT_SYMBOL_GPL(<API key>); EXPORT_SYMBOL_GPL(<API key>); static int hwpoison_filter_dev(struct page *p) { struct address_space *mapping; dev_t dev; if (<API key> == ~0U && <API key> == ~0U) return 0; /* * page_mapping() does not accept slab pages. */ if (PageSlab(p)) return -EINVAL; mapping = page_mapping(p); if (mapping == NULL || mapping->host == NULL) return -EINVAL; dev = mapping->host->i_sb->s_dev; if (<API key> != ~0U && <API key> != MAJOR(dev)) return -EINVAL; if (<API key> != ~0U && <API key> != MINOR(dev)) return -EINVAL; return 0; } static int <API key>(struct page *p) { if (!<API key>) return 0; if ((stable_page_flags(p) & <API key>) == <API key>) return 0; else return -EINVAL; } /* * This allows stress tests to limit test scope to a collection of tasks * by putting them under some memcg. This prevents killing unrelated/important * processes such as /sbin/init. Note that the target task may share clean * pages with init (eg. libc text), which is harmless. If the target task * share _dirty_ pages with another task B, the test scheme must make sure B * is also included in the memcg. At last, due to race conditions this filter * can only guarantee that the page either belongs to the memcg tasks, or is * a freed page. */ #ifdef CONFIG_MEMCG_SWAP u64 <API key>; EXPORT_SYMBOL_GPL(<API key>); static int <API key>(struct page *p) { struct mem_cgroup *mem; struct cgroup_subsys_state *css; unsigned long ino; if (!<API key>) return 0; mem = <API key>(p); if (!mem) return -EINVAL; css = mem_cgroup_css(mem); /* root_mem_cgroup has NULL dentries */ if (!css->cgroup->dentry) return -EINVAL; ino = css->cgroup->dentry->d_inode->i_ino; css_put(css); if (ino != <API key>) return -EINVAL; return 0; } #else static int <API key>(struct page *p) { return 0; } #endif int hwpoison_filter(struct page *p) { if (!<API key>) return 0; if (hwpoison_filter_dev(p)) return -EINVAL; if (<API key>(p)) return -EINVAL; if (<API key>(p)) return -EINVAL; return 0; } #else int hwpoison_filter(struct page *p) { return 0; } #endif EXPORT_SYMBOL_GPL(hwpoison_filter); /* * Send all the processes who have the page mapped a signal. * ``action optional'' if they are not immediately affected by the error * ``action required'' if error happened in current execution context */ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno, unsigned long pfn, struct page *page, int flags) { struct siginfo si; int ret; printk(KERN_ERR "MCE %#lx: Killing %s:%d due to hardware memory corruption\n", pfn, t->comm, t->pid); si.si_signo = SIGBUS; si.si_errno = 0; si.si_addr = (void *)addr; #ifdef __ARCH_SI_TRAPNO si.si_trapno = trapno; #endif si.si_addr_lsb = <API key>(compound_head(page)) + PAGE_SHIFT; if ((flags & MF_ACTION_REQUIRED) && t->mm == current->mm) { si.si_code = BUS_MCEERR_AR; ret = force_sig_info(SIGBUS, &si, current); } else { /* * Don't use force here, it's convenient if the signal * can be temporarily blocked. * This could cause a loop when the user sets SIGBUS * to SIG_IGN, but hopefully no one will do that? */ si.si_code = BUS_MCEERR_AO; ret = send_sig_info(SIGBUS, &si, t); /* synchronous? */ } if (ret < 0) printk(KERN_INFO "MCE: Error sending signal to %s:%d: %d\n", t->comm, t->pid, ret); return ret; } /* * When a unknown page type is encountered drain as many buffers as possible * in the hope to turn the page into a LRU or free page, which we can handle. */ void shake_page(struct page *p, int access) { if (!PageSlab(p)) { lru_add_drain_all(); if (PageLRU(p)) return; drain_all_pages(); if (PageLRU(p) || is_free_buddy_page(p)) return; } /* * Only call shrink_slab here (which would also shrink other caches) if * access is not potentially fatal. */ if (access) { int nr; do { struct shrink_control shrink = { .gfp_mask = GFP_KERNEL, }; shrink.priority = DEF_PRIORITY; nr = shrink_slab(&shrink, 1000, 1000); if (page_count(p) == 1) break; } while (nr > 10); } } EXPORT_SYMBOL_GPL(shake_page); /* * Kill all processes that have a poisoned page mapped and then isolate * the page. * * General strategy: * Find all processes having the page mapped and kill them. * But we keep a page reference around so that the page is not * actually freed yet. * Then stash the page away * * There's no convenient way to get back to mapped processes * from the VMAs. So do a brute-force search over all * running processes. * * Remember that machine checks are not common (or rather * if they are common you have other problems), so this shouldn't * be a performance issue. * * Also there are some races possible while we get from the * error detection to actually handle it. */ struct to_kill { struct list_head nd; struct task_struct *tsk; unsigned long addr; char addr_valid; }; /* * Failure handling: if we can't find or can't kill a process there's * not much we can do. We just print a message and ignore otherwise. */ /* * Schedule a process for later kill. * Uses GFP_ATOMIC allocations to avoid potential recursions in the VM. * TBD would GFP_NOIO be enough? */ static void add_to_kill(struct task_struct *tsk, struct page *p, struct vm_area_struct *vma, struct list_head *to_kill, struct to_kill **tkc) { struct to_kill *tk; if (*tkc) { tk = *tkc; *tkc = NULL; } else { tk = kmalloc(sizeof(struct to_kill), GFP_ATOMIC); if (!tk) { printk(KERN_ERR "MCE: Out of memory while machine check handling\n"); return; } } tk->addr = page_address_in_vma(p, vma); tk->addr_valid = 1; /* * In theory we don't have to kill when the page was * munmaped. But it could be also a mremap. Since that's * likely very rare kill anyways just out of paranoia, but use * a SIGKILL because the error is not contained anymore. */ if (tk->addr == -EFAULT) { pr_info("MCE: Unable to find user space address %lx in %s\n", page_to_pfn(p), tsk->comm); tk->addr_valid = 0; } get_task_struct(tsk); tk->tsk = tsk; list_add_tail(&tk->nd, to_kill); } /* * Kill the processes that have been collected earlier. * * Only do anything when DOIT is set, otherwise just free the list * (this is used for clean pages which do not need killing) * Also when FAIL is set do a force kill because something went * wrong earlier. */ static void kill_procs(struct list_head *to_kill, int forcekill, int trapno, int fail, struct page *page, unsigned long pfn, int flags) { struct to_kill *tk, *next; <API key> (tk, next, to_kill, nd) { if (forcekill) { /* * In case something went wrong with munmapping * make sure the process doesn't catch the * signal and then access the memory. Just kill it. */ if (fail || tk->addr_valid == 0) { printk(KERN_ERR "MCE %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n", pfn, tk->tsk->comm, tk->tsk->pid); force_sig(SIGKILL, tk->tsk); } /* * In theory the process could have mapped * something else on the address in-between. We could * check for that, but we need to tell the * process anyways. */ else if (kill_proc(tk->tsk, tk->addr, trapno, pfn, page, flags) < 0) printk(KERN_ERR "MCE %#lx: Cannot send advisory machine check signal to %s:%d\n", pfn, tk->tsk->comm, tk->tsk->pid); } put_task_struct(tk->tsk); kfree(tk); } } static int task_early_kill(struct task_struct *tsk, int force_early) { if (!tsk->mm) return 0; if (force_early) return 1; if (tsk->flags & PF_MCE_PROCESS) return !!(tsk->flags & PF_MCE_EARLY); return <API key>; } /* * Collect processes when the error hit an anonymous page. */ static void collect_procs_anon(struct page *page, struct list_head *to_kill, struct to_kill **tkc, int force_early) { struct vm_area_struct *vma; struct task_struct *tsk; struct anon_vma *av; pgoff_t pgoff; av = <API key>(page); if (av == NULL) /* Not actually mapped anymore */ return; pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); read_lock(&tasklist_lock); for_each_process (tsk) { struct anon_vma_chain *vmac; if (!task_early_kill(tsk, force_early)) continue; <API key>(vmac, &av->rb_root, pgoff, pgoff) { vma = vmac->vma; if (!page_mapped_in_vma(page, vma)) continue; if (vma->vm_mm == tsk->mm) add_to_kill(tsk, page, vma, to_kill, tkc); } } read_unlock(&tasklist_lock); <API key>(av); } /* * Collect processes when the error hit a file mapped page. */ static void collect_procs_file(struct page *page, struct list_head *to_kill, struct to_kill **tkc, int force_early) { struct vm_area_struct *vma; struct task_struct *tsk; struct address_space *mapping = page->mapping; mutex_lock(&mapping->i_mmap_mutex); read_lock(&tasklist_lock); for_each_process(tsk) { pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); if (!task_early_kill(tsk, force_early)) continue; <API key>(vma, &mapping->i_mmap, pgoff, pgoff) { /* * Send early kill signal to tasks where a vma covers * the page but the corrupted page is not necessarily * mapped it in its pte. * Assume applications who requested early kill want * to be informed of all such data corruptions. */ if (vma->vm_mm == tsk->mm) add_to_kill(tsk, page, vma, to_kill, tkc); } } read_unlock(&tasklist_lock); mutex_unlock(&mapping->i_mmap_mutex); } /* * Collect the processes who have the corrupted page mapped to kill. * This is done in two steps for locking reasons. * First preallocate one tokill structure outside the spin locks, * so that we can kill at least one process reasonably reliable. */ static void collect_procs(struct page *page, struct list_head *tokill, int force_early) { struct to_kill *tk; if (!page->mapping) return; tk = kmalloc(sizeof(struct to_kill), GFP_NOIO); if (!tk) return; if (PageAnon(page)) collect_procs_anon(page, tokill, &tk, force_early); else collect_procs_file(page, tokill, &tk, force_early); kfree(tk); } /* * Error handlers for various types of pages. */ enum outcome { IGNORED, /* Error: cannot be handled */ FAILED, /* Error: handling failed */ DELAYED, /* Will be handled later */ RECOVERED, /* Successfully recovered */ }; static const char *action_name[] = { [IGNORED] = "Ignored", [FAILED] = "Failed", [DELAYED] = "Delayed", [RECOVERED] = "Recovered", }; /* * XXX: It is possible that a page is isolated from LRU cache, * and then kept in swap cache or failed to remove from page cache. * The page count will stop it from being freed by unpoison. * Stress tests should be aware of this memory leak problem. */ static int <API key>(struct page *p) { if (!isolate_lru_page(p)) { /* * Clear sensible page flags, so that the buddy system won't * complain when the page is unpoison-and-freed. */ ClearPageActive(p); <API key>(p); /* * drop the page count elevated by isolate_lru_page() */ page_cache_release(p); return 0; } return -EIO; } /* * Error hit kernel page. * Do nothing, try to be lucky and not touch this instead. For a few cases we * could be more sophisticated. */ static int me_kernel(struct page *p, unsigned long pfn) { return IGNORED; } /* * Page in unknown state. Do nothing. */ static int me_unknown(struct page *p, unsigned long pfn) { printk(KERN_ERR "MCE %#lx: Unknown page state\n", pfn); return FAILED; } /* * Clean (or cleaned) page cache page. */ static int me_pagecache_clean(struct page *p, unsigned long pfn) { int err; int ret = FAILED; struct address_space *mapping; <API key>(p); /* * For anonymous pages we're done the only reference left * should be the one m_f() holds. */ if (PageAnon(p)) return RECOVERED; /* * Now truncate the page in the page cache. This is really * more like a "temporary hole punch" * Don't do this for block devices when someone else * has a reference, because it could be file system metadata * and that's not safe to truncate. */ mapping = page_mapping(p); if (!mapping) { /* * Page has been teared down in the meanwhile */ return FAILED; } /* * Truncation is a bit tricky. Enable it per file system for now. * * Open: to take i_mutex or not for this? Right now we don't. */ if (mapping->a_ops->error_remove_page) { err = mapping->a_ops->error_remove_page(mapping, p); if (err != 0) { printk(KERN_INFO "MCE %#lx: Failed to punch page: %d\n", pfn, err); } else if (page_has_private(p) && !try_to_release_page(p, GFP_NOIO)) { pr_info("MCE %#lx: failed to release buffers\n", pfn); } else { ret = RECOVERED; } } else { /* * If the file system doesn't support it just invalidate * This fails on dirty or anything with private pages */ if (<API key>(p)) ret = RECOVERED; else printk(KERN_INFO "MCE %#lx: Failed to invalidate\n", pfn); } return ret; } /* * Dirty cache page page * Issues: when the error hit a hole page the error is not properly * propagated. */ static int me_pagecache_dirty(struct page *p, unsigned long pfn) { struct address_space *mapping = page_mapping(p); SetPageError(p); /* TBD: print more information about the file. */ if (mapping) { /* * IO error will be reported by write(), fsync(), etc. * who check the mapping. * This way the application knows that something went * wrong with its dirty file data. * * There's one open issue: * * The EIO will be only reported on the next IO * operation and then cleared through the IO map. * Normally Linux has two mechanisms to pass IO error * first through the AS_EIO flag in the address space * and then through the PageError flag in the page. * Since we drop pages on memory failure handling the * only mechanism open to use is through AS_AIO. * * This has the disadvantage that it gets cleared on * the first operation that returns an error, while * the PageError bit is more sticky and only cleared * when the page is reread or dropped. If an * application assumes it will always get error on * fsync, but does other operations on the fd before * and the page is dropped between then the error * will not be properly reported. * * This can already happen even without hwpoisoned * pages: first on metadata IO errors (which only * report through AS_EIO) or when the page is dropped * at the wrong time. * * So right now we assume that the application DTRT on * the first EIO, but we're not worse than other parts * of the kernel. */ mapping_set_error(mapping, EIO); } return me_pagecache_clean(p, pfn); } /* * Clean and dirty swap cache. * * Dirty swap cache page is tricky to handle. The page could live both in page * cache and swap cache(ie. page is freshly swapped in). So it could be * referenced concurrently by 2 types of PTEs: * normal PTEs and swap PTEs. We try to handle them consistently by calling * try_to_unmap(TTU_IGNORE_HWPOISON) to convert the normal PTEs to swap PTEs, * and then * - clear dirty bit to prevent IO * - remove from LRU * - but keep in the swap cache, so that when we return to it on * a later page fault, we know the application is accessing * corrupted data and shall be killed (we installed simple * interception code in do_swap_page to catch it). * * Clean swap cache pages can be directly isolated. A later page fault will * bring in the known good data from disk. */ static int me_swapcache_dirty(struct page *p, unsigned long pfn) { ClearPageDirty(p); /* Trigger EIO in shmem: */ ClearPageUptodate(p); if (!<API key>(p)) return DELAYED; else return FAILED; } static int me_swapcache_clean(struct page *p, unsigned long pfn) { <API key>(p); if (!<API key>(p)) return RECOVERED; else return FAILED; } /* * Huge pages. Needs work. * Issues: * - Error on hugepage is contained in hugepage unit (not in raw page unit.) * To narrow down kill region to one page, we need to break up pmd. */ static int me_huge_page(struct page *p, unsigned long pfn) { int res = 0; struct page *hpage = compound_head(p); /* * We can safely recover from error on free or reserved (i.e. * not in-use) hugepage by dequeuing it from freelist. * To check whether a hugepage is in-use or not, we can't use * page->lru because it can be used in other hugepage operations, * such as <API key>() and <API key>(). * So instead we use page_mapping() and PageAnon(). * We assume that this function is called with page lock held, * so there is no race between isolation and mapping/unmapping. */ if (!(page_mapping(hpage) || PageAnon(hpage))) { res = <API key>(hpage); if (!res) return RECOVERED; } return DELAYED; } /* * Various page states we can handle. * * A page state is defined by its current page->flags bits. * The table matches them in order and calls the right handler. * * This is quite tricky because we can access page at any time * in its live cycle, so all accesses have to be extremely careful. * * This is not complete. More states could be added. * For any missing state don't attempt recovery. */ #define dirty (1UL << PG_dirty) #define sc (1UL << PG_swapcache) #define unevict (1UL << PG_unevictable) #define mlock (1UL << PG_mlocked) #define writeback (1UL << PG_writeback) #define lru (1UL << PG_lru) #define swapbacked (1UL << PG_swapbacked) #define head (1UL << PG_head) #define tail (1UL << PG_tail) #define compound (1UL << PG_compound) #define slab (1UL << PG_slab) #define reserved (1UL << PG_reserved) static struct page_state { unsigned long mask; unsigned long res; char *msg; int (*action)(struct page *p, unsigned long pfn); } error_states[] = { { reserved, reserved, "reserved kernel", me_kernel }, /* * free pages are specially detected outside this table: * PG_buddy pages only make a small fraction of all free pages. */ /* * Could in theory check if slab page is free or if we can drop * currently unused objects without touching them. But just * treat it as standard kernel for now. */ { slab, slab, "kernel slab", me_kernel }, #ifdef <API key> { head, head, "huge", me_huge_page }, { tail, tail, "huge", me_huge_page }, #else { compound, compound, "huge", me_huge_page }, #endif { sc|dirty, sc|dirty, "dirty swapcache", me_swapcache_dirty }, { sc|dirty, sc, "clean swapcache", me_swapcache_clean }, { mlock|dirty, mlock|dirty, "dirty mlocked LRU", me_pagecache_dirty }, { mlock|dirty, mlock, "clean mlocked LRU", me_pagecache_clean }, { unevict|dirty, unevict|dirty, "dirty unevictable LRU", me_pagecache_dirty }, { unevict|dirty, unevict, "clean unevictable LRU", me_pagecache_clean }, { lru|dirty, lru|dirty, "dirty LRU", me_pagecache_dirty }, { lru|dirty, lru, "clean LRU", me_pagecache_clean }, /* * Catchall entry: must be at end. */ { 0, 0, "unknown page state", me_unknown }, }; #undef dirty #undef sc #undef unevict #undef mlock #undef writeback #undef lru #undef swapbacked #undef head #undef tail #undef compound #undef slab #undef reserved /* * "Dirty/Clean" indication is not 100% accurate due to the possibility of * setting PG_dirty outside page lock. See also comment above set_page_dirty(). */ static void action_result(unsigned long pfn, char *msg, int result) { pr_err("MCE %#lx: %s page recovery: %s\n", pfn, msg, action_name[result]); } static int page_action(struct page_state *ps, struct page *p, unsigned long pfn) { int result; int count; result = ps->action(p, pfn); action_result(pfn, ps->msg, result); count = page_count(p) - 1; if (ps->action == me_swapcache_dirty && result == DELAYED) count if (count != 0) { printk(KERN_ERR "MCE %#lx: %s page still referenced by %d users\n", pfn, ps->msg, count); result = FAILED; } /* Could do more checks here if page looks ok */ /* * Could adjust zone counters here to correct for the missing page. */ return (result == RECOVERED || result == DELAYED) ? 0 : -EBUSY; } /* * Do all that is necessary to remove user space mappings. Unmap * the pages and send SIGBUS to the processes if the data was dirty. */ static int <API key>(struct page *p, unsigned long pfn, int trapno, int flags, struct page **hpagep) { enum ttu_flags ttu = TTU_UNMAP | TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS; struct address_space *mapping; LIST_HEAD(tokill); int ret; int kill = 1, forcekill; struct page *hpage = *hpagep; struct page *ppage; if (PageReserved(p) || PageSlab(p)) return SWAP_SUCCESS; /* * This check implies we don't kill processes if their pages * are in the swap cache early. Those are always late kills. */ if (!page_mapped(hpage)) return SWAP_SUCCESS; if (PageKsm(p)) return SWAP_FAIL; if (PageSwapCache(p)) { printk(KERN_ERR "MCE %#lx: keeping poisoned page in swap cache\n", pfn); ttu |= TTU_IGNORE_HWPOISON; } /* * Propagate the dirty bit from PTEs to struct page first, because we * need this to decide if we should kill or just drop the page. * XXX: the dirty test could be racy: set_page_dirty() may not always * be called inside page lock (it's recommended but not enforced). */ mapping = page_mapping(hpage); if (!(flags & MF_MUST_KILL) && !PageDirty(hpage) && mapping && <API key>(mapping)) { if (page_mkclean(hpage)) { SetPageDirty(hpage); } else { kill = 0; ttu |= TTU_IGNORE_HWPOISON; printk(KERN_INFO "MCE %#lx: corrupted page was clean: dropped without side effects\n", pfn); } } /* * ppage: poisoned page * if p is regular page(4k page) * ppage == real poisoned page; * else p is hugetlb or THP, ppage == head page. */ ppage = hpage; if (PageTransHuge(hpage)) { /* * Verify that this isn't a hugetlbfs head page, the check for * PageAnon is just for avoid tripping a split_huge_page * internal debug check, as split_huge_page refuses to deal with * anything that isn't an anon page. PageAnon can't go away fro * under us because we hold a refcount on the hpage, without a * refcount on the hpage. split_huge_page can't be safely called * in the first place, having a refcount on the tail isn't * enough * to be safe. */ if (!PageHuge(hpage) && PageAnon(hpage)) { if (unlikely(split_huge_page(hpage))) { /* * FIXME: if splitting THP is failed, it is * better to stop the following operation rather * than causing panic by unmapping. System might * survive if the page is freed later. */ printk(KERN_INFO "MCE %#lx: failed to split THP\n", pfn); BUG_ON(!PageHWPoison(p)); return SWAP_FAIL; } /* * We pinned the head page for hwpoison handling, * now we split the thp and we are interested in * the hwpoisoned raw page, so move the refcount * to it. Similarly, page lock is shifted. */ if (hpage != p) { if (!(flags & MF_COUNT_INCREASED)) { put_page(hpage); get_page(p); } lock_page(p); unlock_page(hpage); *hpagep = p; } /* THP is split, so ppage should be the real poisoned page. */ ppage = p; } } /* * First collect all the processes that have the page * mapped in dirty form. This has to be done before try_to_unmap, * because ttu takes the rmap data structures down. * * Error handling: We ignore errors here because * there's nothing that can be done. */ if (kill) collect_procs(ppage, &tokill, flags & MF_ACTION_REQUIRED); ret = try_to_unmap(ppage, ttu); if (ret != SWAP_SUCCESS) printk(KERN_ERR "MCE %#lx: failed to unmap page (mapcount=%d)\n", pfn, page_mapcount(ppage)); /* * Now that the dirty bit has been propagated to the * struct page and all unmaps done we can decide if * killing is needed or not. Only kill when the page * was dirty or the process is not restartable, * otherwise the tokill list is merely * freed. When there was a problem unmapping earlier * use a more force-full uncatchable kill to prevent * any accesses to the poisoned memory. */ forcekill = PageDirty(ppage) || (flags & MF_MUST_KILL); kill_procs(&tokill, forcekill, trapno, ret != SWAP_SUCCESS, p, pfn, flags); return ret; } static void <API key>(struct page *hpage) { int i; int nr_pages = 1 << <API key>(hpage); for (i = 0; i < nr_pages; i++) SetPageHWPoison(hpage + i); } static void <API key>(struct page *hpage) { int i; int nr_pages = 1 << <API key>(hpage); for (i = 0; i < nr_pages; i++) ClearPageHWPoison(hpage + i); } /** * memory_failure - Handle memory failure of a page. * @pfn: Page Number of the corrupted page * @trapno: Trap number reported in the signal to user space. * @flags: fine tune action taken * * This function is called by the low level machine check code * of an architecture when it detects hardware memory corruption * of a page. It tries its best to recover, which includes * dropping pages, killing processes etc. * * The function is primarily of use for corruptions that * happen outside the current execution context (e.g. when * detected by a background scrubber) * * Must run in process context (e.g. a work queue) with interrupts * enabled and no spinlocks hold. */ int memory_failure(unsigned long pfn, int trapno, int flags) { struct page_state *ps; struct page *p; struct page *hpage; int res; unsigned int nr_pages; unsigned long page_flags; if (!<API key>) panic("Memory failure from trap %d on page %lx", trapno, pfn); if (!pfn_valid(pfn)) { printk(KERN_ERR "MCE %#lx: memory outside kernel control\n", pfn); return -ENXIO; } p = pfn_to_page(pfn); hpage = compound_head(p); if (TestSetPageHWPoison(p)) { printk(KERN_ERR "MCE %#lx: already hardware poisoned\n", pfn); return 0; } /* * Currently errors on hugetlbfs pages are measured in hugepage units, * so nr_pages should be 1 << compound_order. OTOH when errors are on * transparent hugepages, they are supposed to be split and error * measurement is done in normal page units. So nr_pages should be one * in this case. */ if (PageHuge(p)) nr_pages = 1 << compound_order(hpage); else /* normal page or thp */ nr_pages = 1; atomic_long_add(nr_pages, &num_poisoned_pages); /* * We need/can do nothing about count=0 pages. * 1) it's a free page, and therefore in safe hand: * prep_new_page() will be the gate keeper. * 2) it's a free hugepage, which is also safe: * an affected hugepage will be dequeued from hugepage freelist, * so there's no concern about reusing it ever after. * 3) it's part of a non-compound high order page. * Implies some kernel user: cannot stop them from * R/W the page; let's pray that the page has been * used and will be freed some time later. * In fact it's dangerous to directly bump up page count from 0, * that may make page_freeze_refs()/page_unfreeze_refs() mismatch. */ if (!(flags & MF_COUNT_INCREASED) && !<API key>(hpage)) { if (is_free_buddy_page(p)) { action_result(pfn, "free buddy", DELAYED); return 0; } else if (PageHuge(hpage)) { /* * Check "just unpoisoned", "filter hit", and * "race with other subpage." */ lock_page(hpage); if (!PageHWPoison(hpage) || (hwpoison_filter(p) && <API key>(p)) || (p != hpage && TestSetPageHWPoison(hpage))) { atomic_long_sub(nr_pages, &num_poisoned_pages); return 0; } <API key>(hpage); res = <API key>(hpage); action_result(pfn, "free huge", res ? IGNORED : DELAYED); unlock_page(hpage); return res; } else { action_result(pfn, "high order kernel", IGNORED); return -EBUSY; } } /* * We ignore non-LRU pages for good reasons. * - PG_locked is only well defined for LRU pages and a few others * - to avoid races with __set_page_locked() * - to avoid races with __SetPageSlab*() (and more non-atomic ops) * The check (unnecessarily) ignores LRU pages being isolated and * walked by the page reclaim code, however that's not a big loss. */ if (!PageHuge(p)) { if (!PageLRU(hpage)) shake_page(hpage, 0); if (!PageLRU(hpage)) { /* * shake_page could have turned it free. */ if (is_free_buddy_page(p)) { action_result(pfn, "free buddy, 2nd try", DELAYED); return 0; } action_result(pfn, "non LRU", IGNORED); put_page(p); return -EBUSY; } } /* * Lock the page and wait for writeback to finish. * It's very difficult to mess with pages currently under IO * and in many cases impossible, so we just avoid it here. */ lock_page(hpage); page_flags = p->flags; /* * unpoison always clear PG_hwpoison inside page lock */ if (!PageHWPoison(p)) { printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn); res = 0; goto out; } if (hwpoison_filter(p)) { if (<API key>(p)) atomic_long_sub(nr_pages, &num_poisoned_pages); unlock_page(hpage); put_page(hpage); return 0; } /* * For error on the tail page, we should set PG_hwpoison * on the head page to show that the hugepage is hwpoisoned */ if (PageHuge(p) && PageTail(p) && TestSetPageHWPoison(hpage)) { action_result(pfn, "hugepage already hardware poisoned", IGNORED); unlock_page(hpage); put_page(hpage); return 0; } /* * Set PG_hwpoison on all pages in an error hugepage, * because containment is done in hugepage unit for now. * Since we have done TestSetPageHWPoison() for the head page with * page lock held, we can safely set PG_hwpoison bits on tail pages. */ if (PageHuge(p)) <API key>(hpage); <API key>(p); /* * Now take care of user space mappings. * Abort on fail: <API key>() assumes unmapped page. * * When the raw error page is thp tail page, hpage points to the raw * page after thp split. */ if (<API key>(p, pfn, trapno, flags, &hpage) != SWAP_SUCCESS) { printk(KERN_ERR "MCE %#lx: cannot unmap page, give up\n", pfn); res = -EBUSY; goto out; } /* * Torn down by someone else? */ if (PageLRU(p) && !PageSwapCache(p) && p->mapping == NULL) { action_result(pfn, "already truncated LRU", IGNORED); res = -EBUSY; goto out; } res = -EBUSY; /* * The first check uses the current page flags which may not have any * relevant information. The second check with the saved page flagss is * carried out only if the first check can't determine the page status. */ for (ps = error_states;; ps++) if ((p->flags & ps->mask) == ps->res) break; if (!ps->mask) for (ps = error_states;; ps++) if ((page_flags & ps->mask) == ps->res) break; res = page_action(ps, p, pfn); out: unlock_page(hpage); return res; } EXPORT_SYMBOL_GPL(memory_failure); #define <API key> 4 #define <API key> (1 << <API key>) struct <API key> { unsigned long pfn; int trapno; int flags; }; struct memory_failure_cpu { DECLARE_KFIFO(fifo, struct <API key>, <API key>); spinlock_t lock; struct work_struct work; }; static DEFINE_PER_CPU(struct memory_failure_cpu, memory_failure_cpu); /** * <API key> - Schedule handling memory failure of a page. * @pfn: Page Number of the corrupted page * @trapno: Trap number reported in the signal to user space. * @flags: Flags for memory failure handling * * This function is called by the low level hardware error handler * when it detects hardware memory corruption of a page. It schedules * the recovering of error page, including dropping pages, killing * processes etc. * * The function is primarily of use for corruptions that * happen outside the current execution context (e.g. when * detected by a background scrubber) * * Can run in IRQ context. */ void <API key>(unsigned long pfn, int trapno, int flags) { struct memory_failure_cpu *mf_cpu; unsigned long proc_flags; struct <API key> entry = { .pfn = pfn, .trapno = trapno, .flags = flags, }; mf_cpu = &get_cpu_var(memory_failure_cpu); spin_lock_irqsave(&mf_cpu->lock, proc_flags); if (kfifo_put(&mf_cpu->fifo, &entry)) schedule_work_on(smp_processor_id(), &mf_cpu->work); else pr_err("Memory failure: buffer overflow when queuing memory failure at 0x%#lx\n", pfn); <API key>(&mf_cpu->lock, proc_flags); put_cpu_var(memory_failure_cpu); } EXPORT_SYMBOL_GPL(<API key>); static void <API key>(struct work_struct *work) { struct memory_failure_cpu *mf_cpu; struct <API key> entry = { 0, }; unsigned long proc_flags; int gotten; mf_cpu = &__get_cpu_var(memory_failure_cpu); for (;;) { spin_lock_irqsave(&mf_cpu->lock, proc_flags); gotten = kfifo_get(&mf_cpu->fifo, &entry); <API key>(&mf_cpu->lock, proc_flags); if (!gotten) break; memory_failure(entry.pfn, entry.trapno, entry.flags); } } static int __init memory_failure_init(void) { struct memory_failure_cpu *mf_cpu; int cpu; <API key>(cpu) { mf_cpu = &per_cpu(memory_failure_cpu, cpu); spin_lock_init(&mf_cpu->lock); INIT_KFIFO(mf_cpu->fifo); INIT_WORK(&mf_cpu->work, <API key>); } return 0; } core_initcall(memory_failure_init); /** * unpoison_memory - Unpoison a previously poisoned page * @pfn: Page number of the to be unpoisoned page * * Software-unpoison a page that has been poisoned by * memory_failure() earlier. * * This is only done on the software-level, so it only works * for linux injected failures, not real hardware failures * * Returns 0 for success, otherwise -errno. */ int unpoison_memory(unsigned long pfn) { struct page *page; struct page *p; int freeit = 0; unsigned int nr_pages; if (!pfn_valid(pfn)) return -ENXIO; p = pfn_to_page(pfn); page = compound_head(p); if (!PageHWPoison(p)) { pr_info("MCE: Page was already unpoisoned %#lx\n", pfn); return 0; } nr_pages = 1 << <API key>(page); if (!<API key>(page)) { /* * Since HWPoisoned hugepage should have non-zero refcount, * race between memory failure and unpoison seems to happen. * In such case unpoison fails and memory failure runs * to the end. */ if (PageHuge(page)) { pr_info("MCE: Memory failure is now running on free hugepage %#lx\n", pfn); return 0; } if (<API key>(p)) atomic_long_sub(nr_pages, &num_poisoned_pages); pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn); return 0; } lock_page(page); /* * This test is racy because PG_hwpoison is set outside of page lock. * That's acceptable because that won't trigger kernel panic. Instead, * the PG_hwpoison page will be caught and isolated on the entrance to * the free buddy page pool. */ if (<API key>(page)) { pr_info("MCE: Software-unpoisoned page %#lx\n", pfn); atomic_long_sub(nr_pages, &num_poisoned_pages); freeit = 1; if (PageHuge(page)) <API key>(page); } unlock_page(page); put_page(page); if (freeit) put_page(page); return 0; } EXPORT_SYMBOL(unpoison_memory); static struct page *new_page(struct page *p, unsigned long private, int **x) { int nid = page_to_nid(p); if (PageHuge(p)) return <API key>(page_hstate(compound_head(p)), nid); else return <API key>(nid, <API key>, 0); } /* * Safely get reference count of an arbitrary page. * Returns 0 for a free page, -EIO for a zero refcount page * that is not free, and 1 for any other page type. * For 1 the page is returned with increased page count, otherwise not. */ static int __get_any_page(struct page *p, unsigned long pfn, int flags) { int ret; if (flags & MF_COUNT_INCREASED) return 1; /* * The lock_memory_hotplug prevents a race with memory hotplug. * This is a big hammer, a better would be nicer. */ lock_memory_hotplug(); /* * Isolate the page, so that it doesn't get reallocated if it * was free. This flag should be kept set until the source page * is freed and PG_hwpoison on it is set. */ <API key>(p, true); /* * When the target page is a free hugepage, just remove it * from free hugepage list. */ if (!<API key>(compound_head(p))) { if (PageHuge(p)) { pr_info("%s: %#lx free huge page\n", __func__, pfn); ret = 0; } else if (is_free_buddy_page(p)) { pr_info("%s: %#lx free buddy page\n", __func__, pfn); ret = 0; } else { pr_info("%s: %#lx: unknown zero refcount page type %lx\n", __func__, pfn, p->flags); ret = -EIO; } } else { /* Not a free page */ ret = 1; } <API key>(); return ret; } static int get_any_page(struct page *page, unsigned long pfn, int flags) { int ret = __get_any_page(page, pfn, flags); if (ret == 1 && !PageHuge(page) && !PageLRU(page)) { /* * Try to free it. */ put_page(page); shake_page(page, 1); /* * Did it turn free? */ ret = __get_any_page(page, pfn, 0); if (!PageLRU(page)) { pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n", pfn, page->flags); return -EIO; } } return ret; } static int <API key>(struct page *page, int flags) { int ret; unsigned long pfn = page_to_pfn(page); struct page *hpage = compound_head(page); /* * This double-check of PageHWPoison is to avoid the race with * memory_failure(). See also comment in __soft_offline_page(). */ lock_page(hpage); if (PageHWPoison(hpage)) { unlock_page(hpage); put_page(hpage); pr_info("soft offline: %#lx hugepage already poisoned\n", pfn); return -EBUSY; } unlock_page(hpage); /* Keep page count to indicate a given hugepage is isolated. */ ret = migrate_huge_page(hpage, new_page, MPOL_MF_MOVE_ALL, MIGRATE_SYNC); put_page(hpage); if (ret) { pr_info("soft offline: %#lx: migration failed %d, type %lx\n", pfn, ret, page->flags); } else { /* overcommit hugetlb page will be freed to buddy */ if (PageHuge(page)) { <API key>(hpage); <API key>(hpage); atomic_long_add(1 << compound_order(hpage), &num_poisoned_pages); } else { SetPageHWPoison(page); atomic_long_inc(&num_poisoned_pages); } } return ret; } static int __soft_offline_page(struct page *page, int flags); /** * soft_offline_page - Soft offline a page. * @page: page to offline * @flags: flags. Same as memory_failure(). * * Returns 0 on success, otherwise negated errno. * * Soft offline a page, by migration or invalidation, * without killing anything. This is for the case when * a page is not corrupted yet (so it's still valid to access), * but has had a number of corrected errors and is better taken * out. * * The actual policy on when to do that is maintained by * user space. * * This should never impact any application or cause data loss, * however it might take some time. * * This is not a 100% solution for all memory, but tries to be * ``good enough'' for the majority of memory. */ int soft_offline_page(struct page *page, int flags) { int ret; unsigned long pfn = page_to_pfn(page); struct page *hpage = compound_head(page); if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); return -EBUSY; } if (!PageHuge(page) && PageTransHuge(hpage)) { if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) { pr_info("soft offline: %#lx: failed to split THP\n", pfn); return -EBUSY; } } ret = get_any_page(page, pfn, flags); if (ret < 0) return ret; if (ret) { /* for in-use pages */ if (PageHuge(page)) ret = <API key>(page, flags); else ret = __soft_offline_page(page, flags); } else { /* for free pages */ if (PageHuge(page)) { <API key>(hpage); <API key>(hpage); atomic_long_add(1 << <API key>(hpage), &num_poisoned_pages); } else { SetPageHWPoison(page); atomic_long_inc(&num_poisoned_pages); } } <API key>(page, MIGRATE_MOVABLE); return ret; } static int __soft_offline_page(struct page *page, int flags) { int ret; unsigned long pfn = page_to_pfn(page); /* * Check PageHWPoison again inside page lock because PageHWPoison * is set by memory_failure() outside page lock. Note that * memory_failure() also double-checks PageHWPoison inside page lock, * so there's no race between soft_offline_page() and memory_failure(). */ lock_page(page); <API key>(page); if (PageHWPoison(page)) { unlock_page(page); put_page(page); pr_info("soft offline: %#lx page already poisoned\n", pfn); return -EBUSY; } /* * Try to invalidate first. This should work for * non dirty unmapped page cache pages. */ ret = <API key>(page); unlock_page(page); /* * RED-PEN would be better to keep it isolated here, but we * would need to fix isolation locking first. */ if (ret == 1) { put_page(page); pr_info("soft_offline: %#lx: invalidated\n", pfn); SetPageHWPoison(page); atomic_long_inc(&num_poisoned_pages); return 0; } /* * Simple invalidation didn't work. * Try to migrate to a new page instead. migrate.c * handles a large number of cases for us. */ ret = isolate_lru_page(page); /* * Drop page reference which is came from get_any_page() * successful isolate_lru_page() already took another one. */ put_page(page); if (!ret) { LIST_HEAD(pagelist); inc_zone_page_state(page, NR_ISOLATED_ANON + page_is_file_cache(page)); list_add(&page->lru, &pagelist); ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, MIGRATE_SYNC, MR_MEMORY_FAILURE); if (ret) { putback_lru_pages(&pagelist); pr_info("soft offline: %#lx: migration failed %d, type %lx\n", pfn, ret, page->flags); if (ret > 0) ret = -EIO; } else { /* * After page migration succeeds, the source page can * be trapped in pagevec and actual freeing is delayed. * Freeing code works differently based on PG_hwpoison, * so there's a race. We need to make sure that the * source page should be freed back to buddy before * setting PG_hwpoison. */ if (!is_free_buddy_page(page)) lru_add_drain_all(); if (!is_free_buddy_page(page)) drain_all_pages(); SetPageHWPoison(page); if (!is_free_buddy_page(page)) pr_info("soft offline: %#lx: page leaked\n", pfn); atomic_long_inc(&num_poisoned_pages); } } else { pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n", pfn, ret, page_count(page), page->flags); } return ret; }
package org.hl7.v3; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for LengthOutOfRange. * * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;simpleType name="LengthOutOfRange"> * &lt;restriction base="{urn:hl7-org:v3}cs"> * &lt;enumeration value="LEN_RANGE"/> * &lt;enumeration value="LEN_LONG"/> * &lt;enumeration value="LEN_SHORT"/> * &lt;/restriction> * &lt;/simpleType> * </pre> * */ @XmlType(name = "LengthOutOfRange") @XmlEnum public enum LengthOutOfRange { LEN_RANGE, LEN_LONG, LEN_SHORT; public String value() { return name(); } public static LengthOutOfRange fromValue(String v) { return valueOf(v); } }
# SCORE MPI-parallelized cellular automaton ensemble model for the simulation of primary recrystallization phenomena in 3D A detailed documentation of the model and the program is available under: http://score.readthedocs.org/en/master/ The authors of SCORE gratefully acknowledge the financial support from the Deutsche <API key> (DFG) within the "Reinhart Koselleck-Project" (GO 335/44-1) and the granting of computing time which was provided by the RWTH Aachen University JARAHPC research alliance (JARA0076). The authors of SCORE gratefully acknowledge the financial support from the <API key> through the provisioning of computing time grants in the frame of the BiGmax, the Max-Planck-Society's Research Network on Big-Data-Driven Materials Science. Latest bugfixes: - 2016/01/13: uncomment the line #define DEBUG in src/SCORE_Io.h when utilizing the GNU compiler - 2019/02/23: we implemented a right-handed coordinate system and made modifications to use the code for the following paper. Now it is required that the code gets linked to a static local installation of the Hierarchical Data Format 5 (HDF5) library. M. Diehl and M. Kuehbach, Coupled <API key> analysis of primary static recrystallization in low carbon steel", Modelling and Simulation in Materials Science and Engineering, 28, 2020, http://doi.org/10.1088/1361-651X/ab51bd Further details to this study and example input data are available here: http:
/* DEBUG: section 16 Cache Manager API */ #include "squid.h" #include "base/TextException.h" #include "ipc/TypedMsgHdr.h" #include "mgr/ActionParams.h" Mgr::ActionParams::ActionParams(): httpMethod(Http::METHOD_NONE) { } Mgr::ActionParams::ActionParams(const Ipc::TypedMsgHdr &msg) { msg.getString(httpUri); String method; msg.getString(method); httpMethod = HttpRequestMethod(method.termedBuf(), NULL); msg.getPod(httpFlags); msg.getString(httpOrigin); msg.getString(actionName); msg.getString(userName); msg.getString(password); queryParams.unpack(msg); } void Mgr::ActionParams::pack(Ipc::TypedMsgHdr &msg) const { msg.putString(httpUri); String foo(httpMethod.image().toString()); msg.putString(foo); msg.putPod(httpFlags); msg.putString(httpOrigin); msg.putString(actionName); msg.putString(userName); msg.putString(password); queryParams.pack(msg); }
/* OSSAudio.cc * * Audio agent -- OSS functions * * Authors: Michal Svec <msvec@suse.cz> */ #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/soundcard.h> #include <y2util/y2log.h> #include "OSSAudio.h" /** * stereo volume structure for oss volume settings */ typedef struct { unsigned char left; unsigned char right; } stereovolume; /* channels' names, to be used for channel to nubmer mapping sometime */ const char *ossChannels[] = SOUND_DEVICE_LABELS; int ossChannels_num = <API key>; /** * convert channel string to oss device number * FIXME: use ossChannels for convertion [make a map in constructor -> search] */ int ossDevice(const string channel) { if(channel=="" || channel=="Master") return SOUND_MIXER_VOLUME; else if(channel=="BASS") return SOUND_MIXER_BASS; else if(channel=="TREBLE") return SOUND_MIXER_TREBLE; else if(channel=="SYNTH") return SOUND_MIXER_SYNTH; else if(channel=="PCM") return SOUND_MIXER_PCM; else if(channel=="SPEAKER") return SOUND_MIXER_SPEAKER; else if(channel=="LINE") return SOUND_MIXER_LINE; else if(channel=="MIC") return SOUND_MIXER_MIC; else if(channel=="CD") return SOUND_MIXER_CD; else if(channel=="IMIX") return SOUND_MIXER_IMIX; else if(channel=="ALTPCM") return SOUND_MIXER_ALTPCM; else if(channel=="RECLEV") return SOUND_MIXER_RECLEV; else if(channel=="IGAIN") return SOUND_MIXER_IGAIN; else if(channel=="OGAIN") return SOUND_MIXER_OGAIN; else if(channel=="LINE1") return SOUND_MIXER_LINE1; else if(channel=="LINE2") return SOUND_MIXER_LINE2; else if(channel=="LINE3") return SOUND_MIXER_LINE3; else if(channel=="DIGITAL1") return <API key>; else if(channel=="DIGITAL2") return <API key>; else if(channel=="DIGITAL3") return <API key>; else if(channel=="PHONEIN") return SOUND_MIXER_PHONEIN; else if(channel=="PHONEOUT") return <API key>; else if(channel=="VIDEO") return SOUND_MIXER_VIDEO; else if(channel=="RADIO") return SOUND_MIXER_RADIO; else if(channel=="MONITOR") return SOUND_MIXER_MONITOR; // else if(channel=="") return SOUND_MIXER_; else { return -1; } } YCPBoolean ossSetVolume(const string card, const string channel, const int value) { string mixerfile = "/dev/mixer"; mixerfile += card; int vol = value; if(vol<0) { y2warning("volume set to 0"); vol=0; } if(vol>99) { y2warning("volume set to 99"); vol=99; } int device = SOUND_MIXER_VOLUME; if(channel!="") { device = ossDevice(channel); if(device == -1) { y2error("bad channel specification: %s", channel.c_str()); return YCPBoolean(false); } } stereovolume volume; volume.left = vol; volume.right = vol; int mixer_fd = open(mixerfile.c_str(), O_RDWR, 0); if(mixer_fd < 0) { string error = string("cannot open mixer: '" + string(mixerfile) + "' : " + string(strerror(errno))).c_str(); y2error("Error: %s", error.c_str()); return YCPBoolean(false); } if(ioctl(mixer_fd,MIXER_WRITE(device),&volume) == -1) { string error = string("ioctl failed : ") + strerror(errno); close(mixer_fd); y2error("Error: %s", error.c_str()); return YCPBoolean(false); } close(mixer_fd); return YCPBoolean (true); } YCPValue ossGetVolume(const string card, const string channel) { string mixerfile = "/dev/mixer"; mixerfile += card; y2debug("mixerfile=%s",mixerfile.c_str()); stereovolume volume; int device = SOUND_MIXER_VOLUME; if(channel!="") { device = ossDevice(channel); if(device == -1) { string error = string("bad channel specification: ") + channel.c_str(); return YCPError(error); } } y2debug("device=%d",device); int mixer_fd = open(mixerfile.c_str(), O_RDWR, 0); if(mixer_fd < 0) { string error = string("cannot open mixer: '") + mixerfile + "' : " + strerror(errno); return YCPError(error, YCPInteger(-1)); } if(ioctl(mixer_fd,MIXER_READ(device),&volume) == -1) { string error = string("ioctl failed : ") + strerror(errno); close(mixer_fd); return YCPError(error, YCPInteger(-1)); } if(volume.left != volume.right) y2warning("volume is not balanced (%d,%d)", volume.left, volume.right); int vol = volume.left; if(vol<0) { y2warning("read volume set to 0"); vol=0; } if(vol>99) { y2warning("read volume set to 99"); vol=99; } close(mixer_fd); return YCPInteger(vol); }
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #ifndef SPECTRUM_WIFI_PHY_H #define SPECTRUM_WIFI_PHY_H #include "ns3/antenna-model.h" #include "wifi-phy.h" #include "<API key>.h" #include "ns3/spectrum-channel.h" #include "ns3/<API key>.h" namespace ns3 { /** * \brief 802.11 PHY layer model * \ingroup wifi * * This PHY implements a spectrum-aware enhancement of the 802.11 SpectrumWifiPhy * model. * * This PHY model depends on a channel loss and delay * model as provided by the ns3::<API key> * and ns3::<API key> classes. * */ class SpectrumWifiPhy : public WifiPhy { public: static TypeId GetTypeId (void); SpectrumWifiPhy (); virtual ~SpectrumWifiPhy (); /** * Set the SpectrumChannel this SpectrumWifiPhy is to be connected to. * * \param channel the SpectrumChannel this SpectrumWifiPhy is to be connected to */ void SetChannel (Ptr<SpectrumChannel> channel); /** * Add a channel number to the list of operational channels. This method * is used to support scanning for strongest base station. * * \param channelNumber the channel number to add */ void <API key> (uint16_t channelNumber); /** * Return a list of channels to which it may be possible to roam * By default, this method will return the current channel number followed * by any other channel numbers that have been added. * * \return vector of channel numbers to which it may be possible to roam */ std::vector<uint16_t> <API key> (void) const; /** * Clear the list of operational channels. */ void <API key> (void); /** * Input method for delivering a signal from the spectrum channel * and low-level Phy interface to this SpectrumWifiPhy instance. * * \param rxParams Input signal parameters */ void StartRx (Ptr<<API key>> rxParams); /** * \param packet the packet to send * \param txVector the TXVECTOR that has tx parameters such as mode, the transmission mode to use to send * this packet, and txPowerLevel, a power level to use to send this packet. The real transmission * power is calculated as txPowerMin + txPowerLevel * (txPowerMax - txPowerMin) / nTxLevels * \param txDuration duration of the transmission. */ void StartTx (Ptr<Packet> packet, WifiTxVector txVector, Time txDuration); /** * Method to encapsulate the creation of the <API key> * object (used to bind the WifiSpectrumPhy to a SpectrumChannel) and * to link it to this SpectrumWifiPhy instance * * \param device pointer to the NetDevice object including this new object */ void <API key> (Ptr<NetDevice> device); /** * \return pointer to <API key> associated with this Phy */ Ptr<<API key>> GetSpectrumPhy (void) const; /** * \param antenna an AntennaModel to include in the transmitted * <API key> (in case any objects downstream of the * SpectrumWifiPhy wish to adjust signal properties based on the * transmitted antenna model. This antenna is also used when * the underlying <API key>::GetRxAntenna() method * is called. * * Note: this method may be split into separate SetTx and SetRx * methods in the future if the modelling need for this arises */ void SetAntenna (Ptr<AntennaModel> antenna); /** * Get the antenna model used for reception * * \return the AntennaModel used for reception */ Ptr<AntennaModel> GetRxAntenna (void) const; /** * \return returns the SpectrumModel that this SpectrumPhy expects to be used * for all SpectrumValues that are passed to StartRx. If 0 is * returned, it means that any model will be accepted. */ Ptr<const SpectrumModel> GetRxSpectrumModel () const; /** * Callback invoked when the Phy model starts to process a signal * * \param signalType Whether signal is WiFi (true) or foreign (false) * \param senderNodeId Node Id of the sender of the signal * \param rxPower received signal power (dBm) * \param duration Signal duration */ typedef void (* <API key>) (bool signalType, uint32_t senderNodeId, double rxPower, Time duration); virtual Ptr<WifiChannel> GetChannel (void) const; protected: // Inherited virtual void DoDispose (void); virtual void DoInitialize (void); private: /** * \param centerFrequency center frequency (MHz) * \param channelWidth channel width (MHz) of the channel * \param txPowerW power in W to spread across the bands * \return Ptr to SpectrumValue * * This is a helper function to create the right Tx PSD corresponding * to the standard in use. */ Ptr<SpectrumValue> <API key> (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW) const; Ptr<SpectrumChannel> m_channel; //!< SpectrumChannel that this SpectrumWifiPhy is connected to std::vector<uint16_t> <API key>; //!< List of possible channels Ptr<<API key>> <API key>; Ptr<AntennaModel> m_antenna; mutable Ptr<const SpectrumModel> m_rxSpectrumModel; bool <API key>; //!< forces this Phy to fail to sync on any signal TracedCallback<bool, uint32_t, double, Time> m_signalCb; }; } //namespace ns3 #endif /* SPECTRUM_WIFI_PHY_H */
<?php /** * @file * Contains \Drupal\social_counters\Plugin\SocialCounters\Twitter. */ namespace Drupal\social_counters\Plugin\SocialCounters; use Drupal\Core\Url; use Drupal\social_counters\Plugin\<API key>; /** * Provides a Twitter social counters plugin. * @Plugin( * id = "<API key>", * label = @Translation("Twitter"), * ) */ class Twitter extends <API key> { /** * {@inheritdoc} */ public function getCount() { $count = 0; $config = $this->configuration['config']; $url = Url::fromUri('https://api.twitter.com/1.1/users/show.json', array('query' => array( 'screen_name' => $config->id, )))->toString(); try { $response = $this->http_client->request('GET', $url, array( 'headers' => array( 'Authorization' => 'Bearer ' . $config->bearer_token, ) )); $result = $this->json_serializer->decode((string)$response->getBody()); if ($response->getStatusCode() == 200) { $count = $result['followers_count']; } else { if (!empty($result['errors'])) { foreach ($result['errors'] as $error) { $this->logger->warning('%message', array('%message' => $error['message'])); } } } } catch (RequestException $e) { // @todo Find out if we can do it without global function. watchdog_exception('social_counters', $e); } return $count; } /** * {@inheritdoc} */ public function label() { return $this->t('Twitter'); } /** * {@inheritdoc} */ public function entityForm(&$form, &$form_state, $config) { $form['id'] = array( '#title' => $this->t('Twitter account'), '#description' => $this->t('The Twitter account to pull the number of followers.'), '#type' => 'textfield', '#required' => TRUE, '#default_value' => !empty($config->id) ? $config->id : '', ); $form['bearer_token'] = array( '#title' => $this->t('Bearer token(Twitter).'), '#description' => t('See documentation about barear token on <a href="@application-only">Application-only authentication</a> page.', array( '@application-only' => Url::fromUri('https://dev.twitter.com/oauth/application-only')->toString(), )), '#type' => 'textfield', '#required' => TRUE, '#size' => 128, '#maxlength' => 256, '#default_value' => !empty($config->bearer_token) ? $config->bearer_token : '', ); } }
<?php namespace core; use Cellular; class Helper { public static function token($len = 32, $md5 = true) { mt_srand((double)microtime() * 1000000); $chars = array( 'Q', '@', '8', 'y', '%', '^', '5', 'Z', '(', 'G', '_', 'O', '`', 'S', '-', 'N', '<', 'D', '{', '}', '[', ']', 'h', ';', 'W', '.', '/', '|', ':', '1', 'E', 'L', '4', '&', '6', '7', '#', '9', 'a', 'A', 'b', 'B', '~', 'C', 'd', '>', 'e', '2', 'f', 'P', 'g', ')', '?', 'H', 'i', 'X', 'U', 'J', 'k', 'r', 'l', '3', 't', 'M', 'n', '=', 'o', '+', 'p', 'F', 'q', '!', 'K', 'R', 's', 'c', 'm', 'T', 'v', 'j', 'u', 'V', 'w', ',', 'x', 'I', '$', 'Y', 'z', '*' ); $numChars = count($chars) - 1; $token = ''; # Create random token at the specified length for ($i=0; $i<$len; $i++) $token .= $chars[mt_rand(0, $numChars)]; # Should token be run through md5? if ( $md5 ) { # Number of 32 char chunks $chunks = ceil(strlen($token) / 32); $md5token = ''; # Run each chunk through md5 for ( $i=1; $i<=$chunks; $i++ ) $md5token .= md5(substr($token, $i * 32 - 32, 32)); # Trim the token $token = substr($md5token, 0, $len); } return $token; } public static function randNum($length = 6) { $number = null; while ($length) { $number .= mt_rand(0, 9); $length } return $number; } public function strArray($str, $split = ',', $assign = '=') { if ($str) { $arr = array(); $temp = strpos($str, $split) ? explode($split, $str) : [$str]; foreach ($temp as $value) { $value = explode($assign, $value); $arr[$value[0]] = $value[1]; } return $arr; } return null; } /** * URI */ public static function URL($controller = null, $action = null, $param = null) { return Cellular::getURL($controller, $action, $param); } public static function location($controller = null, $action = null, $param = null) { header('location: '.self::URL($controller, $action, $param)); exit(); } public static function UUID() { return md5(uniqid(md5(microtime(true)),true)); } /** * IP * @return string IP */ public static function ip() { if (isset($_SERVER['<API key>'])) { $arr = explode(',', $_SERVER['<API key>']); $pos = array_search('unknown', $arr); if(false !== $pos) unset($arr[$pos]); $ip = trim($arr[0]); } elseif(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } if (sprintf("%u",ip2long($ip))) { return $ip; } return '0.0.0.0'; } /** * * , " * " "" " * 1. "\t" tab 2. "" = ="0123" */ public static function escape($str) { if (stripos($str, ',') !== false || stripos($str, '"') !== false) { if (stripos($str, '"') !== false) { $str = str_replace('"', '""', $str); } $str = '"' . $str . '"'; } return $str; } public static function randName () { return date('YmdHis') . substr(microtime(), 2, 6); } public static function floatToInteger($float, $precision) { $number = sprintf('%.' . $precision . 'f', $float); $number = str_replace('.', '', $number); return intval($number); } /** * Redis * @return Redis */ public static function redis() { static $redis; if (isset($redis)) { return $redis; } $config = Cellular::config('redis'); $redis = new \Redis(); $redis->connect($config['host'], $config['port']); return $redis; } /** * base64 URL * @param $value * @return mixed|string */ public static function encodeBase64($value) { $data = base64_encode($value); $data = str_replace(array('+','/','='),array('-','_',''),$data); return $data; } /** * base64 URL * @param $value * @return mixed|string */ public static function decodeBase64($value) { $data = str_replace(array('-','_'),array('+','/'),$value); $mod4 = strlen($data) % 4; if ($mod4) { $data .= substr('====', $mod4); } return base64_decode($data); } } ?>
#if !defined(<API key>) #define <API key> #if defined ( TOUCH_PLATFORM_MTK ) #if defined ( TOUCH_MODEL_Y70 ) #define TOUCH_I2C_BUS_NUM 0 #define <API key> 0x20 #elif defined ( TOUCH_MODEL_LION_3G ) #define TOUCH_I2C_USE #define TOUCH_I2C_BUS_NUM 0 #define <API key> #define <API key> 0x20 #elif defined ( TOUCH_MODEL_M2 ) #define TOUCH_I2C_USE #define TOUCH_I2C_BUS_NUM 0 #define <API key> #define <API key> 0x34 #else #error "Model should be defined" #endif #endif #if defined ( TOUCH_MODEL_Y30 ) #define TOUCH_I2C_USE #define <API key> #define TOUCH_I2C_BUS_NUM 1 #elif defined (TOUCH_MODEL_P1C ) #define TOUCH_I2C_USE #define <API key> #define TOUCH_I2C_BUS_NUM 5 #endif #if defined ( TOUCH_PLATFORM_MTK ) int <API key>(int index); #endif #if defined ( TOUCH_PLATFORM_QCT ) || defined (CONFIG_USE_OF) struct of_device_id * <API key>(int index); #endif #endif /* <API key> */ /* End Of File */
package cn.canyin.service.impl; import java.util.List; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import cn.canyin.dao.FoodDao; import cn.canyin.model.Food; import cn.canyin.service.FoodService; public class FoodServiceImpl implements FoodService { private static Logger logger = Logger.getLogger(FoodServiceImpl.class); @Autowired private FoodDao foodDao; @Override public Food getByFID(long fid) throws Exception { // TODO Auto-generated method stub logger.info("Enter FoodServiceImpl.getByFID method"); return foodDao.getByFID(fid); } @Override public List<Food> getByFoodName(String fname) throws Exception { // TODO Auto-generated method stub return foodDao.getByFoodName(fname); } @Override public long addFood(Food food) throws Exception { // TODO Auto-generated method stub return foodDao.addFood(food); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } }
package com.oddlabs.tt.player; import java.util.List; import com.oddlabs.tt.model.RacesResources; import com.oddlabs.tt.model.Selectable; import com.oddlabs.tt.model.Unit; import com.oddlabs.tt.pathfinder.FindOccupantFilter; import com.oddlabs.tt.pathfinder.UnitGrid; public final strictfp class NativeChieftainAI extends ChieftainAI { private final static int <API key> = 2; private final static int <API key> = 5; public final void decide(Unit chieftain) { nodeLightningCloud(chieftain); nodePoisonFog(chieftain); } private final void nodeLightningCloud(Unit chieftain) { if (chieftain.getMagicProgress(RacesResources.<API key>) < 1) return; float hit_radius = 30f; int num_enemy_units = numEnemyUnits(chieftain.getOwner()); int <API key> = <API key>(chieftain, hit_radius); if (<API key> >= <API key> || (num_enemy_units < <API key> && <API key> > 1) || (chieftain.getHitPoints() <= 2 && <API key> > 1)) { chieftain.doMagic(RacesResources.<API key>, false); } } private final void nodePoisonFog(Unit chieftain) { if (chieftain.getMagicProgress(RacesResources.INDEX_MAGIC_POISON) < 1) return; float hit_radius = chieftain.getOwner().getRace().getMagicFactory(RacesResources.INDEX_MAGIC_POISON).getHitRadius(); int num_enemy_units = numEnemyUnits(chieftain.getOwner()); int <API key> = <API key>(chieftain, hit_radius); int <API key> = <API key>(chieftain, hit_radius); if (2*<API key> < <API key> && (<API key> >= <API key> || (num_enemy_units < <API key> && <API key> > 1) || (chieftain.getHitPoints() <= 2 && <API key> > 1))) { chieftain.doMagic(RacesResources.INDEX_MAGIC_POISON, false); } } private final int <API key>(Unit chieftain, float hit_radius) { FindOccupantFilter filter = new FindOccupantFilter(chieftain.getPositionX(), chieftain.getPositionY(), hit_radius, chieftain, Unit.class); chieftain.getUnitGrid().scan(filter, chieftain.getGridX(), chieftain.getGridY()); List target_list = filter.getResult(); int <API key> = 0; for (int i = 0; i < target_list.size(); i++) { Unit unit = (Unit)target_list.get(i); if (unit.isDead()) continue; float dx = unit.getPositionX() - chieftain.getPositionX(); float dy = unit.getPositionY() - chieftain.getPositionY(); float squared_dist = dx*dx + dy*dy; if (chieftain.getOwner().isEnemy(unit.getOwner()) && squared_dist < hit_radius*hit_radius) { <API key>++; } } return <API key>; } private final int <API key>(Unit chieftain, float hit_radius) { FindOccupantFilter filter = new FindOccupantFilter(chieftain.getPositionX(), chieftain.getPositionY(), hit_radius, chieftain, Selectable.class); chieftain.getUnitGrid().scan(filter, chieftain.getGridX(), chieftain.getGridY()); List target_list = filter.getResult(); int <API key> = 0; for (int i = 0; i < target_list.size(); i++) { Selectable s = (Selectable)target_list.get(i); if (s.isDead()) continue; float dx = s.getPositionX() - chieftain.getPositionX(); float dy = s.getPositionY() - chieftain.getPositionY(); float squared_dist = dx*dx + dy*dy; if (!chieftain.getOwner().isEnemy(s.getOwner()) && squared_dist < hit_radius*hit_radius) { <API key>++; } } return <API key>; } }
#ifndef <API key> #define <API key> #include "Platform/Define.h" #include "Database/DatabaseEnv.h" #include <vector> class Player; class ObjectMgr; #define MAX_QUEST_LOG_SIZE 25 #define <API key> 4 #define <API key> <API key> #define <API key> 4 #define <API key> 6 #define QUEST_REWARDS_COUNT 4 #define QUEST_DEPLINK_COUNT 10 #define <API key> 5 #define QUEST_EMOTE_COUNT 4 enum QuestFailedReasons { <API key> = 0, // this is default case <API key> = 1, // You are not high enough level for that quest. <API key> = 4, // Inventory is full <API key> = 6, // That quest is not available to your race. <API key> = 7, // You have completed that quest. <API key> = 12, // You can only be on one timed quest at a time. <API key> = 13, // You are already on that quest. <API key> = 16, // This quest requires an expansion enabled account. <API key> = 17, // Duplicate item found. <API key> = 18, // You are already on that quest. <API key> = 21, // You don't have the required items with you. Check storage. <API key> = 23, // You don't have enough money for that quest. <API key> = 26, // You have already completed 10 daily quests today. <API key> = 27 // You cannot complete quests once you have reached tired time. }; enum QuestShareMessages { <API key> = 0, // <API key> <API key> = 1, // <API key> <API key> = 2, // <API key> <API key> = 3, // <API key> <API key> = 4, // removed in 3.x <API key> = 5, // <API key> <API key> = 6, // <API key> <API key> = 7, // <API key> <API key> = 8, // <API key> }; enum __QuestTradeSkill { QUEST_TRSKILL_NONE = 0, <API key> = 1, <API key> = 2, <API key> = 3, <API key> = 4, <API key> = 5, <API key> = 6, <API key> = 7, <API key> = 8, <API key> = 9, <API key> = 10, <API key> = 11, <API key> = 12, <API key> = 13, <API key> = 14, }; enum QuestStatus { QUEST_STATUS_NONE = 0, <API key> = 1, <API key> = 2, <API key> = 3, <API key> = 4, // unused in fact QUEST_STATUS_FAILED = 5, MAX_QUEST_STATUS }; enum __QuestGiverStatus { DIALOG_STATUS_NONE = 0, <API key> = 1, // Grey Exclamation Mark DIALOG_STATUS_CHAT = 2, // No marker <API key> = 3, // Grey Question Mark - quest taken <API key> = 4, // Blue Question Mark - non-daily repeatable available <API key> = 5, // Blue Exclamation Mark - daily available <API key> = 6, // Yellow Exclamation Mark - quest available <API key> = 7, // no yellow dot on minimap <API key> = 8, // yellow dot on minimap <API key> = 100 // Used as result for unassigned ScriptCall }; // values based at QuestInfo.dbc enum QuestTypes { QUEST_TYPE_ELITE = 1, QUEST_TYPE_LIFE = 21, QUEST_TYPE_PVP = 41, QUEST_TYPE_RAID = 62, QUEST_TYPE_DUNGEON = 81, <API key> = 82, <API key> = 83, QUEST_TYPE_ESCORT = 84, QUEST_TYPE_HEROIC = 85, }; enum QuestFlags { // Flags used at server and sent to client QUEST_FLAGS_NONE = 0x00000000, <API key> = 0x00000001, // Quest is failed on dying <API key> = 0x00000002, // If player in party, all players that can accept this quest will receive confirmation box to accept quest <API key>/<API key> <API key> = 0x00000004, // Not used currently <API key> = 0x00000008, // Can be shared: Player::CanShareQuest() // QUEST_FLAGS_NONE2 = 0x00000010, // Not used currently QUEST_FLAGS_EPIC = 0x00000020, // Not used currently: Unsure of content QUEST_FLAGS_RAID = 0x00000040, // Not used currently QUEST_FLAGS_TBC = 0x00000080, // Not used currently: Available if TBC expansion enabled only QUEST_FLAGS_UNK2 = 0x00000100, // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs <API key> = 0x00000200, // Items and money rewarded only sent in <API key> (not in <API key> or in client quest log(<API key>)) <API key> = 0x00000400, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side. <API key> = 0x00000800, // Not used currently: Blood elf/Draenei starting zone quests QUEST_FLAGS_DAILY = 0x00001000, // Daily quest. Can be done once a day. Quests reset at regular intervals for all players. <API key> = 0x00002000, // activates PvP on accept QUEST_FLAGS_UNK4 = 0x00004000, // ? Membership Card Renewal QUEST_FLAGS_WEEKLY = 0x00008000, // Weekly quest. Can be done once a week. Quests reset at regular intervals for all players. }; enum QuestSpecialFlags { // Mangos flags for set SpecialFlags in DB if required but used only at server <API key> = 0x001, // |1 in SpecialFlags from DB <API key> = 0x002, // |2 in SpecialFlags from DB (if required area explore, spell <API key> casting, table `*_script` command <API key> use, set from script DLL) <API key> = 0x004, // |4 in SpecialFlags. Quest reset for player at beginning of month. // Mangos flags for internal use only <API key> = 0x008, // Internal flag computed only <API key> = 0x010, // Internal flag computed only <API key> = 0x020, // Internal flag computed only <API key> = 0x040, // Internal flag computed only }; #define <API key> (<API key> | <API key> | <API key>) struct QuestLocale { QuestLocale() { ObjectiveText.resize(<API key>); } std::vector<std::string> Title; std::vector<std::string> Details; std::vector<std::string> Objectives; std::vector<std::string> OfferRewardText; std::vector<std::string> RequestItemsText; std::vector<std::string> EndText; std::vector< std::vector<std::string> > ObjectiveText; }; // This Quest class provides a convenient way to access a few pretotaled (cached) quest details, // all base quest information, and any utility functions such as generating the amount of // xp to give class Quest { friend class ObjectMgr; public: Quest(Field* questRecord); uint32 XPValue(Player* pPlayer) const; uint32 GetQuestFlags() const { return m_QuestFlags; } bool HasQuestFlag(QuestFlags flag) const { return (m_QuestFlags & flag) != 0; } bool HasSpecialFlag(QuestSpecialFlags flag) const { return (m_SpecialFlags & flag) != 0; } void SetSpecialFlag(QuestSpecialFlags flag) { m_SpecialFlags |= flag; } // table data accessors: uint32 GetQuestId() const { return QuestId; } uint32 GetQuestMethod() const { return QuestMethod; } int32 GetZoneOrSort() const { return ZoneOrSort; } uint32 GetMinLevel() const { return MinLevel; } int32 GetQuestLevel() const { return QuestLevel; } uint32 GetType() const { return Type; } uint32 GetRequiredClasses() const { return RequiredClasses; } uint32 GetRequiredRaces() const { return RequiredRaces; } uint32 GetRequiredSkill() const { return RequiredSkill; } uint32 <API key>() const { return RequiredSkillValue; } uint32 <API key>() const { return RequiredCondition; } uint32 <API key>() const { return RepObjectiveFaction; } int32 <API key>() const { return RepObjectiveValue; } uint32 <API key>() const { return <API key>; } int32 <API key>() const { return RequiredMinRepValue; } uint32 <API key>() const { return <API key>; } int32 <API key>() const { return RequiredMaxRepValue; } uint32 GetSuggestedPlayers() const { return SuggestedPlayers; } uint32 GetLimitTime() const { return LimitTime; } int32 GetPrevQuestId() const { return PrevQuestId; } int32 GetNextQuestId() const { return NextQuestId; } int32 GetExclusiveGroup() const { return ExclusiveGroup; } uint32 GetNextQuestInChain() const { return NextQuestInChain; } uint32 GetCharTitleId() const { return CharTitleId; } uint32 <API key>() const; // in 2.x in different from 3.x in some quest packets used bit index insed id uint32 GetSrcItemId() const { return SrcItemId; } uint32 GetSrcItemCount() const { return SrcItemCount; } uint32 GetSrcSpell() const { return SrcSpell; } std::string GetTitle() const { return Title; } std::string GetDetails() const { return Details; } std::string GetObjectives() const { return Objectives; } std::string GetOfferRewardText() const { return OfferRewardText; } std::string GetRequestItemsText() const { return RequestItemsText; } std::string GetEndText() const { return EndText; } int32 GetRewOrReqMoney() const; uint32 <API key>() const { return RewHonorableKills; } uint32 GetRewMoneyMaxLevel() const { return RewMoneyMaxLevel; } // use in XP calculation at client uint32 GetRewSpell() const { return RewSpell; } uint32 GetRewSpellCast() const { return RewSpellCast; } uint32 <API key>() const { return RewMailTemplateId; } uint32 GetRewMailDelaySecs() const { return RewMailDelaySecs; } uint32 GetPointMapId() const { return PointMapId; } float GetPointX() const { return PointX; } float GetPointY() const { return PointY; } uint32 GetPointOpt() const { return PointOpt; } uint32 GetIncompleteEmote() const { return IncompleteEmote; } uint32 <API key>() const { return <API key>; } uint32 GetCompleteEmote() const { return CompleteEmote; } uint32 <API key>() const { return CompleteEmoteDelay; } uint32 <API key>() const { return m_detailsemotecount; } uint32 GetQuestStartScript() const { return QuestStartScript; } uint32 <API key>() const { return QuestCompleteScript; } bool IsRepeatable() const { return (m_SpecialFlags & <API key>) != 0; } bool IsAutoComplete() const { return !QuestMethod; } bool IsDaily() const { return (m_QuestFlags & QUEST_FLAGS_DAILY) != 0; } bool IsWeekly() const { return (m_QuestFlags & QUEST_FLAGS_WEEKLY) != 0; } bool IsMonthly() const { return (m_SpecialFlags & <API key>) != 0; } bool IsDailyOrWeekly() const { return (m_QuestFlags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) != 0; } bool IsAllowedInRaid() const; // quest can be fully deactivated and will not be available for any player void SetQuestActiveState(bool state) { m_isActive = state; } bool IsActive() const { return m_isActive; } // multiple values std::string ObjectiveText[<API key>]; uint32 ReqItemId[<API key>]; uint32 ReqItemCount[<API key>]; uint32 ReqSourceId[<API key>]; uint32 ReqSourceCount[<API key>]; int32 ReqCreatureOrGOId[<API key>]; // >0 Creature <0 Gameobject uint32 <API key>[<API key>]; uint32 ReqSpell[<API key>]; uint32 RewChoiceItemId[<API key>]; uint32 RewChoiceItemCount[<API key>]; uint32 RewItemId[QUEST_REWARDS_COUNT]; uint32 RewItemCount[QUEST_REWARDS_COUNT]; uint32 RewRepFaction[<API key>]; int32 RewRepValue[<API key>]; int32 RewMaxRepValue[<API key>]; uint32 DetailsEmote[QUEST_EMOTE_COUNT]; uint32 DetailsEmoteDelay[QUEST_EMOTE_COUNT]; uint32 OfferRewardEmote[QUEST_EMOTE_COUNT]; uint32 <API key>[QUEST_EMOTE_COUNT]; uint32 GetReqItemsCount() const { return m_reqitemscount; } uint32 <API key>() const { return <API key>; } uint32 <API key>() const { return <API key>; } uint32 GetRewItemsCount() const { return m_rewitemscount; } typedef std::vector<int32> PrevQuests; PrevQuests prevQuests; typedef std::vector<uint32> PrevChainQuests; PrevChainQuests prevChainQuests; // cached data private: uint32 m_reqitemscount; uint32 <API key>; uint32 <API key>; uint32 m_rewitemscount; uint32 m_detailsemotecount; // actual allowed value 0..4 bool m_isActive; // table data protected: uint32 QuestId; uint32 QuestMethod; int32 ZoneOrSort; uint32 MinLevel; int32 QuestLevel; uint32 Type; uint32 RequiredClasses; uint32 RequiredRaces; uint32 RequiredSkill; uint32 RequiredSkillValue; uint32 RequiredCondition; uint32 RepObjectiveFaction; int32 RepObjectiveValue; uint32 <API key>; int32 RequiredMinRepValue; uint32 <API key>; int32 RequiredMaxRepValue; uint32 SuggestedPlayers; uint32 LimitTime; uint32 m_QuestFlags; uint32 m_SpecialFlags; uint32 CharTitleId; int32 PrevQuestId; int32 NextQuestId; int32 ExclusiveGroup; uint32 NextQuestInChain; uint32 SrcItemId; uint32 SrcItemCount; uint32 SrcSpell; std::string Title; std::string Details; std::string Objectives; std::string OfferRewardText; std::string RequestItemsText; std::string EndText; uint32 RewHonorableKills; int32 RewOrReqMoney; uint32 RewMoneyMaxLevel; uint32 RewSpell; uint32 RewSpellCast; uint32 RewMailTemplateId; uint32 RewMailDelaySecs; uint32 PointMapId; float PointX; float PointY; uint32 PointOpt; uint32 IncompleteEmote; uint32 <API key>; uint32 CompleteEmote; uint32 CompleteEmoteDelay; uint32 QuestStartScript; uint32 QuestCompleteScript; }; enum QuestUpdateState { QUEST_UNCHANGED = 0, QUEST_CHANGED = 1, QUEST_NEW = 2 }; struct QuestStatusData { QuestStatusData() : m_status(QUEST_STATUS_NONE), m_rewarded(false), m_explored(false), m_timer(0), uState(QUEST_NEW) { memset(m_itemcount, 0, <API key> * sizeof(uint32)); memset(m_creatureOrGOcount, 0, <API key> * sizeof(uint32)); } QuestStatus m_status; bool m_rewarded; bool m_explored; uint32 m_timer; QuestUpdateState uState; uint32 m_itemcount[ <API key> ]; uint32 m_creatureOrGOcount[ <API key> ]; }; #endif
// Black-Scholes // Analytical method for calculating European Options // Reference Source: Options, Futures, and Other Derivatives, 3rd Edition, Prentice // Hall, John C. Hull, #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #ifdef ENABLE_PARSEC_HOOKS #include <hooks.h> #endif // Multi-threaded pthreads header #ifdef ENABLE_THREADS #define MAX_THREADS 128 // Add the following line so that icc 9.0 is compatible with pthread lib. #define __thread __threadp #ifdef _XOPEN_SOURCE #undef _XOPEN_SOURCE #define _XOPEN_SOURCE 700 #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef __USE_XOPEN2K #define __USE_XOPEN2K #endif #ifndef __USE_UNIX98 #define __USE_UNIX98 #endif #include <pthread.h> #include <time.h> pthread_t _M4_threadsTable[MAX_THREADS]; pthread_mutexattr_t _M4_normalMutexAttr; int _M4_numThreads = MAX_THREADS; #undef __thread #endif // Multi-threaded OpenMP header #ifdef ENABLE_OPENMP #include <omp.h> #endif // Multi-threaded header for Windows #ifdef WIN32 #pragma warning(disable : 4305) #pragma warning(disable : 4244) #include <windows.h> #define MAX_THREADS 128 #endif //Precision to use for calculations #define fptype float #define NUM_RUNS 100 typedef struct OptionData_ { fptype s; // spot price fptype strike; // strike price fptype r; // risk-free interest rate fptype divq; // dividend rate fptype v; // volatility fptype t; // time to maturity or option expiration in years // (1yr = 1.0, 6mos = 0.5, 3mos = 0.25, ..., etc) char OptionType; // Option type. "P"=PUT, "C"=CALL fptype divs; // dividend vals (not used in this test) fptype DGrefval; // DerivaGem Reference Value } OptionData; OptionData *data; fptype *prices; int numOptions; int * otype; fptype * sptprice; fptype * strike; fptype * rate; fptype * volatility; fptype * otime; int numError = 0; int nThreads; // Cumulative Normal Distribution Function // See Hull, Section 11.8, P.243-244 #define inv_sqrt_2xPI 0.<API key> fptype CNDF ( fptype InputX ) { int sign; fptype OutputX; fptype xInput; fptype xNPrimeofX; fptype expValues; fptype xK2; fptype xK2_2, xK2_3; fptype xK2_4, xK2_5; fptype xLocal, xLocal_1; fptype xLocal_2, xLocal_3; // Check for negative value of InputX if (InputX < 0.0) { InputX = -InputX; sign = 1; } else sign = 0; xInput = InputX; // Compute NPrimeX term common to both four & six decimal accuracy calcs expValues = exp(-0.5f * InputX * InputX); xNPrimeofX = expValues; xNPrimeofX = xNPrimeofX * inv_sqrt_2xPI; xK2 = 0.2316419 * xInput; xK2 = 1.0 + xK2; xK2 = 1.0 / xK2; xK2_2 = xK2 * xK2; xK2_3 = xK2_2 * xK2; xK2_4 = xK2_3 * xK2; xK2_5 = xK2_4 * xK2; xLocal_1 = xK2 * 0.319381530; xLocal_2 = xK2_2 * (-0.356563782); xLocal_3 = xK2_3 * 1.781477937; xLocal_2 = xLocal_2 + xLocal_3; xLocal_3 = xK2_4 * (-1.821255978); xLocal_2 = xLocal_2 + xLocal_3; xLocal_3 = xK2_5 * 1.330274429; xLocal_2 = xLocal_2 + xLocal_3; xLocal_1 = xLocal_2 + xLocal_1; xLocal = xLocal_1 * xNPrimeofX; xLocal = 1.0 - xLocal; OutputX = xLocal; if (sign) { OutputX = 1.0 - OutputX; } return OutputX; } // For debugging void print_xmm(fptype in, char* s) { printf("%s: %f\n", s, in); } fptype BlkSchlsEqEuroNoDiv( fptype sptprice, fptype strike, fptype rate, fptype volatility, fptype time, int otype, float timet ) { fptype OptionPrice; // local private working variables for the calculation fptype xStockPrice; fptype xStrikePrice; fptype xRiskFreeRate; fptype xVolatility; fptype xTime; fptype xSqrtTime; fptype logValues; fptype xLogTerm; fptype xD1; fptype xD2; fptype xPowerTerm; fptype xDen; fptype d1; fptype d2; fptype FutureValueX; fptype NofXd1; fptype NofXd2; fptype NegNofXd1; fptype NegNofXd2; xStockPrice = sptprice; xStrikePrice = strike; xRiskFreeRate = rate; xVolatility = volatility; xTime = time; xSqrtTime = sqrt(xTime); logValues = log( sptprice / strike ); xLogTerm = logValues; xPowerTerm = xVolatility * xVolatility; xPowerTerm = xPowerTerm * 0.5; xD1 = xRiskFreeRate + xPowerTerm; xD1 = xD1 * xTime; xD1 = xD1 + xLogTerm; xDen = xVolatility * xSqrtTime; xD1 = xD1 / xDen; xD2 = xD1 - xDen; d1 = xD1; d2 = xD2; NofXd1 = CNDF( d1 ); NofXd2 = CNDF( d2 ); FutureValueX = strike * ( exp( -(rate)*(time) ) ); if (otype == 0) { OptionPrice = (sptprice * NofXd1) - (FutureValueX * NofXd2); } else { NegNofXd1 = (1.0 - NofXd1); NegNofXd2 = (1.0 - NofXd2); OptionPrice = (FutureValueX * NegNofXd2) - (sptprice * NegNofXd1); } return OptionPrice; } #ifdef WIN32 DWORD WINAPI bs_thread(LPVOID tid_ptr){ #else int bs_thread(void *tid_ptr) { #endif int i, j; fptype price; fptype priceDelta; int tid = *(int *)tid_ptr; int start = tid * (numOptions / nThreads); int end = start + (numOptions / nThreads); for (j=0; j<NUM_RUNS; j++) { #ifdef ENABLE_OPENMP #pragma omp parallel for for (i=0; i<numOptions; i++) { #else //ENABLE_OPENMP for (i=start; i<end; i++) { #endif //ENABLE_OPENMP /* Calling main function to calculate option value based on * Black & Sholes's equation. */ price = BlkSchlsEqEuroNoDiv( sptprice[i], strike[i], rate[i], volatility[i], otime[i], otype[i], 0); prices[i] = price; #ifdef ERR_CHK priceDelta = data[i].DGrefval - price; if( fabs(priceDelta) >= 1e-4 ){ printf("Error on %d. Computed=%.5f, Ref=%.5f, Delta=%.5f\n", i, price, data[i].DGrefval, priceDelta); numError ++; } #endif } } return 0; } int main (int argc, char **argv) { FILE *file; int i; int loopnum; fptype * buffer; int * buffer2; int rv; #ifdef PARSEC_VERSION #define __PARSEC_STRING(x) #define __PARSEC_XSTRING(x) __PARSEC_STRING(x) printf("PARSEC Benchmark Suite Version "__PARSEC_XSTRING(PARSEC_VERSION)"\n"); fflush(NULL); #else printf("PARSEC Benchmark Suite\n"); fflush(NULL); #endif //PARSEC_VERSION #ifdef ENABLE_PARSEC_HOOKS <API key>(<API key>); #endif if (argc != 4) { printf("Usage:\n\t%s <nthreads> <inputFile> <outputFile>\n", argv[0]); exit(1); } nThreads = atoi(argv[1]); char *inputFile = argv[2]; char *outputFile = argv[3]; //Read input data from file file = fopen(inputFile, "r"); if(file == NULL) { printf("ERROR: Unable to open file %s.\n", inputFile); exit(1); } rv = fscanf(file, "%i", &numOptions); if(rv != 1) { printf("ERROR: Unable to read from file %s.\n", inputFile); fclose(file); exit(1); } if(nThreads > numOptions) { printf("WARNING: Not enough work, reducing number of threads to match number of options.\n"); nThreads = numOptions; } #if !defined(ENABLE_THREADS) && !defined(ENABLE_OPENMP) if(nThreads != 1) { printf("Error: <nthreads> must be 1 (serial version)\n"); exit(1); } #endif // alloc spaces for the option data data = (OptionData*)malloc(numOptions*sizeof(OptionData)); prices = (fptype*)malloc(numOptions*sizeof(fptype)); for ( loopnum = 0; loopnum < numOptions; ++ loopnum ) { rv = fscanf(file, "%f %f %f %f %f %f %c %f %f", &data[loopnum].s, &data[loopnum].strike, &data[loopnum].r, &data[loopnum].divq, &data[loopnum].v, &data[loopnum].t, &data[loopnum].OptionType, &data[loopnum].divs, &data[loopnum].DGrefval); if(rv != 9) { printf("ERROR: Unable to read from file %s with loopnum %d.\n", inputFile, loopnum); fclose(file); exit(1); } } rv = fclose(file); if(rv != 0) { printf("ERROR: Unable to close file %s.\n", inputFile); exit(1); } #ifdef ENABLE_THREADS // <API key>( &_M4_normalMutexAttr); // <API key>( &_M4_normalMutexAttr, <API key>); _M4_numThreads = nThreads; { int _M4_i; for ( _M4_i = 0; _M4_i < MAX_THREADS; _M4_i++) { _M4_threadsTable[_M4_i] = (pthread_t) -1; } } ; #endif printf("Num of Options: %d\n", numOptions); printf("Num of Runs: %d\n", NUM_RUNS); #define PAD 256 #define LINESIZE 64 buffer = (fptype *) malloc(5 * numOptions * sizeof(fptype) + PAD); sptprice = (fptype *) (((unsigned long long)buffer + PAD) & ~(LINESIZE - 1)); strike = sptprice + numOptions; rate = strike + numOptions; volatility = rate + numOptions; otime = volatility + numOptions; buffer2 = (int *) malloc(numOptions * sizeof(fptype) + PAD); otype = (int *) (((unsigned long long)buffer2 + PAD) & ~(LINESIZE - 1)); for (i=0; i<numOptions; i++) { otype[i] = (data[i].OptionType == 'P') ? 1 : 0; sptprice[i] = data[i].s; strike[i] = data[i].strike; rate[i] = data[i].r; volatility[i] = data[i].v; otime[i] = data[i].t; } printf("Size of data: %d\n", numOptions * (sizeof(OptionData) + sizeof(int))); #ifdef ENABLE_PARSEC_HOOKS __parsec_roi_begin(); #endif #ifdef ENABLE_THREADS int tids[nThreads]; pthread_t thread_table[nThreads]; for(i=0; i<nThreads; i++) { tids[i]=i; } for(i=0; i<nThreads; i++) { // fprintf(stderr, "create %d thread\n", i); pthread_create(&thread_table[i],NULL,(void *(*)(void *))bs_thread,(void *)&tids[i]); } for(i=0; i<nThreads; i++) { pthread_join(thread_table[i], NULL); } #else//ENABLE_THREADS #ifdef ENABLE_OPENMP { int tid=0; omp_set_num_threads(nThreads); bs_thread(&tid); } #else //ENABLE_OPENMP #ifdef WIN32 if (nThreads > 1) { HANDLE threads[MAX_THREADS]; int nums[MAX_THREADS]; for(i=0; i<nThreads; i++) { nums[i] = i; threads[i] = CreateThread(0, 0, bs_thread, &nums[i], 0, 0); } <API key>(nThreads, threads, TRUE, INFINITE); } else #endif { int tid=0; bs_thread(&tid); } #endif //ENABLE_OPENMP #endif //ENABLE_THREADS #ifdef ENABLE_PARSEC_HOOKS __parsec_roi_end(); #endif //Write prices to output file file = fopen(outputFile, "w"); if(file == NULL) { printf("ERROR: Unable to open file %s.\n", outputFile); exit(1); } rv = fprintf(file, "%i\n", numOptions); if(rv < 0) { printf("ERROR: Unable to write to file %s.\n", outputFile); fclose(file); exit(1); } for(i=0; i<numOptions; i++) { rv = fprintf(file, "%.18f\n", prices[i]); if(rv < 0) { printf("ERROR: Unable to write to file %s.\n", outputFile); fclose(file); exit(1); } } rv = fclose(file); if(rv != 0) { printf("ERROR: Unable to close file %s.\n", outputFile); exit(1); } #ifdef ERR_CHK printf("Num Errors: %d\n", numError); #endif free(data); free(prices); #ifdef ENABLE_PARSEC_HOOKS __parsec_bench_end(); #endif return 0; }
#include <bsp.h> #include <rtems/libio.h> #include <termios.h> #include <at91rm9200.h> #include <at91rm9200_dbgu.h> #include <at91rm9200_pmc.h> #include <rtems/bspIo.h> #include <libchip/serial.h> #include <libchip/sersupp.h> volatile int dbg_dly; /* static function prototypes */ static int dbgu_first_open(int major, int minor, void *arg); static int dbgu_last_close(int major, int minor, void *arg); static int dbgu_read(int minor); static ssize_t dbgu_write(int minor, const char *buf, size_t len); static void dbgu_init(int minor); static void dbgu_write_polled(int minor, char c); static int dbgu_set_attributes(int minor, const struct termios *t); /* Pointers to functions for handling the UART. */ console_fns dbgu_fns = { <API key>, dbgu_first_open, dbgu_last_close, dbgu_read, dbgu_write, dbgu_init, dbgu_write_polled, /* not used in this driver */ dbgu_set_attributes, FALSE /* TRUE if interrupt driven, FALSE if not. */ }; /* Functions called via callbacks (i.e. the ones in uart_fns */ /* * This is called the first time each device is opened. Since * the driver is polled, we don't have to do anything. If the driver * were interrupt driven, we'd enable interrupts here. */ static int dbgu_first_open(int major, int minor, void *arg) { return 0; } /* * This is called the last time each device is closed. Since * the driver is polled, we don't have to do anything. If the driver * were interrupt driven, we'd disable interrupts here. */ static int dbgu_last_close(int major, int minor, void *arg) { return 0; } /* * Read one character from UART. * * return -1 if there's no data, otherwise return * the character in lowest 8 bits of returned int. */ static int dbgu_read(int minor) { char c; console_tbl *console_entry; <API key> *dbgu; console_entry = <API key>(minor); if (console_entry == NULL) { return -1; } dbgu = (<API key> *)console_entry->ulCtrlPort1; if (!(dbgu->sr & DBGU_INT_RXRDY)) { return -1; } c = dbgu->rhr & 0xff; return c; } /* * Write buffer to UART * * return 1 on success, -1 on error */ static ssize_t dbgu_write(int minor, const char *buf, size_t len) { int i, x; char c; console_tbl *console_entry; <API key> *dbgu; console_entry = <API key>(minor); if (console_entry == NULL) { return -1; } dbgu = (<API key> *)console_entry->ulCtrlPort1; for (i = 0; i < len; i++) { /* Wait for fifo to have room */ while(1) { if (dbgu->sr & DBGU_INT_TXRDY) { break; } } c = (char) buf[i]; dbgu->thr = c; /* the TXRDY flag does not seem to update right away (is this true?) */ /* so we wait a bit before continuing */ for (x = 0; x < 100; x++) { dbg_dly++; /* using a global so this doesn't get optimized out */ } } return 1; } /* Set up the UART. */ static void dbgu_init(int minor) { console_tbl *console_entry; <API key> *dbgu; console_entry = <API key>(minor); if (console_entry == NULL) { return; } dbgu = (<API key> *)console_entry->ulCtrlPort1; /* Clear error bits, and reset */ dbgu->cr = (DBGU_CR_RSTSTA | DBGU_CR_RSTTX | DBGU_CR_RSTRX); /* Clear pending interrupts */ dbgu->idr = DBGU_INT_ALL; dbgu->imr = 0; /* Set port to no parity, no loopback */ dbgu->mr = DBGU_MR_PAR_NONE | DBGU_MR_CHMODE_NORM; /* Set the baud rate */ dbgu->brgr = (at91rm9200_get_mck() / 16) / BSP_get_baud(); /* Enable the DBGU */ dbgu->cr = (DBGU_CR_TXEN | DBGU_CR_RXEN); } /* This is used for getchark support */ static void dbgu_write_polled(int minor, char c) { dbgu_write(minor, &c, 1); } /* This is for setting baud rate, bits, etc. */ static int dbgu_set_attributes(int minor, const struct termios *t) { return 0; } /* * The following functions are not used by TERMIOS, but other RTEMS * functions use them instead. */ /* * Read from UART. This is used in the exit code, and can't * rely on interrupts. */ int dbgu_poll_read(int minor) { return dbgu_read(minor); } /* * Write a character to the console. This is used by printk() and * maybe other low level functions. It should not use interrupts or any * RTEMS system calls. It needs to be very simple */ static void _BSP_put_char( char c ) { dbgu_write_polled(0, c); if ( c == '\n' ) dbgu_write_polled(0, '\r'); } <API key> BSP_output_char = _BSP_put_char; int _BSP_poll_char(void) { return dbgu_poll_read(0); } <API key> BSP_poll_char = _BSP_poll_char;
package main import ( "runtime" "strings" "github.com/gin-gonic/gin" "go.bug.st/serial" ) func infoHandler(c *gin.Context) { host := c.Request.Host parts := strings.Split(host, ":") host = parts[0] c.JSON(200, gin.H{ "version": version, "http": "http://" + host + port, "https": "https://localhost" + portSSL, "ws": "ws://" + host + port, "wss": "wss://localhost" + portSSL, "origins": origins, "update_url": updateUrl, "os": runtime.GOOS + ":" + runtime.GOARCH, }) } func pauseHandler(c *gin.Context) { go func() { ports, _ := serial.GetPortsList() for _, element := range ports { spClose(element) } *hibernate = true Systray.Pause() }() c.JSON(200, nil) }
#define _GNU_SOURCE #define NETMAP_WITH_LIBS #include <poll.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <unistd.h> #include <net/netmap_user.h> #include <netinet/ether.h> #include <sys/ioctl.h> #include <pico_ipv4.h> #include <pico_stack.h> #include <pico_socket.h> #define BSIZE 2048 struct { char *if_mac; char *if_name; char *if_addr; char *port; } config; void setup_tcp_app(); void pico_netmap_destroy(struct pico_device *dev); struct pico_device *pico_netmap_create(char *interface, char *name, uint8_t *mac); static char recvbuf[BSIZE]; static int pos = 0; static int len = 0; static int flag = 0; void deferred_exit(pico_time __attribute__((unused)) now, void *arg) { if (arg) { free(arg); arg = NULL; } exit(0); } int send_tcpecho(struct pico_socket *s) { int w, ww = 0; if (len > pos) { do { w = pico_socket_write(s, recvbuf + pos, len - pos); if (w > 0) { pos += w; ww += w; if (pos >= len) { pos = 0; len = 0; } } } while((w > 0) && (pos < len)); } return ww; } void cb_tcpecho(uint16_t ev, struct pico_socket *s) { int r = 0; printf("tcpecho> wakeup ev=%u\n", ev); if (ev & PICO_SOCK_EV_RD) { if (flag & PICO_SOCK_EV_CLOSE) { printf("SOCKET> EV_RD, FIN RECEIVED\n"); } while (len < BSIZE) { r = pico_socket_read(s, recvbuf + len, BSIZE - len); if (r > 0) { len += r; flag &= ~(PICO_SOCK_EV_RD); } else { flag |= PICO_SOCK_EV_RD; break; } } if (flag & PICO_SOCK_EV_WR) { flag &= ~PICO_SOCK_EV_WR; send_tcpecho(s); } } if (ev & PICO_SOCK_EV_CONN) { struct pico_socket *sock_a = { 0 }; struct pico_ip4 orig = { 0 }; uint16_t port = 0; char peer[30] = { 0 }; int yes = 1; sock_a = pico_socket_accept(s, &orig, &port); pico_ipv4_to_string(peer, orig.addr); printf("Connection established with %s:%d.\n", peer, short_be(port)); <API key>(sock_a, PICO_TCP_NODELAY, &yes); } if (ev & PICO_SOCK_EV_FIN) { printf("Socket closed. Exit normally. \n"); pico_timer_add(2000, deferred_exit, NULL); } if (ev & PICO_SOCK_EV_ERR) { printf("Socket error received: %s. Bailing out.\n", strerror(pico_err)); exit(1); } if (ev & PICO_SOCK_EV_CLOSE) { printf("Socket received close from peer.\n"); if (flag & PICO_SOCK_EV_RD) { <API key>(s, PICO_SHUT_WR); printf("SOCKET> Called shutdown write, ev = %d\n", ev); } } if (ev & PICO_SOCK_EV_WR) { r = send_tcpecho(s); if (r == 0) { flag |= PICO_SOCK_EV_WR; } else { flag &= (~PICO_SOCK_EV_WR); } } } void setup_tcp_app() { struct pico_socket *listen_socket; struct pico_ip4 address; uint16_t port; int ret, yes; yes = 1; port = short_be(atoi(config.port)); bzero(&address, sizeof(address)); listen_socket = pico_socket_open(PICO_PROTO_IPV4, PICO_PROTO_TCP, &cb_tcpecho); if (!listen_socket) { printf("cannot open socket: %s", strerror(pico_err)); exit(1); } <API key>(listen_socket, PICO_TCP_NODELAY, &yes); ret = pico_socket_bind(listen_socket, &address, &port); if (ret < 0) { printf("cannot bind socket to port %u: %s", short_be(port), strerror(pico_err)); exit(1); } ret = pico_socket_listen(listen_socket, 40); if (ret != 0) { printf("cannot listen on port %u", short_be(port)); exit(1); } return; } struct pico_device_netmap { struct pico_device dev; struct nm_desc *conn; }; int pico_netmap_send(struct pico_device *dev, void *buf, int len) { struct pico_device_netmap *netmap = (struct pico_device_netmap *) dev; return nm_inject(netmap->conn, buf, len); } void pico_dev_netmap_cb(u_char *u, const struct nm_pkthdr *h, const uint8_t *buf) { struct pico_device *dev = (struct pico_device *) u; pico_stack_recv(dev, (uint8_t *) buf, (uint32_t) h->len); } int pico_netmap_poll(struct pico_device *dev, int loop_score) { struct pico_device_netmap *netmap; struct pollfd fds; netmap = (struct pico_device_netmap *) dev; fds.fd = NETMAP_FD(netmap->conn); fds.events = POLLIN; do { if (poll(&fds, 1, 0) <= 0) { return loop_score; } loop_score -= nm_dispatch(netmap->conn, loop_score, pico_dev_netmap_cb, (u_char *) netmap); } while(loop_score > 0); return 0; } void pico_netmap_destroy(struct pico_device *dev) { struct pico_device_netmap *netmap = (struct pico_device_netmap *) dev; nm_close(netmap->conn); } struct pico_device * pico_netmap_create(char *interface, char *name, uint8_t *mac) { struct pico_device_netmap *netmap; char ifname[IFNAMSIZ + 7]; netmap = PICO_ZALLOC(sizeof(struct pico_device_netmap)); if (!netmap) { return NULL; } if (pico_device_init((struct pico_device *)netmap, name, mac)) { pico_netmap_destroy((struct pico_device *)netmap); return NULL; } sprintf(ifname, "netmap:%s", interface); netmap->dev.overhead = 0; netmap->conn = nm_open(ifname, NULL, 0, 0); if (! netmap->conn) { pico_netmap_destroy((struct pico_device *)netmap); return NULL; } netmap->dev.send = pico_netmap_send; netmap->dev.poll = pico_netmap_poll; netmap->dev.destroy = pico_netmap_destroy; return (struct pico_device *) netmap; } void init_picotcp() { struct ether_addr mac; struct pico_device *dev = NULL; struct pico_ip4 addr; struct pico_ip4 netm; ether_aton_r(config.if_mac, &mac); pico_stack_init(); dev = pico_netmap_create(config.if_name, "eth_if", (uint8_t *) &mac); pico_string_to_ipv4(config.if_addr, &addr.addr); pico_string_to_ipv4("255.255.255.0", &netm.addr); pico_ipv4_link_add(dev, addr, netm); } int main(int argc, char *argv[]) { if (argc < 4) { printf("usage: %s if_name if_mac if_addr port\n", argv[0]); exit(1); } config.if_name = argv[1]; config.if_mac = argv[2]; config.if_addr = argv[3]; config.port = argv[4]; init_picotcp(); setup_tcp_app(); pico_stack_loop(); return 0; }
// C++ code generated with wxFormBuilder (version Nov 6 2013) // PLEASE DO "NOT" EDIT THIS FILE! #ifndef <API key> #define <API key> #include <wx/artprov.h> #include <wx/xrc/xmlres.h> #include <wx/intl.h> #include <wx/scrolwin.h> #include <wx/gdicmn.h> #include <wx/font.h> #include <wx/colour.h> #include <wx/settings.h> #include <wx/string.h> #include <wx/bitmap.h> #include <wx/image.h> #include <wx/icon.h> #include <wx/notebook.h> #include <wx/stattext.h> #include <wx/textctrl.h> #include <wx/sizer.h> #include <wx/statbox.h> #include <wx/button.h> #include <wx/radiobox.h> #include <wx/slider.h> #include <wx/panel.h> #include <wx/statusbr.h> #include <wx/frame.h> Class BM2CMP_FRAME_BASE class BM2CMP_FRAME_BASE : public wxFrame { private: protected: wxNotebook* m_notebook1; wxScrolledWindow* <API key>; wxScrolledWindow* <API key>; wxScrolledWindow* m_BNPicturePanel; wxPanel* m_panelRight; wxStaticText* m_staticTextSize; wxStaticText* m_SizeXValue; wxStaticText* m_SizeYValue; wxStaticText* m_SizePixUnits; wxStaticText* m_staticTextSize1; wxStaticText* m_SizeXValue_mm; wxStaticText* m_SizeYValue_mm; wxStaticText* m_Size_mmxUnits; wxStaticText* m_staticTextBPP; wxStaticText* m_BPPValue; wxStaticText* m_BPPunits; wxStaticText* m_staticTextBPI; wxTextCtrl* m_DPIValueX; wxTextCtrl* m_DPIValueY; wxStaticText* m_DPI_Units; wxButton* m_buttonLoad; wxButton* m_buttonExport; wxRadioBox* m_radioBoxFormat; wxRadioBox* m_rbOptions; wxStaticText* m_ThresholdText; wxSlider* m_sliderThreshold; wxStatusBar* m_statusBar; // Virtual event handlers, overide them in your derived class virtual void OnPaint( wxPaintEvent& event ) { event.Skip(); } virtual void UpdatePPITextValueX( wxMouseEvent& event ) { event.Skip(); } virtual void OnResolutionChange( wxCommandEvent& event ) { event.Skip(); } virtual void UpdatePPITextValueY( wxMouseEvent& event ) { event.Skip(); } virtual void OnLoadFile( wxCommandEvent& event ) { event.Skip(); } virtual void OnExport( wxCommandEvent& event ) { event.Skip(); } virtual void OnOptionsSelection( wxCommandEvent& event ) { event.Skip(); } virtual void OnThresholdChange( wxScrollEvent& event ) { event.Skip(); } public: BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bitmap to Component Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 527,470 ), long style = <API key>|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); ~BM2CMP_FRAME_BASE(); }; #endif //<API key>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>git resources &mdash; NumPy v1.10 Manual</title> <link rel="stylesheet" type="text/css" href="../../static_/css/spc-bootstrap.css"> <link rel="stylesheet" type="text/css" href="../../static_/css/spc-extend.css"> <link rel="stylesheet" href="../../static_/scipy.css" type="text/css" > <link rel="stylesheet" href="../../static_/pygments.css" type="text/css" > <script type="text/javascript"> var <API key> = { URL_ROOT: '../../', VERSION: '1.10.1', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: false }; </script> <script type="text/javascript" src="../../static_/jquery.js"></script> <script type="text/javascript" src="../../static_/underscore.js"></script> <script type="text/javascript" src="../../static_/doctools.js"></script> <script type="text/javascript" src="../../static_/js/copybutton.js"></script> <link rel="author" title="About these documents" href="../../about.html" > <link rel="top" title="NumPy v1.10 Manual" href="../../index.html" > <link rel="up" title="Working with NumPy source code" href="index.html" > <link rel="next" title="Setting up and using your development environment" href="../<API key>.html" > <link rel="prev" title="Development workflow" href="<API key>.html" > </head> <body> <div class="container"> <div class="header"> </div> </div> <div class="container"> <div class="main"> <div class="row-fluid"> <div class="span12"> <div class="spc-navbar"> <ul class="nav nav-pills pull-left"> <li class="active"><a href="../../index.html">NumPy v1.10 Manual</a></li> <li class="active"><a href="../index.html" >Contributing to Numpy</a></li> <li class="active"><a href="index.html" accesskey="U">Working with <em>NumPy</em> source code</a></li> </ul> <ul class="nav nav-pills pull-right"> <li class="active"> <a href="../../genindex.html" title="General Index" accesskey="I">index</a> </li> <li class="active"> <a href="../<API key>.html" title="Setting up and using your development environment" accesskey="N">next</a> </li> <li class="active"> <a href="<API key>.html" title="Development workflow" accesskey="P">previous</a> </li> </ul> </div> </div> </div> <div class="row-fluid"> <div class="spc-rightsidebar span3"> <div class="<API key>"> <h3><a href="../../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">git resources</a><ul> <li><a class="reference internal" href="#<API key>">Tutorials and summaries</a></li> <li><a class="reference internal" href="#<API key>">Advanced git workflow</a></li> <li><a class="reference internal" href="#manual-pages-online">Manual pages online</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="<API key>.html" title="previous chapter">Development workflow</a></p> <h4>Next topic</h4> <p class="topless"><a href="../<API key>.html" title="next chapter">Setting up and using your development environment</a></p> </div> </div> <div class="span9"> <div class="bodywrapper"> <div class="body" id="spc-section-body"> <div class="section" id="git-resources"> <span id="id1"></span><h1><a class="reference external" href="http://git-scm.com/">git</a> resources<a class="headerlink" href=" <div class="section" id="<API key>"> <h2>Tutorials and summaries<a class="headerlink" href=" <ul class="simple"> <li><a class="reference external" href="http://help.github.com">github help</a> has an excellent series of how-to guides.</li> <li><a class="reference external" href="http://learn.github.com/">learn.github</a> has an excellent series of tutorials</li> <li>The <a class="reference external" href="http://progit.org/">pro git book</a> is a good in-depth book on git.</li> <li>A <a class="reference external" href="http://github.com/guides/git-cheat-sheet">git cheat sheet</a> is a page giving summaries of common commands.</li> <li>The <a class="reference external" href="http: <li>The <a class="reference external" href="http: <li>The <a class="reference external" href="http://book.git-scm.com/">git community book</a></li> <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http://www-cs-students.stanford.edu/~blynn/gitmagic/index.html">git magic</a> - extended introduction with intermediate detail</li> <li>The <a class="reference external" href="http://tom.preston-werner.com/2009/05/19/the-git-parable.html">git parable</a> is an easy read explaining the concepts behind git.</li> <li>Our own <a class="reference external" href="http: <li>Fernando Perez& <li>A good but technical page on <a class="reference external" href="http: <li><a class="reference external" href="http: </ul> </div> <div class="section" id="<API key>"> <h2>Advanced git workflow<a class="headerlink" href=" <p>There are many ways of working with <a class="reference external" href="http://git-scm.com/">git</a>; here are some posts on the rules of thumb that other projects have come up with:</p> <ul class="simple"> <li>Linus Torvalds on <a class="reference external" href="http://kerneltrap.org/Linux/Git_Management">git management</a></li> <li>Linus Torvalds on <a class="reference external" href="http://www.mail-archive.com/dri-devel&#64;lists.sourceforge.net/msg39091.html">linux git workflow</a> . Summary; use the git tools to make the history of your edits as clean as possible; merge from upstream edits as little as possible in branches where you are doing active development.</li> </ul> </div> <div class="section" id="manual-pages-online"> <h2>Manual pages online<a class="headerlink" href=" <p>You can get these on your own machine with (e.g) <tt class="docutils literal"><span class="pre">git</span> <span class="pre">help</span> <span class="pre">push</span></tt> or (same thing) <tt class="docutils literal"><span class="pre">git</span> <span class="pre">push</span> <span class="pre">--help</span></tt>, but, for convenience, here are the online manual pages for some common commands:</p> <ul class="simple"> <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: <li><a class="reference external" href="http: </ul> </div> </div> </div> </div> </div> </div> </div> </div> <div class="container <API key>"> <div class="spc-navbar"> </div> </div> <div class="container"> <div class="footer"> <div class="row-fluid"> <ul class="inline pull-left"> <li> &copy; Copyright 2008-2009, The Scipy community. </li> <li> Last updated on Oct 18, 2015. </li> <li> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2.1. </li> </ul> </div> </div> </div> </body> </html>
<!DOCTYPE HTML> <! Alpha by HTML5 UP html5up.net | @n33co Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) <html> <head> <title>{{ page.title }}</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <!--[if lte IE 8]><script src="{{ site.baseurl }}/assets/css/ie/html5shiv.js"></script><![endif]--> <script src="{{ site.baseurl }}/assets/js/jquery.min.js"></script> <script src="{{ site.baseurl }}/assets/js/jquery.dropotron.min.js"></script> <script src="{{ site.baseurl }}/assets/js/skel.min.js"></script> <script src="{{ site.baseurl }}/assets/js/skel-layers.min.js"></script> <script src="{{ site.baseurl }}/assets/js/jquery.scrollgress.min.js"></script> <script src="{{ site.baseurl }}/assets/js/init.js"></script> <noscript> <link rel="stylesheet" href="{{ site.baseurl }}/assets/css/skel.css" /> <link rel="stylesheet" href="{{ site.baseurl }}/assets/css/style.css" /> <link rel="stylesheet" href="{{ site.baseurl }}/assets/css/pattern.css" /> <link rel="stylesheet" href="{{ site.baseurl }}/assets/css/style-desktop.css" /> </noscript> <!--[if lte IE 8]><link rel="stylesheet" href="{{ site.baseurl }}/assets/css/ie/v8.css" /><![endif]--> </head> {% if page.url == "/index.html" %} <!-- Banner --> <body class="landing"> <section id="banner"> <h2>Hello, I am Yathannsh Kulshrestha</h2> <h3><b><font color= "white">Developer.&nbsp;Programmer.&nbsp; Creative.&nbsp; Innovator</font><b></h3> <ul class="actions"><br><br> <li><a href="#know" class="button">know More</a></li> </ul> </section> {% else %} <body> <section id="banner"></section> {% endif %} {% include nav.html %} <!-- Main --> <section id="main" class="container">
<?php add_action( 'wp_enqueue_scripts', '<API key>' ); function <API key>() { wp_enqueue_style( 'wpe-styles', get_stylesheet_uri() ); } add_action( 'after_switch_theme', '<API key>' ); function <API key>() { add_option('wpe_b1_theme',md5(rand())); $dir = <API key>(); require $dir . '/inc/identicon-mod.php'; if(function_exists('<API key>')) { try { for($i=0;$i<5;++$i) { $img = identicon_fromhash(md5(rand()), 200); imagepng($img, $dir . '/img/'.$i.'.png'); } } catch(Exception $e) {} } } ?>
#ifndef BRUSHTOOL_H #define BRUSHTOOL_H #include "stroketool.h" #include "bitmapimage.h" class BrushTool : public StrokeTool { Q_OBJECT public: explicit BrushTool( QObject *parent = 0 ); ToolType type() override; void loadSettings() override; QCursor cursor() override; void mouseMoveEvent( QMouseEvent* ) override; void mousePressEvent( QMouseEvent* ) override; void mouseReleaseEvent( QMouseEvent* ) override; void tabletMoveEvent( QTabletEvent* ) override; void tabletPressEvent( QTabletEvent* ) override; void tabletReleaseEvent( QTabletEvent* ) override; void <API key>( qreal pressure, bool mouseDevice ) override; void drawStroke(); void paintVectorStroke(); void paintBitmapStroke(); void paintAt( QPointF point ); void setWidth( const qreal width ) override; void setFeather( const qreal feather ) override; void setUseFeather( const bool usingFeather ) override; void setPressure( const bool pressure ) override; void setInvisibility( const bool invisibility) override; void setAA( const int useAA ) override; void setStabilizerLevel( const int level ) override; protected: QPointF mLastBrushPoint; QPointF mMouseDownPoint; BitmapImage mImg; QColor <API key>; qreal mOpacity; }; #endif // BRUSHTOOL_H
/* $Id: QIArrowButtonPress.h 55401 2015-04-23 10:03:17Z vboxsync $ */ /** @file * VBox Qt GUI - QIArrowButtonPress class declaration. */ #ifndef <API key> #define <API key> /* GUI includes: */ #include "QIRichToolButton.h" #include "QIWithRetranslateUI.h" /** QIRichToolButton extension * representing arrow tool-button with text-label, * can be used as back/next buttons in various places. */ class QIArrowButtonPress : public QIWithRetranslateUI<QIRichToolButton> { Q_OBJECT; public: /** Button types. */ enum ButtonType { ButtonType_Back, ButtonType_Next }; /** Constructor, passes @a pParent to the QIRichToolButton constructor. * @param buttonType is used to define which type of the button it is. */ QIArrowButtonPress(ButtonType buttonType, QWidget *pParent = 0); protected: /** Retranslation routine. * @todo Fix translation context. */ virtual void retranslateUi(); /** Key-press-event handler. */ virtual void keyPressEvent(QKeyEvent *pEvent); private: /** Holds the button-type. */ ButtonType m_buttonType; }; #endif /* !<API key> */
<!DOCTYPE HTML PUBLIC "- <!--NewPage <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_20) on Sun May 04 12:45:13 EDT 2014 --> <TITLE> FtpHost (JFtp) </TITLE> <META NAME="date" CONTENT="2014-05-04"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="FtpHost (JFtp)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <A NAME="navbar_top"></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <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="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</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;<A HREF="../../../../../net/sf/jftp/gui/base/DownloadQueue.html" title="class in net.sf.jftp.gui.base"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../../../net/sf/jftp/gui/base/LocalDir.html" title="class in net.sf.jftp.gui.base"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?net/sf/jftp/gui/base/FtpHost.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="FtpHost.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <HR> <H2> <FONT SIZE="-1"> net.sf.jftp.gui.base</FONT> <BR> Class FtpHost</H2> <PRE> java.lang.Object <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>net.sf.jftp.gui.base.FtpHost</B> </PRE> <HR> <DL> <DT><PRE>public class <B>FtpHost</B><DT>extends java.lang.Object</DL> </PRE> <P> <HR> <P> <A NAME="field_summary"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Field Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../net/sf/jftp/gui/base/FtpHost.html#hostname">hostname</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../net/sf/jftp/gui/base/FtpHost.html#name">name</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../net/sf/jftp/gui/base/FtpHost.html#password">password</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../net/sf/jftp/gui/base/FtpHost.html#port">port</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../net/sf/jftp/gui/base/FtpHost.html#username">username</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <A NAME="constructor_summary"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Constructor Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><B><A HREF="../../../../../net/sf/jftp/gui/base/FtpHost.html#FtpHost()">FtpHost</A></B>()</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" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../net/sf/jftp/gui/base/FtpHost.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>.lang.Object"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="<API key>"> <TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait</CODE></TD> </TR> </TABLE> &nbsp; <P> <A NAME="field_detail"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Field Detail</B></FONT></TH> </TR> </TABLE> <A NAME="name"></A><H3> name</H3> <PRE> public java.lang.String <B>name</B></PRE> <DL> <DL> </DL> </DL> <HR> <A NAME="hostname"></A><H3> hostname</H3> <PRE> public java.lang.String <B>hostname</B></PRE> <DL> <DL> </DL> </DL> <HR> <A NAME="username"></A><H3> username</H3> <PRE> public java.lang.String <B>username</B></PRE> <DL> <DL> </DL> </DL> <HR> <A NAME="password"></A><H3> password</H3> <PRE> public java.lang.String <B>password</B></PRE> <DL> <DL> </DL> </DL> <HR> <A NAME="port"></A><H3> port</H3> <PRE> public java.lang.String <B>port</B></PRE> <DL> <DL> </DL> </DL> <A NAME="constructor_detail"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Constructor Detail</B></FONT></TH> </TR> </TABLE> <A NAME="FtpHost()"></A><H3> FtpHost</H3> <PRE> public <B>FtpHost</B>()</PRE> <DL> </DL> <A NAME="method_detail"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="toString()"></A><H3> toString</H3> <PRE> public java.lang.String <B>toString</B>()</PRE> <DL> <DD><DL> <DT><B>Overrides:</B><DD><CODE>toString</CODE> in class <CODE>java.lang.Object</CODE></DL> </DD> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="navbar_bottom"></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="<API key>"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <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="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</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;<A HREF="../../../../../net/sf/jftp/gui/base/DownloadQueue.html" title="class in net.sf.jftp.gui.base"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../../../net/sf/jftp/gui/base/LocalDir.html" title="class in net.sf.jftp.gui.base"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?net/sf/jftp/gui/base/FtpHost.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="FtpHost.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <HR> </BODY> </HTML>
#ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <errno.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/ioctl.h> #include <sys/wait.h> #include <bluetooth/bluetooth.h> #include <bluetooth/hci.h> #include <bluetooth/hci_lib.h> #include <glib.h> #include "hcid.h" #include "sdpd.h" #include "adapter.h" #include "plugin.h" #include "log.h" #include "manager.h" static int child_pipe[2] = { -1, -1 }; static guint child_io_id = 0; static guint ctl_io_id = 0; static gboolean child_exit(GIOChannel *io, GIOCondition cond, void *user_data) { int status, fd = <API key>(io); pid_t child_pid; if (read(fd, &child_pid, sizeof(child_pid)) != sizeof(child_pid)) { error("child_exit: unable to read child pid from pipe"); return TRUE; } if (waitpid(child_pid, &status, 0) != child_pid) error("waitpid(%d) failed", child_pid); else DBG("child %d exited", child_pid); return TRUE; } static void at_child_exit(void) { pid_t pid = getpid(); if (write(child_pipe[1], &pid, sizeof(pid)) != sizeof(pid)) error("unable to write to child pipe"); } static void configure_device(int index) { struct hci_dev_info di; uint16_t policy; int dd, err; if (hci_devinfo(index, &di) < 0) return; if (hci_test_bit(HCI_RAW, &di.flags)) return; dd = hci_open_dev(index); if (dd < 0) { err = errno; error("Can't open device hci%d: %s (%d)", index, strerror(err), err); return; } /* Set page timeout */ if ((main_opts.flags & (1 << HCID_SET_PAGETO))) { <API key> cp; cp.timeout = htobs(main_opts.pageto); hci_send_cmd(dd, OGF_HOST_CTL, <API key>, <API key>, &cp); } /* Set default link policy */ policy = htobs(main_opts.link_policy); hci_send_cmd(dd, OGF_LINK_POLICY, <API key>, 2, &policy); hci_close_dev(dd); } static void init_device(int index) { struct hci_dev_req dr; struct hci_dev_info di; pid_t pid; int dd, err; /* Do initialization in the separate process */ pid = fork(); switch (pid) { case 0: atexit(at_child_exit); break; case -1: err = errno; error("Fork failed. Can't init device hci%d: %s (%d)", index, strerror(err), err); default: DBG("child %d forked", pid); return; } dd = hci_open_dev(index); if (dd < 0) { err = errno; error("Can't open device hci%d: %s (%d)", index, strerror(err), err); exit(1); } memset(&dr, 0, sizeof(dr)); dr.dev_id = index; /* Set link mode */ dr.dev_opt = main_opts.link_mode; if (ioctl(dd, HCISETLINKMODE, (unsigned long) &dr) < 0) { err = errno; error("Can't set link mode on hci%d: %s (%d)", index, strerror(err), err); } /* Set link policy */ dr.dev_opt = main_opts.link_policy; if (ioctl(dd, HCISETLINKPOL, (unsigned long) &dr) < 0 && errno != ENETDOWN) { error("Can't set link policy on hci%d: %s (%d)", index, strerror(errno), errno); } /* Start HCI device */ if (ioctl(dd, HCIDEVUP, index) < 0 && errno != EALREADY) { error("Can't init device hci%d: %s (%d)", index, strerror(errno), errno); goto fail; } if (hci_devinfo(index, &di) < 0) goto fail; if (hci_test_bit(HCI_RAW, &di.flags)) goto done; done: hci_close_dev(dd); exit(0); fail: hci_close_dev(dd); exit(1); } static void device_devreg_setup(int index) { struct hci_dev_info di; gboolean devup; init_device(index); memset(&di, 0, sizeof(di)); if (hci_devinfo(index, &di) < 0) return; devup = hci_test_bit(HCI_UP, &di.flags); if (!hci_test_bit(HCI_RAW, &di.flags)) <API key>(index, devup); } static void device_devup_setup(int index) { configure_device(index); <API key>(index); /* Return value 1 means ioctl(DEVDOWN) was performed */ if (<API key>(index) == 1) <API key>(index); } static void device_event(int event, int index) { switch (event) { case HCI_DEV_REG: info("HCI dev %d registered", index); device_devreg_setup(index); break; case HCI_DEV_UNREG: info("HCI dev %d unregistered", index); <API key>(index); break; case HCI_DEV_UP: info("HCI dev %d up", index); device_devup_setup(index); break; case HCI_DEV_DOWN: info("HCI dev %d down", index); <API key>(index); <API key>(index); break; } } static int init_known_adapters(int ctl) { struct hci_dev_list_req *dl; struct hci_dev_req *dr; int i, err; dl = g_try_malloc0(HCI_MAX_DEV * sizeof(struct hci_dev_req) + sizeof(uint16_t)); if (!dl) { err = errno; error("Can't allocate devlist buffer: %s (%d)", strerror(err), err); return -err; } dl->dev_num = HCI_MAX_DEV; dr = dl->dev_req; if (ioctl(ctl, HCIGETDEVLIST, (void *) dl) < 0) { err = errno; error("Can't get device list: %s (%d)", strerror(err), err); g_free(dl); return -err; } for (i = 0; i < dl->dev_num; i++, dr++) { device_event(HCI_DEV_REG, dr->dev_id); if (hci_test_bit(HCI_UP, &dr->dev_opt)) device_event(HCI_DEV_UP, dr->dev_id); } g_free(dl); return 0; } static gboolean io_stack_event(GIOChannel *chan, GIOCondition cond, gpointer data) { unsigned char buf[HCI_MAX_FRAME_SIZE], *ptr; evt_stack_internal *si; evt_si_device *sd; hci_event_hdr *eh; int type; size_t len; GIOError err; ptr = buf; err = g_io_channel_read(chan, (gchar *) buf, sizeof(buf), &len); if (err) { if (err == G_IO_ERROR_AGAIN) return TRUE; error("Read from control socket failed: %s (%d)", strerror(errno), errno); return FALSE; } type = *ptr++; if (type != HCI_EVENT_PKT) return TRUE; eh = (hci_event_hdr *) ptr; if (eh->evt != EVT_STACK_INTERNAL) return TRUE; ptr += HCI_EVENT_HDR_SIZE; si = (evt_stack_internal *) ptr; switch (si->type) { case EVT_SI_DEVICE: sd = (void *) &si->data; device_event(sd->event, sd->dev_id); break; } return TRUE; } static int hciops_setup(void) { struct sockaddr_hci addr; struct hci_filter flt; GIOChannel *ctl_io, *child_io; int sock, err; if (child_pipe[0] != -1) return -EALREADY; if (pipe(child_pipe) < 0) { err = errno; error("pipe(): %s (%d)", strerror(err), err); return -err; } child_io = <API key>(child_pipe[0]); <API key>(child_io, TRUE); child_io_id = g_io_add_watch(child_io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, child_exit, NULL); g_io_channel_unref(child_io); /* Create and bind HCI socket */ sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (sock < 0) { err = errno; error("Can't open HCI socket: %s (%d)", strerror(err), err); return -err; } /* Set filter */ hci_filter_clear(&flt); <API key>(HCI_EVENT_PKT, &flt); <API key>(EVT_STACK_INTERNAL, &flt); if (setsockopt(sock, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) { err = errno; error("Can't set filter: %s (%d)", strerror(err), err); return -err; } memset(&addr, 0, sizeof(addr)); addr.hci_family = AF_BLUETOOTH; addr.hci_dev = HCI_DEV_NONE; if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { err = errno; error("Can't bind HCI socket: %s (%d)", strerror(err), err); return -err; } ctl_io = <API key>(sock); <API key>(ctl_io, TRUE); ctl_io_id = g_io_add_watch(ctl_io, G_IO_IN, io_stack_event, NULL); g_io_channel_unref(ctl_io); /* Initialize already connected devices */ return init_known_adapters(sock); } static void hciops_cleanup(void) { if (child_io_id) { g_source_remove(child_io_id); child_io_id = 0; } if (ctl_io_id) { g_source_remove(ctl_io_id); ctl_io_id = 0; } if (child_pipe[0] >= 0) { close(child_pipe[0]); child_pipe[0] = -1; } if (child_pipe[1] >= 0) { close(child_pipe[1]); child_pipe[1] = -1; } } static int hciops_start(int index) { int dd; int err = 0; dd = hci_open_dev(index); if (dd < 0) return -EIO; if (ioctl(dd, HCIDEVUP, index) == 0) goto done; /* on success */ if (errno != EALREADY) { err = errno; error("Can't init device hci%d: %s (%d)", index, strerror(err), err); } done: hci_close_dev(dd); return -err; } static int hciops_stop(int index) { int dd; int err = 0; dd = hci_open_dev(index); if (dd < 0) return -EIO; if (ioctl(dd, HCIDEVDOWN, index) == 0) goto done; /* on success */ if (errno != EALREADY) { err = errno; error("Can't stop device hci%d: %s (%d)", index, strerror(err), err); } done: hci_close_dev(dd); return -err; } static int hciops_powered(int index, gboolean powered) { int dd; uint8_t mode = SCAN_DISABLED; if (powered) return hciops_start(index); dd = hci_open_dev(index); if (dd < 0) return -EIO; hci_send_cmd(dd, OGF_HOST_CTL, <API key>, 1, &mode); hci_close_dev(dd); return hciops_stop(index); } static int hciops_connectable(int index) { int dd; uint8_t mode = SCAN_PAGE; dd = hci_open_dev(index); if (dd < 0) return -EIO; hci_send_cmd(dd, OGF_HOST_CTL, <API key>, 1, &mode); hci_close_dev(dd); return 0; } static int hciops_discoverable(int index) { int dd; uint8_t mode = (SCAN_PAGE | SCAN_INQUIRY); dd = hci_open_dev(index); if (dd < 0) return -EIO; hci_send_cmd(dd, OGF_HOST_CTL, <API key>, 1, &mode); hci_close_dev(dd); return 0; } static int hciops_set_class(int index, uint32_t class) { int dd, err; <API key> cp; dd = hci_open_dev(index); if (dd < 0) return -EIO; memcpy(cp.dev_class, &class, 3); err = hci_send_cmd(dd, OGF_HOST_CTL, <API key>, <API key>, &cp); if (err < 0) err = -errno; hci_close_dev(dd); return err; } static int <API key>(int index, uint32_t class, gboolean limited) { int dd; int num = (limited ? 2 : 1); uint8_t lap[] = { 0x33, 0x8b, 0x9e, 0x00, 0x8b, 0x9e }; <API key> cp; /* * 1: giac * 2: giac + liac */ dd = hci_open_dev(index); if (dd < 0) return -EIO; memset(&cp, 0, sizeof(cp)); cp.num_current_iac = num; memcpy(&cp.lap, lap, num * 3); hci_send_cmd(dd, OGF_HOST_CTL, <API key>, (num * 3 + 1), &cp); hci_close_dev(dd); return hciops_set_class(index, class); } static int <API key>(int index, gboolean periodic) { uint8_t lap[3] = { 0x33, 0x8b, 0x9e }; int dd, err; dd = hci_open_dev(index); if (dd < 0) return -EIO; if (periodic) { periodic_inquiry_cp cp; memset(&cp, 0, sizeof(cp)); memcpy(&cp.lap, lap, 3); cp.max_period = htobs(24); cp.min_period = htobs(16); cp.length = 0x08; cp.num_rsp = 0x00; err = hci_send_cmd(dd, OGF_LINK_CTL, <API key>, <API key>, &cp); } else { inquiry_cp inq_cp; memset(&inq_cp, 0, sizeof(inq_cp)); memcpy(&inq_cp.lap, lap, 3); inq_cp.length = 0x08; inq_cp.num_rsp = 0x00; err = hci_send_cmd(dd, OGF_LINK_CTL, OCF_INQUIRY, INQUIRY_CP_SIZE, &inq_cp); } if (err < 0) err = -errno; hci_close_dev(dd); return err; } static int <API key>(int index) { struct hci_dev_info di; int dd, err; if (hci_devinfo(index, &di) < 0) return -errno; dd = hci_open_dev(index); if (dd < 0) return -EIO; if (hci_test_bit(HCI_INQUIRY, &di.flags)) err = hci_send_cmd(dd, OGF_LINK_CTL, OCF_INQUIRY_CANCEL, 0, 0); else err = hci_send_cmd(dd, OGF_LINK_CTL, <API key>, 0, 0); if (err < 0) err = -errno; hci_close_dev(dd); return err; } static int hciops_resolve_name(int index, bdaddr_t *bdaddr) { remote_name_req_cp cp; int dd, err; dd = hci_open_dev(index); if (dd < 0) return -EIO; memset(&cp, 0, sizeof(cp)); bacpy(&cp.bdaddr, bdaddr); cp.pscan_rep_mode = 0x02; err = hci_send_cmd(dd, OGF_LINK_CTL, OCF_REMOTE_NAME_REQ, <API key>, &cp); if (err < 0) err = -errno; hci_close_dev(dd); return err; } static int hciops_set_name(int index, const char *name) { <API key> cp; int dd, err; dd = hci_open_dev(index); if (dd < 0) return -EIO; memset(&cp, 0, sizeof(cp)); strncpy((char *) cp.name, name, sizeof(cp.name)); err = hci_send_cmd(dd, OGF_HOST_CTL, <API key>, <API key>, &cp); if (err < 0) err = -errno; hci_close_dev(dd); return err; } static int hciops_read_name(int index) { int dd, err; dd = hci_open_dev(index); if (dd < 0) return -EIO; err = hci_send_cmd(dd, OGF_HOST_CTL, OCF_READ_LOCAL_NAME, 0, 0); if (err < 0) err = -errno; hci_close_dev(dd); return err; } static int <API key>(int index, bdaddr_t *bdaddr) { <API key> cp; int dd, err; dd = hci_open_dev(index); if (dd < 0) return -EIO; memset(&cp, 0, sizeof(cp)); bacpy(&cp.bdaddr, bdaddr); err = hci_send_cmd(dd, OGF_LINK_CTL, <API key>, <API key>, &cp); if (err < 0) err = -errno; hci_close_dev(dd); return err; } static struct btd_adapter_ops hci_ops = { .setup = hciops_setup, .cleanup = hciops_cleanup, .start = hciops_start, .stop = hciops_stop, .set_powered = hciops_powered, .set_connectable = hciops_connectable, .set_discoverable = hciops_discoverable, .<API key> = <API key>, .start_discovery = <API key>, .stop_discovery = <API key>, .resolve_name = hciops_resolve_name, .cancel_resolve_name = <API key>, .set_name = hciops_set_name, .read_name = hciops_read_name, .set_class = hciops_set_class, }; static int hciops_init(void) { return <API key>(&hci_ops); } static void hciops_exit(void) { <API key>(&hci_ops); } <API key>(hciops, VERSION, <API key>, hciops_init, hciops_exit)
#include <libratbox_config.h> #include <ratbox_lib.h> #include <commio-int.h> #include <commio-ssl.h> #ifdef HAVE_MBEDTLS #include "mbedtls/entropy.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/certs.h" #include "mbedtls/x509.h" #include "mbedtls/ssl.h" #include "mbedtls/net.h" #include "mbedtls/error.h" #include "mbedtls/debug.h" #include "mbedtls/dhm.h" #include "mbedtls/version.h" static mbedtls_x509_crt x509; static mbedtls_pk_context serv_pk; static mbedtls_dhm_context dh_params; static <API key> ctr_drbg; static <API key> entropy; static mbedtls_ssl_config serv_config; static mbedtls_ssl_config client_config; #define SSL_P(x) ((mbedtls_ssl_context *)F->ssl) void rb_ssl_shutdown(rb_fde_t *F) { int i; if(F == NULL || F->ssl == NULL) return; for(i = 0; i < 4; i++) { int r = <API key>(SSL_P(F)); if(r != <API key> && r != <API key>) break; } mbedtls_ssl_free(SSL_P(F)); rb_free(F->ssl); } unsigned int <API key>(rb_fde_t *F) { return F->handshake_count; } void <API key>(rb_fde_t *F) { F->handshake_count = 0; } static void rb_ssl_timeout(rb_fde_t *F, void *notused) { lrb_assert(F->accept != NULL); F->accept->callback(F, RB_ERR_TIMEOUT, NULL, 0, F->accept->data); } static int do_ssl_handshake(rb_fde_t *F, PF * callback, void *data) { int ret; int flags; ret = <API key>(SSL_P(F)); if(ret < 0) { if (ret == -1 && rb_ignore_errno(errno)) ret = <API key>; if((ret == <API key> || ret == <API key>)) { if(ret == <API key>) flags = RB_SELECT_READ; else flags = RB_SELECT_WRITE; rb_setselect(F, flags, callback, data); return 0; } F->ssl_errno = ret; return -1; } return 1; /* handshake is finished..go about life */ } static void rb_ssl_tryaccept(rb_fde_t *F, void *data) { int ret; struct acceptdata *ad; lrb_assert(F->accept != NULL); ret = do_ssl_handshake(F, rb_ssl_tryaccept, NULL); /* do_ssl_handshake does the rb_setselect */ if(ret == 0) return; ad = F->accept; F->accept = NULL; rb_settimeout(F, 0, NULL, NULL); rb_setselect(F, RB_SELECT_READ | RB_SELECT_WRITE, NULL, NULL); if(ret > 0) ad->callback(F, RB_OK, (struct sockaddr *)&ad->S, ad->addrlen, ad->data); else ad->callback(F, RB_ERROR_SSL, NULL, 0, ad->data); rb_free(ad); } static int rb_ssl_read_cb(void *opaque, unsigned char *buf, size_t size) { int ret; rb_fde_t *F = opaque; ret = read(F->fd, buf, size); if (ret < 0 && rb_ignore_errno(errno)) return <API key>; return ret; } static int rb_ssl_write_cb(void *opaque, const unsigned char *buf, size_t size) { rb_fde_t *F = opaque; int ret; ret = write(F->fd, buf, size); if (ret < 0 && rb_ignore_errno(errno)) return <API key>; return ret; } static void <API key>(rb_fde_t *F, mbedtls_ssl_context *ssl) { int ret; mbedtls_ssl_init(ssl); if ((ret = mbedtls_ssl_setup(ssl, &serv_config)) != 0) { rb_lib_log("<API key>: failed to set up ssl context: -0x%x", -ret); rb_close(F); return; } mbedtls_ssl_set_bio(ssl, F, rb_ssl_write_cb, rb_ssl_read_cb, NULL); } void <API key>(rb_fde_t *new_F, ACCB * cb, void *data, int timeout) { mbedtls_ssl_context *ssl; new_F->type |= RB_FD_SSL; ssl = new_F->ssl = rb_malloc(sizeof(mbedtls_ssl_context)); new_F->accept = rb_malloc(sizeof(struct acceptdata)); new_F->accept->callback = cb; new_F->accept->data = data; rb_settimeout(new_F, timeout, rb_ssl_timeout, NULL); new_F->accept->addrlen = 0; <API key>(new_F, ssl); if(do_ssl_handshake(new_F, rb_ssl_tryaccept, NULL)) { struct acceptdata *ad = new_F->accept; new_F->accept = NULL; ad->callback(new_F, RB_OK, (struct sockaddr *)&ad->S, ad->addrlen, ad->data); rb_free(ad); } } void rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen) { new_F->type |= RB_FD_SSL; new_F->ssl = rb_malloc(sizeof(mbedtls_ssl_context)); new_F->accept = rb_malloc(sizeof(struct acceptdata)); new_F->accept->callback = F->accept->callback; new_F->accept->data = F->accept->data; rb_settimeout(new_F, 10, rb_ssl_timeout, NULL); memcpy(&new_F->accept->S, st, addrlen); new_F->accept->addrlen = addrlen; <API key>(new_F, new_F->ssl); if(do_ssl_handshake(F, rb_ssl_tryaccept, NULL)) { struct acceptdata *ad = F->accept; F->accept = NULL; ad->callback(F, RB_OK, (struct sockaddr *)&ad->S, ad->addrlen, ad->data); rb_free(ad); } } static ssize_t <API key>(int r_or_w, rb_fde_t *F, void *rbuf, const void *wbuf, size_t count) { ssize_t ret; if(r_or_w == 0) ret = mbedtls_ssl_read(F->ssl, rbuf, count); else ret = mbedtls_ssl_write(F->ssl, wbuf, count); if(ret < 0) { switch (ret) { case <API key>: return RB_RW_SSL_NEED_READ; case <API key>: return <API key>; default: F->ssl_errno = ret; errno = EIO; return RB_RW_IO_ERROR; } } return ret; } ssize_t rb_ssl_read(rb_fde_t *F, void *buf, size_t count) { return <API key>(0, F, buf, NULL, count); } ssize_t rb_ssl_write(rb_fde_t *F, const void *buf, size_t count) { return <API key>(1, F, NULL, buf, count); } int rb_init_ssl(void) { int ret; <API key>(&entropy); <API key>(&ctr_drbg); if((ret = <API key>(&ctr_drbg, <API key>, &entropy, NULL, 0)) != 0) { rb_lib_log("rb_init_prng: unable to initialize PRNG, <API key>() returned -0x%x", -ret); return 0; } <API key>(&serv_config); if ((ret = <API key>(&serv_config, <API key>, <API key>, <API key>)) != 0) { rb_lib_log("rb_init_ssl: unable to initialize default SSL parameters for server context: -0x%x", -ret); return 0; } <API key>(&serv_config, <API key>, &ctr_drbg); <API key>(&client_config); if ((ret = <API key>(&client_config, <API key>, <API key>, <API key>)) != 0) { rb_lib_log("rb_init_ssl: unable to initialize default SSL parameters for client context: -0x%x", -ret); return 0; } <API key>(&client_config, <API key>, &ctr_drbg); <API key>(&client_config, <API key>); return 1; } int rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile, const char *cipher_list) { int ret; <API key>(&x509); ret = <API key>(&x509, cert); if (ret != 0) { rb_lib_log("rb_setup_ssl_server: failed to parse certificate '%s': -0x%x", cert, -ret); return 0; } mbedtls_pk_init(&serv_pk); ret = <API key>(&serv_pk, keyfile, NULL); if (ret != 0) { rb_lib_log("rb_setup_ssl_server: failed to parse private key '%s': -0x%x", keyfile, -ret); return 0; } mbedtls_dhm_init(&dh_params); ret = <API key>(&dh_params, dhfile); if (ret != 0) { rb_lib_log("rb_setup_ssl_server: failed to parse DH parameters '%s': -0x%x", dhfile, -ret); return 0; } ret = <API key>(&serv_config, &dh_params); if (ret != 0) { rb_lib_log("rb_setup_ssl_server: failed to set DH parameters on SSL config context: -0x%x", -ret); return 0; } if (x509.next) { <API key>(&serv_config, x509.next, NULL); <API key>(&client_config, x509.next, NULL); } if ((ret = <API key>(&serv_config, &x509, &serv_pk)) != 0) { rb_lib_log("rb_setup_ssl_server: failed to set up own certificate: -0x%x", -ret); return 0; } if ((ret = <API key>(&client_config, &x509, &serv_pk)) != 0) { rb_lib_log("rb_setup_ssl_server: failed to set up own certificate: -0x%x", -ret); return 0; } /* XXX support cipher lists when added to mbedtls */ return 1; } int rb_ssl_listen(rb_fde_t *F, int backlog, int defer_accept) { int result; result = rb_listen(F, backlog, defer_accept); F->type = RB_FD_SOCKET | RB_FD_LISTEN | RB_FD_SSL; return result; } struct ssl_connect { CNCB *callback; void *data; int timeout; }; static void <API key>(rb_fde_t *F, int status, struct ssl_connect *sconn) { F->connect->callback = sconn->callback; F->connect->data = sconn->data; rb_free(sconn); rb_connect_callback(F, status); } static void <API key>(rb_fde_t *F, void *data) { <API key>(F, RB_ERR_TIMEOUT, data); } static void rb_ssl_tryconn_cb(rb_fde_t *F, void *data) { struct ssl_connect *sconn = data; int ret; ret = do_ssl_handshake(F, rb_ssl_tryconn_cb, (void *)sconn); switch (ret) { case -1: <API key>(F, RB_ERROR_SSL, sconn); break; case 0: /* do_ssl_handshake does the rb_setselect stuff */ return; default: break; } <API key>(F, RB_OK, sconn); } static void <API key>(rb_fde_t *F, mbedtls_ssl_context *ssl) { int ret; mbedtls_ssl_init(ssl); if ((ret = mbedtls_ssl_setup(ssl, &client_config)) != 0) { rb_lib_log("<API key>: failed to set up ssl context: -0x%x", -ret); rb_close(F); return; } mbedtls_ssl_set_bio(ssl, F, rb_ssl_write_cb, rb_ssl_read_cb, NULL); } static void rb_ssl_tryconn(rb_fde_t *F, int status, void *data) { struct ssl_connect *sconn = data; if(status != RB_OK) { <API key>(F, status, sconn); return; } F->type |= RB_FD_SSL; rb_settimeout(F, sconn->timeout, <API key>, sconn); F->ssl = rb_malloc(sizeof(mbedtls_ssl_context)); <API key>(F, F->ssl); do_ssl_handshake(F, rb_ssl_tryconn_cb, (void *)sconn); } void rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest, struct sockaddr *clocal, int socklen, CNCB * callback, void *data, int timeout) { struct ssl_connect *sconn; if(F == NULL) return; sconn = rb_malloc(sizeof(struct ssl_connect)); sconn->data = data; sconn->callback = callback; sconn->timeout = timeout; rb_connect_tcp(F, dest, clocal, socklen, rb_ssl_tryconn, sconn, timeout); } void <API key>(rb_fde_t *F, CNCB * callback, void *data, int timeout) { struct ssl_connect *sconn; if(F == NULL) return; sconn = rb_malloc(sizeof(struct ssl_connect)); sconn->data = data; sconn->callback = callback; sconn->timeout = timeout; F->connect = rb_malloc(sizeof(struct conndata)); F->connect->callback = callback; F->connect->data = data; F->type |= RB_FD_SSL; F->ssl = rb_malloc(sizeof(mbedtls_ssl_context)); <API key>(F, F->ssl); rb_settimeout(F, sconn->timeout, <API key>, sconn); do_ssl_handshake(F, rb_ssl_tryconn_cb, (void *)sconn); } int rb_init_prng(const char *path, prng_seed_t seed_type) { return 1; } int rb_get_random(void *buf, size_t length) { if (<API key>(&ctr_drbg, buf, length)) return 0; return 1; } const char * rb_get_ssl_strerror(rb_fde_t *F) { #ifdef MBEDTLS_ERROR_C static char errbuf[512]; mbedtls_strerror(F->ssl_errno, errbuf, sizeof errbuf); return errbuf; #else return "???"; #endif } int rb_get_ssl_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN], int method) { const mbedtls_x509_crt *peer_cert; uint8_t hash[RB_SSL_CERTFP_LEN]; size_t hashlen; const mbedtls_md_info_t *md_info; mbedtls_md_type_t md_type; int ret; switch (method) { case <API key>: md_type = MBEDTLS_MD_SHA1; hashlen = <API key>; case <API key>: md_type = MBEDTLS_MD_SHA256; hashlen = <API key>; case <API key>: md_type = MBEDTLS_MD_SHA512; hashlen = <API key>; default: return 0; } peer_cert = <API key>(SSL_P(F)); if (peer_cert == NULL) return 0; md_info = <API key>(md_type); if (md_info == NULL) return 0; if ((ret = mbedtls_md(md_info, peer_cert->raw.p, peer_cert->raw.len, hash)) != 0) { rb_lib_log("rb_get_ssl_certfp: unable to get certfp for F: %p, -0x%x", -ret); return 0; } memcpy(certfp, hash, hashlen); return 1; } int rb_supports_ssl(void) { return 1; } void rb_get_ssl_info(char *buf, size_t len) { char version_str[512]; <API key>(version_str); rb_snprintf(buf, len, "MBEDTLS: compiled (%s), library(%s)", <API key>, version_str); } const char * rb_ssl_get_cipher(rb_fde_t *F) { if(F == NULL || F->ssl == NULL) return NULL; return <API key>(SSL_P(F)); } #endif /* HAVE_GNUTLS */
<?php include "Php/MsgHandler.php"; ?> <html> <head> <meta charset="UTF-8"> <!--FavIcon <link rel="shortcut icon" href="Graphics/favicon.ico" type="image/x-icon"> <link rel="icon" href="Graphics/favicon.ico" type="image/x-icon"> <!--CSS <link rel="stylesheet" type="text/css" href="Styles/common.css"> <link rel="stylesheet" type="text/css" href="Styles/index.css"> <!--JQuery <script src="Libraries/jquery-2.0.3.js"></script> <script src="Libraries/jquery.color-2.1.2.js"></script> <script src="Libraries/jquery.scrollTo.js"></script> <!--ScrollToTop Library <script src="Libraries/scrolltopcontrol.js"></script> <!--Scripts <script src="Scripts/index.js"></script> <title>WebDisplay</title> </head> <body> <!--FrontPage <div class="PageBaseWrapper" id="PageTitleWrapper"> <div class="PageCenter DisabledSelection"> <div id="WebDisplayLogo"></div> <div id="Title">Web Display</div> <div class="SubLine"></div> <div id="SubTitle">Simple display with network connectivity</div> <div id="MessageManagerLink" onclick="window.location.assign('messageManager.php');">Open Message Manager</div> <div id="ArrowDown" onclick="ScrollTo('<API key>');"></div> </div> </div> <!--DescriptionPage <div class="PageBaseWrapper" id="<API key>"> <div class="PageCenter" style="width: 200px; background-color: #CECECE;"> <div id="StatusInfoText"> <div class="StatusText">Status</div> MySQL Database: <span id="StatusSQL"> <?php if(SqlConnect()) { echo "Online"; } else { echo "Offline"; }?> </span><br> <br> <div class="StatusText">Statistics</div> GetMessage requests: <?php echo <API key>("GetRequest");?> <br> WriteMessage requests: <?php echo <API key>("WriteRequest");?> </div> </div> <div class="PageCenter"> <div id="LogoWrapper" class="DisabledSelection"> <span id="DescriptionTitle">Web Display</span> <span id="DescriptionText">by</span> <br> <div id="LogoHeBaSoft"></div> </div> <div id="BaseTextWrapper"> <b>WebDisplay</b> is a Arduino based device containing display with ability to show text messages that are send from website interface<br> <br> Principal of <b>WebDisplay</b> is based around sending <i>HTTP GET</i> requests to your web server to save message and on periodical <i>HTTP POST</i> requests from Arduino to web server to receive current message status<br> <br> <b>Project consists of:</b><br> &nbsp <i>Software part</i> - Website interface and Arduino program<br> &nbsp <i>Hardware part</i> - Receiving device with display and Ethernet port<br> <br> Currently there is only one prototype of receiving device and it is located at school <b>Brno, Čichnova 23</b> at classroom <b>D2/408</b><br> <span style="font-size: 10px; color: #A5A8AF;">If classroom is locked the key can be found under doormat in front of the doors. Plase do not steal anything, but we are not police so do whatever you want. Right?</span> </div> </div> </div> <!--InfoPage <div class="PageBaseWrapper" id="PageInfoWrapper"> <div class="InfoLine"> <div class="InfoCell"> <div class="InfoIcon" id="InfoIconHtml"></div> <div class="InfoName">Web Interface</div> <div class="InfoDescription"> <b>Web interface</b> is one of two main parts of <b>WebDisplay</b> project. This website is responsible for sending messages, storing logs, displaying current message and handling messages history. </div> </div> <div class="InfoCell"> <div class="InfoIcon" id="InfoIconTech"></div> <div class="InfoName">Technology</div> <div class="InfoDescription"> <b>Arduino</b> is project is based on a family of microcontroller boards that are using various <b>Atmel AVR</b> microcontrollers First prototype of our receiving device is based on this microcontroller board and Ethernet shield for it. </div> </div> <div class="InfoCell"> <div class="InfoIcon" id="InfoIconGit"></div> <div class="InfoName">Open source</div> <div class="InfoDescription"> <b>Open source</b> is changing the world! Entire <b>WebDisplay</b> project is open sourced. Every line of code from web server and Arduino program is publicly available at our <a href="https: </div> </div> </div> <div class="DivineLine"></div> <div class="InfoLine"> <div class="InfoCell"> <div class="InfoIcon" id="InfoIconDatabase"></div> <div class="InfoName">SQL Database</div> <div class="InfoDescription"> <b>MySQL</b> is the world's most popular open-source database system. With its speed, reliability, and ease of use interface, <b>MySQL</b> has become the preferred choice for web development. Our message logs are stored in our <b>MySQL</b> database and data are publicly available by using our public <b>API</b> or through our website. </div> </div> <div class="InfoCell"> <div class="InfoIcon" id="InfoIconStorage"></div> <div class="InfoName">Message logging</div> <div class="InfoDescription"> System is currently set up to log and store up to <b>100</b> messages with information about name of user and date when message was created. </div> </div> <div class="InfoCell"> <div class="InfoIcon" id="InfoIconApi"></div> <div class="InfoName">Public API</div> <div class="InfoDescription"> Our website in not the only way to send messages and access to our data. You can also use our public <b>API</b> to easily retrieve informations by sending HTTP GET requests to your public <b>API</b>. </div> </div> </div> </div> </body> </html>
<?php session_start(); include_once 'config.php'; // loads config variables include_once 'lib/query.php'; // imports queries include_once 'lib/functions.php'; $query = sprintf(TAEKWON, $CONFIG_gm_hide); $result = execute_query($query, 'taekwon.php'); caption($lang['TAEKWON_LADDER']); echo ' <table class="maintable dataformat"> <tr> <th align="right">'.$lang['POS'].'</th> <th align="left">'.$lang['NAME'].'</th> <th align="left">'.$lang['LADDER_GUILD'].'</th> <th align="right">'.$lang['TAEKWON_POINTS'].'</th> </tr> '; $nusers = 0; if ($result) { while ($line = $result->fetch_assoc()) { $nusers++; $_SESSION[$CONFIG_name.'emblems'][$line['guild_id']] = $line['emblem_data']; $charname = htmlformat($line['name']); $gname = htmlformat($line['guild_name']); if (isset($_SESSION[$CONFIG_name.'account_id']) && $line['account_id'] == $_SESSION[$CONFIG_name.'account_id']) echo '<tr class="highlight">'; else echo '<tr>'; echo ' <td align="right">'.$nusers.'</td> <td align="left">'.$charname.'</td> <td align="left">'.($line['guild_id']>0?('<img src="emblema.php?data='.$line['guild_id'].'" alt="'.$gname.'" class="emblem" />'.$gname):'<div class="emblem"></div>').'</td> <td align="right">'.moneyformat($line['fame']).'</td> </tr> '; } } echo '</table>'; fim(); ?>