libowfat/test/urlencode.c

26 lines
499 B
C
Raw Normal View History

2002-09-03 08:51:28 +00:00
#include <string.h>
#include "buffer.h"
#include "textcode.h"
2004-01-06 23:35:06 +00:00
#include "havealloca.h"
2002-09-03 08:51:28 +00:00
void urlencode(const char* c) {
char* buf=alloca(strlen(c)*3+1);
buffer_put(buffer_1,buf,fmt_urlencoded(buf,c,strlen(c)));
buffer_putnlflush(buffer_1);
}
main(int argc,char* argv[]) {
int i;
for (i=1; i<argc; ++i) {
urlencode(argv[i]);
}
2002-09-06 18:00:07 +00:00
if (argc<2) {
char src[1024];
int len=read(0,src,sizeof(src)-1);
if (len==-1) return(1);
src[len]=0;
urlencode(src);
}
2002-09-03 08:51:28 +00:00
return 0;
}