Advertisement
SirSpamModz

Untitled

Aug 12th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1.  
  2. static string get_env(
  3. string env[],
  4. string name)
  5. {
  6. for (int i = 0; env[i] != NULL; i++) {
  7. if (StartsWith(env[i], name) == TRUE) {
  8. return (string)(&env[i][0] + StringLength(name));
  9. }
  10. }
  11. return NULL;
  12. }
  13.  
  14. static BOOL StartsWith(
  15. string sig,
  16. string to_match)
  17. {
  18. int sig_length = strlen(sig);
  19. int to_match_length = strlen(to_match);
  20.  
  21. if (sig_length < to_match_length) {
  22. return FALSE;
  23. }
  24.  
  25. for (int i = 0; i < to_match_length; i++) {
  26. if (sig[i] != to_match[i]) {
  27. return FALSE;
  28. }
  29. }
  30.  
  31. return TRUE;
  32. }
  33.  
  34. static int strlen(
  35. string string)
  36. {
  37. int length = 0;
  38. while (string[length++] != '\0');
  39. return length - 1;
  40. }
  41.  
  42. static string urlencode(
  43. string data)
  44. {
  45. string output = "";
  46. string temp = "";
  47. int length = strlen(data);
  48.  
  49. for (int i = 0; i < length; i++) {
  50. if ((data[i] > 'a' || data[i] < 'Z') || (data[i] > '1' || data[i] < '0')) {
  51. AppendString(output, data[i]);
  52. }
  53. else {
  54. temp = "\0\0\0\0";
  55. sprintf(temp, "%X", data[i]);
  56. if (strlgn(temp) == 2) {
  57. temp[0] = '%';
  58. temp[2] = temp[1];
  59. temp[1] = '0';
  60. }
  61.  
  62. AppendString(output, temp);
  63. }
  64. }
  65.  
  66. temp = "\0\0\0\0";
  67. return output;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement