Example #1
0
BUrl::BUrl(const BUrl& base, const BString& location)
	:
	fUrlString(),
	fProtocol(),
	fUser(),
	fPassword(),
	fHost(),
	fPort(0),
	fPath(),
	fRequest(),
	fAuthorityValid(false),
	fUserInfoValid(false),
	fHasUserName(false),
	fHasPassword(false),
	fHasHost(false),
	fHasPort(false),
	fHasFragment(false)
{
	// This implements the algorithm in RFC3986, Section 5.2.

	BUrl relative(location);
	if (relative.HasProtocol()) {
		SetProtocol(relative.Protocol());
		if (relative.HasAuthority())
			SetAuthority(relative.Authority());
		SetPath(relative.Path());
		SetRequest(relative.Request());
	} else {
		if (relative.HasAuthority()) {
			SetAuthority(relative.Authority());
			SetPath(relative.Path());
			SetRequest(relative.Request());
		} else {
			if (relative.Path().IsEmpty()) {
				_SetPathUnsafe(base.Path());
				if (relative.HasRequest())
					SetRequest(relative.Request());
				else
					SetRequest(base.Request());
			} else {
				if (relative.Path()[0] == '/')
					SetPath(relative.Path());
				else {
					BString path = base._MergePath(relative.Path());
					SetPath(path);
				}
				SetRequest(relative.Request());
			}

			if (base.HasAuthority())
				SetAuthority(base.Authority());
		}
		SetProtocol(base.Protocol());
	}

	if (relative.HasFragment())
		SetFragment(relative.Fragment());
}
Example #2
0
BUrl::BUrl(const BUrl& base, const BString& location)
	:
	fUrlString(),
	fProtocol(),
	fUser(),
	fPassword(),
	fHost(),
	fPort(0),
	fPath(),
	fRequest(),
	fHasAuthority(false)
{
	// This implements the algorithm in RFC3986, Section 5.2.

	BUrl relative(location);
	if (relative.HasProtocol()) {
		SetProtocol(relative.Protocol());
		SetAuthority(relative.Authority());
		SetPath(relative.Path()); // TODO _RemoveDotSegments()
		SetRequest(relative.Request());
	} else {
		if (relative.HasAuthority()) {
			SetAuthority(relative.Authority());
			SetPath(relative.Path()); // TODO _RemoveDotSegments()
			SetRequest(relative.Request());
		} else {
			if (relative.Path().IsEmpty()) {
				SetPath(base.Path());
				if (relative.HasRequest())
					SetRequest(relative.Request());
				else
					SetRequest(Request());
			} else {
				if (relative.Path()[0] == '/')
					SetPath(relative.Path());
				else {
					BString path = base.Path();
					// Remove last part of path (the file, if any) so we get the
					// "current directory"
					path.Truncate(path.FindLast('/') + 1);
					path += relative.Path();
					// TODO _RemoveDotSegments()
					SetPath(path);
				}
				SetRequest(relative.Request());
			}
			SetAuthority(base.Authority());
		}
		SetProtocol(base.Protocol());
	}

	SetFragment(relative.Fragment());
}
Example #3
0
void ParseStdArgs(int argc, char **argv,int *extra_argc, char ***extra_argv) {
  Options options[] = {{"P","protocol",1,0,0},
		       {"h","hostfile",1,0,0},
		       {"s","server",0,0,0},
		       {"m","multi",0,0,0},
		       {"c","compression",1,0,0},
		       {0,0,0,0}};
  ParseCommand(argc,argv,options,1,extra_argc,extra_argv);
  if (options[0].present && options[0].value)
    SetProtocol(options[0].value);
  if (options[1].present && options[1].value)
    SetHostfile(options[1].value);
  if (options[2].present) {
    if (options[3].present) {
      fprintf(stderr,"Cannot select both server mode and multi mode\n\n");
      PrintHelp(0);
    } else {
      SetMulti(1);
      SetContextSwitching(0);
    }
  }
  if (options[3].present) {
    SetMulti(1);
    SetContextSwitching(1);
  }
  if (options[4].present && options[4].value)
    SetCompressionLevel(atoi(options[4].value));
}
Example #4
0
BOOL SetC4FileClasses(const char *szEnginePath)
  {

  if (!SetRegFileClass("Clonk4.Scenario",		"c4s", "Clonk 4 Scenario",					szEnginePath, 1, C4FileClassContentType)) return FALSE;
  if (!SetRegFileClass("Clonk4.Group",			"c4g", "Clonk 4 Group",							szEnginePath, 2, C4FileClassContentType)) return FALSE;
  if (!SetRegFileClass("Clonk4.Folder",			"c4f", "Clonk 4 Folder",						szEnginePath, 3, C4FileClassContentType)) return FALSE;
  if (!SetRegFileClass("Clonk4.Player",			"c4p", "Clonk 4 Player",						szEnginePath, 4, C4FileClassContentType)) return FALSE;
  if (!SetRegFileClass("Clonk4.Definition", "c4d", "Clonk 4 Object Definition", szEnginePath, 6, C4FileClassContentType)) return FALSE;
  if (!SetRegFileClass("Clonk4.Object",			"c4i", "Clonk 4 Object Info",				szEnginePath, 7, C4FileClassContentType)) return FALSE;
  if (!SetRegFileClass("Clonk4.Material",		"c4m", "Clonk 4 Material",					szEnginePath, 8, "text/plain")) return FALSE;
  if (!SetRegFileClass("Clonk4.Binary",			"c4b", "Clonk 4 Binary",						szEnginePath, 9, "application/octet-stream")) return FALSE;
  if (!SetRegFileClass("Clonk4.Video",			"c4v", "Clonk 4 Video",							szEnginePath, 10, "video/avi")) return FALSE;
  if (!SetRegFileClass("Clonk4.Weblink",		"c4l", "Clonk 4 Weblink",						szEnginePath, 11, C4FileClassContentType)) return FALSE;
  if (!SetRegFileClass("Clonk4.Key",				"c4k", "Clonk 4 Key",								szEnginePath, 12, "application/octet-stream")) return FALSE;
  if (!SetRegFileClass("Clonk4.Update",			"c4u", "Clonk 4 Update",						szEnginePath, 13, C4FileClassContentType)) return FALSE;
	
	if (!SetProtocol("clonk", "%s %%1 /Fullscreen", szEnginePath)) return FALSE;

	char strCommand[2048];
	// c4k installation: send to engine
	sprintf(strCommand, "\"%s\" \"%%1\"", szEnginePath);
	if (!SetRegShell("Clonk4.Key", "Register", "Register", strCommand)) return FALSE;
	// c4u application: send to engine
	sprintf(strCommand, "\"%s\" \"%%1\"", szEnginePath);
	if (!SetRegShell("Clonk4.Update", "Update", "Update", strCommand, TRUE)) return FALSE;

	// kill old App Paths registration
	DeleteRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Clonk.exe");

	return TRUE;
  }
Example #5
0
bool FGOutput::Load(int subSystems, std::string protocol, std::string  type, std::string port, std::string name, double outRate, std::vector<FGPropertyManager *> & outputProperties)
{
  SetType(type);
  SetRate(outRate);
  SubSystems = subSystems;
  OutputProperties = outputProperties;

  if (((Type == otCSV) || (Type == otTab)) && (name != "cout") && (name !="COUT"))
    name = FDMExec->GetRootDir() + name;

  if (!port.empty() && (Type == otSocket || Type == otFlightGear)) {
    SetProtocol(protocol);
    socket = new FGfdmSocket(name, atoi(port.c_str()), Protocol);
  } else {
    BaseFilename = Filename = name;
  }

  if (Type == otMAVLink)
  {
    mavlink = new FGMAVLink(0,0,MAV_TYPE_GENERIC,"/dev/ttyUSB0",115200);
  }

  Debug(2);
  return true;
}
Example #6
0
BUrl::BUrl(const BPath& path)
	:
	fUrlString(),
	fProtocol(),
	fUser(),
	fPassword(),
	fHost(),
	fPort(0),
	fPath(),
	fRequest(),
	fHasHost(false),
	fHasFragment(false)
{
	SetUrlString(UrlEncode(path.Path(), true, true));
	SetProtocol("file");
}
Example #7
0
/*******************************************************************************
* Function Name  : Speaker_NoData_Setup
* Description    : Handle the no data class specific requests.
* Input          : None.
* Output         : None.
* Return         : USB_UNSUPPORT or USB_SUCCESS.
*******************************************************************************/
RESULT Speaker_NoData_Setup(u8 RequestNo)
{
  if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
      && (RequestNo == SET_PROTOCOL))
  {
    SetProtocol(pInformation->USBwIndex0,pInformation->USBwValue0);
    return USB_SUCCESS;
  }
  else if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
      && (RequestNo == SET_REPORT))
  {
    return USB_SUCCESS;
  }
  else if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
      && (RequestNo == SET_IDLE))
  {
    SetIdle(pInformation->USBwIndex0,pInformation->USBwValue0,pInformation->USBwValue1);
    return USB_SUCCESS;
  }
  else
  {
    return USB_UNSUPPORT;
  }
}
void Scr_Connect::UpdProtocol()
{
	SetProtocol(Setting::Instance()->CurrProto());
}
Example #9
0
/*
 * This function takes a URL in string-form and parses the components of the URL out.
 */
status_t
BUrl::_ExplodeUrlString(const BString& url)
{
	_ResetFields();

	// RFC3986, Appendix C; the URL should not contain whitespace or delimiters
	// by this point.

	if (_ContainsDelimiter(url))
		return B_BAD_VALUE;

	explode_url_parse_state state = EXPLODE_PROTOCOL;
	int32 offset = 0;
	int32 length = url.Length();
	const char *url_c = url.String();

	// The regexp is provided in RFC3986 (URI generic syntax), Appendix B
	// ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?
	// The ensuing logic attempts to simulate the behaviour of extracting the groups
	// from the string without requiring a group-capable regex engine.

	while (offset < length) {
		switch (state) {

			case EXPLODE_PROTOCOL:
			{
				int32 end_protocol = char_offset_until_fn_false(url_c, length,
					offset, explode_is_protocol_char);

				if (end_protocol < length) {
					SetProtocol(BString(&url_c[offset], end_protocol - offset));
					state = EXPLODE_PROTOCOLTERMINATOR;
					offset = end_protocol;
				} else {
					// No protocol was found, try parsing from the string
					// start, beginning with authority or path
					SetProtocol("");
					offset = 0;
					state = EXPLODE_AUTHORITYORPATH;
				}
				break;
			}

			case EXPLODE_PROTOCOLTERMINATOR:
			{
				if (url[offset] == ':') {
					offset++;
				} else {
					// No protocol was found, try parsing from the string
					// start, beginning with authority or path
					SetProtocol("");
					offset = 0;
				}
				state = EXPLODE_AUTHORITYORPATH;
				break;
			}

			case EXPLODE_AUTHORITYORPATH:
			{
				// The authority must start with //. If it isn't there, skip
				// to parsing the path.
				if (strncmp(&url_c[offset], "//", 2) == 0) {
					state = EXPLODE_AUTHORITY;
					offset += 2;
				} else {
					state = EXPLODE_PATH;
				}
				break;
			}

			case EXPLODE_AUTHORITY:
			{
				int end_authority = char_offset_until_fn_false(url_c, length,
					offset, explode_is_authority_char);
				SetAuthority(BString(&url_c[offset], end_authority - offset));
				state = EXPLODE_PATH;
				offset = end_authority;
				break;
			}

			case EXPLODE_PATH:
			{
				int end_path = char_offset_until_fn_false(url_c, length, offset,
					explode_is_path_char);
				SetPath(BString(&url_c[offset], end_path - offset));
				state = EXPLODE_REQUEST;
				offset = end_path;
				break;
			}

			case EXPLODE_REQUEST: // query
			{
				if (url_c[offset] == '?') {
					offset++;
					int end_request = char_offset_until_fn_false(url_c, length,
						offset, explode_is_request_char);
					SetRequest(BString(&url_c[offset], end_request - offset));
					offset = end_request;
				}
				state = EXPLODE_FRAGMENT;
				break;
			}

			case EXPLODE_FRAGMENT:
			{
				if (url_c[offset] == '#') {
					offset++;
					SetFragment(BString(&url_c[offset], length - offset));
					offset = length;
				}
				state = EXPLODE_COMPLETE;
				break;
			}

			case EXPLODE_COMPLETE:
				// should never be reached - keeps the compiler happy
				break;

		}
	}

	return B_OK;
}