Commit Graph

93 Commits

Author SHA1 Message Date
Armin Novak
fe51dd1e10 Fixed logging, added file name. 2015-12-10 10:39:37 +01:00
Armin Novak
400d1b8b96 Fixed open mode for fdopen. 2015-12-10 10:37:44 +01:00
Armin Novak
19744f3bb8 Added additional file functions and tests. 2015-12-09 18:29:16 +01:00
Bernhard Miklautz
0cdb4f7924 Fix compiler warnings
gcc (Debian 4.9.2-10) 4.9.2

winpr/libwinpr/thread/argv.c: In function ‘CommandLineToArgvA’:
winpr/libwinpr/thread/argv.c:94:6: warning: unused variable ‘index’ [-Wunused-variable]
  int index;

winpr/libwinpr/file/test/TestFileGetStdHandle.c: In function ‘TestFileGetStdHandle’:
winpr/libwinpr/file/test/TestFileGetStdHandle.c:44:2: warning: implicit
	declaration of function ‘CloseHandle’ [-Wimplicit-function-declaration]
  CloseHandle(stdout);
    ^
libfreerdp/codec/test/TestFreeRDPRegion.c: In function ‘test_norbert2_case’:
libfreerdp/codec/test/TestFreeRDPRegion.c:697:6: warning: unused variable ‘i’ [-Wunused-variable]
  int i;

channels/cliprdr/server/cliprdr_main.c: In function ‘cliprdr_server_receive_format_list’:
channels/cliprdr/server/cliprdr_main.c:636:24: warning: unused variable ‘cliprdr’ [-Wunused-variable]
  CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
                        ^
channels/cliprdr/server/cliprdr_main.c: In function ‘cliprdr_server_init’:
channels/cliprdr/server/cliprdr_main.c:1097:24: warning: unused variable ‘cliprdr’ [-Wunused-variable]
  CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
2015-11-09 19:26:34 +01:00
Martin Haimberger
925e4ea4d4 winpr/file: extend API
added windows code
fixed compiler issue
2015-09-15 04:14:30 -07:00
Bernhard Miklautz
074854735f winpr/file: extend API
Add function GetFileHandleForFileDescriptor to get
a file handle for a valid file descriptor.
2015-09-15 02:16:36 -07:00
Bernhard Miklautz
0d9dfb974d winpr/file: integrate pull request feedback
* simplify RemoveDirectory
* move std handle function into an extern C block
2015-09-10 11:50:10 +02:00
Bernhard Miklautz
0f5e7c60a7 winpr/file: don't close stdin/stdout/stderr
If the handle is closed stdin/stdout/stderr should be left open.
2015-09-09 17:07:40 +02:00
Bernhard Miklautz
8091530779 winpr/file: fix ios build
comm is only build on linux.
2015-09-09 17:07:13 +02:00
Bernhard Miklautz
6b52a2e5cc winpr/file: initial regular file support
Add initial support for "regular" files. First implemented call is
GetStdHandle to get stdin/stdout/stderr.
2015-09-09 16:47:03 +02:00
Bernhard Miklautz
204ae5462a winpr/file: refactoring
The used method for initalizing and registering the handle creators
had certain disadvantages like that it was necessary to have the creators
initialized before the first call to CreateFile. In case of comm it
wouldn't have been possible to open an comm port without calling any
other call related function first.
Now the handle creators are initialized the first time CreateFile is
called. This way it is also possible to ensure a certain order of the
handler invocations.

