15 unsigned int codepage;
16 size_t in_len = strlen(str);
19 size_t mbssize, wcssize;
22 wcssize = MultiByteToWideChar(codepage, 0, str, in_len, NULL, 0);
23 wcsdata = (
wchar_t*) malloc((wcssize + 1) *
sizeof(wchar_t));
24 wcssize = MultiByteToWideChar(codepage, 0, str, in_len, wcsdata, wcssize + 1);
27 mbssize = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) wcsdata, -1, NULL, 0, NULL, NULL);
28 mbsdata = (
char*) malloc((mbssize + 1));
29 mbssize = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) wcsdata, -1, mbsdata, mbssize, NULL, NULL);
34 char *ret = malloc (strlen (str) + 1);
35 if(ret !=NULL) strcpy(ret,str);
45 int getopts(
int argc,
char** argv,
char* opts) {
54 else if(strcmp(argv[
optind],
"--") == 0) {
60 if(c ==
':' || (cp=strchr(opts, c)) == NULL) {
61 if(argv[
optind][++sp] ==
'\0') {
68 if(argv[
optind][sp+1] !=
'\0')
70 else if(++
optind >= argc) {
77 if(argv[
optind][++sp] ==
'\0') {
86 int main(
int argc,
char* argv[]) {
90 char* password = NULL;
91 char* appname =
"gntp-send";
92 char* notify =
"gntp-send notify";
100 while ((c =
getopts(argc, argv,
"a:n:s:p:u") != -1)) {
102 case 'a': appname =
optarg;
break;
103 case 'n': notify =
optarg;
break;
104 case 's': server =
optarg;
break;
105 case 'p': password =
optarg;
break;
106 case 'u': tcpsend = 0;
break;
108 default: argc = 0;
break;
114 fprintf(stderr,
"%s: [-u] [-a APPNAME] [-n NOTIFY] [-s SERVER:PORT] [-p PASSWORD] title message [icon] [url]\n", argv[0]);
123 if (!server) server =
"127.0.0.1";
127 rc =
growl(server,appname,notify,title,message,icon,password,url);
129 rc =
growl_udp(server,appname,notify,title,message,icon,password,url);
133 if (title) free(title);
134 if (message) free(message);
135 if (icon) free(icon);
GROWL_EXPORT int growl_udp(const char *const server, const char *const appname, const char *const notify, const char *const title, const char *const message, const char *const icon, const char *const password, const char *url)
static char * string_to_utf8_alloc(const char *str)
int getopts(int argc, char **argv, char *opts)
GROWL_EXPORT int growl_init(void)
int main(int argc, char *argv[])
GROWL_EXPORT void growl_shutdown(void)
GROWL_EXPORT int growl(const char *const server, const char *const appname, const char *const notify, const char *const title, const char *const message, const char *const icon, const char *const password, const char *url)