Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.5KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2012 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include <string.h>
  19. #include <stdio.h>
  20. void unescape_url ( char *url )
  21. {
  22. char *r, *w;
  23. r = w = url;
  24. for ( ; *r; r++, w++ )
  25. {
  26. if ( *r == '%' )
  27. {
  28. char data[3] = { *(r + 1), *(r + 2), 0 };
  29. int c;
  30. sscanf( data, "%2X", &c );
  31. *w = c;
  32. r += 2;
  33. }
  34. else
  35. *w = *r;
  36. }
  37. *w = 0;
  38. }
  39. char *escape_url ( const char *url )
  40. {
  41. const char *s;
  42. char *w;
  43. char r[1024];
  44. s = url;
  45. w = r;
  46. for ( ; *s && w < r + sizeof( r ); s++, w++ )
  47. {
  48. switch ( *s )
  49. {
  50. case '<':
  51. case '>':
  52. case '%':
  53. // liblo doesn't like these in method names
  54. case '[':
  55. case ']':
  56. case '{':
  57. case '}':
  58. case '?':
  59. case ',':
  60. case '#':
  61. case '*':
  62. case ' ':
  63. sprintf( w, "%%%2X", *s );
  64. w += 2;
  65. break;
  66. default:
  67. *w = *s;
  68. break;
  69. }
  70. }
  71. *w = 0;
  72. return strdup( r );
  73. }