Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static string get_env(
- string env[],
- string name)
- {
- for (int i = 0; env[i] != NULL; i++) {
- if (StartsWith(env[i], name) == TRUE) {
- return (string)(&env[i][0] + StringLength(name));
- }
- }
- return NULL;
- }
- static BOOL StartsWith(
- string sig,
- string to_match)
- {
- int sig_length = strlen(sig);
- int to_match_length = strlen(to_match);
- if (sig_length < to_match_length) {
- return FALSE;
- }
- for (int i = 0; i < to_match_length; i++) {
- if (sig[i] != to_match[i]) {
- return FALSE;
- }
- }
- return TRUE;
- }
- static int strlen(
- string string)
- {
- int length = 0;
- while (string[length++] != '\0');
- return length - 1;
- }
- static string urlencode(
- string data)
- {
- string output = "";
- string temp = "";
- int length = strlen(data);
- for (int i = 0; i < length; i++) {
- if ((data[i] > 'a' || data[i] < 'Z') || (data[i] > '1' || data[i] < '0')) {
- AppendString(output, data[i]);
- }
- else {
- temp = "\0\0\0\0";
- sprintf(temp, "%X", data[i]);
- if (strlgn(temp) == 2) {
- temp[0] = '%';
- temp[2] = temp[1];
- temp[1] = '0';
- }
- AppendString(output, temp);
- }
- }
- temp = "\0\0\0\0";
- return output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement