Permalink
Browse files

fixed all warnings

  • Loading branch information...
1 parent 087a1a4 commit ab3dbeab5c28cf98d0e821609550f44a1a8cc35a @ers35 ers35 committed Jul 19, 2012
View
30 127.0.0.1_8080/#127.0.0.1/csp/forum_simple.c
@@ -22,7 +22,7 @@ static char
base_tpl[] =
"<html><body>"
"<head><title>G-WAN Forum</title></head>"
- "<h1><a href='/csp/forum_simple.c'>G-WAN Forum</a></h1><hr/>"
+ "<h1><a href='/?forum_simple'>G-WAN Forum</a></h1><hr/>"
"<form method='POST'><!--form--></form>"
"<!--tpl-->"
"</body></html>",
@@ -38,12 +38,13 @@ static char
"<input type='submit' value='Create thread'/>";
//template rendering functions
-int list_posts(const kv_item *item, const void *reply)
+int list_posts(const kv_item *item, const void *reply_)
{
+ xbuf_t *reply = (xbuf_t*)reply_;
Post *post = (Post*)item->val;
//using HTML comments
- const char post_li[] = "<li><!--contents--></li>";
+ static char post_li[] = "<li><!--contents--></li>";
char *pos = xbuf_findstr(reply, "<!--tpl-->");
if (pos) xbuf_insert(reply, pos, sizeof(post_li) - 1, post_li);
@@ -53,16 +54,17 @@ int list_posts(const kv_item *item, const void *reply)
return 1; //continue searching
}
-int list_threads(const kv_item *item, const void *reply)
+int list_threads(const kv_item *item, const void *reply_)
{
+ xbuf_t *reply = (xbuf_t*)reply_;
Thread *thread = (Thread*)item->val;
xbuf_t thread_li;
xbuf_init(&thread_li);
{
//using sprintf-like formatting
xbuf_xcat(&thread_li,
- "<li><a href='/csp/forum_simple.c/act=t/id=%llu'>%s</a> (%lu)</li>",
+ "<li><a href='/?forum_simple/act=t/id=%llu'>%s</a> (%lu)</li>",
thread->id, thread->title.ptr, thread->posts.nbr_items
);
@@ -79,7 +81,7 @@ int list_threads(const kv_item *item, const void *reply)
int main(int argc, char *argv[])
{
//initialize Key-Value store
- kv_t **vhost_ptr = get_env(argv, US_VHOST_DATA), //persistent pointer
+ kv_t **vhost_ptr = (void*)get_env(argv, US_VHOST_DATA), //persistent pointer
*forum_store = 0; //convenience pointer (var->m instead of (*var)->m)
if (vhost_ptr && !*vhost_ptr) {
@@ -106,7 +108,7 @@ int main(int argc, char *argv[])
xbuf_cat(reply, base_tpl); //set base template
//HTTP state of a connection
- http_t *http = get_env(argv, HTTP_HEADERS);
+ http_t *http = (void*)get_env(argv, HTTP_HEADERS);
redirect: //simulate HTTP, <meta>, or JavaScript redirect without page reload
@@ -122,7 +124,7 @@ int main(int argc, char *argv[])
case HTTP_POST:
{
//get the thread to which this post belongs
- Thread *thread = (Thread*)kv_get(forum_store, &int_id, sizeof(int_id));
+ Thread *thread = (void*)kv_get(forum_store, (void*)&int_id, sizeof(int_id));
if (!thread) { //thread not found
xbuf_repl(reply, "<!--tpl-->", http_error(404));
@@ -141,9 +143,9 @@ int main(int argc, char *argv[])
//add post to thread
kv_add(&thread->posts, &(kv_item) {
- .key = &post->id,
+ .key = (void*)&post->id,
.klen = sizeof(post->id),
- .val = post,
+ .val = (void*)post,
.flags = 0,
});
@@ -164,7 +166,7 @@ int main(int argc, char *argv[])
//view a thread
case HTTP_GET:
{
- Thread *thread = (Thread*)kv_get(forum_store, &int_id, sizeof(int_id));
+ Thread *thread = (Thread*)kv_get(forum_store, (void*)&int_id, sizeof(int_id));
if (!thread) {
xbuf_repl(reply, "<!--tpl-->", http_error(404));
@@ -193,14 +195,14 @@ int main(int argc, char *argv[])
//add thread to KV store
kv_add(forum_store, &(kv_item) {
- .key = &thread->id,
+ .key = (void*)&thread->id,
.klen = sizeof(thread->id),
- .val = thread,
+ .val = (void*)thread,
.flags = 0,
});
http->h_method = HTTP_GET;
- *act= "";
+ act= "";
goto redirect;
} break;
View
2 127.0.0.1_8080/#127.0.0.1/csp/kv_bench.c
@@ -2,7 +2,7 @@
//compare with kv_bench.c from the official G-WAN distribution
// ----------------------------------------------------------------------------
-//#define TEST_SQLITE // usually pre-installed on Linux
+#define TEST_SQLITE // usually pre-installed on Linux
#define TEST_GWAN_KV // available in G-WAN 2.7+
//#define TEST_TC // install Tokyo Cabinet 32-bit to test it
//#define TEST_TC_FIXED // install Tokyo Cabinet 32-bit to test it
View
17 127.0.0.1_8080/#127.0.0.1/csp/kv_payment.c
@@ -1,6 +1,7 @@
//in response to http://forum.gwan.com/index.php?p=/discussion/402/key-value-store-with-in-place-editing-and-appending-for-huge-value/#Item_1
#include "gwan.h"
+#include "stdio.h"
#include "stdlib.h"
typedef struct {
@@ -29,9 +30,9 @@ Payment* payment_add(kv_t *store, u32 amount)
payment->amount = amount;
kv_add(store, &(kv_item){
- .key = &payment->id,
+ .key = (void*)&payment->id,
.klen = sizeof(payment->id),
- .val = payment,
+ .val = (void*)payment,
.flags = 0,
});
@@ -53,9 +54,9 @@ int main(int argc, char *argv[])
user->payments = payments_store;
kv_add(&users_store, &(kv_item){
- .key = &user->id,
+ .key = (void*)&user->id,
.klen = sizeof(user->id),
- .val = user,
+ .val = (void*)user,
.flags = 0,
});
@@ -67,13 +68,13 @@ int main(int argc, char *argv[])
//"...appending one more payment to existing array of payment"
//search for user id 45
- User *user = kv_get(&users_store, &(u32){45}, sizeof(u32));
+ User *user = (void*)kv_get(&users_store, (void*)&(u32){45}, sizeof(u32));
Payment *payment = payment_add(user->payments, 100);
//"...some small change in the existing array of payment"
u32 payment_search = 1; //search for payment id 1
- payment = kv_get(user->payments, &payment_search, sizeof(payment_search));
+ payment = (void*)kv_get(user->payments, (void*)&payment_search, sizeof(payment_search));
payment->amount = 999;
//list users and payments
@@ -82,11 +83,11 @@ int main(int argc, char *argv[])
{
printf("User %i's payments:\n", userid);
- User *user = kv_get(&users_store, &userid, sizeof(userid));
+ User *user = (void*)kv_get(&users_store, (void*)&userid, sizeof(userid));
for (int paymentid = 1; paymentid <= user->payments->nbr_items; paymentid++)
{
- Payment *payment = kv_get(user->payments, &paymentid, sizeof(paymentid));
+ Payment *payment = (void*)kv_get(user->payments, (void*)&paymentid, sizeof(paymentid));
printf("\tPayment %i = %i\n", paymentid, payment->amount);
}
}
View
10 127.0.0.1_8080/#127.0.0.1/csp/pthread.c
@@ -1,11 +1,13 @@
//demonstrates the dangers of thread-unsafe code
//http://forum.gwan.com/index.php?p=/discussion/comment/3952/#Comment_3952
-#define _POSIX_C_SOURCE 199309L
#include "gwan.h"
+#include "stdio.h"
#include "sys/syscall.h"
#include "pthread.h"
#include "sys/time.h"
+#include <sys/types.h>
+#include "unistd.h"
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
@@ -24,7 +26,7 @@ static int slept = 0;
void *servlet_main(void *name)
{
- printf("%i: setting myfriend = %s\n", syscall(SYS_gettid), (char*)name);
+ printf("%zu: setting myfriend = %s\n", syscall(SYS_gettid), (char*)name);
myfriend = (char*)name;
@@ -35,7 +37,9 @@ void *servlet_main(void *name)
tsleep(1);
}
- printf("%i: myfriend is actually = %s\n", syscall(SYS_gettid), myfriend);
+ printf("%zu: myfriend is actually = %s\n", syscall(SYS_gettid), myfriend);
+
+ return 0;
}
int main(int argc, char *argv[])
View
13 127.0.0.1_8080/#127.0.0.1/csp/tcbdbfwmkeys.c
@@ -1,9 +1,12 @@
//in response to http://forum.gwan.com/index.php?p=/discussion/comment/4100/#Comment_4100
#include "gwan.h"
+#include "stdio.h"
-int add_key(kv_item *item, void **keys[])
+int add_key(const kv_item *item, const void *keys_)
{
+ char ***keys = (char***)keys_;
+
**keys = item->key;
(*keys)++;
@@ -31,16 +34,16 @@ int main(int argc, char *argv[])
}
);
- char *keys[1024],
- *keys_ptr = keys;
+ char *keys[1024];
+ char **keys_ptr = keys;
//search by key prefix "k"
- kv_do(&store, "k", sizeof("k") - 1, &add_key, &keys_ptr);
+ kv_do(&store, "k", sizeof("k") - 1, add_key, &keys_ptr);
printf("Key: %s\n", keys[0]); //Key: key1
printf("Key: %s\n", keys[1]); //Key: key2
kv_free(&store);
- return 200;
+ return 204;
}
View
1 127.0.0.1_8080/#127.0.0.1/csp/zlib.c
@@ -1,6 +1,7 @@
//in response to http://forum.gwan.com/index.php?p=/discussion/514/zlib_cmp-customizing-logs/p1
#include "gwan.h"
+#include "stdio.h"
int main(int argc, char *argv[])
{
View
2 gwan-browser-plugin/README
@@ -2,7 +2,7 @@ This is an NPAPI browser plugin for G-WAN.
install
-------
-1) Set PATH_TO_GWAN in gwan-browser-plugin.c to your G-WAN directory.
+1) Set PATH_TO_GWAN in gwan-browser-plugin.c to point to your G-WAN executable.
A listener on port 8080 is assumed.
2) make && make install
3) Open gwan-browser-plugin.html in Firefox, wait a few seconds for G-WAN to
View
1 gwan-browser-plugin/gwan-browser-plugin.c
@@ -4,6 +4,7 @@
// http://forum.gwan.com/index.php?p=/discussion/comment/1407/#Comment_1407
// http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/npp_api.html#1004145
+// https://developer.mozilla.org/En/Gecko_Plugin_API_Reference:Scripting_plugins
#include <stdlib.h>
#include <string.h>

0 comments on commit ab3dbea

Please sign in to comment.