code
stringlengths
3
1.05M
repo_name
stringlengths
4
116
path
stringlengths
3
942
language
stringclasses
30 values
license
stringclasses
15 values
size
int32
3
1.05M
/* class for generating random sample data*/ public class ValueGenerator { private static String[] values = { "elephant","giraffe","monkey","cheetah","dog","cat","tiger", "mouse","tortoise","shark","whale","salmon","deer","wolf", "grizzlybear","fox","snake","worm","fly","bee","hornet" }; public static String[] getNewStringArray(){ int size = (int)(Math.random()*20 +1); String[] arr = new String[size]; for(int i=0; i<size;++i){ arr[i] = getNewString(); } return arr; } public static String getNewString(){ int index = (int)(Math.random()*values.length); return values[index]; } public static int getNewInt(){ return (int)(Math.random()*100); } public static Integer[] getNewIntArray(){ int size = (int)(Math.random()*20 +1); Integer[] arr = new Integer[size]; for(int i=0; i<size;++i){ arr[i] = getNewInt(); } return arr; } public static double getNewDouble(){ //round double to ##.### return Math.floor(Math.random()*100000 ) / 1000; } public static Double[] getNewDoubleArray(){ int size = (int)(Math.random()*20 +1); Double[] arr = new Double[size]; for(int i=0; i<size;++i){ arr[i] = getNewDouble(); } return arr; } }
DB-SE/isp2014.marcus.kamieth
Algorithms_DataStructures_RTVar/src/ValueGenerator.java
Java
gpl-2.0
1,197
//============================================================================= // YHTTPD // Helper //============================================================================= // c #include <cstdio> // printf prototype. #include <cstdlib> // calloc and free prototypes. #include <cstring> // str* and memset prototypes. #include <cstdarg> #include <sstream> #include <iomanip> #include <unistd.h> // yhttpd #include <yconfig.h> #include <tuxboxapi/controlapi.h> #include "ytypes_globals.h" #include "helper.h" #include "ylogging.h" //============================================================================= // Integers //============================================================================= //------------------------------------------------------------------------- // Check and set integer inside boundaries (min, max) //------------------------------------------------------------------------- int minmax(int value, int min, int max) { if (value < min) return min; if (value > max) return max; return value; } //============================================================================= // Date & Time //============================================================================= //------------------------------------------------------------------------- // Check and set Date/Time (tm*) inside boundaries //------------------------------------------------------------------------- void correctTime(struct tm *zt) { zt->tm_year = minmax(zt->tm_year, 0, 129); zt->tm_mon = minmax(zt->tm_mon, 0, 11); zt->tm_mday = minmax(zt->tm_mday, 1, 31); //-> eine etwas laxe pruefung, aber mktime biegt das wieder grade zt->tm_hour = minmax(zt->tm_hour, 0, 23); zt->tm_min = minmax(zt->tm_min, 0, 59); zt->tm_sec = minmax(zt->tm_sec, 0, 59); zt->tm_isdst = -1; } //============================================================================= // Strings //============================================================================= //------------------------------------------------------------------------- // Integer to Hexadecimal-String //------------------------------------------------------------------------- std::string itoh(unsigned int conv) { return string_printf("0x%06x", conv); } //------------------------------------------------------------------------- // Integer to String //------------------------------------------------------------------------- std::string itoa(unsigned int conv) { return string_printf("%u", conv); } //------------------------------------------------------------------------- // convert timer_t to "<hour>:<minutes>" String //------------------------------------------------------------------------- std::string timeString(time_t time) { char tmp[7] = { '\0' }; struct tm *tm = localtime(&time); if (strftime(tmp, 6, "%H:%M", tm)) return std::string(tmp); else return std::string("??:??"); } //------------------------------------------------------------------------- // Printf and return formatet String. Buffer-save! // max length up to bufferlen -> then snip //------------------------------------------------------------------------- std::string string_printf(const char *fmt, ...) { va_list arglist; const int bufferlen = 4*1024; char buffer[bufferlen] = {0}; va_start(arglist, fmt); vsnprintf(buffer, bufferlen, fmt, arglist); va_end(arglist); return std::string(buffer); } //------------------------------------------------------------------------- // ySplitString: spit string "str" in two strings "left" and "right" at // one of the chars in "delimiter" returns true if delimiter found //------------------------------------------------------------------------- bool ySplitString(std::string str, std::string delimiter, std::string& left, std::string& right) { std::string::size_type pos; if ((pos = str.find_first_of(delimiter)) != std::string::npos) { left = str.substr(0, pos); right = str.substr(pos + 1, str.length() - (pos + 1)); } else { left = str; //default if not found right = ""; } return (pos != std::string::npos); } //------------------------------------------------------------------------- // ySplitString: spit string "str" in two strings "left" and "right" at // one of the chars in "delimiter" returns true if delimiter found //------------------------------------------------------------------------- bool ySplitStringExact(std::string str, std::string delimiter, std::string& left, std::string& right) { std::string::size_type pos; if ((pos = str.find(delimiter)) != std::string::npos) { left = str.substr(0, pos); right = str.substr(pos + delimiter.length(), str.length() - (pos + delimiter.length())); } else { left = str; //default if not found right = ""; } return (pos != std::string::npos); } //------------------------------------------------------------------------- // ySplitStringRight: spit string "str" in two strings "left" and "right" at // one of the chars in "delimiter" returns true if delimiter found //------------------------------------------------------------------------- bool ySplitStringLast(std::string str, std::string delimiter, std::string& left, std::string& right) { std::string::size_type pos; if ((pos = str.find_last_of(delimiter)) != std::string::npos) { left = str.substr(0, pos); right = str.substr(pos + 1, str.length() - (pos + 1)); } else { left = str; //default if not found right = ""; } return (pos != std::string::npos); } //------------------------------------------------------------------------- // ySplitStringVector: spit string "str" and build vector of strings //------------------------------------------------------------------------- CStringArray ySplitStringVector(std::string str, std::string delimiter) { std::string left, right, rest; bool found; CStringArray split; rest = str; do { found = ySplitString(rest, delimiter, left, right); split.push_back(left); rest = right; } while (found); return split; } //------------------------------------------------------------------------- // trim whitespaces //------------------------------------------------------------------------- std::string trim(std::string const& source, char const* delims) { std::string result(source); std::string::size_type index = result.find_last_not_of(delims); if (index != std::string::npos) result.erase(++index); index = result.find_first_not_of(delims); if (index != std::string::npos) result.erase(0, index); else result.erase(); return result; } //------------------------------------------------------------------------- // replace all occurrences find_what //------------------------------------------------------------------------- void replace(std::string &str, const std::string &find_what, const std::string &replace_with) { std::string::size_type pos = 0; while ((pos = str.find(find_what, pos)) != std::string::npos) { str.erase(pos, find_what.length()); str.insert(pos, replace_with); pos += replace_with.length(); } } //------------------------------------------------------------------------- // equal-function for case insensitive compare //------------------------------------------------------------------------- bool nocase_compare(char c1, char c2) { return toupper(c1) == toupper(c2); } //----------------------------------------------------------------------------- // Decode URLEncoded std::string //----------------------------------------------------------------------------- std::string decodeString(std::string encodedString) { const char *string = encodedString.c_str(); unsigned int count = 0; char hex[3] = { '\0' }; unsigned long iStr; std::string result = ""; count = 0; while (count < encodedString.length()) /* use the null character as a loop terminator */ { if (string[count] == '%' && count + 2 < encodedString.length()) { hex[0] = string[count + 1]; hex[1] = string[count + 2]; hex[2] = '\0'; iStr = strtoul(hex, NULL, 16); /* convert to Hex char */ result += (char) iStr; count += 3; } else if (string[count] == '+') { result += ' '; count++; } else { result += string[count]; count++; } } /* end of while loop */ return result; } //----------------------------------------------------------------------------- // HTMLEncode std::string //----------------------------------------------------------------------------- std::string encodeString(const std::string &decodedString) { std::string result=""; char buf[10]= {0}; for (unsigned int i=0; i<decodedString.length(); i++) { const char one_char = decodedString[i]; if (isalnum(one_char)) { result += one_char; } else { snprintf(buf,sizeof(buf), "&#%d;",(unsigned char) one_char); result +=buf; } } result+='\0'; result.reserve(); return result; } //----------------------------------------------------------------------------- // returns string in lower case //----------------------------------------------------------------------------- std::string string_tolower(std::string str) { for (unsigned int i = 0; i < str.length(); i++) str[i] = tolower(str[i]); return str; } //----------------------------------------------------------------------------- // write string to a file //----------------------------------------------------------------------------- bool write_to_file(std::string filename, std::string content, bool append) { FILE *fd = NULL; if ((fd = fopen(filename.c_str(), append ? "a" : "w")) != NULL) // open file { fwrite(content.c_str(), content.length(), 1, fd); fflush(fd); // flush and close file fclose(fd); return true; } else return false; } //----------------------------------------------------------------------------- // JSON: create pair string "<_key>". "<_value>" // Handle wrong quotes //----------------------------------------------------------------------------- std::string json_out_quote_convert(std::string _str) { replace(_str, "\"", "\'"); return _str; } //----------------------------------------------------------------------------- // JSON: create pair string "<_key>". "<_value>" // Handle wrong quotes //----------------------------------------------------------------------------- std::string json_out_pair(std::string _key, std::string _value) { replace(_key, "\"", ""); replace(_value, "\"", "\'"); return "\"" + _key + "\": " + "\"" + _value + "\""; } //----------------------------------------------------------------------------- // JSON: create success return string //----------------------------------------------------------------------------- std::string json_out_success(std::string _result) { return "{\"success\": \"true\", \"data\":{" + _result + "}}"; } //----------------------------------------------------------------------------- // JSON: create success return string //----------------------------------------------------------------------------- std::string json_out_error(std::string _error) { return "{\"success\": \"false\", \"error\":{\"text\": \"" + _error + "\"}}"; } //----------------------------------------------------------------------------- // JSON: convert string to JSON-String //----------------------------------------------------------------------------- std::string json_convert_string(std::string value) { std::string result; for (size_t i = 0; i < value.length(); i++) { unsigned char c = unsigned(value[i]); switch(c) { case '\"': result += "\\\""; break; case '\\': result += "\\\\"; break; case '\b': result += "\\b"; break; case '\f': result += "\\f"; break; case '\n': result += "\\n"; break; case '\r': result += "\\r"; break; case '\t': result += "\\t"; break; default: if ( isControlCharacter( c ) ) { std::ostringstream oss; oss << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast<int>(c); result += oss.str(); } else { result += c; } break; } } return result; } #if 0 std::string json_convert_string(std::string s) { std::stringstream ss; for (size_t i = 0; i < s.length(); ) { unsigned char ch = unsigned(s[i]); if(ch == 0x0d){ ss << "\\u000d"; i++; continue; } if(ch == 0x0a){ ss << "\\u000a"; i++; continue; } if(ch < '\x20' || ch == '\\' || ch == '"' || ch >= '\x80') { unsigned long unicode = 0; size_t todo = 0; if (ch <= 0xBF) { } else if (ch <= 0xDF) { unicode = ch & 0x1F; todo = 1; } else if (ch <= 0xEF) { unicode = ch & 0x0F; todo = 2; } else if (ch <= 0xF7) { unicode = ch & 0x07; todo = 3; } for (size_t j = 0; j < todo; ++j){ ++i; unicode <<= 6; unicode += unsigned(s[i]) & 0x3F; } if (unicode <= 0xFFFF) { ss << "\\u" << std::setfill('0') << std::setw(4) << std::hex << unicode; }else { unicode -= 0x10000; ss << "\\u" << std::setfill('0') << std::setw(4) << std::hex << ((unicode >> 10) + 0xD800); ss << "\\u" << std::setfill('0') << std::setw(4) << std::hex << ((unicode & 0x3FF) + 0xDC00); } } else { ss << s[i]; } ++i; } return ss.str(); } #endif // 0 std::string yExecuteScript(std::string cmd) { #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE const char *fbshot = "Y_Tools fbshot fb /"; int len = strlen(fbshot); if (!strncmp(cmd.c_str(), fbshot, len)) return CFrameBuffer::getInstance()->OSDShot(cmd.substr(len - 1)) ? "" : "error"; #endif std::string script, para, result; bool found = false; //aprintf("%s: %s\n", __func__, cmd.c_str()); // split script and parameters int pos; if ((pos = cmd.find_first_of(" ")) > 0) { script = cmd.substr(0, pos); para = cmd.substr(pos + 1, cmd.length() - (pos + 1)); // snip } else script = cmd; // get file std::string fullfilename; script += ".sh"; //add script extention char cwd[255]; getcwd(cwd, 254); for (unsigned int i = 0; i < CControlAPI::PLUGIN_DIR_COUNT && !found; i++) { fullfilename = CControlAPI::PLUGIN_DIRS[i] + "/" + script; FILE *test = fopen(fullfilename.c_str(), "r"); // use fopen: popen does not work if (test != NULL) { fclose(test); chdir(CControlAPI::PLUGIN_DIRS[i].c_str()); FILE *f = popen((fullfilename + " " + para).c_str(), "r"); //execute if (f != NULL) { found = true; char output[1024]; while (fgets(output, 1024, f)) // get script output result += output; pclose(f); } } } chdir(cwd); if (!found) { printf("%s: script %s not found in:\n", __func__, script.c_str()); for (unsigned int i = 0; i < CControlAPI::PLUGIN_DIR_COUNT; i++) { printf("\t%s\n", CControlAPI::PLUGIN_DIRS[i].c_str()); } result = "error"; } return result; }
j00zek/j00zeks-neutrino-mp-cst-next
src/nhttpd/yhttpd_core/helper.cpp
C++
gpl-2.0
14,657
/* * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /* * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /** * \file limSendManagementFrames.c * * \brief Code for preparing and sending 802.11 Management frames * * Copyright (C) 2005-2007 Airgo Networks, Incorporated * */ #include "sirApi.h" #include "aniGlobal.h" #include "sirMacProtDef.h" #include "cfgApi.h" #include "utilsApi.h" #include "limTypes.h" #include "limUtils.h" #include "limSecurityUtils.h" #include "limPropExtsUtils.h" #include "dot11f.h" #include "limStaHashApi.h" #include "schApi.h" #include "limSendMessages.h" #include "limAssocUtils.h" #include "limFT.h" #if defined WLAN_FEATURE_VOWIFI #include "rrmApi.h" #endif #include "wlan_qct_wda.h" #ifdef WLAN_FEATURE_11W #include "dot11fdefs.h" #endif //////////////////////////////////////////////////////////////////////// /** * * \brief This function is called by various LIM modules to prepare the * 802.11 frame MAC header * * * \param pMac Pointer to Global MAC structure * * \param pBD Pointer to the frame buffer that needs to be populate * * \param type Type of the frame * * \param subType Subtype of the frame * * \return eHalStatus * * * The pFrameBuf argument points to the beginning of the frame buffer to * which - a) The 802.11 MAC header is set b) Following this MAC header * will be the MGMT frame payload The payload itself is populated by the * caller API * * */ tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac, tANI_U8* pBD, tANI_U8 type, tANI_U8 subType, tSirMacAddr peerAddr, tSirMacAddr selfMacAddr) { tSirRetStatus statusCode = eSIR_SUCCESS; tpSirMacMgmtHdr pMacHdr; /// Prepare MAC management header pMacHdr = (tpSirMacMgmtHdr) (pBD); // Prepare FC pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION; pMacHdr->fc.type = type; pMacHdr->fc.subType = subType; // Prepare Address 1 vos_mem_copy( (tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr, sizeof( tSirMacAddr )); // Prepare Address 2 sirCopyMacAddr(pMacHdr->sa,selfMacAddr); // Prepare Address 3 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr, sizeof( tSirMacAddr )); return statusCode; } /*** end limPopulateMacHeader() ***/ #ifdef WLAN_FEATURE_11W /** * * \brief This function is called by various LIM modules to correctly set * the Protected bit in the Frame Control Field of the 802.11 frame MAC header * * * \param pMac Pointer to Global MAC structure * * \param psessionEntry Pointer to session corresponding to the connection * * \param peer Peer address of the STA to which the frame is to be sent * * \param pMacHdr Pointer to the frame MAC header * * \return nothing * * */ void limSetProtectedBit(tpAniSirGlobal pMac, tpPESession psessionEntry, tSirMacAddr peer, tpSirMacMgmtHdr pMacHdr) { tANI_U16 aid; tpDphHashNode pStaDs; if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ) { pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable ); if( pStaDs != NULL ) if( pStaDs->rmfEnabled ) pMacHdr->fc.wep = 1; } else if ( psessionEntry->limRmfEnabled ) pMacHdr->fc.wep = 1; } /*** end limSetProtectedBit() ***/ #endif /** * \brief limSendProbeReqMgmtFrame * * * \param pMac Pointer to Global MAC structure * * \param pSsid SSID to be sent in Probe Request frame * * \param bssid BSSID to be sent in Probe Request frame * * \param nProbeDelay probe delay to be used before sending Probe Request * frame * * \param nChannelNum Channel # on which the Probe Request is going out * * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame * * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame * * This function is called by various LIM modules to send Probe Request frame * during active scan/learn phase. * Probe request is sent out in the following scenarios: * --heartbeat failure: session needed * --join req: session needed * --foreground scan: no session * --background scan: no session * --schBeaconProcessing: to get EDCA parameters: session needed * * */ tSirRetStatus limSendProbeReqMgmtFrame(tpAniSirGlobal pMac, tSirMacSSid *pSsid, tSirMacAddr bssid, tANI_U8 nChannelNum, tSirMacAddr SelfMacAddr, tANI_U32 dot11mode, tANI_U32 nAdditionalIELen, tANI_U8 *pAdditionalIE) { tDot11fProbeRequest pr; tANI_U32 nStatus, nBytes, nPayload; tSirRetStatus nSirStatus; tANI_U8 *pFrame; void *pPacket; eHalStatus halstatus; tpPESession psessionEntry; tANI_U8 sessionId; tANI_U8 *p2pIe = NULL; tANI_U8 txFlag = 0; #ifndef GEN4_SCAN return eSIR_FAILURE; #endif #if defined ( ANI_DVT_DEBUG ) return eSIR_FAILURE; #endif /* * session context may or may not be present, when probe request needs to be sent out. * following cases exist: * --heartbeat failure: session needed * --join req: session needed * --foreground scan: no session * --background scan: no session * --schBeaconProcessing: to get EDCA parameters: session needed * If session context does not exist, some IEs will be populated from CFGs, * e.g. Supported and Extended rate set IEs */ psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId); // The scheme here is to fill out a 'tDot11fProbeRequest' structure // and then hand it off to 'dot11fPackProbeRequest' (for // serialization). We start by zero-initializing the structure: vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0); // & delegating to assorted helpers: PopulateDot11fSSID( pMac, pSsid, &pr.SSID ); if( nAdditionalIELen && pAdditionalIE ) { p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen); } /* Don't include 11b rate only when device is doing P2P Search */ if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) && ( p2pIe != NULL ) && /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */ ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) && pMac->lim.gpLimMlmScanReq->p2pSearch ) || ( ( psessionEntry != NULL ) && ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) ) ) ) { /* In the below API pass channel number > 14, do that it fills only * 11a rates in supported rates */ PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry); } else { PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,psessionEntry); if ( WNI_CFG_DOT11_MODE_11B != dot11mode ) { PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates ); } } #if defined WLAN_FEATURE_VOWIFI //Table 7-14 in IEEE Std. 802.11k-2008 says //DS params "can" be present in RRM is disabled and "is" present if //RRM is enabled. It should be ok even if we add it into probe req when //RRM is not enabled. PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry ); //Call RRM module to get the tx power for management used. { tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry ); PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 ); } #endif if (psessionEntry != NULL ) { psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode); //Include HT Capability IE if (psessionEntry->htCapability) { PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps ); } } else { //psessionEntry == NULL if (IS_DOT11_MODE_HT(dot11mode)) { PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps ); } } /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */ if( nChannelNum <= SIR_11B_CHANNEL_END) { pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ; pr.HTCaps.shortGI40MHz = 0; } #ifdef WLAN_FEATURE_11AC if (psessionEntry != NULL ) { psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode); //Include HT Capability IE if (psessionEntry->vhtCapability) { PopulateDot11fVHTCaps( pMac, &pr.VHTCaps ); } } else { if (IS_DOT11_MODE_VHT(dot11mode)) { PopulateDot11fVHTCaps( pMac, &pr.VHTCaps ); } } #endif // That's it-- now we pack it. First, how much space are we going to // need? nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Probe Request (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fProbeRequest ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating" "the packed size for a Probe Request (" "0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen; // Ok-- try to allocate some memory: halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro" "be Request."), nBytes ); return eSIR_MEM_ALLOC_FAILED; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a Probe Request (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return nSirStatus; // allocated! } // That done, pack the Probe Request: nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a P" "robe Request (0x%08x)."), nStatus ); } // Append any AddIE if present. if( nAdditionalIELen ) { vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, pAdditionalIE, nAdditionalIELen ); nPayload += nAdditionalIELen; } /* If this probe request is sent during P2P Search State, then we need * to send it at OFDM rate. */ if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum)) || (( pMac->lim.gpLimMlmScanReq != NULL) && pMac->lim.gpLimMlmScanReq->p2pSearch ) /* For unicast probe req mgmt from Join function we don't set above variables. So we need to add one more check whether it is pePersona is P2P_CLIENT or not */ || ( ( psessionEntry != NULL ) && ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) ) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("could not send Probe Request frame!" )); //Pkt will be freed up by the callback return eSIR_FAILURE; } return eSIR_SUCCESS; } // End limSendProbeReqMgmtFrame. tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac, tANI_U8* addIE, tANI_U16 *addnIELen, tANI_U8 probeReqP2pIe) { /* If Probe request doesn't have P2P IE, then take out P2P IE from additional IE */ if(!probeReqP2pIe) { tANI_U8* tempbuf = NULL; tANI_U16 tempLen = 0; int left = *addnIELen; v_U8_t *ptr = addIE; v_U8_t elem_id, elem_len; if(NULL == addIE) { PELOGE(limLog(pMac, LOGE, FL(" NULL addIE pointer"));) return eSIR_FAILURE; } tempbuf = vos_mem_malloc(left); if ( NULL == tempbuf ) { PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store addn IE"));) return eSIR_MEM_ALLOC_FAILED; } while(left >= 2) { elem_id = ptr[0]; elem_len = ptr[1]; left -= 2; if(elem_len > left) { limLog( pMac, LOGE, FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), elem_id,elem_len,left); vos_mem_free(tempbuf); return eSIR_FAILURE; } if ( !( (SIR_MAC_EID_VENDOR == elem_id) && (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) ) { vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2); tempLen += (elem_len + 2); } left -= elem_len; ptr += (elem_len + 2); } vos_mem_copy (addIE, tempbuf, tempLen); *addnIELen = tempLen; vos_mem_free(tempbuf); } return eSIR_SUCCESS; } void limSendProbeRspMgmtFrame(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tpAniSSID pSsid, short nStaId, tANI_U8 nKeepAlive, tpPESession psessionEntry, tANI_U8 probeReqP2pIe) { tDot11fProbeResponse *pFrm; tSirRetStatus nSirStatus; tANI_U32 cfg, nPayload, nBytes, nStatus; tpSirMacMgmtHdr pMacHdr; tANI_U8 *pFrame; void *pPacket; eHalStatus halstatus; tANI_U32 addnIEPresent; tANI_U32 addnIE1Len=0; tANI_U32 addnIE2Len=0; tANI_U32 addnIE3Len=0; tANI_U16 totalAddnIeLen = 0; tANI_U32 wpsApEnable=0, tmp; tANI_U8 txFlag = 0; tANI_U8 *addIE = NULL; tANI_U8 *pP2pIe = NULL; tANI_U8 noaLen = 0; tANI_U8 total_noaLen = 0; tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN]; tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN]; if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests { return; // in this case. } if(NULL == psessionEntry) { return; } pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse)); if ( NULL == pFrm ) { limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") ); return; } // Fill out 'frm', after which we'll just hand the struct off to // 'dot11fPackProbeResponse'. vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0); // Timestamp to be updated by TFP, below. // Beacon Interval: if(psessionEntry->limSystemRole == eLIM_AP_ROLE) { pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval; } else { nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg); if (eSIR_SUCCESS != nSirStatus) { limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."), nSirStatus ); vos_mem_free(pFrm); return; } pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg; } PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry ); PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID ); PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &pFrm->SuppRates,psessionEntry); PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry); PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry ); if(psessionEntry->limSystemRole == eLIM_AP_ROLE) { if(psessionEntry->wps_state != SAP_WPS_DISABLED) { PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry); } } else { if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS) limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE ); wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP; if (wpsApEnable) { PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes); } if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN) { PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes); pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS; } if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END) { DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes); pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP; } } PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry); PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry); if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B) PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry); // N.B. In earlier implementations, the RSN IE would be placed in // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined. PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &pFrm->ExtSuppRates, psessionEntry ); //Populate HT IEs, when operating in 11n or Taurus modes. if ( psessionEntry->htCapability ) { PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps ); PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry ); } #ifdef WLAN_FEATURE_11AC if(psessionEntry->vhtCapability) { limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response")); PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps ); PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation ); // we do not support multi users yet //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad ); PopulateDot11fExtCap( pMac, &pFrm->ExtCap); } #endif if ( psessionEntry->pLimStartBssReq ) { PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ), &pFrm->WPA ); PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ), &pFrm->RSNOpaque ); } PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry ); #if defined(FEATURE_WLAN_WAPI) if( psessionEntry->pLimStartBssReq ) { PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ), &pFrm->WAPI ); } #endif // defined(FEATURE_WLAN_WAPI) nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Probe Response (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fProbeResponse ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating" "the packed size for a Probe Response " "(0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); addnIEPresent = false; if( pMac->lim.gpLimRemainOnChanReq ) { nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) ); } //Only use CFG for non-listen mode. This CFG is not working for concurrency //In listening mode, probe rsp IEs is passed in the message from SME to PE else { if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG, &addnIEPresent) != eSIR_SUCCESS) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG")); vos_mem_free(pFrm); return; } } if (addnIEPresent) { addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3); if ( NULL == addIE ) { PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store addn IE"));) vos_mem_free(pFrm); return; } //Probe rsp IE available if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) ) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length")); vos_mem_free(addIE); vos_mem_free(pFrm); return; } if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len && (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE) { if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0], &addnIE1Len) ) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String")); vos_mem_free(addIE); vos_mem_free(pFrm); return; } } //Probe rsp IE available if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) ) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length")); vos_mem_free(addIE); vos_mem_free(pFrm); return; } if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len && (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE) { if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len], &addnIE2Len) ) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String")); vos_mem_free(addIE); vos_mem_free(pFrm); return; } } //Probe rsp IE available if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) ) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length")); vos_mem_free(addIE); vos_mem_free(pFrm); return; } if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len && (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE) { if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addIE[addnIE1Len + addnIE2Len], &addnIE3Len) ) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String")); vos_mem_free(addIE); vos_mem_free(pFrm); return; } } totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len; if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe)) { limLog(pMac, LOGP, FL("Unable to get final Additional IE for Probe Req")); vos_mem_free(addIE); vos_mem_free(pFrm); return; } nBytes = nBytes + totalAddnIeLen; if (probeReqP2pIe) { pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen); if (pP2pIe != NULL) { //get NoA attribute stream P2P IE noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry); if (noaLen != 0) { total_noaLen = limBuildP2pIe(pMac, &noaIe[0], &noaStream[0], noaLen); nBytes = nBytes + total_noaLen; } } } } halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro" "be Response."), nBytes ); if ( addIE != NULL ) { vos_mem_free(addIE); } vos_mem_free(pFrm); return; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a Probe Response (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); if ( addIE != NULL ) { vos_mem_free(addIE); } vos_mem_free(pFrm); return; } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); // That done, pack the Probe Response: nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); if ( addIE != NULL ) { vos_mem_free(addIE); } vos_mem_free(pFrm); return; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a P" "robe Response (0x%08x)."), nStatus ); } PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") ); limPrintMacAddr( pMac, peerMacAddr, LOG3 );) pMac->sys.probeRespond++; if( pMac->lim.gpLimRemainOnChanReq ) { vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) ); } if ( addnIEPresent ) { vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen); } if (noaLen != 0) { if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) { limLog(pMac, LOGE, FL("Not able to insert NoA because of length constraint")); vos_mem_free(addIE); vos_mem_free(pFrm); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; } else { vos_mem_copy( &pFrame[nBytes - (total_noaLen)], &noaIe[0], total_noaLen); } } if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } // Queue Probe Response frame in high priority WQ halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_LOW, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Could not send Probe Response.") ); //Pkt will be freed up by the callback } if ( addIE != NULL ) { vos_mem_free(addIE); } vos_mem_free(pFrm); return; } // End limSendProbeRspMgmtFrame. void limSendAddtsReqActionFrame(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry) { tANI_U16 i; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tDot11fAddTSRequest AddTSReq; tDot11fWMMAddTSRequest WMMAddTSReq; tANI_U32 nPayload, nBytes, nStatus; tpSirMacMgmtHdr pMacHdr; void *pPacket; #ifdef FEATURE_WLAN_CCX tANI_U32 phyMode; #endif eHalStatus halstatus; tANI_U8 txFlag = 0; if(NULL == psessionEntry) { return; } if ( ! pAddTS->wmeTspecPresent ) { vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0); AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ; AddTSReq.DialogToken.token = pAddTS->dialogToken; AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT; if ( pAddTS->lleTspecPresent ) { PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC ); } else { PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC ); } if ( pAddTS->lleTspecPresent ) { AddTSReq.num_WMMTCLAS = 0; AddTSReq.num_TCLAS = pAddTS->numTclas; for ( i = 0; i < pAddTS->numTclas; ++i) { PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i], &AddTSReq.TCLAS[i] ); } } else { AddTSReq.num_TCLAS = 0; AddTSReq.num_WMMTCLAS = pAddTS->numTclas; for ( i = 0; i < pAddTS->numTclas; ++i) { PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i], &AddTSReq.WMMTCLAS[i] ); } } if ( pAddTS->tclasProcPresent ) { if ( pAddTS->lleTspecPresent ) { AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc; AddTSReq.TCLASSPROC.present = 1; } else { AddTSReq.WMMTCLASPROC.version = 1; AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc; AddTSReq.WMMTCLASPROC.present = 1; } } nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or an Add TS Request (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fAddTSRequest ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating" "the packed size for an Add TS Request" " (0x%08x)."), nStatus ); } } else { vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0); WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ; WMMAddTSReq.DialogToken.token = pAddTS->dialogToken; WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME; // WMM spec 2.2.10 - status code is only filled in for ADDTS response WMMAddTSReq.StatusCode.statusCode = 0; PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC ); #ifdef FEATURE_WLAN_CCX limGetPhyMode(pMac, &phyMode, psessionEntry); if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A) { pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS; } else { pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS; } PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8)); #endif // fillWmeTspecIE nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a WMM Add TS Request (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fAddTSRequest ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating" "the packed size for a WMM Add TS Requ" "est (0x%08x)."), nStatus ); } } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad" "d TS Request."), nBytes ); return; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for an Add TS Request (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; #if 0 cfgLen = SIR_MAC_ADDR_LENGTH; if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, ( tANI_U8* )pMacHdr->bssId, &cfgLen ) ) { limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil" "e sending an Add TS Request.") ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; } #endif //TO SUPPORT BT-AMP sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr); #endif // That done, pack the struct: if ( ! pAddTS->wmeTspecPresent ) { nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack an Add TS Request " "(0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing " "an Add TS Request (0x%08x)."), nStatus ); } } else { nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque" "st (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing " "a WMM Add TS Request (0x%08x)."), nStatus ); } } PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") ); limPrintMacAddr( pMac, peerMacAddr, LOG3 );) if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } // Queue Addts Response frame in high priority WQ halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request" " (%X) ***" ), halstatus ); //Pkt will be freed up by the callback } } // End limSendAddtsReqActionFrame. void limSendAssocRspMgmtFrame(tpAniSirGlobal pMac, tANI_U16 statusCode, tANI_U16 aid, tSirMacAddr peerMacAddr, tANI_U8 subType, tpDphHashNode pSta,tpPESession psessionEntry) { static tDot11fAssocResponse frm; tANI_U8 *pFrame, *macAddr; tpSirMacMgmtHdr pMacHdr; tSirRetStatus nSirStatus; tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0; tHalBitVal qosMode, wmeMode; tANI_U32 nPayload, nBytes, nStatus; void *pPacket; eHalStatus halstatus; tUpdateBeaconParams beaconParams; tANI_U8 txFlag = 0; tANI_U32 addnIEPresent = false; tANI_U32 addnIELen=0; tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN]; tpSirAssocReq pAssocReq = NULL; if(NULL == psessionEntry) { return; } vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); limGetQosMode(psessionEntry, &qosMode); limGetWmeMode(psessionEntry, &wmeMode); // An Add TS IE is added only if the AP supports it and the requesting // STA sent a traffic spec. fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0; PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry ); frm.Status.status = statusCode; frm.AID.associd = aid | LIM_AID_MASK; if ( NULL == pSta ) { PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry); PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry ); } else { PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates, pSta->supportedRates.llbRates, pSta->supportedRates.llaRates ); } if(psessionEntry->limSystemRole == eLIM_AP_ROLE) { if( pSta != NULL && eSIR_SUCCESS == statusCode ) { pAssocReq = (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId]; /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */ if( pAssocReq != NULL && pAssocReq->addIEPresent ) { PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq); } } } if ( NULL != pSta ) { if ( eHAL_SET == qosMode ) { if ( pSta->lleEnabled ) { lleMode = 1; if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ) { PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry); // FramesToDo:... // if ( fAddTS ) // { // tANI_U8 *pAf = pBody; // *pAf++ = SIR_MAC_QOS_ACTION_EID; // tANI_U32 tlen; // status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL, // &tlen, bufLen - frameLen); // } // End if on Add TS. } } // End if on .11e enabled in 'pSta'. } // End if on QOS Mode on. if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled ) { if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) ) { PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry); if ( pSta->wsmEnabled ) { PopulateDot11fWMMCaps(&frm.WMMCaps ); } } } if ( pSta->aniPeer ) { if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) || ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) ) { edcaInclude = 1; } } // End if on Airgo peer. if ( pSta->mlmStaContext.htCapability && psessionEntry->htCapability ) { PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps ); PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry ); } #ifdef WLAN_FEATURE_11AC if( pSta->mlmStaContext.vhtCapability && psessionEntry->vhtCapability ) { limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response")); PopulateDot11fVHTCaps( pMac, &frm.VHTCaps ); PopulateDot11fVHTOperation( pMac, &frm.VHTOperation); PopulateDot11fExtCap( pMac, &frm.ExtCap); } #endif } // End if on non-NULL 'pSta'. vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0); if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){ if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE) limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry); } limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry); limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry); beaconParams.bssIdx = psessionEntry->bssIdx; //Send message to HAL about beacon parameter change. if(beaconParams.paramChangeBitmap) { schSetFixedBeaconFields(pMac,psessionEntry); limSendBeaconParams(pMac, &beaconParams, psessionEntry ); } // Allocate a buffer for this frame: nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to calculate the packed size f" "or an Association Response (0x%08x)."), nStatus ); return; } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for an Association Re" "sponse (0x%08x)."), nStatus ); } nBytes = sizeof( tSirMacMgmtHdr ) + nPayload; if ( pAssocReq != NULL ) { if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, &addnIEPresent) != eSIR_SUCCESS) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG")); return; } if (addnIEPresent) { //Assoc rsp IE available if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA, &addnIELen) != eSIR_SUCCESS) { limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length")); return; } if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen && (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE) { if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA, &addIE[0], &addnIELen) == eSIR_SUCCESS) { nBytes = nBytes + addnIELen; } } } } halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP.")); return; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, ( LIM_ASSOC == subType ) ? SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP, peerMacAddr,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for an Association Response (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); nStatus = dot11fPackAssocResponse( pMac, &frm, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing an " "Association Response (0x%08x)."), nStatus ); } macAddr = pMacHdr->da; if (subType == LIM_ASSOC) { PELOG1(limLog(pMac, LOG1, FL("*** Sending Assoc Resp status %d aid %d to "), statusCode, aid);) } else{ PELOG1(limLog(pMac, LOG1, FL("*** Sending ReAssoc Resp status %d aid %d to "), statusCode, aid);) } PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);) if ( addnIEPresent ) { vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ; } if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } /// Queue Association Response frame in high priority WQ halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog(pMac, LOGE, FL("*** Could not Send Re/AssocRsp, retCode=%X ***"), nSirStatus); //Pkt will be freed up by the callback } // update the ANI peer station count //FIXME_PROTECTION : take care of different type of station // counter inside this function. limUtilCountStaAdd(pMac, pSta, psessionEntry); } // End limSendAssocRspMgmtFrame. void limSendAddtsRspActionFrame(tpAniSirGlobal pMac, tSirMacAddr peer, tANI_U16 nStatusCode, tSirAddtsReqInfo *pAddTS, tSirMacScheduleIE *pSchedule, tpPESession psessionEntry) { tANI_U8 *pFrame; tpSirMacMgmtHdr pMacHdr; tDot11fAddTSResponse AddTSRsp; tDot11fWMMAddTSResponse WMMAddTSRsp; tSirRetStatus nSirStatus; tANI_U32 i, nBytes, nPayload, nStatus; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; if(NULL == psessionEntry) { return; } if ( ! pAddTS->wmeTspecPresent ) { vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 ); AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT; AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP; AddTSRsp.DialogToken.token = pAddTS->dialogToken; AddTSRsp.Status.status = nStatusCode; // The TsDelay information element is only filled in for a specific // status code: if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode ) { if ( pAddTS->wsmTspecPresent ) { AddTSRsp.WMMTSDelay.version = 1; AddTSRsp.WMMTSDelay.delay = 10; AddTSRsp.WMMTSDelay.present = 1; } else { AddTSRsp.TSDelay.delay = 10; AddTSRsp.TSDelay.present = 1; } } if ( pAddTS->wsmTspecPresent ) { PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC ); } else { PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC ); } if ( pAddTS->wsmTspecPresent ) { AddTSRsp.num_WMMTCLAS = 0; AddTSRsp.num_TCLAS = pAddTS->numTclas; for ( i = 0; i < AddTSRsp.num_TCLAS; ++i) { PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i], &AddTSRsp.TCLAS[i] ); } } else { AddTSRsp.num_TCLAS = 0; AddTSRsp.num_WMMTCLAS = pAddTS->numTclas; for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i) { PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i], &AddTSRsp.WMMTCLAS[i] ); } } if ( pAddTS->tclasProcPresent ) { if ( pAddTS->wsmTspecPresent ) { AddTSRsp.WMMTCLASPROC.version = 1; AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc; AddTSRsp.WMMTCLASPROC.present = 1; } else { AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc; AddTSRsp.TCLASSPROC.present = 1; } } // schedule element is included only if requested in the tspec and we are // using hcca (or both edca and hcca) // 11e-D8.0 is inconsistent on whether the schedule element is included // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but // pg 46, line 17-18 says something else. So just include it and let the // sta figure it out if ((pSchedule != NULL) && ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) || (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH))) { if ( pAddTS->wsmTspecPresent ) { PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule ); } else { PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule ); } } nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed si" "ze for an Add TS Response (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fAddTSResponse ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calcula" "ting the packed size for an Add TS" " Response (0x%08x)."), nStatus ); } } else { vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 ); WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME; WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP; WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken; WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode; PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC ); nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed si" "ze for a WMM Add TS Response (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fWMMAddTSResponse ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calcula" "ting the packed size for a WMM Add" "TS Response (0x%08x)."), nStatus ); } } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad" "d TS Response."), nBytes ); return; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for an Add TS Response (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; #if 0 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, ( tANI_U8* )pMacHdr->bssId, &cfgLen ) ) { limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil" "e sending an Add TS Response.") ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } #endif //TO SUPPORT BT-AMP sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif // That done, pack the struct: if ( ! pAddTS->wmeTspecPresent ) { nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack an Add TS Response " "(0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing " "an Add TS Response (0x%08x)."), nStatus ); } } else { nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response " "(0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing " "a WMM Add TS Response (0x%08x)."), nStatus ); } } PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "), nStatusCode ); limPrintMacAddr( pMac, pMacHdr->da, LOG1 );) if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } // Queue the frame in high priority WQ: halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"), nSirStatus ); //Pkt will be freed up by the callback } } // End limSendAddtsRspActionFrame. void limSendDeltsReqActionFrame(tpAniSirGlobal pMac, tSirMacAddr peer, tANI_U8 wmmTspecPresent, tSirMacTSInfo *pTsinfo, tSirMacTspecIE *pTspecIe, tpPESession psessionEntry) { tANI_U8 *pFrame; tpSirMacMgmtHdr pMacHdr; tDot11fDelTS DelTS; tDot11fWMMDelTS WMMDelTS; tSirRetStatus nSirStatus; tANI_U32 nBytes, nPayload, nStatus; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; if(NULL == psessionEntry) { return; } if ( ! wmmTspecPresent ) { vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 ); DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT; DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ; PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo ); nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed si" "ze for a Del TS (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fDelTS ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calcula" "ting the packed size for a Del TS" " (0x%08x)."), nStatus ); } } else { vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 ); WMMDelTS.Category.category = SIR_MAC_ACTION_WME; WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ; WMMDelTS.DialogToken.token = 0; WMMDelTS.StatusCode.statusCode = 0; PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC ); nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed si" "ze for a WMM Del TS (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fDelTS ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calcula" "ting the packed size for a WMM De" "l TS (0x%08x)."), nStatus ); } } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad" "d TS Response."), nBytes ); return; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for an Add TS Response (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; #if 0 cfgLen = SIR_MAC_ADDR_LENGTH; if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, ( tANI_U8* )pMacHdr->bssId, &cfgLen ) ) { limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil" "e sending an Add TS Response.") ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } #endif //TO SUPPORT BT-AMP sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif // That done, pack the struct: if ( !wmmTspecPresent ) { nStatus = dot11fPackDelTS( pMac, &DelTS, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing " "a Del TS frame (0x%08x)."), nStatus ); } } else { nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing " "a WMM Del TS frame (0x%08x)."), nStatus ); } } PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes); limPrintMacAddr(pMac, pMacHdr->da, LOG1);) if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"), nSirStatus ); //Pkt will be freed up by the callback } } // End limSendDeltsReqActionFrame. void limSendAssocReqMgmtFrame(tpAniSirGlobal pMac, tLimMlmAssocReq *pMlmAssocReq, tpPESession psessionEntry) { tDot11fAssocRequest *pFrm; tANI_U16 caps; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tLimMlmAssocCnf mlmAssocCnf; tANI_U32 nBytes, nPayload, nStatus; tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled; void *pPacket; eHalStatus halstatus; tANI_U16 nAddIELen; tANI_U8 *pAddIE; tANI_U8 *wpsIe = NULL; #if defined WLAN_FEATURE_VOWIFI tANI_U8 PowerCapsPopulated = FALSE; #endif tANI_U8 txFlag = 0; if(NULL == psessionEntry) { return; } if(NULL == psessionEntry->pLimJoinReq) { return; } /* check this early to avoid unncessary operation */ if(NULL == psessionEntry->pLimJoinReq) { return; } nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length; pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata; pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest)); if ( NULL == pFrm ) { limLog(pMac, LOGE, FL("Unable to allocate memory in limSendAssocReqMgmtFrame") ); return; } vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 ); caps = pMlmAssocReq->capabilityInfo; if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) ) ((tSirMacCapabilityInfo *) &caps)->qos = 0; #if defined(FEATURE_WLAN_WAPI) /* CR: 262463 : According to WAPI standard: 7.3.1.4 Capability Information field In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and Reassociation management frames. */ if ( psessionEntry->encryptType == eSIR_ED_WPI) ((tSirMacCapabilityInfo *) &caps)->privacy = 0; #endif swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities ); pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval; PopulateDot11fSSID2( pMac, &pFrm->SSID ); PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &pFrm->SuppRates,psessionEntry); fQosEnabled = ( psessionEntry->limQosEnabled) && SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps ); fWmeEnabled = ( psessionEntry->limWmeEnabled ) && LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps ); // We prefer .11e asociations: if ( fQosEnabled ) fWmeEnabled = false; fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled && LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps ); if ( psessionEntry->lim11hEnable && psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE ) { #if defined WLAN_FEATURE_VOWIFI PowerCapsPopulated = TRUE; PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry); #endif PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry); } #if defined WLAN_FEATURE_VOWIFI if( pMac->rrm.rrmPEContext.rrmEnable && SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) ) { if (PowerCapsPopulated == FALSE) { PowerCapsPopulated = TRUE; PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry); } } #endif if ( fQosEnabled && ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap))) PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation ); PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &pFrm->ExtSuppRates, psessionEntry ); #if defined WLAN_FEATURE_VOWIFI if( pMac->rrm.rrmPEContext.rrmEnable && SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) ) { PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry ); } #endif // The join request *should* contain zero or one of the WPA and RSN // IEs. The payload send along with the request is a // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie': // typedef struct sSirRSNie // { // tANI_U16 length; // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2]; // } tSirRSNie, *tpSirRSNie; // So, we should be able to make the following two calls harmlessly, // since they do nothing if they don't find the given IE in the // bytestream with which they're provided. // The net effect of this will be to faithfully transmit whatever // security IE is in the join request. // *However*, if we're associating for the purpose of WPS // enrollment, and we've been configured to indicate that by // eliding the WPA or RSN IE, we just skip this: if( nAddIELen && pAddIE ) { wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen); } if ( NULL == wpsIe ) { PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ), &pFrm->RSNOpaque ); PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ), &pFrm->WPAOpaque ); #if defined(FEATURE_WLAN_WAPI) PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ), &pFrm->WAPIOpaque ); #endif // defined(FEATURE_WLAN_WAPI) } // include WME EDCA IE as well if ( fWmeEnabled ) { if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) ) { PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation ); } if ( fWsmEnabled && ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap ))) { PopulateDot11fWMMCaps( &pFrm->WMMCaps ); } } //Populate HT IEs, when operating in 11n or Taurus modes AND //when AP is also operating in 11n mode. if ( psessionEntry->htCapability && pMac->lim.htCapabilityPresentInBeacon) { PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps ); #ifdef DISABLE_GF_FOR_INTEROP /* * To resolve the interop problem with Broadcom AP, * where TQ STA could not pass traffic with GF enabled, * TQ STA will do Greenfield only with TQ AP, for * everybody else it will be turned off. */ if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator)) { limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield")); pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE; } #endif } #ifdef WLAN_FEATURE_11AC if ( psessionEntry->vhtCapability && psessionEntry->vhtCapabilityPresentInBeacon) { limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request")); PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps ); PopulateDot11fExtCap( pMac, &pFrm->ExtCap); } #endif #if defined WLAN_FEATURE_VOWIFI_11R if (psessionEntry->pLimJoinReq->is11Rconnection) { #if defined WLAN_FEATURE_VOWIFI_11R_DEBUG limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"), (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0], (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1], (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]); #endif PopulateMDIE( pMac, &pFrm->MobilityDomain, psessionEntry->pLimJoinReq->bssDescription.mdie); } else { // No 11r IEs dont send any MDIE limLog( pMac, LOG1, FL("MDIE not present")); } #endif #ifdef FEATURE_WLAN_CCX /* For CCX Associations fill the CCX IEs */ if (psessionEntry->isCCXconnection && psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled) { #ifndef FEATURE_DISABLE_RM PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap); #endif PopulateDot11fCCXVersion(&pFrm->CCXVersion); } #endif nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or an Association Request (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fAssocRequest ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for an Association Re " "quest(0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen; halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As" "sociation Request."), nBytes ); psessionEntry->limMlmState = psessionEntry->limPrevMlmState; MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState)); /* Update PE session id*/ mlmAssocCnf.sessionId = psessionEntry->peSessionId; mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE; palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF, ( tANI_U32* ) &mlmAssocCnf); vos_mem_free(pFrm); return; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for an Association Request (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); vos_mem_free(pFrm); return; } // That done, pack the Probe Request: nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0" "8x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); vos_mem_free(pFrm); return; } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a P" "robe Response (0x%08x)."), nStatus ); } PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d" "to "), nBytes );) // limPrintMacAddr( pMac, bssid, LOG1 ); if( psessionEntry->assocReq != NULL ) { vos_mem_free(psessionEntry->assocReq); psessionEntry->assocReq = NULL; } if( nAddIELen ) { vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload, pAddIE, nAddIELen ); nPayload += nAddIELen; } psessionEntry->assocReq = vos_mem_malloc(nPayload); if ( NULL == psessionEntry->assocReq ) { PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));) } else { //Store the Assoc request. This is sent to csr/hdd in join cnf response. vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload); psessionEntry->assocReqLen = nPayload; } if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) { txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK; } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload), HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"), halstatus ); //Pkt will be freed up by the callback vos_mem_free(pFrm); return; } // Free up buffer allocated for mlmAssocReq vos_mem_free(pMlmAssocReq); pMlmAssocReq = NULL; vos_mem_free(pFrm); return; } // End limSendAssocReqMgmtFrame #if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR) /*------------------------------------------------------------------------------------ * * Send Reassoc Req with FTIEs. * *----------------------------------------------------------------------------------- */ void limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac, tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry) { static tDot11fReAssocRequest frm; tANI_U16 caps; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tANI_U32 nBytes, nPayload, nStatus; tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled; void *pPacket; eHalStatus halstatus; #if defined WLAN_FEATURE_VOWIFI tANI_U8 PowerCapsPopulated = FALSE; #endif tANI_U16 ft_ies_length = 0; tANI_U8 *pBody; tANI_U16 nAddIELen; tANI_U8 *pAddIE; #if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR) tANI_U8 *wpsIe = NULL; #endif tANI_U8 txFlag = 0; if (NULL == psessionEntry) { return; } /* check this early to avoid unncessary operation */ if(NULL == psessionEntry->pLimReAssocReq) { return; } nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length; pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata; limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in " "state (%d)."), psessionEntry->limMlmState); vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); caps = pMlmReassocReq->capabilityInfo; if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap)) ((tSirMacCapabilityInfo *) &caps)->qos = 0; #if defined(FEATURE_WLAN_WAPI) /* CR: 262463 : According to WAPI standard: 7.3.1.4 Capability Information field In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and Reassociation management frames. */ if ( psessionEntry->encryptType == eSIR_ED_WPI) ((tSirMacCapabilityInfo *) &caps)->privacy = 0; #endif swapBitField16(caps, ( tANI_U16* )&frm.Capabilities ); frm.ListenInterval.interval = pMlmReassocReq->listenInterval; // Get the old bssid of the older AP. vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac, pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6); PopulateDot11fSSID2( pMac, &frm.SSID ); PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry); fQosEnabled = ( psessionEntry->limQosEnabled) && SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps ); fWmeEnabled = ( psessionEntry->limWmeEnabled ) && LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps ); fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled && LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps ); if ( psessionEntry->lim11hEnable && psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE ) { #if defined WLAN_FEATURE_VOWIFI PowerCapsPopulated = TRUE; PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry); PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry); #endif } #if defined WLAN_FEATURE_VOWIFI if( pMac->rrm.rrmPEContext.rrmEnable && SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) ) { if (PowerCapsPopulated == FALSE) { PowerCapsPopulated = TRUE; PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry); } } #endif if ( fQosEnabled && ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) )) { PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation ); } PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry ); #if defined WLAN_FEATURE_VOWIFI if( pMac->rrm.rrmPEContext.rrmEnable && SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) ) { PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry ); } #endif // Ideally this should be enabled for 11r also. But 11r does // not follow the usual norm of using the Opaque object // for rsnie and fties. Instead we just add // the rsnie and fties at the end of the pack routine for 11r. // This should ideally! be fixed. #if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR) // // The join request *should* contain zero or one of the WPA and RSN // IEs. The payload send along with the request is a // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie': // typedef struct sSirRSNie // { // tANI_U16 length; // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2]; // } tSirRSNie, *tpSirRSNie; // So, we should be able to make the following two calls harmlessly, // since they do nothing if they don't find the given IE in the // bytestream with which they're provided. // The net effect of this will be to faithfully transmit whatever // security IE is in the join request. // *However*, if we're associating for the purpose of WPS // enrollment, and we've been configured to indicate that by // eliding the WPA or RSN IE, we just skip this: if (!psessionEntry->is11Rconnection) { if( nAddIELen && pAddIE ) { wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen); } if ( NULL == wpsIe ) { PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ), &frm.RSNOpaque ); PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ), &frm.WPAOpaque ); } #ifdef FEATURE_WLAN_CCX if (psessionEntry->pLimReAssocReq->cckmIE.length) { PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ), &frm.CCXCckmOpaque ); } #endif //FEATURE_WLAN_CCX } #ifdef FEATURE_WLAN_CCX // For CCX Associations fill the CCX IEs if (psessionEntry->isCCXconnection && psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled) { #ifndef FEATURE_DISABLE_RM PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap); #endif PopulateDot11fCCXVersion(&frm.CCXVersion); } #endif //FEATURE_WLAN_CCX #endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR // include WME EDCA IE as well if ( fWmeEnabled ) { if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) ) { PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation ); } if ( fWsmEnabled && ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap ))) { PopulateDot11fWMMCaps( &frm.WMMCaps ); } #ifdef FEATURE_WLAN_CCX if (psessionEntry->isCCXconnection) { PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry); // Populate the TSRS IE if TSPEC is included in the reassoc request if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs) { tANI_U32 phyMode; tSirMacCCXTSRSIE tsrsIE; limGetPhyMode(pMac, &phyMode, psessionEntry); tsrsIE.tsid = 0; if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A) { tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS; } else { tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS; } PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8)); } } #endif } if ( psessionEntry->htCapability && pMac->lim.htCapabilityPresentInBeacon) { PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps ); } #if defined WLAN_FEATURE_VOWIFI_11R if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length) #if defined FEATURE_WLAN_CCX && !psessionEntry->isCCXconnection #endif ) { PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie); } #endif #ifdef WLAN_FEATURE_11AC if ( psessionEntry->vhtCapability && psessionEntry->vhtCapabilityPresentInBeacon) { limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request")); PopulateDot11fVHTCaps( pMac, &frm.VHTCaps ); PopulateDot11fExtCap( pMac, &frm.ExtCap); } #endif nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Re-Association Request (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fReAssocRequest ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Re-Association Re " "quest(0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen; #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."), pMac->ft.ftSmeContext.reassoc_ft_ies_length); #endif #if defined WLAN_FEATURE_VOWIFI_11R if (psessionEntry->is11Rconnection) { ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length; } #endif halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { psessionEntry->limMlmState = psessionEntry->limPrevMlmState; MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState)); limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As" "sociation Request."), nBytes ); goto end; } // Paranoia: vos_mem_set( pFrame, nBytes + ft_ies_length, 0); #if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR) limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1); #endif // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_REASSOC_REQ, psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for an Association Request (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); goto end; } // That done, pack the ReAssoc Request: nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque" "st (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); goto end; } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a R" "e-Association Request (0x%08x)."), nStatus ); } PELOG3(limLog( pMac, LOG3, FL("*** Sending Re-Association Request length %d %d to "), nBytes, nPayload );) if( psessionEntry->assocReq != NULL ) { vos_mem_free(psessionEntry->assocReq); psessionEntry->assocReq = NULL; } if( nAddIELen ) { vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload, pAddIE, nAddIELen ); nPayload += nAddIELen; } psessionEntry->assocReq = vos_mem_malloc(nPayload); if ( NULL == psessionEntry->assocReq ) { PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));) } else { //Store the Assoc request. This is sent to csr/hdd in join cnf response. vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload); psessionEntry->assocReqLen = nPayload; } if (psessionEntry->is11Rconnection) { { int i = 0; pBody = pFrame + nBytes; for (i=0; i<ft_ies_length; i++) { *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i]; pBody++; } } } #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: ")); sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1, (tANI_U8 *)pFrame, (nBytes + ft_ies_length));) #endif if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if( NULL != psessionEntry->assocReq ) { vos_mem_free(psessionEntry->assocReq); psessionEntry->assocReq = NULL; } psessionEntry->assocReq = vos_mem_malloc(ft_ies_length); if ( NULL == psessionEntry->assocReq ) { PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));) psessionEntry->assocReqLen = 0; } else { //Store the Assoc request. This is sent to csr/hdd in join cnf response. vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies, (ft_ies_length)); psessionEntry->assocReqLen = (ft_ies_length); } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length), HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send Re-Association Request" "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback goto end; } end: // Free up buffer allocated for mlmAssocReq vos_mem_free( pMlmReassocReq ); psessionEntry->pLimMlmReassocReq = NULL; } void limSendRetryReassocReqFrame(tpAniSirGlobal pMac, tLimMlmReassocReq *pMlmReassocReq, tpPESession psessionEntry) { tLimMlmReassocCnf mlmReassocCnf; // keep sme tLimMlmReassocReq *pTmpMlmReassocReq = NULL; if(NULL == pTmpMlmReassocReq) { pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq)); if ( NULL == pTmpMlmReassocReq ) goto end; vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0); vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq)); } // Prepare and send Reassociation request frame // start reassoc timer. pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId; // Start reassociation failure timer MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER)); if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer) != TX_SUCCESS) { // Could not start reassoc failure timer. // Log error limLog(pMac, LOGP, FL("could not start Reassociation failure timer")); // Return Reassoc confirm with // Resources Unavailable mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE; mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS; goto end; } limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry); return; end: // Free up buffer allocated for reassocReq if (pMlmReassocReq != NULL) { vos_mem_free(pMlmReassocReq); pMlmReassocReq = NULL; } if (pTmpMlmReassocReq != NULL) { vos_mem_free(pTmpMlmReassocReq); pTmpMlmReassocReq = NULL; } mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE; mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS; /* Update PE sessio Id*/ mlmReassocCnf.sessionId = psessionEntry->peSessionId; limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf); } #endif /* WLAN_FEATURE_VOWIFI_11R */ void limSendReassocReqMgmtFrame(tpAniSirGlobal pMac, tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry) { static tDot11fReAssocRequest frm; tANI_U16 caps; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tANI_U32 nBytes, nPayload, nStatus; tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled; void *pPacket; eHalStatus halstatus; tANI_U16 nAddIELen; tANI_U8 *pAddIE; tANI_U8 *wpsIe = NULL; tANI_U8 txFlag = 0; #if defined WLAN_FEATURE_VOWIFI tANI_U8 PowerCapsPopulated = FALSE; #endif if(NULL == psessionEntry) { return; } /* check this early to avoid unncessary operation */ if(NULL == psessionEntry->pLimReAssocReq) { return; } nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length; pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata; vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); caps = pMlmReassocReq->capabilityInfo; if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap)) ((tSirMacCapabilityInfo *) &caps)->qos = 0; #if defined(FEATURE_WLAN_WAPI) /* CR: 262463 : According to WAPI standard: 7.3.1.4 Capability Information field In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and Reassociation management frames. */ if ( psessionEntry->encryptType == eSIR_ED_WPI) ((tSirMacCapabilityInfo *) &caps)->privacy = 0; #endif swapBitField16(caps, ( tANI_U16* )&frm.Capabilities ); frm.ListenInterval.interval = pMlmReassocReq->listenInterval; vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac, ( tANI_U8* )psessionEntry->bssId, 6 ); PopulateDot11fSSID2( pMac, &frm.SSID ); PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry); fQosEnabled = ( psessionEntry->limQosEnabled ) && SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps ); fWmeEnabled = ( psessionEntry->limWmeEnabled ) && LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps ); fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled && LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps ); if ( psessionEntry->lim11hEnable && psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE ) { #if defined WLAN_FEATURE_VOWIFI PowerCapsPopulated = TRUE; PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry); PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry); #endif } #if defined WLAN_FEATURE_VOWIFI if( pMac->rrm.rrmPEContext.rrmEnable && SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) ) { if (PowerCapsPopulated == FALSE) { PowerCapsPopulated = TRUE; PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry); } } #endif if ( fQosEnabled && ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) )) { PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation ); } PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry ); #if defined WLAN_FEATURE_VOWIFI if( pMac->rrm.rrmPEContext.rrmEnable && SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) ) { PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry ); } #endif // The join request *should* contain zero or one of the WPA and RSN // IEs. The payload send along with the request is a // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie': // typedef struct sSirRSNie // { // tANI_U16 length; // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2]; // } tSirRSNie, *tpSirRSNie; // So, we should be able to make the following two calls harmlessly, // since they do nothing if they don't find the given IE in the // bytestream with which they're provided. // The net effect of this will be to faithfully transmit whatever // security IE is in the join request. // *However*, if we're associating for the purpose of WPS // enrollment, and we've been configured to indicate that by // eliding the WPA or RSN IE, we just skip this: if( nAddIELen && pAddIE ) { wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen); } if ( NULL == wpsIe ) { PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ), &frm.RSNOpaque ); PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ), &frm.WPAOpaque ); #if defined(FEATURE_WLAN_WAPI) PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ), &frm.WAPIOpaque ); #endif // defined(FEATURE_WLAN_WAPI) } // include WME EDCA IE as well if ( fWmeEnabled ) { if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) ) { PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation ); } if ( fWsmEnabled && ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap ))) { PopulateDot11fWMMCaps( &frm.WMMCaps ); } } if ( psessionEntry->htCapability && pMac->lim.htCapabilityPresentInBeacon) { PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps ); } #ifdef WLAN_FEATURE_11AC if ( psessionEntry->vhtCapability && psessionEntry->vhtCapabilityPresentInBeacon) { limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request")); PopulateDot11fVHTCaps( pMac, &frm.VHTCaps ); PopulateDot11fExtCap( pMac, &frm.ExtCap); } #endif nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Re-Association Request (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fReAssocRequest ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Re-Association Re " "quest(0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen; halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { psessionEntry->limMlmState = psessionEntry->limPrevMlmState; MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState)); limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As" "sociation Request."), nBytes ); goto end; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_REASSOC_REQ, psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for an Association Request (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); goto end; } // That done, pack the Probe Request: nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque" "st (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); goto end; } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a R" "e-Association Request (0x%08x)."), nStatus ); } PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d" "to "), nBytes );) if( psessionEntry->assocReq != NULL ) { vos_mem_free(psessionEntry->assocReq); psessionEntry->assocReq = NULL; } if( nAddIELen ) { vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload, pAddIE, nAddIELen ); nPayload += nAddIELen; } psessionEntry->assocReq = vos_mem_malloc(nPayload); if ( NULL == psessionEntry->assocReq ) { PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));) } else { //Store the Assoc request. This is sent to csr/hdd in join cnf response. vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload); psessionEntry->assocReqLen = nPayload; } if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) { txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK; } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload), HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send Re-Association Request" "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback goto end; } end: // Free up buffer allocated for mlmAssocReq vos_mem_free( pMlmReassocReq ); psessionEntry->pLimMlmReassocReq = NULL; } // limSendReassocReqMgmtFrame /** * \brief Send an Authentication frame * * * \param pMac Pointer to Global MAC structure * * \param pAuthFrameBody Pointer to Authentication frame structure that need * to be sent * * \param peerMacAddr MAC address of the peer entity to which Authentication * frame is destined * * \param wepBit Indicates whether wep bit to be set in FC while sending * Authentication frame3 * * * This function is called by limProcessMlmMessages(). Authentication frame * is formatted and sent when this function is called. * * */ void limSendAuthMgmtFrame(tpAniSirGlobal pMac, tpSirMacAuthFrameBody pAuthFrameBody, tSirMacAddr peerMacAddr, tANI_U8 wepBit, tpPESession psessionEntry ) { tANI_U8 *pFrame, *pBody; tANI_U32 frameLen = 0, bodyLen = 0; tpSirMacMgmtHdr pMacHdr; tANI_U16 i; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; if(NULL == psessionEntry) { return; } if (wepBit == LIM_WEP_IN_FC) { /// Auth frame3 to be sent with encrypted framebody /** * Allocate buffer for Authenticaton frame of size equal * to management frame header length plus 2 bytes each for * auth algorithm number, transaction number, status code, * 128 bytes for challenge text and 4 bytes each for * IV & ICV. */ frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN; bodyLen = LIM_ENCR_AUTH_BODY_LEN; } // if (wepBit == LIM_WEP_IN_FC) else { switch (pAuthFrameBody->authTransactionSeqNumber) { case SIR_MAC_AUTH_FRAME_1: /** * Allocate buffer for Authenticaton frame of size * equal to management frame header length plus 2 bytes * each for auth algorithm number, transaction number * and status code. */ frameLen = sizeof(tSirMacMgmtHdr) + SIR_MAC_AUTH_CHALLENGE_OFFSET; bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET; #if defined WLAN_FEATURE_VOWIFI_11R if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) { if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length) { frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"), pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length); } else { limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!")); frameLen += (2+SIR_MDIE_SIZE); } } #endif break; case SIR_MAC_AUTH_FRAME_2: if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) || ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) && (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS))) { /** * Allocate buffer for Authenticaton frame of size * equal to management frame header length plus * 2 bytes each for auth algorithm number, * transaction number and status code. */ frameLen = sizeof(tSirMacMgmtHdr) + SIR_MAC_AUTH_CHALLENGE_OFFSET; bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET; } else { // Shared Key algorithm with challenge text // to be sent /** * Allocate buffer for Authenticaton frame of size * equal to management frame header length plus * 2 bytes each for auth algorithm number, * transaction number, status code and 128 bytes * for challenge text. */ frameLen = sizeof(tSirMacMgmtHdr) + sizeof(tSirMacAuthFrame); bodyLen = sizeof(tSirMacAuthFrameBody); } break; case SIR_MAC_AUTH_FRAME_3: /// Auth frame3 to be sent without encrypted framebody /** * Allocate buffer for Authenticaton frame of size equal * to management frame header length plus 2 bytes each * for auth algorithm number, transaction number and * status code. */ frameLen = sizeof(tSirMacMgmtHdr) + SIR_MAC_AUTH_CHALLENGE_OFFSET; bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET; break; case SIR_MAC_AUTH_FRAME_4: /** * Allocate buffer for Authenticaton frame of size equal * to management frame header length plus 2 bytes each * for auth algorithm number, transaction number and * status code. */ frameLen = sizeof(tSirMacMgmtHdr) + SIR_MAC_AUTH_CHALLENGE_OFFSET; bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET; break; } // switch (pAuthFrameBody->authTransactionSeqNumber) } // end if (wepBit == LIM_WEP_IN_FC) halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { // Log error limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame")); return; } for (i = 0; i < frameLen; i++) pFrame[i] = 0; // Prepare BD if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS) { palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; pMacHdr->fc.wep = wepBit; // Prepare BSSId if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ) { vos_mem_copy( (tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) psessionEntry->bssId, sizeof( tSirMacAddr )); } /// Prepare Authentication frame body pBody = pFrame + sizeof(tSirMacMgmtHdr); if (wepBit == LIM_WEP_IN_FC) { vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen); PELOG1(limLog(pMac, LOG1, FL("*** Sending Auth seq# 3 status %d (%d) to"), pAuthFrameBody->authStatusCode, (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)); limPrintMacAddr(pMac, pMacHdr->da, LOG1);) } else { *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber); pBody += sizeof(tANI_U16); bodyLen -= sizeof(tANI_U16); *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber); pBody += sizeof(tANI_U16); bodyLen -= sizeof(tANI_U16); *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode); pBody += sizeof(tANI_U16); bodyLen -= sizeof(tANI_U16); if ( bodyLen <= (sizeof (pAuthFrameBody->type) + sizeof (pAuthFrameBody->length) + sizeof (pAuthFrameBody->challengeText))) vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen); #if defined WLAN_FEATURE_VOWIFI_11R if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) && (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1)) { { int i = 0; if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length) { #if defined WLAN_FEATURE_VOWIFI_11R_DEBUG PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: ")); sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE, (tANI_U8 *)pBody, (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));) #endif for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++) { *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i]; pBody++; } } else { /* MDID attr is 54*/ *pBody = 54; pBody++; *pBody = SIR_MDIE_SIZE; pBody++; for(i=0;i<SIR_MDIE_SIZE;i++) { *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i]; pBody++; } } } } #endif PELOG1(limLog(pMac, LOG1, FL("*** Sending Auth seq# %d status %d (%d) to "), pAuthFrameBody->authTransactionSeqNumber, pAuthFrameBody->authStatusCode, (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)); limPrintMacAddr(pMac, pMacHdr->da, LOG1);) } PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);) if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq) && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum))) #endif ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) { txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK; } /// Queue Authentication frame in high priority WQ halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog(pMac, LOGE, FL("*** Could not send Auth frame, retCode=%X ***"), halstatus); //Pkt will be freed up by the callback } return; } /*** end limSendAuthMgmtFrame() ***/ eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac) { tANI_U16 aid; tpDphHashNode pStaDs; tLimMlmDeauthReq *pMlmDeauthReq; tLimMlmDeauthCnf mlmDeauthCnf; tpPESession psessionEntry; pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq; if (pMlmDeauthReq) { if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer)) { limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER); } if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL) { PELOGE(limLog(pMac, LOGE, FL("session does not exist for given sessionId"));) mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS; goto end; } pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable); if (pStaDs == NULL) { mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS; goto end; } /// Receive path cleanup with dummy packet limCleanupRxPath(pMac, pStaDs,psessionEntry); /// Free up buffer allocated for mlmDeauthReq vos_mem_free(pMlmDeauthReq); pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL; } return eHAL_STATUS_SUCCESS; end: vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr, (tANI_U8 *) pMlmDeauthReq->peerMacAddr, sizeof(tSirMacAddr)); mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger; mlmDeauthCnf.aid = pMlmDeauthReq->aid; mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId; // Free up buffer allocated // for mlmDeauthReq vos_mem_free(pMlmDeauthReq); limPostSmeMessage(pMac, LIM_MLM_DEAUTH_CNF, (tANI_U32 *) &mlmDeauthCnf); return eHAL_STATUS_SUCCESS; } eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac) { tANI_U16 aid; tpDphHashNode pStaDs; tLimMlmDisassocCnf mlmDisassocCnf; tpPESession psessionEntry; tLimMlmDisassocReq *pMlmDisassocReq; pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq; if (pMlmDisassocReq) { if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer)) { limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER); } if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL) { PELOGE(limLog(pMac, LOGE, FL("session does not exist for given sessionId"));) mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS; goto end; } pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable); if (pStaDs == NULL) { mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS; goto end; } /// Receive path cleanup with dummy packet if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry)) { mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE; goto end; } #ifdef WLAN_FEATURE_VOWIFI_11R if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) && ( #ifdef FEATURE_WLAN_CCX (psessionEntry->isCCXconnection ) || #endif #ifdef FEATURE_WLAN_LFR (psessionEntry->isFastRoamIniFeatureEnabled ) || #endif (psessionEntry->is11Rconnection )) && (pMlmDisassocReq->reasonCode != eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) { PELOGE(limLog(pMac, LOGE, FL("FT Preauth Session (%p,%d) Cleanup"), psessionEntry, psessionEntry->peSessionId);); limFTCleanup(pMac); } else { PELOGE(limLog(pMac, LOGE, FL("No FT Preauth Session Cleanup in role %d" #ifdef FEATURE_WLAN_CCX " isCCX %d" #endif #ifdef FEATURE_WLAN_LFR " isLFR %d" #endif " is11r %d reason %d"), psessionEntry->limSystemRole, #ifdef FEATURE_WLAN_CCX psessionEntry->isCCXconnection, #endif #ifdef FEATURE_WLAN_LFR psessionEntry->isFastRoamIniFeatureEnabled, #endif psessionEntry->is11Rconnection, pMlmDisassocReq->reasonCode);); } #endif /// Free up buffer allocated for mlmDisassocReq vos_mem_free(pMlmDisassocReq); pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL; return eHAL_STATUS_SUCCESS; } else { return eHAL_STATUS_SUCCESS; } end: vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr, (tANI_U8 *) pMlmDisassocReq->peerMacAddr, sizeof(tSirMacAddr)); mlmDisassocCnf.aid = pMlmDisassocReq->aid; mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger; /* Update PE session ID*/ mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId; if(pMlmDisassocReq != NULL) { /// Free up buffer allocated for mlmDisassocReq vos_mem_free(pMlmDisassocReq); pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL; } limPostSmeMessage(pMac, LIM_MLM_DISASSOC_CNF, (tANI_U32 *) &mlmDisassocCnf); return eHAL_STATUS_SUCCESS; } eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess) { return limSendDisassocCnf(pMac); } eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess) { return limSendDeauthCnf(pMac); } /** * \brief This function is called to send Disassociate frame. * * * \param pMac Pointer to Global MAC structure * * \param nReason Indicates the reason that need to be sent in * Disassociation frame * * \param peerMacAddr MAC address of the STA to which Disassociation frame is * sent * * */ void limSendDisassocMgmtFrame(tpAniSirGlobal pMac, tANI_U16 nReason, tSirMacAddr peer, tpPESession psessionEntry, tANI_BOOLEAN waitForAck) { tDot11fDisassociation frm; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; tANI_U32 val = 0; if(NULL == psessionEntry) { return; } vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0); frm.Reason.code = nReason; nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Disassociation (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fDisassociation ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Disassociation " "(0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis" "association."), nBytes ); return; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a Disassociation (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // just allocated... } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; // Prepare the BSSID sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif nStatus = dot11fPackDisassociation( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a D" "isassociation (0x%08x)."), nStatus ); } PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea" "son %d to"), nReason ); limPrintMacAddr( pMac, pMacHdr->da, LOG1 );) if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) || (psessionEntry->pePersona == VOS_P2P_GO_MODE)) { txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK; } if (waitForAck) { // Queue Disassociation frame in high priority WQ /* get the duration from the request */ halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, limDisassocTxCompleteCnf, txFlag ); val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT); if (tx_timer_change( &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0) != TX_SUCCESS) { limLog(pMac, LOGP, FL("Unable to change Disassoc ack Timer val")); return; } else if(TX_SUCCESS != tx_timer_activate( &pMac->lim.limTimers.gLimDisassocAckTimer)) { limLog(pMac, LOGP, FL("Unable to activate Disassoc ack Timer")); limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER); return; } } else { // Queue Disassociation frame in high priority WQ halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send Disassociation " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback return; } } } // End limSendDisassocMgmtFrame. /** * \brief This function is called to send a Deauthenticate frame * * * \param pMac Pointer to global MAC structure * * \param nReason Indicates the reason that need to be sent in the * Deauthenticate frame * * \param peeer address of the STA to which the frame is to be sent * * */ void limSendDeauthMgmtFrame(tpAniSirGlobal pMac, tANI_U16 nReason, tSirMacAddr peer, tpPESession psessionEntry, tANI_BOOLEAN waitForAck) { tDot11fDeAuth frm; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; tANI_U32 val = 0; #ifdef FEATURE_WLAN_TDLS tANI_U16 aid; tpDphHashNode pStaDs; #endif if(NULL == psessionEntry) { return; } vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 ); frm.Reason.code = nReason; nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a De-Authentication (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fDeAuth ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a De-Authentication " "(0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-" "Authentication."), nBytes ); return; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a De-Authentication (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // just allocated... } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; // Prepare the BSSID sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif nStatus = dot11fPackDeAuth( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a D" "e-Authentication (0x%08x)."), nStatus ); } PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea" "son %d to"), nReason ); limPrintMacAddr( pMac, pMacHdr->da, LOG1 );) if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) || (psessionEntry->pePersona == VOS_P2P_GO_MODE)) { txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK; } #ifdef FEATURE_WLAN_TDLS pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable); #endif if (waitForAck) { // Queue Disassociation frame in high priority WQ halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send De-Authentication " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback limTxComplete /*Call limProcessDeauthAckTimeout which will send * DeauthCnf for this frame */ limProcessDeauthAckTimeout(pMac); return; } val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT); if (tx_timer_change( &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0) != TX_SUCCESS) { limLog(pMac, LOGP, FL("Unable to change Deauth ack Timer val")); return; } else if(TX_SUCCESS != tx_timer_activate( &pMac->lim.limTimers.gLimDeauthAckTimer)) { limLog(pMac, LOGP, FL("Unable to activate Deauth ack Timer")); limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER); return; } } else { #ifdef FEATURE_WLAN_TDLS if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) { // Queue Disassociation frame in high priority WQ halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); } else { #endif // Queue Disassociation frame in high priority WQ halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); #ifdef FEATURE_WLAN_TDLS } #endif if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send De-Authentication " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback return; } } } // End limSendDeauthMgmtFrame. #ifdef ANI_SUPPORT_11H /** * \brief Send a Measurement Report Action frame * * * \param pMac Pointer to the global MAC structure * * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame * * \return eSIR_SUCCESS on success, eSIR_FAILURE else * * */ tSirRetStatus limSendMeasReportFrame(tpAniSirGlobal pMac, tpSirMacMeasReqActionFrame pMeasReqFrame, tSirMacAddr peer) { tDot11fMeasurementReport frm; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus, nCfg; void *pPacket; eHalStatus halstatus; vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT; frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID; frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken; switch ( pMeasReqFrame->measReqIE.measType ) { case SIR_MAC_BASIC_MEASUREMENT_TYPE: nSirStatus = PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame, &frm.MeasurementReport ); break; case SIR_MAC_CCA_MEASUREMENT_TYPE: nSirStatus = PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame, &frm.MeasurementReport ); break; case SIR_MAC_RPI_MEASUREMENT_TYPE: nSirStatus = PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame, &frm.MeasurementReport ); break; default: limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen" "dMeasReportFrame."), pMeasReqFrame->measReqIE.measType ); return eSIR_FAILURE; } if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE; nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Measurement Report (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fMeasurementReport ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Measurement Rep" "ort (0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-" "Authentication."), nBytes ); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a Measurement Report (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // just allocated... } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; nCfg = 6; nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg ); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from" " CFG (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // just allocated... } #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a M" "easurement Report (0x%08x)."), nStatus ); } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, 0 ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send a Measurement Report " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback return eSIR_FAILURE; // just allocated... } return eSIR_SUCCESS; } // End limSendMeasReportFrame. /** * \brief Send a TPC Request Action frame * * * \param pMac Pointer to the global MAC datastructure * * \param peer MAC address to which the frame should be sent * * */ void limSendTpcRequestFrame(tpAniSirGlobal pMac, tSirMacAddr peer) { tDot11fTPCRequest frm; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus, nCfg; void *pPacket; eHalStatus halstatus; vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT; frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID; frm.DialogToken.token = 1; frm.TPCRequest.present = 1; nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a TPC Request (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fTPCRequest ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a TPC Request (0x" "%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC" " Request."), nBytes ); return; } // Paranoia: vos_mem_set(pFrame, nBytes,0); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a TPC Request (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // just allocated... } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; nCfg = 6; nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg ); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from" " CFG (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // just allocated... } #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a T" "PC Request (0x%08x)."), nStatus ); } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, 0 ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send a TPC Request " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback return; } } // End limSendTpcRequestFrame. /** * \brief Send a TPC Report Action frame * * * \param pMac Pointer to the global MAC datastructure * * \param pTpcReqFrame Pointer to the received TPC Request * * \return eSIR_SUCCESS on success, eSIR_FAILURE else * * */ tSirRetStatus limSendTpcReportFrame(tpAniSirGlobal pMac, tpSirMacTpcReqActionFrame pTpcReqFrame, tSirMacAddr peer) { tDot11fTPCReport frm; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus, nCfg; void *pPacket; eHalStatus halstatus; vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT; frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID; frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken; // FramesToDo: On the Gen4_TVM branch, there was a comment: // "misplaced this function, need to replace: // txPower = halGetRateToPwrValue(pMac, staid, // pMac->lim.gLimCurrentChannelId, 0); frm.TPCReport.tx_power = 0; frm.TPCReport.link_margin = 0; frm.TPCReport.present = 1; nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a TPC Report (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fTPCReport ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a TPC Report (0x" "%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC" " Report."), nBytes ); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a TPC Report (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // just allocated... } pMacHdr = ( tpSirMacMgmtHdr ) pFrame; nCfg = 6; nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg ); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from" " CFG (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // just allocated... } #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif nStatus = dot11fPackTPCReport( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a T" "PC Report (0x%08x)."), nStatus ); } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, 0 ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send a TPC Report " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback return eSIR_FAILURE; // just allocated... } return eSIR_SUCCESS; } // End limSendTpcReportFrame. #endif //ANI_SUPPORT_11H /** * \brief Send a Channel Switch Announcement * * * \param pMac Pointer to the global MAC datastructure * * \param peer MAC address to which this frame will be sent * * \param nMode * * \param nNewChannel * * \param nCount * * \return eSIR_SUCCESS on success, eSIR_FAILURE else * * */ tSirRetStatus limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac, tSirMacAddr peer, tANI_U8 nMode, tANI_U8 nNewChannel, tANI_U8 nCount, tpPESession psessionEntry ) { tDot11fChannelSwitch frm; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus;//, nCfg; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT; frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID; frm.ChanSwitchAnn.switchMode = nMode; frm.ChanSwitchAnn.newChannel = nNewChannel; frm.ChanSwitchAnn.switchCount = nCount; frm.ChanSwitchAnn.present = 1; nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Channel Switch (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fChannelSwitch ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Channel Switch (0x" "%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC" " Report."), nBytes ); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr); pMacHdr = ( tpSirMacMgmtHdr ) pFrame; vos_mem_copy( (tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) psessionEntry->bssId, sizeof( tSirMacAddr )); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a Channel Switch (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // just allocated... } #if 0 pMacHdr = ( tpSirMacMgmtHdr ) pFrame; nCfg = 6; nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg ); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from" " CFG (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // just allocated... } #endif #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a C" "hannel Switch (0x%08x)."), nStatus ); } if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send a Channel Switch " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback return eSIR_FAILURE; } return eSIR_SUCCESS; } // End limSendChannelSwitchMgmtFrame. #ifdef WLAN_FEATURE_11AC tSirRetStatus limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac, tSirMacAddr peer, tANI_U8 nMode, tpPESession psessionEntry ) { tDot11fOperatingMode frm; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_VHT; frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION; frm.OperatingMode.chanWidth = nMode; frm.OperatingMode.rxNSS = 0; frm.OperatingMode.rxNSSType = 0; nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Operating Mode (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fOperatingMode); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Operating Mode (0x" "%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode" " Report."), nBytes ); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: if(psessionEntry->pePersona == VOS_STA_SAP_MODE) { nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr); } else nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr); pMacHdr = ( tpSirMacMgmtHdr ) pFrame; vos_mem_copy( (tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) psessionEntry->bssId, sizeof( tSirMacAddr )); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a Operating Mode (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // just allocated... } nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode" " (0x%08x)."), nStatus ); } if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send a Channel Switch " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback return eSIR_FAILURE; } return eSIR_SUCCESS; } /** * \brief Send a VHT Channel Switch Announcement * * * \param pMac Pointer to the global MAC datastructure * * \param peer MAC address to which this frame will be sent * * \param nChanWidth * * \param nNewChannel * * * \return eSIR_SUCCESS on success, eSIR_FAILURE else * * */ tSirRetStatus limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac, tSirMacAddr peer, tANI_U8 nChanWidth, tANI_U8 nNewChannel, tANI_U8 ncbMode, tpPESession psessionEntry ) { tDot11fChannelSwitch frm; tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus;//, nCfg; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT; frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID; frm.ChanSwitchAnn.switchMode = 1; frm.ChanSwitchAnn.newChannel = nNewChannel; frm.ChanSwitchAnn.switchCount = 1; frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode); frm.ExtChanSwitchAnn.present = 1; frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth; frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth); frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0; frm.ChanSwitchAnn.present = 1; frm.WiderBWChanSwitchAnn.present = 1; nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Channel Switch (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fChannelSwitch ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Channel Switch (0x" "%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC" " Report."), nBytes ); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Next, we fill out the buffer descriptor: nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr); pMacHdr = ( tpSirMacMgmtHdr ) pFrame; vos_mem_copy( (tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) psessionEntry->bssId, sizeof( tSirMacAddr )); if ( eSIR_SUCCESS != nSirStatus ) { limLog( pMac, LOGE, FL("Failed to populate the buffer descrip" "tor for a Channel Switch (%d)."), nSirStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // just allocated... } nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame + sizeof(tSirMacMgmtHdr), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."), nStatus ); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return eSIR_FAILURE; // allocated! } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while packing a C" "hannel Switch (0x%08x)."), nStatus ); } if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGE, FL("Failed to send a Channel Switch " "(%X)!"), nSirStatus ); //Pkt will be freed up by the callback return eSIR_FAILURE; } return eSIR_SUCCESS; } // End limSendVHTChannelSwitchMgmtFrame. #endif /** * \brief Send an ADDBA Req Action Frame to peer * * \sa limSendAddBAReq * * \param pMac The global tpAniSirGlobal object * * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains * the necessary parameters reqd by PE send the ADDBA Req Action * Frame to the peer * * \return eSIR_SUCCESS if setup completes successfully * eSIR_FAILURE is some problem is encountered */ tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac, tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry) { tDot11fAddBAReq frmAddBAReq; tANI_U8 *pAddBAReqBuffer = NULL; tpSirMacMgmtHdr pMacHdr; tANI_U32 frameLen = 0, nStatus, nPayload; tSirRetStatus statusCode; eHalStatus halStatus; void *pPacket; tANI_U8 txFlag = 0; if(NULL == psessionEntry) { return eSIR_FAILURE; } vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0); // Category - 3 (BA) frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK; // Action - 0 (ADDBA Req) frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ; // FIXME - Dialog Token, generalize this... frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken; // Fill the ADDBA Parameter Set frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID; frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy; frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize; // BA timeout // 0 - indicates no BA timeout frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout; // BA Starting Sequence Number // Fragment number will always be zero if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) { pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP; } frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP; nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGW, FL( "Failed to calculate the packed size for " "an ADDBA Request (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fAddBAReq ); } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while calculating " "the packed size for an ADDBA Req (0x%08x)."), nStatus ); } // Add the MGMT header to frame length frameLen = nPayload + sizeof( tSirMacMgmtHdr ); // Need to allocate a buffer for ADDBA AF if( eHAL_STATUS_SUCCESS != (halStatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (tANI_U16) frameLen, (void **) &pAddBAReqBuffer, (void **) &pPacket ))) { // Log error limLog( pMac, LOGP, FL("palPktAlloc FAILED! Length [%d], Status [%d]"), frameLen, halStatus ); statusCode = eSIR_MEM_ALLOC_FAILED; goto returnAfterError; } vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 ); // Copy necessary info to BD if( eSIR_SUCCESS != (statusCode = limPopulateMacHeader( pMac, pAddBAReqBuffer, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr))) goto returnAfterError; // Update A3 with the BSSID pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer; #if 0 cfgLen = SIR_MAC_ADDR_LENGTH; if( eSIR_SUCCESS != cfgGetStr( pMac, WNI_CFG_BSSID, (tANI_U8 *) pMacHdr->bssId, &cfgLen )) { limLog( pMac, LOGP, FL( "Failed to retrieve WNI_CFG_BSSID while" "sending an ACTION Frame" )); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } #endif//TO SUPPORT BT-AMP sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr); #endif // Now, we're ready to "pack" the frames nStatus = dot11fPackAddBAReq( pMac, &frmAddBAReq, pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGE, FL( "Failed to pack an ADDBA Req (0x%08x)." ), nStatus ); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while packing an ADDBA Req (0x%08x)."), nStatus ); } limLog( pMac, LOGW, FL( "Sending an ADDBA REQ to " )); limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW ); if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if( eHAL_STATUS_SUCCESS != (halStatus = halTxFrame( pMac, pPacket, (tANI_U16) frameLen, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pAddBAReqBuffer, txFlag ))) { limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]"), halStatus ); // FIXME - Need to convert eHalStatus to tSirRetStatus statusCode = eSIR_FAILURE; //Pkt will be freed up by the callback return statusCode; } else return eSIR_SUCCESS; returnAfterError: // Release buffer, if allocated if( NULL != pAddBAReqBuffer ) palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (void *) pAddBAReqBuffer, (void *) pPacket ); return statusCode; } /** * \brief Send an ADDBA Rsp Action Frame to peer * * \sa limSendAddBARsp * * \param pMac The global tpAniSirGlobal object * * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains * the necessary parameters reqd by PE send the ADDBA Rsp Action * Frame to the peer * * \return eSIR_SUCCESS if setup completes successfully * eSIR_FAILURE is some problem is encountered */ tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac, tpLimMlmAddBARsp pMlmAddBARsp, tpPESession psessionEntry) { tDot11fAddBARsp frmAddBARsp; tANI_U8 *pAddBARspBuffer = NULL; tpSirMacMgmtHdr pMacHdr; tANI_U32 frameLen = 0, nStatus, nPayload; tSirRetStatus statusCode; eHalStatus halStatus; void *pPacket; tANI_U8 txFlag = 0; if(NULL == psessionEntry) { PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));) return eSIR_FAILURE; } vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0); // Category - 3 (BA) frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK; // Action - 1 (ADDBA Rsp) frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP; // Should be same as the one we received in the ADDBA Req frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken; // ADDBA Req status frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode; // Fill the ADDBA Parameter Set as provided by caller frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID; frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy; frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize; if(psessionEntry->isAmsduSupportInAMPDU) { frmAddBARsp.AddBAParameterSet.amsduSupported = psessionEntry->amsduSupportedInBA; } else { frmAddBARsp.AddBAParameterSet.amsduSupported = 0; } // BA timeout // 0 - indicates no BA timeout frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout; nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGW, FL( "Failed to calculate the packed size for " "an ADDBA Response (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fAddBARsp ); } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while calculating " "the packed size for an ADDBA Rsp (0x%08x)."), nStatus ); } // Need to allocate a buffer for ADDBA AF frameLen = nPayload + sizeof( tSirMacMgmtHdr ); // Allocate shared memory if( eHAL_STATUS_SUCCESS != (halStatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (tANI_U16) frameLen, (void **) &pAddBARspBuffer, (void **) &pPacket ))) { // Log error limLog( pMac, LOGP, FL("palPktAlloc FAILED! Length [%d], Status [%d]"), frameLen, halStatus ); statusCode = eSIR_MEM_ALLOC_FAILED; goto returnAfterError; } vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 ); // Copy necessary info to BD if( eSIR_SUCCESS != (statusCode = limPopulateMacHeader( pMac, pAddBARspBuffer, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr))) goto returnAfterError; // Update A3 with the BSSID pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer; #if 0 cfgLen = SIR_MAC_ADDR_LENGTH; if( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, (tANI_U8 *) pMacHdr->bssId, &cfgLen )) { limLog( pMac, LOGP, FL( "Failed to retrieve WNI_CFG_BSSID while" "sending an ACTION Frame" )); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } #endif // TO SUPPORT BT-AMP sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr); #endif // Now, we're ready to "pack" the frames nStatus = dot11fPackAddBARsp( pMac, &frmAddBARsp, pAddBARspBuffer + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGE, FL( "Failed to pack an ADDBA Rsp (0x%08x)." ), nStatus ); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ), nStatus); } limLog( pMac, LOGW, FL( "Sending an ADDBA RSP to " )); limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW ); if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if( eHAL_STATUS_SUCCESS != (halStatus = halTxFrame( pMac, pPacket, (tANI_U16) frameLen, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pAddBARspBuffer, txFlag ))) { limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus ); // FIXME - HAL error codes are different from PE error // codes!! And, this routine is returning tSirRetStatus statusCode = eSIR_FAILURE; //Pkt will be freed up by the callback return statusCode; } else return eSIR_SUCCESS; returnAfterError: // Release buffer, if allocated if( NULL != pAddBARspBuffer ) palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (void *) pAddBARspBuffer, (void *) pPacket ); return statusCode; } /** * \brief Send a DELBA Indication Action Frame to peer * * \sa limSendDelBAInd * * \param pMac The global tpAniSirGlobal object * * \param peerMacAddr MAC Address of peer * * \param reasonCode Reason for the DELBA notification * * \param pBAParameterSet The DELBA Parameter Set. * This identifies the TID for which the BA session is * being deleted. * * \return eSIR_SUCCESS if setup completes successfully * eSIR_FAILURE is some problem is encountered */ tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac, tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry) { tDot11fDelBAInd frmDelBAInd; tANI_U8 *pDelBAIndBuffer = NULL; //tANI_U32 val; tpSirMacMgmtHdr pMacHdr; tANI_U32 frameLen = 0, nStatus, nPayload; tSirRetStatus statusCode; eHalStatus halStatus; void *pPacket; tANI_U8 txFlag = 0; if(NULL == psessionEntry) { return eSIR_FAILURE; } vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0); // Category - 3 (BA) frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK; // Action - 2 (DELBA) frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL; // Fill the DELBA Parameter Set as provided by caller frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID; frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection; // BA Starting Sequence Number // Fragment number will always be zero frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode; nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGW, FL( "Failed to calculate the packed size for " "an DELBA Indication (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fDelBAInd ); } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while calculating " "the packed size for an DELBA Ind (0x%08x)."), nStatus ); } // Add the MGMT header to frame length frameLen = nPayload + sizeof( tSirMacMgmtHdr ); // Allocate shared memory if( eHAL_STATUS_SUCCESS != (halStatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (tANI_U16) frameLen, (void **) &pDelBAIndBuffer, (void **) &pPacket ))) { // Log error limLog( pMac, LOGP, FL("palPktAlloc FAILED! Length [%d], Status [%d]"), frameLen, halStatus ); statusCode = eSIR_MEM_ALLOC_FAILED; goto returnAfterError; } vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 ); // Copy necessary info to BD if( eSIR_SUCCESS != (statusCode = limPopulateMacHeader( pMac, pDelBAIndBuffer, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr))) goto returnAfterError; // Update A3 with the BSSID pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer; #if 0 cfgLen = SIR_MAC_ADDR_LENGTH; if( eSIR_SUCCESS != cfgGetStr( pMac, WNI_CFG_BSSID, (tANI_U8 *) pMacHdr->bssId, &cfgLen )) { limLog( pMac, LOGP, FL( "Failed to retrieve WNI_CFG_BSSID while" "sending an ACTION Frame" )); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } #endif //TO SUPPORT BT-AMP sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr); #endif // Now, we're ready to "pack" the frames nStatus = dot11fPackDelBAInd( pMac, &frmDelBAInd, pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGE, FL( "Failed to pack an DELBA Ind (0x%08x)." ), nStatus ); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while packing an DELBA Ind (0x%08x)." ), nStatus); } limLog( pMac, LOGW, FL( "Sending a DELBA IND to " )); limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW ); if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if( eHAL_STATUS_SUCCESS != (halStatus = halTxFrame( pMac, pPacket, (tANI_U16) frameLen, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pDelBAIndBuffer, txFlag ))) { PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );) statusCode = eSIR_FAILURE; //Pkt will be freed up by the callback return statusCode; } else return eSIR_SUCCESS; returnAfterError: // Release buffer, if allocated if( NULL != pDelBAIndBuffer ) palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (void *) pDelBAIndBuffer, (void *) pPacket ); return statusCode; } #if defined WLAN_FEATURE_VOWIFI /** * \brief Send a Neighbor Report Request Action frame * * * \param pMac Pointer to the global MAC structure * * \param pNeighborReq Address of a tSirMacNeighborReportReq * * \param peer mac address of peer station. * * \param psessionEntry address of session entry. * * \return eSIR_SUCCESS on success, eSIR_FAILURE else * * */ tSirRetStatus limSendNeighborReportRequestFrame(tpAniSirGlobal pMac, tpSirMacNeighborReportReq pNeighborReq, tSirMacAddr peer, tpPESession psessionEntry ) { tSirRetStatus statusCode = eSIR_SUCCESS; tDot11fNeighborReportRequest frm; tANI_U8 *pFrame; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; if ( psessionEntry == NULL ) { limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") ); return eSIR_FAILURE; } vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_RRM; frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ; frm.DialogToken.token = pNeighborReq->dialogToken; if( pNeighborReq->ssid_present ) { PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID ); } nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Neighbor Report Request(0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fNeighborReportRequest ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Neighbor Rep" "ort Request(0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor " "Report Request."), nBytes ); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Copy necessary info to BD if( eSIR_SUCCESS != (statusCode = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr))) goto returnAfterError; // Update A3 with the BSSID pMacHdr = ( tpSirMacMgmtHdr ) pFrame; sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId ); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif // Now, we're ready to "pack" the frames nStatus = dot11fPackNeighborReportRequest( pMac, &frm, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGE, FL( "Failed to pack an Neighbor Report Request (0x%08x)." ), nStatus ); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while packing Neighbor Report " "Request (0x%08x)." ), nStatus); } limLog( pMac, LOGW, FL( "Sending a Neighbor Report Request to " )); limPrintMacAddr( pMac, peer, LOGW ); if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if( eHAL_STATUS_SUCCESS != (halstatus = halTxFrame( pMac, pPacket, (tANI_U16) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ))) { PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );) statusCode = eSIR_FAILURE; //Pkt will be freed up by the callback return statusCode; } else return eSIR_SUCCESS; returnAfterError: palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return statusCode; } // End limSendNeighborReportRequestFrame. /** * \brief Send a Link Report Action frame * * * \param pMac Pointer to the global MAC structure * * \param pLinkReport Address of a tSirMacLinkReport * * \param peer mac address of peer station. * * \param psessionEntry address of session entry. * * \return eSIR_SUCCESS on success, eSIR_FAILURE else * * */ tSirRetStatus limSendLinkReportActionFrame(tpAniSirGlobal pMac, tpSirMacLinkReport pLinkReport, tSirMacAddr peer, tpPESession psessionEntry ) { tSirRetStatus statusCode = eSIR_SUCCESS; tDot11fLinkMeasurementReport frm; tANI_U8 *pFrame; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; if ( psessionEntry == NULL ) { limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") ); return eSIR_FAILURE; } vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_RRM; frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT; frm.DialogToken.token = pLinkReport->dialogToken; //IEEE Std. 802.11 7.3.2.18. for the report element. //Even though TPC report an IE, it is represented using fixed fields since it is positioned //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle //such case this way than changing the frame parser. frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID; frm.TPCEleLen.TPCLen = 2; frm.TxPower.txPower = pLinkReport->txPower; frm.LinkMargin.linkMargin = 0; frm.RxAntennaId.antennaId = pLinkReport->rxAntenna; frm.TxAntennaId.antennaId = pLinkReport->txAntenna; frm.RCPI.rcpi = pLinkReport->rcpi; frm.RSNI.rsni = pLinkReport->rsni; nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Link Report (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fLinkMeasurementReport ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Link Rep" "ort (0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link " "Report."), nBytes ); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Copy necessary info to BD if( eSIR_SUCCESS != (statusCode = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr))) goto returnAfterError; // Update A3 with the BSSID pMacHdr = ( tpSirMacMgmtHdr ) pFrame; sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId ); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif // Now, we're ready to "pack" the frames nStatus = dot11fPackLinkMeasurementReport( pMac, &frm, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGE, FL( "Failed to pack an Link Report (0x%08x)." ), nStatus ); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while packing Link Report (0x%08x)." ), nStatus ); } limLog( pMac, LOGW, FL( "Sending a Link Report to " )); limPrintMacAddr( pMac, peer, LOGW ); if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if( eHAL_STATUS_SUCCESS != (halstatus = halTxFrame( pMac, pPacket, (tANI_U16) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ))) { PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );) statusCode = eSIR_FAILURE; //Pkt will be freed up by the callback return statusCode; } else return eSIR_SUCCESS; returnAfterError: palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return statusCode; } // End limSendLinkReportActionFrame. /** * \brief Send a Beacon Report Action frame * * * \param pMac Pointer to the global MAC structure * * \param dialog_token dialog token to be used in the action frame. * * \param num_report number of reports in pRRMReport. * * \param pRRMReport Address of a tSirMacRadioMeasureReport. * * \param peer mac address of peer station. * * \param psessionEntry address of session entry. * * \return eSIR_SUCCESS on success, eSIR_FAILURE else * * */ tSirRetStatus limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac, tANI_U8 dialog_token, tANI_U8 num_report, tpSirMacRadioMeasureReport pRRMReport, tSirMacAddr peer, tpPESession psessionEntry ) { tSirRetStatus statusCode = eSIR_SUCCESS; tANI_U8 *pFrame; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus; void *pPacket; eHalStatus halstatus; tANI_U8 i; tANI_U8 txFlag = 0; tDot11fRadioMeasurementReport *frm = vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport)); if (!frm) { limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") ); return eSIR_FAILURE; } if ( psessionEntry == NULL ) { limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") ); vos_mem_free(frm); return eSIR_FAILURE; } vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 ); frm->Category.category = SIR_MAC_ACTION_RRM; frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT; frm->DialogToken.token = dialog_token; frm->num_MeasurementReport = (num_report > RADIO_REPORTS_MAX_IN_A_FRAME ) ? RADIO_REPORTS_MAX_IN_A_FRAME : num_report; for( i = 0 ; i < frm->num_MeasurementReport ; i++ ) { frm->MeasurementReport[i].type = pRRMReport[i].type; frm->MeasurementReport[i].token = pRRMReport[i].token; frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm) switch( pRRMReport[i].type ) { case SIR_MAC_RRM_BEACON_TYPE: PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport ); frm->MeasurementReport[i].incapable = pRRMReport[i].incapable; frm->MeasurementReport[i].refused = pRRMReport[i].refused; frm->MeasurementReport[i].present = 1; break; default: frm->MeasurementReport[i].incapable = pRRMReport[i].incapable; frm->MeasurementReport[i].refused = pRRMReport[i].refused; frm->MeasurementReport[i].present = 1; break; } } nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload ); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a Radio Measure Report (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fLinkMeasurementReport ); vos_mem_free(frm); return eSIR_FAILURE; } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for a Radio Measure Rep" "ort (0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure " "Report."), nBytes ); vos_mem_free(frm); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Copy necessary info to BD if( eSIR_SUCCESS != (statusCode = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr))) goto returnAfterError; // Update A3 with the BSSID pMacHdr = ( tpSirMacMgmtHdr ) pFrame; sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId ); #ifdef WLAN_FEATURE_11W limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr); #endif // Now, we're ready to "pack" the frames nStatus = dot11fPackRadioMeasurementReport( pMac, frm, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGE, FL( "Failed to pack an Radio Measure Report (0x%08x)." ), nStatus ); // FIXME - Need to convert to tSirRetStatus statusCode = eSIR_FAILURE; goto returnAfterError; } else if( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while packing Radio " "Measure Report (0x%08x)." ), nStatus); } limLog( pMac, LOGW, FL( "Sending a Radio Measure Report to " )); limPrintMacAddr( pMac, peer, LOGW ); if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE) ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } if( eHAL_STATUS_SUCCESS != (halstatus = halTxFrame( pMac, pPacket, (tANI_U16) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ))) { PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );) statusCode = eSIR_FAILURE; //Pkt will be freed up by the callback vos_mem_free(frm); return statusCode; } else { vos_mem_free(frm); return eSIR_SUCCESS; } returnAfterError: vos_mem_free(frm); palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return statusCode; } // End limSendBeaconReportActionFrame. #endif #ifdef WLAN_FEATURE_11W /** * \brief Send SA query response action frame to peer * * \sa limSendSaQueryResponseFrame * * * \param pMac The global tpAniSirGlobal object * * \param transId Transaction identifier received in SA query request action frame * * \param peer The Mac address of the AP to which this action frame is addressed * * \param psessionEntry The PE session entry * * \return eSIR_SUCCESS if setup completes successfully * eSIR_FAILURE is some problem is encountered */ tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId, tSirMacAddr peer,tpPESession psessionEntry) { tDot11fSaQueryRsp frm; // SA query reponse action frame tANI_U8 *pFrame; tSirRetStatus nSirStatus; tpSirMacMgmtHdr pMacHdr; tANI_U32 nBytes, nPayload, nStatus; void *pPacket; eHalStatus halstatus; tANI_U8 txFlag = 0; vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 ); frm.Category.category = SIR_MAC_ACTION_SA_QUERY; /*11w action field is : action: 0 --> SA query request action frame action: 1 --> SA query response action frame */ frm.Action.action = SIR_MAC_SA_QUERY_RSP; /*11w SA query response transId is same as SA query request transId*/ vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 ); nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload); if ( DOT11F_FAILED( nStatus ) ) { limLog( pMac, LOGP, FL("Failed to calculate the packed size f" "or a SA Query Response (0x%08x)."), nStatus ); // We'll fall back on the worst case scenario: nPayload = sizeof( tDot11fSaQueryRsp ); } else if ( DOT11F_WARNED( nStatus ) ) { limLog( pMac, LOGW, FL("There were warnings while calculating " "the packed size for an SA Query Response" " (0x%08x)."), nStatus ); } nBytes = nPayload + sizeof( tSirMacMgmtHdr ); halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket ); if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) { limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response" " action frame"), nBytes ); return eSIR_FAILURE; } // Paranoia: vos_mem_set( pFrame, nBytes, 0 ); // Copy necessary info to BD nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr ); if ( eSIR_SUCCESS != nSirStatus ) goto returnAfterError; // Update A3 with the BSSID pMacHdr = ( tpSirMacMgmtHdr ) pFrame; sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId ); // Since this is a SA Query Response, set the "protect" (aka WEP) bit // in the FC if ( psessionEntry->limRmfEnabled ) { pMacHdr->fc.wep = 1; } // Pack 11w SA query response frame nStatus = dot11fPackSaQueryRsp( pMac, &frm, pFrame + sizeof( tSirMacMgmtHdr ), nPayload, &nPayload ); if ( DOT11F_FAILED( nStatus )) { limLog( pMac, LOGE, FL( "Failed to pack an SA Query Response (0x%08x)." ), nStatus ); // FIXME - Need to convert to tSirRetStatus nSirStatus = eSIR_FAILURE; goto returnAfterError; } else if ( DOT11F_WARNED( nStatus )) { limLog( pMac, LOGW, FL( "There were warnings while packing SA Query Response (0x%08x)." ), nStatus); } limLog( pMac, LOG1, FL( "Sending a SA Query Response to " )); limPrintMacAddr( pMac, peer, LOGW ); if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) ) #ifdef WLAN_FEATURE_P2P || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) || ( psessionEntry->pePersona == VOS_P2P_GO_MODE ) #endif ) { txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; } halstatus = halTxFrame( pMac, pPacket, (tANI_U16) nBytes, HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, limTxComplete, pFrame, txFlag ); if ( eHAL_STATUS_SUCCESS != halstatus ) { PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );) nSirStatus = eSIR_FAILURE; //Pkt will be freed up by the callback return nSirStatus; } else { return eSIR_SUCCESS; } returnAfterError: palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket ); return nSirStatus; } // End limSendSaQueryResponseFrame #endif
Vachounet/android_kernel_acer_hemingway
drivers/staging/prima/CORE/MAC/src/pe/lim/limSendManagementFrames.c
C
gpl-2.0
211,973
#ifndef _ERRORCODES_H #define _ERRORCODES_H /* (replaced by 0x08) 0x00 Unable to read bootsector. */ #define ERR_FAT_NO_MBR 0x01 /* No MBR detected. */ #define ERR_FAT_NO_PART 0x02 /* Unable to find first partition. */ #define ERR_FAT_IO_PART 0x03 /* Unable to read from first partition. */ #define ERR_FAT_IO_FAT 0x04 /* Unable to read the FAT table. */ #define ERR_FAT_NO_FAT32 0x05 /* No FAT32 filesystem detected. */ #define ERR_FAT_IO_ROOT 0x06 /* Unable to read root directory. */ #define ERR_FAT_NO_KERNEL 0x07 /* Kernel file not found. */ #define ERR_FAT_IO_BOOT 0x08 /* Unable to read bootsector. */ #define ERR_FAT_BAD_IMAGE 0x09 /* uImage header rejected. */ #define ERR_MMC_INIT 0x0a /* Initialization failed. */ #define ERR_MMC_TIMEOUT 0x0b /* Time out. */ #define ERR_MMC_IO 0x0c /* Read error. */ #define ERR_MMC_SEND_IF_COND 0x0e #define ERR_MMC_SEND_OP_COND 0x0f #define ERR_MMC_SEND_OP_COND_TOUT 0x10 #define ERR_MMC_SEND_OP_COND_ERR 0x11 #define ERR_MMC_NTOUT 0x12 #define ERR_MMC_CID 0x13 #define ERR_MMC_RCA 0x14 #define ERR_MMC_CSD 0x15 #define ERR_MMC_SELECT 0x16 #define ERR_SD_CMD 0x17 #define ERR_SD_BW 0x18 #define ERR_MMC_SWITCH 0x19 #define ERR_NAND_IO_UNC 0x20 /* Uncorrectable read error. */ #define ERR_NAND_IO 0x21 /* Read error. */ #define ERR_UBI_NO_PART 0x30 /* Partition is not a UBI drive. */ #define ERR_UBI_NO_KERNEL 0x31 /* Unable to locate kernel partition. */ #define ERR_UBI_IO 0x32 /* UBI structure parsing failed */ #endif
pcercuei/UBIBoot
src/errorcodes.h
C
gpl-2.0
1,570
/* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AWESOME_PLAYER_H_ #define AWESOME_PLAYER_H_ #define PROFILING 1 #include "HTTPBase.h" #include "TimedEventQueue.h" #include <media/MediaPlayerInterface.h> #include <media/stagefright/DataSource.h> #include <media/stagefright/OMXClient.h> #include <media/stagefright/TimeSource.h> #include <utils/threads.h> #include <drm/DrmManagerClient.h> #include <utils/List.h> #include "jittertool.h" namespace android { #ifdef PROFILING // **CAUTION** Any change in the 2 tables below should be mirrored into ProfileFlags enum in DataSource.h static const char *kProfileProps[] = { "enable-noAud", "enable-noAvs", "enable-noCache", "enable-noRend", "enable-prof", "enable-showJitter", }; static const char *kProfilePropsFile[] = { "noAudio", "noAvsync", "noCache", "noRender", "statFlag", "showJitter", }; #endif struct AudioPlayer; struct DataSource; struct MediaBuffer; struct MediaExtractor; struct MediaSource; struct NuCachedSource2; struct ISurfaceTexture; class DrmManagerClinet; class DecryptHandle; class TimedTextDriver; struct WVMExtractor; struct AwesomeRenderer : public RefBase { AwesomeRenderer() {} virtual void render(MediaBuffer *buffer) = 0; private: AwesomeRenderer(const AwesomeRenderer &); AwesomeRenderer &operator=(const AwesomeRenderer &); }; struct AwesomePlayer { AwesomePlayer(); ~AwesomePlayer(); void setListener(const wp<MediaPlayerBase> &listener); void setUID(uid_t uid); status_t setDataSource( const char *uri, const KeyedVector<String8, String8> *headers = NULL); status_t setDataSource(int fd, int64_t offset, int64_t length); status_t setDataSource(const sp<IStreamSource> &source); void reset(); status_t prepare(); status_t prepare_l(); status_t prepareAsync(); status_t prepareAsync_l(); status_t play(); status_t pause(); bool isPlaying() const; status_t setSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture); void setAudioSink(const sp<MediaPlayerBase::AudioSink> &audioSink); status_t setLooping(bool shouldLoop); status_t getDuration(int64_t *durationUs); status_t getPosition(int64_t *positionUs); status_t setParameter(int key, const Parcel &request); status_t getParameter(int key, Parcel *reply); status_t invoke(const Parcel &request, Parcel *reply); status_t setCacheStatCollectFreq(const Parcel &request); status_t seekTo(int64_t timeUs); // This is a mask of MediaExtractor::Flags. uint32_t flags() const; void postAudioEOS(int64_t delayUs = 0ll); void postAudioSeekComplete(); status_t recreateAudioChain(); status_t dump(int fd, const Vector<String16> &args) const; private: friend struct AwesomeEvent; friend struct AwesomeNotifyEvent; friend struct PreviewPlayer; enum { PLAYING = 0x01, LOOPING = 0x02, FIRST_FRAME = 0x04, PREPARING = 0x08, PREPARED = 0x10, AT_EOS = 0x20, PREPARE_CANCELLED = 0x40, CACHE_UNDERRUN = 0x80, AUDIO_AT_EOS = 0x0100, VIDEO_AT_EOS = 0x0200, AUTO_LOOPING = 0x0400, // We are basically done preparing but are currently buffering // sufficient data to begin playback and finish the preparation phase // for good. PREPARING_CONNECTED = 0x0800, // We're triggering a single video event to display the first frame // after the seekpoint. SEEK_PREVIEW = 0x1000, AUDIO_RUNNING = 0x2000, AUDIOPLAYER_STARTED = 0x4000, INCOGNITO = 0x8000, TEXT_RUNNING = 0x10000, TEXTPLAYER_INITIALIZED = 0x20000, SLOW_DECODER_HACK = 0x40000, }; mutable Mutex mLock; Mutex mMiscStateLock; mutable Mutex mStatsLock; Mutex mAudioLock; OMXClient mClient; TimedEventQueue mNotifyQueue; bool mNotifyQueueStarted; TimedEventQueue mQueue; bool mQueueStarted; wp<MediaPlayerBase> mListener; bool mUIDValid; uid_t mUID; sp<ANativeWindow> mNativeWindow; sp<MediaPlayerBase::AudioSink> mAudioSink; SystemTimeSource mSystemTimeSource; TimeSource *mTimeSource; String8 mUri; KeyedVector<String8, String8> mUriHeaders; sp<DataSource> mFileSource; sp<MediaSource> mVideoTrack; sp<MediaSource> mVideoSource; sp<AwesomeRenderer> mVideoRenderer; bool mVideoRenderingStarted; bool mVideoRendererIsPreview; ssize_t mActiveAudioTrackIndex; sp<MediaSource> mAudioTrack; sp<MediaSource> mAudioSource; AudioPlayer *mAudioPlayer; int64_t mDurationUs; int32_t mDisplayWidth; int32_t mDisplayHeight; int32_t mVideoScalingMode; uint32_t mFlags; uint32_t mExtractorFlags; uint32_t mSinceLastDropped; int64_t mTimeSourceDeltaUs; int64_t mVideoTimeUs; enum SeekType { NO_SEEK, SEEK, SEEK_VIDEO_ONLY }; SeekType mSeeking; bool mSeekNotificationSent; int64_t mSeekTimeUs; int64_t mBitrate; // total bitrate of the file (in bps) or -1 if unknown. bool mWatchForAudioSeekComplete; bool mWatchForAudioEOS; sp<TimedEventQueue::Event> mVideoEvent; bool mVideoEventPending; sp<TimedEventQueue::Event> mStreamDoneEvent; bool mStreamDoneEventPending; sp<TimedEventQueue::Event> mBufferingEvent; bool mBufferingEventPending; sp<TimedEventQueue::Event> mCheckAudioStatusEvent; bool mAudioStatusEventPending; sp<TimedEventQueue::Event> mVideoLagEvent; bool mVideoLagEventPending; sp<TimedEventQueue::Event> mDisableUlpEvent; bool mDisableUlpEventPending; sp<TimedEventQueue::Event> mNotifyEvent; sp<TimedEventQueue::Event> mAsyncPrepareEvent; Condition mPreparedCondition; bool mIsAsyncPrepare; status_t mPrepareResult; status_t mStreamDoneStatus; //flag for tracking whether Buffering Start notified properly to listener bool mIsBufferingStartEventNotified; void postVideoEvent_l(int64_t delayUs = -1); void postBufferingEvent_l(); void postStreamDoneEvent_l(status_t status); void postCheckAudioStatusEvent(int64_t delayUs); void postVideoLagEvent_l(); status_t play_l(); MediaBuffer *mVideoBuffer; sp<HTTPBase> mConnectingDataSource; sp<NuCachedSource2> mCachedSource; DrmManagerClient *mDrmManagerClient; sp<DecryptHandle> mDecryptHandle; int64_t mLastVideoTimeUs; TimedTextDriver *mTextDriver; //Audio ULP bool mStreamSupportsULP; bool mOwnerAudioULP; bool mEnabledAudioULP; static bool mAudioULPInstanceRunning; static Mutex mAudioULP; int64_t mOffsetTimeUs; sp<WVMExtractor> mWVMExtractor; sp<MediaExtractor> mExtractor; status_t setDataSource_l( const char *uri, const KeyedVector<String8, String8> *headers = NULL); status_t setDataSource_l(const sp<DataSource> &dataSource); status_t setDataSource_l(const sp<MediaExtractor> &extractor); void reset_l(); status_t seekTo_l(int64_t timeUs); status_t pause_l(bool at_eos = false); void initRenderer_l(); void notifyVideoSize_l(); void seekAudioIfNecessary_l(); void cancelPlayerEvents(bool keepNotifications = false); void setAudioSource(sp<MediaSource> source); status_t initAudioDecoder(); void setVideoSource(sp<MediaSource> source); status_t initVideoDecoder(uint32_t flags = 0); void addTextSource_l(size_t trackIndex, const sp<MediaSource>& source); void onStreamDone(); void notifyListener_l(int msg, int ext1 = 0, int ext2 = 0); void onVideoEvent(); void onBufferingUpdate(); void onCheckAudioStatus(); void onPrepareAsyncEvent(); void abortPrepare(status_t err); void finishAsyncPrepare_l(); void onVideoLagUpdate(); void onUlpDisable(); bool getCachedDuration_l(int64_t *durationUs, bool *eos); status_t finishSetDataSource_l(); static bool ContinuePreparation(void *cookie); bool getBitrate(int64_t *bitrate); void finishSeekIfNecessary(int64_t videoTimeUs); void ensureCacheIsFetching_l(); status_t startAudioPlayer_l(bool sendErrorNotification = true); void shutdownVideoDecoder_l(); status_t setNativeWindow_l(const sp<ANativeWindow> &native); bool isStreamingHTTP() const; void sendCacheStats(); void checkDrmStatus(const sp<DataSource>& dataSource); enum FlagMode { SET, CLEAR, ASSIGN }; void modifyFlags(unsigned value, FlagMode mode); struct TrackStat { String8 mMIME; String8 mDecoderName; }; // protected by mStatsLock struct Stats { int mFd; String8 mURI; int64_t mBitrate; // FIXME: // These two indices are just 0 or 1 for now // They are not representing the actual track // indices in the stream. ssize_t mAudioTrackIndex; ssize_t mVideoTrackIndex; int64_t mNumVideoFramesDecoded; int64_t mNumVideoFramesDropped; int32_t mVideoWidth; int32_t mVideoHeight; uint32_t mFlags; Vector<TrackStat> mTracks; } mStats; status_t setVideoScalingMode(int32_t mode); status_t setVideoScalingMode_l(int32_t mode); status_t getTrackInfo(Parcel* reply) const; status_t selectAudioTrack_l(const sp<MediaSource>& source, size_t trackIndex); // when select is true, the given track is selected. // otherwise, the given track is unselected. status_t selectTrack(size_t trackIndex, bool select); size_t countTracks() const; AwesomePlayer(const AwesomePlayer &); AwesomePlayer &operator=(const AwesomePlayer &); uint32_t mDataSourceFlags; int mAudioSystemSupportsULP; bool mReachedEOSAudioULP; #ifdef PROFILING struct ProfileStats{ uint64_t mProfFlags;//1 - noAudio, 2 - noAvsync, 4 - noPreCache, 8 - noRender, 16 - statFlag, 32 - showJitter uint32_t numLateSeek; uint32_t numRendFrame; uint32_t printVideoStat; uint32_t printAudioStat; int32_t videoFrameRate; //flags for audio profiling int32_t mInSamplerate; int32_t mInChannels; int32_t mInBitrate; int32_t mOutSamplerate; int32_t mOutChannels; int64_t startTimeUs; int64_t audioStartTimeUs; int64_t mInDurationUs; int64_t mHighWaterMarkTimeUs; int64_t mBufStartTimeUs; int32_t mNoOfPauses; JitterTool *pJitter; JitterTool *pSrcJitter; }; ProfileStats *mProfileStats; void setProfileFlags(); #endif }; } // namespace android #endif // AWESOME_PLAYER_H_
DmitryADP/diff_qc750
frameworks/av/media/libstagefright/include/AwesomePlayer.h
C
gpl-2.0
11,585
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # $Id$ # use Netcomics::HTML::Theme; package Netcomics::HTML::Themes::CleanRound; use vars '@ISA'; @ISA = ("Netcomics::HTML::Themes::Default"); use strict; require Exporter; use vars qw($VERSION); $VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/); my (%html,%imgs,%prefs); $html{'links'} = <<END_LINKS; <TABLE WIDTH=100%> <TR> <TD ALIGN=left><A HREF="<FILE=PREV>"><img border=0 src="<THEME_DIR>/prev.gif"></A></TD> <TD ALIGN=right><A HREF="<FILE=NEXT>"><img border=0 src="<THEME_DIR>/next.gif"></A></TD> </TR> </TABLE> END_LINKS # To use the corners als real images is neccessary, or some browsers # will render the left and right side with a wrong width in some # situations. # # Putting the corners into the background-attribute as well does not # work in those situations. # # This is no problem, since the corners are never needed to be stretched # only the horizontal and vertical bars need to be handeled this way. $html{'body'} = <<END_BODY; <tr><td> <center> <table cellspacing=0 cellpadding=0 border=0> <tr> <td><img src="<THEME_DIR>/top_l.gif" width="20" height="20"></td> <td background="<THEME_DIR>/top.gif" height="20">&nbsp;</td> <td><img src="<THEME_DIR>/top_r.gif" width="20" height="20" ></td> </tr> <tr> <td background="<THEME_DIR>/left.gif" width="20">&nbsp;</td> <td <WIDTH> bgcolor="#f7f7f7" align=center><font face="Arial,Helvetica" size=+1 color=black><b><a name="<COMIC_ID>"><COMIC_NAME></a></b></font></td> <td background="<THEME_DIR>/right.gif" width="20">&nbsp;</td> </tr> <tr> <td background="<THEME_DIR>/left.gif" width="20">&nbsp;</td> <td bgcolor="#f7f7f7" height="10">&nbsp;</td> <td background="<THEME_DIR>/right.gif" width="20">&nbsp;</td> </tr> <tr> <td background="<THEME_DIR>/left.gif" width="20">&nbsp;</td> <td><ELEMENT></td> <td background="<THEME_DIR>/right.gif" width="20">&nbsp;</td> </tr> <tr> <td><img src="<THEME_DIR>/bot_l.gif" width="20" height="20"></td> <td background="<THEME_DIR>/bot.gif" height="20">&nbsp;</td> <td><img src="<THEME_DIR>/bot_r.gif" width="20" height="20"></td> </tr> </table> <CAPTION> </center> </td></tr> END_BODY $html{'tail'} = <<END_TAIL; <HR> <FONT SIZE=-1><CENTER>This page was created by the CleanRound theme on <CTIME>.</CENTER></FONT> </BODY> </HTML> END_TAIL $html{'links_index'} = <<END_LINKS_INDEX; <TR><TD> <TABLE WIDTH=100%> <TR> <TD ALIGN=left><A HREF="<FILE=PREV>"><img border=0 src="<THEME_DIR>/prev.gif"></A></TD> <TD ALIGN=center><A HREF="<FILE=INDEX>"><img border=0 src="<THEME_DIR>/index.gif"></A></TD> <TD ALIGN=right><A HREF="<FILE=NEXT>"><img border=0 src="<THEME_DIR>/next.gif"></A></TD> </TR> </TABLE> </TD></TR> END_LINKS_INDEX $imgs{'bot.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAAAAAL+/v/f39////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQAh+QQBCgADACwAAAAAFAAUAAACHpSPqcvtD6OctNqLXdi8ez+E4kiW5omm6sq27gubBQA7 END_MIME $imgs{'bot_l.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAAAAAL+/v/f39////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQAh+QQBCgADACwAAAAAFAAUAAACLZxvIcstiJRz8MjJasJNj8t5ICaOlMgt3mdma9A+K2vO FowH9s73/g8MCoeQAgA7 END_MIME $imgs{'bot_r.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAAAAAL+/v/f39////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQAh+QQBCgADACwAAAAAFAAUAAACLpSPEsPNCZdrMMk5KrpTH+54Bkh5AfmYWFmdaxqh7Oe+ zInX9s73/g8MCodEYQEAOw== END_MIME $imgs{'index.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAL+/v/f39////////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQAh+QQBCgACACwAAAAAFAAUAAACOJR/AMhtEMJyDkZJmb04i811VRhOGkmaD4qaIMstyqyk tNK8YqarVO9ZlYKfFBEYRHqUPGPSiSgAADs= END_MIME $imgs{'left.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAAAAAL+/v/f39////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt CgAh+QQBCgADACwAAAAAFAAUAAACLZxvIcstiJRz8MjJasJNj8t5ICZymTZOpfmgbFullMuu ph3St57HL07iBX2sAgA7 END_MIME $imgs{'next.gif'} = <<END_MIME; R0lGODlhHgAUAKEAAL+/v/f39////////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQAh+QQBCgACACwAAAAAHgAUAAACRJSPmaDtDtibMEiKDQg2581dXsV1R4Sm6gqWVwnH8hwa 9I13+S63PO/74RjCnYSFXMVEI4SP2Ty5oiQoVWO6KiJayKMAADs= END_MIME $imgs{'prev.gif'} = <<END_MIME; R0lGODlhHgAUAKEAAL+/v/f39////////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQAh+QQBCgACACwAAAAAHgAUAAACR5R/gMvNoJyUIMSJU7C51311zgeK1IZC6sq2EYnG8jwL MI3nd87Lew+0AYcow49YM/pcTBYCFjI9UtLJJ1pdVLDZJ7ebABcAADs= END_MIME $imgs{'right.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAAAAAL+/v/f39////yH+HE5ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQoAIfkEAQoAAwAsAAAAABQAFAAAAi6UjxLDzQmXazDJOSq6Ux/ueAZIieRjYqh3ZqkqKqrL znF72y+Ww3v3CwVLNVUBADs= END_MIME $imgs{'top.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAAAAAL+/v/f39////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt CgAh+QQBCgADACwAAAAAFAAUAAACHpyPqcvtD6OctK6As95b+A+G4kiW5omm6sq27gubBQA7 END_MIME $imgs{'top_l.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAAAAAL+/v/f39////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQAh+QQBCgADACwAAAAAFAAUAAACK5yPqcvtD6OctFoTsg5Piw86GUgKzViGTJCSK9t+a6wq MD3T5nLHOc7TCQoAOw== END_MIME $imgs{'top_r.gif'} = <<END_MIME; R0lGODlhFAAUAKEAAAAAAL+/v/f39////yH+G05ldGNvbWljcyBjbGVhbiByb3VuZCB0aGVt ZQAh+QQBCgADACwAAAAAFAAUAAACK5yPqcvtD6OctK6Ac4ii+/x4ooA5o1gyJ9qs37a4nyqT tAwrtR3XebL7IQoAOw== END_MIME $prefs{'vlink_color'} = "VLINK=\"#606060\""; $prefs{'link_color'} = "LINK=\"#4c4c4c\""; sub new { my ($class, $name, $r_imgs, $r_html, $r_prefs) = @_; $name = "CleanRound" unless defined $name; my %html_c = %html; my %imgs_c = %imgs; my %prefs_c = %prefs; if (defined($r_html)) { #only copy the html templates that get used foreach (@Netcomics::HTML::Theme::html_keys) { $html_c{$_} = $r_html->{$_} if defined $r_html->{$_}; } } if (defined($r_imgs)) { foreach (keys(%$r_imgs)) { #copy all images $imgs_c{$_} = $r_imgs->{$_}; } } if (defined($r_prefs)) { foreach (keys(%$r_prefs)) { #copy all prefs $prefs_c{$_} = $r_prefs->{$_}; } } return $class->SUPER::new($name, \%imgs_c, \%html_c, \%prefs_c); } 1;
shartge/netcomics
Netcomics/HTML/Themes/CleanRound.pm
Perl
gpl-2.0
6,742
<?php /** * @version SEBLOD 3.x Core ~ $Id: _debug.php sebastienheraud $ * @package SEBLOD (App Builder & CCK) // SEBLOD nano (Form Builder) * @url http://www.seblod.com * @editor Octopoos - www.octopoos.com * @copyright Copyright (C) 2009 - 2016 SEBLOD. All Rights Reserved. * @license GNU General Public License version 2 or later; see _LICENSE.php **/ defined( '_JEXEC' ) or die; // Init jimport( 'joomla.error.profiler' ); $db = JFactory::getDbo(); $config = JCckDev::init(); $cck = JCckDev::preload( array( '' ) ); $doc = JFactory::getDocument(); $profiler = new JProfiler(); // -- DEBUG:START -- // $js = ''; $js2 = ''; $js_script = ''; $js_script = JURI::root( true ).$js_script; echo '<br /><div style="color: #999999; font-size: 10px; font-weight: bold;">-------- Debug --------<br />'; // -------- -------- -------- -------- -------- -------- -------- -------- // $n = 10000; $profiler = new JProfiler(); for ( $i = 0; $i < $n; $i++ ) { // } $profiler_res = $profiler->mark( 'afterDebug' ); // -------- -------- -------- -------- -------- -------- -------- -------- // if ( $js_script ) { $doc->addScript( $js_script ); } if ( $js || $js2 ) { echo '<input text id="toto" name="toto" value="" />'.'<input text id="toto2" name="toto2" value="" />'; $doc->addScriptDeclaration( 'jQuery(document).ready(function($) {' . $js . '});' . $js2 ); } echo '<br />'. $profiler_res . '<br />-------- Debug --------<br /></div>'; // -- DEBUG:END -- // /* $log = JLog::addLogger( array( 'format'=>'{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}', 'text_file'=>'com_cck.php' ) ); */
klas/SEBLOD
administrator/components/com_cck/helpers/scripts/_debug.php
PHP
gpl-2.0
1,658
// Aseprite Document Library // Copyright (c) 2001-2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. #pragma once #include "doc/algorithm/hline.h" #include "gfx/fwd.h" namespace doc { class Image; class Mask; namespace algorithm { void floodfill(const Image* image, const Mask* mask, int x, int y, const gfx::Rect& bounds, int tolerance, bool contiguous, void* data, AlgoHLine proc); } }
aseprite-gpl/aseprite
src/doc/algorithm/floodfill.h
C
gpl-2.0
596
/* * Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.oracle.svm.hosted; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ConfigurationCondition; import com.oracle.svm.core.TypeResult; public abstract class ConditionalConfigurationRegistry { private final Map<String, List<Runnable>> pendingReachabilityHandlers = new ConcurrentHashMap<>(); protected void registerConditionalConfiguration(ConfigurationCondition condition, Runnable runnable) { if (ConfigurationCondition.alwaysTrue().equals(condition)) { /* analysis optimization to include new types as early as possible */ runnable.run(); } else { List<Runnable> handlers = pendingReachabilityHandlers.computeIfAbsent(condition.getTypeName(), key -> new ArrayList<>()); handlers.add(runnable); } } public void flushConditionalConfiguration(Feature.BeforeAnalysisAccess b) { for (Map.Entry<String, List<Runnable>> reachabilityEntry : pendingReachabilityHandlers.entrySet()) { TypeResult<Class<?>> typeResult = ((FeatureImpl.BeforeAnalysisAccessImpl) b).getImageClassLoader().findClass(reachabilityEntry.getKey()); b.registerReachabilityHandler(access -> reachabilityEntry.getValue().forEach(Runnable::run), typeResult.get()); } pendingReachabilityHandlers.clear(); } public void flushConditionalConfiguration(Feature.DuringAnalysisAccess b) { if (!pendingReachabilityHandlers.isEmpty()) { b.requireAnalysisIteration(); } flushConditionalConfiguration((Feature.BeforeAnalysisAccess) b); } }
smarr/Truffle
substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConditionalConfigurationRegistry.java
Java
gpl-2.0
2,958
<?php /** * @package Blue Hat CDN * @version 2.9.4 * @copyright (C) Copyright 2006-2014 Blue Hat Network, BlueHatNetwork.com. All rights reserved. * @license GNU/GPL http://www.gnu.org/licenses/gpl-3.0.txt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); class BlueHatNetworkCommon { private static $_getWebsiteOwnerEmailAddress; public static function isValidEmailAddress($emailAddress) { if(!class_exists('BlueHatNetworkFactory')) require BHN_PLUGIN_ADMIN_ROOT.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'factory.php'; if(BlueHatNetworkFactory::isWordPress()) { return is_email($emailAddress); } elseif(BlueHatNetworkFactory::isJoomla()) { jimport('joomla.mail.helper'); return JMailHelper::isEmailAddress($emailAddress); } } public static function getWebsiteOwnerEmailAddress() { if(!empty(self::$_getWebsiteOwnerEmailAddress)) return self::$_getWebsiteOwnerEmailAddress; if(!class_exists('BlueHatNetworkFactory')) require BHN_PLUGIN_ADMIN_ROOT.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'factory.php'; if(BlueHatNetworkFactory::isWordPress()) { self::$_getWebsiteOwnerEmailAddress = get_bloginfo('admin_email'); } elseif(BlueHatNetworkFactory::isJoomla()) { $config =& JFactory::getConfig(); if(method_exists($config, 'getValue')) { self::$_getWebsiteOwnerEmailAddress = $config->getValue('config.mailfrom'); } else { self::$_getWebsiteOwnerEmailAddress = $config->get('mailfrom'); } } return self::$_getWebsiteOwnerEmailAddress; } public static function mkdir($dirPath) { if(!class_exists('BlueHatNetworkFactory')) require BHN_PLUGIN_ADMIN_ROOT.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'factory.php'; if(BlueHatNetworkFactory::isWordPress()) { return wp_mkdir_p($dirPath); } elseif(BlueHatNetworkFactory::isJoomla()) { jimport('joomla.filesystem.folder'); return JFolder::create($dirPath); } } public static function humanReadableFilesize($size) { $mod = 1024; $units = explode(' ', 'Bytes KB MB GB TB PB'); for($i = 0; $size > $mod; $i++) { $size /= $mod; } return round($size, 2).' '.$units[$i]; } public static function getFileExt($file) { return substr($file, strrpos($file, '.')+1); } public static function isWindows() { if(strncasecmp(PHP_OS, 'WIN', 3) == 0) { return true; } else { return false; } } public static function extractGzipFile($gzipFilePath) { if(!is_file($gzipFilePath)) return false; // Raising this value may increase performance $buffer_size = 4096; // read 4kb at a time $out_file_name = preg_replace('@\.gz$@i', '', $gzipFilePath, 1); // Open our files (in binary mode) $file = gzopen($gzipFilePath, 'rb'); $out_file = fopen($out_file_name, 'wb'); // Keep repeating until the end of the input file while(!gzeof($file)) { // Read buffer-size bytes // Both fwrite and gzread and binary-safe fwrite($out_file, gzread($file, $buffer_size)); } // Files are done, close files fclose($out_file); gzclose($file); } }
dialoquad/dialoquad
wp-content/plugins/blue-hat-cdn/lib/common.php
PHP
gpl-2.0
3,884
<?php // Checking if visitor is connected $connected = false; $is_admin = false; if ( !empty($_SESSION['member'])) { $connected = true; $stmt = $PDO->prepare('SELECT members_id FROM admins WHERE id=1'); $stmt->execute(); $rslt = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); $members_id = explode(',', $rslt['members_id']); if ( in_array($_SESSION['member']['id'], $members_id) ) $is_admin = true; // Visitor is an admin } // Global settings error_reporting(0); // Define path define( 'PATH', '/TSBlog/' ); // Default : "/" // Gettings configs $stmt = $PDO->prepare('SELECT * FROM config WHERE id=1'); $stmt->execute(); $rslt = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); define( 'MAX_SIZE_PICTURE', $rslt['maxsize'] ); // Limit of file's size 4 Mo define( 'SITE_NAME', $rslt['sitename'] ); // Site name define( 'PHONE_NUMBER', $rslt['phonenumber'] ); // Your phone number define ('EMAIL_ADRESS', $rslt['email'] ); // Email adress define('ABOUT', $rslt['aboutme'] ); // About me // List of months $mois = array('01'=>$lang15, '02'=>$lang16, '03'=>$lang17, '04'=>$lang18, '05'=>$lang19, '06'=>$lang20, '07'=>$lang21, '08'=>$lang22, '09'=>$lang23, '10'=>$lang24, '11'=>$lang25, '12'=>$lang26); ?>
Tunisia-Sat/TSBlog
config/config.php
PHP
gpl-2.0
1,343
<wicket:panel> <b><span wicket:id="prompt">How often do _____ and _____ speak with each other?</span></b> <table> <tr wicket:id="questions"> <td align="right"> <span wicket:id="alter">Alex</span> </td> <td align="left"> <div wicket:id="question"></div> </td> </tr> </table> <br /> <span wicket:id="refDKCheck" style="margin-left:10em">Refuse and dont know checkboxes</span> </wicket:panel>
ericlavigne/sandbox
src/net/sf/egonet/web/panel/InterviewingPanel.html
HTML
gpl-2.0
426
using System; using System.Diagnostics; using System.Resources; using System.Windows; using System.Windows.Markup; using System.Windows.Navigation; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using HTTPServer.Resources; namespace HTTPServer { public partial class App : Application { /// <summary> ///提供对电话应用程序的根框架的轻松访问。 /// </summary> /// <returns>电话应用程序的根框架。</returns> public static PhoneApplicationFrame RootFrame { get; private set; } /// <summary> /// Application 对象的构造函数。 /// </summary> public App() { // 未捕获的异常的全局处理程序。 UnhandledException += Application_UnhandledException; // 标准 XAML 初始化 InitializeComponent(); // 特定于电话的初始化 InitializePhoneApplication(); // 语言显示初始化 InitializeLanguage(); // 调试时显示图形分析信息。 if (Debugger.IsAttached) { // 显示当前帧速率计数器。 Application.Current.Host.Settings.EnableFrameRateCounter = true; // 显示在每个帧中重绘的应用程序区域。 //Application.Current.Host.Settings.EnableRedrawRegions = true; // 启用非生产分析可视化模式, // 该模式显示递交给 GPU 的包含彩色重叠区的页面区域。 //Application.Current.Host.Settings.EnableCacheVisualization = true; // 通过禁用以下对象阻止在调试过程中关闭屏幕 // 应用程序的空闲检测。 // 注意: 仅在调试模式下使用此设置。禁用用户空闲检测的应用程序在用户不使用电话时将继续运行 // 并且消耗电池电量。 PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } } // 应用程序启动(例如,从“开始”菜单启动)时执行的代码 // 此代码在重新激活应用程序时不执行 private void Application_Launching(object sender, LaunchingEventArgs e) { } // 激活应用程序(置于前台)时执行的代码 // 此代码在首次启动应用程序时不执行 private void Application_Activated(object sender, ActivatedEventArgs e) { } // 停用应用程序(发送到后台)时执行的代码 // 此代码在应用程序关闭时不执行 private void Application_Deactivated(object sender, DeactivatedEventArgs e) { } // 应用程序关闭(例如,用户点击“后退”)时执行的代码 // 此代码在停用应用程序时不执行 private void Application_Closing(object sender, ClosingEventArgs e) { } // 导航失败时执行的代码 private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { if (Debugger.IsAttached) { // 导航已失败;强行进入调试器 Debugger.Break(); } } // 出现未处理的异常时执行的代码 private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { if (Debugger.IsAttached) { // 出现未处理的异常;强行进入调试器 Debugger.Break(); } } #region 电话应用程序初始化 // 避免双重初始化 private bool phoneApplicationInitialized = false; // 请勿向此方法中添加任何其他代码 private void InitializePhoneApplication() { if (phoneApplicationInitialized) return; // 创建框架但先不将它设置为 RootVisual;这允许初始 // 屏幕保持活动状态,直到准备呈现应用程序时。 RootFrame = new PhoneApplicationFrame(); RootFrame.Navigated += CompleteInitializePhoneApplication; // 处理导航故障 RootFrame.NavigationFailed += RootFrame_NavigationFailed; // 在下一次导航中处理清除 BackStack 的重置请求, RootFrame.Navigated += CheckForResetNavigation; // 确保我们未再次初始化 phoneApplicationInitialized = true; } // 请勿向此方法中添加任何其他代码 private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) { // 设置根视觉效果以允许应用程序呈现 if (RootVisual != RootFrame) RootVisual = RootFrame; // 删除此处理程序,因为不再需要它 RootFrame.Navigated -= CompleteInitializePhoneApplication; } private void CheckForResetNavigation(object sender, NavigationEventArgs e) { // 如果应用程序收到“重置”导航,则需要进行检查 // 以确定是否应重置页面堆栈 if (e.NavigationMode == NavigationMode.Reset) RootFrame.Navigated += ClearBackStackAfterReset; } private void ClearBackStackAfterReset(object sender, NavigationEventArgs e) { // 取消注册事件,以便不再调用该事件 RootFrame.Navigated -= ClearBackStackAfterReset; // 只为“新建”(向前)和“刷新”导航清除堆栈 if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh) return; // 为了获得 UI 一致性,请清除整个页面堆栈 while (RootFrame.RemoveBackEntry() != null) { ; // 不执行任何操作 } } #endregion // 初始化应用程序在其本地化资源字符串中定义的字体和排列方向。 // // 若要确保应用程序的字体与受支持的语言相符,并确保 // 这些语言的 FlowDirection 都采用其传统方向,ResourceLanguage // 应该初始化每个 resx 文件中的 ResourceFlowDirection,以便将这些值与以下对象匹配 // 文件的区域性。例如: // // AppResources.es-ES.resx // ResourceLanguage 的值应为“es-ES” // ResourceFlowDirection 的值应为“LeftToRight” // // AppResources.ar-SA.resx // ResourceLanguage 的值应为“ar-SA” // ResourceFlowDirection 的值应为“RightToLeft” // // 有关本地化 Windows Phone 应用程序的详细信息,请参见 http://go.microsoft.com/fwlink/?LinkId=262072。 // private void InitializeLanguage() { try { // 将字体设置为与由以下对象定义的显示语言匹配 // 每种受支持的语言的 ResourceLanguage 资源字符串。 // // 如果显示出现以下情况,则回退到非特定语言的字体 // 手机的语言不受支持。 // // 如果命中编译器错误,则表示以下对象中缺少 ResourceLanguage // 资源文件。 RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage); // 根据以下条件设置根框架下的所有元素的 FlowDirection // 每个以下对象的 ResourceFlowDirection 资源字符串上的 // 受支持的语言。 // // 如果命中编译器错误,则表示以下对象中缺少 ResourceFlowDirection // 资源文件。 FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection); RootFrame.FlowDirection = flow; } catch { // 如果此处导致了异常,则最可能的原因是 // ResourceLangauge 未正确设置为受支持的语言 // 代码或 ResourceFlowDirection 设置为 LeftToRight 以外的值 // 或 RightToLeft。 if (Debugger.IsAttached) { Debugger.Break(); } throw; } } } }
sintrb/WindowsPhoneHTTPServer
App.xaml.cs
C#
gpl-2.0
8,746
//Copyright Notice /* eXintegrator integrated expression analysis system Copyright (C) 2004 Martin Jakt & Okada Mitsuhiro This file is part of the eXintegrator integrated expression analysis system. eXintegrator is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA PS. If you can think of a better name, please let me know... */ //End Copyright Notice #ifndef ISHANNOTATIONERRORMESSAGE_H #define ISHANNOTATIONERRORMESSAGE_H #include "../dataStructs.h" #include <qdialog.h> #include <qstring.h> class IshAnnotationErrorMessage : public QDialog { Q_OBJECT public : IshAnnotationErrorMessage(ishTextInsert ti, QWidget* parent=0, const char* name=0); IshAnnotationErrorMessage(ishFloatInsert ti, bool classification, QWidget* parent=0, const char* name=0); // two constructors, which can be used with different types of error. Make a new one each time and delete // after exec() returns; // try again is set to private slots : void giveUp(); // calls done(0); void tryAgain(); // calls done(1) }; #endif
lmjakt/exint_client
jpgView/ishAnnotationErrorMessage.h
C
gpl-2.0
1,722
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_65) on Wed Jan 29 20:09:42 CET 2014 --> <TITLE> de.fhpotsdam.unfolding.texture Class Hierarchy </TITLE> <META NAME="date" CONTENT="2014-01-29"> <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="de.fhpotsdam.unfolding.texture Class Hierarchy"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <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"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Tree</B></FONT>&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="../../../../de/fhpotsdam/unfolding/providers/package-tree.html"><B>PREV</B></A>&nbsp; &nbsp;<A HREF="../../../../de/fhpotsdam/unfolding/tiles/package-tree.html"><B>NEXT</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?de/fhpotsdam/unfolding/texture/package-tree.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="package-tree.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> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <CENTER> <H2> Hierarchy For Package de.fhpotsdam.unfolding.texture </H2> </CENTER> <DL> <DT><B>Package Hierarchies:</B><DD><A HREF="../../../../overview-tree.html">All Packages</A></DL> <HR> <H2> Class Hierarchy </H2> <UL> <LI TYPE="circle">java.lang.Object<UL> <LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/AbstractLensDistorter.html" title="class in de.fhpotsdam.unfolding.texture"><B>AbstractLensDistorter</B></A> (implements de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/Distorter.html" title="interface in de.fhpotsdam.unfolding.texture">Distorter</A>) <UL> <LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/LinearInterpolationDistorter.html" title="class in de.fhpotsdam.unfolding.texture"><B>LinearInterpolationDistorter</B></A><LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/ScaleInterpolationDistorter.html" title="class in de.fhpotsdam.unfolding.texture"><B>ScaleInterpolationDistorter</B></A></UL> <LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/DisplacedDistorter.html" title="class in de.fhpotsdam.unfolding.texture"><B>DisplacedDistorter</B></A> (implements de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/Distorter.html" title="interface in de.fhpotsdam.unfolding.texture">Distorter</A>) <LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/ExtrusionDistorter.html" title="class in de.fhpotsdam.unfolding.texture"><B>ExtrusionDistorter</B></A> (implements de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/Distorter.html" title="interface in de.fhpotsdam.unfolding.texture">Distorter</A>) <LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/PAppletFactory.html" title="class in de.fhpotsdam.unfolding.texture"><B>PAppletFactory</B></A><LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/RippleDistorter.html" title="class in de.fhpotsdam.unfolding.texture"><B>RippleDistorter</B></A> (implements de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/Distorter.html" title="interface in de.fhpotsdam.unfolding.texture">Distorter</A>) <LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/TextureDistorter.html" title="class in de.fhpotsdam.unfolding.texture"><B>TextureDistorter</B></A></UL> </UL> <H2> Interface Hierarchy </H2> <UL> <LI TYPE="circle">de.fhpotsdam.unfolding.texture.<A HREF="../../../../de/fhpotsdam/unfolding/texture/Distorter.html" title="interface in de.fhpotsdam.unfolding.texture"><B>Distorter</B></A></UL> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <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="navbar_bottom_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"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Tree</B></FONT>&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="../../../../de/fhpotsdam/unfolding/providers/package-tree.html"><B>PREV</B></A>&nbsp; &nbsp;<A HREF="../../../../de/fhpotsdam/unfolding/tiles/package-tree.html"><B>NEXT</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?de/fhpotsdam/unfolding/texture/package-tree.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="package-tree.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> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>
phiLangley/openPHD
[CODE]/processing/libraries/Unfolding/reference/de/fhpotsdam/unfolding/texture/package-tree.html
HTML
gpl-2.0
8,372
package com.arantius.tivocommander.rpc.request; import com.arantius.tivocommander.rpc.MindRpc; public class Unsubscribe extends MindRpcRequest { public Unsubscribe(String subscriptionId) { super("unsubscribe"); mDataMap.put("bodyId", MindRpc.mTivoDevice.tsn); mDataMap.put("subscriptionId", subscriptionId); } }
arantius/TiVo-Commander
src/com/arantius/tivocommander/rpc/request/Unsubscribe.java
Java
gpl-2.0
330
# WP Term Meta Generic meta data on any taxonomy's term that doesn't depend on new tables or pollute the options table. Meta is kept in a special post type that the term in question is assigned to. The post is filtered from all queries on this term. ## Plugin brought to you by Oomph, Inc ![](https://github.com/gdtrombetti/WP-Term-Meta/blob/master/images/Oomph_logo.png) Oomph is a full service digital design and engineering firm assisting premium brands and media companies with large-scale content engagement solutions. http://oomphinc.com/
oomphinc/WP-Term-Meta
README.md
Markdown
gpl-2.0
549
/* ----------------------------------------------------------------------------------------------------------- Software License for The Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android © Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. Copyright (C) 2012 Sony Mobile Communications AB. 1. INTRODUCTION The Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. This FDK AAC Codec software is intended to be used on a wide variety of Android devices. AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part of the MPEG specifications. Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer) may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners individually for the purpose of encoding or decoding bit streams in products that are compliant with the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec software may already be covered under those patent licenses when it is used for those licensed purposes only. Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality, are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional applications information and documentation. 2. COPYRIGHT LICENSE Redistribution and use in source and binary forms, with or without modification, are permitted without payment of copyright license fees provided that you satisfy the following conditions: You must retain the complete text of this software license in redistributions of the FDK AAC Codec or your modifications thereto in source code form. You must retain the complete text of this software license in the documentation and/or other materials provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. You must make available free of charge copies of the complete source code of the FDK AAC Codec and your modifications thereto to recipients of copies in binary form. The name of Fraunhofer may not be used to endorse or promote products derived from this library without prior written permission. You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec software or your modifications thereto. Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software and the date of any change. For modified versions of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android." 3. NO PATENT LICENSE NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with respect to this software. You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized by appropriate patent licenses. 4. DISCLAIMER This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of this software, even if advised of the possibility of such damage. 5. CONTACT INFORMATION Fraunhofer Institute for Integrated Circuits IIS Attention: Audio and Multimedia Departments - FDK AAC LL Am Wolfsmantel 33 91058 Erlangen, Germany www.iis.fraunhofer.de/amm amm-info@iis.fraunhofer.de ----------------------------------------------------------------------------------------------------------- */ /******************************** Fraunhofer IIS *************************** Author(s): Arthur Tritthart Description: (ARM optimised) LPP transposer subroutines ******************************************************************************/ #if defined(__arm__) #define FUNCTION_LPPTRANSPOSER_func1 #ifdef FUNCTION_LPPTRANSPOSER_func1 /* Note: This code requires only 43 cycles per iteration instead of 61 on ARM926EJ-S */ __attribute__ ((noinline)) static void lppTransposer_func1( FIXP_DBL *lowBandReal, FIXP_DBL *lowBandImag, FIXP_DBL **qmfBufferReal, FIXP_DBL **qmfBufferImag, int loops, int hiBand, int dynamicScale, int descale, FIXP_SGL a0r, FIXP_SGL a0i, FIXP_SGL a1r, FIXP_SGL a1i) { FIXP_DBL real1, real2, imag1, imag2, accu1, accu2; real2 = lowBandReal[-2]; real1 = lowBandReal[-1]; imag2 = lowBandImag[-2]; imag1 = lowBandImag[-1]; for(int i=0; i < loops; i++) { accu1 = fMultDiv2( a0r,real1); accu2 = fMultDiv2( a0i,imag1); accu1 = fMultAddDiv2(accu1,a1r,real2); accu2 = fMultAddDiv2(accu2,a1i,imag2); real2 = fMultDiv2( a1i,real2); accu1 = accu1 - accu2; accu1 = accu1 >> dynamicScale; accu2 = fMultAddDiv2(real2,a1r,imag2); real2 = real1; imag2 = imag1; accu2 = fMultAddDiv2(accu2,a0i,real1); real1 = lowBandReal[i]; accu2 = fMultAddDiv2(accu2,a0r,imag1); imag1 = lowBandImag[i]; accu2 = accu2 >> dynamicScale; accu1 <<= 1; accu2 <<= 1; qmfBufferReal[i][hiBand] = accu1 + (real1>>descale); qmfBufferImag[i][hiBand] = accu2 + (imag1>>descale); } } #endif /* #ifdef FUNCTION_LPPTRANSPOSER_func1 */ #endif /* __arm__ */
percy-g2/Novathor_xperia_u8500
6.2.A.1.100/external/aac/libSBRdec/src/arm/lpp_tran_arm.cpp
C++
gpl-2.0
6,494
/******************************************************************************* * This file is part of OpenNMS(R). * * Copyright (C) 2008-2020 The OpenNMS Group, Inc. * OpenNMS(R) is Copyright (C) 1999-2020 The OpenNMS Group, Inc. * * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. * * OpenNMS(R) is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * OpenNMS(R) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with OpenNMS(R). If not, see: * http://www.gnu.org/licenses/ * * For more information contact: * OpenNMS(R) Licensing <license@opennms.org> * http://www.opennms.org/ * http://www.opennms.com/ *******************************************************************************/ package org.opennms.web.rest.v1; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.EnumUtils; import org.opennms.core.criteria.CriteriaBuilder; import org.opennms.netmgt.dao.api.AcknowledgmentDao; import org.opennms.netmgt.dao.api.AlarmDao; import org.opennms.netmgt.model.AckAction; import org.opennms.netmgt.model.OnmsAcknowledgment; import org.opennms.netmgt.model.OnmsAlarm; import org.opennms.netmgt.model.OnmsAlarmCollection; import org.opennms.netmgt.model.TroubleTicketState; import org.opennms.netmgt.model.alarm.AlarmSummary; import org.opennms.netmgt.model.alarm.AlarmSummaryCollection; import org.opennms.web.rest.support.MultivaluedMapImpl; import org.opennms.web.rest.support.SecurityHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @Component("alarmRestService") @Path("alarms") public class AlarmRestService extends AlarmRestServiceBase { @Autowired private AlarmDao m_alarmDao; @Autowired private AcknowledgmentDao m_ackDao; /** * <p> * getAlarm * </p> * * @param alarmId * a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.model.OnmsAlarm} object. */ @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) @Path("{alarmId}") @Transactional public Response getAlarm(@Context SecurityContext securityContext, @PathParam("alarmId") final String alarmId) { SecurityHelper.assertUserReadCredentials(securityContext); if ("summaries".equals(alarmId)) { final List<AlarmSummary> collection = m_alarmDao.getNodeAlarmSummaries(); return collection == null ? Response.status(Status.NOT_FOUND).build() : Response.ok(new AlarmSummaryCollection(collection)).build(); } else { final OnmsAlarm alarm = m_alarmDao.get(Integer.valueOf(alarmId)); return alarm == null ? Response.status(Status.NOT_FOUND).build() : Response.ok(alarm).build(); } } /** * <p> * getCount * </p> * * @return a {@link java.lang.String} object. */ @GET @Produces(MediaType.TEXT_PLAIN) @Path("count") @Transactional public String getCount(@Context SecurityContext securityContext) { SecurityHelper.assertUserReadCredentials(securityContext); return Integer.toString(m_alarmDao.countAll()); } /** * <p> * getAlarms * </p> * * @return a {@link org.opennms.netmgt.model.OnmsAlarmCollection} object. */ @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) @Transactional public OnmsAlarmCollection getAlarms(@Context final SecurityContext securityContext, @Context final UriInfo uriInfo) { SecurityHelper.assertUserReadCredentials(securityContext); final CriteriaBuilder builder = getCriteriaBuilder(uriInfo.getQueryParameters(), false); builder.distinct(); final OnmsAlarmCollection coll = new OnmsAlarmCollection(m_alarmDao.findMatching(builder.toCriteria())); // For getting totalCount coll.setTotalCount(m_alarmDao.countMatching(builder.count().toCriteria())); return coll; } /** * <p> * updateAlarm * </p> * * @param alarmId * a {@link java.lang.String} object. * @param ack * a {@link java.lang.Boolean} object. */ @PUT @Path("{alarmId}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Transactional public Response updateAlarm(@Context final SecurityContext securityContext, @PathParam("alarmId") final Integer alarmId, final MultivaluedMapImpl formProperties) { writeLock(); try { if (alarmId == null) { return getBadRequestResponse("Unable to determine alarm ID to update based on query path."); } final String ackValue = formProperties.getFirst("ack"); formProperties.remove("ack"); final String escalateValue = formProperties.getFirst("escalate"); formProperties.remove("escalate"); final String clearValue = formProperties.getFirst("clear"); formProperties.remove("clear"); final String ackUserValue = formProperties.getFirst("ackUser"); formProperties.remove("ackUser"); final String ticketIdValue = formProperties.getFirst("ticketId"); formProperties.remove("ticketId"); final String ticketStateValue = formProperties.getFirst("ticketState"); formProperties.remove("ticketState"); final OnmsAlarm alarm = m_alarmDao.get(alarmId); if (alarm == null) { return getBadRequestResponse("Unable to locate alarm with ID '" + alarmId + "'"); } boolean alarmUpdated = false; if (StringUtils.isNotBlank(ticketIdValue)) { alarmUpdated = true; alarm.setTTicketId(ticketIdValue); } if (EnumUtils.isValidEnum(TroubleTicketState.class, ticketStateValue)) { alarmUpdated = true; alarm.setTTicketState(TroubleTicketState.valueOf(ticketStateValue)); } if (alarmUpdated) { m_alarmDao.saveOrUpdate(alarm); } final String ackUser = ackUserValue == null ? securityContext.getUserPrincipal().getName() : ackUserValue; if (ackUser != null && StringUtils.isNotBlank(ackUser)) { SecurityHelper.assertUserEditCredentials(securityContext, ackUser); } final OnmsAcknowledgment acknowledgement = new OnmsAcknowledgment(alarm, ackUser); acknowledgement.setAckAction(AckAction.UNSPECIFIED); boolean isProcessAck = false; if (ackValue != null) { isProcessAck = true; if (Boolean.parseBoolean(ackValue)) { acknowledgement.setAckAction(AckAction.ACKNOWLEDGE); } else { acknowledgement.setAckAction(AckAction.UNACKNOWLEDGE); } } else if (escalateValue != null) { isProcessAck = true; if (Boolean.parseBoolean(escalateValue)) { acknowledgement.setAckAction(AckAction.ESCALATE); } } else if (clearValue != null) { isProcessAck = true; if (Boolean.parseBoolean(clearValue)) { acknowledgement.setAckAction(AckAction.CLEAR); } } if (isProcessAck) { m_ackDao.processAck(acknowledgement); m_ackDao.flush(); } return Response.noContent().build(); } finally { writeUnlock(); } } /** * <p> * updateAlarms * </p> * * @param formProperties * a {@link org.opennms.web.rest.support.MultivaluedMapImpl} object. */ @PUT @Transactional @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response updateAlarms(@Context final SecurityContext securityContext, final MultivaluedMapImpl formProperties) { writeLock(); try { final String ackValue = formProperties.getFirst("ack"); formProperties.remove("ack"); final String escalateValue = formProperties.getFirst("escalate"); formProperties.remove("escalate"); final String clearValue = formProperties.getFirst("clear"); formProperties.remove("clear"); final CriteriaBuilder builder = getCriteriaBuilder(formProperties, false); builder.distinct(); builder.limit(0); builder.offset(0); final String ackUser = formProperties.containsKey("ackUser") ? formProperties.getFirst("ackUser") : securityContext.getUserPrincipal().getName(); formProperties.remove("ackUser"); SecurityHelper.assertUserEditCredentials(securityContext, ackUser); final List<OnmsAlarm> alarms = m_alarmDao.findMatching(builder.toCriteria()); for (final OnmsAlarm alarm : alarms) { final OnmsAcknowledgment acknowledgement = new OnmsAcknowledgment(alarm, ackUser); acknowledgement.setAckAction(AckAction.UNSPECIFIED); if (ackValue != null) { if (Boolean.parseBoolean(ackValue)) { acknowledgement.setAckAction(AckAction.ACKNOWLEDGE); } else { acknowledgement.setAckAction(AckAction.UNACKNOWLEDGE); } } else if (escalateValue != null) { if (Boolean.parseBoolean(escalateValue)) { acknowledgement.setAckAction(AckAction.ESCALATE); } } else if (clearValue != null) { if (Boolean.parseBoolean(clearValue)) { acknowledgement.setAckAction(AckAction.CLEAR); } } else { throw getException(Status.BAD_REQUEST, "Must supply one of the 'ack', 'escalate', or 'clear' parameters, set to either 'true' or 'false'."); } m_ackDao.processAck(acknowledgement); } return alarms == null || alarms.isEmpty() ? Response.notModified().build() : Response.noContent().build(); } finally { writeUnlock(); } } }
jeffgdotorg/opennms
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v1/AlarmRestService.java
Java
gpl-2.0
11,406
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace VDS.RDF.Query.Expressions.Functions.Leviathan.Numeric.Trigonometry { /// <summary> /// Represents the Leviathan lfn:cot() or lfn:cot-1 function /// </summary> public class CotangentFunction : BaseTrigonometricFunction { private bool _inverse = false; private static Func<double, double> _cotangent = (d => (Math.Cos(d) / Math.Sin(d))); private static Func<double, double> _arccotangent = (d => Math.Atan(1 / d)); /// <summary> /// Creates a new Leviathan Cotangent Function /// </summary> /// <param name="expr">Expression</param> public CotangentFunction(ISparqlExpression expr) : base(expr, _cotangent) { } /// <summary> /// Creates a new Leviathan Cotangent Function /// </summary> /// <param name="expr">Expression</param> /// <param name="inverse">Whether this should be the inverse function</param> public CotangentFunction(ISparqlExpression expr, bool inverse) : base(expr) { this._inverse = inverse; if (this._inverse) { this._func = _arccotangent; } else { this._func = _cotangent; } } /// <summary> /// Gets the String representation of the function /// </summary> /// <returns></returns> public override string ToString() { if (this._inverse) { return "<" + LeviathanFunctionFactory.LeviathanFunctionsNamespace + LeviathanFunctionFactory.TrigCotanInv + ">(" + this._expr.ToString() + ")"; } else { return "<" + LeviathanFunctionFactory.LeviathanFunctionsNamespace + LeviathanFunctionFactory.TrigCotan + ">(" + this._expr.ToString() + ")"; } } /// <summary> /// Gets the Functor of the Expression /// </summary> public override string Functor { get { if (this._inverse) { return LeviathanFunctionFactory.LeviathanFunctionsNamespace + LeviathanFunctionFactory.TrigCotanInv; } else { return LeviathanFunctionFactory.LeviathanFunctionsNamespace + LeviathanFunctionFactory.TrigCotan; } } } /// <summary> /// Transforms the Expression using the given Transformer /// </summary> /// <param name="transformer">Expression Transformer</param> /// <returns></returns> public override ISparqlExpression Transform(IExpressionTransformer transformer) { return new CotangentFunction(transformer.Transform(this._expr), this._inverse); } } }
jmahmud/RDFer
RDFerSolution/dotNetRdf/Query/Expressions/Functions/Leviathan/Numeric/Trigonometry/CotangentFunction.cs
C#
gpl-2.0
2,997
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>wallproxy - 已颁发证书</title> <script src="js/jquery.js"></script> <script src="/certs.js"></script> <script type="text/javascript"> $(document).ready(function(){ var colWidth = 300; var cols = Math.floor(document.documentElement.clientWidth / colWidth); if (cols == 0) cols = 1; colWidth = Math.floor(100 / cols); var cnt = WP_certs.length, idx = 0; var rows = Math.ceil(cnt / cols); var html = '<table border="0" width="100%">\n'; while (--rows >= 0) { html += '\t<tr>\n'; for (var col=0; col < cols && idx < cnt; col++, idx++) { html += '\t\t<td width="' +colWidth+ '%"><a href="/certs/'; html += WP_certs[idx]+ '">' +WP_certs[idx]+ '</a></td>\n'; } html += '\t</tr>\n'; } html += '</table>'; $('#certs_tbl').html(html); }); </script> </head> <body><div id="certs_tbl"></div></body>
lichuan261/wuand
WallProxy/src.zip/web/certs.html
HTML
gpl-2.0
953
// $ANTLR 2.7.0a11: "antlr.g" -> "ANTLRLexer.java"$ package antlr; public interface ANTLRTokenTypes { int EOF = 1; int NULL_TREE_LOOKAHEAD = 3; int LITERAL_tokens = 4; int LITERAL_header = 5; int STRING_LITERAL = 6; int ACTION = 7; int DOC_COMMENT = 8; int LITERAL_lexclass = 9; int LITERAL_class = 10; int LITERAL_extends = 11; int LITERAL_Lexer = 12; int LITERAL_TreeParser = 13; int OPTIONS = 14; int ASSIGN = 15; int SEMI = 16; int RCURLY = 17; int LITERAL_charVocabulary = 18; int CHAR_LITERAL = 19; int INT = 20; int OR = 21; int RANGE = 22; int TOKENS = 23; int TOKEN_REF = 24; int OPEN_ELEMENT_OPTION = 25; int CLOSE_ELEMENT_OPTION = 26; int LPAREN = 27; int RULE_REF = 28; int RPAREN = 29; int LITERAL_Parser = 30; int LITERAL_protected = 31; int LITERAL_public = 32; int LITERAL_private = 33; int BANG = 34; int ARG_ACTION = 35; int LITERAL_returns = 36; int COLON = 37; int LITERAL_exception = 38; int LITERAL_catch = 39; int NOT_OP = 40; int SEMPRED = 41; int TREE_BEGIN = 42; int QUESTION = 43; int STAR = 44; int PLUS = 45; int IMPLIES = 46; int CARET = 47; int WILDCARD = 48; int LITERAL_options = 49; int WS = 50; int COMMENT = 51; int SL_COMMENT = 52; int ML_COMMENT = 53; int COMMA = 54; int ESC = 55; int DIGIT = 56; int XDIGIT = 57; int VOCAB = 58; int NESTED_ARG_ACTION = 59; int NESTED_ACTION = 60; int WS_LOOP = 61; int INTERNAL_RULE_REF = 62; int WS_OPT = 63; int NOT_USEFUL = 64; }
dbenn/cgp
lib/antlr-2.7.0/antlr/ANTLRTokenTypes.java
Java
gpl-2.0
1,472
/* * Copyright (c) 2004, Bull SA. All rights reserved. * Created by: Laurent.Vivier@bull.net * This file is licensed under the GPL license. For the full content * of this license, see the COPYING file at the top level of this * source tree. */ /* * assertion: * * aio_lio_opcode shall be ignored. * * method: * * - write data to a file * - fill in an aiocb with an LIO_WRITE aio_lio_opcode * - call aio_read with this aiocb * - check data is effectively read (ignoring aio_lio_opcode) */ #if 1 /* Temporarily disable it until https://tracker.crystax.net/issues/1145 is fixed */ int main() { return 0; } #else #define _XOPEN_SOURCE 600 #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <errno.h> #include <stdlib.h> #include <aio.h> #include "posixtest.h" #define TNAME "aio_read/5-1.c" int main() { char tmpfname[256]; #define BUF_SIZE 111 unsigned char buf[BUF_SIZE]; unsigned char check[BUF_SIZE]; int fd; struct aiocb aiocb; int i; #if _POSIX_ASYNCHRONOUS_IO != 200112L exit(PTS_UNSUPPORTED); #endif snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_aio_read_5_1_%d", getpid()); unlink(tmpfname); fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR); if (fd == -1) { printf(TNAME " Error at open(): %s\n", strerror(errno)); exit(PTS_UNRESOLVED); } unlink(tmpfname); for (i = 0; i < BUF_SIZE; i++) buf[i] = i; if (write(fd, buf, BUF_SIZE) != BUF_SIZE) { printf(TNAME " Error at write(): %s\n", strerror(errno)); exit(PTS_UNRESOLVED); } memset(check, 0xaa, BUF_SIZE); memset(&aiocb, 0, sizeof(struct aiocb)); aiocb.aio_fildes = fd; aiocb.aio_buf = check; aiocb.aio_nbytes = BUF_SIZE; aiocb.aio_lio_opcode = LIO_WRITE; if (aio_read(&aiocb) == -1) { printf(TNAME " Error at aio_read(): %s\n", strerror(errno)); exit(PTS_FAIL); } int err; int ret; /* Wait until end of transaction */ while ((err = aio_error (&aiocb)) == EINPROGRESS); err = aio_error(&aiocb); ret = aio_return(&aiocb); if (err != 0) { printf(TNAME " Error at aio_error() : %s\n", strerror (err)); close(fd); exit(PTS_FAIL); } if (ret != BUF_SIZE) { printf(TNAME " Error at aio_return()\n"); close(fd); exit(PTS_FAIL); } /* check it */ for (i = 0; i < BUF_SIZE; i++) { if (buf[i] != check[i]) { printf(TNAME " read values are corrupted\n"); exit(PTS_FAIL); } } close(fd); printf ("Test PASSED\n"); return PTS_PASS; } #endif
crystax/android-vendor-openpts
conformance/interfaces/aio_read/5-1.c
C
gpl-2.0
2,542
package Common.Loggers; import Common.FuncInterfaces.*; import Common.Interfaces.ILogger; import java.io.*; import static Common.Utils.StringUtils.LineBreak; import static Common.Utils.TimeUtils.nowTime; import static java.lang.String.format; /** * Created by roman.i on 25.09.2014. */ public class DefaultLogger implements ILogger { public FuncT<String> LogFileFormat; private static String LogRecordTemplate = LineBreak + "[%s] %s: %s" + LineBreak; private FuncTTT<String, String, String> LogRecord = (String s1, String s2) -> format(LogRecordTemplate, s1, nowTime("yyyy-MM-dd HH:mm:ss.S"), s2); public FuncT<String> LogDirectoryRoot = () -> ".Logs/"; public boolean CreateFoldersForLogTypes = true; public static String getValidUrl(String logPath) { if (logPath == null || logPath.equals("")) return ""; String result = logPath.replace("/", "\\"); if (result.charAt(1) != ':') if (result.substring(0, 3).equals("..\\")) result = result.substring(2); if (result.charAt(0) != '\\') result = "\\" + result; return (result.charAt(result.length() - 1) == '\\') ? result : result + "\\"; } public File getFile(String fileName) throws Exception { File file = new File("."); String current = file.getCanonicalPath(); String logDirectory = current + getValidUrl(LogDirectoryRoot.invoke()) + (CreateFoldersForLogTypes ? fileName + "s\\" : ""); return new File(logDirectory + format(LogFileFormat.invoke(), fileName)); } public void createDirFile(File file) throws IOException { file.getParentFile().mkdirs(); if (!file.exists()) file.createNewFile(); } private void InLog(String fileName, String typeName, String msg) throws Exception { File file = getFile(fileName); createDirFile(file); writeInFile(file, LogRecord.invoke(typeName, msg)); } private void writeInFile(File file, String msg) throws Exception { FileWriter fw = new FileWriter(file, true); fw.write(msg); fw.close(); } public void Event(String msg) throws Exception { InLog("Event", "Event", msg); } public void Error(String msg) throws Exception { InLog("Error", "Error", msg); InLog("Event", "Error", msg); } }
elv1s42/VIQAUITestingTool
Java/src/main/java/Common/Loggers/DefaultLogger.java
Java
gpl-2.0
2,428
<!doctype html> <html lang="en" itemscope itemtype="http://schema.org/Person"> <head> <meta charset="utf-8"> <!-- Site Meta Data --> <title>Parbhat Puri - python</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="Software Developer and Founder"> <meta name="author" content="Parbhat Puri"> <link rel="shortcut icon" href="https://parbhatpuri.com/images/favicon.ico"> <!-- schema.org --> <meta itemprop="name" content="Parbhat Puri"> <meta itemprop="image" content=""> <meta itemprop="description" content="Software Developer and Founder"> <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'> <!-- Style Meta Data --> <link rel="stylesheet" href="https://parbhatpuri.com/theme/css/style.css" type="text/css"/> <link rel="stylesheet" href="https://parbhatpuri.com/theme/css/pygments.css" type="text/css"/> <!-- Feed Meta Data --> <link href="https://parbhatpuri.com/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Parbhat Puri ATOM Feed"/> <!-- Twitter Feed --> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="@parbhatpuri"> <meta name="twitter:creator" content="parbhatpuri"> <meta name="twitter:url" content="https://parbhatpuri.com"> <meta name="twitter:title" content="Parbhat Puri"> <meta name="twitter:description" content="Software Developer and Founder"> <!-- Facebook Meta Data --> <meta property="og:title" content="Parbhat Puri"/> <meta property="og:description" content="Software Developer and Founder"/> <meta property="og:image" content=""/> <meta name="twitter:creator" content="parbhatpuri"> <meta name="twitter:url" content="https://parbhatpuri.com/tag/python.html"> <meta name="twitter:title" content="Parbhat Puri ~ python"> <meta name="twitter:description" content="Articles de python"> <!-- Facebook Meta Data --> <meta property="og:title" content="Parbhat Puri ~ python"/> <meta property="og:description" content="Articles de python"/> <meta property="og:image" content=""/> </head> <body> <!-- Sidebar --> <aside> <!--<center><a href="https://parbhatpuri.com"><img id="avatar" src=""></a></center>--> <h1>Parbhat Puri</h1> <p>Software Developer and Founder</p> <br> <a class="twitter-follow-button" href="https://twitter.com/parbhatpuri" data-show-count="false" data-lang="en"> Follow @twitterdev </a> <script type="text/javascript"> window.twttr = (function (d, s, id) { var t, js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); return window.twttr || (t = { _e: [], ready: function (f) { t._e.push(f) } }); }(document, "script", "twitter-wjs")); </script> <nav class="nav"> <ul class="list-bare"> <li><a class="nav__link" href="https://parbhatpuri.com">Blog</a></li> <li><a class="nav__link" href="https://parbhatpuri.com/pages/about.html">About</a></li> <li><a class="nav__link" href="https://parbhatpuri.com/parbhat_resume.pdf">Resume</a></li> </ul> </nav> <p class="social"> <a href="https://www.linkedin.com/in/parbhat" target="_blank"><img src="https://parbhatpuri.com/theme/images/icons/linkedin.png"></a> <a href="https://github.com/parbhat" target="_blank"><img src="https://parbhatpuri.com/theme/images/icons/github.png"></a> <a href="https://twitter.com/parbhatpuri" target="_blank"><img src="https://parbhatpuri.com/theme/images/icons/twitter.png"></a> <a href="https://parbhatpuri.com/feeds/all.atom.xml" rel="alternate"> <img src="https://parbhatpuri.com/theme/images/icons/rss.png"></a> </p> </aside> <!-- Content --> <article> <h1 class="title">Hi, I'm Parbhat Puri</h1> <ol class="posts"> <h2 class="latest">Latest Posts</h2> <li class="post_list"><p class="post_entry"> <h2 class="post_title"><a href="https://parbhatpuri.com/a-3-year-journey-of-an-indian-remote-software-developer.html" rel="bookmark" title="Permalink to A 3-year journey of an Indian remote Software developer">A 3-year journey of an Indian remote Software developer</a> </h2> <a href="https://parbhatpuri.com/author/parbhat-puri.html">@Parbhat Puri</a> <span> in </span> <span class="post_category"><a href="https://parbhatpuri.com/category/remote.html" rel="bookmark" title="Permalink to remote">[ remote ]</a></span> <span class="post_date">Sat 28 April 2018</span> </li> <li class="post_list"><p class="post_entry"> <h2 class="post_title"><a href="https://parbhatpuri.com/open-sourcing-pelican-blue-theme-used-in-this-blog.html" rel="bookmark" title="Permalink to Open Sourcing pelican-blue theme used in this blog">Open Sourcing pelican-blue theme used in this blog</a> </h2> <a href="https://parbhatpuri.com/author/parbhat-puri.html">@Parbhat Puri</a> <span> in </span> <span class="post_category"><a href="https://parbhatpuri.com/category/opensource.html" rel="bookmark" title="Permalink to opensource">[ opensource ]</a></span> <span class="post_date">Mon 18 January 2016</span> </li> <li class="post_list"><p class="post_entry"> <h2 class="post_title"><a href="https://parbhatpuri.com/why-you-should-learn-flask-before-django.html" rel="bookmark" title="Permalink to Why you should learn Flask before Django?">Why you should learn Flask before Django?</a> </h2> <a href="https://parbhatpuri.com/author/parbhat-puri.html">@Parbhat Puri</a> <span> in </span> <span class="post_category"><a href="https://parbhatpuri.com/category/python.html" rel="bookmark" title="Permalink to python">[ python ]</a></span> <span class="post_date">Sat 04 April 2015</span> </li> <li class="post_list"><p class="post_entry"> <h2 class="post_title"><a href="https://parbhatpuri.com/Why-you-should-learn-python-in-2015.html" rel="bookmark" title="Permalink to Why you should learn Python in 2015?">Why you should learn Python in 2015?</a> </h2> <a href="https://parbhatpuri.com/author/parbhat-puri.html">@Parbhat Puri</a> <span> in </span> <span class="post_category"><a href="https://parbhatpuri.com/category/python.html" rel="bookmark" title="Permalink to python">[ python ]</a></span> <span class="post_date">Sun 04 January 2015</span> </li> <li class="post_list"><p class="post_entry"> <h2 class="post_title"><a href="https://parbhatpuri.com/virtualenvwrapper-on-top-of-virtualenv.html" rel="bookmark" title="Permalink to VirtualenvWrapper on top of Virtualenv">VirtualenvWrapper on top of Virtualenv</a> </h2> <a href="https://parbhatpuri.com/author/parbhat-puri.html">@Parbhat Puri</a> <span> in </span> <span class="post_category"><a href="https://parbhatpuri.com/category/python.html" rel="bookmark" title="Permalink to python">[ python ]</a></span> <span class="post_date">Thu 27 November 2014</span> </li> <li class="post_list"><p class="post_entry"> <h2 class="post_title"><a href="https://parbhatpuri.com/why-use-linux-for-python-development.html" rel="bookmark" title="Permalink to Why use Linux for Python development?">Why use Linux for Python development?</a> </h2> <a href="https://parbhatpuri.com/author/parbhat-puri.html">@Parbhat Puri</a> <span> in </span> <span class="post_category"><a href="https://parbhatpuri.com/category/python.html" rel="bookmark" title="Permalink to python">[ python ]</a></span> <span class="post_date">Sat 22 November 2014</span> </li> <li class="post_list"><p class="post_entry"> <h2 class="post_title"><a href="https://parbhatpuri.com/django_tutorials.html" rel="bookmark" title="Permalink to Django (Python Web Framework) Tutorials">Django (Python Web Framework) Tutorials</a> </h2> <a href="https://parbhatpuri.com/author/parbhat-puri.html">@Parbhat Puri</a> <span> in </span> <span class="post_category"><a href="https://parbhatpuri.com/category/python.html" rel="bookmark" title="Permalink to Python">[ Python ]</a></span> <span class="post_date">Fri 18 July 2014</span> </li> </ol> </article> <!-- Footer --> <footer> <p> Blog powered by <a href="http://getpelican.com/">Pelican</a>, which takes great advantage of <a href="http://python.org">Python</a>. Theme <a href="https://github.com/parbhat/pelican-blue">Pelican-Blue</a> by <a href="https://parbhatpuri.com/">@parbhat</a>. </p> </footer> <!-- Analytics --> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-50405008-1']); _gaq.push(['_trackPageview']); (function () { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </body> </html>
Parbhat/portfolio
tag/python.html
HTML
gpl-2.0
11,475
/* * mantis_sysfs.c * * Created on: 2013-4-2 * Author: zekezang */ /* mantis model support. */ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/debugfs.h> #include <linux/seq_file.h> #include <linux/device.h> #include "mantis.h" static struct class *mantis_class; struct dentry *mantis_debugfs = NULL; int __init mantis_sysfs_init(void) { MT_INFO("mantis mantis_sysfs_init....."); mantis_debugfs = debugfs_create_dir("mantis", NULL); mantis_class = class_create(THIS_MODULE, "mantis"); if (IS_ERR(mantis_class)) return PTR_ERR(mantis_class); return 0; }
zekezang/linux-2.6.38
net/0-mantis/mantis_sysfs.c
C
gpl-2.0
623
/* * This file is part of the coreboot project. * * Copyright 2014 SolidRun ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <arch/io.h> #include <device/device.h> #include <elog.h> #include <boot/coreboot_tables.h> #include <vendorcode/google/chromeos/chromeos.h> static void setup_pinmux(void) { } static void setup_kernel_info(void) { } static void mainboard_init(device_t dev) { setup_pinmux(); setup_kernel_info(); elog_init(); #if CONFIG_VBOOT_VERIFY_FIRMWARE elog_add_boot_reason(); #endif } static void mainboard_enable(device_t dev) { dev->ops->init = &mainboard_init; } struct chip_operations mainboard_ops = { .name = "acorn", .enable_dev = mainboard_enable, }; void lb_board(struct lb_header *header) { struct lb_range *dma; dma = (struct lb_range *)lb_new_record(header); dma->tag = LB_TAB_DMA; dma->size = sizeof(*dma); dma->range_start = CONFIG_DRAM_DMA_START; dma->range_size = CONFIG_DRAM_DMA_SIZE; }
acorn-marvell/coreboot
src/mainboard/marvell/acorn/mainboard.c
C
gpl-2.0
1,577
<?php //- $ranges=Array( "3573547008" => array("3573612543","ES"), "3573612544" => array("3573743615","GB"), "3573743616" => array("3573809151","CH"), "3573809152" => array("3573874687","ES"), "3573874688" => array("3573878783","PL"), "3573878784" => array("3573882879","RU"), "3573882880" => array("3573884927","DK"), "3573884928" => array("3573886975","PL"), "3573886976" => array("3573889023","RU"), "3573889024" => array("3573891071","HR"), "3573891072" => array("3573893119","NL"), "3573893120" => array("3573897215","RU"), "3573897216" => array("3573899263","GB"), "3573899264" => array("3573903359","RU"), "3573903360" => array("3573905407","SI"), "3573905408" => array("3573909503","RU"), "3573909504" => array("3573913599","PL"), "3573913600" => array("3573915647","CH"), "3573915648" => array("3573917695","RU"), "3573917696" => array("3573919743","SA"), "3573919744" => array("3573921791","GB"), "3573921792" => array("3573923839","RU"), "3573923840" => array("3573925887","UA"), "3573925888" => array("3573929983","PL"), "3573929984" => array("3573938175","RU"), "3573938176" => array("3573940223","PL"), "3573940224" => array("3574005759","PS"), "3574005760" => array("3574071295","CY"), "3574071296" => array("3574136831","IL"), "3574136832" => array("3574169599","DE"), "3574169600" => array("3574202367","ES"), "3574202368" => array("3574267903","NL"), "3574267904" => array("3574333439","FR"), "3574333440" => array("3574398975","EU"), "3574398976" => array("3574464511","PT"), "3574464512" => array("3574530047","TR"), "3574530048" => array("3574595583","SE"), "3574595584" => array("3574603775","FR"), "3574603776" => array("3574611967","BG"), "3574611968" => array("3574628351","HU"), "3574628352" => array("3574661119","GR"), "3574661120" => array("3574693887","NL"), "3574693888" => array("3574726655","PL"), "3574726656" => array("3574792191","GB"), "3574792192" => array("3574824959","CZ"), "3574824960" => array("3574857727","GB"), "3574857728" => array("3574923263","DE"), "3574923264" => array("3574939647","RU"), "3574939648" => array("3574956031","SE"), "3574956032" => array("3574972415","IT"), "3574972416" => array("3574988799","LV"), "3574988800" => array("3575054335","PT"), "3575054336" => array("3575119871","DE"), "3575119872" => array("3575185407","RU"), "3575185408" => array("3575250943","PL"), "3575250944" => array("3575316479","IT"), "3575316480" => array("3575349247","RU"), "3575349248" => array("3575382015","ES"), "3575382016" => array("3575447551","FI"), "3575447552" => array("3575513087","CZ"), "3575513088" => array("3575545855","PT"), "3575545856" => array("3575562239","FR"), "3575562240" => array("3575578623","DE"), "3575578624" => array("3575644159","BE"), "3575644160" => array("3575709695","DK"), "3575709696" => array("3575742463","AT"), "3575742464" => array("3575775231","RU"), "3575775232" => array("3575824383","NL"), "3575824384" => array("3575832575","KW"), "3575832576" => array("3575840767","NL"), "3575840768" => array("3575873535","GB"), "3575873536" => array("3575906303","EE"), "3575906304" => array("3575971839","FR"), "3575971840" => array("3576037375","ES"), "3576037376" => array("3576102911","EU"), "3576102912" => array("3576135679","GB"), "3576135680" => array("3576168447","DE"), "3576168448" => array("3576266751","GB"), "3576266752" => array("3576299519","FR"), "3576299520" => array("3576365055","AE"), "3576365056" => array("3576430591","TR"), "3576430592" => array("3576496127","FR"), "3576496128" => array("3576561663","IT"), "3576561664" => array("3576627199","NL"), "3576627200" => array("3576692735","AT"), "3576692736" => array("3576758271","GB"), "3576758272" => array("3576823807","BE"), "3576823808" => array("3576889343","SE"), "3576889344" => array("3576954879","NL"), "3576954880" => array("3576987647","NO"), "3576987648" => array("3577020415","GB"), "3577020416" => array("3577085951","NL"), "3577085952" => array("3577151487","DE"), "3577151488" => array("3577167871","FR"), "3577167872" => array("3577184255","ET"), "3577184256" => array("3577217023","CH"), "3577217024" => array("3577282559","FR"), "3577282560" => array("3577348095","IL"), "3577348096" => array("3577413631","PT"), "3577413632" => array("3577479167","RU"), "3577479168" => array("3577544703","ES"), "3577544704" => array("3577610239","DE"), "3577610240" => array("3577675775","EU"), "3577675776" => array("3577741311","PT"), "3577741312" => array("3578003455","SE"), "3578003456" => array("3578265599","DE"), "3578265600" => array("3578331135","GB"), "3578331136" => array("3578339327","PL"), "3578339328" => array("3578347519","ES"), "3578347520" => array("3578363903","DE"), "3578363904" => array("3578396671","NL"), "3578396672" => array("3578462207","TR"), "3578462208" => array("3578527743","NL"), "3578527744" => array("3578658815","PL"), "3578658816" => array("3578724351","GB"), "3578724352" => array("3578732543","RU"), "3578732544" => array("3578740735","IE"), "3578740736" => array("3578757119","RU"), "3578757120" => array("3578822655","SE"), "3578822656" => array("3578855423","RU"), "3578855424" => array("3578888191","GB"), "3578888192" => array("3578920959","SK"), "3578920960" => array("3578986495","IT"), "3578986496" => array("3579002879","DE"), "3579002880" => array("3579019263","GB"), "3579019264" => array("3579052031","DK"), "3579052032" => array("3579117567","NL"), "3579117568" => array("3579183103","RU"), "3579183104" => array("3579248639","GB"), "3579248640" => array("3579346943","RU"), "3579346944" => array("3579445247","SE"), "3579445248" => array("3579478015","AT"), "3579478016" => array("3579527167","FR"), "3579527168" => array("3579543551","BA"), "3579543552" => array("3579576319","BG"), "3579576320" => array("3579609087","IT"), "3579609088" => array("3579641855","PL"), "3579641856" => array("3579707391","NL"), "3579707392" => array("3579723775","ES"), "3579723776" => array("3579740159","AT"), "3579740160" => array("3579772927","IE"), "3579772928" => array("3579838463","DE"), "3579838464" => array("3580100607","ES"), "3580100608" => array("3580362751","SE"), "3580362752" => array("3580624895","GB"), "3580624896" => array("3580626943","RU"), "3580626944" => array("3580628991","PL"), "3580628992" => array("3580631039","RU"), "3580631040" => array("3580633087","NL"), "3580633088" => array("3580635135","RU"), "3580635136" => array("3580637183","UA"), "3580637184" => array("3580639231","KZ"), "3580639232" => array("3580641279","PL"), "3580641280" => array("3580643327","FR"), "3580643328" => array("3580645375","UA"), "3580645376" => array("3580647423","PL"), "3580647424" => array("3580649471","DE"), "3580649472" => array("3580651519","SE"), "3580651520" => array("3580653567","NL"), "3580653568" => array("3580655615","PL"), "3580655616" => array("3580657663","SK"), "3580657664" => array("3580663807","RU"), "3580663808" => array("3580665855","PL"), "3580665856" => array("3580667903","CZ"), "3580667904" => array("3580669951","RU"), "3580669952" => array("3580671999","UA"), "3580672000" => array("3580682239","RU"), "3580682240" => array("3580684287","PL"), "3580684288" => array("3580686335","FR"), "3580686336" => array("3580688383","BG"), "3580688384" => array("3580698623","RU"), "3580698624" => array("3580702719","PL"), "3580702720" => array("3580710911","RU"), "3580710912" => array("3580715007","UA"), "3580715008" => array("3580719103","RU"), "3580719104" => array("3580723199","NL"), "3580723200" => array("3580727295","UA"), "3580727296" => array("3580731391","RU"), "3580731392" => array("3580739583","RO"), "3580739584" => array("3580743679","RU"), "3580743680" => array("3580751871","UA"), "3580751872" => array("3580755967","IR"), "3580755968" => array("3580772351","RU"), "3580772352" => array("3580780543","LV"), "3580780544" => array("3580805119","UA"), "3580805120" => array("3580821503","RU"), "3580821504" => array("3580837887","FR"), "3580837888" => array("3580887039","UA"), "3580887040" => array("3581149183","SE"), "3581149184" => array("3581280255","EU"), "3581280256" => array("3581411327","BE"), "3581411328" => array("3581673471","GB"), "3581673472" => array("3581935615","NL"), "3581935616" => array("3581943807","RU"), "3581943808" => array("3581951999","FR"), "3581952000" => array("3581960191","TR"), "3581960192" => array("3581976575","DE"), "3581976576" => array("3581984767","NO"), "3581984768" => array("3581992959","RU"), "3581992960" => array("3582001151","GB"), "3582001152" => array("3582009343","DK"), "3582009344" => array("3582017535","RU"), "3582017536" => array("3582025727","GB"), "3582025728" => array("3582033919","RU"), "3582033920" => array("3582042111","CZ"), "3582042112" => array("3582050303","ES"), "3582050304" => array("3582058495","NL"), "3582058496" => array("3582066687","AT"), "3582066688" => array("3582074879","UA"), "3582074880" => array("3582083071","GB"), "3582083072" => array("3582091263","BG"), "3582091264" => array("3582099455","QA"), "3582099456" => array("3582107647","GB"), "3582107648" => array("3582115839","NL"), "3582115840" => array("3582124031","SE"), "3582124032" => array("3582132223","FI"), "3582132224" => array("3582140415","RU"), "3582140416" => array("3582148607","GE"), "3582148608" => array("3582156799","EG"), "3582156800" => array("3582164991","GB"), "3582164992" => array("3582173183","SE"), "3582173184" => array("3582181375","GB"), "3582181376" => array("3582197759","DE"), "3582197760" => array("3582205951","DK"), "3582205952" => array("3582214143","AE"), "3582214144" => array("3582222335","RU"), "3582222336" => array("3582230527","SE"), "3582230528" => array("3582238719","BE"), "3582238720" => array("3582255103","NL"), "3582255104" => array("3582263295","KW"), "3582263296" => array("3582271487","ME"), "3582271488" => array("3582279679","NL"), "3582279680" => array("3582287871","GB"), "3582287872" => array("3582296063","DE"), "3582296064" => array("3582304255","GB"), "3582304256" => array("3582312447","UA"), "3582312448" => array("3582320639","JE"), "3582320640" => array("3582328831","CH"), "3582328832" => array("3582337023","HU"), "3582337024" => array("3582345215","ES"), "3582345216" => array("3582353407","IT"), "3582353408" => array("3582361599","SE"), "3582361600" => array("3582377983","PL"), "3582377984" => array("3582386175","RU"), "3582386176" => array("3582394367","NL"), "3582394368" => array("3582402559","DE"), "3582402560" => array("3582410751","PL"), "3582410752" => array("3582435327","RU"), "3582435328" => array("3582443519","MK"), "3582443520" => array("3582451711","DE"), "3582451712" => array("3582459903","LU"), "3582459904" => array("3582468095","NL"), "3582468096" => array("3582476287","SE"), "3582476288" => array("3582484479","DE"), "3582484480" => array("3582492671","CI"), "3582492672" => array("3582509055","IT"), "3582509056" => array("3582517247","SA"), "3582517248" => array("3582525439","PL"), "3582525440" => array("3582533631","GB"), "3582533632" => array("3582541823","BG"), "3582541824" => array("3582550015","US"), "3582550016" => array("3582558207","RS"), "3582558208" => array("3582566399","MC"), "3582566400" => array("3582574591","EU"), "3582574592" => array("3582582783","DE"), "3582582784" => array("3582590975","RU"), "3582590976" => array("3582599167","FR"), "3582599168" => array("3582607359","DE"), "3582607360" => array("3582615551","RU"), "3582615552" => array("3582623743","GB"), "3582623744" => array("3582631935","FI"), "3582631936" => array("3582640127","NO"), "3582640128" => array("3582648319","RU"), "3582648320" => array("3582656511","PT"), "3582656512" => array("3582664703","ES"), "3582664704" => array("3582672895","JO"), "3582672896" => array("3582681087","DE"), "3582681088" => array("3582689279","FR"), "3582689280" => array("3582697471","DE"), "3582697472" => array("3582705663","FI"), "3582705664" => array("3582722047","TR"), "3582722048" => array("3582730239","IT"), "3582730240" => array("3582738431","ES"), "3582738432" => array("3582746623","DK"), "3582746624" => array("3582754815","RU"), "3582754816" => array("3582763007","GR"), "3582763008" => array("3582771199","FI"), "3582771200" => array("3582779391","CY"), "3582779392" => array("3582787583","RU"), "3582787584" => array("3582795775","PT"), "3582795776" => array("3582803967","ES"), "3582803968" => array("3582812159","SE"), "3582812160" => array("3582820351","FI"), "3582820352" => array("3582828543","RU"), "3582828544" => array("3582836735","KZ"), "3582836736" => array("3582853119","RU"), "3582853120" => array("3582861311","SE"), "3582861312" => array("3582869503","RU"), "3582869504" => array("3582877695","NO"), "3582877696" => array("3582885887","AT"), "3582885888" => array("3582894079","TR"), "3582894080" => array("3582902271","CH"), "3582902272" => array("3582910463","RU"), "3582910464" => array("3582918655","SI"), "3582918656" => array("3582926847","GB"), "3582926848" => array("3582935039","ES"), "3582935040" => array("3582943231","SI"), "3582943232" => array("3582951423","AT"), "3582951424" => array("3582959615","GB"), "3582959616" => array("3582967807","FI"), "3582967808" => array("3582975999","DE"), "3582976000" => array("3582984191","TR"), "3582984192" => array("3582992383","DE"), "3582992384" => array("3583000575","ES"), "3583000576" => array("3583008767","IT"), "3583008768" => array("3583016959","TR"), "3583016960" => array("3583025151","CH"), "3583025152" => array("3583033343","IT"), "3583033344" => array("3583041535","FR"), "3583041536" => array("3583049727","NL"), "3583049728" => array("3583066111","RU"), "3583066112" => array("3583074303","DE"), "3583074304" => array("3583082495","BG"), "3583082496" => array("3583090687","KG"), "3583090688" => array("3583098879","NO"), "3583098880" => array("3583107071","FI"), "3583107072" => array("3583115263","AT"), "3583115264" => array("3583123455","CH"), "3583123456" => array("3583131647","PL"), "3583131648" => array("3583139839","SE"), "3583139840" => array("3583148031","DE"), "3583148032" => array("3583164415","GB"), "3583164416" => array("3583172607","PT"), "3583172608" => array("3583188991","DE"), "3583188992" => array("3583197183","RU"), "3583197184" => array("3583205375","KE"), "3583205376" => array("3583213567","HR"), "3583213568" => array("3583221759","IR"), "3583221760" => array("3583229951","AT"), "3583229952" => array("3583238143","RU"), "3583238144" => array("3583246335","GB"), "3583246336" => array("3583254527","RU"), "3583254528" => array("3583262719","GB"), "3583262720" => array("3583270911","TR"), "3583270912" => array("3583287295","DE"), "3583287296" => array("3583295487","RU"), "3583295488" => array("3583303679","ES"), "3583303680" => array("3583311871","NL"), "3583311872" => array("3583320063","RU"), "3583320064" => array("3583328255","HR"), "3583328256" => array("3583336447","DE"), "3583336448" => array("3583344639","ME"), "3583344640" => array("3583352831","BG"), "3583352832" => array("3583361023","CY"), "3583361024" => array("3583369215","IT"), "3583369216" => array("3583377407","ES"), "3583377408" => array("3583385599","AT"), "3583385600" => array("3583393791","DK"), "3583393792" => array("3583401983","RU"), "3583401984" => array("3583410175","KE"), "3583410176" => array("3583418367","SE"), "3583418368" => array("3583426559","TN"), "3583426560" => array("3583434751","CI"), "3583434752" => array("3583442943","AT"), "3583442944" => array("3583451135","UA"), "3583451136" => array("3583459327","IL"), "3583459328" => array("3583467519","CZ"), "3583467520" => array("3583475711","ES"), "3583475712" => array("3583483903","NO"), "3583483904" => array("3583492095","FR"), "3583492096" => array("3583508479","SK"), "3583508480" => array("3583516671","FR"), "3583516672" => array("3583524863","GB"), "3583524864" => array("3583533055","EG"), "3583533056" => array("3583541247","DE"), "3583541248" => array("3583549439","RU"), "3583549440" => array("3583557631","NL"), "3583557632" => array("3583565823","IT"), "3583565824" => array("3583574015","GB"), "3583574016" => array("3583582207","NO"), "3583582208" => array("3583590399","AT"), "3583590400" => array("3583598591","DE"), "3583598592" => array("3583606783","SE"), "3583606784" => array("3583639551","TR"), "3583639552" => array("3583647743","AZ"), "3583647744" => array("3583655935","EG"), "3583655936" => array("3583664127","SN"), "3583664128" => array("3583680511","RO"), "3583680512" => array("3583688703","RU"), "3583688704" => array("3583696895","UA"), "3583696896" => array("3583705087","NL"), "3583705088" => array("3583713279","UA"), "3583713280" => array("3583721471","CZ"), "3583721472" => array("3583729663","DE"), "3583729664" => array("3583737855","TR"), "3583737856" => array("3583746047","EU"), "3583746048" => array("3583754239","PL"), "3583754240" => array("3583762431","RU"), "3583762432" => array("3583770623","CZ"), "3583770624" => array("3583778815","NL"), "3583778816" => array("3583787007","IT"), "3583787008" => array("3583795199","UA"), "3583795200" => array("3583803391","PL"), "3583803392" => array("3583811583","RU"), "3583811584" => array("3583819775","DE"), "3583819776" => array("3583827967","RU"), "3583827968" => array("3583836159","CH"), "3583836160" => array("3583844351","DE"), "3583844352" => array("3583852543","KZ"), "3583852544" => array("3583860735","FI"), "3583860736" => array("3583868927","HU"), "3583868928" => array("3583877119","AT"), "3583877120" => array("3583885311","RO"), "3583885312" => array("3583893503","GE"), "3583893504" => array("3583901695","SI"), "3583901696" => array("3583909887","RU"), "3583909888" => array("3583918079","SE"), "3583918080" => array("3583926271","IT"), "3583926272" => array("3583934463","DE"), "3583934464" => array("3583942655","CH"), "3583942656" => array("3583950847","EG"), "3583950848" => array("3583959039","PL"), "3583959040" => array("3583967231","NO"), "3583967232" => array("3583975423","NL"), "3583975424" => array("3583983615","LT"), "3583983616" => array("3583999999","RU"), "3584000000" => array("3584008191","IE"), "3584008192" => array("3584016383","DK"), "3584016384" => array("3584024575","RU"), "3584024576" => array("3584032767","UA"), "3584032768" => array("3584040959","DE"), "3584040960" => array("3584049151","CH"), "3584049152" => array("3584057343","DE"), "3584057344" => array("3584065535","GB"), "3584065536" => array("3584073727","UA"), "3584073728" => array("3584081919","SK"), "3584081920" => array("3584098303","NL"), "3584098304" => array("3584106495","SI"), "3584106496" => array("3584114687","FI"), "3584114688" => array("3584122879","GB"), "3584122880" => array("3584131071","PL"), "3584131072" => array("3584139263","TR"), "3584139264" => array("3584147455","NO"), "3584147456" => array("3584155647","FR"), "3584155648" => array("3584163839","NO"), "3584163840" => array("3584172031","CH"), "3584172032" => array("3584180223","FR"), "3584180224" => array("3584188415","AT"), "3584188416" => array("3584196607","GB"), "3584196608" => array("3584204799","DE"), "3584204800" => array("3584212991","NL"), "3584212992" => array("3584221183","ES"), "3584221184" => array("3584229375","NO"), "3584229376" => array("3584245759","HU"), "3584245760" => array("3584253951","NL"), "3584253952" => array("3584262143","ME"), "3584262144" => array("3584270335","SE"), "3584270336" => array("3584278527","FR"), "3584278528" => array("3584286719","GB"), "3584286720" => array("3584303103","AT"), "3584303104" => array("3584311295","ES"), "3584311296" => array("3584319487","DE"), "3584319488" => array("3584327679","LT"), "3584327680" => array("3584335871","DE"), "3584335872" => array("3584344063","ES"), "3584344064" => array("3584352255","SE"), "3584352256" => array("3584360447","RO"), "3584360448" => array("3584368639","GB"), "3584368640" => array("3584376831","LB"), "3584376832" => array("3584393215","DE"), "3584393216" => array("3584401407","GB"), "3584401408" => array("3584409599","MT"), "3584409600" => array("3584417791","RU"), "3584417792" => array("3584434175","GB"), "3584434176" => array("3584442367","LU"), "3584442368" => array("3584450559","GB"), "3584450560" => array("3584458751","EU"), "3584458752" => array("3584466943","SA"), "3584466944" => array("3584475135","NO"), "3584475136" => array("3584483327","FR"), "3584483328" => array("3584491519","DE"), "3584491520" => array("3584499711","BG"), "3584499712" => array("3584507903","RU"), "3584507904" => array("3584516095","GB"), "3584516096" => array("3584524287","NO"), "3584524288" => array("3584532479","IS"), "3584532480" => array("3584540671","DE"), "3584540672" => array("3584548863","RU"), "3584548864" => array("3584557055","ES"), "3584557056" => array("3584565247","EE"), "3584565248" => array("3584573439","RU"), "3584573440" => array("3584589823","DE"), "3584589824" => array("3584598015","RU"), "3584598016" => array("3584606207","CZ"), "3584606208" => array("3584614399","DE"), "3584614400" => array("3584622591","IE"), "3584622592" => array("3584630783","FI"), "3584630784" => array("3584638975","BG"), "3584638976" => array("3584647167","UA"), "3584647168" => array("3584655359","LU"), "3584655360" => array("3584663551","CY"), "3584663552" => array("3584671743","FR"), "3584671744" => array("3584688127","NL"), "3584688128" => array("3584696319","GB"), "3584696320" => array("3584704511","ES"), "3584704512" => array("3584720895","RU"), "3584720896" => array("3584729087","GB"), "3584729088" => array("3584737279","DE"), "3584737280" => array("3584745471","GR"), "3584745472" => array("3584753663","DK"), "3584753664" => array("3584770047","RU"), "3584770048" => array("3584778239","NL"), "3584778240" => array("3584786431","IT"), "3584786432" => array("3584794623","NL"), "3584794624" => array("3584802815","IT"), "3584802816" => array("3584811007","GB"), "3584811008" => array("3584819199","ES"), "3584819200" => array("3584827391","RU"), "3584827392" => array("3584835583","ES"), "3584835584" => array("3584843775","AZ"), "3584843776" => array("3584851967","DE"), "3584860160" => array("3584868351","PL"), "3584868352" => array("3584876543","NO"), "3584876544" => array("3584884735","SI"), "3584884736" => array("3584892927","DE"), "3584892928" => array("3584901119","IL"), "3584901120" => array("3584909311","AT"), "3584909312" => array("3584917503","IT"), "3584917504" => array("3584925695","FI"), "3584925696" => array("3584933887","CH"), "3584933888" => array("3584942079","SE"), "3584942080" => array("3584950271","DK"), "3584950272" => array("3584958463","UA"), "3584958464" => array("3584966655","DE"), "3584966656" => array("3584974847","DK"), "3584974848" => array("3584983039","FR"), "3584983040" => array("3584991231","NL"), "3584991232" => array("3584999423","IT"), "3584999424" => array("3585007615","GB"), "3585007616" => array("3585015807","AT"), "3585015808" => array("3585023999","IT"), "3585024000" => array("3585032191","CZ"), "3585032192" => array("3585048575","LV"), "3585048576" => array("3585056767","GB"), "3585056768" => array("3585064959","LB"), "3585064960" => array("3585081343","GB"), "3585081344" => array("3585114111","IR"), "3585114112" => array("3585122303","IS"), "3585122304" => array("3585130495","ES"), "3585130496" => array("3585138687","FR"), "3585138688" => array("3585146879","RU"), "3585146880" => array("3585155071","RO"), "3585155072" => array("3585163263","GB"), "3585163264" => array("3585171455","BE"), "3585171456" => array("3585179647","RU"), "3585179648" => array("3585196031","BE"), "3585196032" => array("3585204223","ES"), "3585204224" => array("3585212415","GB"), "3585212416" => array("3585220607","DE"), "3585220608" => array("3585228799","RU"), "3585228800" => array("3585236991","DE"), "3585236992" => array("3585245183","HU"), "3585245184" => array("3585253375","GB"), "3585253376" => array("3585261567","DE"), "3585261568" => array("3585269759","IT"), "3585269760" => array("3585277951","SY"), "3585277952" => array("3585286143","SE"), "3585286144" => array("3585294335","NO"), "3585294336" => array("3585302527","DE"), "3585302528" => array("3585310719","ES"), "3585310720" => array("3585318911","DE"), "3585318912" => array("3585327103","DZ"), "3585327104" => array("3585335295","NL"), "3585335296" => array("3585343487","UA"), "3585343488" => array("3585351679","EE"), "3585351680" => array("3585359871","CZ"), "3585359872" => array("3585368063","SE"), "3585368064" => array("3585376255","LV"), "3585376256" => array("3585384447","PL"), "3585384448" => array("3585392639","CH"), "3585392640" => array("3585400831","RU"), "3585400832" => array("3585409023","FR"), "3585409024" => array("3585417215","RU"), "3585417216" => array("3585425407","BE"), "3585425408" => array("3585433599","ES"), "3585433600" => array("3585441791","IS"), "3585441792" => array("3585449983","SK"), "3585449984" => array("3585458175","SA"), "3585458176" => array("3585466367","HU"), "3585466368" => array("3585474559","EG"), "3585474560" => array("3585482751","DE"), "3585482752" => array("3585490943","FR"), "3585490944" => array("3585499135","IT"), "3585499136" => array("3585515519","DE"), "3585515520" => array("3585523711","RU"), "3585523712" => array("3585531903","LV"), "3585531904" => array("3585540095","AT"), "3585540096" => array("3585548287","DE"), "3585548288" => array("3585556479","RU"), "3585556480" => array("3585564671","DE"), "3585564672" => array("3585572863","RU"), "3585572864" => array("3585581055","IT"), "3585581056" => array("3585597439","DE"), "3585597440" => array("3585605631","RU"), "3585605632" => array("3585613823","PL"), "3585613824" => array("3585622015","EE"), "3585622016" => array("3585630207","RU"), "3585630208" => array("3585638399","RS"), "3585638400" => array("3585646591","RU"), "3585646592" => array("3585654783","SA"), "3585654784" => array("3585662975","NO"), "3585662976" => array("3585671167","BY"), "3585671168" => array("3585679359","SE"), "3585679360" => array("3585687551","FI"), "3585687552" => array("3585695743","DE"), "3585695744" => array("3585703935","GB"), "3585703936" => array("3585712127","DE"), "3585712128" => array("3585720319","AT"), "3585720320" => array("3585728511","GB"), "3585728512" => array("3585736703","SE"), "3585736704" => array("3585744895","HR"), "3585744896" => array("3585753087","FR"), "3585753088" => array("3585761279","PL"), "3585761280" => array("3585769471","UA"), "3585769472" => array("3585777663","TR"), "3585777664" => array("3585785855","JO"), "3585785856" => array("3585794047","UA"), "3585794048" => array("3585802239","FI"), "3585802240" => array("3585810431","IT"), "3585810432" => array("3585818623","GB"), "3585818624" => array("3585826815","DE"), "3585826816" => array("3585835007","RU"), "3585835008" => array("3585843199","US"), "3585843200" => array("3585851391","NO"), "3585851392" => array("3585859583","SE"), "3585859584" => array("3585867775","DE"), "3585867776" => array("3585875967","NO"), "3585875968" => array("3585884159","CH"), "3585884160" => array("3585892351","IQ"), "3585892352" => array("3585900543","DE"), "3585900544" => array("3585908735","NO"), "3585908736" => array("3585916927","FR"), "3585916928" => array("3585925119","IT"), "3585925120" => array("3585933311","CH"), "3585933312" => array("3585941503","NL"), "3585941504" => array("3585949695","PL"), "3585949696" => array("3585957887","KW"), "3585957888" => array("3585966079","SE"), "3585966080" => array("3585974271","CH"), "3585974272" => array("3585982463","BE"), "3585982464" => array("3585998847","RU"), "3585998848" => array("3586007039","ES"), "3586007040" => array("3586015231","LT"), "3586015232" => array("3586023423","FR"), "3586023424" => array("3586031615","IS"), "3586031616" => array("3586039807","IE"), "3586039808" => array("3586047999","GB"), "3586048000" => array("3586056191","PT"), "3586056192" => array("3586072575","RU"), "3586072576" => array("3586088959","DE"), "3586088960" => array("3586097151","CZ"), "3586097152" => array("3586105343","HR"), "3586113536" => array("3586121727","BG"), "3586121728" => array("3586129919","IE"), "3586129920" => array("3586146303","CZ"), "3586146304" => array("3586162687","PL"), "3586162688" => array("3586179071","FI"), "3586179072" => array("3586195455","ES"), "3586195456" => array("3586203647","RU"), "3586203648" => array("3586211839","ZA"), "3586211840" => array("3586228223","CH"), "3586228224" => array("3586244607","BE"), "3586244608" => array("3586260991","NL"), "3586260992" => array("3586277375","ES"), "3586277376" => array("3586293759","TR"), "3586293760" => array("3586310143","ES"), "3586310144" => array("3586326527","CZ"), "3586326528" => array("3586342911","IR"), "3586342912" => array("3586359295","ES"), "3586359296" => array("3586375679","PL"), "3586375680" => array("3586392063","CZ"), "3586392064" => array("3586408447","NL"), "3586408448" => array("3586424831","BA"), "3586424832" => array("3586441215","CH"), "3586441216" => array("3586457599","DE"), "3586457600" => array("3586473983","NL"), "3586473984" => array("3586490367","HU"), "3586490368" => array("3586506751","LT"), "3586506752" => array("3586523135","NL"), "3586523136" => array("3586555903","DE"), "3586555904" => array("3586572287","IT"), "3586572288" => array("3586588671","RS"), "3586588672" => array("3586596863","IT"), "3586596864" => array("3586605055","GB"), "3586605056" => array("3586621439","SE"), "3586621440" => array("3586637823","GB"), "3586637824" => array("3586654207","PL"), "3586654208" => array("3586662399","GE"), "3586662400" => array("3586670591","UA"), "3586670592" => array("3586686975","IE"), "3586686976" => array("3586703359","SE"), "3586703360" => array("3586719743","CH"), "3586719744" => array("3586752511","ES"), "3586752512" => array("3586785279","NL"), "3586785280" => array("3586793471","OM"), "3586793472" => array("3586801663","CH"), "3586801664" => array("3586818047","HR"), "3586818048" => array("3586834431","IE"), "3586834432" => array("3586850815","DE"), "3586850816" => array("3586867199","NO"), "3586867200" => array("3586883583","FR"), "3586883584" => array("3586899967","IT"), "3586899968" => array("3586916351","DE"), "3586916352" => array("3586924543","IT"), "3586924544" => array("3586932735","AX"), "3586932736" => array("3586949119","LB"), "3586949120" => array("3586965503","SE"), "3586965504" => array("3586981887","NL"), "3586981888" => array("3586998271","IT"), "3586998272" => array("3587006463","PT"), "3587006464" => array("3587014655","FR"), "3587014656" => array("3587055615","GB"), "3587055616" => array("3587063807","UZ"), "3587063808" => array("3587080191","NL"), "3587080192" => array("3587088383","GB"), "3587088384" => array("3587096575","DE"), "3587096576" => array("3587121151","NL"), "3587121152" => array("3587129343","AL"), "3587129344" => array("3587145727","NL"), "3587145728" => array("3587162111","CY"), "3587162112" => array("3587178495","IR"), "3587178496" => array("3587186687","AT"), "3587186688" => array("3587194879","DE"), "3587194880" => array("3587211263","GB"), "3587211264" => array("3587219455","AT"), "3587219456" => array("3587227647","RU"), "3587227648" => array("3587244031","GB"), "3587244032" => array("3587260415","IT"), "3587260416" => array("3587284991","DE"), "3587284992" => array("3587309567","IT"), "3587309568" => array("3587325951","GB"), "3587325952" => array("3587342335","RU"), "3587342336" => array("3587358719","CZ"), "3587358720" => array("3587375103","SA"), "3587375104" => array("3587383295","TR"), "3587383296" => array("3587391487","CZ"), "3587391488" => array("3587407871","KZ"), "3587407872" => array("3587424255","BE"), "3587424256" => array("3587440639","DE"), "3587440640" => array("3587457023","SE"), "3587457024" => array("3587473407","GB"), "3587473408" => array("3587489791","IT"), "3587489792" => array("3587506175","EG"), "3587506176" => array("3587538943","IT"), "3587538944" => array("3587547135","IS"), "3587547136" => array("3587555327","CH"), "3587555328" => array("3587571711","BE"), "3587571712" => array("3587579903","DE"), "3587579904" => array("3587588095","BE"), "3587588096" => array("3587596287","BG"), "3587596288" => array("3587604479","NL"), "3587604480" => array("3587620863","FI"), "3587620864" => array("3587637247","SE"), "3587637248" => array("3587653631","FR"), "3587653632" => array("3587670015","SK"), "3587670016" => array("3587702783","IT"), "3587702784" => array("3587710975","DE"), "3587710976" => array("3587719167","CZ"), "3587719168" => array("3587735551","PL"), "3587735552" => array("3587751935","GB"), "3587751936" => array("3587768319","FI"), "3587768320" => array("3587776511","DE"), "3587776512" => array("3587784703","IR"), "3587784704" => array("3587801087","DE"), "3587801088" => array("3587817471","IT"), "3587817472" => array("3587833855","MT"), "3587833856" => array("3587842047","DE"), "3587842048" => array("3587850239","IT"), "3587850240" => array("3587866623","PL"), "3587866624" => array("3587874815","FR"), "3587874816" => array("3587883007","DE"), "3587883008" => array("3587915775","GB"), "3587915776" => array("3587932159","EE"), "3587932160" => array("3587948543","BE"), "3587948544" => array("3587964927","RU"), "3587964928" => array("3587981311","ES"), "3587981312" => array("3587997695","IS"), "3587997696" => array("3588014079","DE"), "3588014080" => array("3588030463","CZ"), "3588030464" => array("3588046847","RU"), "3588046848" => array("3588063231","DE"), "3588063232" => array("3588071423","CH"), "3588071424" => array("3588079615","GB"), "3588079616" => array("3588095999","CH"), "3588096000" => array("3588104191","NL"), "3588104192" => array("3588112383","BG"), "3588112384" => array("3588128767","FR"), "3588128768" => array("3588145151","HU"), "3588145152" => array("3588153343","PL"), "3588153344" => array("3588161535","RU"), "3588161536" => array("3588227071","FR"), "3588227072" => array("3588292607","BE"), "3588292608" => array("3588308991","AT"), "3588308992" => array("3588325375","NO"), "3588325376" => array("3588333567","GB"), "3588333568" => array("3588341759","FR"), "3588341760" => array("3588358143","IT"), "3588358144" => array("3588374527","BG"), "3588374528" => array("3588390911","SE"), "3588390912" => array("3588407295","LT"), "3588407296" => array("3588423679","CZ"), "3588423680" => array("3588440063","ES"), "3588440064" => array("3588456447","PL"), "3588456448" => array("3588464639","NL"), "3588464640" => array("3588472831","AT"), "3588472832" => array("3588489215","UA"), "3588489216" => array("3588505599","FR"), "3588505600" => array("3588521983","RU"), "3588521984" => array("3588538367","PT"), "3588538368" => array("3588554751","GB"), "3588554752" => array("3588571135","AT"), "3588571136" => array("3588587519","GB"), "3588587520" => array("3588603903","ES"), "3588603904" => array("3588620287","SI"), "3588620288" => array("3588628479","SA"), "3588628480" => array("3588636671","CH"), "3588636672" => array("3588653055","UZ"), "3588653056" => array("3588661247","IT"), "3588661248" => array("3588669439","NO"), "3588669440" => array("3588685823","GB"), "3588685824" => array("3588702207","UA"), "3588702208" => array("3588718591","ES"), "3588718592" => array("3588734975","BG"), "3588734976" => array("3588751359","PL"), "3588751360" => array("3588767743","TR"), "3588767744" => array("3588784127","GB"), "3588784128" => array("3588800511","CH"), "3588800512" => array("3588816895","RU"), "3588816896" => array("3588833279","IT"), "3588833280" => array("3588849663","RO"), "3588849664" => array("3588857855","IE"), "3588857856" => array("3588866047","IR"), "3588866048" => array("3588882431","NL"), "3588882432" => array("3588890623","RU"), "3588890624" => array("3588898815","GB"), "3588898816" => array("3588915199","NO"), "3588915200" => array("3588931583","IT"), "3588931584" => array("3588947967","RU"), "3588947968" => array("3588964351","GB"), "3588964352" => array("3588997119","CZ"), "3588997120" => array("3589013503","AT"), "3589013504" => array("3589021695","ES"), "3589021696" => array("3589029887","SA"), "3589029888" => array("3589046271","NL"), "3589046272" => array("3589079039","NO"), "3589079040" => array("3589128191","DK"), "3589128192" => array("3589144575","GB"), "3589144576" => array("3589152767","UA"), "3589152768" => array("3589160959","DE"), "3589160960" => array("3589177343","PL"), "3589177344" => array("3589193727","TR"), "3589193728" => array("3589210111","SE"), "3589210112" => array("3589226495","NL"), "3589226496" => array("3589242879","NO"), "3589242880" => array("3589259263","NL"), "3589259264" => array("3589275647","DE"), "3589275648" => array("3589292031","RS"), "3589292032" => array("3589308415","AT"), "3589308416" => array("3589324799","DE"), "3589324800" => array("3589341183","BG"), "3589341184" => array("3589373951","PL"), "3589373952" => array("3589390335","DE"), "3589390336" => array("3589423103","RU"), "3589423104" => array("3589439487","GB"), "3589439488" => array("3589455871","SE"), "3589455872" => array("3589472255","RU"), "3589472256" => array("3589488639","TR"), "3589488640" => array("3589505023","RU"), "3589505024" => array("3589521407","FI"), "3589521408" => array("3589537791","IT"), "3589537792" => array("3589545983","FR"), "3589545984" => array("3589554175","DE"), "3589554176" => array("3589570559","PS"), "3589570560" => array("3589586943","GB"), "3589586944" => array("3589603327","RS"), "3589603328" => array("3589668863","FR"), "3589668864" => array("3589677055","RU"), "3589677056" => array("3589685247","FR"), "3589685248" => array("3589718015","GB"), "3589718016" => array("3589734399","BE"), "3589734400" => array("3589742591","EG"), "3589742592" => array("3589767167","NL"), "3589767168" => array("3589816319","RU"), "3589816320" => array("3589832703","EU"), "3589832704" => array("3589849087","TR"), "3589849088" => array("3589865471","GB"), "3589865472" => array("3589881855","GR"), "3589881856" => array("3589890047","NL"), "3589890048" => array("3589931007","GB"), "3589931008" => array("3589947391","SI"), "3589947392" => array("3589963775","FI"), "3589963776" => array("3589980159","ES"), "3589980160" => array("3589996543","CZ"), "3589996544" => array("3590012927","GB"), "3590012928" => array("3590029311","BE"), "3590029312" => array("3590045695","FR"), "3590045696" => array("3590062079","RU"), "3590062080" => array("3590078463","DE"), "3590078464" => array("3590094847","RU"), "3590094848" => array("3590111231","DE"), "3590111232" => array("3590127615","LT"), "3590127616" => array("3590143999","GB"), "3590144000" => array("3590160383","SI"), "3590160384" => array("3590176767","GB"), "3590176768" => array("3590193151","HU"), "3590193152" => array("3590201343","IT"), "3590201344" => array("3590209535","DE"), "3590209536" => array("3590225919","ES"), "3590225920" => array("3590234111","TR"), "3590234112" => array("3590242303","GB"), "3590242304" => array("3590258687","IE"), "3590258688" => array("3590291455","IT"), "3590291456" => array("3590299647","EG"), "3590299648" => array("3590307839","FI"), "3590307840" => array("3590324223","GB"), ); ?>
hodorogandrei/contesteasyplatform
admiasi/include/ip2country_files/213.php
PHP
gpl-2.0
38,880
def float_example(): a = -10 print a.__float__() print float(a) if __name__ == '__main__': float_example()
ramesharpu/python
basic-coding/built-in-functions/float.py
Python
gpl-2.0
124
# # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2001 David R. Hampton # Copyright (C) 2001-2006 Donald N. Allingham # Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # #------------------------------------------------------------------------- # # Gramps modules # #------------------------------------------------------------------------- from gramps.gen.utils.grampslocale import GrampsLocale from gramps.gen.display.name import NameDisplay from gramps.gen.config import config #------------------------------------------------------------------------- # # Report # #------------------------------------------------------------------------- class Report: """ The Report base class. This is a base class for generating customized reports. It cannot be used as is, but it can be easily sub-classed to create a functional report generator. """ def __init__(self, database, options_class, user): self.database = database self.options_class = options_class self._user = user self.doc = options_class.get_document() creator = database.get_researcher().get_name() self.doc.set_creator(creator) output = options_class.get_output() if output: self.standalone = True self.doc.open(options_class.get_output()) else: self.standalone = False def begin_report(self): pass def set_locale(self, language): """ Set the translator to one selected with stdoptions.add_localization_option(). """ if language == GrampsLocale.DEFAULT_TRANSLATION_STR: language = None locale = GrampsLocale(lang=language) self._ = locale.translation.sgettext self._get_date = locale.get_date self._get_type = locale.get_type self._ldd = locale.date_displayer self._name_display = NameDisplay(locale) # a legacy/historical name self._name_display.set_name_format(self.database.name_formats) fmt_default = config.get('preferences.name-format') self._name_display.set_default_format(fmt_default) return locale def write_report(self): pass def end_report(self): if self.standalone: self.doc.close()
beernarrd/gramps
gramps/gen/plug/report/_reportbase.py
Python
gpl-2.0
3,048
<?php // Search // Wp Estate Pack global $row_number_col; get_header(); $options = wpestate_page_details(''); $unit_class = "col-md-6"; $row_number_col=6; if($options['content_class'] == "col-md-12"){ $unit_class="col-md-4"; $row_number_col=4; } $row_number_col=4; ?> <div class="row content-fixed"> <?php get_template_part('templates/breadcrumbs'); ?> <div class=" col-md-12 "> <div class="blog_list_wrapper row"> <?php if (have_posts()){ print ' <h1 class="entry-title-search">'. esc_html__( 'Search Results for: ','wpestate');print '"' . get_search_query() . '"'.'</h1>'; while (have_posts()) : the_post(); get_template_part('templates/blog_unit'); endwhile; }else{ ?> <h1 class="entry-title-search"><?php esc_html_e( 'We didn\'t find any results. Please try again with different search parameters. ', 'wpestate' ); ?></h1> <form method="get" class="searchform" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <input type="text" class="form-control search_res_form" name="s" id="s" value="<?php esc_attr (esc_html_e( 'Type Keyword', 'wpestate' )); ?>" /> <input type="submit" id="submit-form" class="wpb_btn-info wpb_regularsize wpestate_vc_button vc_button" value="<?php esc_attr ( esc_html_e( 'Search', 'wpestate') ); ?>"> </form> <?php } wp_reset_query(); ?> </div> <?php kriesi_pagination('', $range = 2); ?> </div><!-- end 8col container--> <?php // include(locate_template('sidebar.php')); ?> </div> <?php get_footer(); ?>
riddya85/rentail_upwrk
wp-content/themes/wprentals/search.php
PHP
gpl-2.0
1,879
<patTemplate:tmpl name="pageoutput" unusedvars="strip"> <h2 class="page-header">Local Events Settings</h2> <p>{_JRPORTAL_LOCAL_EVENTS_SETTINGS_RADIUS_DESC}</p> <form action="{JOMRES_SITEPAGE_URL_ADMIN}" method="post" name="adminForm" class="form-horizontal"> {JOMRESTOOLBAR} <div class="control-group"> <div class="control-label"> {_JRPORTAL_LOCAL_EVENTS_SETTINGS_RADIUS} </div> <div class="controls"> <input type="text" name="radius" value="{RADIUS}" class="input-medium"/> </div> </div> <input type="hidden" name="no_html" value="1" /> <input type="hidden" name="task" value="save_local_events_settings" /> </form> </patTemplate:tmpl>
parksandwildlife/parkstay
jomres/core-plugins/local_events/templates/bootstrap/admin_local_events.html
HTML
gpl-2.0
653
from distutils.core import setup setup( name='tinyfsm', version='0.1', packages=[''], url='https://github.com/tonyfunc/tinyfsm', license='GNU Library', author='tony', author_email='me@tonyfunc.com', description='A tiny implementation of Finite State Machine in Python.' )
tonyfunc/tinyfsm
setup.py
Python
gpl-2.0
305
#banner { height: 0px; background: none; } #legend li.externalLink { background: none; padding-right: 0px; } a.externalLink, a.externalLink:link, a.externalLink:visited, a.externalLink:active, a.externalLink:hover { background: none; padding-right: 0px; } #legend li.newWindow { background: none; padding-left: 0px; } a.newWindow, a.newWindow:link, a.newWindow:visited, a.newWindow:active, a.newWindow:hover { background: none; padding-right: 0px; } h3 { background-image: none; } #breadcrumbs { background: none; } .navcolumn h5 { background-image: none; } dt { background-image:none; } .errormark, .warningmark, .donemark, .infomark { background: none; }
stephenostermiller/ostermillerutils
src/site/resources/css/site.css
CSS
gpl-2.0
686
package cn.guoyukun.demo.cts.dao; import java.util.Map; import java.util.Map.Entry; import org.springframework.stereotype.Repository; @Repository public class DealerDao extends BaseDao{ private static final String _TABLE_NAME = "dealer"; private static final String _PK_NAME = "JXSDM"; @Override protected String getTableName() { return _TABLE_NAME; } @Override protected String getPKName() { return _PK_NAME; } public void add(Map <String,Object> info){ super.getJdbcTemplate().update("insert into dealer (" + "JXSDM," + "JXSMC," + "SYB," + "SHENG," + "SHI," + "QY," + "SFTY" + ") values(?,?,?,?,?,?,?)", info.get("JXSDM"), info.get("JXSMC"), info.get("SYB"), info.get("SHENG"), info.get("SHI"), info.get("QY"), info.get("SFTY") ); } public void edit(Map <String,Object> info){ super.getJdbcTemplate().update("update dealer set "+ "JXSMC=?,"+ "SYB=?,"+ "SHENG=?,"+ "SHI=?,"+ "QY=?,"+ "SFTY=?"+ " where JXSMC=?", info.get("JXSMC"), info.get("SYB"), info.get("SHENG"), info.get("SHI"), info.get("QY"), info.get("SFTY"), info.get("JXSDM") ); } }
gyk001/demo-cts
src/main/java/cn/guoyukun/demo/cts/dao/DealerDao.java
Java
gpl-2.0
1,189
/* * SuperH Ethernet device driver * * Copyright (C) 2006-2012 Nobuhiro Iwamatsu * Copyright (C) 2008-2012 Renesas Solutions Corp. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. * * The full GNU General Public License is included in this distribution in * the file called "COPYING". */ #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/dma-mapping.h> #include <linux/etherdevice.h> #include <linux/delay.h> #include <linux/platform_device.h> #include <linux/mdio-bitbang.h> #include <linux/netdevice.h> #include <linux/phy.h> #include <linux/cache.h> #include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/ethtool.h> #include <linux/if_vlan.h> #include <linux/clk.h> #include <linux/sh_eth.h> #include "sh_eth.h" #define SH_ETH_DEF_MSG_ENABLE \ (NETIF_MSG_LINK | \ NETIF_MSG_TIMER | \ NETIF_MSG_RX_ERR| \ NETIF_MSG_TX_ERR) /* There is CPU dependent code */ #if defined(CONFIG_CPU_SUBTYPE_SH7724) || defined(CONFIG_ARCH_R8A7779) #define SH_ETH_RESET_DEFAULT 1 static void sh_eth_set_duplex(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned int bits = ECMR_RTM; #if defined(CONFIG_ARCH_R8A7779) bits |= ECMR_ELB; #endif switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~bits, ECMR); break; case 100:/* 100BASE */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | bits, ECMR); break; default: break; } } /* SH7724 */ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .set_duplex = sh_eth_set_duplex, .set_rate = sh_eth_set_rate, .ecsr_value = ECSR_PSRTO | ECSR_LCHNG | ECSR_ICD, .ecsipr_value = ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | ECSIPR_ICDIP, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x01ff009f, .tx_check = EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO, .eesr_err_check = EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | EESR_ECI, .tx_error_check = EESR_TWB | EESR_TABT | EESR_TDE | EESR_TFE, .apr = 1, .mpr = 1, .tpauser = 1, .hw_swap = 1, .rpadir = 1, .rpadir_value = 0x00020000, /* NET_IP_ALIGN assumed to be 2 */ }; #elif defined(CONFIG_CPU_SUBTYPE_SH7757) #define SH_ETH_HAS_BOTH_MODULES 1 #define SH_ETH_HAS_TSU 1 static void sh_eth_set_duplex(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, 0, RTRATE); break; case 100:/* 100BASE */ sh_eth_write(ndev, 1, RTRATE); break; default: break; } } /* SH7757 */ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .set_duplex = sh_eth_set_duplex, .set_rate = sh_eth_set_rate, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .rmcr_value = 0x00000001, .tx_check = EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO, .eesr_err_check = EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | EESR_ECI, .tx_error_check = EESR_TWB | EESR_TABT | EESR_TDE | EESR_TFE, .apr = 1, .mpr = 1, .tpauser = 1, .hw_swap = 1, .no_ade = 1, .rpadir = 1, .rpadir_value = 2 << 16, }; #define SH_GIGA_ETH_BASE 0xfee00000 #define GIGA_MALR(port) (SH_GIGA_ETH_BASE + 0x800 * (port) + 0x05c8) #define GIGA_MAHR(port) (SH_GIGA_ETH_BASE + 0x800 * (port) + 0x05c0) static void sh_eth_chip_reset_giga(struct net_device *ndev) { int i; unsigned long mahr[2], malr[2]; /* save MAHR and MALR */ for (i = 0; i < 2; i++) { malr[i] = ioread32((void *)GIGA_MALR(i)); mahr[i] = ioread32((void *)GIGA_MAHR(i)); } /* reset device */ iowrite32(ARSTR_ARSTR, (void *)(SH_GIGA_ETH_BASE + 0x1800)); mdelay(1); /* restore MAHR and MALR */ for (i = 0; i < 2; i++) { iowrite32(malr[i], (void *)GIGA_MALR(i)); iowrite32(mahr[i], (void *)GIGA_MAHR(i)); } } static int sh_eth_is_gether(struct sh_eth_private *mdp); static void sh_eth_reset(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int cnt = 100; if (sh_eth_is_gether(mdp)) { sh_eth_write(ndev, 0x03, EDSR); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR); while (cnt > 0) { if (!(sh_eth_read(ndev, EDMR) & 0x3)) break; mdelay(1); cnt--; } if (cnt < 0) printk(KERN_ERR "Device reset fail\n"); /* Table Init */ sh_eth_write(ndev, 0x0, TDLAR); sh_eth_write(ndev, 0x0, TDFAR); sh_eth_write(ndev, 0x0, TDFXR); sh_eth_write(ndev, 0x0, TDFFR); sh_eth_write(ndev, 0x0, RDLAR); sh_eth_write(ndev, 0x0, RDFAR); sh_eth_write(ndev, 0x0, RDFXR); sh_eth_write(ndev, 0x0, RDFFR); } else { sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_ETHER, EDMR); mdelay(3); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) & ~EDMR_SRST_ETHER, EDMR); } } static void sh_eth_set_duplex_giga(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate_giga(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, 0x00000000, GECMR); break; case 100:/* 100BASE */ sh_eth_write(ndev, 0x00000010, GECMR); break; case 1000: /* 1000BASE */ sh_eth_write(ndev, 0x00000020, GECMR); break; default: break; } } /* SH7757(GETHERC) */ static struct sh_eth_cpu_data sh_eth_my_cpu_data_giga = { .chip_reset = sh_eth_chip_reset_giga, .set_duplex = sh_eth_set_duplex_giga, .set_rate = sh_eth_set_rate_giga, .ecsr_value = ECSR_ICD | ECSR_MPD, .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .tx_check = EESR_TC1 | EESR_FTC, .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | \ EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | \ EESR_ECI, .tx_error_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_TDE | \ EESR_TFE, .fdr_value = 0x0000072f, .rmcr_value = 0x00000001, .apr = 1, .mpr = 1, .tpauser = 1, .bculr = 1, .hw_swap = 1, .rpadir = 1, .rpadir_value = 2 << 16, .no_trimd = 1, .no_ade = 1, .tsu = 1, }; static struct sh_eth_cpu_data *sh_eth_get_cpu_data(struct sh_eth_private *mdp) { if (sh_eth_is_gether(mdp)) return &sh_eth_my_cpu_data_giga; else return &sh_eth_my_cpu_data; } #elif defined(CONFIG_CPU_SUBTYPE_SH7734) || defined(CONFIG_CPU_SUBTYPE_SH7763) #define SH_ETH_HAS_TSU 1 static void sh_eth_reset_hw_crc(struct net_device *ndev); static void sh_eth_chip_reset(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); /* reset device */ sh_eth_tsu_write(mdp, ARSTR_ARSTR, ARSTR); mdelay(1); } static void sh_eth_reset(struct net_device *ndev) { int cnt = 100; sh_eth_write(ndev, EDSR_ENALL, EDSR); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR); while (cnt > 0) { if (!(sh_eth_read(ndev, EDMR) & 0x3)) break; mdelay(1); cnt--; } if (cnt == 0) printk(KERN_ERR "Device reset fail\n"); /* Table Init */ sh_eth_write(ndev, 0x0, TDLAR); sh_eth_write(ndev, 0x0, TDFAR); sh_eth_write(ndev, 0x0, TDFXR); sh_eth_write(ndev, 0x0, TDFFR); sh_eth_write(ndev, 0x0, RDLAR); sh_eth_write(ndev, 0x0, RDFAR); sh_eth_write(ndev, 0x0, RDFXR); sh_eth_write(ndev, 0x0, RDFFR); /* Reset HW CRC register */ sh_eth_reset_hw_crc(ndev); } static void sh_eth_set_duplex(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, GECMR_10, GECMR); break; case 100:/* 100BASE */ sh_eth_write(ndev, GECMR_100, GECMR); break; case 1000: /* 1000BASE */ sh_eth_write(ndev, GECMR_1000, GECMR); break; default: break; } } /* sh7763 */ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .chip_reset = sh_eth_chip_reset, .set_duplex = sh_eth_set_duplex, .set_rate = sh_eth_set_rate, .ecsr_value = ECSR_ICD | ECSR_MPD, .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .tx_check = EESR_TC1 | EESR_FTC, .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | \ EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | \ EESR_ECI, .tx_error_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_TDE | \ EESR_TFE, .apr = 1, .mpr = 1, .tpauser = 1, .bculr = 1, .hw_swap = 1, .no_trimd = 1, .no_ade = 1, .tsu = 1, #if defined(CONFIG_CPU_SUBTYPE_SH7734) .hw_crc = 1, #endif }; static void sh_eth_reset_hw_crc(struct net_device *ndev) { if (sh_eth_my_cpu_data.hw_crc) sh_eth_write(ndev, 0x0, CSMR); } #elif defined(CONFIG_ARCH_R8A7740) #define SH_ETH_HAS_TSU 1 static void sh_eth_chip_reset(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned long mii; /* reset device */ sh_eth_tsu_write(mdp, ARSTR_ARSTR, ARSTR); mdelay(1); switch (mdp->phy_interface) { case PHY_INTERFACE_MODE_GMII: mii = 2; break; case PHY_INTERFACE_MODE_MII: mii = 1; break; case PHY_INTERFACE_MODE_RMII: default: mii = 0; break; } sh_eth_write(ndev, mii, RMII_MII); } static void sh_eth_reset(struct net_device *ndev) { int cnt = 100; sh_eth_write(ndev, EDSR_ENALL, EDSR); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR); while (cnt > 0) { if (!(sh_eth_read(ndev, EDMR) & 0x3)) break; mdelay(1); cnt--; } if (cnt == 0) printk(KERN_ERR "Device reset fail\n"); /* Table Init */ sh_eth_write(ndev, 0x0, TDLAR); sh_eth_write(ndev, 0x0, TDFAR); sh_eth_write(ndev, 0x0, TDFXR); sh_eth_write(ndev, 0x0, TDFFR); sh_eth_write(ndev, 0x0, RDLAR); sh_eth_write(ndev, 0x0, RDFAR); sh_eth_write(ndev, 0x0, RDFXR); sh_eth_write(ndev, 0x0, RDFFR); } static void sh_eth_set_duplex(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, GECMR_10, GECMR); break; case 100:/* 100BASE */ sh_eth_write(ndev, GECMR_100, GECMR); break; case 1000: /* 1000BASE */ sh_eth_write(ndev, GECMR_1000, GECMR); break; default: break; } } /* R8A7740 */ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .chip_reset = sh_eth_chip_reset, .set_duplex = sh_eth_set_duplex, .set_rate = sh_eth_set_rate, .ecsr_value = ECSR_ICD | ECSR_MPD, .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .tx_check = EESR_TC1 | EESR_FTC, .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | \ EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | \ EESR_ECI, .tx_error_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_TDE | \ EESR_TFE, .apr = 1, .mpr = 1, .tpauser = 1, .bculr = 1, .hw_swap = 1, .no_trimd = 1, .no_ade = 1, .tsu = 1, }; #elif defined(CONFIG_CPU_SUBTYPE_SH7619) #define SH_ETH_RESET_DEFAULT 1 static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .apr = 1, .mpr = 1, .tpauser = 1, .hw_swap = 1, }; #elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) #define SH_ETH_RESET_DEFAULT 1 #define SH_ETH_HAS_TSU 1 static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .tsu = 1, }; #endif static void sh_eth_set_default_cpu_data(struct sh_eth_cpu_data *cd) { if (!cd->ecsr_value) cd->ecsr_value = DEFAULT_ECSR_INIT; if (!cd->ecsipr_value) cd->ecsipr_value = DEFAULT_ECSIPR_INIT; if (!cd->fcftr_value) cd->fcftr_value = DEFAULT_FIFO_F_D_RFF | \ DEFAULT_FIFO_F_D_RFD; if (!cd->fdr_value) cd->fdr_value = DEFAULT_FDR_INIT; if (!cd->rmcr_value) cd->rmcr_value = DEFAULT_RMCR_VALUE; if (!cd->tx_check) cd->tx_check = DEFAULT_TX_CHECK; if (!cd->eesr_err_check) cd->eesr_err_check = DEFAULT_EESR_ERR_CHECK; if (!cd->tx_error_check) cd->tx_error_check = DEFAULT_TX_ERROR_CHECK; } #if defined(SH_ETH_RESET_DEFAULT) /* Chip Reset */ static void sh_eth_reset(struct net_device *ndev) { sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_ETHER, EDMR); mdelay(3); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) & ~EDMR_SRST_ETHER, EDMR); } #endif #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE) static void sh_eth_set_receive_align(struct sk_buff *skb) { int reserve; reserve = SH4_SKB_RX_ALIGN - ((u32)skb->data & (SH4_SKB_RX_ALIGN - 1)); if (reserve) skb_reserve(skb, reserve); } #else static void sh_eth_set_receive_align(struct sk_buff *skb) { skb_reserve(skb, SH2_SH3_SKB_RX_ALIGN); } #endif /* CPU <-> EDMAC endian convert */ static inline __u32 cpu_to_edmac(struct sh_eth_private *mdp, u32 x) { switch (mdp->edmac_endian) { case EDMAC_LITTLE_ENDIAN: return cpu_to_le32(x); case EDMAC_BIG_ENDIAN: return cpu_to_be32(x); } return x; } static inline __u32 edmac_to_cpu(struct sh_eth_private *mdp, u32 x) { switch (mdp->edmac_endian) { case EDMAC_LITTLE_ENDIAN: return le32_to_cpu(x); case EDMAC_BIG_ENDIAN: return be32_to_cpu(x); } return x; } /* * Program the hardware MAC address from dev->dev_addr. */ static void update_mac_address(struct net_device *ndev) { sh_eth_write(ndev, (ndev->dev_addr[0] << 24) | (ndev->dev_addr[1] << 16) | (ndev->dev_addr[2] << 8) | (ndev->dev_addr[3]), MAHR); sh_eth_write(ndev, (ndev->dev_addr[4] << 8) | (ndev->dev_addr[5]), MALR); } /* * Get MAC address from SuperH MAC address register * * SuperH's Ethernet device doesn't have 'ROM' to MAC address. * This driver get MAC address that use by bootloader(U-boot or sh-ipl+g). * When you want use this device, you must set MAC address in bootloader. * */ static void read_mac_address(struct net_device *ndev, unsigned char *mac) { if (mac[0] || mac[1] || mac[2] || mac[3] || mac[4] || mac[5]) { memcpy(ndev->dev_addr, mac, 6); } else { ndev->dev_addr[0] = (sh_eth_read(ndev, MAHR) >> 24); ndev->dev_addr[1] = (sh_eth_read(ndev, MAHR) >> 16) & 0xFF; ndev->dev_addr[2] = (sh_eth_read(ndev, MAHR) >> 8) & 0xFF; ndev->dev_addr[3] = (sh_eth_read(ndev, MAHR) & 0xFF); ndev->dev_addr[4] = (sh_eth_read(ndev, MALR) >> 8) & 0xFF; ndev->dev_addr[5] = (sh_eth_read(ndev, MALR) & 0xFF); } } static int sh_eth_is_gether(struct sh_eth_private *mdp) { if (mdp->reg_offset == sh_eth_offset_gigabit) return 1; else return 0; } static unsigned long sh_eth_get_edtrr_trns(struct sh_eth_private *mdp) { if (sh_eth_is_gether(mdp)) return EDTRR_TRNS_GETHER; else return EDTRR_TRNS_ETHER; } struct bb_info { void (*set_gate)(void *addr); struct mdiobb_ctrl ctrl; void *addr; u32 mmd_msk;/* MMD */ u32 mdo_msk; u32 mdi_msk; u32 mdc_msk; }; /* PHY bit set */ static void bb_set(void *addr, u32 msk) { iowrite32(ioread32(addr) | msk, addr); } /* PHY bit clear */ static void bb_clr(void *addr, u32 msk) { iowrite32((ioread32(addr) & ~msk), addr); } /* PHY bit read */ static int bb_read(void *addr, u32 msk) { return (ioread32(addr) & msk) != 0; } /* Data I/O pin control */ static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); if (bit) bb_set(bitbang->addr, bitbang->mmd_msk); else bb_clr(bitbang->addr, bitbang->mmd_msk); } /* Set bit data*/ static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); if (bit) bb_set(bitbang->addr, bitbang->mdo_msk); else bb_clr(bitbang->addr, bitbang->mdo_msk); } /* Get bit data*/ static int sh_get_mdio(struct mdiobb_ctrl *ctrl) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); return bb_read(bitbang->addr, bitbang->mdi_msk); } /* MDC pin control */ static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); if (bit) bb_set(bitbang->addr, bitbang->mdc_msk); else bb_clr(bitbang->addr, bitbang->mdc_msk); } /* mdio bus control struct */ static struct mdiobb_ops bb_ops = { .owner = THIS_MODULE, .set_mdc = sh_mdc_ctrl, .set_mdio_dir = sh_mmd_ctrl, .set_mdio_data = sh_set_mdio, .get_mdio_data = sh_get_mdio, }; /* free skb and descriptor buffer */ static void sh_eth_ring_free(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int i; /* Free Rx skb ringbuffer */ if (mdp->rx_skbuff) { for (i = 0; i < RX_RING_SIZE; i++) { if (mdp->rx_skbuff[i]) dev_kfree_skb(mdp->rx_skbuff[i]); } } kfree(mdp->rx_skbuff); /* Free Tx skb ringbuffer */ if (mdp->tx_skbuff) { for (i = 0; i < TX_RING_SIZE; i++) { if (mdp->tx_skbuff[i]) dev_kfree_skb(mdp->tx_skbuff[i]); } } kfree(mdp->tx_skbuff); } /* format skb and descriptor buffer */ static void sh_eth_ring_format(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int i; struct sk_buff *skb; struct sh_eth_rxdesc *rxdesc = NULL; struct sh_eth_txdesc *txdesc = NULL; int rx_ringsize = sizeof(*rxdesc) * RX_RING_SIZE; int tx_ringsize = sizeof(*txdesc) * TX_RING_SIZE; mdp->cur_rx = mdp->cur_tx = 0; mdp->dirty_rx = mdp->dirty_tx = 0; memset(mdp->rx_ring, 0, rx_ringsize); /* build Rx ring buffer */ for (i = 0; i < RX_RING_SIZE; i++) { /* skb */ mdp->rx_skbuff[i] = NULL; skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz); mdp->rx_skbuff[i] = skb; if (skb == NULL) break; dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, DMA_FROM_DEVICE); sh_eth_set_receive_align(skb); /* RX descriptor */ rxdesc = &mdp->rx_ring[i]; rxdesc->addr = virt_to_phys(PTR_ALIGN(skb->data, 4)); rxdesc->status = cpu_to_edmac(mdp, RD_RACT | RD_RFP); /* The size of the buffer is 16 byte boundary. */ rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); /* Rx descriptor address set */ if (i == 0) { sh_eth_write(ndev, mdp->rx_desc_dma, RDLAR); if (sh_eth_is_gether(mdp)) sh_eth_write(ndev, mdp->rx_desc_dma, RDFAR); } } mdp->dirty_rx = (u32) (i - RX_RING_SIZE); /* Mark the last entry as wrapping the ring. */ rxdesc->status |= cpu_to_edmac(mdp, RD_RDEL); memset(mdp->tx_ring, 0, tx_ringsize); /* build Tx ring buffer */ for (i = 0; i < TX_RING_SIZE; i++) { mdp->tx_skbuff[i] = NULL; txdesc = &mdp->tx_ring[i]; txdesc->status = cpu_to_edmac(mdp, TD_TFP); txdesc->buffer_length = 0; if (i == 0) { /* Tx descriptor address set */ sh_eth_write(ndev, mdp->tx_desc_dma, TDLAR); if (sh_eth_is_gether(mdp)) sh_eth_write(ndev, mdp->tx_desc_dma, TDFAR); } } txdesc->status |= cpu_to_edmac(mdp, TD_TDLE); } /* Get skb and descriptor buffer */ static int sh_eth_ring_init(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int rx_ringsize, tx_ringsize, ret = 0; /* * +26 gets the maximum ethernet encapsulation, +7 & ~7 because the * card needs room to do 8 byte alignment, +2 so we can reserve * the first 2 bytes, and +16 gets room for the status word from the * card. */ mdp->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ : (((ndev->mtu + 26 + 7) & ~7) + 2 + 16)); if (mdp->cd->rpadir) mdp->rx_buf_sz += NET_IP_ALIGN; /* Allocate RX and TX skb rings */ mdp->rx_skbuff = kmalloc(sizeof(*mdp->rx_skbuff) * RX_RING_SIZE, GFP_KERNEL); if (!mdp->rx_skbuff) { dev_err(&ndev->dev, "Cannot allocate Rx skb\n"); ret = -ENOMEM; return ret; } mdp->tx_skbuff = kmalloc(sizeof(*mdp->tx_skbuff) * TX_RING_SIZE, GFP_KERNEL); if (!mdp->tx_skbuff) { dev_err(&ndev->dev, "Cannot allocate Tx skb\n"); ret = -ENOMEM; goto skb_ring_free; } /* Allocate all Rx descriptors. */ rx_ringsize = sizeof(struct sh_eth_rxdesc) * RX_RING_SIZE; mdp->rx_ring = dma_alloc_coherent(NULL, rx_ringsize, &mdp->rx_desc_dma, GFP_KERNEL); if (!mdp->rx_ring) { dev_err(&ndev->dev, "Cannot allocate Rx Ring (size %d bytes)\n", rx_ringsize); ret = -ENOMEM; goto desc_ring_free; } mdp->dirty_rx = 0; /* Allocate all Tx descriptors. */ tx_ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE; mdp->tx_ring = dma_alloc_coherent(NULL, tx_ringsize, &mdp->tx_desc_dma, GFP_KERNEL); if (!mdp->tx_ring) { dev_err(&ndev->dev, "Cannot allocate Tx Ring (size %d bytes)\n", tx_ringsize); ret = -ENOMEM; goto desc_ring_free; } return ret; desc_ring_free: /* free DMA buffer */ dma_free_coherent(NULL, rx_ringsize, mdp->rx_ring, mdp->rx_desc_dma); skb_ring_free: /* Free Rx and Tx skb ring buffer */ sh_eth_ring_free(ndev); return ret; } static int sh_eth_dev_init(struct net_device *ndev) { int ret = 0; struct sh_eth_private *mdp = netdev_priv(ndev); u_int32_t rx_int_var, tx_int_var; u32 val; /* Soft Reset */ sh_eth_reset(ndev); /* Descriptor format */ sh_eth_ring_format(ndev); if (mdp->cd->rpadir) sh_eth_write(ndev, mdp->cd->rpadir_value, RPADIR); /* all sh_eth int mask */ sh_eth_write(ndev, 0, EESIPR); #if defined(__LITTLE_ENDIAN) if (mdp->cd->hw_swap) sh_eth_write(ndev, EDMR_EL, EDMR); else #endif sh_eth_write(ndev, 0, EDMR); /* FIFO size set */ sh_eth_write(ndev, mdp->cd->fdr_value, FDR); sh_eth_write(ndev, 0, TFTR); /* Frame recv control */ sh_eth_write(ndev, mdp->cd->rmcr_value, RMCR); rx_int_var = mdp->rx_int_var = DESC_I_RINT8 | DESC_I_RINT5; tx_int_var = mdp->tx_int_var = DESC_I_TINT2; sh_eth_write(ndev, rx_int_var | tx_int_var, TRSCER); if (mdp->cd->bculr) sh_eth_write(ndev, 0x800, BCULR); /* Burst sycle set */ sh_eth_write(ndev, mdp->cd->fcftr_value, FCFTR); if (!mdp->cd->no_trimd) sh_eth_write(ndev, 0, TRIMD); /* Recv frame limit set register */ sh_eth_write(ndev, ndev->mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN, RFLR); sh_eth_write(ndev, sh_eth_read(ndev, EESR), EESR); sh_eth_write(ndev, mdp->cd->eesipr_value, EESIPR); /* PAUSE Prohibition */ val = (sh_eth_read(ndev, ECMR) & ECMR_DM) | ECMR_ZPF | (mdp->duplex ? ECMR_DM : 0) | ECMR_TE | ECMR_RE; sh_eth_write(ndev, val, ECMR); if (mdp->cd->set_rate) mdp->cd->set_rate(ndev); /* E-MAC Status Register clear */ sh_eth_write(ndev, mdp->cd->ecsr_value, ECSR); /* E-MAC Interrupt Enable register */ sh_eth_write(ndev, mdp->cd->ecsipr_value, ECSIPR); /* Set MAC address */ update_mac_address(ndev); /* mask reset */ if (mdp->cd->apr) sh_eth_write(ndev, APR_AP, APR); if (mdp->cd->mpr) sh_eth_write(ndev, MPR_MP, MPR); if (mdp->cd->tpauser) sh_eth_write(ndev, TPAUSER_UNLIMITED, TPAUSER); /* Setting the Rx mode will start the Rx process. */ sh_eth_write(ndev, EDRRR_R, EDRRR); netif_start_queue(ndev); return ret; } /* free Tx skb function */ static int sh_eth_txfree(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_txdesc *txdesc; int freeNum = 0; int entry = 0; for (; mdp->cur_tx - mdp->dirty_tx > 0; mdp->dirty_tx++) { entry = mdp->dirty_tx % TX_RING_SIZE; txdesc = &mdp->tx_ring[entry]; if (txdesc->status & cpu_to_edmac(mdp, TD_TACT)) break; /* Free the original skb. */ if (mdp->tx_skbuff[entry]) { dma_unmap_single(&ndev->dev, txdesc->addr, txdesc->buffer_length, DMA_TO_DEVICE); dev_kfree_skb_irq(mdp->tx_skbuff[entry]); mdp->tx_skbuff[entry] = NULL; freeNum++; } txdesc->status = cpu_to_edmac(mdp, TD_TFP); if (entry >= TX_RING_SIZE - 1) txdesc->status |= cpu_to_edmac(mdp, TD_TDLE); ndev->stats.tx_packets++; ndev->stats.tx_bytes += txdesc->buffer_length; } return freeNum; } /* Packet receive function */ static int sh_eth_rx(struct net_device *ndev, u32 intr_status) { struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_rxdesc *rxdesc; int entry = mdp->cur_rx % RX_RING_SIZE; int boguscnt = (mdp->dirty_rx + RX_RING_SIZE) - mdp->cur_rx; struct sk_buff *skb; u16 pkt_len = 0; u32 desc_status; rxdesc = &mdp->rx_ring[entry]; while (!(rxdesc->status & cpu_to_edmac(mdp, RD_RACT))) { desc_status = edmac_to_cpu(mdp, rxdesc->status); pkt_len = rxdesc->frame_length; #if defined(CONFIG_ARCH_R8A7740) desc_status >>= 16; #endif if (--boguscnt < 0) break; if (!(desc_status & RDFEND)) ndev->stats.rx_length_errors++; if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 | RD_RFS5 | RD_RFS6 | RD_RFS10)) { ndev->stats.rx_errors++; if (desc_status & RD_RFS1) ndev->stats.rx_crc_errors++; if (desc_status & RD_RFS2) ndev->stats.rx_frame_errors++; if (desc_status & RD_RFS3) ndev->stats.rx_length_errors++; if (desc_status & RD_RFS4) ndev->stats.rx_length_errors++; if (desc_status & RD_RFS6) ndev->stats.rx_missed_errors++; if (desc_status & RD_RFS10) ndev->stats.rx_over_errors++; } else { if (!mdp->cd->hw_swap) sh_eth_soft_swap( phys_to_virt(ALIGN(rxdesc->addr, 4)), pkt_len + 2); skb = mdp->rx_skbuff[entry]; mdp->rx_skbuff[entry] = NULL; if (mdp->cd->rpadir) skb_reserve(skb, NET_IP_ALIGN); skb_put(skb, pkt_len); skb->protocol = eth_type_trans(skb, ndev); netif_rx(skb); ndev->stats.rx_packets++; ndev->stats.rx_bytes += pkt_len; } rxdesc->status |= cpu_to_edmac(mdp, RD_RACT); entry = (++mdp->cur_rx) % RX_RING_SIZE; rxdesc = &mdp->rx_ring[entry]; } /* Refill the Rx ring buffers. */ for (; mdp->cur_rx - mdp->dirty_rx > 0; mdp->dirty_rx++) { entry = mdp->dirty_rx % RX_RING_SIZE; rxdesc = &mdp->rx_ring[entry]; /* The size of the buffer is 16 byte boundary. */ rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); if (mdp->rx_skbuff[entry] == NULL) { skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz); mdp->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, DMA_FROM_DEVICE); sh_eth_set_receive_align(skb); skb_checksum_none_assert(skb); rxdesc->addr = virt_to_phys(PTR_ALIGN(skb->data, 4)); } if (entry >= RX_RING_SIZE - 1) rxdesc->status |= cpu_to_edmac(mdp, RD_RACT | RD_RFP | RD_RDEL); else rxdesc->status |= cpu_to_edmac(mdp, RD_RACT | RD_RFP); } /* Restart Rx engine if stopped. */ /* If we don't need to check status, don't. -KDU */ if (!(sh_eth_read(ndev, EDRRR) & EDRRR_R)) { /* fix the values for the next receiving if RDE is set */ if (intr_status & EESR_RDE) mdp->cur_rx = mdp->dirty_rx = (sh_eth_read(ndev, RDFAR) - sh_eth_read(ndev, RDLAR)) >> 4; sh_eth_write(ndev, EDRRR_R, EDRRR); } return 0; } static void sh_eth_rcv_snd_disable(struct net_device *ndev) { /* disable tx and rx */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~(ECMR_RE | ECMR_TE), ECMR); } static void sh_eth_rcv_snd_enable(struct net_device *ndev) { /* enable tx and rx */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | (ECMR_RE | ECMR_TE), ECMR); } /* error control function */ static void sh_eth_error(struct net_device *ndev, int intr_status) { struct sh_eth_private *mdp = netdev_priv(ndev); u32 felic_stat; u32 link_stat; u32 mask; if (intr_status & EESR_ECI) { felic_stat = sh_eth_read(ndev, ECSR); sh_eth_write(ndev, felic_stat, ECSR); /* clear int */ if (felic_stat & ECSR_ICD) ndev->stats.tx_carrier_errors++; if (felic_stat & ECSR_LCHNG) { /* Link Changed */ if (mdp->cd->no_psr || mdp->no_ether_link) { if (mdp->link == PHY_DOWN) link_stat = 0; else link_stat = PHY_ST_LINK; } else { link_stat = (sh_eth_read(ndev, PSR)); if (mdp->ether_link_active_low) link_stat = ~link_stat; } if (!(link_stat & PHY_ST_LINK)) sh_eth_rcv_snd_disable(ndev); else { /* Link Up */ sh_eth_write(ndev, sh_eth_read(ndev, EESIPR) & ~DMAC_M_ECI, EESIPR); /*clear int */ sh_eth_write(ndev, sh_eth_read(ndev, ECSR), ECSR); sh_eth_write(ndev, sh_eth_read(ndev, EESIPR) | DMAC_M_ECI, EESIPR); /* enable tx and rx */ sh_eth_rcv_snd_enable(ndev); } } } if (intr_status & EESR_TWB) { /* Write buck end. unused write back interrupt */ if (intr_status & EESR_TABT) /* Transmit Abort int */ ndev->stats.tx_aborted_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit Abort\n"); } if (intr_status & EESR_RABT) { /* Receive Abort int */ if (intr_status & EESR_RFRMER) { /* Receive Frame Overflow int */ ndev->stats.rx_frame_errors++; if (netif_msg_rx_err(mdp)) dev_err(&ndev->dev, "Receive Abort\n"); } } if (intr_status & EESR_TDE) { /* Transmit Descriptor Empty int */ ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit Descriptor Empty\n"); } if (intr_status & EESR_TFE) { /* FIFO under flow */ ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit FIFO Under flow\n"); } if (intr_status & EESR_RDE) { /* Receive Descriptor Empty int */ ndev->stats.rx_over_errors++; if (netif_msg_rx_err(mdp)) dev_err(&ndev->dev, "Receive Descriptor Empty\n"); } if (intr_status & EESR_RFE) { /* Receive FIFO Overflow int */ ndev->stats.rx_fifo_errors++; if (netif_msg_rx_err(mdp)) dev_err(&ndev->dev, "Receive FIFO Overflow\n"); } if (!mdp->cd->no_ade && (intr_status & EESR_ADE)) { /* Address Error */ ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Address Error\n"); } mask = EESR_TWB | EESR_TABT | EESR_ADE | EESR_TDE | EESR_TFE; if (mdp->cd->no_ade) mask &= ~EESR_ADE; if (intr_status & mask) { /* Tx error */ u32 edtrr = sh_eth_read(ndev, EDTRR); /* dmesg */ dev_err(&ndev->dev, "TX error. status=%8.8x cur_tx=%8.8x ", intr_status, mdp->cur_tx); dev_err(&ndev->dev, "dirty_tx=%8.8x state=%8.8x EDTRR=%8.8x.\n", mdp->dirty_tx, (u32) ndev->state, edtrr); /* dirty buffer free */ sh_eth_txfree(ndev); /* SH7712 BUG */ if (edtrr ^ sh_eth_get_edtrr_trns(mdp)) { /* tx dma start */ sh_eth_write(ndev, sh_eth_get_edtrr_trns(mdp), EDTRR); } /* wakeup */ netif_wake_queue(ndev); } } static irqreturn_t sh_eth_interrupt(int irq, void *netdev) { struct net_device *ndev = netdev; struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_cpu_data *cd = mdp->cd; irqreturn_t ret = IRQ_NONE; u32 intr_status = 0; spin_lock(&mdp->lock); /* Get interrpt stat */ intr_status = sh_eth_read(ndev, EESR); /* Clear interrupt */ if (intr_status & (EESR_FRC | EESR_RMAF | EESR_RRF | EESR_RTLF | EESR_RTSF | EESR_PRE | EESR_CERF | cd->tx_check | cd->eesr_err_check)) { sh_eth_write(ndev, intr_status, EESR); ret = IRQ_HANDLED; } else goto other_irq; if (intr_status & (EESR_FRC | /* Frame recv*/ EESR_RMAF | /* Multi cast address recv*/ EESR_RRF | /* Bit frame recv */ EESR_RTLF | /* Long frame recv*/ EESR_RTSF | /* short frame recv */ EESR_PRE | /* PHY-LSI recv error */ EESR_CERF)){ /* recv frame CRC error */ sh_eth_rx(ndev, intr_status); } /* Tx Check */ if (intr_status & cd->tx_check) { sh_eth_txfree(ndev); netif_wake_queue(ndev); } if (intr_status & cd->eesr_err_check) sh_eth_error(ndev, intr_status); other_irq: spin_unlock(&mdp->lock); return ret; } static void sh_eth_timer(unsigned long data) { struct net_device *ndev = (struct net_device *)data; struct sh_eth_private *mdp = netdev_priv(ndev); mod_timer(&mdp->timer, jiffies + (10 * HZ)); } /* PHY state control function */ static void sh_eth_adjust_link(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct phy_device *phydev = mdp->phydev; int new_state = 0; if (phydev->link != PHY_DOWN) { if (phydev->duplex != mdp->duplex) { new_state = 1; mdp->duplex = phydev->duplex; if (mdp->cd->set_duplex) mdp->cd->set_duplex(ndev); } if (phydev->speed != mdp->speed) { new_state = 1; mdp->speed = phydev->speed; if (mdp->cd->set_rate) mdp->cd->set_rate(ndev); } if (mdp->link == PHY_DOWN) { sh_eth_write(ndev, (sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR); new_state = 1; mdp->link = phydev->link; } } else if (mdp->link) { new_state = 1; mdp->link = PHY_DOWN; mdp->speed = 0; mdp->duplex = -1; } if (new_state && netif_msg_link(mdp)) phy_print_status(phydev); } /* PHY init function */ static int sh_eth_phy_init(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); char phy_id[MII_BUS_ID_SIZE + 3]; struct phy_device *phydev = NULL; snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, mdp->mii_bus->id , mdp->phy_id); mdp->link = PHY_DOWN; mdp->speed = 0; mdp->duplex = -1; /* Try connect to PHY */ phydev = phy_connect(ndev, phy_id, sh_eth_adjust_link, 0, mdp->phy_interface); if (IS_ERR(phydev)) { dev_err(&ndev->dev, "phy_connect failed\n"); return PTR_ERR(phydev); } dev_info(&ndev->dev, "attached phy %i to driver %s\n", phydev->addr, phydev->drv->name); mdp->phydev = phydev; return 0; } /* PHY control start function */ static int sh_eth_phy_start(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int ret; ret = sh_eth_phy_init(ndev); if (ret) return ret; /* reset phy - this also wakes it from PDOWN */ phy_write(mdp->phydev, MII_BMCR, BMCR_RESET); phy_start(mdp->phydev); return 0; } static int sh_eth_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned long flags; int ret; spin_lock_irqsave(&mdp->lock, flags); ret = phy_ethtool_gset(mdp->phydev, ecmd); spin_unlock_irqrestore(&mdp->lock, flags); return ret; } static int sh_eth_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned long flags; int ret; spin_lock_irqsave(&mdp->lock, flags); /* disable tx and rx */ sh_eth_rcv_snd_disable(ndev); ret = phy_ethtool_sset(mdp->phydev, ecmd); if (ret) goto error_exit; if (ecmd->duplex == DUPLEX_FULL) mdp->duplex = 1; else mdp->duplex = 0; if (mdp->cd->set_duplex) mdp->cd->set_duplex(ndev); error_exit: mdelay(1); /* enable tx and rx */ sh_eth_rcv_snd_enable(ndev); spin_unlock_irqrestore(&mdp->lock, flags); return ret; } static int sh_eth_nway_reset(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned long flags; int ret; spin_lock_irqsave(&mdp->lock, flags); ret = phy_start_aneg(mdp->phydev); spin_unlock_irqrestore(&mdp->lock, flags); return ret; } static u32 sh_eth_get_msglevel(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); return mdp->msg_enable; } static void sh_eth_set_msglevel(struct net_device *ndev, u32 value) { struct sh_eth_private *mdp = netdev_priv(ndev); mdp->msg_enable = value; } static const char sh_eth_gstrings_stats[][ETH_GSTRING_LEN] = { "rx_current", "tx_current", "rx_dirty", "tx_dirty", }; #define SH_ETH_STATS_LEN ARRAY_SIZE(sh_eth_gstrings_stats) static int sh_eth_get_sset_count(struct net_device *netdev, int sset) { switch (sset) { case ETH_SS_STATS: return SH_ETH_STATS_LEN; default: return -EOPNOTSUPP; } } static void sh_eth_get_ethtool_stats(struct net_device *ndev, struct ethtool_stats *stats, u64 *data) { struct sh_eth_private *mdp = netdev_priv(ndev); int i = 0; /* device-specific stats */ data[i++] = mdp->cur_rx; data[i++] = mdp->cur_tx; data[i++] = mdp->dirty_rx; data[i++] = mdp->dirty_tx; } static void sh_eth_get_strings(struct net_device *ndev, u32 stringset, u8 *data) { switch (stringset) { case ETH_SS_STATS: memcpy(data, *sh_eth_gstrings_stats, sizeof(sh_eth_gstrings_stats)); break; } } static const struct ethtool_ops sh_eth_ethtool_ops = { .get_settings = sh_eth_get_settings, .set_settings = sh_eth_set_settings, .nway_reset = sh_eth_nway_reset, .get_msglevel = sh_eth_get_msglevel, .set_msglevel = sh_eth_set_msglevel, .get_link = ethtool_op_get_link, .get_strings = sh_eth_get_strings, .get_ethtool_stats = sh_eth_get_ethtool_stats, .get_sset_count = sh_eth_get_sset_count, }; /* network device open function */ static int sh_eth_open(struct net_device *ndev) { int ret = 0; struct sh_eth_private *mdp = netdev_priv(ndev); pm_runtime_get_sync(&mdp->pdev->dev); ret = request_irq(ndev->irq, sh_eth_interrupt, #if defined(CONFIG_CPU_SUBTYPE_SH7763) || \ defined(CONFIG_CPU_SUBTYPE_SH7764) || \ defined(CONFIG_CPU_SUBTYPE_SH7757) IRQF_SHARED, #else 0, #endif ndev->name, ndev); if (ret) { dev_err(&ndev->dev, "Can not assign IRQ number\n"); return ret; } /* Descriptor set */ ret = sh_eth_ring_init(ndev); if (ret) goto out_free_irq; /* device init */ ret = sh_eth_dev_init(ndev); if (ret) goto out_free_irq; /* PHY control start*/ ret = sh_eth_phy_start(ndev); if (ret) goto out_free_irq; /* Set the timer to check for link beat. */ init_timer(&mdp->timer); mdp->timer.expires = (jiffies + (24 * HZ)) / 10;/* 2.4 sec. */ setup_timer(&mdp->timer, sh_eth_timer, (unsigned long)ndev); return ret; out_free_irq: free_irq(ndev->irq, ndev); pm_runtime_put_sync(&mdp->pdev->dev); return ret; } /* Timeout function */ static void sh_eth_tx_timeout(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_rxdesc *rxdesc; int i; netif_stop_queue(ndev); if (netif_msg_timer(mdp)) dev_err(&ndev->dev, "%s: transmit timed out, status %8.8x," " resetting...\n", ndev->name, (int)sh_eth_read(ndev, EESR)); /* tx_errors count up */ ndev->stats.tx_errors++; /* timer off */ del_timer_sync(&mdp->timer); /* Free all the skbuffs in the Rx queue. */ for (i = 0; i < RX_RING_SIZE; i++) { rxdesc = &mdp->rx_ring[i]; rxdesc->status = 0; rxdesc->addr = 0xBADF00D0; if (mdp->rx_skbuff[i]) dev_kfree_skb(mdp->rx_skbuff[i]); mdp->rx_skbuff[i] = NULL; } for (i = 0; i < TX_RING_SIZE; i++) { if (mdp->tx_skbuff[i]) dev_kfree_skb(mdp->tx_skbuff[i]); mdp->tx_skbuff[i] = NULL; } /* device init */ sh_eth_dev_init(ndev); /* timer on */ mdp->timer.expires = (jiffies + (24 * HZ)) / 10;/* 2.4 sec. */ add_timer(&mdp->timer); } /* Packet transmit function */ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_txdesc *txdesc; u32 entry; unsigned long flags; spin_lock_irqsave(&mdp->lock, flags); if ((mdp->cur_tx - mdp->dirty_tx) >= (TX_RING_SIZE - 4)) { if (!sh_eth_txfree(ndev)) { if (netif_msg_tx_queued(mdp)) dev_warn(&ndev->dev, "TxFD exhausted.\n"); netif_stop_queue(ndev); spin_unlock_irqrestore(&mdp->lock, flags); return NETDEV_TX_BUSY; } } spin_unlock_irqrestore(&mdp->lock, flags); entry = mdp->cur_tx % TX_RING_SIZE; mdp->tx_skbuff[entry] = skb; txdesc = &mdp->tx_ring[entry]; /* soft swap. */ if (!mdp->cd->hw_swap) sh_eth_soft_swap(phys_to_virt(ALIGN(txdesc->addr, 4)), skb->len + 2); txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len, DMA_TO_DEVICE); if (skb->len < ETHERSMALL) txdesc->buffer_length = ETHERSMALL; else txdesc->buffer_length = skb->len; if (entry >= TX_RING_SIZE - 1) txdesc->status |= cpu_to_edmac(mdp, TD_TACT | TD_TDLE); else txdesc->status |= cpu_to_edmac(mdp, TD_TACT); mdp->cur_tx++; if (!(sh_eth_read(ndev, EDTRR) & sh_eth_get_edtrr_trns(mdp))) sh_eth_write(ndev, sh_eth_get_edtrr_trns(mdp), EDTRR); return NETDEV_TX_OK; } /* device close function */ static int sh_eth_close(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int ringsize; netif_stop_queue(ndev); /* Disable interrupts by clearing the interrupt mask. */ sh_eth_write(ndev, 0x0000, EESIPR); /* Stop the chip's Tx and Rx processes. */ sh_eth_write(ndev, 0, EDTRR); sh_eth_write(ndev, 0, EDRRR); /* PHY Disconnect */ if (mdp->phydev) { phy_stop(mdp->phydev); phy_disconnect(mdp->phydev); } free_irq(ndev->irq, ndev); del_timer_sync(&mdp->timer); /* Free all the skbuffs in the Rx queue. */ sh_eth_ring_free(ndev); /* free DMA buffer */ ringsize = sizeof(struct sh_eth_rxdesc) * RX_RING_SIZE; dma_free_coherent(NULL, ringsize, mdp->rx_ring, mdp->rx_desc_dma); /* free DMA buffer */ ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE; dma_free_coherent(NULL, ringsize, mdp->tx_ring, mdp->tx_desc_dma); pm_runtime_put_sync(&mdp->pdev->dev); return 0; } static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); pm_runtime_get_sync(&mdp->pdev->dev); ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR); sh_eth_write(ndev, 0, TROCR); /* (write clear) */ ndev->stats.collisions += sh_eth_read(ndev, CDCR); sh_eth_write(ndev, 0, CDCR); /* (write clear) */ ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR); sh_eth_write(ndev, 0, LCCR); /* (write clear) */ if (sh_eth_is_gether(mdp)) { ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR); sh_eth_write(ndev, 0, CERCR); /* (write clear) */ ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR); sh_eth_write(ndev, 0, CEECR); /* (write clear) */ } else { ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR); sh_eth_write(ndev, 0, CNDCR); /* (write clear) */ } pm_runtime_put_sync(&mdp->pdev->dev); return &ndev->stats; } /* ioctl to device function */ static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) { struct sh_eth_private *mdp = netdev_priv(ndev); struct phy_device *phydev = mdp->phydev; if (!netif_running(ndev)) return -EINVAL; if (!phydev) return -ENODEV; return phy_mii_ioctl(phydev, rq, cmd); } #if defined(SH_ETH_HAS_TSU) /* For TSU_POSTn. Please refer to the manual about this (strange) bitfields */ static void *sh_eth_tsu_get_post_reg_offset(struct sh_eth_private *mdp, int entry) { return sh_eth_tsu_get_offset(mdp, TSU_POST1) + (entry / 8 * 4); } static u32 sh_eth_tsu_get_post_mask(int entry) { return 0x0f << (28 - ((entry % 8) * 4)); } static u32 sh_eth_tsu_get_post_bit(struct sh_eth_private *mdp, int entry) { return (0x08 >> (mdp->port << 1)) << (28 - ((entry % 8) * 4)); } static void sh_eth_tsu_enable_cam_entry_post(struct net_device *ndev, int entry) { struct sh_eth_private *mdp = netdev_priv(ndev); u32 tmp; void *reg_offset; reg_offset = sh_eth_tsu_get_post_reg_offset(mdp, entry); tmp = ioread32(reg_offset); iowrite32(tmp | sh_eth_tsu_get_post_bit(mdp, entry), reg_offset); } static bool sh_eth_tsu_disable_cam_entry_post(struct net_device *ndev, int entry) { struct sh_eth_private *mdp = netdev_priv(ndev); u32 post_mask, ref_mask, tmp; void *reg_offset; reg_offset = sh_eth_tsu_get_post_reg_offset(mdp, entry); post_mask = sh_eth_tsu_get_post_mask(entry); ref_mask = sh_eth_tsu_get_post_bit(mdp, entry) & ~post_mask; tmp = ioread32(reg_offset); iowrite32(tmp & ~post_mask, reg_offset); /* If other port enables, the function returns "true" */ return tmp & ref_mask; } static int sh_eth_tsu_busy(struct net_device *ndev) { int timeout = SH_ETH_TSU_TIMEOUT_MS * 100; struct sh_eth_private *mdp = netdev_priv(ndev); while ((sh_eth_tsu_read(mdp, TSU_ADSBSY) & TSU_ADSBSY_0)) { udelay(10); timeout--; if (timeout <= 0) { dev_err(&ndev->dev, "%s: timeout\n", __func__); return -ETIMEDOUT; } } return 0; } static int sh_eth_tsu_write_entry(struct net_device *ndev, void *reg, const u8 *addr) { u32 val; val = addr[0] << 24 | addr[1] << 16 | addr[2] << 8 | addr[3]; iowrite32(val, reg); if (sh_eth_tsu_busy(ndev) < 0) return -EBUSY; val = addr[4] << 8 | addr[5]; iowrite32(val, reg + 4); if (sh_eth_tsu_busy(ndev) < 0) return -EBUSY; return 0; } static void sh_eth_tsu_read_entry(void *reg, u8 *addr) { u32 val; val = ioread32(reg); addr[0] = (val >> 24) & 0xff; addr[1] = (val >> 16) & 0xff; addr[2] = (val >> 8) & 0xff; addr[3] = val & 0xff; val = ioread32(reg + 4); addr[4] = (val >> 8) & 0xff; addr[5] = val & 0xff; } static int sh_eth_tsu_find_entry(struct net_device *ndev, const u8 *addr) { struct sh_eth_private *mdp = netdev_priv(ndev); void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); int i; u8 c_addr[ETH_ALEN]; for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++, reg_offset += 8) { sh_eth_tsu_read_entry(reg_offset, c_addr); if (memcmp(addr, c_addr, ETH_ALEN) == 0) return i; } return -ENOENT; } static int sh_eth_tsu_find_empty(struct net_device *ndev) { u8 blank[ETH_ALEN]; int entry; memset(blank, 0, sizeof(blank)); entry = sh_eth_tsu_find_entry(ndev, blank); return (entry < 0) ? -ENOMEM : entry; } static int sh_eth_tsu_disable_cam_entry_table(struct net_device *ndev, int entry) { struct sh_eth_private *mdp = netdev_priv(ndev); void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); int ret; u8 blank[ETH_ALEN]; sh_eth_tsu_write(mdp, sh_eth_tsu_read(mdp, TSU_TEN) & ~(1 << (31 - entry)), TSU_TEN); memset(blank, 0, sizeof(blank)); ret = sh_eth_tsu_write_entry(ndev, reg_offset + entry * 8, blank); if (ret < 0) return ret; return 0; } static int sh_eth_tsu_add_entry(struct net_device *ndev, const u8 *addr) { struct sh_eth_private *mdp = netdev_priv(ndev); void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); int i, ret; if (!mdp->cd->tsu) return 0; i = sh_eth_tsu_find_entry(ndev, addr); if (i < 0) { /* No entry found, create one */ i = sh_eth_tsu_find_empty(ndev); if (i < 0) return -ENOMEM; ret = sh_eth_tsu_write_entry(ndev, reg_offset + i * 8, addr); if (ret < 0) return ret; /* Enable the entry */ sh_eth_tsu_write(mdp, sh_eth_tsu_read(mdp, TSU_TEN) | (1 << (31 - i)), TSU_TEN); } /* Entry found or created, enable POST */ sh_eth_tsu_enable_cam_entry_post(ndev, i); return 0; } static int sh_eth_tsu_del_entry(struct net_device *ndev, const u8 *addr) { struct sh_eth_private *mdp = netdev_priv(ndev); int i, ret; if (!mdp->cd->tsu) return 0; i = sh_eth_tsu_find_entry(ndev, addr); if (i) { /* Entry found */ if (sh_eth_tsu_disable_cam_entry_post(ndev, i)) goto done; /* Disable the entry if both ports was disabled */ ret = sh_eth_tsu_disable_cam_entry_table(ndev, i); if (ret < 0) return ret; } done: return 0; } static int sh_eth_tsu_purge_all(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int i, ret; if (unlikely(!mdp->cd->tsu)) return 0; for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++) { if (sh_eth_tsu_disable_cam_entry_post(ndev, i)) continue; /* Disable the entry if both ports was disabled */ ret = sh_eth_tsu_disable_cam_entry_table(ndev, i); if (ret < 0) return ret; } return 0; } static void sh_eth_tsu_purge_mcast(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); u8 addr[ETH_ALEN]; void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); int i; if (unlikely(!mdp->cd->tsu)) return; for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++, reg_offset += 8) { sh_eth_tsu_read_entry(reg_offset, addr); if (is_multicast_ether_addr(addr)) sh_eth_tsu_del_entry(ndev, addr); } } /* Multicast reception directions set */ static void sh_eth_set_multicast_list(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); u32 ecmr_bits; int mcast_all = 0; unsigned long flags; spin_lock_irqsave(&mdp->lock, flags); /* * Initial condition is MCT = 1, PRM = 0. * Depending on ndev->flags, set PRM or clear MCT */ ecmr_bits = (sh_eth_read(ndev, ECMR) & ~ECMR_PRM) | ECMR_MCT; if (!(ndev->flags & IFF_MULTICAST)) { sh_eth_tsu_purge_mcast(ndev); mcast_all = 1; } if (ndev->flags & IFF_ALLMULTI) { sh_eth_tsu_purge_mcast(ndev); ecmr_bits &= ~ECMR_MCT; mcast_all = 1; } if (ndev->flags & IFF_PROMISC) { sh_eth_tsu_purge_all(ndev); ecmr_bits = (ecmr_bits & ~ECMR_MCT) | ECMR_PRM; } else if (mdp->cd->tsu) { struct netdev_hw_addr *ha; netdev_for_each_mc_addr(ha, ndev) { if (mcast_all && is_multicast_ether_addr(ha->addr)) continue; if (sh_eth_tsu_add_entry(ndev, ha->addr) < 0) { if (!mcast_all) { sh_eth_tsu_purge_mcast(ndev); ecmr_bits &= ~ECMR_MCT; mcast_all = 1; } } } } else { /* Normal, unicast/broadcast-only mode. */ ecmr_bits = (ecmr_bits & ~ECMR_PRM) | ECMR_MCT; } /* update the ethernet mode */ sh_eth_write(ndev, ecmr_bits, ECMR); spin_unlock_irqrestore(&mdp->lock, flags); } static int sh_eth_get_vtag_index(struct sh_eth_private *mdp) { if (!mdp->port) return TSU_VTAG0; else return TSU_VTAG1; } static int sh_eth_vlan_rx_add_vid(struct net_device *ndev, u16 vid) { struct sh_eth_private *mdp = netdev_priv(ndev); int vtag_reg_index = sh_eth_get_vtag_index(mdp); if (unlikely(!mdp->cd->tsu)) return -EPERM; /* No filtering if vid = 0 */ if (!vid) return 0; mdp->vlan_num_ids++; /* * The controller has one VLAN tag HW filter. So, if the filter is * already enabled, the driver disables it and the filte */ if (mdp->vlan_num_ids > 1) { /* disable VLAN filter */ sh_eth_tsu_write(mdp, 0, vtag_reg_index); return 0; } sh_eth_tsu_write(mdp, TSU_VTAG_ENABLE | (vid & TSU_VTAG_VID_MASK), vtag_reg_index); return 0; } static int sh_eth_vlan_rx_kill_vid(struct net_device *ndev, u16 vid) { struct sh_eth_private *mdp = netdev_priv(ndev); int vtag_reg_index = sh_eth_get_vtag_index(mdp); if (unlikely(!mdp->cd->tsu)) return -EPERM; /* No filtering if vid = 0 */ if (!vid) return 0; mdp->vlan_num_ids--; sh_eth_tsu_write(mdp, 0, vtag_reg_index); return 0; } #endif /* SH_ETH_HAS_TSU */ /* SuperH's TSU register init function */ static void sh_eth_tsu_init(struct sh_eth_private *mdp) { sh_eth_tsu_write(mdp, 0, TSU_FWEN0); /* Disable forward(0->1) */ sh_eth_tsu_write(mdp, 0, TSU_FWEN1); /* Disable forward(1->0) */ sh_eth_tsu_write(mdp, 0, TSU_FCM); /* forward fifo 3k-3k */ sh_eth_tsu_write(mdp, 0xc, TSU_BSYSL0); sh_eth_tsu_write(mdp, 0xc, TSU_BSYSL1); sh_eth_tsu_write(mdp, 0, TSU_PRISL0); sh_eth_tsu_write(mdp, 0, TSU_PRISL1); sh_eth_tsu_write(mdp, 0, TSU_FWSL0); sh_eth_tsu_write(mdp, 0, TSU_FWSL1); sh_eth_tsu_write(mdp, TSU_FWSLC_POSTENU | TSU_FWSLC_POSTENL, TSU_FWSLC); if (sh_eth_is_gether(mdp)) { sh_eth_tsu_write(mdp, 0, TSU_QTAG0); /* Disable QTAG(0->1) */ sh_eth_tsu_write(mdp, 0, TSU_QTAG1); /* Disable QTAG(1->0) */ } else { sh_eth_tsu_write(mdp, 0, TSU_QTAGM0); /* Disable QTAG(0->1) */ sh_eth_tsu_write(mdp, 0, TSU_QTAGM1); /* Disable QTAG(1->0) */ } sh_eth_tsu_write(mdp, 0, TSU_FWSR); /* all interrupt status clear */ sh_eth_tsu_write(mdp, 0, TSU_FWINMK); /* Disable all interrupt */ sh_eth_tsu_write(mdp, 0, TSU_TEN); /* Disable all CAM entry */ sh_eth_tsu_write(mdp, 0, TSU_POST1); /* Disable CAM entry [ 0- 7] */ sh_eth_tsu_write(mdp, 0, TSU_POST2); /* Disable CAM entry [ 8-15] */ sh_eth_tsu_write(mdp, 0, TSU_POST3); /* Disable CAM entry [16-23] */ sh_eth_tsu_write(mdp, 0, TSU_POST4); /* Disable CAM entry [24-31] */ } /* MDIO bus release function */ static int sh_mdio_release(struct net_device *ndev) { struct mii_bus *bus = dev_get_drvdata(&ndev->dev); /* unregister mdio bus */ mdiobus_unregister(bus); /* remove mdio bus info from net_device */ dev_set_drvdata(&ndev->dev, NULL); /* free interrupts memory */ kfree(bus->irq); /* free bitbang info */ free_mdio_bitbang(bus); return 0; } /* MDIO bus init function */ static int sh_mdio_init(struct net_device *ndev, int id, struct sh_eth_plat_data *pd) { int ret, i; struct bb_info *bitbang; struct sh_eth_private *mdp = netdev_priv(ndev); /* create bit control struct for PHY */ bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL); if (!bitbang) { ret = -ENOMEM; goto out; } /* bitbang init */ bitbang->addr = mdp->addr + mdp->reg_offset[PIR]; bitbang->set_gate = pd->set_mdio_gate; bitbang->mdi_msk = 0x08; bitbang->mdo_msk = 0x04; bitbang->mmd_msk = 0x02;/* MMD */ bitbang->mdc_msk = 0x01; bitbang->ctrl.ops = &bb_ops; /* MII controller setting */ mdp->mii_bus = alloc_mdio_bitbang(&bitbang->ctrl); if (!mdp->mii_bus) { ret = -ENOMEM; goto out_free_bitbang; } /* Hook up MII support for ethtool */ mdp->mii_bus->name = "sh_mii"; mdp->mii_bus->parent = &ndev->dev; snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", mdp->pdev->name, id); /* PHY IRQ */ mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); if (!mdp->mii_bus->irq) { ret = -ENOMEM; goto out_free_bus; } for (i = 0; i < PHY_MAX_ADDR; i++) mdp->mii_bus->irq[i] = PHY_POLL; /* regist mdio bus */ ret = mdiobus_register(mdp->mii_bus); if (ret) goto out_free_irq; dev_set_drvdata(&ndev->dev, mdp->mii_bus); return 0; out_free_irq: kfree(mdp->mii_bus->irq); out_free_bus: free_mdio_bitbang(mdp->mii_bus); out_free_bitbang: kfree(bitbang); out: return ret; } static const u16 *sh_eth_get_register_offset(int register_type) { const u16 *reg_offset = NULL; switch (register_type) { case SH_ETH_REG_GIGABIT: reg_offset = sh_eth_offset_gigabit; break; case SH_ETH_REG_FAST_SH4: reg_offset = sh_eth_offset_fast_sh4; break; case SH_ETH_REG_FAST_SH3_SH2: reg_offset = sh_eth_offset_fast_sh3_sh2; break; default: printk(KERN_ERR "Unknown register type (%d)\n", register_type); break; } return reg_offset; } static const struct net_device_ops sh_eth_netdev_ops = { .ndo_open = sh_eth_open, .ndo_stop = sh_eth_close, .ndo_start_xmit = sh_eth_start_xmit, .ndo_get_stats = sh_eth_get_stats, #if defined(SH_ETH_HAS_TSU) .ndo_set_rx_mode = sh_eth_set_multicast_list, .ndo_vlan_rx_add_vid = sh_eth_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = sh_eth_vlan_rx_kill_vid, #endif .ndo_tx_timeout = sh_eth_tx_timeout, .ndo_do_ioctl = sh_eth_do_ioctl, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr, .ndo_change_mtu = eth_change_mtu, }; static int sh_eth_drv_probe(struct platform_device *pdev) { int ret, devno = 0; struct resource *res; struct net_device *ndev = NULL; struct sh_eth_private *mdp = NULL; struct sh_eth_plat_data *pd; /* get base addr */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (unlikely(res == NULL)) { dev_err(&pdev->dev, "invalid resource\n"); ret = -EINVAL; goto out; } ndev = alloc_etherdev(sizeof(struct sh_eth_private)); if (!ndev) { ret = -ENOMEM; goto out; } /* The sh Ether-specific entries in the device structure. */ ndev->base_addr = res->start; devno = pdev->id; if (devno < 0) devno = 0; ndev->dma = -1; ret = platform_get_irq(pdev, 0); if (ret < 0) { ret = -ENODEV; goto out_release; } ndev->irq = ret; SET_NETDEV_DEV(ndev, &pdev->dev); /* Fill in the fields of the device structure with ethernet values. */ ether_setup(ndev); mdp = netdev_priv(ndev); mdp->addr = ioremap(res->start, resource_size(res)); if (mdp->addr == NULL) { ret = -ENOMEM; dev_err(&pdev->dev, "ioremap failed.\n"); goto out_release; } spin_lock_init(&mdp->lock); mdp->pdev = pdev; pm_runtime_enable(&pdev->dev); pm_runtime_resume(&pdev->dev); pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data); /* get PHY ID */ mdp->phy_id = pd->phy; mdp->phy_interface = pd->phy_interface; /* EDMAC endian */ mdp->edmac_endian = pd->edmac_endian; mdp->no_ether_link = pd->no_ether_link; mdp->ether_link_active_low = pd->ether_link_active_low; mdp->reg_offset = sh_eth_get_register_offset(pd->register_type); /* set cpu data */ #if defined(SH_ETH_HAS_BOTH_MODULES) mdp->cd = sh_eth_get_cpu_data(mdp); #else mdp->cd = &sh_eth_my_cpu_data; #endif sh_eth_set_default_cpu_data(mdp->cd); /* set function */ ndev->netdev_ops = &sh_eth_netdev_ops; SET_ETHTOOL_OPS(ndev, &sh_eth_ethtool_ops); ndev->watchdog_timeo = TX_TIMEOUT; /* debug message level */ mdp->msg_enable = SH_ETH_DEF_MSG_ENABLE; mdp->post_rx = POST_RX >> (devno << 1); mdp->post_fw = POST_FW >> (devno << 1); /* read and set MAC address */ read_mac_address(ndev, pd->mac_addr); /* ioremap the TSU registers */ if (mdp->cd->tsu) { struct resource *rtsu; rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (!rtsu) { dev_err(&pdev->dev, "Not found TSU resource\n"); goto out_release; } mdp->tsu_addr = ioremap(rtsu->start, resource_size(rtsu)); mdp->port = devno % 2; ndev->features = NETIF_F_HW_VLAN_FILTER; } /* initialize first or needed device */ if (!devno || pd->needs_init) { if (mdp->cd->chip_reset) mdp->cd->chip_reset(ndev); if (mdp->cd->tsu) { /* TSU init (Init only)*/ sh_eth_tsu_init(mdp); } } /* network device register */ ret = register_netdev(ndev); if (ret) goto out_release; /* mdio bus init */ ret = sh_mdio_init(ndev, pdev->id, pd); if (ret) goto out_unregister; /* print device information */ pr_info("Base address at 0x%x, %pM, IRQ %d.\n", (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); platform_set_drvdata(pdev, ndev); return ret; out_unregister: unregister_netdev(ndev); out_release: /* net_dev free */ if (mdp && mdp->addr) iounmap(mdp->addr); if (mdp && mdp->tsu_addr) iounmap(mdp->tsu_addr); if (ndev) free_netdev(ndev); out: return ret; } static int sh_eth_drv_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->cd->tsu) iounmap(mdp->tsu_addr); sh_mdio_release(ndev); unregister_netdev(ndev); pm_runtime_disable(&pdev->dev); iounmap(mdp->addr); free_netdev(ndev); platform_set_drvdata(pdev, NULL); return 0; } static int sh_eth_runtime_nop(struct device *dev) { /* * Runtime PM callback shared between ->runtime_suspend() * and ->runtime_resume(). Simply returns success. * * This driver re-initializes all registers after * pm_runtime_get_sync() anyway so there is no need * to save and restore registers here. */ return 0; } static struct dev_pm_ops sh_eth_dev_pm_ops = { .runtime_suspend = sh_eth_runtime_nop, .runtime_resume = sh_eth_runtime_nop, }; static struct platform_driver sh_eth_driver = { .probe = sh_eth_drv_probe, .remove = sh_eth_drv_remove, .driver = { .name = CARDNAME, .pm = &sh_eth_dev_pm_ops, }, }; module_platform_driver(sh_eth_driver); MODULE_AUTHOR("Nobuhiro Iwamatsu, Yoshihiro Shimoda"); MODULE_DESCRIPTION("Renesas SuperH Ethernet driver"); MODULE_LICENSE("GPL v2");
slawr/linux-stable
drivers/net/ethernet/renesas/sh_eth.c
C
gpl-2.0
60,257
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Falla extends Model{ protected $fillable = ['name', 'address', 'status']; public function objections(){ return $this->hasMany('App\Models\Objection', 'id_falla'); } public function fools(){ return $this->belongsToMany('App\Models\User', 'objections', 'id_falla', 'id_user'); } }
victorarcasrios/fallas
app/Models/Falla.php
PHP
gpl-2.0
367
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Aria: ArLineSegment Class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.4.2 --> <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <a class="qindex" href="examples.html">Examples</a></div> <h1>ArLineSegment Class Reference</h1><code>#include &lt;ariaUtil.h&gt;</code> <p> <p>Inheritance diagram for ArLineSegment: <p><center><img src="classArLineSegment.png" usemap="#ArLineSegment_map" border="0" alt=""></center> <map name="ArLineSegment_map"> <area href="classArLineFinderSegment.html" alt="ArLineFinderSegment" shape="rect" coords="0,56,135,80"> </map> <a href="classArLineSegment-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2> Represents a line segment in two-dimensional space. <p> The segment is defined by the coordinates of each endpoint. <p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0" doxytag="ArLineSegment::ArLineSegment"></a> &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a0">ArLineSegment</a> (<a class="el" href="classArPose.html">ArPose</a> pose1, <a class="el" href="classArPose.html">ArPose</a> pose2)</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor with endpoints as <a class="el" href="classArPose.html">ArPose</a> objects. Only X and Y components of the poses will be used. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a1">ArLineSegment</a> (double x1, double y1, double x2, double y2)</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor with endpoints. <a href="#a1"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a2">ArLineSegment</a> ()</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a3" doxytag="ArLineSegment::getA"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a3">getA</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the A line parameter (see <a class="el" href="classArLine.html">ArLine</a>). <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a4" doxytag="ArLineSegment::getB"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a4">getB</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the B line parameter (see <a class="el" href="classArLine.html">ArLine</a>). <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a5" doxytag="ArLineSegment::getC"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a5">getC</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the C line parameter (see <a class="el" href="classArLine.html">ArLine</a>). <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a6">getDistToLine</a> (const <a class="el" href="classArPose.html">ArPose</a> pose)</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the distance from this line segment to a point. <a href="#a6"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a7" doxytag="ArLineSegment::getEndPoint1"></a> <a class="el" href="classArPose.html">ArPose</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a7">getEndPoint1</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the first endpoint (X1, Y1). <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a8" doxytag="ArLineSegment::getEndPoint2"></a> <a class="el" href="classArPose.html">ArPose</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a8">getEndPoint2</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the second endpoint of (X2, Y2). <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a9" doxytag="ArLineSegment::getLengthOf"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a9">getLengthOf</a> () const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Determines the length of the line segment. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a10" doxytag="ArLineSegment::getLine"></a> const <a class="el" href="classArLine.html">ArLine</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><b>getLine</b> (void) const </td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a11">getPerpDist</a> (const <a class="el" href="classArPose.html">ArPose</a> pose)</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Calculate the distance from the given point to (its projection on) this line segment. <a href="#a11"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a12">getPerpPoint</a> (const <a class="el" href="classArPose.html">ArPose</a> *pose, <a class="el" href="classArPose.html">ArPose</a> *perpPoint)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a13">getPerpPoint</a> (<a class="el" href="classArPose.html">ArPose</a> pose, <a class="el" href="classArPose.html">ArPose</a> *perpPoint)</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Determine the intersection point between this line segment, and a perpendicular line passing through the given pose (i.e. projects the given pose onto this line segment.). <a href="#a13"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a14">getPerpSquaredDist</a> (const <a class="el" href="classArPose.html">ArPose</a> pose)</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Calculate the squared distance from the given point to (its projection on) this line segment. <a href="#a14"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a15" doxytag="ArLineSegment::getX1"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a15">getX1</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the x coordinate of the first endpoint. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a16" doxytag="ArLineSegment::getX2"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a16">getX2</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the x coordinate of the second endpoint. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a17" doxytag="ArLineSegment::getY1"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a17">getY1</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the y coordinate of the first endpoint. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a18" doxytag="ArLineSegment::getY2"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a18">getY2</a> (void) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the y coordinate of the second endpoint. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a19">intersects</a> (<a class="el" href="classArLineSegment.html">ArLineSegment</a> *line, <a class="el" href="classArPose.html">ArPose</a> *pose)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a20">intersects</a> (const <a class="el" href="classArLine.html">ArLine</a> *line, <a class="el" href="classArPose.html">ArPose</a> *pose) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Determine where a line intersects this line segment. <a href="#a20"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a21" doxytag="ArLineSegment::linePointIsInSegment"></a> bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a21">linePointIsInSegment</a> (<a class="el" href="classArPose.html">ArPose</a> *pose) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Internal function for seeing if a point on our line is within our segment. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a22" doxytag="ArLineSegment::newEndPoints"></a> void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a22">newEndPoints</a> (const <a class="el" href="classArPose.html">ArPose</a> &amp;pt1, const <a class="el" href="classArPose.html">ArPose</a> &amp;pt2)</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set new end points for this line segment. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a23" doxytag="ArLineSegment::newEndPoints"></a> void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a23">newEndPoints</a> (double x1, double y1, double x2, double y2)</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set new end points for this line segment. <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a24" doxytag="ArLineSegment::operator!="></a> virtual bool&nbsp;</td><td class="memItemRight" valign="bottom"><b>operator!=</b> (const <a class="el" href="classArLineSegment.html">ArLineSegment</a> &amp;other) const </td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a25" doxytag="ArLineSegment::operator<"></a> virtual bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a25">operator&lt;</a> (const <a class="el" href="classArLineSegment.html">ArLineSegment</a> &amp;other) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Less than operator (for sets). <br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a26" doxytag="ArLineSegment::operator=="></a> virtual bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArLineSegment.html#a26">operator==</a> (const <a class="el" href="classArLineSegment.html">ArLineSegment</a> &amp;other) const </td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Equality operator (for sets). <br></td></tr> <tr><td colspan="2"><br><h2>Protected Attributes</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="p0" doxytag="ArLineSegment::myLine"></a> <a class="el" href="classArLine.html">ArLine</a>&nbsp;</td><td class="memItemRight" valign="bottom"><b>myLine</b></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="p1" doxytag="ArLineSegment::myX1"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><b>myX1</b></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="p2" doxytag="ArLineSegment::myX2"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><b>myX2</b></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="p3" doxytag="ArLineSegment::myY1"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><b>myY1</b></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="p4" doxytag="ArLineSegment::myY2"></a> double&nbsp;</td><td class="memItemRight" valign="bottom"><b>myY2</b></td></tr> </table> <hr><h2>Constructor &amp; Destructor Documentation</h2> <a class="anchor" name="a2" doxytag="ArLineSegment::ArLineSegment"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">ArLineSegment::ArLineSegment </td> <td class="md" valign="top">(&nbsp;</td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">&nbsp;)&nbsp;</td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> <b>Java and Python Wrappers:</b> Not available in Java or Python wrapper libraries. </td> </tr> </table> <a class="anchor" name="a1" doxytag="ArLineSegment::ArLineSegment"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">ArLineSegment::ArLineSegment </td> <td class="md" valign="top">(&nbsp;</td> <td class="md" nowrap valign="top">double&nbsp;</td> <td class="mdname" nowrap> <em>x1</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>double&nbsp;</td> <td class="mdname" nowrap> <em>y1</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>double&nbsp;</td> <td class="mdname" nowrap> <em>x2</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>double&nbsp;</td> <td class="mdname" nowrap> <em>y2</em></td> </tr> <tr> <td class="md"></td> <td class="md">)&nbsp;</td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> Constructor with endpoints. <p> <b>Java and Python Wrappers:</b> Not available in Java or Python wrapper libraries. </td> </tr> </table> <hr><h2>Member Function Documentation</h2> <a class="anchor" name="a6" doxytag="ArLineSegment::getDistToLine"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">double ArLineSegment::getDistToLine </td> <td class="md" valign="top">(&nbsp;</td> <td class="md" nowrap valign="top">const <a class="el" href="classArPose.html">ArPose</a>&nbsp;</td> <td class="mdname1" valign="top" nowrap> <em>pose</em> </td> <td class="md" valign="top">&nbsp;)&nbsp;</td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> Gets the distance from this line segment to a point. <p> If the point can be projected onto this line segment (i.e. a perpendicular line can be drawn through the point), then return that distance. Otherwise, return the distance to the closest endpoint. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>pose</em>&nbsp;</td><td>the pointer of the pose to find the distance to </td></tr> </table> </dl> </td> </tr> </table> <a class="anchor" name="a11" doxytag="ArLineSegment::getPerpDist"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">virtual double ArLineSegment::getPerpDist </td> <td class="md" valign="top">(&nbsp;</td> <td class="md" nowrap valign="top">const <a class="el" href="classArPose.html">ArPose</a>&nbsp;</td> <td class="mdname1" valign="top" nowrap> <em>pose</em> </td> <td class="md" valign="top">&nbsp;)&nbsp;</td> <td class="md" nowrap><code> [inline, virtual]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> Calculate the distance from the given point to (its projection on) this line segment. <p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>pose</em>&nbsp;</td><td>the the pose to find the perp point of</td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>if the pose does not intersect segment it will return &lt; 0 if the pose intersects the segment it will return the distance to the intersection </dd></dl> </td> </tr> </table> <a class="anchor" name="a12" doxytag="ArLineSegment::getPerpPoint"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">bool ArLineSegment::getPerpPoint </td> <td class="md" valign="top">(&nbsp;</td> <td class="md" nowrap valign="top">const <a class="el" href="classArPose.html">ArPose</a> *&nbsp;</td> <td class="mdname" nowrap> <em>pose</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="classArPose.html">ArPose</a> *&nbsp;</td> <td class="mdname" nowrap> <em>perpPoint</em></td> </tr> <tr> <td class="md"></td> <td class="md">)&nbsp;</td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> If there is no intersection, false is returned. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>pose</em>&nbsp;</td><td>The X and Y components of this pose object indicate the point to project onto this line segment. </td></tr> <tr><td valign="top"></td><td valign="top"><em>perpPoint</em>&nbsp;</td><td>The X and Y components of this pose object are set to indicate the intersection point </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>true if an intersection was found and perpPoint was modified, false otherwise. </dd></dl> <b>Java and Python Wrappers:</b> Not available in Java or Python wrapper libraries. (This version simply allows you to pass the first pose as a pointer, in time-critical situations where a full copy of the object would impact performance.) </td> </tr> </table> <a class="anchor" name="a13" doxytag="ArLineSegment::getPerpPoint"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">bool ArLineSegment::getPerpPoint </td> <td class="md" valign="top">(&nbsp;</td> <td class="md" nowrap valign="top"><a class="el" href="classArPose.html">ArPose</a>&nbsp;</td> <td class="mdname" nowrap> <em>pose</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="classArPose.html">ArPose</a> *&nbsp;</td> <td class="mdname" nowrap> <em>perpPoint</em></td> </tr> <tr> <td class="md"></td> <td class="md">)&nbsp;</td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> Determine the intersection point between this line segment, and a perpendicular line passing through the given pose (i.e. projects the given pose onto this line segment.). <p> If there is no intersection, false is returned. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>pose</em>&nbsp;</td><td>The X and Y components of this pose object indicate the point to project onto this line segment. </td></tr> <tr><td valign="top"></td><td valign="top"><em>perpPoint</em>&nbsp;</td><td>The X and Y components of this pose object are set to indicate the intersection point </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>true if an intersection was found and perpPoint was modified, false otherwise. </dd></dl> <b>Java and Python Wrappers:</b> Not available in Java or Python wrapper libraries. </td> </tr> </table> <a class="anchor" name="a14" doxytag="ArLineSegment::getPerpSquaredDist"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">virtual double ArLineSegment::getPerpSquaredDist </td> <td class="md" valign="top">(&nbsp;</td> <td class="md" nowrap valign="top">const <a class="el" href="classArPose.html">ArPose</a>&nbsp;</td> <td class="mdname1" valign="top" nowrap> <em>pose</em> </td> <td class="md" valign="top">&nbsp;)&nbsp;</td> <td class="md" nowrap><code> [inline, virtual]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> Calculate the squared distance from the given point to (its projection on) this line segment. <p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>pose</em>&nbsp;</td><td>the the pose to find the perp point of</td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>if the pose does not intersect segment it will return &lt; 0 if the pose intersects the segment it will return the distance to the intersection </dd></dl> </td> </tr> </table> <a class="anchor" name="a19" doxytag="ArLineSegment::intersects"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">bool ArLineSegment::intersects </td> <td class="md" valign="top">(&nbsp;</td> <td class="md" nowrap valign="top"><a class="el" href="classArLineSegment.html">ArLineSegment</a> *&nbsp;</td> <td class="mdname" nowrap> <em>line</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="classArPose.html">ArPose</a> *&nbsp;</td> <td class="mdname" nowrap> <em>pose</em></td> </tr> <tr> <td class="md"></td> <td class="md">)&nbsp;</td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>line</em>&nbsp;</td><td>Line to check for intersection against this line segment. </td></tr> <tr><td valign="top"></td><td valign="top"><em>pose</em>&nbsp;</td><td>if the lines intersect, the X and Y components of this pose are set to the point of intersection. </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>true if they intersect, false if they do not</dd></dl> </td> </tr> </table> <a class="anchor" name="a20" doxytag="ArLineSegment::intersects"></a><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">bool ArLineSegment::intersects </td> <td class="md" valign="top">(&nbsp;</td> <td class="md" nowrap valign="top">const <a class="el" href="classArLine.html">ArLine</a> *&nbsp;</td> <td class="mdname" nowrap> <em>line</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="classArPose.html">ArPose</a> *&nbsp;</td> <td class="mdname" nowrap> <em>pose</em></td> </tr> <tr> <td class="md"></td> <td class="md">)&nbsp;</td> <td class="md" colspan="2"> const<code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> &nbsp; </td> <td> <p> Determine where a line intersects this line segment. <p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>line</em>&nbsp;</td><td>Line to check for intersection against this line segment. </td></tr> <tr><td valign="top"></td><td valign="top"><em>pose</em>&nbsp;</td><td>if the lines intersect, the X and Y components of this pose are set to the point of intersection. </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>true if they intersect, false if they do not </dd></dl> </td> </tr> </table> <hr>The documentation for this class was generated from the following file:<ul> <li>ariaUtil.h</ul> <hr size="1"><address style="align: right;"><small>Generated on Thu Jan 7 10:34:42 2010 for Aria by&nbsp; <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address> </body> </html>
charismaticchiu/Robotics
docs/classArLineSegment.html
HTML
gpl-2.0
28,647
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 # # MDAnalysis --- https://www.mdanalysis.org # Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors # (see the file AUTHORS for the full list of names) # # Released under the GNU Public Licence, v2 or any higher version # # Please cite your use of MDAnalysis in published work: # # R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler, # D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein. # MDAnalysis: A Python package for the rapid analysis of molecular dynamics # simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th # Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy. # doi: 10.25080/majora-629e541a-00e # # N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein. # MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations. # J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 # """Water dynamics analysis --- :mod:`MDAnalysis.analysis.waterdynamics` ======================================================================= :Author: Alejandro Bernardin :Year: 2014-2015 :Copyright: GNU Public License v3 .. versionadded:: 0.11.0 This module provides functions to analize water dynamics trajectories and water interactions with other molecules. The functions in this module are: water orientational relaxation (WOR) [Yeh1999]_, hydrogen bond lifetimes (HBL) [Rapaport1983]_, angular distribution (AD) [Grigera1995]_, mean square displacement (MSD) [Brodka1994]_ and survival probability (SP) [Liu2004]_. For more information about this type of analysis please refer to [Araya-Secchi2014]_ (water in a protein cavity) and [Milischuk2011]_ (water in a nanopore). .. rubric:: References .. [Rapaport1983] D.C. Rapaport (1983): Hydrogen bonds in water, Molecular Physics: An International Journal at the Interface Between Chemistry and Physics, 50:5, 1151-1162. .. [Yeh1999] Yu-ling Yeh and Chung-Yuan Mou (1999). Orientational Relaxation Dynamics of Liquid Water Studied by Molecular Dynamics Simulation, J. Phys. Chem. B 1999, 103, 3699-3705. .. [Grigera1995] Raul Grigera, Susana G. Kalko and Jorge Fischbarg (1995). Wall-Water Interface. A Molecular Dynamics Study, Langmuir 1996,12,154-158 .. [Liu2004] Pu Liu, Edward Harder, and B. J. Berne (2004).On the Calculation of Diffusion Coefficients in Confined Fluids and Interfaces with an Application to the Liquid-Vapor Interface of Water, J. Phys. Chem. B 2004, 108, 6595-6602. .. [Brodka1994] Aleksander Brodka (1994). Diffusion in restricted volume, Molecular Physics, 1994, Vol. 82, No. 5, 1075-1078. .. [Araya-Secchi2014] Araya-Secchi, R., Tomas Perez-Acle, Seung-gu Kang, Tien Huynh, Alejandro Bernardin, Yerko Escalona, Jose-Antonio Garate, Agustin D. Martinez, Isaac E. Garcia, Juan C. Saez, Ruhong Zhou (2014). Characterization of a novel water pocket inside the human Cx26 hemichannel structure. Biophysical journal, 107(3), 599-612. .. [Milischuk2011] Anatoli A. Milischuk and Branka M. Ladanyi. Structure and dynamics of water confined in silica nanopores. J. Chem. Phys. 135, 174709 (2011); doi: 10.1063/1.3657408 Example use of the analysis classes ----------------------------------- HydrogenBondLifetimes ~~~~~~~~~~~~~~~~~~~~~ To analyse hydrogen bond lifetime, use :meth:`MDAnalysis.analysis.hydrogenbonds.hbond_analysis.HydrogenBondAnalysis.liftetime`. See Also -------- :mod:`MDAnalysis.analysis.hydrogenbonds.hbond_analysis` WaterOrientationalRelaxation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Analyzing water orientational relaxation (WOR) :class:`WaterOrientationalRelaxation`. In this case we are analyzing "how fast" water molecules are rotating/changing direction. If WOR is very stable we can assume that water molecules are rotating/changing direction very slow, on the other hand, if WOR decay very fast, we can assume that water molecules are rotating/changing direction very fast:: import MDAnalysis from MDAnalysis.analysis.waterdynamics import WaterOrientationalRelaxation as WOR u = MDAnalysis.Universe(pdb, trajectory) select = "byres name OH2 and sphzone 6.0 protein and resid 42" WOR_analysis = WOR(universe, select, 0, 1000, 20) WOR_analysis.run() time = 0 #now we print the data ready to plot. The first two columns are WOR_OH vs t plot, #the second two columns are WOR_HH vs t graph and the third two columns are WOR_dip vs t graph for WOR_OH, WOR_HH, WOR_dip in WOR_analysis.timeseries: print("{time} {WOR_OH} {time} {WOR_HH} {time} {WOR_dip}".format(time=time, WOR_OH=WOR_OH, WOR_HH=WOR_HH,WOR_dip=WOR_dip)) time += 1 #now, if we want, we can plot our data plt.figure(1,figsize=(18, 6)) #WOR OH plt.subplot(131) plt.xlabel('time') plt.ylabel('WOR') plt.title('WOR OH') plt.plot(range(0,time),[column[0] for column in WOR_analysis.timeseries]) #WOR HH plt.subplot(132) plt.xlabel('time') plt.ylabel('WOR') plt.title('WOR HH') plt.plot(range(0,time),[column[1] for column in WOR_analysis.timeseries]) #WOR dip plt.subplot(133) plt.xlabel('time') plt.ylabel('WOR') plt.title('WOR dip') plt.plot(range(0,time),[column[2] for column in WOR_analysis.timeseries]) plt.show() where t0 = 0, tf = 1000 and dtmax = 20. In this way we create 20 windows timesteps (20 values in the x axis), the first window is created with 1000 timestep average (1000/1), the second window is created with 500 timestep average(1000/2), the third window is created with 333 timestep average (1000/3) and so on. AngularDistribution ~~~~~~~~~~~~~~~~~~~ Analyzing angular distribution (AD) :class:`AngularDistribution` for OH vector, HH vector and dipole vector. It returns a line histogram with vector orientation preference. A straight line in the output plot means no preferential orientation in water molecules. In this case we are analyzing if water molecules have some orientational preference, in this way we can see if water molecules are under an electric field or if they are interacting with something (residue, protein, etc):: import MDAnalysis from MDAnalysis.analysis.waterdynamics import AngularDistribution as AD u = MDAnalysis.Universe(pdb, trajectory) selection = "byres name OH2 and sphzone 6.0 (protein and (resid 42 or resid 26) )" bins = 30 AD_analysis = AD(universe,selection,bins) AD_analysis.run() #now we print data ready to graph. The first two columns are P(cos(theta)) vs cos(theta) for OH vector , #the seconds two columns are P(cos(theta)) vs cos(theta) for HH vector and thirds two columns #are P(cos(theta)) vs cos(theta) for dipole vector for bin in range(bins): print("{AD_analysisOH} {AD_analysisHH} {AD_analysisDip}".format(AD_analysis.graph0=AD_analysis.graph[0][bin], AD_analysis.graph1=AD_analysis.graph[1][bin],AD_analysis.graph2=AD_analysis.graph[2][bin])) #and if we want to graph our results plt.figure(1,figsize=(18, 6)) #AD OH plt.subplot(131) plt.xlabel('cos theta') plt.ylabel('P(cos theta)') plt.title('PDF cos theta for OH') plt.plot([float(column.split()[0]) for column in AD_analysis.graph[0][:-1]],[float(column.split()[1]) for column in AD_analysis.graph[0][:-1]]) #AD HH plt.subplot(132) plt.xlabel('cos theta') plt.ylabel('P(cos theta)') plt.title('PDF cos theta for HH') plt.plot([float(column.split()[0]) for column in AD_analysis.graph[1][:-1]],[float(column.split()[1]) for column in AD_analysis.graph[1][:-1]]) #AD dip plt.subplot(133) plt.xlabel('cos theta') plt.ylabel('P(cos theta)') plt.title('PDF cos theta for dipole') plt.plot([float(column.split()[0]) for column in AD_analysis.graph[2][:-1]],[float(column.split()[1]) for column in AD_analysis.graph[2][:-1]]) plt.show() where `P(cos(theta))` is the angular distribution or angular probabilities. MeanSquareDisplacement ~~~~~~~~~~~~~~~~~~~~~~ Analyzing mean square displacement (MSD) :class:`MeanSquareDisplacement` for water molecules. In this case we are analyzing the average distance that water molecules travels inside protein in XYZ direction (cylindric zone of radius 11[nm], Zmax 4.0[nm] and Zmin -8.0[nm]). A strong rise mean a fast movement of water molecules, a weak rise mean slow movement of particles:: import MDAnalysis from MDAnalysis.analysis.waterdynamics import MeanSquareDisplacement as MSD u = MDAnalysis.Universe(pdb, trajectory) select = "byres name OH2 and cyzone 11.0 4.0 -8.0 protein" MSD_analysis = MSD(universe, select, 0, 1000, 20) MSD_analysis.run() #now we print data ready to graph. The graph #represents MSD vs t time = 0 for msd in MSD_analysis.timeseries: print("{time} {msd}".format(time=time, msd=msd)) time += 1 #Plot plt.xlabel('time') plt.ylabel('MSD') plt.title('MSD') plt.plot(range(0,time),MSD_analysis.timeseries) plt.show() .. _SP-examples: SurvivalProbability ~~~~~~~~~~~~~~~~~~~ Analyzing survival probability (SP) :class:`SurvivalProbability` of molecules. In this case we are analyzing how long water molecules remain in a sphere of radius 12.3 centered in the geometrical center of resid 42 and 26. A slow decay of SP means a long permanence time of water molecules in the zone, on the other hand, a fast decay means a short permanence time:: import MDAnalysis from MDAnalysis.analysis.waterdynamics import SurvivalProbability as SP import matplotlib.pyplot as plt universe = MDAnalysis.Universe(pdb, trajectory) select = "byres name OH2 and sphzone 12.3 (resid 42 or resid 26) " sp = SP(universe, select, verbose=True) sp.run(start=0, stop=101, tau_max=20) tau_timeseries = sp.tau_timeseries sp_timeseries = sp.sp_timeseries # print in console for tau, sp in zip(tau_timeseries, sp_timeseries): print("{time} {sp}".format(time=tau, sp=sp)) # plot plt.xlabel('Time') plt.ylabel('SP') plt.title('Survival Probability') plt.plot(tau_timeseries, sp_timeseries) plt.show() One should note that the `stop` keyword as used in the above example has an `exclusive` behaviour, i.e. here the final frame used will be 100 not 101. This behaviour is aligned with :class:`AnalysisBase` but currently differs from other :mod:`MDAnalysis.analysis.waterdynamics` classes, which all exhibit `inclusive` behaviour for their final frame selections. Another example applies to the situation where you work with many different "residues". Here we calculate the SP of a potassium ion around each lipid in a membrane and average the results. In this example, if the SP analysis were run without treating each lipid separately, potassium ions may hop from one lipid to another and still be counted as remaining in the specified region. That is, the survival probability of the potassium ion around the entire membrane will be calculated. Note, for this example, it is advisable to use `Universe(in_memory=True)` to ensure that the simulation is not being reloaded into memory for each lipid:: import MDAnalysis as mda from MDAnalysis.analysis.waterdynamics import SurvivalProbability as SP import numpy as np u = mda.Universe("md.gro", "md100ns.xtc", in_memory=True) lipids = u.select_atoms('resname LIPIDS') joined_sp_timeseries = [[] for _ in range(20)] for lipid in lipids.residues: print("Lipid ID: %d" % lipid.resid) select = "resname POTASSIUM and around 3.5 (resid %d and name O13 O14) " % lipid.resid sp = SP(u, select, verbose=True) sp.run(tau_max=20) # Raw SP points for each tau: for sps, new_sps in zip(joined_sp_timeseries, sp.sp_timeseries_data): sps.extend(new_sps) # average all SP datapoints sp_data = [np.mean(sp) for sp in joined_sp_timeseries] for tau, sp in zip(range(1, tau_max + 1), sp_data): print("{time} {sp}".format(time=tau, sp=sp)) .. _Output: Output ------ WaterOrientationalRelaxation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Water orientational relaxation (WOR) data is returned per window timestep, which is stored in :attr:`WaterOrientationalRelaxation.timeseries`:: results = [ [ # time t0 <WOR_OH>, <WOR_HH>, <WOR_dip> ], [ # time t1 <WOR_OH>, <WOR_HH>, <WOR_dip> ], ... ] AngularDistribution ~~~~~~~~~~~~~~~~~~~ Angular distribution (AD) data is returned per vector, which is stored in :attr:`AngularDistribution.graph`. In fact, AngularDistribution returns a histogram:: results = [ [ # OH vector values # the values are order in this way: <x_axis y_axis> <cos_theta0 ang_distr0>, <cos_theta1 ang_distr1>, ... ], [ # HH vector values <cos_theta0 ang_distr0>, <cos_theta1 ang_distr1>, ... ], [ # dip vector values <cos_theta0 ang_distr0>, <cos_theta1 ang_distr1>, ... ], ] MeanSquareDisplacement ~~~~~~~~~~~~~~~~~~~~~~ Mean Square Displacement (MSD) data is returned in a list, which each element represents a MSD value in its respective window timestep. Data is stored in :attr:`MeanSquareDisplacement.timeseries`:: results = [ #MSD values orders by window timestep <MSD_t0>, <MSD_t1>, ... ] SurvivalProbability ~~~~~~~~~~~~~~~~~~~ Survival Probability (SP) computes two lists: a list of taus (:attr:`SurvivalProbability.tau_timeseries`) and a list of the corresponding survival probabilities (:attr:`SurvivalProbability.sp_timeseries`). results = [ tau1, tau2, ..., tau_n ], [ sp_tau1, sp_tau2, ..., sp_tau_n] Additionally, a list :attr:`SurvivalProbability.sp_timeseries_data`, is provided which contains a list of all SPs calculated for each tau. This can be used to compute the distribution or time dependence of SP, etc. Classes -------- .. autoclass:: WaterOrientationalRelaxation :members: :inherited-members: .. autoclass:: AngularDistribution :members: :inherited-members: .. autoclass:: MeanSquareDisplacement :members: :inherited-members: .. autoclass:: SurvivalProbability :members: :inherited-members: """ from MDAnalysis.lib.correlations import autocorrelation, correct_intermittency import MDAnalysis.analysis.hbonds from itertools import zip_longest import logging import warnings import numpy as np logger = logging.getLogger('MDAnalysis.analysis.waterdynamics') from MDAnalysis.lib.log import ProgressBar class WaterOrientationalRelaxation(object): r"""Water orientation relaxation analysis Function to evaluate the Water Orientational Relaxation proposed by Yu-ling Yeh and Chung-Yuan Mou [Yeh1999_]. WaterOrientationalRelaxation indicates "how fast" water molecules are rotating or changing direction. This is a time correlation function given by: .. math:: C_{\hat u}(\tau)=\langle \mathit{P}_2[\mathbf{\hat{u}}(t_0)\cdot\mathbf{\hat{u}}(t_0+\tau)]\rangle where :math:`P_2=(3x^2-1)/2` is the second-order Legendre polynomial and :math:`\hat{u}` is a unit vector along HH, OH or dipole vector. Parameters ---------- universe : Universe Universe object selection : str Selection string for water [‘byres name OH2’]. t0 : int frame where analysis begins tf : int frame where analysis ends dtmax : int Maximum dt size, `dtmax` < `tf` or it will crash. .. versionadded:: 0.11.0 .. versionchanged:: 1.0.0 Changed `selection` keyword to `select` """ def __init__(self, universe, select, t0, tf, dtmax, nproc=1): self.universe = universe self.selection = select self.t0 = t0 self.tf = tf self.dtmax = dtmax self.nproc = nproc self.timeseries = None def _repeatedIndex(self, selection, dt, totalFrames): """ Indicates the comparation between all the t+dt. The results is a list of list with all the repeated index per frame (or time). Ex: dt=1, so compare frames (1,2),(2,3),(3,4)... Ex: dt=2, so compare frames (1,3),(3,5),(5,7)... Ex: dt=3, so compare frames (1,4),(4,7),(7,10)... """ rep = [] for i in range(int(round((totalFrames - 1) / float(dt)))): if (dt * i + dt < totalFrames): rep.append(self._sameMolecTandDT( selection, dt * i, (dt * i) + dt)) return rep def _getOneDeltaPoint(self, universe, repInd, i, t0, dt): """ Gives one point to calculate the mean and gets one point of the plot C_vect vs t. Ex: t0=1 and tau=1 so calculate the t0-tau=1-2 intervale. Ex: t0=5 and tau=3 so calcultate the t0-tau=5-8 intervale. i = come from getMeanOnePoint (named j) (int) """ valOH = 0 valHH = 0 valdip = 0 n = 0 for j in range(len(repInd[i]) // 3): begj = 3 * j universe.trajectory[t0] Ot0 = repInd[i][begj] H1t0 = repInd[i][begj + 1] H2t0 = repInd[i][begj + 2] OHVector0 = H1t0.position - Ot0.position HHVector0 = H1t0.position - H2t0.position dipVector0 = ((H1t0.position + H2t0.position) * 0.5) - Ot0.position universe.trajectory[t0 + dt] Otp = repInd[i][begj] H1tp = repInd[i][begj + 1] H2tp = repInd[i][begj + 2] OHVectorp = H1tp.position - Otp.position HHVectorp = H1tp.position - H2tp.position dipVectorp = ((H1tp.position + H2tp.position) * 0.5) - Otp.position normOHVector0 = np.linalg.norm(OHVector0) normOHVectorp = np.linalg.norm(OHVectorp) normHHVector0 = np.linalg.norm(HHVector0) normHHVectorp = np.linalg.norm(HHVectorp) normdipVector0 = np.linalg.norm(dipVector0) normdipVectorp = np.linalg.norm(dipVectorp) unitOHVector0 = [OHVector0[0] / normOHVector0, OHVector0[1] / normOHVector0, OHVector0[2] / normOHVector0] unitOHVectorp = [OHVectorp[0] / normOHVectorp, OHVectorp[1] / normOHVectorp, OHVectorp[2] / normOHVectorp] unitHHVector0 = [HHVector0[0] / normHHVector0, HHVector0[1] / normHHVector0, HHVector0[2] / normHHVector0] unitHHVectorp = [HHVectorp[0] / normHHVectorp, HHVectorp[1] / normHHVectorp, HHVectorp[2] / normHHVectorp] unitdipVector0 = [dipVector0[0] / normdipVector0, dipVector0[1] / normdipVector0, dipVector0[2] / normdipVector0] unitdipVectorp = [dipVectorp[0] / normdipVectorp, dipVectorp[1] / normdipVectorp, dipVectorp[2] / normdipVectorp] valOH += self.lg2(np.dot(unitOHVector0, unitOHVectorp)) valHH += self.lg2(np.dot(unitHHVector0, unitHHVectorp)) valdip += self.lg2(np.dot(unitdipVector0, unitdipVectorp)) n += 1 return (valOH/n, valHH/n, valdip/n) if n > 0 else (0, 0, 0) def _getMeanOnePoint(self, universe, selection1, selection_str, dt, totalFrames): """ This function gets one point of the plot C_vec vs t. It uses the _getOneDeltaPoint() function to calculate the average. """ repInd = self._repeatedIndex(selection1, dt, totalFrames) sumsdt = 0 n = 0.0 sumDeltaOH = 0.0 sumDeltaHH = 0.0 sumDeltadip = 0.0 for j in range(totalFrames // dt - 1): a = self._getOneDeltaPoint(universe, repInd, j, sumsdt, dt) sumDeltaOH += a[0] sumDeltaHH += a[1] sumDeltadip += a[2] sumsdt += dt n += 1 # if no water molecules remain in selection, there is nothing to get # the mean, so n = 0. return (sumDeltaOH / n, sumDeltaHH / n, sumDeltadip / n) if n > 0 else (0, 0, 0) def _sameMolecTandDT(self, selection, t0d, tf): """ Compare the molecules in the t0d selection and the t0d+dt selection and select only the particles that are repeated in both frame. This is to consider only the molecules that remains in the selection after the dt time has elapsed. The result is a list with the indexs of the atoms. """ a = set(selection[t0d]) b = set(selection[tf]) sort = sorted(list(a.intersection(b))) return sort def _selection_serial(self, universe, selection_str): selection = [] for ts in ProgressBar(universe.trajectory, verbose=True, total=universe.trajectory.n_frames): selection.append(universe.select_atoms(selection_str)) return selection @staticmethod def lg2(x): """Second Legendre polynomial""" return (3*x*x - 1)/2 def run(self, **kwargs): """Analyze trajectory and produce timeseries""" # All the selection to an array, this way is faster than selecting # later. if self.nproc == 1: selection_out = self._selection_serial( self.universe, self.selection) else: # selection_out = self._selection_parallel(self.universe, # self.selection, self.nproc) # parallel selection to be implemented selection_out = self._selection_serial( self.universe, self.selection) self.timeseries = [] for dt in list(range(1, self.dtmax + 1)): output = self._getMeanOnePoint( self.universe, selection_out, self.selection, dt, self.tf) self.timeseries.append(output) class AngularDistribution(object): r"""Angular distribution function analysis The angular distribution function (AD) is defined as the distribution probability of the cosine of the :math:`\theta` angle formed by the OH vector, HH vector or dipolar vector of water molecules and a vector :math:`\hat n` parallel to chosen axis (z is the default value). The cosine is define as :math:`\cos \theta = \hat u \cdot \hat n`, where :math:`\hat u` is OH, HH or dipole vector. It creates a histogram and returns a list of lists, see Output_. The AD is also know as Angular Probability (AP). Parameters ---------- universe : Universe Universe object select : str Selection string to evaluate its angular distribution ['byres name OH2'] bins : int (optional) Number of bins to create the histogram by means of :func:`numpy.histogram` axis : {'x', 'y', 'z'} (optional) Axis to create angle with the vector (HH, OH or dipole) and calculate cosine theta ['z']. .. versionadded:: 0.11.0 .. versionchanged:: 1.0.0 Changed `selection` keyword to `select` """ def __init__(self, universe, select, bins=40, nproc=1, axis="z"): self.universe = universe self.selection_str = select self.bins = bins self.nproc = nproc self.axis = axis self.graph = None def _getCosTheta(self, universe, selection, axis): valOH = [] valHH = [] valdip = [] i = 0 while i <= (len(selection) - 1): universe.trajectory[i] line = selection[i].positions Ot0 = line[::3] H1t0 = line[1::3] H2t0 = line[2::3] OHVector0 = H1t0 - Ot0 HHVector0 = H1t0 - H2t0 dipVector0 = (H1t0 + H2t0) * 0.5 - Ot0 unitOHVector0 = OHVector0 / \ np.linalg.norm(OHVector0, axis=1)[:, None] unitHHVector0 = HHVector0 / \ np.linalg.norm(HHVector0, axis=1)[:, None] unitdipVector0 = dipVector0 / \ np.linalg.norm(dipVector0, axis=1)[:, None] j = 0 while j < len(line) / 3: if axis == "z": valOH.append(unitOHVector0[j][2]) valHH.append(unitHHVector0[j][2]) valdip.append(unitdipVector0[j][2]) elif axis == "x": valOH.append(unitOHVector0[j][0]) valHH.append(unitHHVector0[j][0]) valdip.append(unitdipVector0[j][0]) elif axis == "y": valOH.append(unitOHVector0[j][1]) valHH.append(unitHHVector0[j][1]) valdip.append(unitdipVector0[j][1]) j += 1 i += 1 return (valOH, valHH, valdip) def _getHistogram(self, universe, selection, bins, axis): """ This function gets a normalized histogram of the cos(theta) values. It return a list of list. """ a = self._getCosTheta(universe, selection, axis) cosThetaOH = a[0] cosThetaHH = a[1] cosThetadip = a[2] lencosThetaOH = len(cosThetaOH) lencosThetaHH = len(cosThetaHH) lencosThetadip = len(cosThetadip) histInterval = bins histcosThetaOH = np.histogram(cosThetaOH, histInterval, density=True) histcosThetaHH = np.histogram(cosThetaHH, histInterval, density=True) histcosThetadip = np.histogram(cosThetadip, histInterval, density=True) return (histcosThetaOH, histcosThetaHH, histcosThetadip) def _hist2column(self, aList): """ This function transform from the histogram format to a column format. """ a = [] for x in zip_longest(*aList, fillvalue="."): a.append(" ".join(str(i) for i in x)) return a def run(self, **kwargs): """Function to evaluate the angular distribution of cos(theta)""" if self.nproc == 1: selection = self._selection_serial( self.universe, self.selection_str) else: # not implemented yet # selection = self._selection_parallel(self.universe, # self.selection_str,self.nproc) selection = self._selection_serial( self.universe, self.selection_str) self.graph = [] output = self._getHistogram( self.universe, selection, self.bins, self.axis) # this is to format the exit of the file # maybe this output could be improved listOH = [list(output[0][1]), list(output[0][0])] listHH = [list(output[1][1]), list(output[1][0])] listdip = [list(output[2][1]), list(output[2][0])] self.graph.append(self._hist2column(listOH)) self.graph.append(self._hist2column(listHH)) self.graph.append(self._hist2column(listdip)) def _selection_serial(self, universe, selection_str): selection = [] for ts in ProgressBar(universe.trajectory, verbose=True, total=universe.trajectory.n_frames): selection.append(universe.select_atoms(selection_str)) return selection class MeanSquareDisplacement(object): r"""Mean square displacement analysis Function to evaluate the Mean Square Displacement (MSD_). The MSD gives the average distance that particles travels. The MSD is given by: .. math:: \langle\Delta r(t)^2\rangle = 2nDt where :math:`r(t)` is the position of particle in time :math:`t`, :math:`\Delta r(t)` is the displacement after time lag :math:`t`, :math:`n` is the dimensionality, in this case :math:`n=3`, :math:`D` is the diffusion coefficient and :math:`t` is the time. .. _MSD: http://en.wikipedia.org/wiki/Mean_squared_displacement Parameters ---------- universe : Universe Universe object select : str Selection string for water [‘byres name OH2’]. t0 : int frame where analysis begins tf : int frame where analysis ends dtmax : int Maximum dt size, `dtmax` < `tf` or it will crash. .. versionadded:: 0.11.0 .. versionchanged:: 1.0.0 Changed `selection` keyword to `select` """ def __init__(self, universe, select, t0, tf, dtmax, nproc=1): self.universe = universe self.selection = select self.t0 = t0 self.tf = tf self.dtmax = dtmax self.nproc = nproc self.timeseries = None def _repeatedIndex(self, selection, dt, totalFrames): """ Indicate the comparation between all the t+dt. The results is a list of list with all the repeated index per frame (or time). - Ex: dt=1, so compare frames (1,2),(2,3),(3,4)... - Ex: dt=2, so compare frames (1,3),(3,5),(5,7)... - Ex: dt=3, so compare frames (1,4),(4,7),(7,10)... """ rep = [] for i in range(int(round((totalFrames - 1) / float(dt)))): if (dt * i + dt < totalFrames): rep.append(self._sameMolecTandDT( selection, dt * i, (dt * i) + dt)) return rep def _getOneDeltaPoint(self, universe, repInd, i, t0, dt): """ Gives one point to calculate the mean and gets one point of the plot C_vect vs t. - Ex: t0=1 and dt=1 so calculate the t0-dt=1-2 interval. - Ex: t0=5 and dt=3 so calcultate the t0-dt=5-8 interva i = come from getMeanOnePoint (named j) (int) """ valO = 0 n = 0 for j in range(len(repInd[i]) // 3): begj = 3 * j universe.trajectory[t0] # Plus zero is to avoid 0to be equal to 0tp Ot0 = repInd[i][begj].position + 0 universe.trajectory[t0 + dt] # Plus zero is to avoid 0to be equal to 0tp Otp = repInd[i][begj].position + 0 # position oxygen OVector = Ot0 - Otp # here it is the difference with # waterdynamics.WaterOrientationalRelaxation valO += np.dot(OVector, OVector) n += 1 # if no water molecules remain in selection, there is nothing to get # the mean, so n = 0. return valO/n if n > 0 else 0 def _getMeanOnePoint(self, universe, selection1, selection_str, dt, totalFrames): """ This function gets one point of the plot C_vec vs t. It's uses the _getOneDeltaPoint() function to calculate the average. """ repInd = self._repeatedIndex(selection1, dt, totalFrames) sumsdt = 0 n = 0.0 sumDeltaO = 0.0 valOList = [] for j in range(totalFrames // dt - 1): a = self._getOneDeltaPoint(universe, repInd, j, sumsdt, dt) sumDeltaO += a valOList.append(a) sumsdt += dt n += 1 # if no water molecules remain in selection, there is nothing to get # the mean, so n = 0. return sumDeltaO/n if n > 0 else 0 def _sameMolecTandDT(self, selection, t0d, tf): """ Compare the molecules in the t0d selection and the t0d+dt selection and select only the particles that are repeated in both frame. This is to consider only the molecules that remains in the selection after the dt time has elapsed. The result is a list with the indexs of the atoms. """ a = set(selection[t0d]) b = set(selection[tf]) sort = sorted(list(a.intersection(b))) return sort def _selection_serial(self, universe, selection_str): selection = [] for ts in ProgressBar(universe.trajectory, verbose=True, total=universe.trajectory.n_frames): selection.append(universe.select_atoms(selection_str)) return selection def run(self, **kwargs): """Analyze trajectory and produce timeseries""" # All the selection to an array, this way is faster than selecting # later. if self.nproc == 1: selection_out = self._selection_serial( self.universe, self.selection) else: # parallel not yet implemented # selection = selection_parallel(universe, selection_str, nproc) selection_out = self._selection_serial( self.universe, self.selection) self.timeseries = [] for dt in list(range(1, self.dtmax + 1)): output = self._getMeanOnePoint( self.universe, selection_out, self.selection, dt, self.tf) self.timeseries.append(output) class SurvivalProbability(object): r""" Survival Probability (SP) gives the probability for a group of particles to remain in a certain region. The SP is given by: .. math:: P(\tau) = \frac1T \sum_{t=1}^T \frac{N(t,t+\tau)}{N(t)} where :math:`T` is the maximum time of simulation, :math:`\tau` is the timestep, :math:`N(t)` the number of particles at time :math:`t`, and :math:`N(t, t+\tau)` is the number of particles at every frame from :math:`t` to `\tau`. Parameters ---------- universe : Universe Universe object select : str Selection string; any selection is allowed. With this selection you define the region/zone where to analyze, e.g.: "resname SOL and around 5 (resid 10)". See `SP-examples`_. verbose : Boolean, optional When True, prints progress and comments to the console. Notes ----- Currently :class:`SurvivalProbability` is the only on in :mod:`MDAnalysis.analysis.waterdynamics` to support an `exclusive` behaviour (i.e. similar to the current behaviour of :class:`AnalysisBase` to the `stop` keyword passed to :meth:`SurvivalProbability.run`. Unlike other :mod:`MDAnalysis.analysis.waterdynamics` final frame definitions which are `inclusive`. .. versionadded:: 0.11.0 .. versionchanged:: 1.0.0 Using the MDAnalysis.lib.correlations.py to carry out the intermittency and autocorrelation calculations. Changed `selection` keyword to `select`. Removed support for the deprecated `t0`, `tf`, and `dtmax` keywords. These should instead be passed to :meth:`SurvivalProbability.run` as the `start`, `stop`, and `tau_max` keywords respectively. The `stop` keyword as passed to :meth:`SurvivalProbability.run` has now changed behaviour and will act in an `exclusive` manner (instead of it's previous `inclusive` behaviour), """ def __init__(self, universe, select, verbose=False): self.universe = universe self.selection = select self.verbose = verbose def run(self, tau_max=20, start=None, stop=None, step=None, residues=False, intermittency=0, verbose=False): """ Computes and returns the Survival Probability (SP) timeseries Parameters ---------- start : int, optional Zero-based index of the first frame to be analysed, Default: None (first frame). stop : int, optional Zero-based index of the last frame to be analysed (exclusive), Default: None (last frame). step : int, optional Jump every `step`-th frame. This is compatible but independant of the taus used, and it is good to consider using the `step` equal to `tau_max` to remove the overlap. Note that `step` and `tau_max` work consistently with intermittency. Default: None (use every frame). tau_max : int, optional Survival probability is calculated for the range 1 <= `tau` <= `tau_max`. residues : Boolean, optional If true, the analysis will be carried out on the residues (.resids) rather than on atom (.ids). A single atom is sufficient to classify the residue as within the distance. intermittency : int, optional The maximum number of consecutive frames for which an atom can leave but be counted as present if it returns at the next frame. An intermittency of `0` is equivalent to a continuous survival probability, which does not allow for the leaving and returning of atoms. For example, for `intermittency=2`, any given atom may leave a region of interest for up to two consecutive frames yet be treated as being present at all frames. The default is continuous (0). verbose : Boolean, optional Print the progress to the console. Returns ------- tau_timeseries : list tau from 1 to `tau_max`. Saved in the field tau_timeseries. sp_timeseries : list survival probability for each value of `tau`. Saved in the field sp_timeseries. sp_timeseries_data: list raw datapoints from which the average is taken (sp_timeseries). Time dependancy and distribution can be extracted. .. versionchanged:: 1.0.0 To math other analysis methods, the `stop` keyword is now exclusive rather than inclusive. """ start, stop, step = self.universe.trajectory.check_slice_indices( start, stop, step ) if tau_max > (stop - start): raise ValueError("Too few frames selected for given tau_max.") # preload the frames (atom IDs) to a list of sets self._selected_ids = [] # fixme - to parallise: the section should be rewritten so that this loop only creates a list of indices, # on which the parallel _single_frame can be applied. # skip frames that will not be used in order to improve performance # because AtomGroup.select_atoms is the most expensive part of this calculation # Example: step 5 and tau 2: LLLSS LLLSS, ... where L = Load, and S = Skip # Intermittency means that we have to load the extra frames to know if the atom is actually missing. # Say step=5 and tau=1, intermittency=0: LLSSS LLSSS # Say step=5 and tau=1, intermittency=1: LLLSL LLLSL frame_loaded_counter = 0 # only for the first window (frames before t are not used) frames_per_window = tau_max + 1 + intermittency # This number will apply after the first windows was loaded frames_per_window_subsequent = (tau_max + 1) + (2 * intermittency) num_frames_to_skip = max(step - frames_per_window_subsequent, 0) frame_no = start while frame_no < stop: # we have already added 1 to stop, therefore < if num_frames_to_skip != 0 and frame_loaded_counter == frames_per_window: logger.info("Skipping the next %d frames:", num_frames_to_skip) frame_no += num_frames_to_skip frame_loaded_counter = 0 # Correct the number of frames to be loaded after the first window (which starts at t=0, and # intermittency does not apply to the frames before) frames_per_window = frames_per_window_subsequent continue # update the frame number self.universe.trajectory[frame_no] logger.info("Loading frame: %d", self.universe.trajectory.frame) atoms = self.universe.select_atoms(self.selection) # SP of residues or of atoms ids = atoms.residues.resids if residues else atoms.ids self._selected_ids.append(set(ids)) frame_no += 1 frame_loaded_counter += 1 # adjust for the frames that were not loaded (step>tau_max + 1), # and for extra frames that were loaded (intermittency) window_jump = step - num_frames_to_skip self._intermittent_selected_ids = correct_intermittency(self._selected_ids, intermittency=intermittency) tau_timeseries, sp_timeseries, sp_timeseries_data = autocorrelation(self._intermittent_selected_ids, tau_max, window_jump) # warn the user if the NaN are found if all(np.isnan(sp_timeseries[1:])): logger.warning('NaN Error: Most likely data was not found. Check your atom selections. ') # user can investigate the distribution and sample size self.sp_timeseries_data = sp_timeseries_data self.tau_timeseries = tau_timeseries self.sp_timeseries = sp_timeseries return self
MDAnalysis/mdanalysis
package/MDAnalysis/analysis/waterdynamics.py
Python
gpl-2.0
41,156
/* * gitg-debug.c * This file is part of gitg - git repository viewer * * Copyright (C) 2009 - Jesse van den Kieboom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ #include "gitg-debug.h" #include <glib.h> static guint debug_enabled = GITG_DEBUG_NONE; #define DEBUG_FROM_ENV(name) \ { \ if (g_getenv(#name)) \ debug_enabled |= name; \ } void gitg_debug_init() { DEBUG_FROM_ENV(GITG_DEBUG_RUNNER); } gboolean gitg_debug_enabled(guint debug) { return debug_enabled & debug; }
nacho/gitg
libgitg/gitg-debug.c
C
gpl-2.0
1,183
var mongoose = require('mongoose'); var Schema = mongoose.Schema; var ObjectId = Schema.Types.ObjectId; var beerSchema = new Schema({ name: String, categoryId: ObjectId, description: String, stars: Number, categoryIdString: String }); var Beer = mongoose.model('Beer', beerSchema); module.exports = Beer;
HomeTap/HomeTap
models/beer.js
JavaScript
gpl-2.0
318
// $Id: DeploymentDiagramRenderer.java 7783 2005-02-20 21:55:19Z linus $ // Copyright (c) 2003-2005 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this // software and its documentation without fee, and without a written // agreement is hereby granted, provided that the above copyright notice // and this paragraph appear in all copies. This software program and // documentation are copyrighted by The Regents of the University of // California. The software program and documentation are supplied "AS // IS", without any accompanying services from The Regents. The Regents // does not warrant that the operation of the program will be // uninterrupted or error-free. The end-user understands that the program // was developed for research purposes and is advised not to rely // exclusively on the program for any reason. IN NO EVENT SHALL THE // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. package org.argouml.uml.diagram.deployment.ui; import java.util.Collection; import java.util.Map; import org.apache.log4j.Logger; import org.argouml.model.Model; import org.argouml.uml.diagram.UmlDiagramRenderer; import org.argouml.uml.diagram.static_structure.ui.CommentEdge; import org.argouml.uml.diagram.static_structure.ui.FigClass; import org.argouml.uml.diagram.static_structure.ui.FigComment; import org.argouml.uml.diagram.static_structure.ui.FigEdgeNote; import org.argouml.uml.diagram.static_structure.ui.FigInterface; import org.argouml.uml.diagram.static_structure.ui.FigLink; import org.argouml.uml.diagram.ui.FigAssociation; import org.argouml.uml.diagram.ui.FigAssociationClass; import org.argouml.uml.diagram.ui.FigAssociationEnd; import org.argouml.uml.diagram.ui.FigDependency; import org.argouml.uml.diagram.ui.FigGeneralization; import org.argouml.uml.diagram.ui.FigNodeAssociation; import org.tigris.gef.base.Layer; import org.tigris.gef.graph.GraphModel; import org.tigris.gef.presentation.FigEdge; import org.tigris.gef.presentation.FigNode; /** * This class defines a renderer object for UML Deployment Diagrams. * */ public class DeploymentDiagramRenderer extends UmlDiagramRenderer { /** * Logger. */ private static final Logger LOG = Logger.getLogger(DeploymentDiagramRenderer.class); /** * Return a Fig that can be used to represent the given node. * * @see org.tigris.gef.graph.GraphNodeRenderer#getFigNodeFor( * org.tigris.gef.graph.GraphModel, org.tigris.gef.base.Layer, * java.lang.Object, java.util.Map) */ public FigNode getFigNodeFor( GraphModel gm, Layer lay, Object node, Map styleAttributes) { if (Model.getFacade().isANode(node)) { return new FigMNode(gm, node); } else if (Model.getFacade().isAAssociation(node)) { return new FigNodeAssociation(gm, node); } else if (Model.getFacade().isANodeInstance(node)) { return new FigMNodeInstance(gm, node); } else if (Model.getFacade().isAComponent(node)) { return new FigComponent(gm, node); } else if (Model.getFacade().isAComponentInstance(node)) { return new FigComponentInstance(gm, node); } else if (Model.getFacade().isAClass(node)) { return new FigClass(gm, node); } else if (Model.getFacade().isAInterface(node)) { return new FigInterface(gm, node); } else if (Model.getFacade().isAObject(node)) { return new FigObject(gm, node); } else if (Model.getFacade().isAComment(node)) { return new FigComment(gm, node); } LOG.debug("TODO: DeploymentDiagramRenderer getFigNodeFor"); return null; } /** * Return a Fig that can be used to represent the given edge. * * @see org.tigris.gef.graph.GraphEdgeRenderer#getFigEdgeFor( * org.tigris.gef.graph.GraphModel, org.tigris.gef.base.Layer, * java.lang.Object, java.util.Map) */ public FigEdge getFigEdgeFor( GraphModel gm, Layer lay, Object edge, Map styleAttributes) { if (Model.getFacade().isAAssociationClass(edge)) { FigAssociationClass ascCFig = new FigAssociationClass(edge, lay); return ascCFig; } else if (Model.getFacade().isAAssociation(edge)) { Object asc = /*(MAssociation)*/ edge; FigAssociation ascFig = new FigAssociation(asc, lay); return ascFig; } else if (Model.getFacade().isAAssociationEnd(edge)) { FigAssociationEnd asend = new FigAssociationEnd(edge, lay); Model.getFacade().getAssociation(edge); FigNode associationFN = (FigNode) lay.presentationFor(Model .getFacade().getAssociation(edge)); FigNode classifierFN = (FigNode) lay.presentationFor(Model .getFacade().getType(edge)); asend.setSourcePortFig(associationFN); asend.setSourceFigNode(associationFN); asend.setDestPortFig(classifierFN); asend.setDestFigNode(classifierFN); return asend; } if (Model.getFacade().isALink(edge)) { Object lnk = /*(MLink)*/ edge; FigLink lnkFig = new FigLink(lnk); Collection linkEnds = Model.getFacade().getConnections(lnk); if (linkEnds == null) { LOG.debug("null linkRoles...."); } Object[] leArray = linkEnds.toArray(); Object fromEnd = leArray[0]; Object fromInst = Model.getFacade().getInstance(fromEnd); Object toEnd = leArray[1]; Object toInst = Model.getFacade().getInstance(toEnd); FigNode fromFN = (FigNode) lay.presentationFor(fromInst); FigNode toFN = (FigNode) lay.presentationFor(toInst); lnkFig.setSourcePortFig(fromFN); lnkFig.setSourceFigNode(fromFN); lnkFig.setDestPortFig(toFN); lnkFig.setDestFigNode(toFN); return lnkFig; } if (Model.getFacade().isADependency(edge)) { Object dep = /*(MDependency)*/ edge; FigDependency depFig = new FigDependency(dep); Object supplier = ((Model.getFacade().getSuppliers(dep).toArray())[0]); Object client = ((Model.getFacade().getClients(dep).toArray())[0]); FigNode supFN = (FigNode) lay.presentationFor(supplier); FigNode cliFN = (FigNode) lay.presentationFor(client); depFig.setSourcePortFig(cliFN); depFig.setSourceFigNode(cliFN); depFig.setDestPortFig(supFN); depFig.setDestFigNode(supFN); depFig.getFig().setDashed(true); return depFig; } if (Model.getFacade().isAGeneralization(edge)) { Object gen = /*(MGeneralization)*/ edge; FigGeneralization genFig = new FigGeneralization(gen, lay); return genFig; } if (edge instanceof CommentEdge) { return new FigEdgeNote(edge, lay); } return null; } static final long serialVersionUID = 8002278834226522224L; }
carvalhomb/tsmells
sample/argouml/argouml/org/argouml/uml/diagram/deployment/ui/DeploymentDiagramRenderer.java
Java
gpl-2.0
7,999
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_65) on Fri Dec 05 16:00:20 CET 2014 --> <TITLE> Uses of Class healpix.essentials.Constants </TITLE> <META NAME="date" CONTENT="2014-12-05"> <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="Uses of Class healpix.essentials.Constants"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <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="../../../healpix/essentials/Constants.html" title="class in healpix.essentials"><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?healpix/essentials//class-useConstants.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Constants.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> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <CENTER> <H2> <B>Uses of Class<br>healpix.essentials.Constants</B></H2> </CENTER> No usage of healpix.essentials.Constants <P> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <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="navbar_bottom_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="../../../healpix/essentials/Constants.html" title="class in healpix.essentials"><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> "Built from revision exported"</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?healpix/essentials//class-useConstants.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Constants.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> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>
orlanthi/healpix
doc/html/java/healpix/essentials/class-use/Constants.html
HTML
gpl-2.0
5,732
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <TITLE> Uses of Class com.google.gwt.user.cellview.client.CellBasedWidgetImplStandardBase (Google Web Toolkit Javadoc) </TITLE> <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="Uses of Class com.google.gwt.user.cellview.client.CellBasedWidgetImplStandardBase (Google Web Toolkit Javadoc)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <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="../../../../../../../com/google/gwt/user/cellview/client/CellBasedWidgetImplStandardBase.html" title="class in com.google.gwt.user.cellview.client"><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> GWT 2.6.0</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?com/google/gwt/user/cellview/client//class-useCellBasedWidgetImplStandardBase.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="CellBasedWidgetImplStandardBase.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> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <CENTER> <H2> <B>Uses of Class<br>com.google.gwt.user.cellview.client.CellBasedWidgetImplStandardBase</B></H2> </CENTER> No usage of com.google.gwt.user.cellview.client.CellBasedWidgetImplStandardBase <P> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <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="navbar_bottom_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="../../../../../../../com/google/gwt/user/cellview/client/CellBasedWidgetImplStandardBase.html" title="class in com.google.gwt.user.cellview.client"><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> GWT 2.6.0</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?com/google/gwt/user/cellview/client//class-useCellBasedWidgetImplStandardBase.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="CellBasedWidgetImplStandardBase.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> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>
JakaCikac/dScrum
web/WEB-INF/classes/gwt-2.6.0/doc/javadoc/com/google/gwt/user/cellview/client/class-use/CellBasedWidgetImplStandardBase.html
HTML
gpl-2.0
6,253
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/init.h> #include <linux/err.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/time.h> #include <linux/wait.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/dma-mapping.h> #include <sound/core.h> #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/pcm.h> #include <sound/initval.h> #include <sound/control.h> #include <sound/q6adm.h> #include <asm/dma.h> #include <linux/memory_alloc.h> #include "msm-pcm-afe.h" #include "msm-pcm-q6.h" #define MIN_PERIOD_SIZE (128 * 2) #define MAX_PERIOD_SIZE (128 * 2 * 2 * 6) static struct snd_pcm_hardware msm_afe_hardware = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED), .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE, .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 SNDRV_PCM_RATE_192000), .rate_min = 8000, .rate_max = 192000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = MAX_PERIOD_SIZE * 32, .period_bytes_min = MIN_PERIOD_SIZE, .period_bytes_max = MAX_PERIOD_SIZE, .periods_min = 32, .periods_max = 384, .fifo_size = 0, }; static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt); static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt); static void q6asm_event_handler(uint32_t opcode, uint32_t token, uint32_t *payload, void *priv) { } static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt) { struct pcm_afe_info *prtd = container_of(hrt, struct pcm_afe_info, hrt); struct snd_pcm_substream *substream = prtd->substream; struct snd_pcm_runtime *runtime = substream->runtime; if (prtd->start) { pr_debug("sending frame to DSP: poll_time: %d\n", prtd->poll_time); if (prtd->dsp_cnt == runtime->periods) prtd->dsp_cnt = 0; afe_rt_proxy_port_write( (prtd->dma_addr + (prtd->dsp_cnt * snd_pcm_lib_period_bytes(prtd->substream))), snd_pcm_lib_period_bytes(prtd->substream)); prtd->dsp_cnt++; hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time * 1000)); return HRTIMER_RESTART; } else return HRTIMER_NORESTART; } static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt) { struct pcm_afe_info *prtd = container_of(hrt, struct pcm_afe_info, hrt); struct snd_pcm_substream *substream = prtd->substream; struct snd_pcm_runtime *runtime = substream->runtime; if (prtd->start) { if (prtd->dsp_cnt == runtime->periods) prtd->dsp_cnt = 0; afe_rt_proxy_port_read( (prtd->dma_addr + (prtd->dsp_cnt * snd_pcm_lib_period_bytes(prtd->substream))), snd_pcm_lib_period_bytes(prtd->substream)); prtd->dsp_cnt++; pr_debug("sending frame rec to DSP: poll_time: %d\n", prtd->poll_time); hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time * 1000)); return HRTIMER_RESTART; } else return HRTIMER_NORESTART; } static void pcm_afe_process_tx_pkt(uint32_t opcode, uint32_t token, uint32_t *payload, void *priv) { struct pcm_afe_info *prtd = priv; unsigned long dsp_flags; struct snd_pcm_substream *substream = NULL; struct snd_pcm_runtime *runtime = NULL; uint16_t event; if (prtd == NULL) return; substream = prtd->substream; runtime = substream->runtime; pr_debug("%s\n", __func__); spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); switch (opcode) { case AFE_EVENT_RT_PROXY_PORT_STATUS: { event = (uint16_t)((0xFFFF0000 & payload[0]) >> 0x10); switch (event) { case AFE_EVENT_RTPORT_START: { prtd->dsp_cnt = 0; prtd->poll_time = ((unsigned long)(( snd_pcm_lib_period_bytes (prtd->substream) * 1000 * 1000)/ (runtime->rate * runtime->channels * 2))); pr_debug("prtd->poll_time: %d", prtd->poll_time); break; } case AFE_EVENT_RTPORT_STOP: pr_debug("%s: event!=0\n", __func__); prtd->start = 0; snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); break; case AFE_EVENT_RTPORT_LOW_WM: pr_debug("%s: Underrun\n", __func__); break; case AFE_EVENT_RTPORT_HI_WM: pr_debug("%s: Overrun\n", __func__); break; default: break; } break; } case APR_BASIC_RSP_RESULT: { switch (payload[0]) { case AFE_SERVICE_CMD_RTPORT_WR: pr_debug("write done\n"); prtd->pcm_irq_pos += snd_pcm_lib_period_bytes (prtd->substream); snd_pcm_period_elapsed(prtd->substream); break; default: break; } break; } default: break; } spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); } static void pcm_afe_process_rx_pkt(uint32_t opcode, uint32_t token, uint32_t *payload, void *priv) { struct pcm_afe_info *prtd = priv; unsigned long dsp_flags; struct snd_pcm_substream *substream = NULL; struct snd_pcm_runtime *runtime = NULL; uint16_t event; if (prtd == NULL) return; substream = prtd->substream; runtime = substream->runtime; pr_debug("%s\n", __func__); spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); switch (opcode) { case AFE_EVENT_RT_PROXY_PORT_STATUS: { event = (uint16_t)((0xFFFF0000 & payload[0]) >> 0x10); switch (event) { case AFE_EVENT_RTPORT_START: { prtd->dsp_cnt = 0; prtd->poll_time = ((unsigned long)(( snd_pcm_lib_period_bytes(prtd->substream) * 1000 * 1000)/(runtime->rate * runtime->channels * 2))); pr_debug("prtd->poll_time : %d", prtd->poll_time); break; } case AFE_EVENT_RTPORT_STOP: pr_debug("%s: event!=0\n", __func__); prtd->start = 0; snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); break; case AFE_EVENT_RTPORT_LOW_WM: pr_debug("%s: Underrun\n", __func__); break; case AFE_EVENT_RTPORT_HI_WM: pr_debug("%s: Overrun\n", __func__); break; default: break; } break; } case APR_BASIC_RSP_RESULT: { switch (payload[0]) { case AFE_SERVICE_CMD_RTPORT_RD: pr_debug("Read done\n"); prtd->pcm_irq_pos += snd_pcm_lib_period_bytes (prtd->substream); snd_pcm_period_elapsed(prtd->substream); break; default: break; } break; } default: break; } spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); } static int msm_afe_playback_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct pcm_afe_info *prtd = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *dai = rtd->cpu_dai; int ret = 0; pr_debug("%s: sample_rate=%d\n", __func__, runtime->rate); pr_debug("%s: dai->id =%x\n", __func__, dai->id); ret = afe_register_get_events(dai->id, pcm_afe_process_tx_pkt, prtd); if (ret < 0) { pr_err("afe-pcm:register for events failed\n"); return ret; } pr_debug("%s:success\n", __func__); prtd->prepared++; return ret; } static int msm_afe_capture_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct pcm_afe_info *prtd = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *dai = rtd->cpu_dai; int ret = 0; pr_debug("%s\n", __func__); pr_debug("%s: dai->id =%x\n", __func__, dai->id); ret = afe_register_get_events(dai->id, pcm_afe_process_rx_pkt, prtd); if (ret < 0) { pr_err("afe-pcm:register for events failed\n"); return ret; } pr_debug("%s:success\n", __func__); prtd->prepared++; return 0; } /* Conventional and unconventional sample rate supported */ static unsigned int supported_sample_rates[] = { 8000, 16000, 48000 }; static struct snd_pcm_hw_constraint_list constraints_sample_rates = { .count = ARRAY_SIZE(supported_sample_rates), .list = supported_sample_rates, .mask = 0, }; static int msm_afe_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct pcm_afe_info *prtd = NULL; int ret = 0; prtd = kzalloc(sizeof(struct pcm_afe_info), GFP_KERNEL); if (prtd == NULL) { pr_err("Failed to allocate memory for msm_audio\n"); return -ENOMEM; } else pr_debug("prtd %x\n", (unsigned int)prtd); mutex_init(&prtd->lock); spin_lock_init(&prtd->dsp_lock); prtd->dsp_cnt = 0; mutex_lock(&prtd->lock); runtime->hw = msm_afe_hardware; prtd->substream = substream; runtime->private_data = prtd; prtd->audio_client = q6asm_audio_client_alloc( (app_cb)q6asm_event_handler, prtd); if (!prtd->audio_client) { pr_debug("%s: Could not allocate memory\n", __func__); mutex_unlock(&prtd->lock); kfree(prtd); return -ENOMEM; } hrtimer_init(&prtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) prtd->hrt.function = afe_hrtimer_callback; else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) prtd->hrt.function = afe_hrtimer_rec_callback; mutex_unlock(&prtd->lock); ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_sample_rates); if (ret < 0) pr_err("snd_pcm_hw_constraint_list failed\n"); /* Ensure that buffer size is a multiple of period size */ ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) pr_err("snd_pcm_hw_constraint_integer failed\n"); return 0; } static int msm_afe_close(struct snd_pcm_substream *substream) { int rc = 0; struct snd_dma_buffer *dma_buf; struct snd_pcm_runtime *runtime; struct pcm_afe_info *prtd; struct snd_soc_pcm_runtime *rtd = NULL; struct snd_soc_dai *dai = NULL; int dir = IN; int ret = 0; pr_debug("%s\n", __func__); if (substream == NULL) { pr_err("substream is NULL\n"); return -EINVAL; } rtd = substream->private_data; dai = rtd->cpu_dai; runtime = substream->runtime; prtd = runtime->private_data; mutex_lock(&prtd->lock); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { dir = IN; ret = afe_unregister_get_events(dai->id); if (ret < 0) pr_err("AFE unregister for events failed\n"); } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { dir = OUT; ret = afe_unregister_get_events(dai->id); if (ret < 0) pr_err("AFE unregister for events failed\n"); } hrtimer_cancel(&prtd->hrt); rc = afe_cmd_memory_unmap(runtime->dma_addr); if (rc < 0) pr_err("AFE memory unmap failed\n"); pr_debug("release all buffer\n"); dma_buf = &substream->dma_buffer; if (dma_buf == NULL) { pr_debug("dma_buf is NULL\n"); goto done; } if (dma_buf->area) { dma_buf->area = NULL; } q6asm_audio_client_buf_free_contiguous(dir, prtd->audio_client); done: pr_debug("%s: dai->id =%x\n", __func__, dai->id); q6asm_audio_client_free(prtd->audio_client); mutex_unlock(&prtd->lock); prtd->prepared--; kfree(prtd); return 0; } static int msm_afe_prepare(struct snd_pcm_substream *substream) { int ret = 0; struct snd_pcm_runtime *runtime = substream->runtime; struct pcm_afe_info *prtd = runtime->private_data; prtd->pcm_irq_pos = 0; if (prtd->prepared) return 0; mutex_lock(&prtd->lock); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ret = msm_afe_playback_prepare(substream); else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) ret = msm_afe_capture_prepare(substream); mutex_unlock(&prtd->lock); return ret; } static int msm_afe_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma) { struct snd_pcm_runtime *runtime = substream->runtime; struct pcm_afe_info *prtd = runtime->private_data; int result = 0; pr_debug("%s\n", __func__); prtd->mmap_flag = 1; if (runtime->dma_addr && runtime->dma_bytes) { vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); result = remap_pfn_range(vma, vma->vm_start, runtime->dma_addr >> PAGE_SHIFT, runtime->dma_bytes, vma->vm_page_prot); } else { pr_err("Physical address or size of buf is NULL"); return -EINVAL; } return result; } static int msm_afe_trigger(struct snd_pcm_substream *substream, int cmd) { int ret = 0; struct snd_pcm_runtime *runtime = substream->runtime; struct pcm_afe_info *prtd = runtime->private_data; switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: pr_debug("%s: SNDRV_PCM_TRIGGER_START\n", __func__); prtd->start = 1; hrtimer_start(&prtd->hrt, ns_to_ktime(0), HRTIMER_MODE_REL); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: pr_debug("%s: SNDRV_PCM_TRIGGER_STOP\n", __func__); prtd->start = 0; break; default: ret = -EINVAL; break; } return ret; } static int msm_afe_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_dma_buffer *dma_buf = &substream->dma_buffer; struct pcm_afe_info *prtd = runtime->private_data; struct audio_buffer *buf; int dir, ret; pr_debug("%s:\n", __func__); mutex_lock(&prtd->lock); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) dir = IN; else dir = OUT; ret = q6asm_audio_client_buf_alloc_contiguous(dir, prtd->audio_client, runtime->hw.period_bytes_min, runtime->hw.periods_max); if (ret < 0) { pr_err("Audio Start: Buffer Allocation failed rc = %d\n", ret); mutex_unlock(&prtd->lock); return -ENOMEM; } buf = prtd->audio_client->port[dir].buf; if (buf == NULL || buf[0].data == NULL) { mutex_unlock(&prtd->lock); return -ENOMEM; } pr_debug("%s:buf = %p\n", __func__, buf); dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; dma_buf->dev.dev = substream->pcm->card->dev; dma_buf->private_data = NULL; dma_buf->area = buf[0].data; dma_buf->addr = buf[0].phys; dma_buf->bytes = runtime->hw.buffer_bytes_max; if (!dma_buf->area) { pr_err("%s:MSM AFE physical memory allocation failed\n", __func__); mutex_unlock(&prtd->lock); return -ENOMEM; } memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max); prtd->dma_addr = (u32) dma_buf->addr; mutex_unlock(&prtd->lock); snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); ret = afe_cmd_memory_map(dma_buf->addr, dma_buf->bytes); if (ret < 0) pr_err("fail to map memory to DSP\n"); return ret; } static snd_pcm_uframes_t msm_afe_pointer(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct pcm_afe_info *prtd = runtime->private_data; if (prtd->pcm_irq_pos >= snd_pcm_lib_buffer_bytes(substream)) prtd->pcm_irq_pos = 0; pr_debug("pcm_irq_pos = %d\n", prtd->pcm_irq_pos); return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); } static struct snd_pcm_ops msm_afe_ops = { .open = msm_afe_open, .hw_params = msm_afe_hw_params, .trigger = msm_afe_trigger, .close = msm_afe_close, .prepare = msm_afe_prepare, .mmap = msm_afe_mmap, .pointer = msm_afe_pointer, }; static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; int ret = 0; pr_debug("%s\n", __func__); if (!card->dev->coherent_dma_mask) card->dev->coherent_dma_mask = DMA_BIT_MASK(32); return ret; } static int msm_afe_afe_probe(struct snd_soc_platform *platform) { pr_debug("%s\n", __func__); return 0; } static struct snd_soc_platform_driver msm_soc_platform = { .ops = &msm_afe_ops, .pcm_new = msm_asoc_pcm_new, .probe = msm_afe_afe_probe, }; static __devinit int msm_afe_probe(struct platform_device *pdev) { pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); return snd_soc_register_platform(&pdev->dev, &msm_soc_platform); } static int msm_afe_remove(struct platform_device *pdev) { pr_debug("%s\n", __func__); snd_soc_unregister_platform(&pdev->dev); return 0; } static struct platform_driver msm_afe_driver = { .driver = { .name = "msm-pcm-afe", .owner = THIS_MODULE, }, .probe = msm_afe_probe, .remove = __devexit_p(msm_afe_remove), }; static int __init msm_soc_platform_init(void) { pr_debug("%s\n", __func__); return platform_driver_register(&msm_afe_driver); } module_init(msm_soc_platform_init); static void __exit msm_soc_platform_exit(void) { pr_debug("%s\n", __func__); platform_driver_unregister(&msm_afe_driver); } module_exit(msm_soc_platform_exit); MODULE_DESCRIPTION("AFE PCM module platform driver"); MODULE_LICENSE("GPL v2");
vovanx500/ConceptKernel
sound/soc/msm/msm-pcm-afe.c
C
gpl-2.0
16,825
#!/usr/bin/env python # encoding: utf-8 import sys import argparse if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-m", "--m_number", dest = "m", help = "pleaer enter the m...", type = int) parser.add_argument("-n", "--n_number", dest = "n", help = "pleaer enter the n...", type = int) args = parser.parse_args() print "%d ^ %d = %d" % (args.m, args.n, args.m ** args.n)
gatieme/AderXCoding
language/python/argparse/m-n3.py
Python
gpl-2.0
435
/* * File name: kstdcleanup.h * Summary: Support classes for KDirStat * License: LGPL - See file COPYING.LIB for details. * Author: Stefan Hundhammer <sh@suse.de> * * Updated: 2008-11-27 */ #ifndef KStdCleanup_h #define KStdCleanup_h #ifdef HAVE_CONFIG_H # include <config.h> #endif // Forward declarations class KActionCollection; namespace KDirStat { /** * Predefined standard @ref KCleanup actions to be performed on * @ref KDirTree items. * * This class is not meant to be ever instantiated - use the static methods * only. * * For details about what each individual method does, refer to the help * file. Use the old (KDirStat 0.86) help file in case the current help * file isn't available yet. * * @short KDirStat standard cleanup actions **/ class KStdCleanup { public: static KCleanup *openInKonqueror ( KActionCollection *parent = 0 ); static KCleanup *openInTerminal ( KActionCollection *parent = 0 ); static KCleanup *compressSubtree ( KActionCollection *parent = 0 ); static KCleanup *makeClean ( KActionCollection *parent = 0 ); static KCleanup *deleteTrash ( KActionCollection *parent = 0 ); static KCleanup *moveToTrashBin ( KActionCollection *parent = 0 ); static KCleanup *hardDelete ( KActionCollection *parent = 0 ); private: /** * Prevent instances of this class - private constructor / destructor. **/ KStdCleanup() {} ~KStdCleanup() {} }; } // namespace KDirStat #endif // ifndef KStdCleanup_h // EOF
shundhammer/kdirstat
kdirstat/kstdcleanup.h
C
gpl-2.0
1,566
/* sun3lance.c: Ethernet driver for SUN3 Lance chip */ /* Sun3 Lance ethernet driver, by Sam Creasey (sammy@users.qual.net). This driver is a part of the linux kernel, and is thus distributed under the GNU General Public License. The values used in LANCE_OBIO and LANCE_IRQ seem to be empirically true for the correct IRQ and address of the lance registers. They have not been widely tested, however. What we probably need is a "proper" way to search for a device in the sun3's prom, but, alas, linux has no such thing. This driver is largely based on atarilance.c, by Roman Hodek. Other sources of inspiration were the NetBSD sun3 am7990 driver, and the linux sparc lance driver (sunlance.c). There are more assumptions made throughout this driver, it almost certainly still needs work, but it does work at least for RARP/BOOTP and mounting the root NFS filesystem. */ static char *version = "sun3lance.c: v1.2 1/12/2001 Sam Creasey (sammy@sammy.net)\n"; #include <linux/module.h> #include <linux/stddef.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/ioport.h> #include <linux/delay.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <asm/setup.h> #include <asm/irq.h> #include <asm/bitops.h> #include <asm/io.h> #include <asm/pgtable.h> #include <asm/pgalloc.h> #include <asm/dvma.h> #include <asm/idprom.h> #include <asm/machines.h> #ifdef CONFIG_SUN3 #include <asm/sun3mmu.h> #else #include <asm/sun3xprom.h> #endif /* sun3/60 addr/irq for the lance chip. If your sun is different, change this. */ #define LANCE_OBIO 0x120000 #define LANCE_IRQ IRQ3 /* Debug level: * 0 = silent, print only serious errors * 1 = normal, print error messages * 2 = debug, print debug infos * 3 = debug, print even more debug infos (packet data) */ #define LANCE_DEBUG 0 #ifdef LANCE_DEBUG static int lance_debug = LANCE_DEBUG; #else static int lance_debug = 1; #endif MODULE_PARM(lance_debug, "i"); MODULE_PARM_DESC(lance_debug, "SUN3 Lance debug level (0-3)"); MODULE_LICENSE("GPL"); #define DPRINTK(n,a) \ do { \ if (lance_debug >= n) \ printk a; \ } while( 0 ) /* we're only using 32k of memory, so we use 4 TX buffers and 16 RX buffers. These values are expressed as log2. */ #define TX_LOG_RING_SIZE 3 #define RX_LOG_RING_SIZE 5 /* These are the derived values */ #define TX_RING_SIZE (1 << TX_LOG_RING_SIZE) #define TX_RING_LEN_BITS (TX_LOG_RING_SIZE << 5) #define TX_RING_MOD_MASK (TX_RING_SIZE - 1) #define RX_RING_SIZE (1 << RX_LOG_RING_SIZE) #define RX_RING_LEN_BITS (RX_LOG_RING_SIZE << 5) #define RX_RING_MOD_MASK (RX_RING_SIZE - 1) /* Definitions for packet buffer access: */ #define PKT_BUF_SZ 1544 /* Get the address of a packet buffer corresponding to a given buffer head */ #define PKTBUF_ADDR(head) (void *)((unsigned long)(MEM) | (head)->base) /* The LANCE Rx and Tx ring descriptors. */ struct lance_rx_head { unsigned short base; /* Low word of base addr */ volatile unsigned char flag; unsigned char base_hi; /* High word of base addr (unused) */ short buf_length; /* This length is 2s complement! */ volatile short msg_length; /* This length is "normal". */ }; struct lance_tx_head { unsigned short base; /* Low word of base addr */ volatile unsigned char flag; unsigned char base_hi; /* High word of base addr (unused) */ short length; /* Length is 2s complement! */ volatile short misc; }; /* The LANCE initialization block, described in databook. */ struct lance_init_block { unsigned short mode; /* Pre-set mode */ unsigned char hwaddr[6]; /* Physical ethernet address */ unsigned int filter[2]; /* Multicast filter (unused). */ /* Receive and transmit ring base, along with length bits. */ unsigned short rdra; unsigned short rlen; unsigned short tdra; unsigned short tlen; unsigned short pad[4]; /* is thie needed? */ }; /* The whole layout of the Lance shared memory */ struct lance_memory { struct lance_init_block init; struct lance_tx_head tx_head[TX_RING_SIZE]; struct lance_rx_head rx_head[RX_RING_SIZE]; char rx_data[RX_RING_SIZE][PKT_BUF_SZ]; char tx_data[TX_RING_SIZE][PKT_BUF_SZ]; }; /* The driver's private device structure */ struct lance_private { volatile unsigned short *iobase; struct lance_memory *mem; int new_rx, new_tx; /* The next free ring entry */ int old_tx, old_rx; /* ring entry to be processed */ struct net_device_stats stats; /* These two must be longs for set_bit() */ long tx_full; long lock; }; /* I/O register access macros */ #define MEM lp->mem #define DREG lp->iobase[0] #define AREG lp->iobase[1] #define REGA(a) ( AREG = (a), DREG ) /* Definitions for the Lance */ /* tx_head flags */ #define TMD1_ENP 0x01 /* end of packet */ #define TMD1_STP 0x02 /* start of packet */ #define TMD1_DEF 0x04 /* deferred */ #define TMD1_ONE 0x08 /* one retry needed */ #define TMD1_MORE 0x10 /* more than one retry needed */ #define TMD1_ERR 0x40 /* error summary */ #define TMD1_OWN 0x80 /* ownership (set: chip owns) */ #define TMD1_OWN_CHIP TMD1_OWN #define TMD1_OWN_HOST 0 /* tx_head misc field */ #define TMD3_TDR 0x03FF /* Time Domain Reflectometry counter */ #define TMD3_RTRY 0x0400 /* failed after 16 retries */ #define TMD3_LCAR 0x0800 /* carrier lost */ #define TMD3_LCOL 0x1000 /* late collision */ #define TMD3_UFLO 0x4000 /* underflow (late memory) */ #define TMD3_BUFF 0x8000 /* buffering error (no ENP) */ /* rx_head flags */ #define RMD1_ENP 0x01 /* end of packet */ #define RMD1_STP 0x02 /* start of packet */ #define RMD1_BUFF 0x04 /* buffer error */ #define RMD1_CRC 0x08 /* CRC error */ #define RMD1_OFLO 0x10 /* overflow */ #define RMD1_FRAM 0x20 /* framing error */ #define RMD1_ERR 0x40 /* error summary */ #define RMD1_OWN 0x80 /* ownership (set: ship owns) */ #define RMD1_OWN_CHIP RMD1_OWN #define RMD1_OWN_HOST 0 /* register names */ #define CSR0 0 /* mode/status */ #define CSR1 1 /* init block addr (low) */ #define CSR2 2 /* init block addr (high) */ #define CSR3 3 /* misc */ #define CSR8 8 /* address filter */ #define CSR15 15 /* promiscuous mode */ /* CSR0 */ /* (R=readable, W=writeable, S=set on write, C=clear on write) */ #define CSR0_INIT 0x0001 /* initialize (RS) */ #define CSR0_STRT 0x0002 /* start (RS) */ #define CSR0_STOP 0x0004 /* stop (RS) */ #define CSR0_TDMD 0x0008 /* transmit demand (RS) */ #define CSR0_TXON 0x0010 /* transmitter on (R) */ #define CSR0_RXON 0x0020 /* receiver on (R) */ #define CSR0_INEA 0x0040 /* interrupt enable (RW) */ #define CSR0_INTR 0x0080 /* interrupt active (R) */ #define CSR0_IDON 0x0100 /* initialization done (RC) */ #define CSR0_TINT 0x0200 /* transmitter interrupt (RC) */ #define CSR0_RINT 0x0400 /* receiver interrupt (RC) */ #define CSR0_MERR 0x0800 /* memory error (RC) */ #define CSR0_MISS 0x1000 /* missed frame (RC) */ #define CSR0_CERR 0x2000 /* carrier error (no heartbeat :-) (RC) */ #define CSR0_BABL 0x4000 /* babble: tx-ed too many bits (RC) */ #define CSR0_ERR 0x8000 /* error (RC) */ /* CSR3 */ #define CSR3_BCON 0x0001 /* byte control */ #define CSR3_ACON 0x0002 /* ALE control */ #define CSR3_BSWP 0x0004 /* byte swap (1=big endian) */ /***************************** Prototypes *****************************/ static int lance_probe( struct net_device *dev); static int lance_open( struct net_device *dev ); static void lance_init_ring( struct net_device *dev ); static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev ); static irqreturn_t lance_interrupt( int irq, void *dev_id, struct pt_regs *fp ); static int lance_rx( struct net_device *dev ); static int lance_close( struct net_device *dev ); static struct net_device_stats *lance_get_stats( struct net_device *dev ); static void set_multicast_list( struct net_device *dev ); /************************* End of Prototypes **************************/ struct net_device * __init sun3lance_probe(int unit) { struct net_device *dev; static int found; int err = -ENODEV; /* check that this machine has an onboard lance */ switch(idprom->id_machtype) { case SM_SUN3|SM_3_50: case SM_SUN3|SM_3_60: case SM_SUN3X|SM_3_80: /* these machines have lance */ break; default: return ERR_PTR(-ENODEV); } if (found) return ERR_PTR(-ENODEV); dev = alloc_etherdev(sizeof(struct lance_private)); if (!dev) return ERR_PTR(-ENOMEM); if (unit >= 0) { sprintf(dev->name, "eth%d", unit); netdev_boot_setup_check(dev); } SET_MODULE_OWNER(dev); if (!lance_probe(dev)) goto out; err = register_netdev(dev); if (err) goto out1; found = 1; return dev; out1: #ifdef CONFIG_SUN3 iounmap((void *)dev->base_addr); #endif out: free_netdev(dev); return ERR_PTR(err); } static int __init lance_probe( struct net_device *dev) { unsigned long ioaddr; struct lance_private *lp; int i; static int did_version; volatile unsigned short *ioaddr_probe; unsigned short tmp1, tmp2; #ifdef CONFIG_SUN3 ioaddr = (unsigned long)ioremap(LANCE_OBIO, PAGE_SIZE); if (!ioaddr) return 0; #else ioaddr = SUN3X_LANCE; #endif /* test to see if there's really a lance here */ /* (CSRO_INIT shouldn't be readable) */ ioaddr_probe = (volatile unsigned short *)ioaddr; tmp1 = ioaddr_probe[0]; tmp2 = ioaddr_probe[1]; ioaddr_probe[1] = CSR0; ioaddr_probe[0] = CSR0_INIT | CSR0_STOP; if(ioaddr_probe[0] != CSR0_STOP) { ioaddr_probe[0] = tmp1; ioaddr_probe[1] = tmp2; #ifdef CONFIG_SUN3 iounmap((void *)ioaddr); #endif return 0; } lp = netdev_priv(dev); /* XXX - leak? */ MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000); lp->iobase = (volatile unsigned short *)ioaddr; dev->base_addr = (unsigned long)ioaddr; /* informational only */ REGA(CSR0) = CSR0_STOP; request_irq(LANCE_IRQ, lance_interrupt, SA_INTERRUPT, "SUN3 Lance", dev); dev->irq = (unsigned short)LANCE_IRQ; printk("%s: SUN3 Lance at io %#lx, mem %#lx, irq %d, hwaddr ", dev->name, (unsigned long)ioaddr, (unsigned long)MEM, dev->irq); /* copy in the ethernet address from the prom */ for(i = 0; i < 6 ; i++) dev->dev_addr[i] = idprom->id_ethaddr[i]; /* tell the card it's ether address, bytes swapped */ MEM->init.hwaddr[0] = dev->dev_addr[1]; MEM->init.hwaddr[1] = dev->dev_addr[0]; MEM->init.hwaddr[2] = dev->dev_addr[3]; MEM->init.hwaddr[3] = dev->dev_addr[2]; MEM->init.hwaddr[4] = dev->dev_addr[5]; MEM->init.hwaddr[5] = dev->dev_addr[4]; for( i = 0; i < 6; ++i ) printk( "%02x%s", dev->dev_addr[i], (i < 5) ? ":" : "\n" ); MEM->init.mode = 0x0000; MEM->init.filter[0] = 0x00000000; MEM->init.filter[1] = 0x00000000; MEM->init.rdra = dvma_vtob(MEM->rx_head); MEM->init.rlen = (RX_LOG_RING_SIZE << 13) | (dvma_vtob(MEM->rx_head) >> 16); MEM->init.tdra = dvma_vtob(MEM->tx_head); MEM->init.tlen = (TX_LOG_RING_SIZE << 13) | (dvma_vtob(MEM->tx_head) >> 16); DPRINTK(2, ("initaddr: %08lx rx_ring: %08lx tx_ring: %08lx\n", dvma_vtob(&(MEM->init)), dvma_vtob(MEM->rx_head), (dvma_vtob(MEM->tx_head)))); if (did_version++ == 0) printk( version ); /* The LANCE-specific entries in the device structure. */ dev->open = &lance_open; dev->hard_start_xmit = &lance_start_xmit; dev->stop = &lance_close; dev->get_stats = &lance_get_stats; dev->set_multicast_list = &set_multicast_list; dev->set_mac_address = 0; // KLUDGE -- REMOVE ME set_bit(__LINK_STATE_PRESENT, &dev->state); memset( &lp->stats, 0, sizeof(lp->stats) ); return 1; } static int lance_open( struct net_device *dev ) { struct lance_private *lp = netdev_priv(dev); int i; DPRINTK( 2, ( "%s: lance_open()\n", dev->name )); REGA(CSR0) = CSR0_STOP; lance_init_ring(dev); /* From now on, AREG is kept to point to CSR0 */ REGA(CSR0) = CSR0_INIT; i = 1000000; while (--i > 0) if (DREG & CSR0_IDON) break; if (i < 0 || (DREG & CSR0_ERR)) { DPRINTK( 2, ( "lance_open(): opening %s failed, i=%d, csr0=%04x\n", dev->name, i, DREG )); DREG = CSR0_STOP; return( -EIO ); } DREG = CSR0_IDON | CSR0_STRT | CSR0_INEA; netif_start_queue(dev); DPRINTK( 2, ( "%s: LANCE is open, csr0 %04x\n", dev->name, DREG )); return( 0 ); } /* Initialize the LANCE Rx and Tx rings. */ static void lance_init_ring( struct net_device *dev ) { struct lance_private *lp = netdev_priv(dev); int i; lp->lock = 0; lp->tx_full = 0; lp->new_rx = lp->new_tx = 0; lp->old_rx = lp->old_tx = 0; for( i = 0; i < TX_RING_SIZE; i++ ) { MEM->tx_head[i].base = dvma_vtob(MEM->tx_data[i]); MEM->tx_head[i].flag = 0; MEM->tx_head[i].base_hi = (dvma_vtob(MEM->tx_data[i])) >>16; MEM->tx_head[i].length = 0; MEM->tx_head[i].misc = 0; } for( i = 0; i < RX_RING_SIZE; i++ ) { MEM->rx_head[i].base = dvma_vtob(MEM->rx_data[i]); MEM->rx_head[i].flag = RMD1_OWN_CHIP; MEM->rx_head[i].base_hi = (dvma_vtob(MEM->rx_data[i])) >> 16; MEM->rx_head[i].buf_length = -PKT_BUF_SZ | 0xf000; MEM->rx_head[i].msg_length = 0; } /* tell the card it's ether address, bytes swapped */ MEM->init.hwaddr[0] = dev->dev_addr[1]; MEM->init.hwaddr[1] = dev->dev_addr[0]; MEM->init.hwaddr[2] = dev->dev_addr[3]; MEM->init.hwaddr[3] = dev->dev_addr[2]; MEM->init.hwaddr[4] = dev->dev_addr[5]; MEM->init.hwaddr[5] = dev->dev_addr[4]; MEM->init.mode = 0x0000; MEM->init.filter[0] = 0x00000000; MEM->init.filter[1] = 0x00000000; MEM->init.rdra = dvma_vtob(MEM->rx_head); MEM->init.rlen = (RX_LOG_RING_SIZE << 13) | (dvma_vtob(MEM->rx_head) >> 16); MEM->init.tdra = dvma_vtob(MEM->tx_head); MEM->init.tlen = (TX_LOG_RING_SIZE << 13) | (dvma_vtob(MEM->tx_head) >> 16); /* tell the lance the address of its init block */ REGA(CSR1) = dvma_vtob(&(MEM->init)); REGA(CSR2) = dvma_vtob(&(MEM->init)) >> 16; #ifdef CONFIG_SUN3X REGA(CSR3) = CSR3_BSWP | CSR3_ACON | CSR3_BCON; #else REGA(CSR3) = CSR3_BSWP; #endif } static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev ) { struct lance_private *lp = netdev_priv(dev); int entry, len; struct lance_tx_head *head; unsigned long flags; DPRINTK( 1, ( "%s: transmit start.\n", dev->name)); /* Transmitter timeout, serious problems. */ if (netif_queue_stopped(dev)) { int tickssofar = jiffies - dev->trans_start; if (tickssofar < 20) return( 1 ); DPRINTK( 1, ( "%s: transmit timed out, status %04x, resetting.\n", dev->name, DREG )); DREG = CSR0_STOP; /* * Always set BSWP after a STOP as STOP puts it back into * little endian mode. */ REGA(CSR3) = CSR3_BSWP; lp->stats.tx_errors++; if(lance_debug >= 2) { int i; printk("Ring data: old_tx %d new_tx %d%s new_rx %d\n", lp->old_tx, lp->new_tx, lp->tx_full ? " (full)" : "", lp->new_rx ); for( i = 0 ; i < RX_RING_SIZE; i++ ) printk( "rx #%d: base=%04x blen=%04x mlen=%04x\n", i, MEM->rx_head[i].base, -MEM->rx_head[i].buf_length, MEM->rx_head[i].msg_length); for( i = 0 ; i < TX_RING_SIZE; i++ ) printk("tx #%d: base=%04x len=%04x misc=%04x\n", i, MEM->tx_head[i].base, -MEM->tx_head[i].length, MEM->tx_head[i].misc ); } lance_init_ring(dev); REGA( CSR0 ) = CSR0_INEA | CSR0_INIT | CSR0_STRT; netif_start_queue(dev); dev->trans_start = jiffies; return 0; } /* Block a timer-based transmit from overlapping. This could better be done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */ /* Block a timer-based transmit from overlapping with us by stopping the queue for a bit... */ netif_stop_queue(dev); if (test_and_set_bit( 0, (void*)&lp->lock ) != 0) { printk( "%s: tx queue lock!.\n", dev->name); /* don't clear dev->tbusy flag. */ return 1; } AREG = CSR0; DPRINTK( 2, ( "%s: lance_start_xmit() called, csr0 %4.4x.\n", dev->name, DREG )); #ifdef CONFIG_SUN3X /* this weirdness doesn't appear on sun3... */ if(!(DREG & CSR0_INIT)) { DPRINTK( 1, ("INIT not set, reinitializing...\n")); REGA( CSR0 ) = CSR0_STOP; lance_init_ring(dev); REGA( CSR0 ) = CSR0_INIT | CSR0_STRT; } #endif /* Fill in a Tx ring entry */ #if 0 if (lance_debug >= 2) { u_char *p; int i; printk( "%s: TX pkt %d type 0x%04x from ", dev->name, lp->new_tx, ((u_short *)skb->data)[6]); for( p = &((u_char *)skb->data)[6], i = 0; i < 6; i++ ) printk("%02x%s", *p++, i != 5 ? ":" : "" ); printk(" to "); for( p = (u_char *)skb->data, i = 0; i < 6; i++ ) printk("%02x%s", *p++, i != 5 ? ":" : "" ); printk(" data at 0x%08x len %d\n", (int)skb->data, (int)skb->len ); } #endif /* We're not prepared for the int until the last flags are set/reset. * And the int may happen already after setting the OWN_CHIP... */ local_irq_save(flags); /* Mask to ring buffer boundary. */ entry = lp->new_tx; head = &(MEM->tx_head[entry]); /* Caution: the write order is important here, set the "ownership" bits * last. */ /* the sun3's lance needs it's buffer padded to the minimum size */ len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; // head->length = -len; head->length = (-len) | 0xf000; head->misc = 0; memcpy( PKTBUF_ADDR(head), (void *)skb->data, skb->len ); if (len != skb->len) memset(PKTBUF_ADDR(head) + skb->len, 0, len-skb->len); head->flag = TMD1_OWN_CHIP | TMD1_ENP | TMD1_STP; lp->new_tx = (lp->new_tx + 1) & TX_RING_MOD_MASK; lp->stats.tx_bytes += skb->len; /* Trigger an immediate send poll. */ REGA(CSR0) = CSR0_INEA | CSR0_TDMD | CSR0_STRT; AREG = CSR0; DPRINTK( 2, ( "%s: lance_start_xmit() exiting, csr0 %4.4x.\n", dev->name, DREG )); dev->trans_start = jiffies; dev_kfree_skb( skb ); lp->lock = 0; if ((MEM->tx_head[(entry+1) & TX_RING_MOD_MASK].flag & TMD1_OWN) == TMD1_OWN_HOST) netif_start_queue(dev); local_irq_restore(flags); return 0; } /* The LANCE interrupt handler. */ static irqreturn_t lance_interrupt( int irq, void *dev_id, struct pt_regs *fp) { struct net_device *dev = dev_id; struct lance_private *lp = netdev_priv(dev); int csr0; static int in_interrupt; if (dev == NULL) { DPRINTK( 1, ( "lance_interrupt(): invalid dev_id\n" )); return IRQ_NONE; } if (in_interrupt) DPRINTK( 2, ( "%s: Re-entering the interrupt handler.\n", dev->name )); in_interrupt = 1; still_more: flush_cache_all(); AREG = CSR0; csr0 = DREG; /* ack interrupts */ DREG = csr0 & (CSR0_TINT | CSR0_RINT | CSR0_IDON); /* clear errors */ if(csr0 & CSR0_ERR) DREG = CSR0_BABL | CSR0_MERR | CSR0_CERR | CSR0_MISS; DPRINTK( 2, ( "%s: interrupt csr0=%04x new csr=%04x.\n", dev->name, csr0, DREG )); if (csr0 & CSR0_TINT) { /* Tx-done interrupt */ int old_tx = lp->old_tx; // if(lance_debug >= 3) { // int i; // // printk("%s: tx int\n", dev->name); // // for(i = 0; i < TX_RING_SIZE; i++) // printk("ring %d flag=%04x\n", i, // MEM->tx_head[i].flag); // } while( old_tx != lp->new_tx) { struct lance_tx_head *head = &(MEM->tx_head[old_tx]); DPRINTK(3, ("on tx_ring %d\n", old_tx)); if (head->flag & TMD1_OWN_CHIP) break; /* It still hasn't been Txed */ if (head->flag & TMD1_ERR) { int status = head->misc; lp->stats.tx_errors++; if (status & TMD3_RTRY) lp->stats.tx_aborted_errors++; if (status & TMD3_LCAR) lp->stats.tx_carrier_errors++; if (status & TMD3_LCOL) lp->stats.tx_window_errors++; if (status & (TMD3_UFLO | TMD3_BUFF)) { lp->stats.tx_fifo_errors++; printk("%s: Tx FIFO error\n", dev->name); REGA(CSR0) = CSR0_STOP; REGA(CSR3) = CSR3_BSWP; lance_init_ring(dev); REGA(CSR0) = CSR0_STRT | CSR0_INEA; return IRQ_HANDLED; } } else if(head->flag & (TMD1_ENP | TMD1_STP)) { head->flag &= ~(TMD1_ENP | TMD1_STP); if(head->flag & (TMD1_ONE | TMD1_MORE)) lp->stats.collisions++; lp->stats.tx_packets++; DPRINTK(3, ("cleared tx ring %d\n", old_tx)); } old_tx = (old_tx +1) & TX_RING_MOD_MASK; } lp->old_tx = old_tx; } if (netif_queue_stopped(dev)) { /* The ring is no longer full, clear tbusy. */ netif_start_queue(dev); netif_wake_queue(dev); } if (csr0 & CSR0_RINT) /* Rx interrupt */ lance_rx( dev ); /* Log misc errors. */ if (csr0 & CSR0_BABL) lp->stats.tx_errors++; /* Tx babble. */ if (csr0 & CSR0_MISS) lp->stats.rx_errors++; /* Missed a Rx frame. */ if (csr0 & CSR0_MERR) { DPRINTK( 1, ( "%s: Bus master arbitration failure (?!?), " "status %04x.\n", dev->name, csr0 )); /* Restart the chip. */ REGA(CSR0) = CSR0_STOP; REGA(CSR3) = CSR3_BSWP; lance_init_ring(dev); REGA(CSR0) = CSR0_STRT | CSR0_INEA; } /* Clear any other interrupt, and set interrupt enable. */ // DREG = CSR0_BABL | CSR0_CERR | CSR0_MISS | CSR0_MERR | // CSR0_IDON | CSR0_INEA; REGA(CSR0) = CSR0_INEA; if(DREG & (CSR0_RINT | CSR0_TINT)) { DPRINTK(2, ("restarting interrupt, csr0=%#04x\n", DREG)); goto still_more; } DPRINTK( 2, ( "%s: exiting interrupt, csr0=%#04x.\n", dev->name, DREG )); in_interrupt = 0; return IRQ_HANDLED; } /* get packet, toss into skbuff */ static int lance_rx( struct net_device *dev ) { struct lance_private *lp = netdev_priv(dev); int entry = lp->new_rx; /* If we own the next entry, it's a new packet. Send it up. */ while( (MEM->rx_head[entry].flag & RMD1_OWN) == RMD1_OWN_HOST ) { struct lance_rx_head *head = &(MEM->rx_head[entry]); int status = head->flag; if (status != (RMD1_ENP|RMD1_STP)) { /* There was an error. */ /* There is a tricky error noted by John Murphy, <murf@perftech.com> to Russ Nelson: Even with full-sized buffers it's possible for a jabber packet to use two buffers, with only the last correctly noting the error. */ if (status & RMD1_ENP) /* Only count a general error at the */ lp->stats.rx_errors++; /* end of a packet.*/ if (status & RMD1_FRAM) lp->stats.rx_frame_errors++; if (status & RMD1_OFLO) lp->stats.rx_over_errors++; if (status & RMD1_CRC) lp->stats.rx_crc_errors++; if (status & RMD1_BUFF) lp->stats.rx_fifo_errors++; head->flag &= (RMD1_ENP|RMD1_STP); } else { /* Malloc up new buffer, compatible with net-3. */ // short pkt_len = head->msg_length;// & 0xfff; short pkt_len = (head->msg_length & 0xfff) - 4; struct sk_buff *skb; if (pkt_len < 60) { printk( "%s: Runt packet!\n", dev->name ); lp->stats.rx_errors++; } else { skb = dev_alloc_skb( pkt_len+2 ); if (skb == NULL) { DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n", dev->name )); lp->stats.rx_dropped++; head->msg_length = 0; head->flag |= RMD1_OWN_CHIP; lp->new_rx = (lp->new_rx+1) & RX_RING_MOD_MASK; } #if 0 if (lance_debug >= 3) { u_char *data = PKTBUF_ADDR(head), *p; printk( "%s: RX pkt %d type 0x%04x from ", dev->name, entry, ((u_short *)data)[6]); for( p = &data[6], i = 0; i < 6; i++ ) printk("%02x%s", *p++, i != 5 ? ":" : "" ); printk(" to "); for( p = data, i = 0; i < 6; i++ ) printk("%02x%s", *p++, i != 5 ? ":" : "" ); printk(" data %02x %02x %02x %02x %02x %02x %02x %02x " "len %d at %08x\n", data[15], data[16], data[17], data[18], data[19], data[20], data[21], data[22], pkt_len, data); } #endif if (lance_debug >= 3) { u_char *data = PKTBUF_ADDR(head); printk( "%s: RX pkt %d type 0x%04x len %d\n ", dev->name, entry, ((u_short *)data)[6], pkt_len); } skb->dev = dev; skb_reserve( skb, 2 ); /* 16 byte align */ skb_put( skb, pkt_len ); /* Make room */ // memcpy( skb->data, PKTBUF_ADDR(head), pkt_len ); eth_copy_and_sum(skb, PKTBUF_ADDR(head), pkt_len, 0); skb->protocol = eth_type_trans( skb, dev ); netif_rx( skb ); dev->last_rx = jiffies; lp->stats.rx_packets++; lp->stats.rx_bytes += pkt_len; } } // head->buf_length = -PKT_BUF_SZ | 0xf000; head->msg_length = 0; head->flag = RMD1_OWN_CHIP; entry = lp->new_rx = (lp->new_rx +1) & RX_RING_MOD_MASK; } /* From lance.c (Donald Becker): */ /* We should check that at least two ring entries are free. If not, we should free one and mark stats->rx_dropped++. */ return 0; } static int lance_close( struct net_device *dev ) { struct lance_private *lp = netdev_priv(dev); netif_stop_queue(dev); AREG = CSR0; DPRINTK( 2, ( "%s: Shutting down ethercard, status was %2.2x.\n", dev->name, DREG )); /* We stop the LANCE here -- it occasionally polls memory if we don't. */ DREG = CSR0_STOP; return 0; } static struct net_device_stats *lance_get_stats( struct net_device *dev ) { struct lance_private *lp = netdev_priv(dev); return &lp->stats; } /* Set or clear the multicast filter for this adaptor. num_addrs == -1 Promiscuous mode, receive all packets num_addrs == 0 Normal mode, clear multicast list num_addrs > 0 Multicast mode, receive normal and MC packets, and do best-effort filtering. */ /* completely untested on a sun3 */ static void set_multicast_list( struct net_device *dev ) { struct lance_private *lp = netdev_priv(dev); if(netif_queue_stopped(dev)) /* Only possible if board is already started */ return; /* We take the simple way out and always enable promiscuous mode. */ DREG = CSR0_STOP; /* Temporarily stop the lance. */ if (dev->flags & IFF_PROMISC) { /* Log any net taps. */ DPRINTK( 1, ( "%s: Promiscuous mode enabled.\n", dev->name )); REGA( CSR15 ) = 0x8000; /* Set promiscuous mode */ } else { short multicast_table[4]; int num_addrs = dev->mc_count; int i; /* We don't use the multicast table, but rely on upper-layer * filtering. */ memset( multicast_table, (num_addrs == 0) ? 0 : -1, sizeof(multicast_table) ); for( i = 0; i < 4; i++ ) REGA( CSR8+i ) = multicast_table[i]; REGA( CSR15 ) = 0; /* Unset promiscuous mode */ } /* * Always set BSWP after a STOP as STOP puts it back into * little endian mode. */ REGA( CSR3 ) = CSR3_BSWP; /* Resume normal operation and reset AREG to CSR0 */ REGA( CSR0 ) = CSR0_IDON | CSR0_INEA | CSR0_STRT; } #ifdef MODULE static struct net_device *sun3lance_dev; int init_module(void) { sun3lance_dev = sun3lance_probe(-1); if (IS_ERR(sun3lance_dev)) return PTR_ERR(sun3lance_dev); return 0; } void cleanup_module(void) { unregister_netdev(sun3lance_dev); #ifdef CONFIG_SUN3 iounmap((void *)sun3lance_dev->base_addr); #endif free_netdev(sun3lance_dev); } #endif /* MODULE */
iPodLinux/linux-2.6.7-ipod
drivers/net/sun3lance.c
C
gpl-2.0
26,755
/*************************************************************************** testqgslayoutcontext.cpp ------------------------ begin : November 2014 copyright : (C) 2014 by Nyall Dawson email : nyall dot dawson at gmail dot com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "qgslayoutrendercontext.h" #include "qgslayoutreportcontext.h" #include "qgis.h" #include "qgsfeature.h" #include "qgsvectorlayer.h" #include "qgsgeometry.h" #include "qgsproject.h" #include "qgslayout.h" #include "qgsexpressionutils.h" #include <QObject> #include "qgstest.h" #include <QtTest/QSignalSpy> class TestQgsLayoutContext: public QObject { Q_OBJECT private slots: void initTestCase();// will be called before the first testfunction is executed. void cleanupTestCase();// will be called after the last testfunction was executed. void init();// will be called before each testfunction is executed. void cleanup();// will be called after every testfunction. void creation(); //test creation of QgsLayout void flags(); //test QgsLayout flags void feature(); void layer(); void dpi(); void renderContextFlags(); void boundingBoxes(); void exportLayer(); void geometry(); void scales(); private: QString mReport; }; void TestQgsLayoutContext::initTestCase() { mReport = QStringLiteral( "<h1>Layout Context Tests</h1>\n" ); } void TestQgsLayoutContext::cleanupTestCase() { QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { QTextStream myQTextStream( &myFile ); myQTextStream << mReport; myFile.close(); } } void TestQgsLayoutContext::init() { } void TestQgsLayoutContext::cleanup() { } void TestQgsLayoutContext::creation() { QgsLayoutRenderContext *context = new QgsLayoutRenderContext( nullptr ); QVERIFY( context ); delete context; } void TestQgsLayoutContext::flags() { QgsLayoutRenderContext context( nullptr ); QSignalSpy spyFlagsChanged( &context, &QgsLayoutRenderContext::flagsChanged ); //test getting and setting flags context.setFlags( QgsLayoutRenderContext::Flags( QgsLayoutRenderContext::FlagAntialiasing | QgsLayoutRenderContext::FlagUseAdvancedEffects ) ); // default flags, so should be no signal QCOMPARE( spyFlagsChanged.count(), 0 ); QVERIFY( context.flags() == ( QgsLayoutRenderContext::FlagAntialiasing | QgsLayoutRenderContext::FlagUseAdvancedEffects ) ); QVERIFY( context.testFlag( QgsLayoutRenderContext::FlagAntialiasing ) ); QVERIFY( context.testFlag( QgsLayoutRenderContext::FlagUseAdvancedEffects ) ); QVERIFY( ! context.testFlag( QgsLayoutRenderContext::FlagDebug ) ); context.setFlag( QgsLayoutRenderContext::FlagDebug ); QCOMPARE( spyFlagsChanged.count(), 1 ); QVERIFY( context.testFlag( QgsLayoutRenderContext::FlagDebug ) ); context.setFlag( QgsLayoutRenderContext::FlagDebug, false ); QCOMPARE( spyFlagsChanged.count(), 2 ); QVERIFY( ! context.testFlag( QgsLayoutRenderContext::FlagDebug ) ); context.setFlag( QgsLayoutRenderContext::FlagDebug, false ); //no change QCOMPARE( spyFlagsChanged.count(), 2 ); context.setFlags( QgsLayoutRenderContext::FlagDebug ); QCOMPARE( spyFlagsChanged.count(), 3 ); } void TestQgsLayoutContext::feature() { QgsLayoutReportContext context( nullptr ); //test removing feature context.setFeature( QgsFeature() ); QVERIFY( !context.feature().isValid() ); //test setting/getting feature QgsFeature testFeature; testFeature.initAttributes( 1 ); testFeature.setAttribute( 0, "Test" ); context.setFeature( testFeature ); QCOMPARE( context.feature().attribute( 0 ), testFeature.attribute( 0 ) ); } void TestQgsLayoutContext::layer() { QgsLayoutReportContext context( nullptr ); //test clearing layer context.setLayer( nullptr ); QVERIFY( !context.layer() ); //test setting/getting layer QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "A" ), QStringLiteral( "memory" ) ); context.setLayer( layer ); QCOMPARE( context.layer(), layer ); //clear layer context.setLayer( nullptr ); QVERIFY( !context.layer() ); QgsLayout l( QgsProject::instance() ); l.reportContext().setLayer( layer ); //test that expression context created for layout contains report context layer scope QgsExpressionContext expContext = l.createExpressionContext(); QCOMPARE( QgsExpressionUtils::getVectorLayer( expContext.variable( "layer" ), nullptr ), layer ); delete layer; } void TestQgsLayoutContext::dpi() { QgsLayoutRenderContext context( nullptr ); QSignalSpy spyDpiChanged( &context, &QgsLayoutRenderContext::dpiChanged ); context.setDpi( 600 ); QCOMPARE( context.dpi(), 600.0 ); QCOMPARE( context.measurementConverter().dpi(), 600.0 ); QCOMPARE( spyDpiChanged.count(), 1 ); context.setDpi( 600 ); QCOMPARE( spyDpiChanged.count(), 1 ); context.setDpi( 6000 ); QCOMPARE( spyDpiChanged.count(), 2 ); } void TestQgsLayoutContext::renderContextFlags() { QgsLayoutRenderContext context( nullptr ); context.setFlags( 0 ); QgsRenderContext::Flags flags = context.renderContextFlags(); QVERIFY( !( flags & QgsRenderContext::Antialiasing ) ); QVERIFY( !( flags & QgsRenderContext::UseAdvancedEffects ) ); QVERIFY( ( flags & QgsRenderContext::ForceVectorOutput ) ); context.setFlag( QgsLayoutRenderContext::FlagAntialiasing ); flags = context.renderContextFlags(); QVERIFY( ( flags & QgsRenderContext::Antialiasing ) ); QVERIFY( !( flags & QgsRenderContext::UseAdvancedEffects ) ); QVERIFY( ( flags & QgsRenderContext::ForceVectorOutput ) ); context.setFlag( QgsLayoutRenderContext::FlagUseAdvancedEffects ); flags = context.renderContextFlags(); QVERIFY( ( flags & QgsRenderContext::Antialiasing ) ); QVERIFY( ( flags & QgsRenderContext::UseAdvancedEffects ) ); QVERIFY( ( flags & QgsRenderContext::ForceVectorOutput ) ); } void TestQgsLayoutContext::boundingBoxes() { QgsLayoutRenderContext context( nullptr ); context.setBoundingBoxesVisible( false ); QVERIFY( !context.boundingBoxesVisible() ); context.setBoundingBoxesVisible( true ); QVERIFY( context.boundingBoxesVisible() ); } void TestQgsLayoutContext::exportLayer() { QgsLayoutRenderContext context( nullptr ); // must default to -1 QCOMPARE( context.currentExportLayer(), -1 ); context.setCurrentExportLayer( 1 ); QCOMPARE( context.currentExportLayer(), 1 ); } void TestQgsLayoutContext::geometry() { QgsProject p; QgsLayout l( &p ); QgsLayoutReportContext context( &l ); // no feature set QVERIFY( context.currentGeometry().isNull() ); QVERIFY( context.currentGeometry( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ).isNull() ); // no layer set QgsFeature f; f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString( 144 -38, 145 -39 )" ) ) ); context.setFeature( f ); QCOMPARE( context.currentGeometry().asWkt(), f.geometry().asWkt() ); QVERIFY( context.currentGeometry( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ).isNull() ); //with layer QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "Point?crs=EPSG:4326&field=id_a:integer" ), QStringLiteral( "A" ), QStringLiteral( "memory" ) ); context.setLayer( layer ); QCOMPARE( context.currentGeometry().asWkt(), f.geometry().asWkt() ); QVERIFY( !context.currentGeometry( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ).isNull() ); QCOMPARE( context.currentGeometry( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ).asWkt( 0 ), QStringLiteral( "LineString (2412169 2388563, 2500000 2277996)" ) ); // should be cached QCOMPARE( context.currentGeometry( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ).asWkt( 0 ), QStringLiteral( "LineString (2412169 2388563, 2500000 2277996)" ) ); // layer crs QCOMPARE( context.currentGeometry( layer->crs() ).asWkt(), f.geometry().asWkt() ); // clear cache QgsFeature f2; context.setFeature( f2 ); QVERIFY( context.currentGeometry().isNull() ); QVERIFY( context.currentGeometry( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ).isNull() ); delete layer; } void TestQgsLayoutContext::scales() { QVector< qreal > scales; scales << 1 << 15 << 5 << 10; QgsLayoutReportContext context( nullptr ); context.setPredefinedScales( scales ); // should be sorted QCOMPARE( context.predefinedScales(), QVector< qreal >() << 1 << 5 << 10 << 15 ); } QGSTEST_MAIN( TestQgsLayoutContext ) #include "testqgslayoutcontext.moc"
CS-SI/QGIS
tests/src/core/testqgslayoutcontext.cpp
C++
gpl-2.0
9,396
var winston = require('winston'); var WinstonFileTransport = winston.transports.File, WinstonConsoleTransport = winston.transports.Console; configLevel(); exports = winston; module.exports = winston; global.logs = winston; exports.configLevel = configLevel; function configLevel(config) { winston.clear(); config = config || {}; var logLevel = 'debug'; if (config.runMode === 'beta') { logLevel = 'info'; } else if (config.runMode === 'production') { logLevel = 'error'; } winston.add(WinstonConsoleTransport, { timestamp: true, colorize: true, level: logLevel }); winston.add(WinstonFileTransport, { name: 'file#out', timestamp: true, colorize: true, filename: 'logs/api_' + process.env.MODE + '_out.log', maxsize: 10485760,// maxsize: 10mb maxFiles: 20, level: logLevel, json: false }); winston.add(WinstonFileTransport, { name: 'file#err', timestamp: true, colorize: true, filename: 'logs/api_' + process.env.MODE + '_err.log', maxsize: 10485760,// maxsize: 10mb maxFiles: 20, level: 'error', json: false }); }
CaptureYou/captureyou-www
general/log.js
JavaScript
gpl-2.0
1,136
Proyecto-final ==============
csaldana/Proyecto-final
README.md
Markdown
gpl-2.0
30
<?php /** * File containing the eZDiffEngine class. * * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version 2012.5 * @package lib */ /*! \class eZDiffEngine ezdiffengine.php \abstract \ingroup eZDiff \brief eZDiff provides an access point the diff system The eZDiffEngine class is an abstract class, providing interface and shared code for the different available DiffEngine. */ class eZDiffEngine { /*! This method must be overridden for each implementation of eZDiffEngine. This is the function which created the object containing the detected changes in the data set. */ function createDifferenceObject( $fromData, $toData ) { } /// \privatesection public $DiffMode; } ?>
pauletienney/siliconnexion
lib/ezdiff/classes/ezdiffengine.php
PHP
gpl-2.0
850
/* * Kexi Report Plugin * Copyright (C) 2007-2009 by Adam Pigg (adam@piggz.co.uk) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ #include "kexisourceselector.h" #include <kpushbutton.h> #include <klineedit.h> #include <QLabel> #include <klocale.h> #include <kdebug.h> #include <QDomElement> #include "KexiDataSourceComboBox.h" #include <kexiproject.h> //#define NO_EXTERNAL_SOURCES #ifdef NO_EXTERNAL_SOURCES #ifdef __GNUC__ #warning enable external data sources for 2.3 #else #pragma WARNING( enable external data sources for 2.3 ) #endif #endif class KexiSourceSelector::Private { public: Private() : kexiDBData(0) { } ~Private() { delete kexiDBData; #ifndef KEXI_MOBILE delete kexiMigrateData; #endif } KexiDB::Connection *conn; QVBoxLayout *layout; QComboBox *sourceType; KexiDataSourceComboBox *internalSource; KLineEdit *externalSource; KPushButton *setData; KexiDBReportData *kexiDBData; #ifndef KEXI_MOBILE KexiMigrateReportData *kexiMigrateData; #endif }; KexiSourceSelector::KexiSourceSelector(KexiProject* project, QWidget* parent) : QWidget(parent) , d(new Private) { d->conn = project->dbConnection(); d->kexiDBData = 0; #ifndef KEXI_MOBILE d->kexiMigrateData = 0; #endif d->layout = new QVBoxLayout(this); d->sourceType = new QComboBox(this); d->internalSource = new KexiDataSourceComboBox(this); d->internalSource->setProject(project); d->externalSource = new KLineEdit(this); d->setData = new KPushButton(i18n("Set Data")); connect(d->setData, SIGNAL(clicked()), this, SLOT(setDataClicked())); d->sourceType->addItem(i18n("Internal"), QVariant("internal")); d->sourceType->addItem(i18n("External"), QVariant("external")); #ifndef NO_EXTERNAL_SOURCES //!@TODO enable when adding external data d->layout->addWidget(new QLabel(i18n("Source Type:"), this)); d->layout->addWidget(d->sourceType); d->layout->addSpacing(10); #else d->sourceType->setVisible(false); d->externalSource->setVisible(false); #endif d->layout->addWidget(new QLabel(i18n("Internal Source:"), this)); d->layout->addWidget(d->internalSource); d->layout->addSpacing(10); #ifndef NO_EXTERNAL_SOURCES d->layout->addWidget(new QLabel(i18n("External Source:"), this)); d->layout->addWidget(d->externalSource); #endif d->layout->addSpacing(20); d->layout->addWidget(d->setData); d->layout->addStretch(); setLayout(d->layout); } KexiSourceSelector::~KexiSourceSelector() { delete d; } void KexiSourceSelector::setConnectionData(QDomElement c) { if (c.attribute("type") == "internal") { d->sourceType->setCurrentIndex(d->sourceType->findData("internal")); d->internalSource->setCurrentIndex(d->internalSource->findText(c.attribute("source"))); } if (c.attribute("type") == "external") { d->sourceType->setCurrentIndex(d->sourceType->findText("external")); d->externalSource->setText(c.attribute("source")); } emit(setData(sourceData())); } QDomElement KexiSourceSelector::connectionData() { kDebug(); QDomDocument dd; QDomElement conndata = dd.createElement("connection"); #ifndef NO_EXTERNAL_SOURCES //!@TODO Make a better gui for selecting external data source conndata.setAttribute("type", d->sourceType->itemData(d->sourceType->currentIndex()).toString()); if (d->sourceType->itemData(d->sourceType->currentIndex()).toString() == "internal") { conndata.setAttribute("source", d->internalSource->currentText()); } else { conndata.setAttribute("source", d->externalSource->text()); } #else conndata.setAttribute("type", "internal"); conndata.setAttribute("source", d->internalSource->currentText()); #endif return conndata; } KoReportData* KexiSourceSelector::sourceData() { if (d->kexiDBData) { delete d->kexiDBData; d->kexiDBData = 0; } #ifndef KEXI_MOBILE if (d->kexiMigrateData) { delete d->kexiMigrateData; d->kexiMigrateData = 0; } #endif //!@TODO Fix when enable external data #ifndef NO_EXTERNAL_SOURCES if (d->sourceType->itemData(d->sourceType->currentIndex()).toString() == "internal" && d->internalSource->isSelectionValid()) { d->kexiDBData = new KexiDBReportData(d->internalSource->selectedName(), d->internalSource->selectedPartClass(), d->conn); return d->kexiDBData; } #ifndef KEXI_MOBILE if (d->sourceType->itemData(d->sourceType->currentIndex()).toString() == "external") { d->kexiMigrateData = new KexiMigrateReportData(d->externalSource->text()); return d->kexiMigrateData; } #endif #else if (d->internalSource->isSelectionValid()) { d->kexiDBData = new KexiDBReportData(d->internalSource->selectedName(), d->conn); return d->kexiDBData; } #endif return 0; } void KexiSourceSelector::setDataClicked() { emit(setData(sourceData())); }
donniexyz/calligra
kexi/plugins/reports/kexisourceselector.cpp
C++
gpl-2.0
5,620
/* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. This file is part of Quake III Arena source code. Quake III Arena source code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Quake III Arena source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Quake III Arena source code; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ #include "vm_local.h" #include <stdint.h> #define PAD(base, alignment) (((base)+(alignment)-1) & ~((alignment)-1)) #define PADLEN(base, alignment) (PAD((base), (alignment)) - (base)) #define PADP(base, alignment) ((void *) PAD((intptr_t) (base), (alignment))) #define ARRAY_LEN(x) (sizeof(x) / sizeof(*(x))) //#define DEBUG_VM #ifdef DEBUG_VM static char *opnames[256] = { "OP_UNDEF", "OP_IGNORE", "OP_BREAK", "OP_ENTER", "OP_LEAVE", "OP_CALL", "OP_PUSH", "OP_POP", "OP_CONST", "OP_LOCAL", "OP_JUMP", //------------------- "OP_EQ", "OP_NE", "OP_LTI", "OP_LEI", "OP_GTI", "OP_GEI", "OP_LTU", "OP_LEU", "OP_GTU", "OP_GEU", "OP_EQF", "OP_NEF", "OP_LTF", "OP_LEF", "OP_GTF", "OP_GEF", //------------------- "OP_LOAD1", "OP_LOAD2", "OP_LOAD4", "OP_STORE1", "OP_STORE2", "OP_STORE4", "OP_ARG", "OP_BLOCK_COPY", //------------------- "OP_SEX8", "OP_SEX16", "OP_NEGI", "OP_ADD", "OP_SUB", "OP_DIVI", "OP_DIVU", "OP_MODI", "OP_MODU", "OP_MULI", "OP_MULU", "OP_BAND", "OP_BOR", "OP_BXOR", "OP_BCOM", "OP_LSH", "OP_RSHI", "OP_RSHU", "OP_NEGF", "OP_ADDF", "OP_SUBF", "OP_DIVF", "OP_MULF", "OP_CVIF", "OP_CVFI" }; #endif #if idppc //FIXME: these, um... look the same to me #if defined(__GNUC__) static ID_INLINE unsigned int loadWord(void *addr) { unsigned int word; asm("lwbrx %0,0,%1" : "=r" (word) : "r" (addr)); return word; } #else static ID_INLINE unsigned int __lwbrx(register void *addr, register int offset) { register unsigned int word; asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset)); return word; } #define loadWord(addr) __lwbrx(addr,0) #endif #else static ID_INLINE int loadWord(void *addr) { int word; memcpy(&word, addr, 4); return LittleLong(word); } #endif char *VM_Indent( vm_t *vm ) { static char *string = " "; if ( vm->callLevel > 20 ) { return string; } return string + 2 * ( 20 - vm->callLevel ); } void VM_StackTrace( vm_t *vm, int programCounter, int programStack ) { int count; count = 0; do { Com_Printf( "%s\n", VM_ValueToSymbol( vm, programCounter ) ); programStack = *(int *)&vm->dataBase[programStack+4]; programCounter = *(int *)&vm->dataBase[programStack]; } while ( programCounter != -1 && ++count < 32 ); } /* ==================== VM_PrepareInterpreter ==================== */ void VM_PrepareInterpreter( vm_t *vm, vmHeader_t *header ) { int op; int byte_pc; int int_pc; byte *code; int instruction; int *codeBase; vm->codeBase = (byte *)Hunk_Alloc( vm->codeLength*4, h_high ); // we're now int aligned // memcpy( vm->codeBase, (byte *)header + header->codeOffset, vm->codeLength ); // we don't need to translate the instructions, but we still need // to find each instructions starting point for jumps int_pc = byte_pc = 0; instruction = 0; code = (byte *)header + header->codeOffset; codeBase = (int *)vm->codeBase; // Copy and expand instructions to words while building instruction table while ( instruction < header->instructionCount ) { vm->instructionPointers[ instruction ] = int_pc; instruction++; op = (int)code[ byte_pc ]; codeBase[int_pc] = op; if(byte_pc > header->codeLength) Com_Error(ERR_DROP, "VM_PrepareInterpreter: pc > header->codeLength"); byte_pc++; int_pc++; // these are the only opcodes that aren't a single byte switch ( op ) { case OP_ENTER: case OP_CONST: case OP_LOCAL: case OP_LEAVE: case OP_EQ: case OP_NE: case OP_LTI: case OP_LEI: case OP_GTI: case OP_GEI: case OP_LTU: case OP_LEU: case OP_GTU: case OP_GEU: case OP_EQF: case OP_NEF: case OP_LTF: case OP_LEF: case OP_GTF: case OP_GEF: case OP_BLOCK_COPY: codeBase[int_pc] = loadWord(&code[byte_pc]); byte_pc += 4; int_pc++; break; case OP_ARG: codeBase[int_pc] = (int)code[byte_pc]; byte_pc++; int_pc++; break; default: break; } } int_pc = 0; instruction = 0; // Now that the code has been expanded to int-sized opcodes, we'll translate instruction index //into an index into codeBase[], which contains opcodes and operands. while ( instruction < header->instructionCount ) { op = codeBase[ int_pc ]; instruction++; int_pc++; switch ( op ) { // These ops need to translate addresses in jumps from instruction index to int index case OP_EQ: case OP_NE: case OP_LTI: case OP_LEI: case OP_GTI: case OP_GEI: case OP_LTU: case OP_LEU: case OP_GTU: case OP_GEU: case OP_EQF: case OP_NEF: case OP_LTF: case OP_LEF: case OP_GTF: case OP_GEF: if(codeBase[int_pc] < 0 || codeBase[int_pc] > vm->instructionCount) Com_Error(ERR_DROP, "VM_PrepareInterpreter: Jump to invalid instruction number"); // codeBase[pc] is the instruction index. Convert that into an offset into //the int-aligned codeBase[] by the lookup table. codeBase[int_pc] = vm->instructionPointers[codeBase[int_pc]]; int_pc++; break; // These opcodes have an operand that isn't an instruction index case OP_ENTER: case OP_CONST: case OP_LOCAL: case OP_LEAVE: case OP_BLOCK_COPY: case OP_ARG: int_pc++; break; default: break; } } } /* ============== VM_Call Upon a system call, the stack will look like: sp+32 parm1 sp+28 parm0 sp+24 return stack sp+20 return address sp+16 local1 sp+14 local0 sp+12 arg1 sp+8 arg0 sp+4 return stack sp return address An interpreted function will immediately execute an OP_ENTER instruction, which will subtract space for locals from sp ============== */ #define DEBUGSTR va("%s%i", VM_Indent(vm), opStackOfs) int VM_CallInterpreted( vm_t *vm, int *args ) { byte stack[OPSTACK_SIZE + 15]; int *opStack; uint8_t opStackOfs; int programCounter; int programStack; int stackOnEntry; byte *image; int *codeImage; int v1; int dataMask; int arg; #ifdef DEBUG_VM vmSymbol_t *profileSymbol; #endif // interpret the code vm->currentlyInterpreting = qtrue; // we might be called recursively, so this might not be the very top programStack = stackOnEntry = vm->programStack; #ifdef DEBUG_VM profileSymbol = VM_ValueToFunctionSymbol( vm, 0 ); // uncomment this for debugging breakpoints vm->breakFunction = 0; #endif // set up the stack frame image = vm->dataBase; codeImage = (int *)vm->codeBase; dataMask = vm->dataMask; programCounter = 0; programStack -= ( 8 + 4 * MAX_VMMAIN_ARGS ); for ( arg = 0; arg < MAX_VMMAIN_ARGS; arg++ ) *(int *)&image[ programStack + 8 + arg * 4 ] = args[ arg ]; *(int *)&image[ programStack + 4 ] = 0; // return stack *(int *)&image[ programStack ] = -1; // will terminate the loop on return VM_Debug(0); // leave a free spot at start of stack so // that as long as opStack is valid, opStack-1 will // not corrupt anything opStack = (int *)PADP(stack, 16); *opStack = 0xDEADBEEF; opStackOfs = 0; // vm_debugLevel=2; // main interpreter loop, will exit when a LEAVE instruction // grabs the -1 program counter #define r2 codeImage[programCounter] while ( 1 ) { int opcode, r0, r1; // unsigned int r2; nextInstruction: r0 = opStack[opStackOfs]; r1 = opStack[(uint8_t) (opStackOfs - 1)]; nextInstruction2: #ifdef DEBUG_VM if ( (unsigned)programCounter >= vm->codeLength ) { Com_Error( ERR_DROP, "VM pc out of range" ); return 0; } if ( programStack <= vm->stackBottom ) { Com_Error( ERR_DROP, "VM stack overflow" ); return 0; } if ( programStack & 3 ) { Com_Error( ERR_DROP, "VM program stack misaligned" ); return 0; } if ( vm_debugLevel > 1 ) { Com_Printf( "%s %s\n", DEBUGSTR, opnames[opcode] ); } profileSymbol->profileCount++; #endif opcode = codeImage[ programCounter++ ]; switch ( opcode ) { #ifdef DEBUG_VM default: Com_Error( ERR_DROP, "Bad VM instruction" ); // this should be scanned on load! return 0; #endif case OP_BREAK: vm->breakCount++; goto nextInstruction2; case OP_CONST: opStackOfs++; r1 = r0; r0 = opStack[opStackOfs] = r2; programCounter += 1; goto nextInstruction2; case OP_LOCAL: opStackOfs++; r1 = r0; r0 = opStack[opStackOfs] = r2+programStack; programCounter += 1; goto nextInstruction2; case OP_LOAD4: #ifdef DEBUG_VM if(opStack[opStackOfs] & 3) { Com_Error( ERR_DROP, "OP_LOAD4 misaligned" ); return 0; } #endif r0 = opStack[opStackOfs] = *(int *) &image[r0 & dataMask & ~3 ]; goto nextInstruction2; case OP_LOAD2: r0 = opStack[opStackOfs] = *(unsigned short *)&image[ r0&dataMask&~1 ]; goto nextInstruction2; case OP_LOAD1: r0 = opStack[opStackOfs] = image[ r0&dataMask ]; goto nextInstruction2; case OP_STORE4: *(int *)&image[ r1&(dataMask & ~3) ] = r0; opStackOfs -= 2; goto nextInstruction; case OP_STORE2: *(short *)&image[ r1&(dataMask & ~1) ] = r0; opStackOfs -= 2; goto nextInstruction; case OP_STORE1: image[ r1&dataMask ] = r0; opStackOfs -= 2; goto nextInstruction; case OP_ARG: // single byte offset from programStack *(int *)&image[ (codeImage[programCounter] + programStack)&dataMask&~3 ] = r0; opStackOfs--; programCounter += 1; goto nextInstruction; case OP_BLOCK_COPY: VM_BlockCopy(r1, r0, r2); programCounter += 1; opStackOfs -= 2; goto nextInstruction; case OP_CALL: // save current program counter *(int *)&image[ programStack ] = programCounter; // jump to the location on the stack programCounter = r0; opStackOfs--; if ( programCounter < 0 ) { // system call int r; // int temp; #ifdef DEBUG_VM int stomped; if ( vm_debugLevel ) { Com_Printf( "%s---> systemcall(%i)\n", DEBUGSTR, -1 - programCounter ); } #endif // save the stack to allow recursive VM entry // temp = vm->callLevel; vm->programStack = programStack - 4; #ifdef DEBUG_VM stomped = *(int *)&image[ programStack + 4 ]; #endif *(int *)&image[ programStack + 4 ] = -1 - programCounter; //VM_LogSyscalls( (int *)&image[ programStack + 4 ] ); { // the vm has ints on the stack, we expect // pointers so we might have to convert it if (sizeof(intptr_t) != sizeof(int)) { intptr_t argarr[ MAX_VMSYSCALL_ARGS ]; int *imagePtr = (int *)&image[ programStack ]; int i; for (i = 0; i < ARRAY_LEN(argarr); ++i) { argarr[i] = *(++imagePtr); } r = vm->systemCall( argarr ); } else { intptr_t* argptr = (intptr_t *)&image[ programStack + 4 ]; r = vm->systemCall( argptr ); } } #ifdef DEBUG_VM // this is just our stack frame pointer, only needed // for debugging *(int *)&image[ programStack + 4 ] = stomped; #endif // save return value opStackOfs++; opStack[opStackOfs] = r; programCounter = *(int *)&image[ programStack ]; // vm->callLevel = temp; #ifdef DEBUG_VM if ( vm_debugLevel ) { Com_Printf( "%s<--- %s\n", DEBUGSTR, VM_ValueToSymbol( vm, programCounter ) ); } #endif } else if ( (unsigned)programCounter >= vm->instructionCount ) { Com_Error( ERR_DROP, "VM program counter out of range in OP_CALL" ); return 0; } else { programCounter = vm->instructionPointers[ programCounter ]; } goto nextInstruction; // push and pop are only needed for discarded or bad function return values case OP_PUSH: opStackOfs++; goto nextInstruction; case OP_POP: opStackOfs--; goto nextInstruction; case OP_ENTER: #ifdef DEBUG_VM profileSymbol = VM_ValueToFunctionSymbol( vm, programCounter ); #endif // get size of stack frame v1 = r2; programCounter += 1; programStack -= v1; #ifdef DEBUG_VM // save old stack frame for debugging traces *(int *)&image[programStack+4] = programStack + v1; if ( vm_debugLevel ) { Com_Printf( "%s---> %s\n", DEBUGSTR, VM_ValueToSymbol( vm, programCounter - 5 ) ); if ( vm->breakFunction && programCounter - 5 == vm->breakFunction ) { // this is to allow setting breakpoints here in the debugger vm->breakCount++; // vm_debugLevel = 2; // VM_StackTrace( vm, programCounter, programStack ); } // vm->callLevel++; } #endif goto nextInstruction; case OP_LEAVE: // remove our stack frame v1 = r2; programStack += v1; // grab the saved program counter programCounter = *(int *)&image[ programStack ]; #ifdef DEBUG_VM profileSymbol = VM_ValueToFunctionSymbol( vm, programCounter ); if ( vm_debugLevel ) { // vm->callLevel--; Com_Printf( "%s<--- %s\n", DEBUGSTR, VM_ValueToSymbol( vm, programCounter ) ); } #endif // check for leaving the VM if ( programCounter == -1 ) { goto done; } else if ( (unsigned)programCounter >= vm->codeLength ) { Com_Error( ERR_DROP, "VM program counter out of range in OP_LEAVE" ); return 0; } goto nextInstruction; /* =================================================================== BRANCHES =================================================================== */ case OP_JUMP: if ( (unsigned)r0 >= vm->instructionCount ) { Com_Error( ERR_DROP, "VM program counter out of range in OP_JUMP" ); return 0; } programCounter = vm->instructionPointers[ r0 ]; opStackOfs--; goto nextInstruction; case OP_EQ: opStackOfs -= 2; if ( r1 == r0 ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_NE: opStackOfs -= 2; if ( r1 != r0 ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_LTI: opStackOfs -= 2; if ( r1 < r0 ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_LEI: opStackOfs -= 2; if ( r1 <= r0 ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_GTI: opStackOfs -= 2; if ( r1 > r0 ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_GEI: opStackOfs -= 2; if ( r1 >= r0 ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_LTU: opStackOfs -= 2; if ( ((unsigned)r1) < ((unsigned)r0) ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_LEU: opStackOfs -= 2; if ( ((unsigned)r1) <= ((unsigned)r0) ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_GTU: opStackOfs -= 2; if ( ((unsigned)r1) > ((unsigned)r0) ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_GEU: opStackOfs -= 2; if ( ((unsigned)r1) >= ((unsigned)r0) ) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_EQF: opStackOfs -= 2; if(((float *) opStack)[(uint8_t) (opStackOfs + 1)] == ((float *) opStack)[(uint8_t) (opStackOfs + 2)]) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_NEF: opStackOfs -= 2; if(((float *) opStack)[(uint8_t) (opStackOfs + 1)] != ((float *) opStack)[(uint8_t) (opStackOfs + 2)]) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_LTF: opStackOfs -= 2; if(((float *) opStack)[(uint8_t) (opStackOfs + 1)] < ((float *) opStack)[(uint8_t) (opStackOfs + 2)]) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_LEF: opStackOfs -= 2; if(((float *) opStack)[(uint8_t) ((uint8_t) (opStackOfs + 1))] <= ((float *) opStack)[(uint8_t) ((uint8_t) (opStackOfs + 2))]) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_GTF: opStackOfs -= 2; if(((float *) opStack)[(uint8_t) (opStackOfs + 1)] > ((float *) opStack)[(uint8_t) (opStackOfs + 2)]) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } case OP_GEF: opStackOfs -= 2; if(((float *) opStack)[(uint8_t) (opStackOfs + 1)] >= ((float *) opStack)[(uint8_t) (opStackOfs + 2)]) { programCounter = r2; //vm->instructionPointers[r2]; goto nextInstruction; } else { programCounter += 1; goto nextInstruction; } //=================================================================== case OP_NEGI: opStack[opStackOfs] = -r0; goto nextInstruction; case OP_ADD: opStackOfs--; opStack[opStackOfs] = r1 + r0; goto nextInstruction; case OP_SUB: opStackOfs--; opStack[opStackOfs] = r1 - r0; goto nextInstruction; case OP_DIVI: opStackOfs--; opStack[opStackOfs] = r1 / r0; goto nextInstruction; case OP_DIVU: opStackOfs--; opStack[opStackOfs] = ((unsigned) r1) / ((unsigned) r0); goto nextInstruction; case OP_MODI: opStackOfs--; opStack[opStackOfs] = r1 % r0; goto nextInstruction; case OP_MODU: opStackOfs--; opStack[opStackOfs] = ((unsigned) r1) % ((unsigned) r0); goto nextInstruction; case OP_MULI: opStackOfs--; opStack[opStackOfs] = r1 * r0; goto nextInstruction; case OP_MULU: opStackOfs--; opStack[opStackOfs] = ((unsigned) r1) * ((unsigned) r0); goto nextInstruction; case OP_BAND: opStackOfs--; opStack[opStackOfs] = ((unsigned) r1) & ((unsigned) r0); goto nextInstruction; case OP_BOR: opStackOfs--; opStack[opStackOfs] = ((unsigned) r1) | ((unsigned) r0); goto nextInstruction; case OP_BXOR: opStackOfs--; opStack[opStackOfs] = ((unsigned) r1) ^ ((unsigned) r0); goto nextInstruction; case OP_BCOM: opStack[opStackOfs] = ~((unsigned) r0); goto nextInstruction; case OP_LSH: opStackOfs--; opStack[opStackOfs] = r1 << r0; goto nextInstruction; case OP_RSHI: opStackOfs--; opStack[opStackOfs] = r1 >> r0; goto nextInstruction; case OP_RSHU: opStackOfs--; opStack[opStackOfs] = ((unsigned) r1) >> r0; goto nextInstruction; case OP_NEGF: ((float *) opStack)[opStackOfs] = -((float *) opStack)[opStackOfs]; goto nextInstruction; case OP_ADDF: opStackOfs--; ((float *) opStack)[opStackOfs] = ((float *) opStack)[opStackOfs] + ((float *) opStack)[(uint8_t) (opStackOfs + 1)]; goto nextInstruction; case OP_SUBF: opStackOfs--; ((float *) opStack)[opStackOfs] = ((float *) opStack)[opStackOfs] - ((float *) opStack)[(uint8_t) (opStackOfs + 1)]; goto nextInstruction; case OP_DIVF: opStackOfs--; ((float *) opStack)[opStackOfs] = ((float *) opStack)[opStackOfs] / ((float *) opStack)[(uint8_t) (opStackOfs + 1)]; goto nextInstruction; case OP_MULF: opStackOfs--; ((float *) opStack)[opStackOfs] = ((float *) opStack)[opStackOfs] * ((float *) opStack)[(uint8_t) (opStackOfs + 1)]; goto nextInstruction; case OP_CVIF: ((float *) opStack)[opStackOfs] = (float) opStack[opStackOfs]; goto nextInstruction; case OP_CVFI: opStack[opStackOfs] = Q_ftol(((float *) opStack)[opStackOfs]); goto nextInstruction; case OP_SEX8: opStack[opStackOfs] = (signed char) opStack[opStackOfs]; goto nextInstruction; case OP_SEX16: opStack[opStackOfs] = (short) opStack[opStackOfs]; goto nextInstruction; } } done: vm->currentlyInterpreting = qfalse; if (opStackOfs != 1 || *opStack != 0xDEADBEEF) Com_Error(ERR_DROP, "Interpreter error: opStack[0] = %X, opStackOfs = %d", opStack[0], opStackOfs); vm->programStack = stackOnEntry; // return the result return opStack[opStackOfs]; }
ensiform/jk2mv
src/qcommon/vm_interpreted.cpp
C++
gpl-2.0
21,435
cmd_fs/nfs_common/built-in.o := rm -f fs/nfs_common/built-in.o; /pub/CIS520/usr/arm/bin/arm-angstrom-linux-gnueabi-ar rcs fs/nfs_common/built-in.o
mjmccall/Kernel
fs/nfs_common/.built-in.o.cmd
Batchfile
gpl-2.0
148
# F3AT - Flumotion Asynchronous Autonomous Agent Toolkit # Copyright (C) 2010,2011 Flumotion Services, S.A. # All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # See "LICENSE.GPL" in the source distribution for more information. # Headers in this file shall remain intact. # -*- coding: utf-8 -*- # -*- Mode: Python -*- # vi:si:et:sw=4:sts=4:ts=4 import uuid import time from twisted.internet import defer from zope.interface import implements from feat.agents.base import descriptor, requester, replier, replay from feat.agencies import message, retrying from feat.interface.agency import ExecMode from feat.database.interface import NotFoundError from feat.interface.requests import RequestState from feat.interface.protocols import ProtocolFailed, IInterest, InterestType from feat.test import common, dummies #don't remove dummies, it defines adapter class DummyRequester(requester.BaseRequester): protocol_id = 'dummy-request' timeout = 2 @replay.entry_point def initiate(self, state, argument): state._got_response = False msg = message.RequestMessage() msg.payload = argument state.medium.request(msg) @replay.entry_point def got_reply(self, state, message): state._got_response = True return message.payload @replay.immutable def _get_medium(self, state): self.log(state) return state.medium @replay.immutable def got_response(self, state): return state._got_response class DummyReplier(replier.BaseReplier): protocol_id = 'dummy-request' @replay.entry_point def requested(self, state, request): state.agent.got_payload = request.payload state.medium.reply(message.ResponseMessage(payload=request.payload)) class DummyInterest(object): implements(IInterest) def __init__(self): self.protocol_type = "Contract" self.protocol_id = "some-contract" self.interest_type = InterestType.public self.initiator = message.Announcement class TestDependencies(common.TestCase, common.AgencyTestHelper): @defer.inlineCallbacks def setUp(self): yield common.TestCase.setUp(self) yield common.AgencyTestHelper.setUp(self) def testGettingModes(self): self.assertEqual(ExecMode.test, self.agency.get_mode('unknown')) self.agency.set_mode('something', ExecMode.production) self.assertEqual(ExecMode.production, self.agency.get_mode('something')) self.agency._set_default_mode(ExecMode.production) self.assertEqual(ExecMode.production, self.agency.get_mode('unknown')) class TestAgencyAgent(common.TestCase, common.AgencyTestHelper): timeout = 3 protocol_type = 'Request' protocol_id = 'dummy-request' @defer.inlineCallbacks def setUp(self): yield common.TestCase.setUp(self) yield common.AgencyTestHelper.setUp(self) desc = yield self.doc_factory(descriptor.Descriptor) self.agent = yield self.agency.start_agent(desc) self.assertEqual(1, self.agent.get_descriptor().instance_id) self.endpoint, self.queue = self.setup_endpoint() def testJoinShard(self): messaging = self.agent._messaging self.assertTrue(len(messaging.get_bindings('lobby')) > 1) self.agent.leave_shard('lobby') self.assertEqual(0, len(messaging.get_bindings('lobby'))) @defer.inlineCallbacks def testSwitchingShardRebinding(self): messaging = self.agent._messaging initial = len(messaging.get_bindings('lobby')) interest = DummyInterest() self.agent.register_interest(interest) self.assertEqual(initial + 1, len(messaging.get_bindings('lobby'))) yield self.agent.leave_shard('lobby') self.assertEqual(0, len(messaging.get_bindings('lobby'))) yield self.agent.join_shard('new shard') self.assertEqual(initial + 1, len(messaging.get_bindings('new shard'))) self.assertEqual(0, len(messaging.get_bindings('lobby'))) @defer.inlineCallbacks def testUpdateDocument(self): desc = self.agent.get_descriptor() self.assertIsInstance(desc, descriptor.Descriptor) def update_fun(desc): desc.shard = 'changed' yield self.agent.update_descriptor(update_fun) self.assertEqual('changed', self.agent._descriptor.shard) def testRegisterTwice(self): self.assertTrue(self.agent.register_interest(DummyReplier)) self.failIf(self.agent.register_interest(DummyReplier)) def testRegisteringAndRevokeReplier(self): self.agent.register_interest(DummyReplier) self.assertTrue('Request' in self.agent._interests) self.assertTrue('dummy-request' in self.agent._interests['Request']) self.agent.revoke_interest(DummyReplier) self.assertFalse('dummy-request' in self.agent._interests['Request']) #calling once again nothing bad should happened req = self.agent.revoke_interest(DummyReplier) self.assertFalse(req) def tesGetingRequestWithoutInterest(self): '''Current implementation just ignores such events. Update this test in case we decide to do sth else''' key = (self.agent.get_descriptor()).doc_id msg = message.RequestMessage() return self.recv_msg(msg, self.endpoint, key) @defer.inlineCallbacks def testTerminatingTheAgent(self): # make him have running retrying request (covers all the hard cases) d = self.cb_after(None, self.agent, 'initiate_protocol') factory = retrying.RetryingProtocolFactory(DummyRequester) self.agent.initiate_protocol(factory, self.endpoint, None) yield d yield self.agent._terminate() self.assertCalled(self.agent.agent, 'shutdown') doc_id = self.agent._descriptor.doc_id d = self.agency._database.get_connection().get_document(doc_id) self.assertFailure(d, NotFoundError) yield d self.assertEqual(0, len(self.agency._agents)) @common.attr(timescale=0.05) class TestRequests(common.TestCase, common.AgencyTestHelper): timeout = 3 protocol_type = 'Request' protocol_id = 'dummy-request' @defer.inlineCallbacks def setUp(self): yield common.TestCase.setUp(self) yield common.AgencyTestHelper.setUp(self) desc = yield self.doc_factory(descriptor.Descriptor) self.agent = yield self.agency.start_agent(desc) self.endpoint, self.queue = self.setup_endpoint() def testRequester(self): d = self.queue.get() payload = 5 self.requester =\ self.agent.initiate_protocol(DummyRequester, self.endpoint, payload) self.medium = self.requester._get_medium() self.finished = self.requester.notify_finish() self.assertIsInstance(self.finished, defer.Deferred) def assertsOnMessage(message): desc = self.agent.get_descriptor() self.assertEqual(desc.shard, \ message.reply_to.route) self.assertEqual(desc.doc_id, \ message.reply_to.key) self.assertEqual('Request', message.protocol_type) self.assertEqual('dummy-request', message.protocol_id) self.assertEqual(payload, message.payload) self.assertTrue(message.expiration_time is not None) guid = message.sender_id self.assertEqual(guid, str(guid)) self.assertEqual(RequestState.requested, self.medium.state) return guid, message d.addCallback(assertsOnMessage) def assertsOnAgency((guid, msg, )): self.log('%r', self.agent._protocols.keys()) self.assertTrue(guid in self.agent._protocols.keys()) protocol = self.agent._protocols[guid] self.assertEqual('AgencyRequester', protocol.__class__.__name__) return guid, msg d.addCallback(assertsOnAgency) def mimicReceivingResponse((guid, msg, )): response = message.ResponseMessage() self.reply(response, self.endpoint, msg) return guid d.addCallback(mimicReceivingResponse) d.addCallback(lambda _: self.finished) def assertGotResponseAndTerminated(guid): self.assertFalse(guid in self.agent._protocols.keys()) self.assertTrue(self.requester.got_response) d.addCallback(assertGotResponseAndTerminated) return d @common.attr(timeout=10) @defer.inlineCallbacks def testRequestTimeout(self): payload = 5 self.requester =\ yield self.agent.initiate_protocol(DummyRequester, self.endpoint, payload) self.medium = self.requester._get_medium() self.finished = self.requester.notify_finish() self.assertFailure(self.finished, ProtocolFailed) yield self.finished guid = self.medium.guid self.assertFalse(guid in self.agent._protocols.keys()) self.assertFalse(self.requester.got_response()) self.assertEqual(RequestState.closed, self.medium.state) msg = yield self.queue.get() self.assertIsInstance(msg, message.RequestMessage) def testReplierReplies(self): self.agent.register_interest(DummyReplier) key = (self.agent.get_descriptor()).doc_id req = self._build_req_msg(self.endpoint) d = self.recv_msg(req, self.endpoint, key) d.addCallback(lambda _: self.queue.get()) def assert_on_msg(msg): self.assertEqual('dummy-request', msg.protocol_id) d.addCallback(assert_on_msg) return d def testNotProcessingExpiredRequests(self): self.agent.register_interest(DummyReplier) self.agent.agent.got_payload = False key = (self.agent.get_descriptor()).doc_id # define false sender, he will get the response later req = self._build_req_msg(self.endpoint) expiration_time = time.time() - 1 d = self.recv_msg(req, self.endpoint, key, expiration_time) def asserts_after_procesing(return_value): self.log(return_value) self.assertFalse(return_value) self.assertEqual(False, self.agent.agent.got_payload) d.addCallback(asserts_after_procesing) return d @defer.inlineCallbacks def testTwoAgentsTalking(self): receiver = self.agent desc = yield self.doc_factory(descriptor.Descriptor) sender = yield self.agency.start_agent(desc) receiver.register_interest(DummyReplier) requester = sender.initiate_protocol(DummyRequester, receiver, 1) r = yield requester.notify_finish() self.assertEqual(1, r) self.assertTrue(requester.got_response) self.assertEqual(1, receiver.agent.got_payload) def _build_req_msg(self, recp): r = message.RequestMessage() r.guid = str(uuid.uuid1()) r.traversal_id = str(uuid.uuid1()) r.payload = 10 return r
f3at/feat
src/feat/test/test_agencies_emu_agency.py
Python
gpl-2.0
11,954
<?php if ( ! class_exists( 'Redux_Validation_not_empty' ) ) { class Redux_Validation_not_empty { /** * Field Constructor. * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function * * @since ReduxFramework 1.0.0 */ function __construct( $parent, $field, $value, $current ) { $this->parent = $parent; $this->field = $field; $this->field['msg'] = ( isset( $this->field['msg'] ) ) ? $this->field['msg'] : __( 'This field cannot be empty. Please provide a value.', 'helpme' ); $this->value = $value; $this->current = $current; $this->validate(); } //function /** * Field Render Function. * Takes the vars and outputs the HTML for the field in the settings * * @since ReduxFramework 1.0.0 */ function validate() { if ( ! isset( $this->value ) || empty( $this->value ) ) { $this->value = ( isset( $this->current ) ) ? $this->current : ''; $this->error = $this->field; } } //function } //class }
wanmendoza/fundecan
wp-content/themes/helpme/includes/framework/ReduxCore/inc/validation/not_empty/validation_not_empty.php
PHP
gpl-2.0
1,384
package iptat.util; public interface Observer { public void update(int state); }
AlexandruGhergut/IPTAT
src/iptat/util/Observer.java
Java
gpl-2.0
83
/* * Sibetaintrinsics.h - Intrinsic table for the beta version of Serpent Isle. * * Note: This is used in the virtual machine and the Usecode compiler. * * Copyright (C) 2016-2022 The Exult Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ USECODE_INTRINSIC_PTR(get_random), // 0x00 USECODE_INTRINSIC_PTR(execute_usecode_array), // 0x01 USECODE_INTRINSIC_PTR(delayed_execute_usecode_array), // 0x02 USECODE_INTRINSIC_PTR(show_npc_face), // 0x03 USECODE_INTRINSIC_PTR(remove_npc_face), // 0x04 USECODE_INTRINSIC_PTR(show_npc_face0), // 0x05 USECODE_INTRINSIC_PTR(show_npc_face1), // 0x06 USECODE_INTRINSIC_PTR(remove_npc_face0), // 0x07 USECODE_INTRINSIC_PTR(remove_npc_face1), // 0x08 USECODE_INTRINSIC_PTR(set_conversation_slot), // 0x09 USECODE_INTRINSIC_PTR(change_npc_face0), // 0x0a - UNUSED USECODE_INTRINSIC_PTR(change_npc_face1), // 0x0b - UNUSED USECODE_INTRINSIC_PTR(add_answer), // 0x0c USECODE_INTRINSIC_PTR(remove_answer), // 0x0d USECODE_INTRINSIC_PTR(push_answers), // 0x0e USECODE_INTRINSIC_PTR(pop_answers), // 0x0f USECODE_INTRINSIC_PTR(clear_answers), // 0x10 USECODE_INTRINSIC_PTR(select_from_menu), // 0x11 USECODE_INTRINSIC_PTR(select_from_menu2), // 0x12 USECODE_INTRINSIC_PTR(input_numeric_value), // 0x13 USECODE_INTRINSIC_PTR(set_item_shape), // 0x14 USECODE_INTRINSIC_PTR(find_nearest), // 0x15 USECODE_INTRINSIC_PTR(play_sound_effect), // 0x16 USECODE_INTRINSIC_PTR(die_roll), // 0x17 USECODE_INTRINSIC_PTR(get_item_shape), // 0x18 USECODE_INTRINSIC_PTR(get_item_weight), // 0x19 USECODE_INTRINSIC_PTR(get_item_frame), // 0x1a USECODE_INTRINSIC_PTR(set_item_frame), // 0x1b USECODE_INTRINSIC_PTR(get_item_quality), // 0x1c USECODE_INTRINSIC_PTR(set_item_quality), // 0x1d USECODE_INTRINSIC_PTR(get_item_quantity), // 0x1e USECODE_INTRINSIC_PTR(set_item_quantity), // 0x1f USECODE_INTRINSIC_PTR(get_object_position), // 0x20 USECODE_INTRINSIC_PTR(get_distance), // 0x21 USECODE_INTRINSIC_PTR(find_direction), // 0x22 USECODE_INTRINSIC_PTR(get_npc_object), // 0x23 USECODE_INTRINSIC_PTR(get_schedule_type), // 0x24 USECODE_INTRINSIC_PTR(set_schedule_type), // 0x25 USECODE_INTRINSIC_PTR(add_to_party), // 0x26 USECODE_INTRINSIC_PTR(remove_from_party), // 0x27 USECODE_INTRINSIC_PTR(get_npc_prop), // 0x28 USECODE_INTRINSIC_PTR(set_npc_prop), // 0x29 USECODE_INTRINSIC_PTR(get_avatar_ref), // 0x2a USECODE_INTRINSIC_PTR(get_party_list), // 0x2b USECODE_INTRINSIC_PTR(create_new_object), // 0x2c USECODE_INTRINSIC_PTR(create_new_object2), // 0x2d USECODE_INTRINSIC_PTR(set_last_created), // 0x2e USECODE_INTRINSIC_PTR(update_last_created), // 0x2f USECODE_INTRINSIC_PTR(get_npc_name), // 0x30 USECODE_INTRINSIC_PTR(count_objects), // 0x31 USECODE_INTRINSIC_PTR(find_object), // 0x32 USECODE_INTRINSIC_PTR(get_cont_items), // 0x33 USECODE_INTRINSIC_PTR(remove_party_items), // 0x34 USECODE_INTRINSIC_PTR(add_party_items), // 0x35 USECODE_INTRINSIC_PTR(add_cont_items), // 0x36 USECODE_INTRINSIC_PTR(remove_cont_items), // 0x37 USECODE_INTRINSIC_PTR(get_music_track), // 0x38 USECODE_INTRINSIC_PTR(play_music), // 0x39 USECODE_INTRINSIC_PTR(npc_nearby), // 0x3a USECODE_INTRINSIC_PTR(npc_nearby2), // 0x3b Guess. USECODE_INTRINSIC_PTR(find_nearby_avatar), // 0x3c USECODE_INTRINSIC_PTR(is_npc), // 0x3d USECODE_INTRINSIC_PTR(display_runes), // 0x3e USECODE_INTRINSIC_PTR(click_on_item), // 0x3f USECODE_INTRINSIC_PTR(error_message), // 0x40 USECODE_INTRINSIC_PTR(find_nearby), // 0x41 USECODE_INTRINSIC_PTR(give_last_created), // 0x42 USECODE_INTRINSIC_PTR(is_dead), // 0x43 USECODE_INTRINSIC_PTR(game_hour), // 0x44 USECODE_INTRINSIC_PTR(game_minute), // 0x45 USECODE_INTRINSIC_PTR(get_npc_number), // 0x46 USECODE_INTRINSIC_PTR(part_of_day), // 0x47 USECODE_INTRINSIC_PTR(get_alignment), // 0x48 USECODE_INTRINSIC_PTR(set_alignment), // 0x49 USECODE_INTRINSIC_PTR(move_object), // 0x4a USECODE_INTRINSIC_PTR(remove_npc), // 0x4b USECODE_INTRINSIC_PTR(item_say), // 0x4c USECODE_INTRINSIC_PTR(clear_item_say), // 0x4d USECODE_INTRINSIC_PTR(set_to_attack), // 0x4e USECODE_INTRINSIC_PTR(get_lift), // 0x4f USECODE_INTRINSIC_PTR(set_lift), // 0x50 USECODE_INTRINSIC_PTR(get_weather), // 0x51 USECODE_INTRINSIC_PTR(set_weather), // 0x52 USECODE_INTRINSIC_PTR(sit_down), // 0x53 USECODE_INTRINSIC_PTR(summon), // 0x54 USECODE_INTRINSIC_PTR(si_display_map), // 0x55 USECODE_INTRINSIC_PTR(kill_npc), // 0x56 USECODE_INTRINSIC_PTR(roll_to_win), // 0x57 USECODE_INTRINSIC_PTR(set_attack_mode), // 0x58 USECODE_INTRINSIC_PTR(get_attack_mode), // 0x59 USECODE_INTRINSIC_PTR(set_oppressor), // 0x5a USECODE_INTRINSIC_PTR(get_oppressor), // 0x5b USECODE_INTRINSIC_PTR(get_weapon), // 0x5c USECODE_INTRINSIC_PTR(set_opponent), // 0x5d USECODE_INTRINSIC_PTR(clone), // 0x5e USECODE_INTRINSIC_PTR(UNKNOWN), // 0x5f - UNUSED - Same as BG 0x4e/SI 0x60? USECODE_INTRINSIC_PTR(display_area), // 0x60 - UNUSED USECODE_INTRINSIC_PTR(wizard_eye), // 0x61 - UNUSED USECODE_INTRINSIC_PTR(resurrect), // 0x62 USECODE_INTRINSIC_PTR(resurrect_npc), // 0x63 USECODE_INTRINSIC_PTR(get_body_npc), // 0x64 USECODE_INTRINSIC_PTR(add_spell), // 0x65 USECODE_INTRINSIC_PTR(remove_all_spells), // 0x66 USECODE_INTRINSIC_PTR(sprite_effect), // 0x67 USECODE_INTRINSIC_PTR(attack_object), // 0x68 USECODE_INTRINSIC_PTR(book_mode), // 0x69 USECODE_INTRINSIC_PTR(stop_time), // 0x6a USECODE_INTRINSIC_PTR(cause_light), // 0x6b USECODE_INTRINSIC_PTR(get_barge), // 0x6c USECODE_INTRINSIC_PTR(earthquake), // 0x6d USECODE_INTRINSIC_PTR(is_pc_female), // 0x6e USECODE_INTRINSIC_PTR(armageddon), // 0x6f - UNUSED USECODE_INTRINSIC_PTR(halt_scheduled), // 0x70 USECODE_INTRINSIC_PTR(lightning), // 0x71 USECODE_INTRINSIC_PTR(get_array_size), // 0x72 USECODE_INTRINSIC_PTR(mark_virtue_stone), // 0x73 USECODE_INTRINSIC_PTR(recall_virtue_stone), // 0x74 USECODE_INTRINSIC_PTR(apply_damage), // 0x75 USECODE_INTRINSIC_PTR(is_pc_inside), // 0x76 USECODE_INTRINSIC_PTR(UNKNOWN), // 0x77 - UNUSED - Seems like it could be set_orrery, but does nothing USECODE_INTRINSIC_PTR(UNKNOWN), // 0x78 - UNUSED - Same as BG 0x64/SI 0x79? Something with palettes USECODE_INTRINSIC_PTR(get_timer), // 0x79 USECODE_INTRINSIC_PTR(set_timer), // 0x7a USECODE_INTRINSIC_PTR(wearing_fellowship), // 0x7b USECODE_INTRINSIC_PTR(mouse_exists), // 0x7c USECODE_INTRINSIC_PTR(get_speech_track), // 0x7d USECODE_INTRINSIC_PTR(flash_mouse), // 0x7e USECODE_INTRINSIC_PTR(get_item_frame_rot), // 0x7f USECODE_INTRINSIC_PTR(set_item_frame_rot), // 0x80 USECODE_INTRINSIC_PTR(on_barge), // 0x81 USECODE_INTRINSIC_PTR(get_container), // 0x82 USECODE_INTRINSIC_PTR(remove_item), // 0x83 USECODE_INTRINSIC_PTR(init_conversation), // 0x84 USECODE_INTRINSIC_PTR(end_conversation), // 0x85 USECODE_INTRINSIC_PTR(reduce_health), // 0x86 USECODE_INTRINSIC_PTR(is_readied), // 0x87 USECODE_INTRINSIC_PTR(restart_game), // 0x88 USECODE_INTRINSIC_PTR(start_speech), // 0x89 USECODE_INTRINSIC_PTR(run_endgame), // 0x8a USECODE_INTRINSIC_PTR(fire_projectile), // 0x8b USECODE_INTRINSIC_PTR(nap_time), // 0x8c USECODE_INTRINSIC_PTR(advance_time), // 0x8d USECODE_INTRINSIC_PTR(in_usecode), // 0x8e USECODE_INTRINSIC_PTR(call_guards), // 0x8f USECODE_INTRINSIC_PTR(obj_sprite_effect), // 0x90 USECODE_INTRINSIC_PTR(attack_avatar), // 0x91 USECODE_INTRINSIC_PTR(stop_arresting), // 0x92 USECODE_INTRINSIC_PTR(path_run_usecode), // 0x93 USECODE_INTRINSIC_PTR(sib_path_run_usecode), // 0x94 USECODE_INTRINSIC_PTR(can_avatar_reach_pos), // 0x95 USECODE_INTRINSIC_PTR(sib_is_dest_reachable), // 0x96 USECODE_INTRINSIC_PTR(close_gumps), // 0x97 USECODE_INTRINSIC_PTR(item_say), // 0x98 - item_say in gump USECODE_INTRINSIC_PTR(close_gump), // 0x99 USECODE_INTRINSIC_PTR(in_gump_mode), // 0x9a USECODE_INTRINSIC_PTR(set_light), // 0x9b USECODE_INTRINSIC_PTR(UNKNOWN), // 0x9c - UNUSED - Same as BG 0x83/SI 0x9b? Something with palettes USECODE_INTRINSIC_PTR(set_time_palette), // 0x9d USECODE_INTRINSIC_PTR(ambient_light), // 0x9e USECODE_INTRINSIC_PTR(is_not_blocked), // 0x9f USECODE_INTRINSIC_PTR(play_sound_effect2), // 0xa0 USECODE_INTRINSIC_PTR(direction_from), // 0xa1 USECODE_INTRINSIC_PTR(get_item_flag), // 0xa2 USECODE_INTRINSIC_PTR(set_item_flag), // 0xa3 USECODE_INTRINSIC_PTR(clear_item_flag), // 0xa4 USECODE_INTRINSIC_PTR(get_skin_colour), // 0xa5 USECODE_INTRINSIC_PTR(set_path_failure), // 0xa6 USECODE_INTRINSIC_PTR(fade_palette), // 0xa7 USECODE_INTRINSIC_PTR(fade_palette_sleep), // 0xa8 USECODE_INTRINSIC_PTR(get_party_list2), // 0xa9 USECODE_INTRINSIC_PTR(in_combat), // 0xaa USECODE_INTRINSIC_PTR(is_water), // 0xab USECODE_INTRINSIC_PTR(reset_conv_face), // 0xac - UNUSED USECODE_INTRINSIC_PTR(set_camera), // 0xad USECODE_INTRINSIC_PTR(get_dead_party), // 0xae - UNUSED USECODE_INTRINSIC_PTR(view_tile), // 0xaf - UNUSED USECODE_INTRINSIC_PTR(telekenesis), // 0xb0 USECODE_INTRINSIC_PTR(a_or_an), // 0xb1 USECODE_INTRINSIC_PTR(set_polymorph), // 0xb2 USECODE_INTRINSIC_PTR(revert_schedule), // 0xb3 USECODE_INTRINSIC_PTR(modify_schedule), // 0xb4 USECODE_INTRINSIC_PTR(set_new_schedules), // 0xb5 USECODE_INTRINSIC_PTR(run_schedule), // 0xb6 USECODE_INTRINSIC_PTR(get_temperature), // 0xb7 USECODE_INTRINSIC_PTR(get_temperature_zone), // 0xb8 - UNUSED USECODE_INTRINSIC_PTR(set_temperature), // 0xb9 USECODE_INTRINSIC_PTR(get_npc_warmth), // 0xba - UNUSED USECODE_INTRINSIC_PTR(get_npc_id), // 0xbb USECODE_INTRINSIC_PTR(set_npc_id), // 0xbc USECODE_INTRINSIC_PTR(get_readied), // 0xbd USECODE_INTRINSIC_PTR(approach_avatar), // 0xbe USECODE_INTRINSIC_PTR(set_barge_dir), // 0xbf USECODE_INTRINSIC_PTR(si_path_run_usecode), // 0xc0 // These are SS-only, but we won't bother with the distinction. USECODE_INTRINSIC_PTR(is_on_keyring), // 0xc1 (Exult) USECODE_INTRINSIC_PTR(add_to_keyring), // 0xc2 (Exult) USECODE_INTRINSIC_PTR(remove_from_area), // 0xc3 (Exult) USECODE_INTRINSIC_PTR(infravision), // 0xc4 (Exult) // These are Exult-specific. USECODE_INTRINSIC_PTR(set_intercept_item), // 0xc5 (Exult) USECODE_INTRINSIC_PTR(printf), // 0xc6 (Exult) USECODE_INTRINSIC_PTR(remove_from_keyring), // 0xc7 (Exult) USECODE_INTRINSIC_PTR(begin_casting_mode), // 0xc8 (Exult) USECODE_INTRINSIC_PTR(get_usecode_fun), // 0xc9 (Exult) USECODE_INTRINSIC_PTR(get_map_num), // 0xca (Exult) USECODE_INTRINSIC_PTR(display_map_ex), // 0xcb (Exult) USECODE_INTRINSIC_PTR(book_mode_ex), // 0xcc (Exult) // Here, Exult supports BG intrinsics for users of UCC. USECODE_INTRINSIC_PTR(UNKNOWN), // 0xcd USECODE_INTRINSIC_PTR(center_view), // 0xce USECODE_INTRINSIC_PTR(UNKNOWN), // 0xcf USECODE_INTRINSIC_PTR(is_dest_reachable), // 0xd0 USECODE_INTRINSIC_PTR(set_npc_name), // 0xd1 USECODE_INTRINSIC_PTR(set_usecode_fun), // 0xd2 USECODE_INTRINSIC_PTR(has_spell), // 0xd3 USECODE_INTRINSIC_PTR(remove_spell), // 0xd4 USECODE_INTRINSIC_PTR(create_barge_object), // 0xd5 USECODE_INTRINSIC_PTR(in_usecode_path), // 0xd6 USECODE_INTRINSIC_PTR(start_blocking_speech), // 0xd7 USECODE_INTRINSIC_PTR(close_gumps2), // 0xd8 USECODE_INTRINSIC_PTR(close_gump2), // 0xd9 USECODE_INTRINSIC_PTR(game_day), // 0xda (Exult) USECODE_INTRINSIC_PTR(UNKNOWN), // 0xdb USECODE_INTRINSIC_PTR(UNKNOWN), // 0xdc USECODE_INTRINSIC_PTR(UNKNOWN), // 0xdd USECODE_INTRINSIC_PTR(UNKNOWN), // 0xde USECODE_INTRINSIC_PTR(UNKNOWN), // 0xdf USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe0 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe1 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe2 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe3 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe4 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe5 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe6 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe7 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe8 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xe9 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xea USECODE_INTRINSIC_PTR(UNKNOWN), // 0xeb USECODE_INTRINSIC_PTR(UNKNOWN), // 0xec USECODE_INTRINSIC_PTR(UNKNOWN), // 0xed USECODE_INTRINSIC_PTR(UNKNOWN), // 0xee USECODE_INTRINSIC_PTR(UNKNOWN), // 0xef USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf0 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf1 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf2 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf3 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf4 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf5 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf6 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf7 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf8 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xf9 USECODE_INTRINSIC_PTR(UNKNOWN), // 0xfa USECODE_INTRINSIC_PTR(UNKNOWN), // 0xfb USECODE_INTRINSIC_PTR(UNKNOWN), // 0xfc USECODE_INTRINSIC_PTR(UNKNOWN), // 0xfd USECODE_INTRINSIC_PTR(UNKNOWN), // 0xfe USECODE_INTRINSIC_PTR(UNKNOWN), // 0xff
exult/exult
usecode/sibetaintrinsics.h
C
gpl-2.0
17,659
body, #container, #header, #footer { background-color: #3d4455; }
Mukeysh/alf_git
sites/all/themes/openscholar/scholar_eloquent/flavors/blue/blue.css
CSS
gpl-2.0
69
/* * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * File: datarate.c * * Purpose: Handles the auto fallback & data rates functions * * Author: Lyndon Chen * * Date: July 17, 2002 * * Functions: * RATEvParseMaxRate - Parsing the highest basic & support rate in rate field of frame * RATEvTxRateFallBack - Rate fallback Algorithm Implementaion * RATEuSetIE- Set rate IE field. * * Revision History: * */ #include "ttype.h" #include "tmacro.h" #include "mac.h" #include "80211mgr.h" #include "bssdb.h" #include "datarate.h" #include "card.h" #include "baseband.h" #include "srom.h" #include "rf.h" /*--------------------- Static Definitions -------------------------*/ /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ //static int msglevel =MSG_LEVEL_DEBUG; static int msglevel =MSG_LEVEL_INFO; const BYTE acbyIERate[MAX_RATE] = {0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; #define AUTORATE_TXOK_CNT 0x0400 #define AUTORATE_TXFAIL_CNT 0x0064 #define AUTORATE_TIMEOUT 10 /*--------------------- Static Functions --------------------------*/ void s_vResetCounter(PKnownNodeDB psNodeDBTable); void s_vResetCounter(PKnownNodeDB psNodeDBTable) { BYTE ii; // clear statistic counter for auto_rate <<<<<<< HEAD for (ii = 0; ii <= MAX_RATE; ii++) { ======= for(ii=0;ii<=MAX_RATE;ii++) { >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a psNodeDBTable->uTxOk[ii] = 0; psNodeDBTable->uTxFail[ii] = 0; } } /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ /*+ * * Description: * Get RateIdx from the value in SuppRates IE or ExtSuppRates IE * * Parameters: * In: * BYTE - Rate value in SuppRates IE or ExtSuppRates IE * Out: * none * * Return Value: RateIdx * -*/ BYTE DATARATEbyGetRateIdx ( BYTE byRate ) { BYTE ii; //Erase basicRate flag. byRate = byRate & 0x7F;//0111 1111 for (ii = 0; ii < MAX_RATE; ii ++) { if (acbyIERate[ii] == byRate) return ii; } return 0; } /*+ * * Routine Description: * Rate fallback Algorithm Implementaion * * Parameters: * In: * pDevice - Pointer to the adapter * psNodeDBTable - Pointer to Node Data Base * Out: * none * * Return Value: none * -*/ #define AUTORATE_TXCNT_THRESHOLD 20 #define AUTORATE_INC_THRESHOLD 30 /*+ * * Description: * Get RateIdx from the value in SuppRates IE or ExtSuppRates IE * * Parameters: * In: * BYTE - Rate value in SuppRates IE or ExtSuppRates IE * Out: * none * * Return Value: RateIdx * -*/ WORD RATEwGetRateIdx( BYTE byRate ) { WORD ii; //Erase basicRate flag. byRate = byRate & 0x7F;//0111 1111 for (ii = 0; ii < MAX_RATE; ii ++) { if (acbyIERate[ii] == byRate) return ii; } return 0; } /*+ * * Description: * Parsing the highest basic & support rate in rate field of frame. * * Parameters: * In: * pDevice - Pointer to the adapter * pItemRates - Pointer to Rate field defined in 802.11 spec. * pItemExtRates - Pointer to Extended Rate field defined in 802.11 spec. * Out: * pwMaxBasicRate - Maximum Basic Rate * pwMaxSuppRate - Maximum Supported Rate * pbyTopCCKRate - Maximum Basic Rate in CCK mode * pbyTopOFDMRate - Maximum Basic Rate in OFDM mode * * Return Value: none * -*/ void RATEvParseMaxRate( void *pDeviceHandler, PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pItemExtRates, BOOL bUpdateBasicRate, PWORD pwMaxBasicRate, PWORD pwMaxSuppRate, PWORD pwSuppRate, PBYTE pbyTopCCKRate, PBYTE pbyTopOFDMRate ) { PSDevice pDevice = (PSDevice) pDeviceHandler; unsigned int ii; BYTE byHighSuppRate = 0; BYTE byRate = 0; WORD wOldBasicRate = pDevice->wBasicRate; unsigned int uRateLen; if (pItemRates == NULL) return; *pwSuppRate = 0; uRateLen = pItemRates->len; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate Len: %d\n", uRateLen); if (pDevice->byBBType != BB_TYPE_11B) { if (uRateLen > WLAN_RATES_MAXLEN) uRateLen = WLAN_RATES_MAXLEN; } else { if (uRateLen > WLAN_RATES_MAXLEN_11B) uRateLen = WLAN_RATES_MAXLEN_11B; } for (ii = 0; ii < uRateLen; ii++) { byRate = (BYTE)(pItemRates->abyRates[ii]); if (WLAN_MGMT_IS_BASICRATE(byRate) && (bUpdateBasicRate == TRUE)) { // Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate CARDbAddBasicRate((void *)pDevice, RATEwGetRateIdx(byRate)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", RATEwGetRateIdx(byRate)); } byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F); if (byHighSuppRate == 0) byHighSuppRate = byRate; if (byRate > byHighSuppRate) byHighSuppRate = byRate; *pwSuppRate |= (1<<RATEwGetRateIdx(byRate)); } if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) && (pDevice->byBBType != BB_TYPE_11B)) { unsigned int uExtRateLen = pItemExtRates->len; if (uExtRateLen > WLAN_RATES_MAXLEN) uExtRateLen = WLAN_RATES_MAXLEN; for (ii = 0; ii < uExtRateLen ; ii++) { byRate = (BYTE)(pItemExtRates->abyRates[ii]); // select highest basic rate if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) { // Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate CARDbAddBasicRate((void *)pDevice, RATEwGetRateIdx(byRate)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", RATEwGetRateIdx(byRate)); } byRate = (BYTE)(pItemExtRates->abyRates[ii]&0x7F); if (byHighSuppRate == 0) byHighSuppRate = byRate; if (byRate > byHighSuppRate) byHighSuppRate = byRate; *pwSuppRate |= (1<<RATEwGetRateIdx(byRate)); //DBG_PRN_GRP09(("ParseMaxRate : HighSuppRate: %d, %X\n", RATEwGetRateIdx(byRate), byRate)); } } //if(pItemExtRates != NULL) if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((void *)pDevice)) { pDevice->byPacketType = PK_TYPE_11GA; } *pbyTopCCKRate = pDevice->byTopCCKBasicRate; *pbyTopOFDMRate = pDevice->byTopOFDMBasicRate; *pwMaxSuppRate = RATEwGetRateIdx(byHighSuppRate); if ((pDevice->byPacketType==PK_TYPE_11B) || (pDevice->byPacketType==PK_TYPE_11GB)) *pwMaxBasicRate = pDevice->byTopCCKBasicRate; else *pwMaxBasicRate = pDevice->byTopOFDMBasicRate; if (wOldBasicRate != pDevice->wBasicRate) CARDvSetRSPINF((void *)pDevice, pDevice->byBBType); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Exit ParseMaxRate\n"); } /*+ * * Routine Description: * Rate fallback Algorithm Implementaion * * Parameters: * In: * pDevice - Pointer to the adapter * psNodeDBTable - Pointer to Node Data Base * Out: * none * * Return Value: none * -*/ #define AUTORATE_TXCNT_THRESHOLD 20 #define AUTORATE_INC_THRESHOLD 30 void RATEvTxRateFallBack( void *pDeviceHandler, PKnownNodeDB psNodeDBTable ) { PSDevice pDevice = (PSDevice) pDeviceHandler; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); <<<<<<< HEAD ======= #if 1 //mike fixed old: use packet lose ratio algorithm to control rate >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a WORD wIdxDownRate = 0; unsigned int ii; BOOL bAutoRate[MAX_RATE] = {TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE}; DWORD dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540}; DWORD dwThroughput = 0; WORD wIdxUpRate = 0; DWORD dwTxDiff = 0; if (pMgmt->eScanState != WMAC_NO_SCANNING) { // Don't do Fallback when scanning Channel return; } psNodeDBTable->uTimeCount ++; if (psNodeDBTable->uTxFail[MAX_RATE] > psNodeDBTable->uTxOk[MAX_RATE]) dwTxDiff = psNodeDBTable->uTxFail[MAX_RATE] - psNodeDBTable->uTxOk[MAX_RATE]; if ((psNodeDBTable->uTxOk[MAX_RATE] < AUTORATE_TXOK_CNT) && (dwTxDiff < AUTORATE_TXFAIL_CNT) && (psNodeDBTable->uTimeCount < AUTORATE_TIMEOUT)) { return; } if (psNodeDBTable->uTimeCount >= AUTORATE_TIMEOUT) { psNodeDBTable->uTimeCount = 0; } <<<<<<< HEAD for (ii = 0; ii < MAX_RATE; ii++) { ======= for(ii=0;ii<MAX_RATE;ii++) { >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a if (psNodeDBTable->wSuppRate & (0x0001<<ii)) { if (bAutoRate[ii] == TRUE) { wIdxUpRate = (WORD) ii; } } else { bAutoRate[ii] = FALSE; } } <<<<<<< HEAD for (ii = 0; ii <= psNodeDBTable->wTxDataRate; ii++) { ======= for(ii=0;ii<=psNodeDBTable->wTxDataRate;ii++) { >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a if ( (psNodeDBTable->uTxOk[ii] != 0) || (psNodeDBTable->uTxFail[ii] != 0) ) { dwThroughputTbl[ii] *= psNodeDBTable->uTxOk[ii]; if (ii < RATE_11M) { psNodeDBTable->uTxFail[ii] *= 4; } dwThroughputTbl[ii] /= (psNodeDBTable->uTxOk[ii] + psNodeDBTable->uTxFail[ii]); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate %d,Ok: %d, Fail:%d, Throughput:%d\n", ii, (int)psNodeDBTable->uTxOk[ii], (int)psNodeDBTable->uTxFail[ii], (int)dwThroughputTbl[ii]); } dwThroughput = dwThroughputTbl[psNodeDBTable->wTxDataRate]; wIdxDownRate = psNodeDBTable->wTxDataRate; <<<<<<< HEAD for (ii = psNodeDBTable->wTxDataRate; ii > 0;) { ======= for(ii = psNodeDBTable->wTxDataRate; ii > 0;) { >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a ii--; if ( (dwThroughputTbl[ii] > dwThroughput) && (bAutoRate[ii]==TRUE) ) { dwThroughput = dwThroughputTbl[ii]; wIdxDownRate = (WORD) ii; } } psNodeDBTable->wTxDataRate = wIdxDownRate; if (psNodeDBTable->uTxOk[MAX_RATE]) { if (psNodeDBTable->uTxOk[MAX_RATE] > (psNodeDBTable->uTxFail[MAX_RATE] * 4) ) { psNodeDBTable->wTxDataRate = wIdxUpRate; } }else { // adhoc, if uTxOk(total) =0 & uTxFail(total) = 0 if (psNodeDBTable->uTxFail[MAX_RATE] == 0) psNodeDBTable->wTxDataRate = wIdxUpRate; } if (pDevice->byBBType == BB_TYPE_11A) { if (psNodeDBTable->wTxDataRate <= RATE_11M) psNodeDBTable->wTxDataRate = RATE_6M; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uTxOk[MAX_RATE] %d, uTxFail[MAX_RATE]:%d\n",(int)psNodeDBTable->uTxOk[MAX_RATE], (int)psNodeDBTable->uTxFail[MAX_RATE]); s_vResetCounter(psNodeDBTable); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate: %d, U:%d, D:%d\n", (int)psNodeDBTable->wTxDataRate, (int)wIdxUpRate, (int)wIdxDownRate); return; <<<<<<< HEAD ======= #else //mike fixed new: use differ-signal strength to control rate WORD wIdxUpRate = 0; BOOL bAutoRate[MAX_RATE] = {TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE}; unsigned int ii; long ldBm; if (pMgmt->eScanState != WMAC_NO_SCANNING) { // Don't do Fallback when scanning Channel return; } for(ii=0;ii<MAX_RATE;ii++) { if (psNodeDBTable->wSuppRate & (0x0001<<ii)) { if (bAutoRate[ii] == TRUE) { wIdxUpRate = (WORD) ii; } } else { bAutoRate[ii] = FALSE; } } RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm); if (ldBm > -55) { if ( psNodeDBTable->wSuppRate & (0x0001<<RATE_54M) ) //11a/g { psNodeDBTable->wTxDataRate = RATE_54M; } else{ //11b psNodeDBTable->wTxDataRate = RATE_11M; } } if (wIdxUpRate == RATE_54M ) { //11a/g if (ldBm > -56 ) psNodeDBTable->wTxDataRate = RATE_54M; else if (ldBm > -61 ) psNodeDBTable->wTxDataRate = RATE_48M; else if (ldBm > -66 ) psNodeDBTable->wTxDataRate = RATE_36M; else if (ldBm > -72 ) psNodeDBTable->wTxDataRate = RATE_24M; else if (ldBm > -80 ) psNodeDBTable->wTxDataRate = RATE_5M; else { psNodeDBTable->wTxDataRate = RATE_1M; //increasingVGA = TRUE; } } else { //11b if (ldBm > -65 ) psNodeDBTable->wTxDataRate = RATE_11M; else if (ldBm > -75 ) psNodeDBTable->wTxDataRate = RATE_5M; else psNodeDBTable->wTxDataRate = RATE_1M; } return; #endif >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a } /*+ * * Description: * This routine is used to assemble available Rate IE. * * Parameters: * In: * pDevice * Out: * * Return Value: None * -*/ BYTE RATEuSetIE ( PWLAN_IE_SUPP_RATES pSrcRates, PWLAN_IE_SUPP_RATES pDstRates, unsigned int uRateLen ) { unsigned int ii, uu, uRateCnt = 0; if ((pSrcRates == NULL) || (pDstRates == NULL)) return 0; if (pSrcRates->len == 0) return 0; for (ii = 0; ii < uRateLen; ii++) { for (uu = 0; uu < pSrcRates->len; uu++) { if ((pSrcRates->abyRates[uu] & 0x7F) == acbyIERate[ii]) { pDstRates->abyRates[uRateCnt ++] = pSrcRates->abyRates[uu]; break; } } } return (BYTE)uRateCnt; }
Core2idiot/Kernel-Samsung-3.0...-
drivers/staging/vt6656/datarate.c
C
gpl-2.0
14,607
// typeview.h - Declaration of CExtensionListControl and CTypeView // // WinDirStat - Directory Statistics // Copyright (C) 2003-2004 Bernhard Seifert // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Author: bseifert@users.sourceforge.net, bseifert@daccord.net // // Last modified: $Date: 2004/11/12 22:14:16 $ #pragma once #include "dirstatdoc.h" // SExtensionRecord class CTypeView; // // CExtensionListControl. // class CExtensionListControl: public COwnerDrawnListControl { protected: // Columns enum { COL_EXTENSION, COL_COLOR, COL_DESCRIPTION, COL_BYTES, COL_BYTESPERCENT, COL_FILES }; // CListItem. The items of the CExtensionListControl. class CListItem: public COwnerDrawnListItem { public: CListItem(CExtensionListControl *list, LPCTSTR extension, SExtensionRecord r); virtual bool DrawSubitem(int subitem, CDC *pdc, CRect rc, UINT state, int *width, int *focusLeft) const; virtual CString GetText(int subitem) const; CString GetExtension() const; int GetImage() const; int Compare(const CSortingListItem *other, int subitem) const; private: void DrawColor(CDC *pdc, CRect rc, UINT state, int *width) const; CString GetDescription() const; CString GetBytesPercent() const; double GetBytesFraction() const; CExtensionListControl *m_list; CString m_extension; SExtensionRecord m_record; mutable CString m_description; mutable int m_image; }; public: CExtensionListControl(CTypeView *typeView); virtual bool GetAscendingDefault(int column); void Initialize(); void SetExtensionData(const CExtensionData *ed); void SetRootSize(LONGLONG totalBytes); LONGLONG GetRootSize(); void SelectExtension(LPCTSTR ext); CString GetSelectedExtension(); protected: CListItem *GetListItem(int i); CTypeView *m_typeView; LONGLONG m_rootSize; DECLARE_MESSAGE_MAP() afx_msg void OnDestroy(); afx_msg void OnLvnDeleteitem(NMHDR *pNMHDR, LRESULT *pResult); afx_msg void MeasureItem(LPMEASUREITEMSTRUCT mis); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); }; // // CTypeView. The upper right view, which shows the extensions and their // cushion colors. // class CTypeView: public CView { protected: CTypeView(); DECLARE_DYNCREATE(CTypeView) public: virtual ~CTypeView(); CDirstatDoc* GetDocument() const; void SysColorChanged(); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); bool IsShowTypes(); void ShowTypes(bool show); void SetHighlightExtension(LPCTSTR ext); protected: virtual void OnInitialUpdate(); virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); virtual void OnDraw(CDC* pDC); void SetSelection(); bool m_showTypes; // Whether this view shall be shown (F8 option) CExtensionListControl m_extensionListControl; // The list control DECLARE_MESSAGE_MAP() afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnSetFocus(CWnd* pOldWnd); public: #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; #ifndef _DEBUG // Debugversion in typeview.cpp inline CDirstatDoc* CTypeView::GetDocument() const { return reinterpret_cast<CDirstatDoc*>(m_pDocument); } #endif // $Log: typeview.h,v $ // Revision 1.9 2004/11/12 22:14:16 bseifert // Eliminated CLR_NONE. Minor corrections. // // Revision 1.8 2004/11/12 00:47:42 assarbad // - Fixed the code for coloring of compressed/encrypted items. Now the coloring spans the full row! // // Revision 1.7 2004/11/08 00:46:26 assarbad // - Added feature to distinguish compressed and encrypted files/folders by color as in the Windows 2000/XP explorer. // Same rules apply. (Green = encrypted / Blue = compressed) // // Revision 1.6 2004/11/05 16:53:08 assarbad // Added Date and History tag where appropriate. //
Meitinger/windirstat
typeview.h
C
gpl-2.0
4,637
/* * Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "Battlefield.h" #include "BattlefieldMgr.h" #include "Battleground.h" #include "BattlegroundPackets.h" #include "CellImpl.h" #include "CreatureTextMgr.h" #include "DB2Stores.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "Group.h" #include "GroupMgr.h" #include "Log.h" #include "Map.h" #include "MapManager.h" #include "MiscPackets.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "WorldSession.h" #include "WorldStatePackets.h" #include <G3D/g3dmath.h> Battlefield::Battlefield() { _scriptType = ZONE_SCRIPT_TYPE_BATTLEFIELD; m_Timer = 0; m_IsEnabled = true; m_isActive = false; m_DefenderTeam = TEAM_NEUTRAL; m_TypeId = 0; m_BattleId = 0; m_ZoneId = 0; m_Map = nullptr; m_MapId = 0; m_MaxPlayer = 0; m_MinPlayer = 0; m_MinLevel = 0; m_BattleTime = 0; m_NoWarBattleTime = 0; m_RestartAfterCrash = 0; m_TimeForAcceptInvite = 20; m_uiKickDontAcceptTimer = 1000; m_uiKickAfkPlayersTimer = 1000; m_LastResurrectTimer = 30 * IN_MILLISECONDS; m_StartGroupingTimer = 0; m_StartGrouping = false; } Battlefield::~Battlefield() { for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) delete itr->second; for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr) delete *itr; } // Called when a player enters the zone void Battlefield::HandlePlayerEnterZone(Player* player, Area* /*zone*/) { // If battle is started, // If not full of players > invite player to join the war // If full of players > announce to player that BF is full and kick him after a few second if he desn't leave if (IsWarTime()) { if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) // Vacant spaces InvitePlayerToWar(player); else // No more vacant places { /// @todo Send a packet to announce it to player m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(nullptr) + 10; InvitePlayerToQueue(player); } } else { // If time left is < 15 minutes invite player to join queue if (m_Timer <= m_StartGroupingTimer) InvitePlayerToQueue(player); } // Add player in the list of player in zone m_players[player->GetTeamId()].insert(player->GetGUID()); OnPlayerEnterZone(player); } // Called when a player leave the zone void Battlefield::HandlePlayerLeaveZone(Player* player, Area* /*zone*/) { if (IsWarTime()) { // If the player is participating to the battle if (m_PlayersInWar[player->GetTeamId()].find(player->GetGUID()) != m_PlayersInWar[player->GetTeamId()].end()) { m_PlayersInWar[player->GetTeamId()].erase(player->GetGUID()); player->GetSession()->SendBfLeaveMessage(GetQueueId(), GetState(), player->GetZoneId() == GetZoneId()); if (Group* group = player->GetGroup()) // Remove the player from the raid group group->RemoveMember(player->GetGUID()); OnPlayerLeaveWar(player); } } for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) itr->second->HandlePlayerLeave(player); m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID()); m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID()); m_players[player->GetTeamId()].erase(player->GetGUID()); SendRemoveWorldStates(player); RemovePlayerFromResurrectQueue(player->GetGUID()); OnPlayerLeaveZone(player); } bool Battlefield::Update(uint32 diff) { if (m_Timer <= diff) { // Battlefield ends on time if (IsWarTime()) EndBattle(true); else // Time to start a new battle! StartBattle(); } else m_Timer -= diff; // Invite players a few minutes before the battle's beginning if (!IsWarTime() && !m_StartGrouping && m_Timer <= m_StartGroupingTimer) { m_StartGrouping = true; InvitePlayersInZoneToQueue(); OnStartGrouping(); } bool objective_changed = false; if (IsWarTime()) { if (m_uiKickAfkPlayersTimer <= diff) { m_uiKickAfkPlayersTimer = 1000; KickAfkPlayers(); } else m_uiKickAfkPlayersTimer -= diff; // Kick players who chose not to accept invitation to the battle if (m_uiKickDontAcceptTimer <= diff) { time_t now = time(nullptr); for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); ++itr) if (itr->second <= now) KickPlayerFromBattlefield(itr->first); InvitePlayersInZoneToWar(); for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (PlayerTimerMap::iterator itr = m_PlayersWillBeKick[team].begin(); itr != m_PlayersWillBeKick[team].end(); ++itr) if (itr->second <= now) KickPlayerFromBattlefield(itr->first); m_uiKickDontAcceptTimer = 1000; } else m_uiKickDontAcceptTimer -= diff; for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) if (itr->second->Update(diff)) objective_changed = true; } if (m_LastResurrectTimer <= diff) { for (uint8 i = 0; i < m_GraveyardList.size(); i++) if (GetGraveyardById(i)) m_GraveyardList[i]->Resurrect(); m_LastResurrectTimer = RESURRECTION_INTERVAL; } else m_LastResurrectTimer -= diff; return objective_changed; } void Battlefield::InvitePlayersInZoneToQueue() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) InvitePlayerToQueue(player); } void Battlefield::InvitePlayerToQueue(Player* player) { if (m_PlayersInQueue[player->GetTeamId()].count(player->GetGUID())) return; if (m_PlayersInQueue[player->GetTeamId()].size() <= m_MinPlayer || m_PlayersInQueue[GetOtherTeam(player->GetTeamId())].size() >= m_MinPlayer) player->GetSession()->SendBfInvitePlayerToQueue(GetQueueId(), GetState()); } void Battlefield::InvitePlayersInQueueToWar() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) { for (auto itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) InvitePlayerToWar(player); else { //Full } } } m_PlayersInQueue[team].clear(); } } void Battlefield::InvitePlayersInZoneToWar() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) { for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID())) continue; if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) InvitePlayerToWar(player); else // Battlefield is full of players m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(nullptr) + 10; } } } } uint64 Battlefield::GetQueueId() const { return MAKE_PAIR64(m_BattleId | 0x20000, 0x1F100000); } void Battlefield::InvitePlayerToWar(Player* player) { if (!player) return; /// @todo needed ? if (player->IsInFlight()) return; if (player->InArena() || player->GetBattleground()) { m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID()); return; } // If the player does not match minimal level requirements for the battlefield, kick him if (player->getLevel() < m_MinLevel) { if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0) m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(nullptr) + 10; return; } // Check if player is not already in war if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID())) return; m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID()); m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = time(nullptr) + m_TimeForAcceptInvite; player->GetSession()->SendBfInvitePlayerToWar(GetQueueId(), m_ZoneId, m_TimeForAcceptInvite); } void Battlefield::InitStalker(uint32 entry, Position const& pos) { if (Creature* creature = SpawnCreature(entry, pos)) StalkerGuid = creature->GetGUID(); else TC_LOG_ERROR("bg.battlefield", "Battlefield::InitStalker: Could not spawn Stalker (Creature entry %u), zone messages will be unavailable!", entry); } void Battlefield::KickAfkPlayers() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (player->isAFK()) KickPlayerFromBattlefield(*itr); } void Battlefield::KickPlayerFromBattlefield(ObjectGuid guid) { if (Player* player = ObjectAccessor::FindPlayer(guid)) if (player->GetZoneId() == GetZoneId()) player->TeleportTo(KickPosition); } void Battlefield::StartBattle() { if (m_isActive) return; for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) { m_PlayersInWar[team].clear(); m_Groups[team].clear(); } m_Timer = m_BattleTime; m_isActive = true; InvitePlayersInZoneToWar(); InvitePlayersInQueueToWar(); OnBattleStart(); } void Battlefield::EndBattle(bool endByTimer) { if (!m_isActive) return; m_isActive = false; m_StartGrouping = false; if (!endByTimer) SetDefenderTeam(GetAttackerTeam()); OnBattleEnd(endByTimer); // Reset battlefield timer m_Timer = m_NoWarBattleTime; SendInitWorldStatesToAll(); } void Battlefield::DoPlaySoundToAll(uint32 soundID) { BroadcastPacketToWar(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write()); } bool Battlefield::HasPlayer(Player* player) const { return m_players[player->GetTeamId()].find(player->GetGUID()) != m_players[player->GetTeamId()].end(); } // Called in WorldSession::HandleBfQueueInviteResponse void Battlefield::PlayerAcceptInviteToQueue(Player* player) { // Add player in queue m_PlayersInQueue[player->GetTeamId()].insert(player->GetGUID()); // Send notification player->GetSession()->SendBfQueueInviteResponse(GetQueueId(), m_ZoneId, GetState()); } // Called in WorldSession::HandleBfExitRequest void Battlefield::AskToLeaveQueue(Player* player) { // Remove player from queue m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID()); } // Called in WorldSession::HandleHearthAndResurrect void Battlefield::PlayerAskToLeave(Player* player) { // Player leaving Wintergrasp, teleport to Dalaran. // ToDo: confirm teleport destination. player->TeleportTo(571, 5804.1499f, 624.7710f, 647.7670f, 1.6400f); } // Called in WorldSession::HandleBfEntryInviteResponse void Battlefield::PlayerAcceptInviteToWar(Player* player) { if (!IsWarTime()) return; if (AddOrSetPlayerToCorrectBfGroup(player)) { player->GetSession()->SendBfEntered(GetQueueId(), player->GetZoneId() != GetZoneId(), player->GetTeamId() == GetAttackerTeam()); m_PlayersInWar[player->GetTeamId()].insert(player->GetGUID()); m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID()); if (player->isAFK()) player->ToggleAFK(); OnPlayerJoinWar(player); //for scripting } } void Battlefield::TeamCastSpell(TeamId team, int32 spellId) { if (spellId > 0) { for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->CastSpell(player, uint32(spellId), true); } else { for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->RemoveAuraFromStack(uint32(-spellId)); } } void Battlefield::BroadcastPacketToZone(WorldPacket const* data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->SendDirectMessage(data); } void Battlefield::BroadcastPacketToQueue(WorldPacket const* data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (auto itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) if (Player* player = ObjectAccessor::FindConnectedPlayer(*itr)) player->SendDirectMessage(data); } void Battlefield::BroadcastPacketToWar(WorldPacket const* data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->SendDirectMessage(data); } void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/) { if (Creature* stalker = GetCreature(StalkerGuid)) sCreatureTextMgr->SendChat(stalker, id, target); } void Battlefield::SendUpdateWorldState(uint32 variable, uint32 value, bool hidden /*= false*/) { WorldPackets::WorldState::UpdateWorldState worldstate; worldstate.VariableID = variable; worldstate.Value = value; worldstate.Hidden = hidden; BroadcastPacketToZone(worldstate.Write()); } void Battlefield::AddCapturePoint(BfCapturePoint* cp) { Battlefield::BfCapturePointMap::iterator i = m_capturePoints.find(cp->GetCapturePointEntry()); if (i != m_capturePoints.end()) { TC_LOG_ERROR("bg.battlefield", "Battlefield::AddCapturePoint: CapturePoint %u already exists!", cp->GetCapturePointEntry()); delete i->second; } m_capturePoints[cp->GetCapturePointEntry()] = cp; } BfCapturePoint* Battlefield::GetCapturePoint(uint32 entry) const { Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(entry); if (itr != m_capturePoints.end()) return itr->second; return nullptr; } void Battlefield::RegisterZone(uint32 zoneId) { sBattlefieldMgr->AddZone(zoneId, this); } void Battlefield::HideNpc(Creature* creature) { creature->CombatStop(); creature->SetReactState(REACT_PASSIVE); creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); creature->DisappearAndDie(); creature->SetVisible(false); } void Battlefield::ShowNpc(Creature* creature, bool aggressive) { creature->SetVisible(true); creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); if (!creature->IsAlive()) creature->Respawn(true); if (aggressive) creature->SetReactState(REACT_AGGRESSIVE); else { creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); creature->SetReactState(REACT_PASSIVE); } } // **************************************************** // ******************* Group System ******************* // **************************************************** Group* Battlefield::GetFreeBfRaid(TeamId TeamId) { for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) if (Group* group = sGroupMgr->GetGroupByGUID(*itr)) if (!group->IsFull()) return group; return nullptr; } Group* Battlefield::GetGroupPlayer(ObjectGuid guid, TeamId TeamId) { for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) if (Group* group = sGroupMgr->GetGroupByGUID(*itr)) if (group->IsMember(guid)) return group; return nullptr; } bool Battlefield::AddOrSetPlayerToCorrectBfGroup(Player* player) { if (!player->IsInWorld()) return false; if (Group* group = player->GetGroup()) group->RemoveMember(player->GetGUID()); Group* group = GetFreeBfRaid(player->GetTeamId()); if (!group) { group = new Group; group->SetBattlefieldGroup(this); group->Create(player); sGroupMgr->AddGroup(group); m_Groups[player->GetTeamId()].insert(group->GetGUID()); } else if (group->IsMember(player->GetGUID())) { uint8 subgroup = group->GetMemberGroup(player->GetGUID()); player->SetBattlegroundOrBattlefieldRaid(group, subgroup); } else group->AddMember(player); return true; } //***************End of Group System******************* //***************************************************** //***************Spirit Guide System******************* //***************************************************** //-------------------- //-Battlefield Method- //-------------------- BfGraveyard* Battlefield::GetGraveyardById(uint32 id) const { if (id < m_GraveyardList.size()) { if (BfGraveyard* graveyard = m_GraveyardList.at(id)) return graveyard; else TC_LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:%u does not exist.", id); } else TC_LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:%u could not be found.", id); return nullptr; } WorldSafeLocsEntry const* Battlefield::GetClosestGraveYard(Player* player) { BfGraveyard* closestGY = nullptr; float maxdist = -1; for (uint8 i = 0; i < m_GraveyardList.size(); i++) { if (m_GraveyardList[i]) { if (m_GraveyardList[i]->GetControlTeamId() != player->GetTeamId()) continue; float dist = m_GraveyardList[i]->GetDistance(player); if (dist < maxdist || maxdist < 0) { closestGY = m_GraveyardList[i]; maxdist = dist; } } } if (closestGY) return sWorldSafeLocsStore.LookupEntry(closestGY->GetGraveyardId()); return nullptr; } void Battlefield::AddPlayerToResurrectQueue(ObjectGuid npcGuid, ObjectGuid playerGuid) { for (uint8 i = 0; i < m_GraveyardList.size(); i++) { if (!m_GraveyardList[i]) continue; if (m_GraveyardList[i]->HasNpc(npcGuid)) { m_GraveyardList[i]->AddPlayer(playerGuid); break; } } } void Battlefield::RemovePlayerFromResurrectQueue(ObjectGuid playerGuid) { for (uint8 i = 0; i < m_GraveyardList.size(); i++) { if (!m_GraveyardList[i]) continue; if (m_GraveyardList[i]->HasPlayer(playerGuid)) { m_GraveyardList[i]->RemovePlayer(playerGuid); break; } } } void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, ObjectGuid const& guid) { WorldPackets::Battleground::AreaSpiritHealerTime areaSpiritHealerTime; areaSpiritHealerTime.HealerGuid = guid; areaSpiritHealerTime.TimeLeft = m_LastResurrectTimer; player->SendDirectMessage(areaSpiritHealerTime.Write()); } // ---------------------- // - BfGraveyard Method - // ---------------------- BfGraveyard::BfGraveyard(Battlefield* battlefield) { m_Bf = battlefield; m_GraveyardId = 0; m_ControlTeam = TEAM_NEUTRAL; } void BfGraveyard::Initialize(TeamId startControl, uint32 graveyardId) { m_ControlTeam = startControl; m_GraveyardId = graveyardId; } void BfGraveyard::SetSpirit(Creature* spirit, TeamId team) { if (!spirit) { TC_LOG_ERROR("bg.battlefield", "BfGraveyard::SetSpirit: Invalid Spirit."); return; } m_SpiritGuide[team] = spirit->GetGUID(); spirit->SetReactState(REACT_PASSIVE); } float BfGraveyard::GetDistance(Player* player) { WorldSafeLocsEntry const* safeLoc = sWorldSafeLocsStore.LookupEntry(m_GraveyardId); return player->GetDistance2d(safeLoc->Loc.X, safeLoc->Loc.Y); } void BfGraveyard::AddPlayer(ObjectGuid playerGuid) { if (!m_ResurrectQueue.count(playerGuid)) { m_ResurrectQueue.insert(playerGuid); if (Player* player = ObjectAccessor::FindPlayer(playerGuid)) player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true); } } void BfGraveyard::RemovePlayer(ObjectGuid playerGuid) { m_ResurrectQueue.erase(m_ResurrectQueue.find(playerGuid)); if (Player* player = ObjectAccessor::FindPlayer(playerGuid)) player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT); } void BfGraveyard::Resurrect() { if (m_ResurrectQueue.empty()) return; for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) { // Get player object from his guid Player* player = ObjectAccessor::FindPlayer(*itr); if (!player) continue; // Check if the player is in world and on the good graveyard if (player->IsInWorld()) if (Creature* spirit = m_Bf->GetCreature(m_SpiritGuide[m_ControlTeam])) spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true); // Resurrect player player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true); player->ResurrectPlayer(1.0f); player->CastSpell(player, 6962, true); player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true); player->SpawnCorpseBones(false); } m_ResurrectQueue.clear(); } // For changing graveyard control void BfGraveyard::GiveControlTo(TeamId team) { // Guide switching // Note: Visiblity changes are made by phasing /*if (m_SpiritGuide[1 - team]) m_SpiritGuide[1 - team]->SetVisible(false); if (m_SpiritGuide[team]) m_SpiritGuide[team]->SetVisible(true);*/ m_ControlTeam = team; // Teleport to other graveyard, player witch were on this graveyard RelocateDeadPlayers(); } void BfGraveyard::RelocateDeadPlayers() { WorldSafeLocsEntry const* closestGrave = nullptr; for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) { Player* player = ObjectAccessor::FindPlayer(*itr); if (!player) continue; if (closestGrave) player->TeleportTo(player->GetMapId(), closestGrave->Loc.X, closestGrave->Loc.Y, closestGrave->Loc.Z, player->GetOrientation()); else { closestGrave = m_Bf->GetClosestGraveYard(player); if (closestGrave) player->TeleportTo(player->GetMapId(), closestGrave->Loc.X, closestGrave->Loc.Y, closestGrave->Loc.Z, player->GetOrientation()); } } } bool BfGraveyard::HasNpc(ObjectGuid guid) { if (!m_SpiritGuide[TEAM_ALLIANCE] || !m_SpiritGuide[TEAM_HORDE]) return false; if (!m_Bf->GetCreature(m_SpiritGuide[TEAM_ALLIANCE]) || !m_Bf->GetCreature(m_SpiritGuide[TEAM_HORDE])) return false; return (m_SpiritGuide[TEAM_ALLIANCE] == guid || m_SpiritGuide[TEAM_HORDE] == guid); } // ******************************************************* // *************** End Spirit Guide system *************** // ******************************************************* // ********************** Misc *************************** // ******************************************************* Creature* Battlefield::SpawnCreature(uint32 entry, Position const& pos) { //Get map object Map* map = sMapMgr->CreateBaseMap(m_MapId); if (!map) { TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u, map not found.", entry); return nullptr; } if (!sObjectMgr->GetCreatureTemplate(entry)) { TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry); return nullptr; } Creature* creature = Creature::CreateCreature(entry, map, pos); if (!creature) { TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry); return nullptr; } creature->SetHomePosition(pos); // Set creature in world map->AddToMap(creature); creature->setActive(true); return creature; } // Method for spawning gameobject on map GameObject* Battlefield::SpawnGameObject(uint32 entry, Position const& pos, QuaternionData const& rot) { // Get map object Map* map = sMapMgr->CreateBaseMap(m_MapId); if (!map) { TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Can't create GameObject (Entry: %u). Map not found.", entry); return nullptr; } if (!sObjectMgr->GetGameObjectTemplate(entry)) { TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: GameObject template %u not found in database! Battlefield not created!", entry); return nullptr; } // Create gameobject GameObject* go = GameObject::CreateGameObject(entry, map, pos, rot, 255, GO_STATE_READY); if (!go) { TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Could not create gameobject template %u! Battlefield has not been created!", entry); return nullptr; } // Add to world map->AddToMap(go); go->setActive(true); return go; } Creature* Battlefield::GetCreature(ObjectGuid guid) { if (!m_Map) return nullptr; return m_Map->GetCreature(guid); } GameObject* Battlefield::GetGameObject(ObjectGuid guid) { if (!m_Map) return nullptr; return m_Map->GetGameObject(guid); } // ******************************************************* // ******************* CapturePoint ********************** // ******************************************************* BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePointGUID() { m_team = TEAM_NEUTRAL; m_value = 0; m_minValue = 0.0f; m_maxValue = 0.0f; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL; m_OldState = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL; m_capturePointEntry = 0; m_neutralValuePct = 0; m_maxSpeed = 0; } bool BfCapturePoint::HandlePlayerEnter(Player* player) { if (!m_capturePointGUID.IsEmpty()) { if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) { player->SendUpdateWorldState(capturePoint->GetGOInfo()->controlZone.worldState1, 1); player->SendUpdateWorldState(capturePoint->GetGOInfo()->controlZone.worldstate2, uint32(ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f))); player->SendUpdateWorldState(capturePoint->GetGOInfo()->controlZone.worldstate3, m_neutralValuePct); } } return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second; } GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player) { if (!m_capturePointGUID.IsEmpty()) if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) player->SendUpdateWorldState(capturePoint->GetGOInfo()->controlZone.worldState1, 0); GuidSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID()); if (current == m_activePlayers[player->GetTeamId()].end()) return current; // return end() m_activePlayers[player->GetTeamId()].erase(current++); return current; } void BfCapturePoint::SendChangePhase() { if (!m_capturePointGUID) return; if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) { // send this too, sometimes the slider disappears, dunno why :( SendUpdateWorldState(capturePoint->GetGOInfo()->controlZone.worldState1, 1); // send these updates to only the ones in this objective SendUpdateWorldState(capturePoint->GetGOInfo()->controlZone.worldstate2, (uint32)std::ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); // send this too, sometimes it resets :S SendUpdateWorldState(capturePoint->GetGOInfo()->controlZone.worldstate3, m_neutralValuePct); } } bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint) { ASSERT(capturePoint); TC_LOG_DEBUG("bg.battlefield", "Creating capture point %u", capturePoint->GetEntry()); m_capturePointGUID = capturePoint->GetGUID(); m_capturePointEntry = capturePoint->GetEntry(); // check info existence GameObjectTemplate const* goinfo = capturePoint->GetGOInfo(); if (goinfo->type != GAMEOBJECT_TYPE_CONTROL_ZONE) { TC_LOG_ERROR("misc", "OutdoorPvP: GO %u is not a capture point!", capturePoint->GetEntry()); return false; } // get the needed values from goinfo m_maxValue = goinfo->controlZone.maxTime; m_maxSpeed = m_maxValue / (goinfo->controlZone.minTime ? goinfo->controlZone.minTime : 60); m_neutralValuePct = goinfo->controlZone.neutralPercent; m_minValue = m_maxValue * goinfo->controlZone.neutralPercent / 100; if (m_team == TEAM_ALLIANCE) { m_value = m_maxValue; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE; } else { m_value = -m_maxValue; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE; } return true; } GameObject* BfCapturePoint::GetCapturePointGo() { return m_Bf->GetGameObject(m_capturePointGUID); } bool BfCapturePoint::DelCapturePoint() { if (!m_capturePointGUID.IsEmpty()) { if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) { capturePoint->SetRespawnTime(0); // not save respawn time capturePoint->Delete(); capturePoint = nullptr; } m_capturePointGUID.Clear(); } return true; } bool BfCapturePoint::Update(uint32 diff) { if (!m_capturePointGUID) return false; if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) { float radius = capturePoint->GetGOInfo()->controlZone.radius; for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) { for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { if (!capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) itr = HandlePlayerLeave(player); else ++itr; } else ++itr; } } std::list<Player*> players; Trinity::AnyPlayerInObjectRangeCheck checker(capturePoint, radius); Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(capturePoint, players, checker); Cell::VisitWorldObjects(capturePoint, searcher, radius); for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) if ((*itr)->IsOutdoorPvPActive()) if (m_activePlayers[(*itr)->GetTeamId()].insert((*itr)->GetGUID()).second) HandlePlayerEnter(*itr); } // get the difference of numbers float fact_diff = ((float) m_activePlayers[TEAM_ALLIANCE].size() - (float) m_activePlayers[TEAM_HORDE].size()) * diff / BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL; if (G3D::fuzzyEq(fact_diff, 0.0f)) return false; uint32 Challenger = 0; float maxDiff = m_maxSpeed * diff; if (fact_diff < 0) { // horde is in majority, but it's already horde-controlled -> no change if (m_State == BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE && m_value <= -m_maxValue) return false; if (fact_diff < -maxDiff) fact_diff = -maxDiff; Challenger = HORDE; } else { // ally is in majority, but it's already ally-controlled -> no change if (m_State == BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue) return false; if (fact_diff > maxDiff) fact_diff = maxDiff; Challenger = ALLIANCE; } float oldValue = m_value; TeamId oldTeam = m_team; m_OldState = m_State; m_value += fact_diff; if (m_value < -m_minValue) // red { if (m_value < -m_maxValue) m_value = -m_maxValue; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE; m_team = TEAM_HORDE; } else if (m_value > m_minValue) // blue { if (m_value > m_maxValue) m_value = m_maxValue; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE; m_team = TEAM_ALLIANCE; } else if (oldValue * m_value <= 0) // grey, go through mid point { // if challenger is ally, then n->a challenge if (Challenger == ALLIANCE) m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE; // if challenger is horde, then n->h challenge else if (Challenger == HORDE) m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } else // grey, did not go through mid point { // old phase and current are on the same side, so one team challenges the other if (Challenger == ALLIANCE && (m_OldState == BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE || m_OldState == BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE)) m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE; else if (Challenger == HORDE && (m_OldState == BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE || m_OldState == BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE)) m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } if (G3D::fuzzyNe(m_value, oldValue)) SendChangePhase(); if (m_OldState != m_State) { //TC_LOG_ERROR("bg.battlefield", "%u->%u", m_OldState, m_State); if (oldTeam != m_team) ChangeTeam(oldTeam); return true; } return false; } void BfCapturePoint::SendUpdateWorldState(uint32 field, uint32 value) { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->SendUpdateWorldState(field, value); } void BfCapturePoint::SendObjectiveComplete(uint32 id, ObjectGuid guid) { uint8 team; switch (m_State) { case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE: team = TEAM_ALLIANCE; break; case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE: team = TEAM_HORDE; break; default: return; } // send to all players present in the area for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->KilledMonsterCredit(id, guid); } bool BfCapturePoint::IsInsideObjective(Player* player) const { return m_activePlayers[player->GetTeamId()].find(player->GetGUID()) != m_activePlayers[player->GetTeamId()].end(); }
conan513/SingleCore_TC
src/server/game/Battlefield/Battlefield.cpp
C++
gpl-2.0
37,310
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM coladdr,curmosaicsz,curvidoffset,domosaic16b,mode7A,drawmode7dcolor EXTSYM mode7B,mode7C,mode7D,mode7X0,mode7Y0,mode7set,mode7tab EXTSYM pal16b,pal16bcl,pal16bxcl,scaddtype,scrnon,transpbuf EXTSYM vesa2_clbit,vram,vrama,winon,xtravbuf,winptrref,scaddset EXTSYM fulladdtab EXTSYM cwinptr NEWSYM M716TExtAsmStart ;******************************************************* ; Processes & Draws Mode 7 ;******************************************************* %macro mode7halfadd 0 mov [esi+288*2],dl test dl,80h jnz %%nodraw or dl,dl jz %%nodraw mov ecx,[ebp] mov ebx,[pal16bcl+edx*4] cmp cx,0 je %%noadd and ebx,[vesa2_clbit] and ecx,[vesa2_clbit] add ebx,ecx shr ebx,1 %%noadd mov [esi],bx xor ecx,ecx %%nodraw %endmacro %macro mode7fulladd 0 mov [esi+288*2],dl test dl,80h jnz %%nodraw or dl,dl jz %%nodraw mov ecx,[ebp] mov ebx,[pal16bcl+edx*4] and ecx,[vesa2_clbit] add ebx,ecx shr ebx,1 mov ebx,[fulladdtab+ebx*2] mov [esi],bx %%nodraw %endmacro %macro mode7fullsub 0 mov [esi+288*2],dl test dl,80h jnz %%nodraw or dl,dl jz %%nodraw mov ecx,[ebp] mov ebx,[pal16bxcl+edx*4] and ecx,[vesa2_clbit] add ebx,ecx shr ebx,1 mov ebx,[fulladdtab+ebx*2] xor ebx,0FFFFh mov [esi],bx %%nodraw %endmacro %macro mode7mainsub 0 mov [esi+288*2],dl test dl,80h jnz %%nodraw or dl,dl jz %%nodraw mov ecx,[pal16b+edx*4] mov [esi],cx mov [ebp],cx %%nodraw %endmacro %macro mode7halfaddwinon 0 mov [esi+288*2],dl mov eax,[cwinptr] test dl,80h jnz %%nodraw or dl,dl jz %%nodraw test byte[eax],0FFh jnz %%nodraw mov ecx,[ebp] mov ebx,[pal16bcl+edx*4] cmp cx,0 je %%noadd and ebx,[vesa2_clbit] and ecx,[vesa2_clbit] add ebx,ecx shr ebx,1 %%noadd mov [esi],bx xor ecx,ecx %%nodraw inc dword[cwinptr] %endmacro %macro mode7fulladdwinon 0 mov [esi+288*2],dl mov eax,[cwinptr] test dl,80h jnz %%nodraw or dl,dl jz %%nodraw test byte[eax],0FFh jnz %%nodraw mov ecx,[ebp] mov ebx,[pal16bcl+edx*4] and ecx,[vesa2_clbit] add ebx,ecx shr ebx,1 mov ebx,[fulladdtab+ebx*2] mov [esi],bx %%nodraw inc dword[cwinptr] %endmacro %macro mode7fullsubwinon 0 mov [esi+288*2],dl mov eax,[cwinptr] test dl,80h jnz %%nodraw or dl,dl jz %%nodraw test byte[eax],0FFh jnz %%nodraw mov ecx,[ebp] mov ebx,[pal16bxcl+edx*4] and ecx,[vesa2_clbit] add ebx,ecx shr ebx,1 mov ebx,[fulladdtab+ebx*2] xor ebx,0FFFFh mov [esi],bx %%nodraw inc dword[cwinptr] %endmacro %macro mode7mainsubwinon 0 mov [esi+288*2],dl mov eax,[cwinptr] test dl,80h jnz %%nodraw or dl,dl jz %%nodraw test byte[eax],0FFh jnz %%nodraw mov ecx,[pal16b+edx*4] mov [esi],cx mov [ebp],cx %%nodraw inc dword[cwinptr] %endmacro %macro mode716tmacro 1 ; mode 7, ax = curyposition, dx = curxposition (left side) ; draw center map coordinates at (X0-bg1scrolx,Y0-bg1scroly) on screen ; center map coordinates = (X0,Y0) ; 1.) cx=X0-bg1scrolx, cy =Y0-ax mov bx,[mode7X0] and bx,0001111111111111b ; 13 -> 16 bit signed value test bx,0001000000000000b jz .nonega or bx,1110000000000000b .nonega mov [.cxloc],bx mov bx,dx and bx,0001111111111111b ; 13 -> 16 bit signed value test bx,0001000000000000b jz .nonegb or bx,1110000000000000b .nonegb sub [.cxloc],bx mov bx,ax and bx,0001111111111111b ; 13 -> 16 bit signed value test bx,0001000000000000b jz .nonegc or bx,1110000000000000b .nonegc mov [.cyloc],bx mov bx,[mode7Y0] and bx,0001111111111111b ; 13 -> 16 bit signed value test bx,0001000000000000b jz .nonegd or bx,1110000000000000b .nonegd sub word[.cyloc],bx ; 2.) Find position at scaled y, centered x at SCX=X0-(cy*C),SCY=Y0-(cy*D) movsx ebx,word[.cyloc] movsx eax,word[mode7C] imul eax,ebx neg eax mov [.mode7xpos],eax mov bx,word[mode7X0] add [.mode7xpos+1],bx movsx ebx,word[.cyloc] movsx eax,word[mode7D] imul eax,ebx ; neg ax mov [.mode7ypos],eax mov bx,word[mode7Y0] add [.mode7ypos+1],bx ; 3.) Find left scaled location : SCX=SCX-(cx*A),SCY=SCY-(cx*B) movsx ebx,word[.cxloc] movsx eax,word[mode7A] mov [.mode7xadder],eax imul eax,ebx neg eax add [.mode7xpos],eax movsx ebx,word[.cxloc] movsx eax,word[mode7B] mov [.mode7yadder],eax imul eax,ebx add [.mode7ypos],eax ; esi = pointer to video buffer mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16 mov edi,[vram] cmp byte[curmosaicsz],1 je .nomosaic mov esi,xtravbuf+32 mov ecx,128 .clearnext mov dword[esi],0 add esi,4 dec ecx jnz .clearnext mov esi,xtravbuf+32 .nomosaic mov ebp,transpbuf+32 ; esi = pointer to video buffer ; edi = pointer to vram ; [.mode7xadder] = dword value to add to x value (decimal between 7 & 8bit) ; [.mode7yadder] = dword value to add to y value (decimal between 7 & 8bit) ; [.mode7xpos] = dword value of x position, decimal between 7 & 8bit ; [.mode7xpos+1] = word value of x position ; [.mode7ypos] = dword value of y position, decimal between 7 & 8bit ; [.mode7ypos+1] = word value of y position mov byte[.temp],0 xor ebx,ebx xor edx,edx xor ecx,ecx mov dword[.mode7xadd2],800h mov byte[.mode7xinc],2 test dword[.mode7xadder],80000000h jz .noneg mov dword[.mode7xadd2],-800h mov byte[.mode7xinc],-2 .noneg mov dword[.mode7yadd2],800h mov byte[.mode7yinc],1 test dword[.mode7yadder],80000000h jz .noneg2 mov dword[.mode7yadd2],-800h mov byte[.mode7yinc],-1 .noneg2 mov edi,[vram] cmp dword[.mode7xadder],7F0h jg near .nextval3 cmp dword[.mode7xadder],-7F0h jl near .nextval3 cmp dword[.mode7yadder],7F0h jg near .nextval3 cmp dword[.mode7yadder],-7F0h jl near .nextval3 test byte[mode7set],80h jnz near .norep2 mov eax,[.mode7xpos] and eax,7FFh mov [.mode7xrpos],eax mov eax,[.mode7ypos] and eax,7FFh mov [.mode7yrpos],eax ; get tile data offset into edi mov ebx,[.mode7ypos+1] mov eax,[.mode7xpos+1] shl ebx,5 shr eax,3 and ebx,07FF8h shl al,1 mov bl,al mov edi,[vram] xor ch,ch mov [.mode7ptr],ebx mov cl,[edi+ebx] shl ecx,7 add edi,ecx .nextval test byte[.mode7xrpos+1],08h jnz near .rposoffx .nextposx test byte[.mode7yrpos+1],08h jnz near .rposoffy .nextposy mov cl,[.mode7yrpos+1] mov eax,[.mode7xadder] mov ch,[.mode7xrpos+1] add [.mode7xrpos],eax mov dl,[mode7tab+ecx] mov eax,[.mode7yadder] mov dl,[edi+edx] sub [.mode7yrpos],eax %1 add esi,2 add ebp,2 dec byte[.temp] jnz near .nextval jmp .finishmode7 .rposoffx mov al,[.mode7xinc] mov edi,[vram] add [.mode7ptr],al mov ebx,[.mode7ptr] xor ecx,ecx mov cl,[edi+ebx] mov eax,[.mode7xadd2] shl ecx,7 sub [.mode7xrpos],eax add edi,ecx jmp .nextposx .rposoffy mov al,[.mode7yinc] mov edi,[vram] sub [.mode7ptr+1],al and byte[.mode7ptr+1],7Fh mov ebx,[.mode7ptr] xor ecx,ecx mov cl,[edi+ebx] mov eax,[.mode7yadd2] shl ecx,7 add [.mode7yrpos],eax add edi,ecx jmp .nextposy .finishmode7 xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret ;********************************************************** ; Mode 7, no repetition mode ;********************************************************** .norep2 test byte[mode7set],40h jnz .tilerep2 .nextvalb2 cmp byte[.mode7ypos+2],3 ja .offscr2 cmp byte[.mode7xpos+2],3 jbe near .offscr3 .offscr2 mov eax,[.mode7xadder] mov ebx,[.mode7yadder] add [.mode7xpos],eax sub [.mode7ypos],ebx add esi,2 add ebp,2 dec byte[.temp] jnz near .nextvalb2 jmp .finishmode7 .tilerep2 .nextvalb3 cmp byte[.mode7ypos+2],3 ja .offscr2b cmp byte[.mode7xpos+2],3 jbe near .offscr3 .offscr2b mov ch,[.mode7xpos+1] mov eax,[.mode7xadder] mov cl,[.mode7ypos+1] mov ebx,[.mode7yadder] mov dl,[mode7tab+ecx] add [.mode7xpos],eax mov dl,[vrama+edx] sub [.mode7ypos],ebx %1 add esi,2 add ebp,2 dec byte[.temp] jnz near .nextvalb3 jmp .finishmode7 .offscr3 mov eax,[.mode7xpos] and eax,7FFh mov [.mode7xrpos],eax mov eax,[.mode7ypos] and eax,7FFh mov [.mode7yrpos],eax ; get tile data offset into edi mov ebx,[.mode7ypos+1] mov eax,[.mode7xpos+1] shl ebx,5 shr eax,3 and ebx,07FF8h shl al,1 mov bl,al mov edi,[vram] xor ch,ch mov [.mode7ptr],ebx mov cl,[edi+ebx] shl ecx,7 add edi,ecx .nextvalr test byte[.mode7xrpos+1],08h jnz near .rposoffxr .nextposxr test byte[.mode7yrpos+1],08h jnz near .rposoffyr .nextposyr mov cl,[.mode7yrpos+1] mov eax,[.mode7xadder] mov ch,[.mode7xrpos+1] add [.mode7xrpos],eax mov dl,[mode7tab+ecx] mov eax,[.mode7yadder] mov dl,[edi+edx] sub [.mode7yrpos],eax %1 add esi,2 add ebp,2 dec byte[.temp] jnz near .nextvalr jmp .finishmode7 .rposoffxr mov al,[.mode7xinc] mov edi,[vram] add [.mode7ptr],al jz .roff cmp byte[.mode7ptr],0FEh je .roff .roffxretb mov ebx,[.mode7ptr] xor ecx,ecx mov cl,[edi+ebx] mov eax,[.mode7xadd2] shl ecx,7 sub [.mode7xrpos],eax add edi,ecx jmp .nextposxr .rposoffyr mov al,[.mode7yinc] mov edi,[vram] sub [.mode7ptr+1],al js .roff .roffyretb mov ebx,[.mode7ptr] xor ecx,ecx mov cl,[edi+ebx] mov eax,[.mode7yadd2] shl ecx,7 add [.mode7yrpos],eax add edi,ecx jmp .nextposyr .roff test byte[mode7set],40h jnz .tilerep3 jmp .finishmode7 .tilerep3 and byte[.mode7yrpos+1],07h and byte[.mode7xrpos+1],07h mov cl,[.mode7yrpos+1] mov eax,[.mode7xadder] mov ch,[.mode7xrpos+1] add [.mode7xrpos],eax mov dl,[mode7tab+ecx] mov eax,[.mode7yadder] mov dl,[vrama+edx] sub [.mode7yrpos],eax %1 add esi,2 add ebp,2 dec byte[.temp] jnz near .tilerep3 jmp .finishmode7 ;********************************************************** ; Mode 7, old routines ;********************************************************** .nextval3 test byte[mode7set],80h jnz near .norep .nextval2 ; get tile # @ ([.mode7xpos],[.mode7ypos]) ; get tile location in vram (tileloc=x*2+y*256) mov ebx,[.mode7ypos+1] mov eax,[.mode7xpos+1] mov cl,bl mov ch,al shl ebx,5 shr eax,3 mov dl,[mode7tab+ecx] and ebx,07FF8h shl al,1 mov bl,al xor ch,ch mov cl,[edi+ebx] mov eax,[.mode7xadder] shl ecx,7 add [.mode7xpos],eax add ecx,edx mov eax,[.mode7yadder] mov dl,[edi+ecx] sub [.mode7ypos],eax %1 add esi,2 add ebp,2 dec byte[.temp] jnz near .nextval2 xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret ; Color repetition .norep test byte[mode7set],40h jnz near .tilerep .nextvalb ; get tile # @ ([.mode7xpos],[.mode7ypos]) ; get tile location in vram (tileloc=x*2+y*256) cmp byte[.mode7ypos+2],3 ja near .offscr cmp byte[.mode7xpos+2],3 ja near .offscr .offscrb mov ebx,[.mode7ypos+1] mov eax,[.mode7xpos+1] mov cl,bl mov ch,al shl ebx,5 shr eax,3 mov dl,[mode7tab+ecx] and ebx,07FF8h shl al,1 mov bl,al xor ch,ch mov cl,[edi+ebx] mov eax,[.mode7xadder] shl ecx,7 add [.mode7xpos],eax add ecx,edx mov eax,[.mode7yadder] mov dl,[edi+ecx] sub [.mode7ypos],eax %1 add esi,2 add ebp,2 dec byte[.temp] jnz near .nextvalb jmp .goon .offscrc cmp byte[.mode7ypos+2],3 ja .offscr cmp byte[.mode7xpos+2],3 jbe near .offscrb .offscr mov eax,[.mode7xadder] mov ebx,[.mode7yadder] add [.mode7xpos],eax sub [.mode7ypos],ebx add esi,2 add ebp,2 dec byte[.temp] jnz .offscrc .goon xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret .tilerep .nextvalbtr ; get tile # @ ([.mode7xpos],[.mode7ypos]) ; get tile location in vram (tileloc=x*2+y*256) cmp byte[.mode7ypos+2],3 ja near .offscrtr cmp byte[.mode7xpos+2],3 ja near .offscrtr .offscrtrb mov ebx,[.mode7ypos+1] mov eax,[.mode7xpos+1] mov cl,bl mov ch,al shl ebx,5 shr eax,3 mov dl,[mode7tab+ecx] and ebx,07FF8h shl al,1 mov bl,al xor ch,ch mov cl,[edi+ebx] mov eax,[.mode7xadder] shl ecx,7 add [.mode7xpos],eax add ecx,edx mov eax,[.mode7yadder] mov dl,[edi+ecx] sub [.mode7ypos],eax %1 add esi,2 add ebp,2 dec byte[.temp] jnz near .nextvalbtr jmp .goon .offscrtrc cmp byte[.mode7ypos+2],3 ja .offscrtr cmp byte[.mode7xpos+2],3 jbe near .offscrtrb .offscrtr mov ch,[.mode7xpos+1] mov eax,[.mode7xadder] mov cl,[.mode7ypos+1] mov ebx,[.mode7yadder] mov dl,[mode7tab+ecx] add [.mode7xpos],eax mov dl,[vrama+edx] sub [.mode7ypos],ebx %1 add esi,2 add ebp,2 dec byte[.temp] jnz near .offscrtrc jmp .goon ALIGN32 .temp dd 0 ; for byte move left .mode7xpos dd 0 ; x position .tempa2 dd 0 ; keep this blank! .mode7xrpos dd 0 ; x position .tempa dd 0 ; keep this blank! .mode7ypos dd 0 ; y position .tempb2 dd 0 ; keep this blank! .mode7yrpos dd 0 ; y position .tempb dd 0 ; keep this blank! .mode7xadder dd 0 ; number to add for x .tempc2 dd 0 ; keep this blank! .mode7xadd2 dd 0 ; number to add for x .tempc dd 0 ; keep this blank! .mode7yadder dd 0 ; number to add for y .tempd2 dd 0 ; keep this blank! .mode7yadd2 dd 0 ; number to add for y .tempd dd 0 ; keep this blank! .mode7ptr dd 0 ; pointer value .mode7xinc dd 0 ; number to add for x .mode7yinc dd 0 ; number to add for y .mode7xsloc dd 0 ; which screen x .mode7ysloc dd 0 ; which screen y .mode7xsrl dd 0 ; which relative screen x .mode7ysrl dd 0 ; which relative screen y .cxloc dd 0 ; cx location .cyloc dd 0 ; cy location %endmacro ;******************************************************* ; Processes & Draws Mode 7 half Addition ;******************************************************* NEWSYM drawmode716textbg ; test byte[scaddset],1 ; jnz near drawmode7dcolor mov esi,[cwinptr] mov [winptrref],esi cmp byte[curmosaicsz],1 jne .domosaic cmp byte[winon],0 jne near drawmode716twinonextbg .domosaic test byte[scaddtype],80h jnz near drawmode716tsubextbg test byte[scaddtype],40h jz near drawmode716tfulladdextbg cmp byte[scrnon+1],0 je near drawmode716tfulladdextbg cmp dword[coladdr],0 jnz near drawmode716tfulladdextbg mode716tmacro mode7halfadd ;******************************************************* ; Processes & Draws Mode 7 Full Addition ;******************************************************* NEWSYM drawmode716tfulladdextbg mode716tmacro mode7fulladd ;********************************************************** ; Processes and draws Mode 7 subtract ;********************************************************** drawmode716tsubextbg: mode716tmacro mode7fullsub ;********************************************************** ; Mode 7, main & sub mode ;********************************************************** NEWSYM drawmode716tbextbg mode716tmacro mode7mainsub ;******************************************************* ; Processes & Draws Mode 7 half Addition, Window on ;******************************************************* NEWSYM drawmode716twinonextbg test byte[scaddtype],80h jnz near drawmode716tsubwinonextbg test byte[scaddtype],40h jz near drawmode716tfulladdwinonextbg cmp byte[scrnon+1],0 je near drawmode716tfulladdwinonextbg cmp dword[coladdr],0 jnz near drawmode716tfulladdwinonextbg mode716tmacro mode7halfaddwinon ;******************************************************* ; Processes & Draws Mode 7 Full Addition, Window on ;******************************************************* NEWSYM drawmode716tfulladdwinonextbg mode716tmacro mode7fulladdwinon ;********************************************************** ; Processes and draws Mode 7 subtract, Window on ;********************************************************** NEWSYM drawmode716tsubwinonextbg mode716tmacro mode7fullsubwinon ;********************************************************** ; Mode 7, main & sub mode, Window on ;********************************************************** NEWSYM drawmode716tbwinonextbg mode716tmacro mode7mainsubwinon NEWSYM drawmode716textbg2 mov esi,[cwinptr] mov [winptrref],esi ; esi = pointer to video buffer mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16 mov edi,[vram] cmp byte[curmosaicsz],1 je .nomosaic mov esi,xtravbuf+32 mov ecx,128 .clearnext mov dword[esi],0 add esi,4 dec ecx jnz .clearnext mov esi,xtravbuf+32 .nomosaic mov edi,transpbuf+32 test byte[scaddtype],80h jnz near extbg2sub test byte[scaddtype],40h jz near extbg2add cmp byte[curmosaicsz],1 jne .domosaic cmp byte[winon],0 jne near .drawwin .domosaic mov ecx,256 xor eax,eax .loop mov al,[esi+288*2] test al,80h jz .nopr2 and al,7Fh mov edx,[edi] mov ebx,[pal16bcl+eax*4] cmp dx,0 je .noadd and ebx,[vesa2_clbit] and edx,[vesa2_clbit] add ebx,edx shr ebx,1 .noadd mov [esi],bx .nopr2 add esi,2 add edi,2 dec ecx jnz .loop xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret .drawwin mov ebp,[cwinptr] mov byte[esi],cl .nodrawbw mov ecx,256 xor eax,eax .loop2 mov al,[esi+288*2] test byte[ebp],0FFh jnz .nopr2b test al,80h jz .nopr2b and al,7Fh mov edx,[edi] mov ebx,[pal16bcl+eax*4] cmp dx,0 je .noadd2 and ebx,[vesa2_clbit] and edx,[vesa2_clbit] add ebx,edx shr ebx,1 .noadd2 mov [esi],bx .nopr2b add esi,2 add edi,2 inc ebp dec ecx jnz .loop2 xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret extbg2add: cmp byte[curmosaicsz],1 jne .domosaic cmp byte[winon],0 jne near .drawwin .domosaic mov ecx,256 xor eax,eax .loop mov al,[esi+288*2] test al,80h jz .nopr2 and al,7Fh mov edx,[edi] mov ebx,[pal16bcl+eax*4] and edx,[vesa2_clbit] add ebx,edx shr ebx,1 mov ebx,[fulladdtab+ebx*2] mov [esi],bx .nopr2 add esi,2 add edi,2 dec ecx jnz .loop xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret .drawwin mov ebp,[cwinptr] mov byte[esi],cl .nodrawbw mov ecx,256 xor eax,eax .loop2 mov al,[esi+288*2] test byte[ebp],0FFh jnz .nopr2b test al,80h jz .nopr2b and al,7Fh mov edx,[edi] mov ebx,[pal16bcl+eax*4] and edx,[vesa2_clbit] add ebx,edx shr ebx,1 mov ebx,[fulladdtab+ebx*2] mov [esi],bx .nopr2b add esi,2 add edi,2 inc ebp dec ecx jnz .loop2 xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret extbg2sub: cmp byte[curmosaicsz],1 jne .domosaic cmp byte[winon],0 jne near .drawwin .domosaic mov ecx,256 xor eax,eax .loop mov al,[esi+288*2] test al,80h jz .nopr2 and al,7Fh mov edx,[edi] mov ebx,[pal16bxcl+eax*4] and edx,[vesa2_clbit] add ebx,edx shr ebx,1 mov ebx,[fulladdtab+ebx*2] xor ebx,0FFFFh mov [esi],bx .nopr2 add esi,2 add edi,2 dec ecx jnz .loop xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret .drawwin mov ebp,[cwinptr] mov byte[esi],cl .nodrawbw mov ecx,256 xor eax,eax .loop2 mov al,[esi+288*2] test byte[ebp],0FFh jnz .nopr2b test al,80h jz .nopr2b and al,7Fh mov edx,[edi] mov ebx,[pal16bxcl+eax*4] and edx,[vesa2_clbit] add ebx,edx shr ebx,1 mov ebx,[fulladdtab+ebx*2] xor ebx,0FFFFh mov [esi],bx .nopr2b add esi,2 add edi,2 inc ebp dec ecx jnz .loop2 xor eax,eax mov dh,byte[curmosaicsz] cmp dh,1 jne near domosaic16b ret NEWSYM M716TExtAsmEnd
bazzinotti/mac-zsnes-1.36
src/video/m716text.asm
Assembly
gpl-2.0
21,894
/* * This file is part of the TYPO3 CMS project. * * It is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, either version 2 * of the License, or any later version. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. * * The TYPO3 project - inspiring people to share! */ import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest'); import javaScriptHandler = require('TYPO3/CMS/Core/JavaScriptHandler'); import Notification = require('../../Notification'); import Utility = require('../../Utility'); interface Context { config: Object; hmac: string; } interface Message { title: string; message: string; } export interface AjaxDispatcherResponse { hasErrors: boolean; messages: Message[]; stylesheetFiles: string[]; inlineData: object; requireJsModules: string[]; scriptCall: string[]; scriptItems?: any[]; } export class AjaxDispatcher { private readonly objectGroup: string = null; constructor(objectGroup: string) { this.objectGroup = objectGroup; } public newRequest(endpoint: string): AjaxRequest { return new AjaxRequest(endpoint); } /** * @param {String} routeName */ public getEndpoint(routeName: string): string { if (typeof TYPO3.settings.ajaxUrls[routeName] !== 'undefined') { return TYPO3.settings.ajaxUrls[routeName]; } throw 'Undefined endpoint for route "' + routeName + '"'; } public send(request: AjaxRequest, params: Array<string>): Promise<any> { const sentRequest = request.post(this.createRequestBody(params)).then(async (response: AjaxResponse): Promise<any> => { return this.processResponse(await response.resolve()); }); sentRequest.catch((reason: Error): void => { Notification.error('Error ' + reason.message); }); return sentRequest; } private createRequestBody(input: Array<string>): { [key: string]: string } { const body: { [key: string]: string } = {}; for (let i = 0; i < input.length; i++) { body['ajax[' + i + ']'] = input[i]; } body['ajax[context]'] = JSON.stringify(this.getContext()); return body; } private getContext(): Context { let context: Context; if (typeof TYPO3.settings.FormEngineInline.config[this.objectGroup] !== 'undefined' && typeof TYPO3.settings.FormEngineInline.config[this.objectGroup].context !== 'undefined' ) { context = TYPO3.settings.FormEngineInline.config[this.objectGroup].context; } return context; } private processResponse(json: AjaxDispatcherResponse): AjaxDispatcherResponse { if (json.hasErrors) { for (const message of json.messages) { Notification.error(message.title, message.message); } } // If there are elements they should be added to the <HEAD> tag (e.g. for RTEhtmlarea): if (json.stylesheetFiles) { for (const [index, stylesheetFile] of json.stylesheetFiles.entries()) { if (!stylesheetFile) { break; } const element = document.createElement('link'); element.rel = 'stylesheet'; element.type = 'text/css'; element.href = stylesheetFile; document.querySelector('head').appendChild(element); delete json.stylesheetFiles[index]; } } if (typeof json.inlineData === 'object') { TYPO3.settings.FormEngineInline = Utility.mergeDeep(TYPO3.settings.FormEngineInline, json.inlineData); } if (json.scriptItems instanceof Array && json.scriptItems.length > 0) { javaScriptHandler.processItems(json.scriptItems, true); } // @todo deprecate or remove with TYPO3 v12.0 if (typeof json.requireJsModules === 'object') { for (let requireJsModule of json.requireJsModules) { new Function(requireJsModule)(); } } // TODO: This is subject to be removed // @todo deprecate or remove with TYPO3 v12.0 if (json.scriptCall && json.scriptCall.length > 0) { for (const scriptCall of json.scriptCall) { // eslint-disable-next-line no-eval eval(scriptCall); } } return json; } }
stweil/TYPO3.CMS
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/FormEngine/InlineRelation/AjaxDispatcher.ts
TypeScript
gpl-2.0
4,280
// ************************************************************************* // // Copyright 2004-2010 Bruno PAGES . // // This file is part of the BOUML Uml Toolkit. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // e-mail : bouml@free.fr // home : http://bouml.free.fr // // ************************************************************************* #include <stdio.h> #include "UmlDrag.h" #include "BrowserNode.h" const QString UmlDrag::Key = "Bouml/"; QString UmlDrag::postfix; bool UmlDrag::ro; UmlDrag::UmlDrag(BrowserNode * bn, QWidget * parent, const char * name) : QStoredDrag(UmlDrag::Key + bn->drag_key(), parent, name) { // stay in the same application : can use address directly QByteArray a(sizeof(bn)); memcpy(a.data(), &bn, sizeof(bn)); setEncodedData(a); postfix = bn->drag_postfix(); ro = ((bn->parent() != 0) && !((BrowserNode *) bn->parent())->is_writable()); } bool UmlDrag::canDecode(QDragMoveEvent * e, UmlCode type, bool withpostfix, bool evenro) { if (ro && ! evenro) return FALSE; return (e->source() != 0) && e->provides((withpostfix) ? UmlDrag::Key + QString::number(type) + postfix : UmlDrag::Key + QString::number(type)); } bool UmlDrag::canDecode(QDragMoveEvent * e, const QString & type) { return !ro && (e->source() != 0) && e->provides(UmlDrag::Key + type); } BrowserNode * UmlDrag::decode(QDropEvent * e, UmlCode type, bool withpostfix) { QByteArray payload = e->data((withpostfix) ? UmlDrag::Key + QString::number(type) + postfix : UmlDrag::Key + QString::number(type)); if (payload.size()) { e->accept(); BrowserNode * bn; memcpy(&bn, payload.data(), sizeof(bn)); return bn; } return 0; } BrowserNode * UmlDrag::decode(QDropEvent * e, const QString & type) { QByteArray payload = e->data(UmlDrag::Key + type); if (payload.size()) { e->accept(); BrowserNode * bn; memcpy(&bn, payload.data(), sizeof(bn)); return bn; } return 0; }
gregsmirnov/bouml
src/misc/UmlDrag.cpp
C++
gpl-2.0
2,695
<?php /** * * Ajax Shoutbox extension for the phpBB Forum Software package. * * @copyright (c) 2014 Paul Sohier <http://www.ajax-shoutbox.com> * @license GNU General Public License, version 2 (GPL-2.0) * * Translated By : Bassel Taha Alhitary - www.alhitary.net */ /** * DO NOT CHANGE */ if (!defined('IN_PHPBB')) { exit; } if (empty($lang) || !is_array($lang)) { $lang = array(); } // DEVELOPERS PLEASE NOTE // // All language files should use UTF-8 as their encoding and the files must not contain a BOM. // // Placeholders can now contain order information, e.g. instead of // 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows // translators to re-order the output of data while ensuring it remains correct // // You do not need this where single placeholders are used, e.g. 'Message %d' is fine // equally where a string contains only two placeholders which are used to wrap text // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine // // Some characters you may want to copy&paste: // ’ » “ ” … // $lang = array_merge( $lang, array( 'AJAX_SHOUTBOX' => 'الدردشة أجاكس', 'AJAX_SHOUTBOX_MESSAGE' => 'ارسل رسالتك', 'AJAX_SHOUTBOX_ONLY_AJAX' => 'المعذرة , يجب تفعيل الجافا سكربت لكي تعمل هذه الدردشة.', 'AJAX_SHOUTBOX_NO_PERMISSION' => 'لا توجد صلاحية لتنفيذ هذا الأمر', 'AJAX_SHOUTBOX_MESSAGE_EMPTY' => 'الرسالة فارغة', 'AJAX_SHOUTBOX_ERROR' => 'خطأ', 'AJAX_SHOUTBOX_MISSING_ID' => 'لا يُمكن حذف المشاركة', 'AJAX_SHOUTBOX_NO_SUCH_POST' => 'لا يُمكن العثور على المشاركة', 'AJAX_SHOUTBOX_PUSH_NOT_AVAIL' => 'الخدمة عير متوفرة حالياً', 'AJAXSHOUTBOX_BOARD_DATE_FORMAT' => 'My shoutbox date format', 'AJAXSHOUTBOX_BOARD_DATE_FORMAT_EXPLAIN' => 'Specify a date format for just the shoutbox. You should not use a relative date format.', ) );
Galixte/ajax-shoutbox-ext
language/ar/ajax_shoutbox.php
PHP
gpl-2.0
2,096
<?php /* $Id: tax_classes.php 1692 2012-02-26 01:26:50Z michael.oscmax@gmail.com $ osCmax e-Commerce http://www.oscmax.com Copyright 2000 - 2011 osCmax Released under the GNU General Public License */ define('HEADING_TITLE', 'Tipos de impuestos'); define('TABLE_HEADING_TAX_CLASSES', 'Tipos de impuestos'); define('TABLE_HEADING_ACTION', 'Acción'); define('TEXT_INFO_EDIT_INTRO', 'Realiza los cambios necesarios'); define('TEXT_INFO_CLASS_TITLE', 'Nombre del impuesto:'); define('TEXT_INFO_CLASS_DESCRIPTION', 'Descripción:'); define('TEXT_INFO_DATE_ADDED', 'Fecha creación:'); define('TEXT_INFO_LAST_MODIFIED', 'Última modificación:'); define('TEXT_INFO_INSERT_INTRO', 'Introduce los datos del nuevo tipo de impuesto'); define('TEXT_INFO_DELETE_INTRO', '¿Seguro que quieres eliminar este tipo de impuesto?'); define('TEXT_INFO_HEADING_NEW_TAX_CLASS', 'Nuevo tipo de impuesto'); define('TEXT_INFO_HEADING_EDIT_TAX_CLASS', 'Editar tipo de impuesto'); define('TEXT_INFO_HEADING_DELETE_TAX_CLASS', 'Eliminar tipo de impuesto'); ?>
arnabnaha/NHCPharmacy
catalog/admin/includes/languages/espanol/tax_classes.php
PHP
gpl-2.0
1,041
/* * Copyright (C) 2003 Robert Kooima * * NEVERBALL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ #include <SDL.h> #include <math.h> #include <string.h> #include "glext.h" #include "vec3.h" #include "back.h" #include "image.h" /*---------------------------------------------------------------------------*/ #define PI 3.1415927f static GLuint back_list; static GLuint back_text; /*---------------------------------------------------------------------------*/ #include <pspkernel.h> void back_init(const char *s, int b) { int i, slices = b ? 32 : 16; int j, stacks = b ? 16 : 8; back_free(); back_text = make_image_from_file(s); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); back_list = glGenLists(1); glNewList(back_list, GL_COMPILE); { glBindTexture(GL_TEXTURE_2D, back_text); glColor3f(1.0f, 1.0f, 1.0f); for (i = 0; i < stacks; i++) { float k0 = (float) i / stacks; float k1 = (float) (i + 1) / stacks; float s0, c0; float s1, c1; fsincosf(V_PI * (k0 - 0.5), &s0, &c0); fsincosf(V_PI * (k1 - 0.5), &s1, &c1); #ifdef __PSP__ glBegin(GL_TRIANGLE_STRIP); #else glBegin(GL_QUAD_STRIP); #endif { for (j = 0; j <= slices; j++) { float k = (float) j / slices; float s, c; fsincosf(V_PI * k * 2.0, &s, &c); glTexCoord2f(k, 1.0f - k1); glVertex3f(s * c1, c * c1, s1); glTexCoord2f(k, 1.0f - k0); glVertex3f(s * c0, c * c0, s0); } } glEnd(); } } glEndList(); } void back_free(void) { if (glIsList(back_list)) glDeleteLists(back_list, 1); if (glIsTexture(back_text)) glDeleteTextures(1, &back_text); back_list = 0; back_text = 0; } void back_draw(float t) { return; // FIXME! glPushMatrix(); { GLfloat dx = 60.f * fsinf(t / 10.f) + 90.f; GLfloat dz = 180.f * fsinf(t / 12.f); glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); { glScalef(BACK_DIST, BACK_DIST, BACK_DIST); glRotatef(dz, 0.f, 0.f, 1.f); glRotatef(dx, 1.f, 0.f, 0.f); glCallList(back_list); } glDepthMask(GL_TRUE); glEnable(GL_LIGHTING); } glPopMatrix(); } /*---------------------------------------------------------------------------*/
libcg/neverball-psp
share/back.c
C
gpl-2.0
3,137
// // SLFriendCircleTableSectionFooterView.h // XMPPIM // // Created by wshaolin on 14/12/19. // Copyright (c) 2014年 Bourbon. All rights reserved. // #import <UIKit/UIKit.h> @interface SLFriendCircleTableSectionFooterView : UITableViewHeaderFooterView + (instancetype)sectionFoooterViewWithTableView:(UITableView *)tableView; @end
zhwe130205/taskoffer
TaskOffer/Dynamic/View/SLFriendCircleTableSectionFooterView.h
C
gpl-2.0
341
/* $Id: tag.hpp 55984 2013-01-01 09:34:55Z mordante $ */ /* Copyright (C) 2011 - 2013 by Sytyi Nick <nsytyi@gmail.com> Part of the Battle for Wesnoth Project http://www.wesnoth.org/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. See the COPYING file for more details. */ /** * @file * This file contains objects "tag" and "key", which are used to store * information about tags and keys while annotation parsing. */ #ifndef TOOLS_SCHEMA_TAG_HPP_INCLUDED #define TOOLS_SCHEMA_TAG_HPP_INCLUDED #include <algorithm> #include <iostream> #include <map> #include <sstream> #include <string> class config; namespace schema_validation{ /** * class_key is used to save the information about one key. * Key has next info: name, type, default value or key is mandatory. */ class class_key{ public: class_key():name_(""),type_(""),default_("\"\""),mandatory_(false) { } class_key(const std::string & name, const std::string &type, const std::string &def="\"\"") : name_(name) , type_(type) , default_(def) , mandatory_(def.empty()) { } class_key(const config&); const std::string & get_name() const{ return name_ ; } const std::string & get_type() const{ return type_ ; } const std::string & get_default() const{ return default_; } bool is_mandatory () const{ return mandatory_ ; } void set_name(const std::string& name){ name_ = name; } void set_type(const std::string& type){ type_ = type; } void set_default(const std::string& def){ default_ = def; if (def.empty()){ mandatory_ = true; } } void set_mandatory(bool mandatory){ mandatory_ = mandatory; } /** is used to print key info * the format is next * [key] * name="name" * type="type" * default="default" * mandatory="true/false" * [/key] */ void print(std::ostream& os,int level) const; /** *Compares keys by name. Used in std::sort, i.e. */ bool operator < ( const class_key& k) const{ return (get_name() < k.get_name()); } private: /** Name of key*/ std::string name_; /** Type of key*/ std::string type_; /** Default value*/ std::string default_; /** Shows, if key is a mandatory key.*/ bool mandatory_; }; /** * Stores information about tag. * Each tags is an element of great tag tree. This tree is close to filesystem: * you can use links and special include directory global/ * Normally root is not mentioned in path. * Each tag has name, minimum and maximum occasions number, * and lists of subtags, keys and links. */ class class_tag{ public: typedef std::map<std::string,class_tag> tag_map; typedef std::pair<std::string,class_tag> tag_map_value; typedef std::map<std::string,class_key> key_map; typedef std::pair<std::string,class_key> key_map_value; typedef std::map<std::string,std::string> link_map; typedef std::pair<std::string,std::string> link_map_value; typedef key_map::iterator key_iterator; typedef std::pair<key_iterator,key_iterator> all_key_iterators; typedef key_map::const_iterator const_key_iterator; typedef std::pair<const_key_iterator,const_key_iterator> all_const_key_iterators; typedef tag_map::iterator tag_iterator; typedef std::pair<tag_iterator,tag_iterator> all_tag_iterators; typedef tag_map::const_iterator const_tag_iterator; typedef std::pair<const_tag_iterator,const_tag_iterator> all_const_tag_iterators; typedef link_map::iterator link_iterator; typedef std::pair<link_iterator,link_iterator> all_link_iterators; typedef link_map::const_iterator const_link_iterator; typedef std::pair<const_link_iterator,const_link_iterator> all_const_link_iterators; class_tag() : name_("") , min_(0) , max_(0) , super_("") , tags_() , keys_() , links_() { } class_tag(const std::string & name, int min, int max, const std::string & super="" ) : name_(name) , min_(min) , max_(max) , super_(super) , tags_() , keys_() , links_() { } class_tag(const config&); ~class_tag(){ } /** Prints information about tag to outputstream, recursively * is used to print tag info * the format is next * [tag] * subtags * keys * name="name" * min="min" * max="max" * [/tag] */ void print(std::ostream& os); const std::string & get_name() const{ return name_ ; } int get_min() const{ return min_; } int get_max() const{ return max_; } const std::string & get_super() const{ return super_ ; } bool is_extension() const{ return ! super_.empty(); } void set_name(const std::string& name){ name_ = name; } void set_min(int o){ min_ = o; } void set_max(int o){ max_ = o; } void set_min( std::string const& s){ std::istringstream i(s); if (!(i >> min_)){ min_ = 0; } } void set_max( std::string const & s){ std::istringstream i(s); if (!(i >> max_)){ max_ = 0; } } void set_super(std::string const & s){ super_= s; } void add_key(const class_key& new_key){ keys_.insert(key_map_value(new_key.get_name(),new_key)); } void add_tag(const class_tag& new_tag){ tags_.insert(tag_map_value(new_tag.name_,new_tag)); } void add_link(const std::string & link); /** * Tags are usually organized in tree. * This fuction helps to add tag to his exact place in tree * @param path - path in subtree to exact place of tag * @param tag - tag to add * @param root - root of schema tree - use to support of adding to link. * Path is getting shotter and shoter with each call. * Path schould look like tag1/tag2/parent/ Slash at end is mandatory. */ void add_tag (const std::string & path,const class_tag & tag, class_tag &root); bool operator < ( const class_tag& t) const{ return name_ < t.name_; } bool operator == (const class_tag & other) const { return name_ == other.name_; } /** * Returns pointer to child key */ const class_key * find_key(const std::string & name) const; /** * Returns pointer to child link */ const std::string * find_link(const std::string & name) const; /** * Returns pointer to tag using full path to it. * Also work with links */ const class_tag * find_tag(const std::string & fullpath, const class_tag & root) const; /** * Calls the expansion on each child */ void expand_all(class_tag &root); all_const_tag_iterators tags() const{ return all_const_tag_iterators(tags_.begin(),tags_.end()); } all_const_key_iterators keys() const{ return all_const_key_iterators(keys_.begin(),keys_.end()); } all_const_link_iterators links() const{ return all_const_link_iterators(links_.begin(),links_.end()); } void remove_key_by_name(const std::string &name){ keys_.erase (name); } /** Removes all keys with this type. Works recursively */ void remove_keys_by_type(const std::string &type); #ifdef _MSC_VER // MSVC throws an error if this method is private. // so, define it as public to prevent that. The error is: // error C2248: 'schema_validation::class_tag::find_tag' : cannot // access private member declared in class 'schema_validation::class_tag' class_tag * find_tag(const std::string & fullpath, class_tag & root) ; #endif // class_tag & operator= (class_tag const& ); private: /** name of tag*/ std::string name_; /** number of minimum occasions*/ int min_; /** number of maximum occasions*/ int max_; /** * name of tag to extend "super-tag" * Extension is smth like inheritance and is used in case * when you need to use another tag with all his * keys, childs, etc. But you also want to allow extra subtags of that tags, * so just linking that tag wouldn't help at all. */ std::string super_; /** children tags*/ tag_map tags_; /** keys*/ key_map keys_; /** links to possible children. */ link_map links_; /** * the same as class_tag::print(std::ostream&) * but indents different levels with step space. * @param os stream to print * @param level current level of indentation * @param step step to next indent */ void printl(std::ostream &os,int level, int step = 4); #ifndef _MSC_VER // this is complementary with the above #ifdef for the MSVC error class_tag * find_tag(const std::string & fullpath, class_tag & root) ; #endif void add_tags (const tag_map & list){ tags_.insert(list.begin(),list.end()); } void add_keys (const key_map & list){ keys_.insert(list.begin(),list.end()); } void add_links (const link_map & list){ links_.insert(list.begin(),list.end()); } /** * Copies tags, keys and links of tag to this */ void append_super(const class_tag & tag,const std::string & super); /** * Expands all "super" copying their data to this. */ void expand(class_tag & root); }; } #endif // TOOLS_SCHEMA_TAG_HPP_INCLUDED
RushilPatel/BattleForWesnoth
src/tools/schema/tag.hpp
C++
gpl-2.0
9,062
/* Copyright (C) 2004 Michael Liebscher <wolf3d.redux@gmail.com> Copyright (C) 2000-2002 by DarkOne the Hacker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * \file wolf_sprites.h * \brief Wolfenstein 3-D sprite handling. * \author Michael Liebscher * \date 2004 * \note Portion of this code was derived from NewWolf, and was originally written by DarkOne the Hacker. * Portion of this code was derived from Wolfenstein 3-D, and was originally written by Id Software, Inc. */ #ifndef __WOLF_SPRITES_H__ #define __WOLF_SPRITES_H__ #include <stdio.h> #include "../env/com_math.h" // // sprite constants // enum { SPR_DEMO, SPR_DEATHCAM, // // static sprites // SPR_STAT_0, SPR_STAT_1,SPR_STAT_2, SPR_STAT_3, SPR_STAT_4, SPR_STAT_5,SPR_STAT_6, SPR_STAT_7, SPR_STAT_8, SPR_STAT_9,SPR_STAT_10,SPR_STAT_11, SPR_STAT_12,SPR_STAT_13,SPR_STAT_14,SPR_STAT_15, SPR_STAT_16,SPR_STAT_17,SPR_STAT_18,SPR_STAT_19, SPR_STAT_20,SPR_STAT_21,SPR_STAT_22,SPR_STAT_23, SPR_STAT_24,SPR_STAT_25,SPR_STAT_26,SPR_STAT_27, SPR_STAT_28,SPR_STAT_29,SPR_STAT_30,SPR_STAT_31, SPR_STAT_32,SPR_STAT_33,SPR_STAT_34,SPR_STAT_35, SPR_STAT_36,SPR_STAT_37,SPR_STAT_38,SPR_STAT_39, SPR_STAT_40,SPR_STAT_41,SPR_STAT_42,SPR_STAT_43, SPR_STAT_44,SPR_STAT_45,SPR_STAT_46,SPR_STAT_47, SPR_STAT_48,SPR_STAT_49,SPR_STAT_50,SPR_STAT_51, // // Guard // SPR_GRD_S_1,SPR_GRD_S_2,SPR_GRD_S_3,SPR_GRD_S_4, SPR_GRD_S_5,SPR_GRD_S_6,SPR_GRD_S_7,SPR_GRD_S_8, SPR_GRD_W1_1,SPR_GRD_W1_2,SPR_GRD_W1_3,SPR_GRD_W1_4, SPR_GRD_W1_5,SPR_GRD_W1_6,SPR_GRD_W1_7,SPR_GRD_W1_8, SPR_GRD_W2_1,SPR_GRD_W2_2,SPR_GRD_W2_3,SPR_GRD_W2_4, SPR_GRD_W2_5,SPR_GRD_W2_6,SPR_GRD_W2_7,SPR_GRD_W2_8, SPR_GRD_W3_1,SPR_GRD_W3_2,SPR_GRD_W3_3,SPR_GRD_W3_4, SPR_GRD_W3_5,SPR_GRD_W3_6,SPR_GRD_W3_7,SPR_GRD_W3_8, SPR_GRD_W4_1,SPR_GRD_W4_2,SPR_GRD_W4_3,SPR_GRD_W4_4, SPR_GRD_W4_5,SPR_GRD_W4_6,SPR_GRD_W4_7,SPR_GRD_W4_8, SPR_GRD_PAIN_1,SPR_GRD_DIE_1,SPR_GRD_DIE_2,SPR_GRD_DIE_3, SPR_GRD_PAIN_2,SPR_GRD_DEAD, SPR_GRD_SHOOT1,SPR_GRD_SHOOT2,SPR_GRD_SHOOT3, // // Dog // SPR_DOG_W1_1,SPR_DOG_W1_2,SPR_DOG_W1_3,SPR_DOG_W1_4, SPR_DOG_W1_5,SPR_DOG_W1_6,SPR_DOG_W1_7,SPR_DOG_W1_8, SPR_DOG_W2_1,SPR_DOG_W2_2,SPR_DOG_W2_3,SPR_DOG_W2_4, SPR_DOG_W2_5,SPR_DOG_W2_6,SPR_DOG_W2_7,SPR_DOG_W2_8, SPR_DOG_W3_1,SPR_DOG_W3_2,SPR_DOG_W3_3,SPR_DOG_W3_4, SPR_DOG_W3_5,SPR_DOG_W3_6,SPR_DOG_W3_7,SPR_DOG_W3_8, SPR_DOG_W4_1,SPR_DOG_W4_2,SPR_DOG_W4_3,SPR_DOG_W4_4, SPR_DOG_W4_5,SPR_DOG_W4_6,SPR_DOG_W4_7,SPR_DOG_W4_8, SPR_DOG_DIE_1,SPR_DOG_DIE_2,SPR_DOG_DIE_3,SPR_DOG_DEAD, SPR_DOG_JUMP1,SPR_DOG_JUMP2,SPR_DOG_JUMP3, // // SS // SPR_SS_S_1,SPR_SS_S_2,SPR_SS_S_3,SPR_SS_S_4, SPR_SS_S_5,SPR_SS_S_6,SPR_SS_S_7,SPR_SS_S_8, SPR_SS_W1_1,SPR_SS_W1_2,SPR_SS_W1_3,SPR_SS_W1_4, SPR_SS_W1_5,SPR_SS_W1_6,SPR_SS_W1_7,SPR_SS_W1_8, SPR_SS_W2_1,SPR_SS_W2_2,SPR_SS_W2_3,SPR_SS_W2_4, SPR_SS_W2_5,SPR_SS_W2_6,SPR_SS_W2_7,SPR_SS_W2_8, SPR_SS_W3_1,SPR_SS_W3_2,SPR_SS_W3_3,SPR_SS_W3_4, SPR_SS_W3_5,SPR_SS_W3_6,SPR_SS_W3_7,SPR_SS_W3_8, SPR_SS_W4_1,SPR_SS_W4_2,SPR_SS_W4_3,SPR_SS_W4_4, SPR_SS_W4_5,SPR_SS_W4_6,SPR_SS_W4_7,SPR_SS_W4_8, SPR_SS_PAIN_1,SPR_SS_DIE_1,SPR_SS_DIE_2,SPR_SS_DIE_3, SPR_SS_PAIN_2,SPR_SS_DEAD, SPR_SS_SHOOT1,SPR_SS_SHOOT2,SPR_SS_SHOOT3, // // Mutant // SPR_MUT_S_1,SPR_MUT_S_2,SPR_MUT_S_3,SPR_MUT_S_4, SPR_MUT_S_5,SPR_MUT_S_6,SPR_MUT_S_7,SPR_MUT_S_8, SPR_MUT_W1_1,SPR_MUT_W1_2,SPR_MUT_W1_3,SPR_MUT_W1_4, SPR_MUT_W1_5,SPR_MUT_W1_6,SPR_MUT_W1_7,SPR_MUT_W1_8, SPR_MUT_W2_1,SPR_MUT_W2_2,SPR_MUT_W2_3,SPR_MUT_W2_4, SPR_MUT_W2_5,SPR_MUT_W2_6,SPR_MUT_W2_7,SPR_MUT_W2_8, SPR_MUT_W3_1,SPR_MUT_W3_2,SPR_MUT_W3_3,SPR_MUT_W3_4, SPR_MUT_W3_5,SPR_MUT_W3_6,SPR_MUT_W3_7,SPR_MUT_W3_8, SPR_MUT_W4_1,SPR_MUT_W4_2,SPR_MUT_W4_3,SPR_MUT_W4_4, SPR_MUT_W4_5,SPR_MUT_W4_6,SPR_MUT_W4_7,SPR_MUT_W4_8, SPR_MUT_PAIN_1,SPR_MUT_DIE_1,SPR_MUT_DIE_2,SPR_MUT_DIE_3, SPR_MUT_PAIN_2,SPR_MUT_DIE_4,SPR_MUT_DEAD, SPR_MUT_SHOOT1,SPR_MUT_SHOOT2,SPR_MUT_SHOOT3,SPR_MUT_SHOOT4, // // Officer // SPR_OFC_S_1,SPR_OFC_S_2,SPR_OFC_S_3,SPR_OFC_S_4, SPR_OFC_S_5,SPR_OFC_S_6,SPR_OFC_S_7,SPR_OFC_S_8, SPR_OFC_W1_1,SPR_OFC_W1_2,SPR_OFC_W1_3,SPR_OFC_W1_4, SPR_OFC_W1_5,SPR_OFC_W1_6,SPR_OFC_W1_7,SPR_OFC_W1_8, SPR_OFC_W2_1,SPR_OFC_W2_2,SPR_OFC_W2_3,SPR_OFC_W2_4, SPR_OFC_W2_5,SPR_OFC_W2_6,SPR_OFC_W2_7,SPR_OFC_W2_8, SPR_OFC_W3_1,SPR_OFC_W3_2,SPR_OFC_W3_3,SPR_OFC_W3_4, SPR_OFC_W3_5,SPR_OFC_W3_6,SPR_OFC_W3_7,SPR_OFC_W3_8, SPR_OFC_W4_1,SPR_OFC_W4_2,SPR_OFC_W4_3,SPR_OFC_W4_4, SPR_OFC_W4_5,SPR_OFC_W4_6,SPR_OFC_W4_7,SPR_OFC_W4_8, SPR_OFC_PAIN_1,SPR_OFC_DIE_1,SPR_OFC_DIE_2,SPR_OFC_DIE_3, SPR_OFC_PAIN_2,SPR_OFC_DIE_4,SPR_OFC_DEAD, SPR_OFC_SHOOT1,SPR_OFC_SHOOT2,SPR_OFC_SHOOT3, // // Ghosts // SPR_BLINKY_W1,SPR_BLINKY_W2,SPR_PINKY_W1,SPR_PINKY_W2, SPR_CLYDE_W1,SPR_CLYDE_W2,SPR_INKY_W1,SPR_INKY_W2, // // Hans // SPR_BOSS_W1,SPR_BOSS_W2,SPR_BOSS_W3,SPR_BOSS_W4, SPR_BOSS_SHOOT1,SPR_BOSS_SHOOT2,SPR_BOSS_SHOOT3,SPR_BOSS_DEAD, SPR_BOSS_DIE1,SPR_BOSS_DIE2,SPR_BOSS_DIE3, // // Schabbs // SPR_SCHABB_W1,SPR_SCHABB_W2,SPR_SCHABB_W3,SPR_SCHABB_W4, SPR_SCHABB_SHOOT1,SPR_SCHABB_SHOOT2, SPR_SCHABB_DIE1,SPR_SCHABB_DIE2,SPR_SCHABB_DIE3,SPR_SCHABB_DEAD, SPR_HYPO1,SPR_HYPO2,SPR_HYPO3,SPR_HYPO4, // // Fake // SPR_FAKE_W1,SPR_FAKE_W2,SPR_FAKE_W3,SPR_FAKE_W4, SPR_FAKE_SHOOT,SPR_FIRE1,SPR_FIRE2, SPR_FAKE_DIE1,SPR_FAKE_DIE2,SPR_FAKE_DIE3,SPR_FAKE_DIE4, SPR_FAKE_DIE5,SPR_FAKE_DEAD, // // Hitler // SPR_MECHA_W1,SPR_MECHA_W2,SPR_MECHA_W3,SPR_MECHA_W4, SPR_MECHA_SHOOT1,SPR_MECHA_SHOOT2,SPR_MECHA_SHOOT3,SPR_MECHA_DEAD, SPR_MECHA_DIE1,SPR_MECHA_DIE2,SPR_MECHA_DIE3, SPR_HITLER_W1,SPR_HITLER_W2,SPR_HITLER_W3,SPR_HITLER_W4, SPR_HITLER_SHOOT1,SPR_HITLER_SHOOT2,SPR_HITLER_SHOOT3,SPR_HITLER_DEAD, SPR_HITLER_DIE1,SPR_HITLER_DIE2,SPR_HITLER_DIE3,SPR_HITLER_DIE4, SPR_HITLER_DIE5,SPR_HITLER_DIE6,SPR_HITLER_DIE7, // // Giftmacher // SPR_GIFT_W1,SPR_GIFT_W2,SPR_GIFT_W3,SPR_GIFT_W4, SPR_GIFT_SHOOT1,SPR_GIFT_SHOOT2, SPR_GIFT_DIE1,SPR_GIFT_DIE2,SPR_GIFT_DIE3,SPR_GIFT_DEAD, // // Rocket, smoke and small explosion // SPR_ROCKET_1,SPR_ROCKET_2,SPR_ROCKET_3,SPR_ROCKET_4, SPR_ROCKET_5,SPR_ROCKET_6,SPR_ROCKET_7,SPR_ROCKET_8, SPR_SMOKE_1,SPR_SMOKE_2,SPR_SMOKE_3,SPR_SMOKE_4, SPR_BOOM_1,SPR_BOOM_2,SPR_BOOM_3, // // Angel of Death's DeathSparks(tm) // SPR_HROCKET_1,SPR_HROCKET_2,SPR_HROCKET_3,SPR_HROCKET_4, SPR_HROCKET_5,SPR_HROCKET_6,SPR_HROCKET_7,SPR_HROCKET_8, SPR_HSMOKE_1,SPR_HSMOKE_2,SPR_HSMOKE_3,SPR_HSMOKE_4, SPR_HBOOM_1,SPR_HBOOM_2,SPR_HBOOM_3, SPR_SPARK1,SPR_SPARK2,SPR_SPARK3,SPR_SPARK4, // // Gretel // SPR_GRETEL_W1,SPR_GRETEL_W2,SPR_GRETEL_W3,SPR_GRETEL_W4, SPR_GRETEL_SHOOT1,SPR_GRETEL_SHOOT2,SPR_GRETEL_SHOOT3,SPR_GRETEL_DEAD, SPR_GRETEL_DIE1,SPR_GRETEL_DIE2,SPR_GRETEL_DIE3, // // Fat Face // SPR_FAT_W1,SPR_FAT_W2,SPR_FAT_W3,SPR_FAT_W4, SPR_FAT_SHOOT1,SPR_FAT_SHOOT2,SPR_FAT_SHOOT3,SPR_FAT_SHOOT4, SPR_FAT_DIE1,SPR_FAT_DIE2,SPR_FAT_DIE3,SPR_FAT_DEAD, // // bj // SPR_BJ_W1,SPR_BJ_W2,SPR_BJ_W3,SPR_BJ_W4, SPR_BJ_JUMP1,SPR_BJ_JUMP2,SPR_BJ_JUMP3,SPR_BJ_JUMP4, // // SPEAR OF DESTINY // // // Trans Grosse // SPR_TRANS_W1,SPR_TRANS_W2,SPR_TRANS_W3,SPR_TRANS_W4, SPR_TRANS_SHOOT1,SPR_TRANS_SHOOT2,SPR_TRANS_SHOOT3,SPR_TRANS_DEAD, SPR_TRANS_DIE1,SPR_TRANS_DIE2,SPR_TRANS_DIE3, // // Wilhelm // SPR_WILL_W1,SPR_WILL_W2,SPR_WILL_W3,SPR_WILL_W4, SPR_WILL_SHOOT1,SPR_WILL_SHOOT2,SPR_WILL_SHOOT3,SPR_WILL_SHOOT4, SPR_WILL_DIE1,SPR_WILL_DIE2,SPR_WILL_DIE3,SPR_WILL_DEAD, // // UberMutant // SPR_UBER_W1,SPR_UBER_W2,SPR_UBER_W3,SPR_UBER_W4, SPR_UBER_SHOOT1,SPR_UBER_SHOOT2,SPR_UBER_SHOOT3,SPR_UBER_SHOOT4, SPR_UBER_DIE1,SPR_UBER_DIE2,SPR_UBER_DIE3,SPR_UBER_DIE4, SPR_UBER_DEAD, // // Death Knight // SPR_DEATH_W1,SPR_DEATH_W2,SPR_DEATH_W3,SPR_DEATH_W4, SPR_DEATH_SHOOT1,SPR_DEATH_SHOOT2,SPR_DEATH_SHOOT3,SPR_DEATH_SHOOT4, SPR_DEATH_DIE1,SPR_DEATH_DIE2,SPR_DEATH_DIE3,SPR_DEATH_DIE4, SPR_DEATH_DIE5,SPR_DEATH_DIE6,SPR_DEATH_DEAD, // // Ghost // SPR_SPECTRE_W1,SPR_SPECTRE_W2,SPR_SPECTRE_W3,SPR_SPECTRE_W4, SPR_SPECTRE_F1,SPR_SPECTRE_F2,SPR_SPECTRE_F3,SPR_SPECTRE_F4, // // Angel of Death // SPR_ANGEL_W1,SPR_ANGEL_W2,SPR_ANGEL_W3,SPR_ANGEL_W4, SPR_ANGEL_SHOOT1,SPR_ANGEL_SHOOT2,SPR_ANGEL_TIRED1,SPR_ANGEL_TIRED2, SPR_ANGEL_DIE1,SPR_ANGEL_DIE2,SPR_ANGEL_DIE3,SPR_ANGEL_DIE4, SPR_ANGEL_DIE5,SPR_ANGEL_DIE6,SPR_ANGEL_DIE7,SPR_ANGEL_DEAD, // // player attack frames // SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,SPR_KNIFEATK3, SPR_KNIFEATK4, SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,SPR_PISTOLATK3, SPR_PISTOLATK4, SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,SPR_MACHINEGUNATK2,MACHINEGUNATK3, SPR_MACHINEGUNATK4, SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3, SPR_CHAINATK4, }; #define SPRT_ONE_TEX BIT( 1 ) #define SPRT_NO_ROT BIT( 2 ) #define SPRT_CHG_POS BIT( 3 ) #define SPRT_CHG_TEX BIT( 4 ) #define SPRT_REMOVE BIT( 5 ) typedef struct sprite_s { vec3_t position; int x, y, ang; // very clever to make it not just (x>>TILE_SHIFT) // but also (x>>TILE_SHIFT)-1 if (x%TILEWIDTH)<TILE_HALF // so we will check only 4 files instead of 9 as Carmack did! int tilex, tiley; // controls appearence of this sprite: // SPRT_ONE_TEX: use one texture for each rotation // SPRT_NO_ROT: do not rotate sprite (fence) // SPRT_CHG_POS // SPRT_CHG_TEX // SPRT_REMOVE int flags; // 8 textures: one for each rotation phase! // if SPRT_ONE_TEX flag use tex with index 0! // these are Wolf sprite texture numbers, not OpenGL sprites // or indexes in the textureManager list int tex[ 8 ]; } sprite_t; // total sprites on level in a moment #define MAX_SPRITES 1024 typedef struct visobj_s { int dist; // how we will sort them int x, y; // position in game space! (for OpenGL) int tex; // texture to draw; renderer must know what to draw by this number! } visobj_t; extern visobj_t vislist[]; void Sprite_Reset( void ); void Sprite_RemoveSprite( int sprite_id ); int Sprite_GetNewSprite( void ); void Sprite_SetPos( int sprite_id, int x, int y, int angle ); void Sprite_SetTex( int sprite_id, int index, int tex ); int Sprite_CreateVisList( void ); #endif /* __WOLF_SPRITES_H__ */
MichaelLiebscher/Wolfenstein3D_Redux
wolf3dredux/wolf/wolf_sprites.h
C
gpl-2.0
10,871
<?php require_once("include/config.php"); require_once("include/functions.php"); if(!isset($_SESSION['logat'])) $_SESSION['logat'] = 'Nu'; if($_SESSION['logat'] == 'Da') { if(isset($_SESSION['nume']) && ctype_alnum($_SESSION['nume'])) $setid = $_SESSION['userid']; if(isset($setid)) { if($_SESSION['global']==1 ? $acces=1 : $acces=check_perm("Editare pagini")); if($acces!=1) header('Location: http://'.$_SERVER["SERVER_NAME"].'/admiasi/index.php'); } else header('Location: http://'.$_SERVER["SERVER_NAME"].'/admiasi/index.php'); if(isset($_POST['submit'])) { $id = make_safe($_GET['id']); $galt = make_safe($_POST['galt']); $link = $_POST['link']; if(!validateURL($link)) $mesaj = "Adres&#259; web invalid&#259;."; else { $sql="UPDATE `gallery` SET galt='$galt', link='$link' WHERE id='$id'"; mysql_query($sql); $mesaj = "Datele au fost actualizate!"; } } if(isset($_GET['id']) && is_numeric($_GET['id'])) { $sql = "SELECT * FROM `gallery` WHERE id=".$_GET['id'].""; $result = mysql_query($sql); if(mysql_num_rows($result)>0) { $rand = mysql_fetch_object($result); $id = $rand -> id; $galt = $rand -> galt; $link = $rand -> link; } else $nuexista = 1; } else header('Location: http://'.$_SERVER["SERVER_NAME"].'/admiasi/editare-sponsori.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head profile="http://gmpg.org/xfn/11"> <?php include("include/headerinfoadm.php");?> <link rel="stylesheet" type="text/css" href="js/formValidator/validationEngine.jquery.css" /> </head> <body> <div id="contain"> <div id="main"> <?php include("include/headeradm.php");?> <div id="pagecontent"> <div id="pcontent_f"></div> <?php if(!isset($nuexista)) { ?> <br/> <a href="editare-galerie.php"><img src="images/back.png" class="midalign"/></a>&nbsp;<a href="editare-galerie.php">&Icirc;napoi la pagina de administrare a galeriei foto</a> <br/><br/> <?php display_message($mesaj); ?> <b>Editare imagine galerie foto:</b><br/><br/> <form action="editare-foto.php?id=<?php echo $_GET['id'];?>" method="post" id="validate"> <input type="hidden" name="token" value="<?php echo $_SESSION['token'] ?>" /> Text alternativ imagine: <input name="galt" type="text" value="<?php if(isset($galt)) echo $galt?>" class="stfield"/> <br/><br/> Link imagine: <input name="link" type="text" value="<?php if(isset($link)) echo $link?>" class="stfield" data-validation-engine="validate[custom[url]]"/> <br /><br /> <input name="submit" type="submit" value="Actualizare imagine" /> </form> <? } else {?> Comentariul pe care a&#355;i &icirc;ncercat s&#259; &icirc;l accesa&#355;i nu exist&#259;! <?php } ?> </div> <?php include("include/footeradm.php");?> </div> </div> <script type="text/javascript" src="js/formValidator/jquery.validationEngine.js"></script> <script type="text/javascript" src="js/formValidator/jquery.validationEngine-ro.js" charset="utf-8"></script> <script type="text/javascript"> $(document).ready(function() { $("#validate").validationEngine(); }); </script> </body> </html> <?php } else { header('Location: http://'.$_SERVER["SERVER_NAME"].'/admiasi/index.php'); } ?>
hodorogandrei/contesteasyplatform
admiasi/editare-foto.php
PHP
gpl-2.0
4,821
using System.ComponentModel; using System.Windows; namespace Filewatcher.GUI { public partial class MacroView { public string Value { get; set; } public MacroView() { InitializeComponent(); InitalizeExitRequest(); InitializeLocation(); } private void InitalizeExitRequest() { var currDataContext = DataContext as MacroViewModel; if (currDataContext == null) return; currDataContext.ExitRequest += (s, eArgs) => { if (eArgs.DialogResult) Value = eArgs.Value.ToString(); DialogResult = eArgs.DialogResult; Close(); }; } private void InitializeLocation() { if (Properties.Settings.Default.MACROVIEW_LEFT > 0) Left = Properties.Settings.Default.MACROVIEW_LEFT; if (Properties.Settings.Default.MACROVIEW_TOP > 0) Top = Properties.Settings.Default.MACROVIEW_TOP; } private void WindowClosing(object sender, CancelEventArgs e) { Properties.Settings.Default.MACROVIEW_LEFT = Left; Properties.Settings.Default.MACROVIEW_TOP = Top; Properties.Settings.Default.Save(); } } }
bajak/luba-filewatcher
GUI/Views/MacroView.xaml.cs
C#
gpl-2.0
1,364
<?php // ============================================================+ // File name : example_045.php // Begin : 2008-03-04 // Last Update : 2011-04-15 // // Description : Example 045 for TCPDF class // Bookmarks and Table of Content // // Author: Nicola Asuni // // (c) Copyright: // Nicola Asuni // Tecnick.com LTD // Manor Coach House, Church Hill // Aldershot, Hants, GU12 4RQ // UK // www.tecnick.com // info@tecnick.com // ============================================================+ /** * Creates an example PDF TEST document using TCPDF * * @package com.tecnick.tcpdf * @abstract TCPDF - Example: Bookmarks and Table of Content * @author Nicola Asuni * @since 2008-03-04 */ require_once ('../config/lang/eng.php'); require_once ('../tcpdf.php'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 045'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 045', PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(Array( PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN )); $pdf->setFooterFont(Array( PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA )); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('times', 'B', 20); // add a page $pdf->AddPage(); // set a bookmark for the current position $pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array( 0, 64, 128 )); // print a line using Cell() $pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L'); $pdf->AddPage(); $pdf->Bookmark('Paragraph 1.1', 1, 0, '', '', array( 128, 0, 0 )); $pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L'); $pdf->AddPage(); $pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array( 128, 0, 0 )); $pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L'); $pdf->AddPage(); $pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array( 0, 128, 0 )); $pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L'); $pdf->AddPage(); $pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array( 128, 0, 0 )); $pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L'); // add some pages and bookmarks for ($i = 2; $i < 12; $i ++) { $pdf->AddPage(); $pdf->Bookmark('Chapter ' . $i, 0, 0, '', 'B', array( 0, 64, 128 )); $pdf->Cell(0, 10, 'Chapter ' . $i, 0, 1, 'L'); } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // add a new page for TOC $pdf->addTOCPage(); // write the TOC title $pdf->SetFont('times', 'B', 16); $pdf->MultiCell(0, 0, 'Table Of Content', 0, 'C', 0, 1, '', '', true, 0); $pdf->Ln(); $pdf->SetFont('dejavusans', '', 12); // add a simple Table Of Content at first page // (check the example n. 59 for the HTML version) $pdf->addTOC(1, 'courier', '.', 'INDEX', 'B', array( 128, 0, 0 )); // end of TOC page $pdf->endTOCPage(); // --------------------------------------------------------- // Close and output PDF document $pdf->Output('example_045.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+
memoupao/Fondo-Simon
lib/tcpdf/examples/example_045.php
PHP
gpl-2.0
3,857
#include <linux/version.h> /* * Our Own ASSERT implementation, so we can easily switch among BUG_ON, WARN_ON and nothing */ #ifdef _DEBUG #define ASSERT(expr) WARN_ON(!(expr)) #else #define ASSERT(expr) #endif #include <linux/time.h> /* * Global defines */ /* SD: dont care about context switches #define CAPTURE_CONTEXT_SWITCHES */ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)) #define CAPTURE_SIGNAL_DELIVERIES #endif #define RW_SNAPLEN 80 #define RW_SNAPLEN_EVENT 4096 #define RW_MAX_SNAPLEN (256 * 1024 * 1024) #define DPI_LOOKAHED_SIZE 16 #define PPM_NULL_RDEV MKDEV(1, 3) #define PPM_PORT_MYSQL 3306 #define PPM_PORT_POSTGRES 5432 #define PPM_PORT_STATSD 8125 /* * Global enums */ enum syscall_flags { UF_NONE = 0, UF_USED = (1 << 0), UF_NEVER_DROP = (1 << 1), UF_ALWAYS_DROP = (1 << 2), }; /* * Global structs */ struct syscall_evt_pair { int flags; enum ppm_event_type enter_event_type; enum ppm_event_type exit_event_type; }; /* * The ring descriptor. * We have one of these for each CPU. */ struct ppm_ring_buffer_context { bool cpu_online; bool open; bool capture_enabled; struct ppm_ring_buffer_info *info; char *buffer; struct timespec last_print_time; u32 nevents; atomic_t preempt_count; char *str_storage; /* String storage. Size is one page. */ }; struct ppm_consumer_t { struct task_struct *consumer_id; #ifdef __percpu struct ppm_ring_buffer_context __percpu *ring_buffers; #else struct ppm_ring_buffer_context *ring_buffers; #endif u32 snaplen; u32 sampling_ratio; bool do_dynamic_snaplen; u32 sampling_interval; int is_dropping; int dropping_mode; volatile int need_to_insert_drop_e; volatile int need_to_insert_drop_x; struct list_head node; }; #define STR_STORAGE_SIZE PAGE_SIZE /* * Global functions * * These are analogous to get_user(), copy_from_user() and strncpy_from_user(), * but they can't sleep, barf on page fault or be preempted */ #define ppm_get_user(x, ptr) ({ ppm_copy_from_user(&x, ptr, sizeof(x)) ? -EFAULT : 0; }) unsigned long ppm_copy_from_user(void *to, const void __user *from, unsigned long n); long ppm_strncpy_from_user(char *to, const char __user *from, unsigned long n); /* * Global tables */ #ifdef CONFIG_MIPS #define SYSCALL_TABLE_ID0 __NR_Linux #elif defined CONFIG_ARM #define SYSCALL_TABLE_ID0 __NR_SYSCALL_BASE #elif defined CONFIG_X86 || defined CONFIG_SUPERH #define SYSCALL_TABLE_ID0 0 #elif defined CONFIG_PPC64 #define SYSCALL_TABLE_ID0 0 #elif defined CONFIG_S390 #define SYSCALL_TABLE_ID0 0 #endif #define SYSCALL_TABLE_SIZE 512 extern const struct syscall_evt_pair g_syscall_table[]; extern const struct ppm_event_info g_event_info[]; extern const enum ppm_syscall_code g_syscall_code_routing_table[]; #if defined(CONFIG_X86_64) && defined(CONFIG_IA32_EMULATION) extern const struct syscall_evt_pair g_syscall_ia32_table[]; extern const enum ppm_syscall_code g_syscall_ia32_code_routing_table[]; #endif
thesrinivas/rakshak
rakshak-probe.bkup/driver/approbe.h
C
gpl-2.0
2,945
package de.amshaegar.economy.http; import java.io.IOException; import java.net.InetSocketAddress; import com.sun.net.httpserver.HttpServer; import de.amshaegar.economy.EcoFlow; public class WebInterface { private HttpServer server; public WebInterface(int port) throws IOException { server = HttpServer.create(new InetSocketAddress(port), 0); server.createContext("/", new TemplateHttpHandler()); server.createContext("/auth", new AuthHttpHandler()); server.createContext("/intern", new InternHttpHandler()); server.createContext("/intern/ajax", new AjaxHttpHandler()); server.start(); EcoFlow.getPlugin().getLogger().info(String.format("Web interface started on port %d", server.getAddress().getPort())); } public void stop() { server.stop(0); } }
AmShaegar13/EcoFlow
src/de/amshaegar/economy/http/WebInterface.java
Java
gpl-2.0
780
<?php /** * Auto Amazon Links * * Generates links of Amazon products just coming out today. You just pick categories and they appear even in JavaScript disabled browsers. * * https://en.michaeluno.jp/amazon-auto-links/ * Copyright (c) 2013-2021 Michael Uno */ /** * A scratch class to delete a database table. * * @since 4.3.5 */ class AmazonAutoLinks_Run_Database_Delete_aal_products extends AmazonAutoLinks_Scratch_Base { /** * @purpose Deletes the task table and version option. * @return boolean */ public function scratch_uninstall() { $_oTaskTable = new AmazonAutoLinks_DatabaseTable_aal_products; $_oTaskTable->uninstall(); return ! $_oTaskTable->tableExists(); } }
michaeluno/amazon-auto-links
include/core/component/test/run/delete/database/aal_products/AmazonAutoLinks_Run_Database_Delete_aal_products.php
PHP
gpl-2.0
745
<div class="footer-social"> <div class="container"> <div class="row"> <div class="col-sm-6"> <h3 style="margin-top:8px; font-weight:300;"></h3> </div> <div class="col-sm-1"> <div class="social"> <div class="social-icon"><a href="#"><i class="icon-twitter"></i></a></div> </div> </div><!--/1--> <div class="col-sm-1"> <div class="social"> <div class="social-icon"><a href="#"><i class="icon-facebook"></i></a></div> </div> </div><!--/1--> <div class="col-sm-1"> <div class="social"> <div class="social-icon"><a href="#"><i class="icon-google-plus"></i></a></div> </div> </div><!--/1--> <div class="col-sm-1"> <div class="social"> <div class="social-icon"><a href="#"><i class="icon-linkedin"></i></a></div> </div> </div><!--/1--> </div> </div> </div> <footer class="footer" role="contentinfo"> <div class="container"> <div id="inner-footer" class="wrap clearfix"> <nav role="navigation"> <div class="row"> <div class="col-md-3 col-sm-3"> <?php bones_footer_links(); ?> </div><!--/3--> <div class="col-md-3 col-sm-3"> <?php bones_footer_links_2(); ?> </div><!--/3--> <div class="col-md-3 col-sm-3"> <?php bones_footer_links_3(); ?> </div><!--/3--> <div class="col-md-3 col-sm-3"> <h4>About Us</h4> <p>Helping our clients grow - with responsible, ethical, and technological leadership. TRUEBADORE is poised to humanize the experience of using technology for meaningful business purposes. TRUEBADORE focuses on aligning aesthetic intelligence and technical prowess so that people will be delighted - not disillusioned - by the new reality that every business is a software business.</p> </div><!--/3--> </div> </nav> </div> <!-- end #inner-footer --> </div> <!-- end .container --> </footer> <!-- end footer --> <div class="footer-copyright"> <div class="container"> <div class="row"> <div class="col-md-10"> <p class="source-org copyright">&copy; <?php echo date('Y'); ?> <?php bloginfo( 'name' ); ?>. All Rights Reserved.</p> </div> <div class="col-md-2"> <a href="#">Back to Top <i class="icon-arrow-up"></i></a> </div> </div> </div> </div> </div> <!-- end .wrapper --> <!-- all js scripts are loaded in library/bones.php --> <?php wp_footer(); ?> </body> </html> <!-- end page. what a ride! -->
truebadore/tba
wp-content/themes/cloudhost/footer.php
PHP
gpl-2.0
3,013
<?php if ( !defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } /** * Manages image sizes settings * * Here image sizes settings are defined and managed. * * @version 1.1.4 * @package ecommerce-product-catalog/functions * @author Norbert Dreszer */ add_action( 'admin_init', 'ic_add_wp_screens_settings' ); function ic_add_wp_screens_settings() { add_settings_section( 'default', __( 'Product Catalog Images', 'ecommerce-product-catalog' ), 'ic_catalog_image_sizes_settings', 'media' ); } function ic_catalog_image_sizes_settings() { $images = ic_get_catalog_image_sizes(); ?> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e( 'Catalog Single Page Image', 'ecommerce-product-catalog' ) ?></th> <td><fieldset><legend class="screen-reader-text"><span>Large size</span></legend> <label for="product_page_image_w"><?php _e( 'Max Width' ) ?></label> <input name="catalog_image_sizes[product_page_image_w]" type="number" step="1" min="0" id="product_page_image_w" value="<?php echo $images[ 'product_page_image_w' ] ?>" class="small-text"> <label for="product_page_image_h"><?php _e( 'Max Height' ) ?></label> <input name="catalog_image_sizes[product_page_image_h]" type="number" step="1" min="0" id="product_page_image_h" value="<?php echo $images[ 'product_page_image_h' ] ?>" class="small-text"> </fieldset></td> </tr> <tr> <th scope="row"><?php _e( 'Catalog Category Page Image', 'ecommerce-product-catalog' ) ?></th> <td><fieldset><legend class="screen-reader-text"><span>Large size</span></legend> <label for="product_category_page_image_w"><?php _e( 'Max Width' ) ?></label> <input name="catalog_image_sizes[product_category_page_image_w]" type="number" step="1" min="0" id="product_category_page_image_w" value="<?php echo $images[ 'product_category_page_image_w' ] ?>" class="small-text"> <label for="product_category_page_image_h"><?php _e( 'Max Height' ) ?></label> <input name="catalog_image_sizes[product_category_page_image_h]" type="number" step="1" min="0" id="product_category_page_image_h" value="<?php echo $images[ 'product_category_page_image_h' ] ?>" class="small-text"> </fieldset></td> </tr> <tr> <th scope="row"><?php _e( 'Modern Grid Image', 'ecommerce-product-catalog' ) ?></th> <td><fieldset><legend class="screen-reader-text"><span>Large size</span></legend> <label for="modern_grid_image_w"><?php _e( 'Max Width' ) ?></label> <input name="catalog_image_sizes[modern_grid_image_w]" type="number" step="1" min="0" id="product_page_image_w" value="<?php echo $images[ 'modern_grid_image_w' ] ?>" class="small-text"> <label for="modern_grid_image_h"><?php _e( 'Max Height' ) ?></label> <input name="catalog_image_sizes[modern_grid_image_h]" type="number" step="1" min="0" id="product_page_image_h" value="<?php echo $images[ 'modern_grid_image_h' ] ?>" class="small-text"><br> </fieldset></td> </tr> <tr> <th scope="row"><?php _e( 'Classic Grid Image', 'ecommerce-product-catalog' ) ?></th> <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Classic Grid Image', 'ecommerce-product-catalog' ) ?></span></legend> <label for="classic_grid_image_w"><?php _e( 'Max Width' ) ?></label> <input name="catalog_image_sizes[classic_grid_image_w]" type="number" step="1" min="0" id="product_page_image_w" value="<?php echo $images[ 'classic_grid_image_w' ] ?>" class="small-text"> <label for="classic_grid_image_h"><?php _e( 'Max Height' ) ?></label> <input name="catalog_image_sizes[classic_grid_image_h]" type="number" step="1" min="0" id="product_page_image_h" value="<?php echo $images[ 'classic_grid_image_h' ] ?>" class="small-text"> </fieldset></td> </tr> <tr> <th scope="row"><?php _e( 'Classic List Image', 'ecommerce-product-catalog' ) ?></th> <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Classic List Image', 'ecommerce-product-catalog' ) ?></span></legend> <label for="classic_list_image_w"><?php _e( 'Max Width' ) ?></label> <input name="catalog_image_sizes[classic_list_image_w]" type="number" step="1" min="0" id="product_page_image_w" value="<?php echo $images[ 'classic_list_image_w' ] ?>" class="small-text"> <label for="classic_list_image_h"><?php _e( 'Max Height' ) ?></label> <input name="catalog_image_sizes[classic_list_image_h]" type="number" step="1" min="0" id="product_page_image_h" value="<?php echo $images[ 'classic_list_image_h' ] ?>" class="small-text"> </fieldset></td> </tr> <?php do_action( 'catalog_image_sizes_settings', $images ) ?> </tbody> </table> <?php } function ic_get_default_catalog_image_sizes() { $image_sizes[ 'product_page_image_w' ] = 600; $image_sizes[ 'product_page_image_h' ] = 600; $image_sizes[ 'product_category_page_image_w' ] = 600; $image_sizes[ 'product_category_page_image_h' ] = 600; $image_sizes[ 'classic_grid_image_w' ] = 600; $image_sizes[ 'classic_grid_image_h' ] = 600; $image_sizes[ 'classic_list_image_w' ] = 280; $image_sizes[ 'classic_list_image_h' ] = 160; $image_sizes[ 'modern_grid_image_w' ] = 600; $image_sizes[ 'modern_grid_image_h' ] = 384; return apply_filters( 'default_catalog_image_sizes', $image_sizes ); } /** * Returns catalog image sizes array * * @return type */ function ic_get_catalog_image_sizes() { $image_sizes = ic_get_global( 'catalog_image_sizes' ); if ( !$image_sizes ) { $default = ic_get_default_catalog_image_sizes(); $image_sizes = wp_parse_args( get_option( 'catalog_image_sizes', $default ), $default ); ic_save_global( 'catalog_image_sizes', $image_sizes ); } return $image_sizes; } add_action( 'product-settings-list', 'ic_register_image_setting' ); /** * Registers catalog image sizes * */ function ic_register_image_setting() { register_setting( 'media', 'catalog_image_sizes' ); } add_action( 'after_setup_theme', 'ic_add_catalog_image_sizes' ); /** * Adds image size for classic grid product listing * */ function ic_add_catalog_image_sizes() { $image_sizes = ic_get_catalog_image_sizes(); add_image_size( 'classic-grid-listing', $image_sizes[ 'classic_grid_image_w' ], $image_sizes[ 'classic_grid_image_h' ] ); add_image_size( 'classic-list-listing', $image_sizes[ 'classic_list_image_w' ], $image_sizes[ 'classic_list_image_h' ] ); add_image_size( 'modern-grid-listing', $image_sizes[ 'modern_grid_image_w' ], $image_sizes[ 'modern_grid_image_h' ], true ); add_image_size( 'product-page-image', $image_sizes[ 'product_page_image_w' ], $image_sizes[ 'product_page_image_h' ] ); add_image_size( 'product-category-page-image', $image_sizes[ 'product_category_page_image_w' ], $image_sizes[ 'product_category_page_image_h' ] ); do_action( 'add_catalog_image_sizes', $image_sizes ); } /** * Generates image size settings table tr * * @param type $label * @param type $name */ function ic_image_sizes_settings_tr( $label, $name ) { $images = ic_get_catalog_image_sizes(); ?> <tr> <th scope="row"><?php echo $label ?></th> <td><fieldset><legend class="screen-reader-text"><span><?php echo $label ?></span></legend> <label for="<?php echo $name . '_w' ?>"><?php _e( 'Max Width' ) ?></label> <input name="catalog_image_sizes[<?php echo $name ?>_w]" type="number" step="1" min="0" id="<?php echo $name ?>_w" value="<?php echo $images[ $name . '_w' ] ?>" class="small-text"> <label for="<?php echo $name . '_h' ?>"><?php _e( 'Max Height' ) ?></label> <input name="catalog_image_sizes[<?php echo $name ?>_h]" type="number" step="1" min="0" id="<?php echo $name ?>_h" value="<?php echo $images[ $name . '_h' ] ?>" class="small-text"> </fieldset></td> </tr><?php }
impleCode/ecommerce-product-catalog
includes/settings/image-sizes.php
PHP
gpl-2.0
7,783
package com.tacohen.killbots.Logic; import android.util.Pair; public class GridDimensions { public static Pair<Integer, Integer> gridDimensions; public static int width; public static int height; public static Pair<Integer, Integer> getGridDimensions() { return gridDimensions; } public static void setGridDimensions(Pair<Integer, Integer> gridDimensions) { GridDimensions.gridDimensions = gridDimensions; } public static int getWidth() { return width; } public static void setWidth(int width) { GridDimensions.width = width; } public static int getHeight() { return height; } public static void setHeight(int height) { GridDimensions.height = height; } }
Tacohen/Killbots
Killbots/src/com/tacohen/killbots/Logic/GridDimensions.java
Java
gpl-2.0
692
<?php /* * Plugin Name: Permalink Redirect * Plugin URI: http://scott.yang.id.au/code/permalink-redirect/ * Description: Permalink Redirect ensures that pages and entries are always accessed via the permalink. Otherwise, a 301 redirect will be issued. * Version: 2.0.5 * Author: Scott Yang * Author URI: http://scott.yang.id.au/ */ class YLSY_PermalinkRedirect { function admin_menu() { add_options_page('Permalink Redirect Manager', 'Permalink Redirect', 5, 'permalink-redirect', array($this, 'admin_page')); } function admin_page() { global $wp_version; // If we are updating, we will flush all the rewrite rules to force the // old structure to be added. if (isset($_GET['updated']) || isset($_GET['settings-updated'])) { $this->regenerate_rules(); } $options = array('feedburner', 'feedburnerbrand', 'hostname', 'oldstruct', 'skip', 'newpath'); $optionvars = array(); foreach ($options as $option) { $$option = get_option("permalink_redirect_$option"); if (!$$option) { $$option = ($option == 'feedburnerbrand') ? 'feeds.feedburner.com' : ''; } if ($wp_version < '2' && !$$option) { add_option("permalink_redirect_$option", $$option); } $optionvars[] = "permalink_redirect_$option"; } $home = parse_url(get_option('home')); ?> <div class="wrap"> <h2>Permalink Redirect Manager</h2> <form action="options.php" method="post"> <fieldset class="options"> <legend>Paths to be skipped</legend> <p>Separate each entry with a new line. Matched with regular expression.</p> <textarea name="permalink_redirect_skip" style="width:98%;" rows="5"><?php echo htmlspecialchars($skip); ?></textarea> <legend style="padding-top:20px">Path pairs to redirect from and to</legend> <p>Separate each entry with a new line. Each line is [from]&lt;spaces&gt;[to].</p> <textarea name="permalink_redirect_newpath" style="width:98%;" rows="5"><?php echo htmlspecialchars($newpath); ?></textarea> <table class="optiontable" style="padding-top:20px"> <tr valign="top"> <th scope="row">Old Permalink Structures:</th> <td><textarea name="permalink_redirect_oldstruct" id="permalink_redirect_oldstruct" style="width:98%" rows="3"><?php echo htmlspecialchars($oldstruct); ?></textarea><br/><small><a href="http://codex.wordpress.org/Using_Permalinks">Available tags</a>. One Permalink Structure per line. Current permalink structure: <a href="#" onclick="document.getElementById('permalink_redirect_oldstruct').value = '<?php echo htmlspecialchars(get_option('permalink_structure')); ?>';return false;"><code><?php echo htmlspecialchars(get_option('permalink_structure')); ?></code></a></small></td> </tr> <tr> <th scope="row">FeedBurner Redirect:</th> <td>http://<input name="permalink_redirect_feedburnerbrand" type="text" id="permalink_redirect_feedburnerbrand" value="<?php print htmlspecialchars($feedburnerbrand); ?>" size="20"/>/<input name="permalink_redirect_feedburner" type="text" id="permalink_redirect_feedburner" value="<?php echo htmlspecialchars($feedburner) ?>" size="20" /></td> </tr> <tr> <th scope="row">Hostname Redirect:</th> <td><input name="permalink_redirect_hostname" type="checkbox" id="permalink_redirect_hostname" value="1"<?php if ($hostname) { ?> checked="checked"<?php } ?>/> Redirect if hostname is not <code><?php echo htmlspecialchars($home['host']); ?></code>.</td> </tr> </table> </fieldset> <p class="submit"> <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" /> <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="<?php echo join(',', $optionvars); ?>"/> <?php if (function_exists('wp_nonce_field')) { wp_nonce_field('update-options'); } ?> </p> </form> </div> <?php } function check_hostname() { if (! get_option('permalink_redirect_hostname')) { return false; } $requested = $_SERVER['HTTP_HOST']; $home = parse_url(get_option('home')); return $requested != $home['host']; } function execute() { global $wp_query; $this->execute2($wp_query); } function execute2($query, $testold=true) { $req_uri = $_SERVER['REQUEST_URI']; if ($query->is_trackback || $query->is_search || $query->is_comments_popup || $query->is_robots || $this->is_skip($req_uri)) { return; } $this->redirect_newpath($req_uri); $this->redirect_feedburner($query); if ($query->is_404) { if ($testold) { $this->redirect_old_permalink($req_uri); } return; } if (($req_uri = @parse_url($_SERVER['REQUEST_URI'])) === false) { return; } $req_path = $req_uri['path']; $new_uri = $this->guess_permalink($query); if (!$new_uri) { return; } $permalink = @parse_url($new_uri); // WP2.1: If a static page has been set as the front-page, we'll get // empty string here. if (!$permalink['path']) { $permalink['path'] = '/'; } if (($req_path != $permalink['path']) || $this->check_hostname()) { wp_redirect($new_uri, 301); } } function guess_permalink($query) { $haspost = count($query->posts) > 0; $has_ut = function_exists('user_trailingslashit'); if (get_query_var('m')) { // Handling special case with '?m=yyyymmddHHMMSS' // Since there is no code for producing the archive links for // is_time, we will give up and not trying any redirection. $m = preg_replace('/[^0-9]/', '', get_query_var('m')); switch (strlen($m)) { case 4: // Yearly $link = get_year_link($m); break; case 6: // Monthly $link = get_month_link(substr($m, 0, 4), substr($m, 4, 2)); break; case 8: // Daily $link = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2)); break; default: return false; } } elseif (($query->is_single || $query->is_page) && $haspost) { $post = $query->posts[0]; $link = get_permalink($post->ID); $page = get_query_var('page'); if ($page && $page > 1) { $link = trailingslashit($link) . "$page"; if ($has_ut) { $link = user_trailingslashit($link, 'paged'); } else { $link .= '/'; } } // WP2.2: In Wordpress 2.2+ is_home() returns false and is_page() // returns true if front page is a static page. if ($query->is_page && ('page' == get_option('show_on_front')) && $post->ID == get_option('page_on_front')) { $link = trailingslashit($link); } } elseif ($query->is_author && $haspost) { global $wp_version; if ($wp_version >= '2') { $author = get_userdata(get_query_var('author')); if ($author === false) return false; if (function_exists('get_author_posts_url')) { $link = get_author_posts_url($author->ID, $author->user_nicename); } else { $link = get_author_link(false, $author->ID, $author->user_nicename); } // XXX: get_author_link seems to always return one with // trailing slash. We have to call user_trailingslashit to // make it right. if ($has_ut) { $link = user_trailingslashit($link); } } else { // XXX: get_author_link() bug in WP 1.5.1.2 // s/author_nicename/user_nicename/ global $cache_userdata; $userid = get_query_var('author'); $link = get_author_link(false, $userid, $cache_userdata[$userid]->user_nicename); } } elseif ($query->is_category && $haspost) { $link = get_category_link(get_query_var('cat')); } elseif ($query->is_tag && $haspost) { $link = get_tag_link(get_query_var('tag_id')); } elseif ($query->is_day && $haspost) { $link = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')); } elseif ($query->is_month && $haspost) { $link = get_month_link(get_query_var('year'), get_query_var('monthnum')); } elseif ($query->is_year && $haspost) { $link = get_year_link(get_query_var('year')); } elseif ($query->is_home) { // WP2.1: Handling "Posts page" option. In WordPress 2.1 is_home() // returns true and is_page() returns false if home page has been // set to a page, and we are getting the permalink of that page // here. if ((get_option('show_on_front') == 'page') && ($pageid = get_option('page_for_posts'))) { $link = trailingslashit(get_permalink($pageid)); } else { $link = trailingslashit(get_option('home')); } } else { return false; } if ($query->is_paged) { $paged = get_query_var('paged'); if ($paged) { $link = trailingslashit($link) . "page/$paged"; if ($has_ut) { $link = user_trailingslashit($link, 'paged'); } else { $link .= '/'; } } } if ($query->is_feed) { $link = trailingslashit($link) . 'feed'; if ($has_ut) { $link = user_trailingslashit($link, 'feed'); } else { $link .= '/'; } } return $link; } function is_feedburner() { return strncmp('FeedBurner/', $_SERVER['HTTP_USER_AGENT'], 11) == 0; } function is_skip($path) { $permalink_redirect_skip = get_option('permalink_redirect_skip'); $permalink_redirect_skip = explode("\n", $permalink_redirect_skip); // Apply 'permalink_redirect_skip' filter so other plugins can // customise the skip behaviour. (Denis de Bernardy @ 2006-04-23) $permalink_redirect_skip = apply_filters('permalink_redirect_skip', $permalink_redirect_skip); foreach ($permalink_redirect_skip as $skip) { $skip = trim($skip); if ($skip && ereg($skip, $path)) return true; } return false; } function redirect_feedburner($query) { // Check whether we need to do redirect for FeedBurner. // NOTE this might not always get executed. For feeds, // WP::send_headers() might send back a 304 before template_redirect // action can be called. global $withcomments; if ($query->is_feed && !$query->is_archive && !$withcomments) { if (($feedburner = get_option('permalink_redirect_feedburner')) && (strncmp('FeedBurner/', $_SERVER['HTTP_USER_AGENT'], 11) != 0)) { $brand = get_option('permalink_redirect_feedburnerbrand'); $brand = $brand ? $brand : 'feeds.feedburner.com'; wp_redirect("http://$brand/$feedburner", 302); } } } // Static page redirect contributed by Sergey Menshikov. function redirect_newpath($path) { if ($newpathlist = get_option('permalink_redirect_newpath')) { $newpathlist = explode("\n", $newpathlist); foreach ($newpathlist as $newpath) { $pair = preg_split('/\s+/', trim($newpath)); if ($pair[0] == $path) { wp_redirect($pair[1], 301); } } } } /** * Called when the main execute function gets a 404 to check against old * permalink structures and perform redirect if an old post can be * matched. */ function redirect_old_permalink($req_uri) { global $wp_query, $wp_rewrite; global $wp_version; $rules = get_option('permalink_redirect_rules'); if (!$rules) { return; } // Backing up the rewrite object for you, imperative programmers! $wp_rewrite_old = $wp_rewrite; // Unsetting the globals. Argh! Evil global variables! foreach ($wp_query->query_vars as $key => $val) { unset($GLOBALS[$key]); } // Going through the rules. foreach ($rules as $rules2) { $wp2 = new WP(); $wp_rewrite = new YLSY_Rewrite(); $wp_rewrite->index = $wp_rewrite_old->index; $wp_rewrite->rules = $rules2; $wp2->parse_request(); if (isset($wp2->query_vars['error']) && ($wp2->query_vars['error'] == 404)) { continue; } $query = new WP_Query(); if ($wp_version >= '2.1') { $posts = $query->query($wp2->query_vars); } else { $wp2->build_query_string(); $posts = $query->query($wp2->query_string); } if (count($posts) > 0) { $wp_rewrite = $wp_rewrite_old; $this->execute2($query, false); return; } } // Restoring global variables. We don't bother to reset the other // variables as we are going to do a 404 anyway. $wp_rewrite = $wp_rewrite_old; } /** * This function is called after someone saved the old permalink * structure. It will create cached version of rewrite rules from the * old structure. */ function regenerate_rules() { global $wp_rewrite; $oldstruct = get_option('permalink_redirect_oldstruct'); if ($oldstruct) { $rules = array(); $oldstruct = explode("\n", $oldstruct); foreach ($oldstruct as $item) { $rules2 = $wp_rewrite->generate_rewrite_rule(trim($item), false, false, false, true); $rules3 = array(); foreach ($rules2 as $match => $query) { $query = preg_replace('/\$(\d+)/', '\$matches[\1]', $query); $rules3[$match] = $query; } $rules[] = $rules3; } update_option('permalink_redirect_rules', $rules); } else { delete_option('permalink_redirect_rules'); } } } /** * I am a dummy class to simulate the WP_Rewite class, but only has one * method implemented. */ class YLSY_Rewrite { function wp_rewrite_rules() { return $this->rules; } } if (!function_exists('wp_redirect')) { function wp_redirect($location, $status=302) { global $is_IIS; $location = apply_filters('wp_redirect', $location, $status); $status = apply_filters('wp_redirect_status', $status, $location); if (!$location) return false; if (function_exists('wp_sanitize_redirect')) { $location = wp_sanitize_redirect($location); } if ($is_IIS) { header("Refresh: 0;url=$location"); } else { status_header($status); header("Location: $location"); } } } $_permalink_redirect = new YLSY_PermalinkRedirect(); add_action('admin_menu', array($_permalink_redirect, 'admin_menu')); add_action('template_redirect', array($_permalink_redirect, 'execute'));
amejias101/wordpress
wp-content/plugins/ylsy_permalink_redirect.php
PHP
gpl-2.0
16,822
//http://codeforces.com/problemset/problem/670/D2 #include <iostream> #include <vector> #include <algorithm> using namespace std; #define printv(data) for(auto& e:data) cout<<e<<","; cout<<endl; #define sortv(data) std::sort(data.begin(),data.end()); #define rsortv(data) std::sort(data.rbegin(),data.rend()); #define fori(start,end) for(size_t i{start};i<end;i++) #define forj(start,end) for(size_t j{start};j<end;j++) #define foralli(data) fori(0,data.size()) constexpr size_t min(size_t a,size_t b){ return a<b?a:b; } constexpr size_t max(size_t a,size_t b){ return a>b?a:b; } using ll = long long; using vll = std::vector<ll>; #define get(var_name) ll var_name{0}; cin >> var_name; #define readv(start,end,vec_name) std::vector<ll> vec_name(end); for(size_t i{start};i<end;i++) cin>>vec_name[i]; constexpr ll BIGLL{ std::numeric_limits<ll>::max() }; constexpr ll LL10{ 10000000000 + 1 }; bool check(vll cookie,vll ingred,ll k,ll num){ foralli(cookie){ ll delta = ingred[i] - cookie[i]*num; if(delta<0){ delta*=-1; if(delta<=k){ k -= delta; }else{ return false; } } } return true; } int main() { ios_base::sync_with_stdio(false); get(n); get(k); readv(0,n,cookie); readv(0,n,ingred); ll l{0},r{LL10}; while(l<=r){ ll m{(l+r)/2}; if(check(cookie,ingred,k,m)){ l = m + 1; }else{ r = m - 1; } } cout<<r<<endl; return 0; }
fjanisze/Problems
D2MagicPowder.cpp
C++
gpl-2.0
1,543
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CRAN - Package TurtleGraphics</title> <link rel="stylesheet" type="text/css" href="../../CRAN_web.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="citation_title" content="Turtle graphics in R [R package TurtleGraphics version 1.0-5]" /> <meta name="citation_author1" content="Anna Cena" /> <meta name="citation_author2" content="Marek Gagolewski" /> <meta name="citation_author3" content="Marcin Kosinski" /> <meta name="citation_author4" content="Natalia Potocka" /> <meta name="citation_author5" content="Barbara Zogala-Siudem" /> <meta name="citation_publication_date.Published" content="2016-12-05" /> <meta name="citation_public_url" content="https://CRAN.R-project.org/package=TurtleGraphics" /> <meta name="DC.identifier" content="https://CRAN.R-project.org/package=TurtleGraphics" /> <meta name="DC.publisher" content="Comprehensive R Archive Network (CRAN)" /> <style type="text/css"> table td { vertical-align: top; } </style> </head> <body> <h2>TurtleGraphics: Turtle graphics in R</h2> <p>An implementation of turtle graphics (<a href="http://en.wikipedia.org/wiki/Turtle_graphics">http://en.wikipedia.org/wiki/Turtle_graphics</a>) in R. Turtle graphics comes from Papert's language Logo and has been used to teach concepts of computer programming.</p> <table summary="Package TurtleGraphics summary"> <tr> <td>Version:</td> <td>1.0-5</td> </tr> <tr> <td>Depends:</td> <td>R (&ge; 3.0), grid</td> </tr> <tr> <td>Suggests:</td> <td><a href="../knitr/index.html">knitr</a></td> </tr> <tr> <td>Published:</td> <td>2016-12-05</td> </tr> <tr> <td>Author:</td> <td>Anna Cena [aut], Marek Gagolewski [aut], Marcin Kosinski [aut], Natalia Potocka [aut], Barbara Zogala-Siudem [aut, cre]</td> </tr> <tr> <td>Maintainer:</td> <td>Barbara Zogala-Siudem &#x3c;&#x7a;&#x6f;&#x67;&#x61;&#x6c;&#x61;&#x20;&#x61;&#x74;&#x20;&#x72;&#x65;&#x78;&#x61;&#x6d;&#x69;&#x6e;&#x65;&#x2e;&#x63;&#x6f;&#x6d;&#x3e;</td> </tr> <tr> <td>BugReports:</td> <td><a href="https://github.com/Rexamine/TurtleGraphics/issues">https://github.com/Rexamine/TurtleGraphics/issues</a></td> </tr> <tr> <td>License:</td> <td><a href="../../licenses/GPL-3">GPL (&ge; 3)</a></td> </tr> <tr> <td>URL:</td> <td><a href="http://TurtleGraphics.rexamine.com">http://TurtleGraphics.rexamine.com</a></td> </tr> <tr> <td>NeedsCompilation:</td> <td>no</td> </tr> <tr> <td>Materials:</td> <td><a href="NEWS">NEWS</a> </td> </tr> <tr> <td>CRAN&nbsp;checks:</td> <td><a href="../../checks/check_results_TurtleGraphics.html">TurtleGraphics results</a></td> </tr> </table> <h4>Downloads:</h4> <table summary="Package TurtleGraphics downloads"> <tr> <td> Reference&nbsp;manual: </td> <td> <a href="TurtleGraphics.pdf"> TurtleGraphics.pdf </a> </td> </tr> <tr> <td>Vignettes:</td> <td> <a href="vignettes/TurtleGraphics.pdf">A guide to the TurtleGraphics package</a><br/> </td> </tr> <tr> <td> Package&nbsp;source: </td> <td> <a href="../../../src/contrib/TurtleGraphics_1.0-5.tar.gz"> TurtleGraphics_1.0-5.tar.gz </a> </td> </tr> <tr> <td> Windows&nbsp;binaries: </td> <td> r-devel: <a href="../../../bin/windows/contrib/3.5/TurtleGraphics_1.0-5.zip">TurtleGraphics_1.0-5.zip</a>, r-release: <a href="../../../bin/windows/contrib/3.4/TurtleGraphics_1.0-5.zip">TurtleGraphics_1.0-5.zip</a>, r-oldrel: <a href="../../../bin/windows/contrib/3.3/TurtleGraphics_1.0-5.zip">TurtleGraphics_1.0-5.zip</a> </td> </tr> <tr> <td> OS&nbsp;X&nbsp;El&nbsp;Capitan&nbsp;binaries: </td> <td> r-release: <a href="../../../bin/macosx/el-capitan/contrib/3.4/TurtleGraphics_1.0-5.tgz">TurtleGraphics_1.0-5.tgz</a> </td> </tr> <tr> <td> OS&nbsp;X&nbsp;Mavericks&nbsp;binaries: </td> <td> r-oldrel: <a href="../../../bin/macosx/mavericks/contrib/3.3/TurtleGraphics_1.0-5.tgz">TurtleGraphics_1.0-5.tgz</a> </td> </tr> <tr> <td> Old&nbsp;sources: </td> <td> <a href="../../../src/contrib/Archive/TurtleGraphics"> TurtleGraphics archive </a> </td> </tr> </table> <h4>Linking:</h4> <p>Please use the canonical form <a href="https://CRAN.R-project.org/package=TurtleGraphics"><samp>https://CRAN.R-project.org/package=TurtleGraphics</samp></a> to link to this page.</p> </body> </html>
esander91/NamespacePollution
Code/GetMetaDataFromCRAN/raw_html/TurtleGraphics.html
HTML
gpl-2.0
4,341
#include "abstractrequest.h" #include <QJsonDocument> #pragma once class GetPlaylistRequest : public AbstractRequest { Q_OBJECT public: GetPlaylistRequest(const DataMessage &dataMessage, PlayerHandler *handler, QObject *parent = 0); bool canResponse() const; void execute(); };
Moergil/MultiBox
Server/message/getplaylistrequest.h
C
gpl-2.0
320
function fileQueueError(file, errorCode, message) { try { var imageName = "error.gif"; var errorName = ""; if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) { errorName = "You have attempted to queue too many files."; } if (errorName !== "") { alert(errorName); return; } switch (errorCode) { case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: imageName = "zerobyte.gif"; break; case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: imageName = "toobig.gif"; break; case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: default: alert(message); break; } addImage(images_filepath + imageName); } catch (ex) { this.debug(ex); } } function fileDialogComplete(numFilesSelected, numFilesQueued) { try { if (numFilesQueued > 0) { this.startUpload(); } } catch (ex) { this.debug(ex); } } function uploadProgress(file, bytesLoaded) { try { var percent = Math.ceil((bytesLoaded / file.size) * 100); var progress = new FileProgress(file, this.customSettings.upload_target); progress.setProgress(percent); if (percent === 100) { progress.setStatus("Creating thumbnail..."); progress.toggleCancel(false, this); } else { progress.setStatus("Uploading..."); progress.toggleCancel(true, this); } } catch (ex) { this.debug(ex); } } function uploadSuccess(file, serverData) { try { var progress = new FileProgress(file, this.customSettings.upload_target); if (serverData.substring(0, 7) === "FILEID:") { addImage(serverData.substring(7),serverData.substring(7)); progress.setStatus("Thumbnail Created."); progress.toggleCancel(false); } else { addImage(images_filepath+"error.gif"); progress.setStatus("Error."); progress.toggleCancel(false); alert(serverData); } } catch (ex) { this.debug(ex); } } function uploadComplete(file) { try { /* I want the next upload to continue automatically so I'll call startUpload here */ if (this.getStats().files_queued > 0) { this.startUpload(); } else { var progress = new FileProgress(file, this.customSettings.upload_target); progress.setComplete(); progress.setStatus("All images received."); progress.toggleCancel(false); } } catch (ex) { this.debug(ex); } } function uploadError(file, errorCode, message) { var imageName = "error.gif"; var progress; try { switch (errorCode) { case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: try { progress = new FileProgress(file, this.customSettings.upload_target); progress.setCancelled(); progress.setStatus("Cancelled"); progress.toggleCancel(false); } catch (ex1) { this.debug(ex1); } break; case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: try { progress = new FileProgress(file, this.customSettings.upload_target); progress.setCancelled(); progress.setStatus("Stopped"); progress.toggleCancel(true); } catch (ex2) { this.debug(ex2); } case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: imageName = "uploadlimit.gif"; break; default: alert(message); break; } addImage(images_filepath + imageName); } catch (ex3) { this.debug(ex3); } } function addImage(src,image_id) { var newImg = document.createElement("img"); newImg.setAttribute('id', image_id); newImg.style.margin = "5px"; newImg.style.width='110px'; newImg.style.height='130px'; var newDiv = document.createElement("div"); newDiv.setAttribute('id', 'div_'+image_id); newDiv.setAttribute('class', 'imageBox_label2'); document.getElementById("thumbnails").appendChild(newDiv); document.getElementById('div_'+image_id).appendChild(newImg); if (newImg.filters) { try { newImg.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0; } catch (e) { // If it is not set initially, the browser will throw an error. This will set it if it is not set yet. newImg.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 0 + ')'; } } else { newImg.style.opacity = 0; } newImg.onload = function () { fadeIn(newImg, 0); }; newImg.src = src; //create a tag div = document.getElementById('div_'+image_id); var newlink = document.createElement('a'); newlink.setAttribute('id', 'a_photo_'+image_id); newlink.setAttribute('href', 'javascript:void(0);'); newlink.setAttribute('onclick', 'javascript:removePhoto("","'+image_id+'")'); newlink.innerHTML = '<img src="'+img_delete+'" class="img_delete2" alt="" >'; div.appendChild(newlink); } function fadeIn(element, opacity) { var reduceOpacityBy = 5; var rate = 30; // 15 fps if (opacity < 100) { opacity += reduceOpacityBy; if (opacity > 100) { opacity = 100; } if (element.filters) { try { element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity; } catch (e) { // If it is not set initially, the browser will throw an error. This will set it if it is not set yet. element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')'; } } else { element.style.opacity = opacity / 100; } } if (opacity < 100) { setTimeout(function () { fadeIn(element, opacity); }, rate); } } /* ****************************************** * FileProgress Object * Control object for displaying file info * ****************************************** */ function FileProgress(file, targetID) { this.fileProgressID = "divFileProgress"; this.fileProgressWrapper = document.getElementById(this.fileProgressID); if (!this.fileProgressWrapper) { this.fileProgressWrapper = document.createElement("div"); this.fileProgressWrapper.className = "progressWrapper"; this.fileProgressWrapper.id = this.fileProgressID; this.fileProgressElement = document.createElement("div"); this.fileProgressElement.className = "progressContainer"; var progressCancel = document.createElement("a"); progressCancel.className = "progressCancel"; progressCancel.href = "#"; progressCancel.style.visibility = "hidden"; progressCancel.appendChild(document.createTextNode(" ")); var progressText = document.createElement("div"); progressText.className = "progressName"; progressText.appendChild(document.createTextNode(file.name)); var progressBar = document.createElement("div"); progressBar.className = "progressBarInProgress"; var progressStatus = document.createElement("div"); progressStatus.className = "progressBarStatus"; progressStatus.innerHTML = "&nbsp;"; this.fileProgressElement.appendChild(progressCancel); this.fileProgressElement.appendChild(progressText); this.fileProgressElement.appendChild(progressStatus); this.fileProgressElement.appendChild(progressBar); this.fileProgressWrapper.appendChild(this.fileProgressElement); document.getElementById(targetID).appendChild(this.fileProgressWrapper); fadeIn(this.fileProgressWrapper, 0); } else { this.fileProgressElement = this.fileProgressWrapper.firstChild; this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name; } this.height = this.fileProgressWrapper.offsetHeight; } FileProgress.prototype.setProgress = function (percentage) { this.fileProgressElement.className = "progressContainer green"; this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; this.fileProgressElement.childNodes[3].style.width = percentage + "%"; }; FileProgress.prototype.setComplete = function () { this.fileProgressElement.className = "progressContainer blue"; this.fileProgressElement.childNodes[3].className = "progressBarComplete"; this.fileProgressElement.childNodes[3].style.width = ""; }; FileProgress.prototype.setError = function () { this.fileProgressElement.className = "progressContainer red"; this.fileProgressElement.childNodes[3].className = "progressBarError"; this.fileProgressElement.childNodes[3].style.width = ""; }; FileProgress.prototype.setCancelled = function () { this.fileProgressElement.className = "progressContainer"; this.fileProgressElement.childNodes[3].className = "progressBarError"; this.fileProgressElement.childNodes[3].style.width = ""; }; FileProgress.prototype.setStatus = function (status) { this.fileProgressElement.childNodes[2].innerHTML = status; }; FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) { this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden"; if (swfuploadInstance) { var fileID = this.fileProgressID; this.fileProgressElement.childNodes[0].onclick = function () { swfuploadInstance.cancelUpload(fileID); return false; }; } };
vapvarun/MicrocerptBIZ
wp-content/plugins/PlusOnett/monetize/add_post/image_uploader/swfupload/handlers.js
JavaScript
gpl-2.0
8,928
#define XPM_WIDTH_CYAN10 20 #define XPM_HEIGHT_CYAN10 20 unsigned char Xpm_image_cyan10[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x00,0x79,0x79,0xff,0x00,0x80,0x80,0xff,0x00,0x85,0x85,0xff,0x00,0x89,0x89, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x70,0x70,0xff,0x00,0x7e,0x7e, 0xff,0x00,0x85,0x85,0xff,0x00,0x89,0x89,0xff,0x00,0x91,0x91,0xff,0x00,0x91,0x91, 0xff,0x00,0x94,0x94,0xff,0x00,0x94,0x94,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x00,0x61,0x61,0xff,0x00,0x70,0x70,0xff,0x00,0x79,0x79,0xff,0x00,0x85,0x85, 0xff,0x00,0x89,0x89,0xff,0x00,0x91,0x91,0xff,0x00,0x94,0x94,0xff,0x00,0x98,0x98, 0xff,0x00,0x9c,0x9c,0xff,0x00,0x9c,0x9c,0xff,0x00,0x9c,0x9c,0xff,0x00,0x98,0x98, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x5b,0x5b, 0xff,0x00,0x6a,0x6a,0xff,0x00,0x76,0x76,0xff,0x00,0x80,0x80,0xff,0x00,0x89,0x89, 0xff,0x00,0x8e,0x8e,0xff,0x00,0x94,0x94,0xff,0x00,0x98,0x98,0xff,0x00,0x9c,0x9c, 0xff,0x00,0x9c,0x9c,0xff,0x00,0xa2,0xa2,0xff,0x00,0xa2,0xa2,0xff,0x00,0x9c,0x9c, 0xff,0x00,0x9c,0x9c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x51,0x51,0xff,0x00,0x61,0x61, 0xff,0x00,0x6e,0x6e,0xff,0x00,0x79,0x79,0xff,0x00,0x80,0x80,0xff,0x00,0x89,0x89, 0xff,0x00,0x8e,0x8e,0xff,0x00,0x94,0x94,0xff,0x00,0x98,0x98,0xff,0x00,0x9c,0x9c, 0xff,0x00,0xa2,0xa2,0xff,0x00,0xa2,0xa2,0xff,0x00,0xa2,0xa2,0xff,0x00,0xa2,0xa2, 0xff,0x00,0x9c,0x9c,0xff,0x00,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x56,0x56,0xff,0x00,0x65,0x65, 0xff,0x00,0x70,0x70,0xff,0x00,0x79,0x79,0xff,0x00,0x80,0x80,0xff,0x00,0x89,0x89, 0xff,0x00,0x8e,0x8e,0xff,0x00,0x94,0x94,0xff,0x00,0x98,0x98,0xff,0x00,0x9c,0x9c, 0xff,0x00,0x9c,0x9c,0xff,0x00,0xa2,0xa2,0xff,0x00,0xa2,0xa2,0xff,0x00,0xa2,0xa2, 0xff,0x00,0xa2,0xa2,0xff,0x00,0x9c,0x9c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x46,0x46,0xff,0x00,0x5b,0x5b,0xff,0x00,0x65,0x65, 0xff,0x00,0x70,0x70,0xff,0x00,0x79,0x79,0xff,0x00,0x80,0x80,0xff,0x00,0x85,0x85, 0xff,0x00,0x8e,0x8e,0xff,0x00,0x91,0x91,0xff,0x00,0x94,0x94,0xff,0x00,0x98,0x98, 0xff,0x00,0x9c,0x9c,0xff,0x00,0x9c,0x9c,0xff,0x00,0x9c,0x9c,0xff,0x00,0xa2,0xa2, 0xff,0x00,0xa2,0xa2,0xff,0x00,0x9c,0x9c,0xff,0x00,0x94,0x94,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x46,0x46,0xff,0x00,0x56,0x56,0xff,0x00,0x65,0x65, 0xff,0x00,0x6e,0x6e,0xff,0x00,0x79,0x79,0xff,0x00,0x7e,0x7e,0xff,0x00,0x85,0x85, 0xff,0x00,0x89,0x89,0xff,0x00,0x8e,0x8e,0xff,0x00,0x91,0x91,0xff,0x00,0x98,0x98, 0xff,0x00,0x9c,0x9c,0xff,0x00,0x9c,0x9c,0xff,0x00,0x9c,0x9c,0xff,0x00,0xa2,0xa2, 0xff,0x00,0xa2,0xa2,0xff,0x00,0x9c,0x9c,0xff,0x00,0x94,0x94,0x00,0x00,0x00,0x00, 0xff,0x00,0x32,0x32,0xff,0x00,0x46,0x46,0xff,0x00,0x5b,0x5b,0xff,0x00,0x61,0x61, 0xff,0x00,0x6e,0x6e,0xff,0x00,0x76,0x76,0xff,0x00,0x7e,0x7e,0xff,0x00,0x80,0x80, 0xff,0x00,0x89,0x89,0xff,0x00,0x8e,0x8e,0xff,0x00,0x91,0x91,0xff,0x00,0x91,0x91, 0xff,0x00,0x94,0x94,0xff,0x00,0x98,0x98,0xff,0x00,0x9c,0x9c,0xff,0x00,0x9c,0x9c, 0xff,0x00,0x9c,0x9c,0xff,0x00,0x98,0x98,0xff,0x00,0x94,0x94,0xff,0x00,0x89,0x89, 0xff,0x00,0x32,0x32,0xff,0x00,0x46,0x46,0xff,0x00,0x51,0x51,0xff,0x00,0x61,0x61, 0xff,0x00,0x6a,0x6a,0xff,0x00,0x70,0x70,0xff,0x00,0x79,0x79,0xff,0x00,0x7e,0x7e, 0xff,0x00,0x85,0x85,0xff,0x00,0x85,0x85,0xff,0x00,0x8e,0x8e,0xff,0x00,0x8e,0x8e, 0xff,0x00,0x94,0x94,0xff,0x00,0x94,0x94,0xff,0x00,0x98,0x98,0xff,0x00,0x98,0x98, 0xff,0x00,0x98,0x98,0xff,0x00,0x94,0x94,0xff,0x00,0x91,0x91,0xff,0x00,0x89,0x89, 0xff,0x00,0x32,0x32,0xff,0x00,0x3c,0x3c,0xff,0x00,0x51,0x51,0xff,0x00,0x5b,0x5b, 0xff,0x00,0x65,0x65,0xff,0x00,0x6e,0x6e,0xff,0x00,0x76,0x76,0xff,0x00,0x79,0x79, 0xff,0x00,0x80,0x80,0xff,0x00,0x85,0x85,0xff,0x00,0x89,0x89,0xff,0x00,0x8e,0x8e, 0xff,0x00,0x8e,0x8e,0xff,0x00,0x91,0x91,0xff,0x00,0x94,0x94,0xff,0x00,0x94,0x94, 0xff,0x00,0x94,0x94,0xff,0x00,0x91,0x91,0xff,0x00,0x89,0x89,0xff,0x00,0x80,0x80, 0xff,0x00,0x2d,0x2d,0xff,0x00,0x3a,0x3a,0xff,0x00,0x4b,0x4b,0xff,0x00,0x5b,0x5b, 0xff,0x00,0x61,0x61,0xff,0x00,0x6a,0x6a,0xff,0x00,0x70,0x70,0xff,0x00,0x76,0x76, 0xff,0x00,0x79,0x79,0xff,0x00,0x80,0x80,0xff,0x00,0x85,0x85,0xff,0x00,0x89,0x89, 0xff,0x00,0x89,0x89,0xff,0x00,0x8e,0x8e,0xff,0x00,0x8e,0x8e,0xff,0x00,0x91,0x91, 0xff,0x00,0x8e,0x8e,0xff,0x00,0x8e,0x8e,0xff,0x00,0x85,0x85,0xff,0x00,0x7e,0x7e, 0x00,0x00,0x00,0x00,0xff,0x00,0x34,0x34,0xff,0x00,0x46,0x46,0xff,0x00,0x51,0x51, 0xff,0x00,0x5e,0x5e,0xff,0x00,0x61,0x61,0xff,0x00,0x6a,0x6a,0xff,0x00,0x70,0x70, 0xff,0x00,0x76,0x76,0xff,0x00,0x79,0x79,0xff,0x00,0x80,0x80,0xff,0x00,0x80,0x80, 0xff,0x00,0x85,0x85,0xff,0x00,0x89,0x89,0xff,0x00,0x89,0x89,0xff,0x00,0x89,0x89, 0xff,0x00,0x89,0x89,0xff,0x00,0x85,0x85,0xff,0x00,0x7e,0x7e,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x2d,0x2d,0xff,0x00,0x3c,0x3c,0xff,0x00,0x4b,0x4b, 0xff,0x00,0x56,0x56,0xff,0x00,0x5e,0x5e,0xff,0x00,0x65,0x65,0xff,0x00,0x6e,0x6e, 0xff,0x00,0x70,0x70,0xff,0x00,0x76,0x76,0xff,0x00,0x79,0x79,0xff,0x00,0x7e,0x7e, 0xff,0x00,0x80,0x80,0xff,0x00,0x80,0x80,0xff,0x00,0x80,0x80,0xff,0x00,0x80,0x80, 0xff,0x00,0x80,0x80,0xff,0x00,0x79,0x79,0xff,0x00,0x70,0x70,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x32,0x32,0xff,0x00,0x43,0x43, 0xff,0x00,0x4d,0x4d,0xff,0x00,0x56,0x56,0xff,0x00,0x5e,0x5e,0xff,0x00,0x65,0x65, 0xff,0x00,0x6a,0x6a,0xff,0x00,0x6e,0x6e,0xff,0x00,0x70,0x70,0xff,0x00,0x76,0x76, 0xff,0x00,0x79,0x79,0xff,0x00,0x79,0x79,0xff,0x00,0x7e,0x7e,0xff,0x00,0x79,0x79, 0xff,0x00,0x76,0x76,0xff,0x00,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x2a,0x2a,0xff,0x00,0x34,0x34, 0xff,0x00,0x43,0x43,0xff,0x00,0x4d,0x4d,0xff,0x00,0x56,0x56,0xff,0x00,0x5e,0x5e, 0xff,0x00,0x61,0x61,0xff,0x00,0x65,0x65,0xff,0x00,0x6a,0x6a,0xff,0x00,0x6e,0x6e, 0xff,0x00,0x70,0x70,0xff,0x00,0x70,0x70,0xff,0x00,0x70,0x70,0xff,0x00,0x70,0x70, 0xff,0x00,0x6e,0x6e,0xff,0x00,0x61,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x2a,0x2a, 0xff,0x00,0x34,0x34,0xff,0x00,0x43,0x43,0xff,0x00,0x4b,0x4b,0xff,0x00,0x51,0x51, 0xff,0x00,0x56,0x56,0xff,0x00,0x5e,0x5e,0xff,0x00,0x61,0x61,0xff,0x00,0x61,0x61, 0xff,0x00,0x65,0x65,0xff,0x00,0x65,0x65,0xff,0x00,0x65,0x65,0xff,0x00,0x61,0x61, 0xff,0x00,0x5e,0x5e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x00,0x2a,0x2a,0xff,0x00,0x32,0x32,0xff,0x00,0x3c,0x3c,0xff,0x00,0x46,0x46, 0xff,0x00,0x4b,0x4b,0xff,0x00,0x51,0x51,0xff,0x00,0x56,0x56,0xff,0x00,0x5b,0x5b, 0xff,0x00,0x5b,0x5b,0xff,0x00,0x5b,0x5b,0xff,0x00,0x56,0x56,0xff,0x00,0x51,0x51, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x2d,0x2d,0xff,0x00,0x34,0x34, 0xff,0x00,0x3a,0x3a,0xff,0x00,0x43,0x43,0xff,0x00,0x46,0x46,0xff,0x00,0x46,0x46, 0xff,0x00,0x46,0x46,0xff,0x00,0x46,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x00,0x2d,0x2d,0xff,0x00,0x2d,0x2d,0xff,0x00,0x32,0x32,0xff,0x00,0x34,0x34, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 } ; #define XPM_WIDTH_CYAN8 16 #define XPM_HEIGHT_CYAN8 16 unsigned char Xpm_image_cyan8[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x7b,0x7b,0xff,0x00,0x82,0x82, 0xff,0x00,0x89,0x89,0xff,0x00,0x89,0x89,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x00,0x6a,0x6a,0xff,0x00,0x7b,0x7b,0xff,0x00,0x82,0x82,0xff,0x00,0x8d,0x8d, 0xff,0x00,0x95,0x95,0xff,0x00,0x95,0x95,0xff,0x00,0x9a,0x9a,0xff,0x00,0x9a,0x9a, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x65,0x65, 0xff,0x00,0x76,0x76,0xff,0x00,0x82,0x82,0xff,0x00,0x89,0x89,0xff,0x00,0x90,0x90, 0xff,0x00,0x95,0x95,0xff,0x00,0x9d,0x9d,0xff,0x00,0x9d,0x9d,0xff,0x00,0xa0,0xa0, 0xff,0x00,0x9d,0x9d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x5a,0x5a,0xff,0x00,0x6d,0x6d, 0xff,0x00,0x7b,0x7b,0xff,0x00,0x84,0x84,0xff,0x00,0x8d,0x8d,0xff,0x00,0x95,0x95, 0xff,0x00,0x9a,0x9a,0xff,0x00,0x9d,0x9d,0xff,0x00,0xa0,0xa0,0xff,0x00,0xa0,0xa0, 0xff,0x00,0xa0,0xa0,0xff,0x00,0x9d,0x9d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x4c,0x4c,0xff,0x00,0x60,0x60,0xff,0x00,0x71,0x71, 0xff,0x00,0x7b,0x7b,0xff,0x00,0x84,0x84,0xff,0x00,0x8d,0x8d,0xff,0x00,0x90,0x90, 0xff,0x00,0x95,0x95,0xff,0x00,0x9d,0x9d,0xff,0x00,0xa0,0xa0,0xff,0x00,0xa0,0xa0, 0xff,0x00,0xa0,0xa0,0xff,0x00,0xa0,0xa0,0xff,0x00,0x9a,0x9a,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x4c,0x4c,0xff,0x00,0x60,0x60,0xff,0x00,0x6d,0x6d, 0xff,0x00,0x7b,0x7b,0xff,0x00,0x82,0x82,0xff,0x00,0x89,0x89,0xff,0x00,0x90,0x90, 0xff,0x00,0x95,0x95,0xff,0x00,0x9a,0x9a,0xff,0x00,0x9d,0x9d,0xff,0x00,0xa0,0xa0, 0xff,0x00,0xa0,0xa0,0xff,0x00,0xa0,0xa0,0xff,0x00,0x9a,0x9a,0x00,0x00,0x00,0x00, 0xff,0x00,0x3a,0x3a,0xff,0x00,0x4c,0x4c,0xff,0x00,0x60,0x60,0xff,0x00,0x6d,0x6d, 0xff,0x00,0x76,0x76,0xff,0x00,0x82,0x82,0xff,0x00,0x84,0x84,0xff,0x00,0x8d,0x8d, 0xff,0x00,0x90,0x90,0xff,0x00,0x9a,0x9a,0xff,0x00,0x9a,0x9a,0xff,0x00,0x9a,0x9a, 0xff,0x00,0x9d,0x9d,0xff,0x00,0x9a,0x9a,0xff,0x00,0x95,0x95,0xff,0x00,0x8d,0x8d, 0xff,0x00,0x36,0x36,0xff,0x00,0x4b,0x4b,0xff,0x00,0x5d,0x5d,0xff,0x00,0x6a,0x6a, 0xff,0x00,0x71,0x71,0xff,0x00,0x7c,0x7c,0xff,0x00,0x82,0x82,0xff,0x00,0x89,0x89, 0xff,0x00,0x8d,0x8d,0xff,0x00,0x90,0x90,0xff,0x00,0x95,0x95,0xff,0x00,0x9a,0x9a, 0xff,0x00,0x9a,0x9a,0xff,0x00,0x9a,0x9a,0xff,0x00,0x95,0x95,0xff,0x00,0x89,0x89, 0xff,0x00,0x32,0x32,0xff,0x00,0x46,0x46,0xff,0x00,0x5a,0x5a,0xff,0x00,0x65,0x65, 0xff,0x00,0x6d,0x6d,0xff,0x00,0x76,0x76,0xff,0x00,0x7c,0x7c,0xff,0x00,0x84,0x84, 0xff,0x00,0x89,0x89,0xff,0x00,0x8d,0x8d,0xff,0x00,0x90,0x90,0xff,0x00,0x90,0x90, 0xff,0x00,0x95,0x95,0xff,0x00,0x95,0x95,0xff,0x00,0x8d,0x8d,0xff,0x00,0x82,0x82, 0xff,0x00,0x2d,0x2d,0xff,0x00,0x3d,0x3d,0xff,0x00,0x52,0x52,0xff,0x00,0x5d,0x5d, 0xff,0x00,0x6a,0x6a,0xff,0x00,0x71,0x71,0xff,0x00,0x7b,0x7b,0xff,0x00,0x7c,0x7c, 0xff,0x00,0x82,0x82,0xff,0x00,0x89,0x89,0xff,0x00,0x89,0x89,0xff,0x00,0x8d,0x8d, 0xff,0x00,0x8d,0x8d,0xff,0x00,0x89,0x89,0xff,0x00,0x84,0x84,0xff,0x00,0x7c,0x7c, 0x00,0x00,0x00,0x00,0xff,0x00,0x36,0x36,0xff,0x00,0x4b,0x4b,0xff,0x00,0x57,0x57, 0xff,0x00,0x60,0x60,0xff,0x00,0x6a,0x6a,0xff,0x00,0x71,0x71,0xff,0x00,0x76,0x76, 0xff,0x00,0x7c,0x7c,0xff,0x00,0x7c,0x7c,0xff,0x00,0x84,0x84,0xff,0x00,0x84,0x84, 0xff,0x00,0x84,0x84,0xff,0x00,0x82,0x82,0xff,0x00,0x7b,0x7b,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x2d,0x2d,0xff,0x00,0x3d,0x3d,0xff,0x00,0x4c,0x4c, 0xff,0x00,0x5a,0x5a,0xff,0x00,0x60,0x60,0xff,0x00,0x6a,0x6a,0xff,0x00,0x6d,0x6d, 0xff,0x00,0x76,0x76,0xff,0x00,0x76,0x76,0xff,0x00,0x7b,0x7b,0xff,0x00,0x7c,0x7c, 0xff,0x00,0x7b,0x7b,0xff,0x00,0x76,0x76,0xff,0x00,0x6d,0x6d,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x32,0x32,0xff,0x00,0x3d,0x3d, 0xff,0x00,0x4c,0x4c,0xff,0x00,0x57,0x57,0xff,0x00,0x5d,0x5d,0xff,0x00,0x65,0x65, 0xff,0x00,0x6a,0x6a,0xff,0x00,0x6d,0x6d,0xff,0x00,0x71,0x71,0xff,0x00,0x71,0x71, 0xff,0x00,0x6d,0x6d,0xff,0x00,0x65,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x32,0x32, 0xff,0x00,0x3a,0x3a,0xff,0x00,0x4b,0x4b,0xff,0x00,0x52,0x52,0xff,0x00,0x5a,0x5a, 0xff,0x00,0x5d,0x5d,0xff,0x00,0x60,0x60,0xff,0x00,0x60,0x60,0xff,0x00,0x60,0x60, 0xff,0x00,0x5d,0x5d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x00,0x2d,0x2d,0xff,0x00,0x36,0x36,0xff,0x00,0x3d,0x3d,0xff,0x00,0x46,0x46, 0xff,0x00,0x4c,0x4c,0xff,0x00,0x4c,0x4c,0xff,0x00,0x4c,0x4c,0xff,0x00,0x4c,0x4c, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x32,0x32,0xff,0x00,0x32,0x32, 0xff,0x00,0x36,0x36,0xff,0x00,0x3d,0x3d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 } ; #define XPM_WIDTH_CYAN6 12 #define XPM_HEIGHT_CYAN6 12 unsigned char Xpm_image_cyan6[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x00,0x7b,0x7b,0xff,0x00,0x82,0x82,0xff,0x00,0x8d,0x8d,0xff,0x00,0x91,0x91, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x63,0x63,0xff,0x00,0x73,0x73, 0xff,0x00,0x82,0x82,0xff,0x00,0x8d,0x8d,0xff,0x00,0x96,0x96,0xff,0x00,0x9a,0x9a, 0xff,0x00,0x9e,0x9e,0xff,0x00,0x9a,0x9a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x56,0x56,0xff,0x00,0x66,0x66,0xff,0x00,0x7b,0x7b, 0xff,0x00,0x88,0x88,0xff,0x00,0x91,0x91,0xff,0x00,0x9a,0x9a,0xff,0x00,0x9e,0x9e, 0xff,0x00,0xa1,0xa1,0xff,0x00,0x9e,0x9e,0xff,0x00,0x9a,0x9a,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x56,0x56,0xff,0x00,0x6d,0x6d,0xff,0x00,0x7c,0x7c, 0xff,0x00,0x87,0x87,0xff,0x00,0x91,0x91,0xff,0x00,0x96,0x96,0xff,0x00,0x9e,0x9e, 0xff,0x00,0xa1,0xa1,0xff,0x00,0xa1,0xa1,0xff,0x00,0x9e,0x9e,0x00,0x00,0x00,0x00, 0xff,0x00,0x40,0x40,0xff,0x00,0x56,0x56,0xff,0x00,0x6d,0x6d,0xff,0x00,0x7b,0x7b, 0xff,0x00,0x87,0x87,0xff,0x00,0x8d,0x8d,0xff,0x00,0x96,0x96,0xff,0x00,0x9a,0x9a, 0xff,0x00,0x9e,0x9e,0xff,0x00,0x9e,0x9e,0xff,0x00,0x9a,0x9a,0xff,0x00,0x91,0x91, 0xff,0x00,0x3d,0x3d,0xff,0x00,0x56,0x56,0xff,0x00,0x66,0x66,0xff,0x00,0x76,0x76, 0xff,0x00,0x7c,0x7c,0xff,0x00,0x88,0x88,0xff,0x00,0x8d,0x8d,0xff,0x00,0x96,0x96, 0xff,0x00,0x9a,0x9a,0xff,0x00,0x9a,0x9a,0xff,0x00,0x96,0x96,0xff,0x00,0x8d,0x8d, 0xff,0x00,0x37,0x37,0xff,0x00,0x4e,0x4e,0xff,0x00,0x63,0x63,0xff,0x00,0x6d,0x6d, 0xff,0x00,0x7b,0x7b,0xff,0x00,0x82,0x82,0xff,0x00,0x88,0x88,0xff,0x00,0x8d,0x8d, 0xff,0x00,0x91,0x91,0xff,0x00,0x91,0x91,0xff,0x00,0x8d,0x8d,0xff,0x00,0x87,0x87, 0xff,0x00,0x30,0x30,0xff,0x00,0x40,0x40,0xff,0x00,0x59,0x59,0xff,0x00,0x66,0x66, 0xff,0x00,0x6d,0x6d,0xff,0x00,0x7b,0x7b,0xff,0x00,0x7c,0x7c,0xff,0x00,0x87,0x87, 0xff,0x00,0x87,0x87,0xff,0x00,0x88,0x88,0xff,0x00,0x82,0x82,0xff,0x00,0x7b,0x7b, 0x00,0x00,0x00,0x00,0xff,0x00,0x3a,0x3a,0xff,0x00,0x4c,0x4c,0xff,0x00,0x59,0x59, 0xff,0x00,0x66,0x66,0xff,0x00,0x73,0x73,0xff,0x00,0x76,0x76,0xff,0x00,0x7b,0x7b, 0xff,0x00,0x7c,0x7c,0xff,0x00,0x7b,0x7b,0xff,0x00,0x76,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x2d,0x2d,0xff,0x00,0x3a,0x3a,0xff,0x00,0x4e,0x4e, 0xff,0x00,0x59,0x59,0xff,0x00,0x63,0x63,0xff,0x00,0x66,0x66,0xff,0x00,0x6d,0x6d, 0xff,0x00,0x6d,0x6d,0xff,0x00,0x69,0x69,0xff,0x00,0x66,0x66,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x2d,0x2d,0xff,0x00,0x37,0x37, 0xff,0x00,0x44,0x44,0xff,0x00,0x4e,0x4e,0xff,0x00,0x56,0x56,0xff,0x00,0x59,0x59, 0xff,0x00,0x56,0x56,0xff,0x00,0x56,0x56,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x00,0x2d,0x2d,0xff,0x00,0x37,0x37,0xff,0x00,0x3d,0x3d,0xff,0x00,0x40,0x40, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 } ; #define XPM_WIDTH_CYAN4 8 #define XPM_HEIGHT_CYAN4 8 unsigned char Xpm_image_cyan4[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x74,0x74,0xff,0x00,0x87,0x87, 0xff,0x00,0x8e,0x8e,0xff,0x00,0x97,0x97,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0x00,0x65,0x65,0xff,0x00,0x7f,0x7f,0xff,0x00,0x8e,0x8e, 0xff,0x00,0x99,0x99,0xff,0x00,0x9f,0x9f,0xff,0x00,0x9f,0x9f,0x00,0x00,0x00,0x00, 0xff,0x00,0x4c,0x4c,0xff,0x00,0x65,0x65,0xff,0x00,0x7f,0x7f,0xff,0x00,0x8e,0x8e, 0xff,0x00,0x99,0x99,0xff,0x00,0xa0,0xa0,0xff,0x00,0x9f,0x9f,0xff,0x00,0x97,0x97, 0xff,0x00,0x47,0x47,0xff,0x00,0x64,0x64,0xff,0x00,0x79,0x79,0xff,0x00,0x87,0x87, 0xff,0x00,0x92,0x92,0xff,0x00,0x99,0x99,0xff,0x00,0x99,0x99,0xff,0x00,0x92,0x92, 0xff,0x00,0x3e,0x3e,0xff,0x00,0x5a,0x5a,0xff,0x00,0x6f,0x6f,0xff,0x00,0x79,0x79, 0xff,0x00,0x88,0x88,0xff,0x00,0x8e,0x8e,0xff,0x00,0x8e,0x8e,0xff,0x00,0x87,0x87, 0xff,0x00,0x33,0x33,0xff,0x00,0x47,0x47,0xff,0x00,0x64,0x64,0xff,0x00,0x74,0x74, 0xff,0x00,0x79,0x79,0xff,0x00,0x7f,0x7f,0xff,0x00,0x7f,0x7f,0xff,0x00,0x75,0x75, 0x00,0x00,0x00,0x00,0xff,0x00,0x36,0x36,0xff,0x00,0x49,0x49,0xff,0x00,0x5a,0x5a, 0xff,0x00,0x65,0x65,0xff,0x00,0x65,0x65,0xff,0x00,0x65,0x65,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x33,0x33,0xff,0x00,0x3e,0x3e, 0xff,0x00,0x49,0x49,0xff,0x00,0x4c,0x4c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 } ;
cyamauch/eggx
src/examples_academic/simulations-20110310/cyan.h
C
gpl-2.0
17,933
/** * Copyright (C) 2012-2016 52°North Initiative for Geospatial Open Source * Software GmbH * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 2 as publishedby the Free * Software Foundation. * * If the program is linked with libraries which are licensed under one of the * following licenses, the combination of the program with the linked library is * not considered a "derivative work" of the program: * * - Apache License, version 2.0 * - Apache Software License, version 1.0 * - GNU Lesser General Public License, version 3 * - Mozilla Public License, versions 1.0, 1.1 and 2.0 * - Common Development and Distribution License (CDDL), version 1.0 * * Therefore the distribution of the program linked with libraries licensed under * the aforementioned licenses, is permitted by the copyright holders if the * distribution is compliant with both the GNU General Public License version 2 * and the aforementioned licenses. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package org.n52.server.da.oxf; import org.n52.oxf.sos.adapter.ISOSRequestBuilder; import org.n52.oxf.sos.adapter.SOSRequestBuilderFactory; import org.n52.oxf.sos.util.SosUtil; public class SosRequestBuilderFactory { public static ISOSRequestBuilder createRequestBuilder(String serviceVersion) { if (SosUtil.isVersion100(serviceVersion)) { return new SOSRequestBuilder_100_OXFExtension(); } else if (SosUtil.isVersion200(serviceVersion)) { return new SOSRequestBuilder_200_OXFExtension(); } else { return SOSRequestBuilderFactory.generateRequestBuilder(serviceVersion); } } }
ridoo/SensorWebClient
sensorwebclient-api/src/main/java/org/n52/server/da/oxf/SosRequestBuilderFactory.java
Java
gpl-2.0
1,956
<?php /* define package */ define('PKG_NAME', 'VoteForms'); define('PKG_NAME_LOWER', strtolower(PKG_NAME)); define('PKG_VERSION', '2.0.5'); define('PKG_RELEASE', 'beta'); define('PKG_AUTO_INSTALL', true); /* define paths */ if (isset($_SERVER['MODX_BASE_PATH'])) { define('MODX_BASE_PATH', $_SERVER['MODX_BASE_PATH']); } elseif (file_exists(dirname(dirname(dirname(__FILE__))) . '/core')) { define('MODX_BASE_PATH', dirname(dirname(dirname(__FILE__))) . '/'); } else { define('MODX_BASE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/'); } define('MODX_CORE_PATH', MODX_BASE_PATH . 'core/'); define('MODX_MANAGER_PATH', MODX_BASE_PATH . 'manager/'); define('MODX_CONNECTORS_PATH', MODX_BASE_PATH . 'connectors/'); define('MODX_ASSETS_PATH', MODX_BASE_PATH . 'assets/'); /* define urls */ define('MODX_BASE_URL', '/'); define('MODX_CORE_URL', MODX_BASE_URL . 'core/'); define('MODX_MANAGER_URL', MODX_BASE_URL . 'manager/'); define('MODX_CONNECTORS_URL', MODX_BASE_URL . 'connectors/'); define('MODX_ASSETS_URL', MODX_BASE_URL . 'assets/'); /* define build options */ define('BUILD_MENU_UPDATE', true); define('BUILD_ACTION_UPDATE', true); define('BUILD_SETTING_UPDATE', true); define('BUILD_CHUNK_UPDATE', true); define('BUILD_SNIPPET_UPDATE', true); define('BUILD_PLUGIN_UPDATE', true); //define('BUILD_EVENT_UPDATE', true); //define('BUILD_POLICY_UPDATE', true); //define('BUILD_POLICY_TEMPLATE_UPDATE', true); //define('BUILD_PERMISSION_UPDATE', true); if (!empty($_GET['development'])) { define('PKG_NAMESPACE_PATH', '{base_path}' . PKG_NAME . '/core/components/' . PKG_NAME_LOWER . '/'); define('PKG_CORE_PATH', MODX_BASE_PATH . PKG_NAME . '/core/components/' . PKG_NAME_LOWER . '/'); define('PKG_STATIC_PATH', PKG_NAME . '/core/components/' . PKG_NAME_LOWER); define('PKG_ASSETS_URL', '/' . PKG_NAME .'/assets/components/' . PKG_NAME_LOWER . '/'); define('BUILD_CHUNK_STATIC', true); define('BUILD_SNIPPET_STATIC', true); define('BUILD_PLUGIN_STATIC', true); } else { define('PKG_NAMESPACE_PATH', '{core_path}components/' . PKG_NAME_LOWER . '/'); define('PKG_CORE_PATH', '{core_path}components/' . PKG_NAME_LOWER . '/'); define('PKG_STATIC_PATH', 'core/components/' . PKG_NAME_LOWER); define('PKG_ASSETS_URL', '{assets_url}components/' . PKG_NAME_LOWER . '/'); define('BUILD_CHUNK_STATIC', false); define('BUILD_SNIPPET_STATIC', false); define('BUILD_PLUGIN_STATIC', false); } $BUILD_RESOLVERS = array( 'tables', 'chunks', 'setup', );
me6iaton/VoteForms
_build/build.config.php
PHP
gpl-2.0
2,496
# No bug for the moment, want to raise libtool issue in general. EAPI="5" source "${PORTDIR}/${CATEGORY}/${PN}/${BASH_SOURCE[0]##*/}" EAPI="5" inherit libtool eval " src_prepare() { $(function_body src_prepare) elibtoolize # Fool make to use g-ir-scanner from PATH. touch gtk/g-ir-scanner || die }"
chewi/cross-boss
overlay/x11-libs/gtk+/ebuild:3.sh
Shell
gpl-2.0
307
# Telepítés a Debian Linux rendszerre ## Debian 11.0 Futtassa a következő shell parancsokat, hogy megbízhasson az adattárban. ```bash wget http://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_11/Release.key -O - | sudo apt-key add - ``` Futtassa a következő shell parancsokat az adattár hozzáadásához és a QOwnNotes telepítéséhez onnan. ```bash sudo bash -c "echo 'deb http://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_11/ /' >> /etc/apt/sources.list.d/qownnotes.list" sudo apt-get update sudo apt-get install qownnotes ``` ::: tip Ha ezt az adattárat más Debian Linux verziókhoz használja, ellenőrizze, hogy **Qt** telepítve van-e legalább az **5.11 verzió**-ja. ::: [Közvetlen letöltés](https://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_11) ## Debian 10.0 Futtassa a következő shell parancsokat, hogy megbízhasson az adattárban. ```bash wget http://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_10/Release.key -O - | sudo apt-key add - ``` Futtassa a következő shell parancsokat az adattár hozzáadásához és a QOwnNotes telepítéséhez onnan. ```bash sudo bash -c "echo 'deb http://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_10/ /' >> /etc/apt/sources.list.d/qownnotes.list" sudo apt-get update sudo apt-get install qownnotes ``` ::: tip Ha ezt az adattárat más Debian Linux verziókhoz használja, ellenőrizze, hogy **Qt** telepítve van-e legalább az **5.8 verzió**-ja. ::: [Közvetlen letöltés](https://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_10) ## Debian 9.0 Futtassa a következő shell parancsokat, hogy megbízhasson az adattárban. ```bash wget http://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_9.0/Release.key -O - | sudo apt-key add - ``` Futtassa a következő shell parancsokat az adattár hozzáadásához és a QOwnNotes telepítéséhez onnan. ```bash sudo bash -c "echo 'deb http://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_9.0/ /' >> /etc/apt/sources.list.d/qownnotes.list" sudo apt-get update sudo apt-get install qownnotes ``` ::: tip Ha ezt az adattárat más Debian Linux verziókhoz használja, győződjön meg arról, hogy **Qt** telepítve van-e legalább az **5.5 verzióra**. ::: [Közvetlen letöltés](https://download.opensuse.org/repositories/home:/pbek:/QOwnNotes/Debian_9.0)
pbek/QOwnNotes
webpage/src/hu/installation/debian.md
Markdown
gpl-2.0
2,444
// // ID Engine // ID_IN.c - Input Manager // v1.0d1 // By Jason Blochowiak // // // This module handles dealing with the various input devices // // Depends on: Memory Mgr (for demo recording), Sound Mgr (for timing stuff), // User Mgr (for command line parms) // // Globals: // LastScan - The keyboard scan code of the last key pressed // LastASCII - The ASCII value of the last key pressed // DEBUG - there are more globals // #include "wl_def.h" void IN_GetJoyDelta(int *dx,int *dy) { (void)dx; (void)dy; } /* ============================================================================= GLOBAL VARIABLES ============================================================================= */ #ifdef USE_SDL // // configuration variables // boolean MousePresent; boolean forcegrabmouse; // Global variables volatile boolean Keyboard[SDLK_LAST]; volatile boolean Paused; volatile char LastASCII; volatile ScanCode LastScan; //KeyboardDef KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51}; static KeyboardDef KbdDefs = { sc_Control, // button0 sc_Alt, // button1 sc_Home, // upleft sc_UpArrow, // up sc_PgUp, // upright sc_LeftArrow, // left sc_RightArrow, // right sc_End, // downleft sc_DownArrow, // down sc_PgDn // downright }; static SDL_Joystick *Joystick; int JoyNumButtons; static int JoyNumHats; static bool GrabInput = false; /* ============================================================================= LOCAL VARIABLES ============================================================================= */ byte ASCIINames[] = // Unshifted ASCII for scan codes // TODO: keypad { // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,8 ,9 ,0 ,0 ,0 ,13 ,0 ,0 , // 0 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,27 ,0 ,0 ,0 , // 1 ' ',0 ,0 ,0 ,0 ,0 ,0 ,39 ,0 ,0 ,'*','+',',','-','.','/', // 2 '0','1','2','3','4','5','6','7','8','9',0 ,';',0 ,'=',0 ,0 , // 3 '`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o', // 4 'p','q','r','s','t','u','v','w','x','y','z','[',92 ,']',0 ,0 , // 5 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 }; byte ShiftNames[] = // Shifted ASCII for scan codes { // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,8 ,9 ,0 ,0 ,0 ,13 ,0 ,0 , // 0 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,27 ,0 ,0 ,0 , // 1 ' ',0 ,0 ,0 ,0 ,0 ,0 ,34 ,0 ,0 ,'*','+','<','_','>','?', // 2 ')','!','@','#','$','%','^','&','*','(',0 ,':',0 ,'+',0 ,0 , // 3 '~','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O', // 4 'P','Q','R','S','T','U','V','W','X','Y','Z','{','|','}',0 ,0 , // 5 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 }; byte SpecialNames[] = // ASCII for 0xe0 prefixed codes { // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2 0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 }; static boolean IN_Started; static Direction DirTable[] = // Quick lookup for total direction { dir_NorthWest, dir_North, dir_NorthEast, dir_West, dir_None, dir_East, dir_SouthWest, dir_South, dir_SouthEast }; /////////////////////////////////////////////////////////////////////////// // // INL_GetMouseButtons() - Gets the status of the mouse buttons from the // mouse driver // /////////////////////////////////////////////////////////////////////////// static int INL_GetMouseButtons(void) { int buttons = SDL_GetMouseState(NULL, NULL); int middlePressed = buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE); int rightPressed = buttons & SDL_BUTTON(SDL_BUTTON_RIGHT); buttons &= ~(SDL_BUTTON(SDL_BUTTON_MIDDLE) | SDL_BUTTON(SDL_BUTTON_RIGHT)); if(middlePressed) buttons |= 1 << 2; if(rightPressed) buttons |= 1 << 1; return buttons; } /////////////////////////////////////////////////////////////////////////// // // IN_GetJoyDelta() - Returns the relative movement of the specified // joystick (from +/-127) // /////////////////////////////////////////////////////////////////////////// void IN_GetJoyDelta(int *dx,int *dy) { if(!Joystick) { *dx = *dy = 0; return; } SDL_JoystickUpdate(); #ifdef _arch_dreamcast int x = 0; int y = 0; #else int x = SDL_JoystickGetAxis(Joystick, 0) >> 8; int y = SDL_JoystickGetAxis(Joystick, 1) >> 8; #endif if(param_joystickhat != -1) { uint8_t hatState = SDL_JoystickGetHat(Joystick, param_joystickhat); if(hatState & SDL_HAT_RIGHT) x += 127; else if(hatState & SDL_HAT_LEFT) x -= 127; if(hatState & SDL_HAT_DOWN) y += 127; else if(hatState & SDL_HAT_UP) y -= 127; if(x < -128) x = -128; else if(x > 127) x = 127; if(y < -128) y = -128; else if(y > 127) y = 127; } *dx = x; *dy = y; } /////////////////////////////////////////////////////////////////////////// // // IN_GetJoyFineDelta() - Returns the relative movement of the specified // joystick without dividing the results by 256 (from +/-127) // /////////////////////////////////////////////////////////////////////////// void IN_GetJoyFineDelta(int *dx, int *dy) { if(!Joystick) { *dx = 0; *dy = 0; return; } SDL_JoystickUpdate(); int x = SDL_JoystickGetAxis(Joystick, 0); int y = SDL_JoystickGetAxis(Joystick, 1); if(x < -128) x = -128; else if(x > 127) x = 127; if(y < -128) y = -128; else if(y > 127) y = 127; *dx = x; *dy = y; } /* =================== = = IN_JoyButtons = =================== */ int IN_JoyButtons() { if(!Joystick) return 0; SDL_JoystickUpdate(); int res = 0; for(int i = 0; i < JoyNumButtons && i < 32; i++) res |= SDL_JoystickGetButton(Joystick, i) << i; return res; } boolean IN_JoyPresent() { return Joystick != NULL; } static void processEvent(SDL_Event *event) { switch (event->type) { // exit if the window is closed case SDL_QUIT: Quit(NULL); // check for keypresses case SDL_KEYDOWN: { if(event->key.keysym.sym==SDLK_SCROLLOCK || event->key.keysym.sym==SDLK_F12) { GrabInput = !GrabInput; SDL_WM_GrabInput(GrabInput ? SDL_GRAB_ON : SDL_GRAB_OFF); return; } LastScan = event->key.keysym.sym; SDLMod mod = SDL_GetModState(); if(Keyboard[sc_Alt]) { if(LastScan==SDLK_F4) Quit(NULL); } if(LastScan == SDLK_KP_ENTER) LastScan = SDLK_RETURN; else if(LastScan == SDLK_RSHIFT) LastScan = SDLK_LSHIFT; else if(LastScan == SDLK_RALT) LastScan = SDLK_LALT; else if(LastScan == SDLK_RCTRL) LastScan = SDLK_LCTRL; else { if((mod & KMOD_NUM) == 0) { switch(LastScan) { case SDLK_KP2: LastScan = SDLK_DOWN; break; case SDLK_KP4: LastScan = SDLK_LEFT; break; case SDLK_KP6: LastScan = SDLK_RIGHT; break; case SDLK_KP8: LastScan = SDLK_UP; break; } } } int sym = LastScan; if(sym >= 'a' && sym <= 'z') sym -= 32; // convert to uppercase if(mod & (KMOD_SHIFT | KMOD_CAPS)) { if(sym < lengthof(ShiftNames) && ShiftNames[sym]) LastASCII = ShiftNames[sym]; } else { if(sym < lengthof(ASCIINames) && ASCIINames[sym]) LastASCII = ASCIINames[sym]; } if(LastScan<SDLK_LAST) Keyboard[LastScan] = 1; if(LastScan == SDLK_PAUSE) Paused = true; break; } case SDL_KEYUP: { int key = event->key.keysym.sym; if(key == SDLK_KP_ENTER) key = SDLK_RETURN; else if(key == SDLK_RSHIFT) key = SDLK_LSHIFT; else if(key == SDLK_RALT) key = SDLK_LALT; else if(key == SDLK_RCTRL) key = SDLK_LCTRL; else { if((SDL_GetModState() & KMOD_NUM) == 0) { switch(key) { case SDLK_KP2: key = SDLK_DOWN; break; case SDLK_KP4: key = SDLK_LEFT; break; case SDLK_KP6: key = SDLK_RIGHT; break; case SDLK_KP8: key = SDLK_UP; break; } } } if(key<SDLK_LAST) Keyboard[key] = 0; break; } #if defined(GP2X) case SDL_JOYBUTTONDOWN: GP2X_ButtonDown(event->jbutton.button); break; case SDL_JOYBUTTONUP: GP2X_ButtonUp(event->jbutton.button); break; #endif } } void IN_WaitAndProcessEvents() { SDL_Event event; if(!SDL_WaitEvent(&event)) return; do { processEvent(&event); } while(SDL_PollEvent(&event)); } void IN_ProcessEvents() { SDL_Event event; while (SDL_PollEvent(&event)) { processEvent(&event); } } /////////////////////////////////////////////////////////////////////////// // // IN_Startup() - Starts up the Input Mgr // /////////////////////////////////////////////////////////////////////////// void IN_Startup(void) { if (IN_Started) return; IN_ClearKeysDown(); if(param_joystickindex >= 0 && param_joystickindex < SDL_NumJoysticks()) { Joystick = SDL_JoystickOpen(param_joystickindex); if(Joystick) { JoyNumButtons = SDL_JoystickNumButtons(Joystick); if(JoyNumButtons > 32) JoyNumButtons = 32; // only up to 32 buttons are supported JoyNumHats = SDL_JoystickNumHats(Joystick); if(param_joystickhat < -1 || param_joystickhat >= JoyNumHats) Quit("The joystickhat param must be between 0 and %i!", JoyNumHats - 1); } } SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); if(fullscreen || forcegrabmouse) { GrabInput = true; SDL_WM_GrabInput(SDL_GRAB_ON); } // I didn't find a way to ask libSDL whether a mouse is present, yet... #if defined(GP2X) MousePresent = false; #elif defined(_arch_dreamcast) MousePresent = DC_MousePresent(); #else MousePresent = true; #endif IN_Started = true; } /////////////////////////////////////////////////////////////////////////// // // IN_Shutdown() - Shuts down the Input Mgr // /////////////////////////////////////////////////////////////////////////// void IN_Shutdown(void) { if (!IN_Started) return; if(Joystick) SDL_JoystickClose(Joystick); IN_Started = false; } /////////////////////////////////////////////////////////////////////////// // // IN_ClearKeysDown() - Clears the keyboard array // /////////////////////////////////////////////////////////////////////////// void IN_ClearKeysDown(void) { LastScan = sc_None; LastASCII = key_None; memset ((void *) Keyboard,0,sizeof(Keyboard)); } /////////////////////////////////////////////////////////////////////////// // // IN_ReadControl() - Reads the device associated with the specified // player and fills in the control info struct // /////////////////////////////////////////////////////////////////////////// void IN_ReadControl(int player,ControlInfo *info) { word buttons; int dx,dy; Motion mx,my; dx = dy = 0; mx = my = motion_None; buttons = 0; IN_ProcessEvents(); if (Keyboard[KbdDefs.upleft]) mx = motion_Left,my = motion_Up; else if (Keyboard[KbdDefs.upright]) mx = motion_Right,my = motion_Up; else if (Keyboard[KbdDefs.downleft]) mx = motion_Left,my = motion_Down; else if (Keyboard[KbdDefs.downright]) mx = motion_Right,my = motion_Down; if (Keyboard[KbdDefs.up]) my = motion_Up; else if (Keyboard[KbdDefs.down]) my = motion_Down; if (Keyboard[KbdDefs.left]) mx = motion_Left; else if (Keyboard[KbdDefs.right]) mx = motion_Right; if (Keyboard[KbdDefs.button0]) buttons += 1 << 0; if (Keyboard[KbdDefs.button1]) buttons += 1 << 1; dx = mx * 127; dy = my * 127; info->x = dx; info->xaxis = mx; info->y = dy; info->yaxis = my; info->button0 = (buttons & (1 << 0)) != 0; info->button1 = (buttons & (1 << 1)) != 0; info->button2 = (buttons & (1 << 2)) != 0; info->button3 = (buttons & (1 << 3)) != 0; info->dir = DirTable[((my + 1) * 3) + (mx + 1)]; } /////////////////////////////////////////////////////////////////////////// // // IN_WaitForKey() - Waits for a scan code, then clears LastScan and // returns the scan code // /////////////////////////////////////////////////////////////////////////// ScanCode IN_WaitForKey(void) { ScanCode result; while ((result = LastScan)==0) IN_WaitAndProcessEvents(); LastScan = 0; return(result); } /////////////////////////////////////////////////////////////////////////// // // IN_WaitForASCII() - Waits for an ASCII char, then clears LastASCII and // returns the ASCII value // /////////////////////////////////////////////////////////////////////////// char IN_WaitForASCII(void) { char result; while ((result = LastASCII)==0) IN_WaitAndProcessEvents(); LastASCII = '\0'; return(result); } /////////////////////////////////////////////////////////////////////////// // // IN_Ack() - waits for a button or key press. If a button is down, upon // calling, it must be released for it to be recognized // /////////////////////////////////////////////////////////////////////////// boolean btnstate[NUMBUTTONS]; void IN_StartAck(void) { IN_ProcessEvents(); // // get initial state of everything // IN_ClearKeysDown(); memset(btnstate, 0, sizeof(btnstate)); int buttons = IN_JoyButtons() << 4; if(MousePresent) buttons |= IN_MouseButtons(); for(int i = 0; i < NUMBUTTONS; i++, buttons >>= 1) if(buttons & 1) btnstate[i] = true; } boolean IN_CheckAck (void) { IN_ProcessEvents(); // // see if something has been pressed // if(LastScan) return true; int buttons = IN_JoyButtons() << 4; if(MousePresent) buttons |= IN_MouseButtons(); for(int i = 0; i < NUMBUTTONS; i++, buttons >>= 1) { if(buttons & 1) { if(!btnstate[i]) { // Wait until button has been released do { IN_WaitAndProcessEvents(); buttons = IN_JoyButtons() << 4; if(MousePresent) buttons |= IN_MouseButtons(); } while(buttons & (1 << i)); return true; } } else btnstate[i] = false; } return false; } void IN_Ack (void) { IN_StartAck (); do { IN_WaitAndProcessEvents(); } while(!IN_CheckAck ()); } /////////////////////////////////////////////////////////////////////////// // // IN_UserInput() - Waits for the specified delay time (in ticks) or the // user pressing a key or a mouse button. If the clear flag is set, it // then either clears the key or waits for the user to let the mouse // button up. // /////////////////////////////////////////////////////////////////////////// boolean IN_UserInput(longword delay) { longword lasttime; lasttime = GetTimeCount(); IN_StartAck (); do { IN_ProcessEvents(); if (IN_CheckAck()) return true; DelayMS(5); } while (GetTimeCount() - lasttime < delay); return(false); } //=========================================================================== /* =================== = = IN_MouseButtons = =================== */ int IN_MouseButtons (void) { if (MousePresent) return INL_GetMouseButtons(); else return 0; } bool IN_IsInputGrabbed() { return GrabInput; } void IN_CenterMouse() { SDL_WarpMouse(screenWidth / 2, screenHeight / 2); } #endif
WarlockD/crispy-doom
stm32/wolf3d/id_in.cpp
C++
gpl-2.0
17,126
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>KTimeZone.Phase</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link rel="stylesheet" type="text/css" href="../common/doxygen.css" /> <link rel="stylesheet" media="screen" type="text/css" title="KDE Colors" href="../common/kde.css" /> </head> <body> <div id="container"> <div id="header"> <div id="header_top"> <div> <div> <img alt ="" src="../common/top-kde.jpg"/> KDE 4.9 PyKDE API Reference </div> </div> </div> <div id="header_bottom"> <div id="location"> <ul> <li>KDE's Python API</li> </ul> </div> <div id="menu"> <ul> <li><a href="../modules.html">Overview</a></li> <li><a href="http://techbase.kde.org/Development/Languages/Python">PyKDE Home</a></li> <li><a href="http://kde.org/family/">Sitemap</a></li> <li><a href="http://kde.org/contact/">Contact Us</a></li> </ul> </div> </div> </div> <div id="body_wrapper"> <div id="body"> <div id="right"> <div class="content"> <div id="main"> <div class="clearer">&nbsp;</div> <h1>Phase Class Reference</h1> <code>from PyKDE4.kdecore import *</code> <p> Namespace: <a href="../kdecore/KTimeZone.html">KTimeZone</a><br /> <h2>Detailed Description</h2> <table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><br><h2>Methods</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#Phase">__init__</a> (self)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#Phase">__init__</a> (self, int utcOffset, QByteArray abbreviations, bool dst, QString comment=QString())</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#Phase">__init__</a> (self, int utcOffset, [QByteArray] abbreviations, bool dst, QString comment=QString())</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#Phase">__init__</a> (self, <a href="../kdecore/KTimeZone.Phase.html">KTimeZone.Phase</a> rhs)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">[QByteArray]&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#abbreviations">abbreviations</a> (self)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">QString&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#comment">comment</a> (self)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#isDst">isDst</a> (self)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#operator !=">operator !=</a> (self, <a href="../kdecore/KTimeZone.Phase.html">KTimeZone.Phase</a> rhs)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#operator ==">operator ==</a> (self, <a href="../kdecore/KTimeZone.Phase.html">KTimeZone.Phase</a> rhs)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#utcOffset">utcOffset</a> (self)</td></tr> </table> <hr><h2>Method Documentation</h2><a class="anchor" name="Phase"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">__init__</td> <td>(</td> <td class="paramtype">&nbsp;</td> <td class="paramname"><em>self</em>&nbsp;)</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Default constructor. Creates a standard-time time zone phase with UTC offset 0. </p></div></div><a class="anchor" name="Phase"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">__init__</td> <td>(</td> <td class="paramtype">&nbsp;<em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype">int&nbsp;</td> <td class="paramname"><em>utcOffset</em>, </td> </tr> <tr> <td class="memname"></td> <td></td> <td class="paramtype">QByteArray&nbsp;</td> <td class="paramname"><em>abbreviations</em>, </td> </tr> <tr> <td class="memname"></td> <td></td> <td class="paramtype">bool&nbsp;</td> <td class="paramname"><em>dst</em>, </td> </tr> <tr> <td class="memname"></td> <td></td> <td class="paramtype">QString&nbsp;</td> <td class="paramname"><em>comment=QString()</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Constructor. </p> <p> </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>utcOffset</em>&nbsp;</td><td> number of seconds to add to UTC to get local time in this phase <tr><td></td><td valign="top"><em>abbreviations</em>&nbsp;</td><td> time zone abbreviation for this phase, plus any translations <tr><td></td><td valign="top"><em>dst</em>&nbsp;</td><td> true if daylight savings time, false if standard time <tr><td></td><td valign="top"><em>comment</em>&nbsp;</td><td> optional comment </td></tr> </table></dl> <p> </p></div></div><a class="anchor" name="Phase"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">__init__</td> <td>(</td> <td class="paramtype">&nbsp;<em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype">int&nbsp;</td> <td class="paramname"><em>utcOffset</em>, </td> </tr> <tr> <td class="memname"></td> <td></td> <td class="paramtype">[QByteArray]&nbsp;</td> <td class="paramname"><em>abbreviations</em>, </td> </tr> <tr> <td class="memname"></td> <td></td> <td class="paramtype">bool&nbsp;</td> <td class="paramname"><em>dst</em>, </td> </tr> <tr> <td class="memname"></td> <td></td> <td class="paramtype">QString&nbsp;</td> <td class="paramname"><em>comment=QString()</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Constructor. </p> <p> </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>utcOffset</em>&nbsp;</td><td> number of seconds to add to UTC to get local time in this phase <tr><td></td><td valign="top"><em>abbreviations</em>&nbsp;</td><td> time zone abbreviation for this phase, plus any translations <tr><td></td><td valign="top"><em>dst</em>&nbsp;</td><td> true if daylight savings time, false if standard time <tr><td></td><td valign="top"><em>comment</em>&nbsp;</td><td> optional comment </td></tr> </table></dl> <p> </p></div></div><a class="anchor" name="Phase"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">__init__</td> <td>(</td> <td class="paramtype">&nbsp;<em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="../kdecore/KTimeZone.Phase.html">KTimeZone.Phase</a>&nbsp;</td> <td class="paramname"><em>rhs</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"></div></div><a class="anchor" name="abbreviations"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">[QByteArray] abbreviations</td> <td>(</td> <td class="paramtype">&nbsp;</td> <td class="paramname"><em>self</em>&nbsp;)</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Return the time zone abbreviations which apply to this phase. </p> <p> More than one abbreviation may be returned, to allow for possible translations. </p> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> time zone abbreviations </dd></dl> </p></div></div><a class="anchor" name="comment"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">QString comment</td> <td>(</td> <td class="paramtype">&nbsp;</td> <td class="paramname"><em>self</em>&nbsp;)</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Return the comment (if any) applying to this phase. </p> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> comment </dd></dl> </p></div></div><a class="anchor" name="isDst"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">bool isDst</td> <td>(</td> <td class="paramtype">&nbsp;</td> <td class="paramname"><em>self</em>&nbsp;)</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Return whether daylight savings time applies during this phase. </p> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> true if daylight savings are in operation, false otherwise </dd></dl> </p></div></div><a class="anchor" name="operator !="></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">bool operator !=</td> <td>(</td> <td class="paramtype">&nbsp;<em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="../kdecore/KTimeZone.Phase.html">KTimeZone.Phase</a>&nbsp;</td> <td class="paramname"><em>rhs</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"></div></div><a class="anchor" name="operator =="></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">bool operator ==</td> <td>(</td> <td class="paramtype">&nbsp;<em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="../kdecore/KTimeZone.Phase.html">KTimeZone.Phase</a>&nbsp;</td> <td class="paramname"><em>rhs</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"></div></div><a class="anchor" name="utcOffset"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">int utcOffset</td> <td>(</td> <td class="paramtype">&nbsp;</td> <td class="paramname"><em>self</em>&nbsp;)</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Return the UTC offset in seconds during this phase. The UTC offset is the number of seconds which you must add to UTC to get local time. </p> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> offset in seconds to add to UTC </dd></dl> </p></div></div> </div> </div> </div> <div id="left"> <div class="menu_box"> <div class="nav_list"> <ul> <li><a href="../allclasses.html">Full Index</a></li> </ul> </div> <a name="cp-menu" /><div class="menutitle"><div> <h2 id="cp-menu-project">Modules</h2> </div></div> <div class="nav_list"> <ul><li><a href="../akonadi/index.html">akonadi</a></li> <li><a href="../dnssd/index.html">dnssd</a></li> <li><a href="../kdecore/index.html">kdecore</a></li> <li><a href="../kdeui/index.html">kdeui</a></li> <li><a href="../khtml/index.html">khtml</a></li> <li><a href="../kio/index.html">kio</a></li> <li><a href="../knewstuff/index.html">knewstuff</a></li> <li><a href="../kparts/index.html">kparts</a></li> <li><a href="../kutils/index.html">kutils</a></li> <li><a href="../nepomuk/index.html">nepomuk</a></li> <li><a href="../phonon/index.html">phonon</a></li> <li><a href="../plasma/index.html">plasma</a></li> <li><a href="../polkitqt/index.html">polkitqt</a></li> <li><a href="../solid/index.html">solid</a></li> <li><a href="../soprano/index.html">soprano</a></li> </ul></div></div> </div> </div> <div class="clearer"/> </div> <div id="end_body"></div> </div> <div id="footer"><div id="footer_text"> This documentation is maintained by <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;simon&#64;simonzone&#46;com">Simon Edwards</a>.<br /> KDE<sup>&#174;</sup> and <a href="../images/kde_gear_black.png">the K Desktop Environment<sup>&#174;</sup> logo</a> are registered trademarks of <a href="http://ev.kde.org/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div></div> </body> </html>
KDE/pykde4
docs/html/kdecore/KTimeZone.Phase.html
HTML
gpl-2.0
12,761
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="/benchmark/js/jquery.min.js"></script> <script type="text/javascript" src="/benchmark/js/js.cookie.js"></script> <title>BenchmarkTest02033</title> </head> <body> <form action="/benchmark/pathtraver-02/BenchmarkTest02033" method="POST" id="FormBenchmarkTest02033"> <div><label>Please explain your answer:</label></div> <br/> <div><textarea rows="4" cols="50" id="BenchmarkTest02033Area" name="BenchmarkTest02033Area"></textarea></div> <div><label>Any additional note for the reviewer:</label></div> <div><input type="text" id="answer" name="answer"></input></div> <br/> <div><label>An AJAX request will be sent with a header named BenchmarkTest02033 and value:</label> <input type="text" id="BenchmarkTest02033" name="BenchmarkTest02033" value="FileName" class="safe"></input></div> <div><input type="button" id="login-btn" value="Login" onclick="submitForm()" /></div> </form> <div id="ajax-form-msg1"><pre><code class="prettyprint" id="code"></code></pre></div> <script> $('.safe').keypress(function (e) { if (e.which == 13) { submitForm(); return false; } }); function submitForm() { var formData = $("#FormBenchmarkTest02033").serialize(); var URL = $("#FormBenchmarkTest02033").attr("action"); var text = $("#FormBenchmarkTest02033 input[id=BenchmarkTest02033]").val(); var xhr = new XMLHttpRequest(); xhr.open("POST", URL, true); xhr.setRequestHeader('BenchmarkTest02033', text ); xhr.onreadystatechange = function () { if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { $("#code").html(xhr.responseText); } else { $("#code").html("Error " + xhr.status + " occurred."); } } xhr.send(formData); } function escapeRegExp(str) { return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); } function replaceAll(str, find, replace) { return str.replace(new RegExp(escapeRegExp(find), 'g'), replace); } String.prototype.decodeEscapeSequence = function() { var txt = replaceAll(this,";",""); txt = replaceAll(txt,"&#","\\"); return txt.replace(/\\x([0-9A-Fa-f]{2})/g, function() { return String.fromCharCode(parseInt(arguments[1], 16)); }); }; </script> </body> </html>
h3xstream/Benchmark
src/main/webapp/pathtraver-02/BenchmarkTest02033.html
HTML
gpl-2.0
2,439
<div class="mcl-login-form-login"> <h2><?php echo ($instance_id == "my_columbia_llm") ? "My Columbia LL.M." : "My Columbia Law and Admitted Student" ?></h2> <h3>Security Question Update</h3> <div <?php echo (isset($_SESSION['messages']['status'][0])) ? "class='status-msg'" : "" ?> > <?php echo (isset($_SESSION['messages']['status'][0])) ? $_SESSION['messages']['status'][0] : "" ?> </div> <div <?php echo (isset($_SESSION['messages']['error'][0])) ? "class='error-msg'" : "" ?> > <?php echo (isset($_SESSION['messages']['error'][0])) ? $_SESSION['messages']['error'][0] : "" ?> </div> <?php echo drupal_render($form); ?> <p class="back-to-login"> <a id="back-to-login-link" href="<?php echo base_path() ?>admissions/jd/my-columbia-law">Back to Login Page</a> </p> </div> <style type="text/css"> body div.messages {display: none;} .menu-mlid-4476 a {color:#333333;} div.mcl-login-form-login label { font-weight: bold; font-size: 13px; color: #333333; } div.mcl-login-form-login div#edit-actions { margin-bottom: 0 !important; margin-top: 15px !important; } div.mcl-login-form-login label span.form-required { display: none; } div.error-msg { background-color: #FEF5F1; color: #8C2E0B; border: 1px solid #ED541D; background-image: url("/misc/message-24-error.png"); background-position: 8px 8px; background-repeat: no-repeat; margin: 6px 0; padding: 10px 10px 10px 50px; font-size: 13px; } div.status-msg { background-color: #F8FFF0; color: #234600; border: 1px solid #BBEE77; background-image: url("/misc/message-24-ok.png"); background-position: 8px 8px; background-repeat: no-repeat; margin: 6px 0; padding: 10px 10px 10px 50px; font-size: 13px; } div.mcl-login-form-login input#edit-submit { border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px; background-color: #333333; border: 2px solid #999999; color: #FFFFFF; font: 15px Verdana, Arial, sans-serif; padding: 3px 15px 5px; margin-bottom: 15px; margin-top: 10px; } div.mcl-login-form-login input#edit-submit:active { background-color: #186E9E; color: #FFFFFF; } div.mcl-login-form-login select#edit-security-question-select { width: 345px; font: 12px/10px Verdana,Arial,Helvetica,sans-serif; margin: 10px 0 15px; } div.mcl-login-form-login select#edit-security-question-select, div.mcl-login-form-login input#edit-security-question-other, div.mcl-login-form-login input#edit-security-answer { background-color: #FFFFFF; border: 2px solid #999999; color: #666666; display: block; height: 25px; padding: 1px 10px 3px; } div.mcl-login-form-login input#edit-security-question-other, div.mcl-login-form-login input#edit-security-answer { border-radius:15px; -moz-border-radius:15px; -webkit-border-radius:15px; font: 21px/18px Verdana,Arial,Helvetica,sans-serif; width: 321px; margin: 10px 0; } div.mcl-login-form-login select#edit-security-question-select:focus, div.mcl-login-form-login input#edit-security-question-other:focus, div.mcl-login-form-login input#edit-security-answer { border: #186E9E 2px solid; } p#mcl-security-answer { font-size: 13px; margin-top: 10px; } body div#cls-mcl-account-errors { background-image: none; margin: 0 0 20px; } body div#cls-mcl-account-errors label { width: auto; float: none; color: #cc0000; } body div#cls-mcl-account-errors li { margin: 0 0 5px 15px; color: #cc0000; } div#cls-mcl-account-errors:after { clear: both; content: " "; display: block; font-size: 0; height: 0; line-height: 0; visibility: hidden; width: 0; } </style>
nexttee/culaw
sites/default/modules/cls_mcl/templates/security_question_update.tpl.php
PHP
gpl-2.0
3,687
$Rev: 916 $
boudewijnrempt/HyvesDesktop
3rdparty/socorro/webapp-php/application/views/common/version.php
PHP
gpl-2.0
13
package utility; public class IdConst extends Ident { //Valeur de la constante private int valeur; //Initialisation d'une IdConst (nom, type et valeur) public IdConst(String _name, int _type, int _valeur) { super(_name, _type); //constructeur de Ident this.valeur = _valeur; } public int getValeur() {return this.valeur;} public void setValeur(int _v) {this.valeur = _v;} //Verificateur de type public boolean isConst() {return true;} }
william-insa/Projet_compilateur
Compilateur/src/utility/IdConst.java
Java
gpl-2.0
455
--[[ Copyright (C) 2017-2019 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ]] local asserts = require 'testing.asserts' local test_runner = require 'testing.test_runner' local Room = require 'map_generators.keys_doors.room' local tests = {} function tests.testCreateAndConnectTwoRooms() local room1 = Room.new{ id = 1, grid = {1, 1}, } asserts.EQ(room1.id, 1) local gridi, gridj = room1:gridPosition() asserts.EQ(gridi, 1) asserts.EQ(gridj, 1) local room2 = Room.new{ id = 2, grid = {1, 2}, entryRoom = room1, entryDoorColor = 'red', } asserts.EQ(room2.id, 2) gridi, gridj = room2:gridPosition() asserts.EQ(gridi, 1) asserts.EQ(gridj, 2) asserts.EQ(room1:connectedRoom(1, 2), room2) asserts.EQ(room1:connectedDoor(1, 2), 'red') end function tests.testAddObject() local room = Room.new{ id = 1, grid = {1, 1}, } asserts.EQ(room:addObject('key'), true) asserts.EQ(room:addObject('key'), true) asserts.EQ(room:addObject('key'), false) end --[[ The final map after drawing 5 rooms should be like: ``` ************* ***** ***** ***** ***** ******H****** * Ip I * * * k* * ****** ****** ***** ***** ***** ***** ************* ``` The position of 'p' and 'k' may change within the center room because of the randomness. ]] function tests.testDrawFiveRooms() local rooms = {} rooms[1] = Room.new{ id = 1, grid = {2, 2}, } rooms[1]:addObject('key') rooms[1]:addPlayerSpawn() rooms[2] = Room.new{ id = 2, grid = {1, 2}, entryRoom = rooms[1], entryDoorColor = 'red', } rooms[3] = Room.new{ id = 3, grid = {2, 1}, entryRoom = rooms[1], entryDoorColor = 'green', } rooms[4] = Room.new{ id = 4, grid = {2, 3}, entryRoom = rooms[1], entryDoorColor = 'blue', } rooms[5] = Room.new{ id = 2, grid = {3, 2}, entryRoom = rooms[1], } local code = { wall = '*', emptyFloor = ' ', spawn = 'p', key = 'k', redHorizDoor = 'H', greenHorizDoor = 'H', blueHorizDoor = 'H', redVertDoor = 'I', greenVertDoor = 'I', blueVertDoor = 'I', } local map = {} for i = 1, 10 do map[i] = {} for j = 1, 13 do map[i][j] = code.wall end end for i = 1, 5 do local gridi, gridj = rooms[i]:gridPosition() rooms[i]:draw(map, gridi * 3 - 1, gridj * 4 - 2, code) end -- Check room 1 object assert(map[6][6] == code.key or map[6][8] == code.key) -- Check room 1 player local positions = {{5, 6}, {5, 7}, {5, 8}, {6, 7}} local playerCount = 0 for _, position in ipairs(positions) do if map[position[1]][position[2]] == code.spawn then playerCount = playerCount + 1 end end asserts.EQ(playerCount, 1) -- Check doors asserts.EQ(map[4][7], 'H') asserts.EQ(map[5][5], 'I') asserts.EQ(map[5][9], 'I') -- This door has no color so it will be drawn as empty space. asserts.EQ(map[7][7], ' ') -- Check empty spaces and walls local count = {} count[code.wall] = 0 count[code.emptyFloor] = 0 for i = 1, 10 do for j = 1, 13 do if map[i][j] == code.wall or map[i][j] == code.emptyFloor then count[map[i][j]] = count[map[i][j]] + 1 end end end asserts.EQ(count[code.wall], 96) asserts.EQ(count[code.emptyFloor], 29) end return test_runner.run(tests)
deepmind/lab
lua_tests/keys_doors_room_test.lua
Lua
gpl-2.0
4,042
/* Controller.h This file is part of Charm, a task-based time tracking application. Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com Author: Mirko Boehm <mirko.boehm@kdab.com> Author: Olivier JG <olivier.de.gaalon@kdab.com> Author: Frank Osterfeld <frank.osterfeld@kdab.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef CONTROLLER_H #define CONTROLLER_H #include <QObject> #include "Task.h" #include "Event.h" #include "ControllerInterface.h" class StorageInterface; class Controller : public QObject, public ControllerInterface { Q_OBJECT public: explicit Controller( QObject* parent = nullptr ); ~Controller(); void stateChanged( State previous, State next ) override; void persistMetaData( Configuration& ) override; void provideMetaData( Configuration& ) override; bool initializeBackEnd( const QString& name ) override; bool connectToBackend() override; bool disconnectFromBackend() override; StorageInterface* storage() override; // FIXME add the add/modify/delete functions will not be slots anymore Event makeEvent( const Task& ) override; Event cloneEvent( const Event& ) override; bool modifyEvent( const Event& ) override; bool deleteEvent( const Event& ) override; bool addTask( const Task& parent ) override; bool modifyTask( const Task& ) override; bool deleteTask( const Task& ) override; bool setAllTasks( const TaskList& ) override; QDomDocument exportDatabasetoXml() const override; QString importDatabaseFromXml( const QDomDocument& ) override; void updateModelEventsAndTasks(); public slots: void executeCommand( CharmCommand* ) override; void rollbackCommand ( CharmCommand* ) override; signals: void eventAdded( const Event& event ) override; void eventModified( const Event& event ) override; void eventDeleted( const Event& event ) override; void allEvents( const EventList& ); void definedTasks( const TaskList& ) override; void taskAdded( const Task& ) override; void taskUpdated( const Task& ) override; void taskDeleted( const Task& ) override; void readyToQuit() override; void currentBackendStatus( const QString& text ); void commandCompleted( CharmCommand* ) override; private: void updateSubscriptionForTask( const Task& ); template<class T> void loadConfigValue( const QString &key, T &configValue ) const; StorageInterface* m_storage; }; #endif
sengels/Charm
Core/Controller.h
C
gpl-2.0
3,125
/********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ***********************************************************************/ #ifndef WC_COMMON_WORKLIST_H #define WC_COMMON_WORKLIST_H #include "shared.hh" /* MAX_LEN_NAME */ #define MAX_LEN_WORKLIST 16 #define MAX_NUM_WORKLISTS 16 /* worklist element flags */ enum worklist_elem_flag { WEF_END, /* element is past end of list */ WEF_UNIT, /* element specifies a unit to be built */ WEF_IMPR, /* element specifies an improvement to be built */ WEF_LAST /* leave this last */ }; /* a worklist */ struct worklist { bool is_valid; char name[MAX_LEN_NAME]; enum worklist_elem_flag wlefs[MAX_LEN_WORKLIST]; int wlids[MAX_LEN_WORKLIST]; }; void init_worklist(struct worklist *pwl); int worklist_length(const struct worklist *pwl); bool worklist_is_empty(const struct worklist *pwl); bool worklist_peek(const struct worklist *pwl, int *id, bool *is_unit); bool worklist_peek_ith(const struct worklist *pwl, int *id, bool *is_unit, int idx); void worklist_advance(struct worklist *pwl); void copy_worklist(struct worklist *dst, const struct worklist *src); void worklist_remove(struct worklist *pwl, int idx); bool worklist_append(struct worklist *pwl, int id, bool is_unit); bool worklist_insert(struct worklist *pwl, int id, bool is_unit, int idx); bool are_worklists_equal(const struct worklist *wlist1, const struct worklist *wlist2); #endif /* WC_COMMON_WORKLIST_H */
seggil/warciv
common/worklist.hh
C++
gpl-2.0
2,086