getPgmTag()

return the XML string that specifies a program's name,
including potential library, function, and attributes.

@param $pgm
@param $lib
@param $function
@return string
971806
protected function getPgmTag($pgm, $lib, $function)
    {
        // specify opm mode if given
        $opmString = ($this->getOption('v5r4')) ? " mode='opm'" : "";
        
        // get encoded pgm/lib/func names
        $propArray = array();
        $this->processParamProps($propArray);
        
        // if directed to use hex/CCSID, specify "long form" of program tag, with nested name/lib/func tags.
        // If not using hex/CCSID, use "short form" of program tag.
        // Why allow both? For backward compatibility with older (pre-1.6.8) XMLSERVICE that didn't support long form.
        
        if ($propArray['hexStr']) {
        
            // Hex/CCSID, so use long form of pgm tag
            
            // specify function if given
            $encodedFunction = $this->encodeString($function);
            $funcString = ($function) ? " <func{$propArray['ccsidStr']}{$propArray['hexStr']}>$encodedFunction</func>" : "";
            
            //    $pgmtag = "<pgm name='$pgm' lib='$lib'$opmString$funcString>";
            //  split pgm, name, lib into separate lines to can give separate encodings.
            $pgmtag = "<pgm$opmString>
            <name{$propArray['ccsidStr']}{$propArray['hexStr']}>" . $this->encodeString($pgm) . "</name>
            <lib{$propArray['ccsidStr']}{$propArray['hexStr']}>" . $this->encodeString($lib) . "</lib>
            $funcString";
        } else {
            // no hex/CCSID, so use short form of pgm tag
            // (For backward compability with pre-1.6.8 XMLSERVICE)
            $funcString = ($function) ? " func='$function'" : "";
            $pgmtag = "<pgm name='" . $pgm . "' lib='" . $lib . "' " . $opmString . $funcString . ">";
        }
        
        return $pgmtag;
    }
597824
public static function getCached($function)
    {
        $returnValue = null;

        
		$args = func_get_args();
		array_shift($args);
        if (!is_string($function)){
            $r = new ReflectionFunction($function);
            $serial = md5(
              $r->getFileName().
              $r->getStartLine().
              serialize($args)
            );
        } else {
            $serial = md5($function.serialize($args));
        }
        if (static::singleton()->has($serial)) {
        	$returnValue = static::singleton()->has($serial);
        } else { 
	        $returnValue = call_user_func_array($fn, $args);
	        static::singleton()->put($serial, $returnValue);
        }
        

        return $returnValue;
    }
768201
def get_function(pkgpath):
    
    # Extract the module and function name from pkgpath
    elems = pkgpath.split('.')
    if len(elems) <= 1:
        raise PyMacaronCoreException("Path %s is too short. Should be at least module.func." % elems)
    func_name = elems[-1]
    func_module = '.'.join(elems[0:-1])

    # Load the function's module and get the function
    try:
        m = import_module(func_module)
        f = getattr(m, func_name)
        return f
    except Exception as e:
        t = traceback.format_exc()
        raise PyMacaronCoreException("Failed to import %s: %s\nTrace:\n%s" % (pkgpath, str(e), t))
1042152
public static function static_function($plugin, $function) {
        global $CFG;

        //check that the plugin exists
        $typedirectory = $CFG->dirroot . '/repository/'. $plugin . '/lib.php';
        if (!file_exists($typedirectory)) {
            //throw new repository_exception('invalidplugin', 'repository');
            return false;
        }

        $args = func_get_args();
        if (count($args) <= 2) {
            $args = array();
        } else {
            array_shift($args);
            array_shift($args);
        }

        require_once($typedirectory);
        return call_user_func_array(array('repository_' . $plugin, $function), $args);
    }
45466
public function GenerateArgInfo(
        \Peg\Lib\Definitions\Element\FunctionElement $function_object
    )
    {
        $namespace_name = $function_object->namespace->name;

        if($namespace_name == "\\")
            $namespace_name = "";

        $namespace_name_cpp = str_replace(
            "\\",
            "::",
            $namespace_name
        );

        $namespace_name_var = str_replace(
            "\\",
            "_",
            $namespace_name
        );

        $arginfo_code = "";

        $function_name = $function_object->name;

        // Get the amount of required parameters from the
        // overload which require less.
        $required_parameters = 1000;

        foreach($function_object->overloads as $overload=>$overload_object)
        {
            if($required_parameters > $overload_object->GetRequiredParametersCount())
                $required_parameters = $overload_object->GetRequiredParametersCount();
        }

        // Generate a list of argument objects from the overload
        // with the longest amount of parameters.
        $arguments_list = array();
        foreach($function_object->overloads as $overload=>$overload_object)
        {
            if($overload_object->HasParameters())
            {
                if(count($arguments_list) < count($overload_object->parameters))
                {
                    $index = 0;

                    foreach($overload_object->parameters as $parameter_object)
                    {
                        $arguments_list[$index] = $parameter_object;

                        $index++;
                    }
                }
            }
        }

        // Get Header
        ob_start();
            include($this->GetTemplatePath(
                $function_name,
                "arginfo",
                "header",
                "helpers",
                "arginfo",
                $namespace_name
            ));
            $arginfo_code .= ob_get_contents();
        ob_end_clean();

        foreach($arguments_list as $parameter_object)
        {
            $parameter_name = $parameter_object->name;

            // Generate the entry of arguments
            ob_start();
                include($this->GetParameterTemplate($parameter_object, "", "arginfo"));
                $arginfo_code .= $this->Indent(ob_get_contents(), 4);
            ob_end_clean();
        }

        // Get Header
        ob_start();
            include($this->GetTemplatePath(
                $function_name,
                "arginfo",
                "footer",
                "helpers",
                "arginfo",
                $namespace_name
            ));
            $arginfo_code .= ob_get_contents();
        ob_end_clean();

        return $arginfo_code;
    }
6226
private static function getDestinationFunction(string $imgExtension = null): ?string
    {
        switch ($imgExtension) {
            case 'jpg':
            case 'jpeg':
                $dst['function'] = 'imagejpeg';
                break;
            case 'png':
                $dst['function'] = 'imagepng';
                break;
            case 'gif':
                $dst['function'] = 'imagegif';
                break;
            default:
                $dst['function'] = null;
                break;
        }
        return $dst['function'];
    }
190804
def _library_from_nglims(gi, sample_info, config):
    
    names = [config.get(x, "").strip() for x in ["lab_association", "researcher"]
             if config.get(x)]
    for name in names:
        for ext in ["sequencing", "lab"]:
            check_name = "%s %s" % (name.split()[0], ext)
            try:
                return _get_library_from_name(gi, check_name, None, sample_info)
            except ValueError:
                pass
    check_names = set([x.lower() for x in names])
    for libname, role in config["private_libs"]:
        # Try to find library for lab or rsearcher
        if libname.lower() in check_names:
            return _get_library_from_name(gi, libname, role, sample_info)
    # default to first private library if available
    if len(config.get("private_libs", [])) > 0:
        libname, role = config["private_libs"][0]
        return _get_library_from_name(gi, libname, role, sample_info)
    # otherwise use the lab association or researcher name
    elif len(names) > 0:
        return _get_library_from_name(gi, names[0], None, sample_info, create=True)
    else:
        raise ValueError("Could not find Galaxy library for sample %s" % sample_info["description"])
841613
public static function getStrWord(&$p, $l = false)
    {
        $r = static::binarySubstr($p, 0, 2);
        $p = static::binarySubstr($p, 2);
        if ($l) {
            $r = strrev($r);
        }
        return $r;
    }
477188
function parse_PtgRef(blob, length, opts) {
	var ptg = blob[blob.l] & 0x1F;
	var type = (blob[blob.l] & 0x60)>>5;
	blob.l += 1;
	var loc = parse_RgceLoc(blob, 0, opts);
	return [type, loc];
}
956898
function parse_PtgName(blob, length, opts) {
	var type = (blob.read_shift(1) >>> 5) & 0x03;
	var w = (!opts || (opts.biff >= 8)) ? 4 : 2;
	var nameindex = blob.read_shift(w);
	switch(opts.biff) {
		case 2: blob.l += 5; break;
		case 3: case 4: blob.l += 8; break;
		case 5: blob.l += 12; break;
	}
	return [type, 0, nameindex];
}
526940
function execute($m, $params=null, $paramtypes=null, $msgID=null)
		{
			if (is_object($m))
			{
				// watch out: if $m is an xmlrpcmsg obj, this will raise a warning: no id memeber...
				$methName = $m->method();
				$msgID = $m->id;
			}
			else
			{
				$methName = $m;
			}
			$sysCall = $this->allow_system_funcs && strpos($methName, "system.") === 0;
			$dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap;

			if(!isset($dmap[$methName]['function']))
			{
				// No such method
				return new jsonrpcresp(0,
					$GLOBALS['xmlrpcerr']['unknown_method'],
					$GLOBALS['xmlrpcstr']['unknown_method']);
			}

			// Check signature
			if(isset($dmap[$methName]['signature']))
			{
				$sig = $dmap[$methName]['signature'];
				if (is_object($m))
				{
					list($ok, $errstr) = $this->verifySignature($m, $sig);
				}
				else
				{
					list($ok, $errstr) = $this->verifySignature($paramtypes, $sig);
				}
				if(!$ok)
				{
					// Didn't match.
					return new jsonrpcresp(
						0,
						$GLOBALS['xmlrpcerr']['incorrect_params'],
						$GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}"
					);
				}
			}

			$func = $dmap[$methName]['function'];
			// let the 'class::function' syntax be accepted in dispatch maps
			if(is_string($func) && strpos($func, '::'))
			{
				$func = explode('::', $func);
			}
			// verify that function to be invoked is in fact callable
			if(!is_callable($func))
			{
				error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler is not callable");
				return new jsonrpcresp(
					0,
					$GLOBALS['xmlrpcerr']['server_error'],
					$GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method"
				);
			}

			// If debug level is 3, we should catch all errors generated during
			// processing of user function, and log them as part of response
			if($this->debug > 2)
			{
				$GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler');
			}
			try
			{
				if (is_object($m))
				{
					if($sysCall)
					{
						$r = call_user_func($func, $this, $m);
					}
					else
					{
						$r = call_user_func($func, $m);
					}
					if (!is_a($r, 'xmlrpcresp'))
					{
						error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler does not return an xmlrpcresp object");
						if (is_a($r, 'xmlrpcval'))
						{
							$r = new jsonrpcresp($r);
						}
						else
						{
							$r = new jsonrpcresp(
								0,
								$GLOBALS['xmlrpcerr']['server_error'],
								$GLOBALS['xmlrpcstr']['server_error'] . ": function does not return jsonrpcresp or xmlrpcresp object"
							);
						}
					}
				}
				else
				{
					// call a 'plain php' function
					if($sysCall)
					{
						array_unshift($params, $this);
						$r = call_user_func_array($func,$params);
					}
					else
					{
						// 3rd API convention for method-handling functions: EPI-style
						if ($this->functions_parameters_type == 'epivals')
						{
							$r = call_user_func_array($func, array($methName, $params, $this->user_data));
							// mimic EPI behaviour: if we get an array that looks like an error, make it
							// an eror response
							if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r))
							{
								$r = new jsonrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']);
							}
							else
							{
								// functions using EPI api should NOT return resp objects,
								// so make sure we encode the return type correctly
								$r = new jsonrpcresp(php_xmlrpc_encode($r, array('extension_api')));
							}
						}
						else
						{
							$r = call_user_func_array($func, $params);
						}
					}
					// the return type can be either an xmlrpcresp object or a plain php value...
					if (!is_a($r, 'xmlrpcresp'))
					{
						// what should we assume here about automatic encoding of datetimes
						// and php classes instances???
						$r = new jsonrpcresp(php_jsonrpc_encode($r, $this->phpvals_encoding_options));
					}
				}
				// here $r is either an xmlrpcresp or jsonrpcresp
				if (!is_a($r, 'jsonrpcresp'))
				{

					// dirty trick: user has given us back an xmlrpc response,
					// since he had an existing xmlrpc server with boatloads of code.
					// Be nice to him, and serialize the xmlrpc stuff into JSON.
					// We also override the content_type of the xmlrpc response,
					// but lack knoweledge of intented response charset...
					$r->content_type = 'application/json';
					$r->payload = serialize_jsonrpcresp($r, $msgID);
				}
				else
				{
					$r->id = $msgID;
				}
			}
			catch(Exception $e)
			{
			// (barring errors in the lib) an uncatched exception happened
				// in the called function, we wrap it in a proper error-response
				switch($this->exception_handling)
				{
					case 2:
						throw $e;
						break;
					case 1:
						$r = new jsonrpcresp(0, $e->getCode(), $e->getMessage());
						break;
					default:
						$r = new jsonrpcresp(0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error']);
				}
			}
			if($this->debug > 2)
			{
				// note: restore the error handler we found before calling the
				// user func, even if it has been changed inside the func itself
				if($GLOBALS['_xmlrpcs_prev_ehandler'])
				{
					set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']);
				}
				else
				{
					restore_error_handler();
				}
			}
			return $r;
		}
766639
public static String getFunctionParams( String function ) {
      return RegexpUtils.getMatcher( FUNCTION_PARAMS_PATTERN, true ).getGroupIfMatches( function, 1 );
   }
171503
function (tpl) {
      var tree = []
      var openTag
      var tag
      var name
      var paramStr
      var node
      var closeTag
      var usedExtends = 0

      for (openTag = this.findTag('', tpl); openTag; openTag = this.findTag('', tpl)) {
        if (openTag.index) {
          tree = tree.concat(this.parseText(tpl.slice(0, openTag.index)))
        }
        tpl = tpl.slice((openTag.index + openTag[0].length))
        tag = openTag[1].match(/^\s*(\w+)(.*)$/)
        if (tag) {
          // Function?!
          name = tag[1]
          paramStr = (tag.length > 2) ? tag[2].replace(/^\s+|\s+$/g, '') : ''
          if (name in this.buildInFunctions) {
            var buildIn = this.buildInFunctions[name]
            var params = ('parseParams' in buildIn ? buildIn.parseParams.bind(this) : this.parseParams.bind(this))(paramStr)
            if (buildIn.type === 'block') {
              // Remove new line after block open tag (like in Smarty)
              tpl = tpl.replace(/^\n/, '')
              closeTag = this.findCloseTag('/' + name, name + ' +[^}]*', tpl)
              var functionTree = buildIn.parse.call(this, params, tpl.slice(0, closeTag.index))
              if (functionTree) {
                // Some functions return false like {php} and {function}
                tree = tree.concat(functionTree)
              }
              tpl = tpl.slice(closeTag.index + closeTag[0].length)
            } else {
              if (name === 'extends') {
                // Anything before {extends} should be stripped.
                tree.splice(0, tree.length)
              }
              tree = tree.concat(buildIn.parse.call(this, params))
              if (name === 'extends') {
                usedExtends = tree.length
              }
            }
            tpl = tpl.replace(/^\n/, '')
          } else if (name in this.runTimePlugins) {
            // Possible it is function name. give it a priority before plugin.
            tree = tree.concat(this.parsePluginFunc(name, this.parseParams(paramStr)))
          } else if (name in this.plugins) {
            var plugin = this.plugins[name]
            if (plugin.type === 'block') {
              closeTag = this.findCloseTag('/' + name, name + ' +[^}]*', tpl)
              tree = tree.concat(this.parsePluginBlock(name, this.parseParams(paramStr), tpl.slice(0, closeTag.index)))
              tpl = tpl.slice(closeTag.index + closeTag[0].length)
            } else if (plugin.type === 'function') {
              tree = tree.concat(this.parsePluginFunc(name, this.parseParams(paramStr)))
            }
            if (name === 'append' || name === 'assign' || name === 'capture' || name === 'eval' || name === 'include') {
              tpl = tpl.replace(/^\n/, '')
            }
          } else {
            // Variable.
            node = this.buildInFunctions.expression.parse.call(this, openTag[1])
            tree.push(node)
          }
        } else {
          // Variable.
          node = this.buildInFunctions.expression.parse.call(this, openTag[1])
          if (node.expression.type === 'build-in' && node.expression.name === 'operator' && node.expression.op === '=') {
            tpl = tpl.replace(/^\n/, '')
          }
          tree.push(node)
        }
      }
      if (tpl) {
        tree = tree.concat(this.parseText(tpl))
      }
      tree.usedExtends = usedExtends
      return tree
    }
