Skip to content

Commit 093d483

Browse files
author
YuguoZhang
committed
examples: build using MSVC
1 parent dde1b81 commit 093d483

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

examples/bot.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
#include <stdio.h>
2121
#include <stdlib.h>
2222
#include <string.h>
23-
#include <unistd.h>
2423

2524
#ifdef _WIN32
2625
#include <conio.h>
2726
#include <ctype.h>
27+
#else
28+
#include <unistd.h>
2829
#endif
2930

3031
#include <strophe.h>

examples/complex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <stdio.h>
1414
#include <stdlib.h>
1515
#include <string.h>
16-
#include <unistd.h>
1716

1817
#ifdef _WIN32
1918
#include <conio.h>
@@ -23,6 +22,7 @@
2322
#include <iphlpapi.h>
2423
#include <mstcpip.h> /* tcp_keepalive */
2524
#else
25+
#include <unistd.h>
2626
#include <sys/socket.h>
2727
#include <netinet/in.h>
2828
#include <netinet/tcp.h>

examples/vcard.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212

1313
#include <assert.h>
14+
#ifndef _WIN32
1415
#include <libgen.h> /* basename */
16+
#endif
1517
#include <string.h>
1618
#include <stdio.h>
1719
#include <stdlib.h>
@@ -56,10 +58,18 @@ static void vcard_photo(vcard_t *vc, xmpp_stanza_t *stanza)
5658
copy = (char *)malloc(strlen(s) + 1);
5759
assert(copy != NULL);
5860
copy[0] = '\0';
61+
#ifdef _WIN32
62+
tok = strtok_s(s, "\n\r", &saveptr);
63+
#else
5964
tok = strtok_r(s, "\n\r", &saveptr);
65+
#endif
6066
while (tok != NULL) {
6167
strcat(copy, tok);
68+
#ifdef _WIN32
69+
tok = strtok_s(NULL, "\n\r", &saveptr);
70+
#else
6271
tok = strtok_r(NULL, "\n\r", &saveptr);
72+
#endif
6373
}
6474

6575
xmpp_base64_decode_bin(vc->ctx, copy, strlen(copy), &img, &img_size);
@@ -252,7 +262,11 @@ int main(int argc, char **argv)
252262
prog = argc > 0 ? strdup(argv[0]) : NULL;
253263
printf("Usage: %s <login-jid> <password> <recipient-jid> "
254264
"[image-file]\n\n",
265+
#ifdef _WIN32
266+
"vcard");
267+
#else
255268
prog == NULL ? "vcard" : basename(prog));
269+
#endif
256270
printf("If vCard contains a photo it will be stored to "
257271
"image-file. If you don't provide the image-file "
258272
"default filename will be generated.\n");

0 commit comments

Comments
 (0)