This commit also splits out the client side named pipe code from
the generic file handling (now called generic.c instead of file.c) and
uses the new handle creator infrastructure to register.
2015-09-09 15:48:59 +02:00
Bernhard Miklautz
68e8569110 winpr/synch: remove the dependency on winsock.h
winsock.h pulls in a lot of defines and dependencies that are not
required and partially unwanted in winpr's core (for parts that are not
related to network). In order to get rid of this dependency and have an
independent defines for extended winpr functions the WINPR_FD_* defines
are used internally (and for exposed functions). Where required, like in
WSAEventSelect, the FD_* is mapped to WINPR_FD_*.
2015-07-14 11:39:41 +02:00
Armin Novak
d18b0fbeb4 Handle API updated. 2015-07-03 09:52:52 +02:00
Bernhard Miklautz
bf73f4e4f1 Fix unchecked strdups
* add missing checks
* adapt function return values where necessary
* add initial test for settings
2015-06-22 19:09:59 +02:00
Armin Novak
db7753bc8b Added RemoveDirectoryA, clean up test directories. 2015-06-09 13:16:28 +02:00
Norbert Federa
1eff1a345e free can handle NULL perfectly fine 2015-05-11 09:07:39 +02:00
Bernhard Miklautz
850de59b55 winpr: add checks for *alloc
Add missing checks if memory allocation was successful. Also adapt
caller(s) when possible.
2015-04-08 11:34:37 +02:00
Armin Novak
afe8bd2a86 Fixed missing checks for invalid handle. 2015-03-31 15:18:45 +02:00
Bernhard Miklautz
1d7b3694a9 Integrate feedback from pull request (#2492)
* shell: add missing NULL checks
* thread: handle case where HAVE_EVENTFD_H isn't defined
* wlog: return NULL instead of 0
* wlog: use g_RootLog instead of WLog_GetRoot
  otherwise a new root might be initialized on uninit
* indentation and style fixes
2015-03-25 17:38:21 +01:00
Bernhard Miklautz
3c7662517c hardening
Start to add missing checks for:
* *alloc
* *_New
2015-03-25 17:38:21 +01:00
David FORT
552df08926 Implement ReadFile() and WriteFile() as handle operation 2015-03-16 21:29:19 +01:00
David FORT
52bd4469d9 Make handle operations static
This patch moves the handle operations in a static struct.
2015-03-16 10:31:26 +01:00
Armin Novak
4fda6b1e5a Using new handle cleanup structure 2015-03-11 17:57:01 +01:00
Armin Novak
8848d1d1fa Using handle close callback now. 2015-03-11 15:10:52 +01:00
Armin Novak
cd1782efaa Fixed NULL pointer dereference. 2014-11-16 16:47:38 +01:00
Armin Novak
b22b897389 Reformatted changed files. 2014-09-09 16:32:22 +02:00
Armin Novak
7e3a1b3073 Now using macro to generate module specific log tag. 2014-09-09 16:32:04 +02:00
Armin Novak
28ece6bb46 Replaced stdio logging with WLog 2014-09-09 16:31:46 +02:00
Bernhard Miklautz
6a49bcfe40 winpr: always build "monolitic"
winpr is now always build as single library.
The build option MONOLITHIC_BUILD doesn't influence this behavior anymore.

The only exception is winpr-makecert-tool which is still build as extra
library.

This obsoletes complex_libraries for winpr.
2014-07-10 11:10:58 +02:00
Emmanuel Ledoux
87ce88370a winpr-comm: added _HandleCreatorsLock to protect accesses to _HandleCreators 2014-07-03 11:20:46 +02:00
Emmanuel Ledoux
9fc225ac5d Merge branch 'ports'
Conflicts:
	channels/serial/client/serial_tty.c
2014-06-30 17:22:15 +02:00
Emmanuel Ledoux
d38a323526 winpr-comm, winpr-file: better initialization of the static variables 2014-06-19 12:03:36 +02:00
Hardening
9039a23de3 Silently handle EINTR and retry operation 2014-06-18 22:09:07 +02:00
Hardening
b4d756830a Don't forget to SetLastError() on disconnection
Otherwise if the last error was a ERROR_NO_DATA we have no indication that
the pipe has been closed.
2014-06-12 23:09:49 +02:00
Norbert Federa
aa2efaf573 winpr: rewrite named pipe sharing
Since commit 5e09e37d42 was basically unfixable,
here is a slightly different approach that should hopefully solve all
discovered issues and race conditions.
2014-05-28 13:54:08 +02:00
Norbert Federa
538cc2d4a8 winpr: fixed incorrect pipe reference count usage
- refcount is only relevant for servermode
- refcount was used uninitialized in clientmode
- credit for fix goes to @bmiklautz

Bug was introduced by 5e09e37d42
2014-05-26 21:24:34 +02:00
Bernhard Miklautz
e5fb854a49 winpr-file: harden GetNamePipeFileDescriptor
Ensure that GetNamePipeFileDescriptor returns an error
if the supplied handle isn't a named pipe.
2014-05-07 21:23:54 +02:00
Bernhard Miklautz
b817e92e5e cmake: mark required libraries for export 2014-04-23 10:16:02 +02:00
Emmanuel Ledoux
346c598bbe Introduced RegisterHandleCreator() to be used with CreateFile() 2014-04-22 17:00:14 +02:00
Emmanuel Ledoux
7e44488e0a winpr-file: introduced HANDLE_CREATOR type
winpr-comm: got a _CommHandleCreator
2014-04-18 19:25:25 +02:00
Emmanuel Ledoux
f9fc107c20 new functions: DefineCommDevice / QueryCommDevice / IsCommDevice 2014-04-18 17:18:08 +02:00
Marc-André Moreau
82ed4f0f38 libwinpr-comm: initial stubs 2014-04-02 15:51:28 -04:00
Martin Haimberger
3808705652 WriteFile and ReadFile does not check for INVALID_HANDLE_VALUE 2014-03-11 06:34:41 -07:00
Marc-André Moreau
315885c1eb libwinpr-file: fix improper status code in overlapped i/o 2014-02-28 11:24:44 -05:00
Marc-André Moreau
1697469ced libwinpr-file: implement further AIO-based overlapped I/O 2014-02-17 13:02:39 -05:00
Hardening
569ca5b62e Fix the behaviour ReadFile() and WriteFile() in non-blocking mode
These functions were not returning the correct values when treating
non-blocking file descriptor.
2014-02-07 15:19:46 +01:00
Marc-André Moreau
55565e056c freerdp: export targets 2013-10-28 23:06:39 -04:00
Bernhard Miklautz
96e267fcdf winpr-file: fixed memory leak in error case 2013-10-15 13:22:34 +02:00
Marc-André Moreau
0569de167d libwinpr-utils: further split wlog framework into more source files, add some thread safety for write operations 2013-10-02 13:38:21 -04:00
Marc-André Moreau
8695c5226b libwinpr-file: added more error checking 2013-10-01 12:03:08 -04:00