Commit graph

33 commits

Author SHA1 Message Date
Andy Green
54806b1541 clean internal refactor
- Mainly symbol length reduction
 - Whitespace clean
 - Code refactor for linear flow
 - Audit @Context for API docs vs changes

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 17:03:59 +08:00
Andy Green
00c6d1579c public api remove context from user callback API BREAK
Since struct lws (wsi) now has his own context pointer,
we were able to remove the need for passing context
almost everywhere in the apis.

In turn, that means there's no real use for context being
passed to every callback; in the rare cases context is
needed user code can get it with lws_get_ctx(wsi)

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 07:54:44 +08:00
Andy Green
ab4a94dd46 win align to recent changes
These were warnings seen on Appveyor

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 12:00:20 +08:00
Andy Green
40110e84ab whitespace trailing mass cleanout
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 08:52:03 +08:00
Andy Green
891628b33c lws_plat_fd add wsi to fops and helpers
Having the lws_context alone doesn't let us track state or act different
by wsi, which is the most interesting usecase.  Eg not only simply track
file position / decompression state per wsi but also act differently
according to wsi authentication state / associated cookies.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:43:35 +08:00
Andy Green
0161f01082 win open flags 3 lsb are not bitfields
https://github.com/warmcat/libwebsockets/issues/367

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:40:53 +08:00
Andy Green
d1c6d0bb06 windows use right perversion flgs
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 12:56:46 +08:00
Andy Green
4e442b7743 lws_plat_fd implement platform default handlers
This is a rewrite of the patch from Soapyman here

https://github.com/warmcat/libwebsockets/pull/363

The main changes compared to Soapyman's original patch are

 - There's no new stuff in the info struct user code does any overrides
   it may want to do explicitly after lws_context_create returns

 - User overrides for file ops can call through (subclass) to the original
   platform implementation using lws_get_fops_plat()

 - A typedef is provided for plat-specific fd type

 - Public helpers are provided to allow user code to be platform-independent
   about file access, using the lws platform file operations underneath:

static inline lws_filefd_type
lws_plat_file_open(struct lws_plat_file_ops *fops, const char *filename,
		   unsigned long *filelen, int flags)

static inline int
lws_plat_file_close(struct lws_plat_file_ops *fops, lws_filefd_type fd)

static inline unsigned long
lws_plat_file_seek_cur(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		       long offset_from_cur_pos)

static inline int
lws_plat_file_read(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		   unsigned long *amount, unsigned char *buf, unsigned long len)

static inline int
lws_plat_file_write(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		    unsigned long *amount, unsigned char *buf, unsigned long len)

There's example documentation and implementation in the test server.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 11:01:59 +08:00
Andy Green
4386e36b0b plat combine inits into single lws_plat_init and provide info
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 07:14:16 +08:00
Andy Green
1cc03887f4 clean reduce windows build warnings
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 08:00:03 +08:00
Andy Green
dd6aaa898f windows align lws_service_fd return processing with unix
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-05 09:38:50 +08:00
Andy Green
4b85c1d4ac api rationalization: eliminate all libwebsocket[s]_ prefixes
This nukes all the oldstyle prefixes except in the compatibility code.

struct libwebsockets becomes struct lws too.

The api docs are updated accordingly as are the READMEs that mention
those apis.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 11:08:32 +08:00
Andy Green
6230476455 api rationalization use new names internally
Change all internal uses of rationalized public apis to reflect the
new names.

Theer are a few things that got changed as side effect of search/replace
matches, but these are almost all internal.  I added a compatibility define
for the public enum that got renamed.

Theoretically existing code should not notice the difference from these
two patches.  And new code will find the new names.

https://github.com/warmcat/libwebsockets/issues/357

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 08:43:54 +08:00
Andy Green
9494c66d20 win remove piggybacked hack
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-19 08:43:51 +08:00
Andy Green
d55ac45c39 windows eliminate duplicate POLLOUT
After "hotcookie" on github

https://github.com/warmcat/libwebsockets/issues/345

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-18 09:51:07 +08:00
Andy Green
35fef0534b plat win be robust against NULL wsi_from_fd 3
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-14 07:02:38 +08:00
Andy Green
1064cd7619 plat win be robust against NULL wsi_from_fd 2
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-13 11:43:53 +08:00
Andy Green
46d9b8e06f plat win be robust against NULL wsi_from_fd
After "haitetra"

https://github.com/warmcat/libwebsockets/issues/343

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-13 10:14:50 +08:00
=?UTF-8?q?Joakim=20S=C3=B6derberg?=
caf7e3d63b Fix potential memory leak
- Got rid of ifdef _WIN32 stuff adn moved to plat_ files instead.
- Also, check all calls to lws_zalloc, was potential failure on WIN32
- Made context destory enable to destroy a half inited context as well. This way I got get rid of some of the error handling complexity in libwebsocket_create_context
- Added TODOs for some potential problems I see where things might be leaking and such
2015-10-12 10:05:18 +08:00
Andy Green
d3efcd9461 windows check for NULL getprotobyname
From maxkaro on trac #110
https://libwebsockets.org/trac/libwebsockets/ticket/110

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-04-16 04:24:38 +08:00
Bud Davis
229bfec948 win32 use hashtable for fd management
At least some win32 uses an opaque pointer for fd that is not
an ordinal like it is in unix.

Resurrect the old hashtable management for that platform to use
instead, and introduce a helper to get the wsi from the fd "somehow".

Signed-off-by: Bud Davis <bdavis9659@gmail.com>
2015-01-30 10:48:57 +08:00
Alejandro Mery
6ff28248aa Subject: [PATCH] Use custom allocator
Signed-off-by: Alejandro Mery <amery@geeks.cl>
2014-12-05 07:26:26 +08:00
Emerson Clarke
32ec9d0299 plat win add ibterface to sa 2014-11-06 23:06:01 +08:00
Patrick Gansterer
c11b847fa8 Windows: Fix implementation of lws_plat_inet_ntop()
We need to pass a sockaddr_in6 struct to WSAAddressToString() to have a
working implementation for IPV6. Also use the WideChar version to allow
compilation on Windows CE too.
2014-04-15 18:45:48 +02:00
Patrick Gansterer
fe0ca596d6 Windows: Fix the passed parameter to the setsockopt function
This avoids compiler warnings about missmatched parameter types.
2014-04-15 18:41:38 +02:00
Andy Green
92795d64db windows fix breakage from plat refactor
Reported-by Marjan Tomas

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-03 22:38:49 +08:00
Andy Green
a654fc0d50 clean move lws_plat externs
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-03 07:16:40 +08:00
Andy Green
1cd3ba6fdc ipv6 use lws_plat_ to avoid win naming collision
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 23:03:23 +08:00
Andy Green
5266f66f50 win32 inet_top
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 21:31:07 +08:00
Andy Green
e40aa9b920 plat change to build selection by cmake
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 21:04:03 +08:00
Andy Green
158e804cb7 refactor out WIN32 tests from code
This gets rid of all the platform-dependent #ifdef stuff and
migrates it into the new lws-plat-xxx.c files.

These are then included in a one-time test in libwebsockets.c
according basically to Windows or not.

The idea is from now on, all Windows-specific code should go in
lws-plat-win.c, where any kind of Windows perversion like DWORD
is fine.

Any new functions going in there should be named lws_plat_...
and be defined in all the lws-plat-xxx.c file (currently just
win32 and unix platforms are supported).

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 14:25:10 +08:00
Andy Green
8c2c92491e win32 clean remove leftover ifdef
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-31 22:03:09 +08:00
Andy Green
bfaea95f60 clean libwebsockets.c
Signed-off-by: None <None>
2014-03-31 11:01:32 +08:00