328585
public static function getCreateFunction($tbl): string
    {
        $sql = self::getInstance()->sql_query("SHOW CREATE FUNCTION `$tbl`");

        $q = $sql->fetch(PDO::FETCH_ASSOC);

        return strtr($q['Create Function'], ["\r" => '', "\n" => '', "\t" => '']);
    }
1112530
function parse_PtgFunc(blob, length, opts) {
	var ptg = blob[blob.l] & 0x1F;
	var type = (blob[blob.l] & 0x60)>>5;
	blob.l += 1;
	var iftab = blob.read_shift(opts && opts.biff <= 3 ? 1 : 2);
	return [FtabArgc[iftab], Ftab[iftab], type];
}
594128
def define_api(name, camel_name, effective_names, params, returns, options)
      params, returns = generate_signature(params.dup, returns)

      ffi_lib *(ffi_libraries.map(&:name) << options[:dll]) if options[:dll]
      libs = ffi_libraries.map(&:name)

      alternative = options.delete(:alternative) # Function may have alternative signature
      effective_name = if alternative

        alt_params, alt_returns, condition = generate_signature(*alternative)
        api = function name, params, returns,
                       options.merge( camel_only: true, camel_name: "#{camel_name}Original")
        alt_api = function name, alt_params, alt_returns,
                           options.merge( camel_only: true, camel_name: "#{camel_name}Alternative")

        define_method camel_name do |*args|
          (condition[*args] ? alt_api : api).call(*args)
        end
        module_function camel_name
        public camel_name
        api.effective_name
      else
        effective_names.inject(nil) do |func, effective_name|
          func || begin
            # Try to attach basic CamelCase method via FFI
            attach_function(camel_name, effective_name, params.dup, returns)
            effective_name
          rescue FFI::NotFoundError
            nil
          end
        end
      end

      raise Win::Errors::NotFoundError.new(name, libs) unless effective_name

      # Create API object that holds information about defined and effective function names, params, etc.
      # This object is further used by enhanced snake_case method to reflect on underlying API and
      # intelligently call it.
      API.new(namespace, camel_name, effective_name, params, returns, libs)
    end
327572
def get_xml(self, pdb_id):
        ''' '''
        self.tmp_string = None
        context = etree.iterparse(io.BytesIO(self.xml_contents), events=('end',), tag=self.PDBTM_entry_tag_type)
        try:
            fast_iter(context, self._get_xml, pdb_id = pdb_id.upper())
        except EarlyOut: pass
        return self.tmp_string