Merge pull request #1879 from aquesnel/check_formatting

Add checking the code formatting with astyle during CI builds (#1879)
This commit is contained in:
matt335672 2021-05-26 09:14:59 +01:00 committed by GitHub
commit ce10d3a1a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 1064 additions and 827 deletions

View File

@ -146,3 +146,32 @@ jobs:
- run: ./bootstrap
- run: scripts/install_cppcheck.sh $CPPCHECK_REPO $CPPCHECK_VER
- run: scripts/run_cppcheck.sh -v $CPPCHECK_VER
code_formatting_check:
name: code formatting check
runs-on: ubuntu-latest
env:
CC: gcc
# This is required to use a version of astyle other than that
# supplied with the operating system
ASTYLE_VER: 3.1
ASTYLE_REPO: https://svn.code.sf.net/p/astyle/code/tags
steps:
# This is currently the only way to get a version into
# the cache tag name - see https://github.com/actions/cache/issues/543
- run: |
echo "OS_VERSION=`lsb_release -sr`" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Cache astyle
uses: actions/cache@v2
env:
cache-name: cache-astyle
with:
path: ~/astyle.local
key: ${{ runner.os }}-${{ env.OS_VERSION }}-build-${{ env.cache-name }}-${{ env.ASTYLE_VER }}
- run: sudo scripts/install_astyle_dependencies_with_apt.sh
- run: scripts/install_astyle.sh $ASTYLE_REPO $ASTYLE_VER
- name: Format code with astyle
run: scripts/run_astyle.sh
- name: Check code formatting
run: git diff --exit-code

View File

@ -45,6 +45,14 @@
# For each directory in the command line, process all subdirectories recursively.
--recursive
# Exclude git submodule directories and generated files.
--exclude=libpainter
--exclude=librfxcodec
--exclude=xrdp_configure_options.h
# ignore errors from generated files that do not exist
--ignore-exclude-errors
# Preserve the original file's date and time modified.
--preserve-date
@ -53,4 +61,3 @@
--formatted
--lineend=linux

View File

@ -537,7 +537,7 @@ g_bytes_to_hexdump(const char *src, int len)
+ HEX_DUMP_NEWLINE_SIZE);
dump_number_lines = (len / HEX_DUMP_SOURCE_BYTES_PER_LINE) + 1; /* +1 to round up */
dump_length = (dump_number_lines *dump_line_length /* hex dump lines */
dump_length = (dump_number_lines * dump_line_length /* hex dump lines */
+ 1); /* terminating NULL */
dump_buffer = (char *)g_malloc(dump_length, 1);
if (dump_buffer == NULL)

View File

@ -22,7 +22,8 @@
* xfree86(base)->evdev keycode mapping
*/
int xfree86_to_evdev[137-8+1] = {
int xfree86_to_evdev[137 - 8 + 1] =
{
/* MDSW */ 203,
/* ESC */ 9,
/* AE01 */ 10,

View File

@ -44,7 +44,7 @@
#include <X11/XKBlib.h>
#include <locale.h>
extern int xfree86_to_evdev[137-8+1];
extern int xfree86_to_evdev[137 - 8 + 1];
int main(int argc, char **argv)
{
@ -52,7 +52,8 @@ int main(int argc, char **argv)
char text[256];
char *displayname = NULL;
char *outfname;
const char *sections[8] = {
const char *sections[8] =
{
"noshift", "shift", "altgr", "shiftaltgr",
"capslock", "capslockaltgr", "shiftcapslock", "shiftcapslockaltgr"
};
@ -139,9 +140,13 @@ int main(int argc, char **argv)
for (i = 8; i < 137; i++) /* Keycodes */
{
if (is_evdev)
e.keycode = xfree86_to_evdev[i-8];
{
e.keycode = xfree86_to_evdev[i - 8];
}
else
{
e.keycode = i;
}
nbytes = XLookupString(&e, text, 255, &ks, NULL);
text[nbytes] = 0;
char_count = mbstowcs(wtext, text, 255);

108
scripts/install_astyle.sh Executable file
View File

@ -0,0 +1,108 @@
#!/bin/sh
# Script to install a version of astyle in ~/astyle.local/
#
# Used by CI builds
#
# Currently only supports git repos as sources
#
# Usage: /path/to/install_astyle.sh <astyle-git-repo> <version-tag>
INSTALL_ROOT=~/astyle.local
# ----------------------------------------------------------------------------
# U S A G E
# ----------------------------------------------------------------------------
usage()
{
echo "** Usage: $0 <svn-tags-url> <tag-name>"
echo " e.g. $0 https://svn.code.sf.net/p/astyle/code/tags 3.1"
} >&2
# ----------------------------------------------------------------------------
# C A L L _ M A K E
#
# Calls make with the specified parameters, but only displays the error
# log if it fails
# ----------------------------------------------------------------------------
call_make()
{
# Disable set -e, if active
set_entry_opts=`set +o`
set +e
status=1
log=`mktemp /tmp/astyle-log.XXXXXXXXXX`
if [ -n "$log" ]; then
make "$@" >$log 2>&1
status=$?
if [ $status -ne 0 ]; then
cat $log >&2
fi
rm $log
fi
# Re-enable `set -e` if active before
$set_entry_opts
return $status
}
# ----------------------------------------------------------------------------
# M A I N
# ----------------------------------------------------------------------------
if [ $# -ne 2 ]; then
usage
exit 1
fi
REPO_URL="$1"
ASTYLE_VER="$2"
# Already installed?
exe=$INSTALL_ROOT/$ASTYLE_VER/usr/bin/astyle
if [ -x "$exe" ]; then
echo "astyle version $ASTYLE_VER is already installed at $exe" >&2
exit 0
fi
workdir=`mktemp -d /tmp/astyle.XXXXXXXXXX`
if [ -z "$workdir" ]; then
echo "** Unable to create temporary working directory" 2>&1
exit 1
fi
# Use a sub-process for the next bit to restrict the scope of 'set -e'
(
set -e ; # Exit sub-process on first error
# Put everything in this directory
FILESDIR=$INSTALL_ROOT/$ASTYLE_VER
svn checkout ${REPO_URL}/${ASTYLE_VER}/AStyle $workdir
cd $workdir
make_args="DESTDIR=$FILESDIR"
echo "Creating Makefiles..."
cmake .
echo "Making astyle..."
call_make $make_args
echo "Installing astyle..."
mkdir -p $FILESDIR
call_make install $make_args
# make install DESTDIR=~/astyle.local/3.1
)
status=$?
if [ $status -eq 0 ]; then
rm -rf $workdir
else
"** Script failed. Work dir is $workdir" >&2
fi
exit $status

View File

@ -0,0 +1,6 @@
#!/bin/sh
set -eufx
PACKAGES="subversion cmake"
apt-get -yq --no-install-suggests --no-install-recommends install $PACKAGES

74
scripts/run_astyle.sh Executable file
View File

@ -0,0 +1,74 @@
#!/bin/sh
# Script to run astyle on the code
#
# Usage: /path/to/run_astyle.sh
#
# Note: the script must be run from the root directory of the xrdp repository
INSTALL_ROOT=~/astyle.local
ASTYLE_FROM_XRDP=$INSTALL_ROOT/3.1/usr/bin/astyle
MIN_ASTYLE_VER="3.1"
# ----------------------------------------------------------------------------
# U S A G E
# ----------------------------------------------------------------------------
usage()
{
echo "** Usage: $0"
echo " e.g. $0"
} >&2
# ----------------------------------------------------------------------------
# M A I N
# ----------------------------------------------------------------------------
if [ $# -ne 0 ]; then
usage
exit 1
fi
# check if the built-in astyle meets the minimum requrements
ASTYLE_FROM_OS_VER_OUTPUT=`astyle --version | grep "Artistic Style Version" | cut -d' ' -f4`
ASTYLE=""
ERROR_MESSAGE=""
if [ ! -z "$ASTYLE_FROM_OS_VER_OUTPUT" ]; then
# astyle is installed, so check if it's version meets the minimum requirements
LOWEST_VERSION=`echo -e "$MIN_ASTYLE_VER\n$ASTYLE_FROM_OS_VER_OUTPUT" | sort -V | head -n1`
if [ "$MIN_ASTYLE_VER" = "$LOWEST_VERSION" ]; then
ASTYLE=astyle
else
ERROR_MESSAGE="The version of astyle installed does not meet the minimum version requirement: >= $MIN_ASTYLE_VER "
fi
else
ERROR_MESSAGE="astyle is not installed on the system path"
fi
if [ -z "$ASTYLE" ]; then
# astyle from the os is invlid, fallback to the xrdp version if it is installed
if [ -x "$ASTYLE_FROM_XRDP" ]; then
ASTYLE="$ASTYLE_FROM_XRDP"
ERROR_MESSAGE=""
else
ERROR_MESSAGE="${ERROR_MESSAGE}\nastyle $MIN_ASTYLE_VER is not installed at the expected path: $ASTYLE_FROM_XRDP"
fi
fi
if [ ! -z "$ERROR_MESSAGE" ]; then
echo "$ERROR_MESSAGE"
exit 1
fi
if [ ! -f "astyle_config.as" ]; then
echo "$0 must be run from the root xrdp repository directory which "
echo "contains the 'astyle_config.as' file."
exit 2
fi
ASTYLE_FLAGS="--options=astyle_config.as ./\*.c ./\*.h"
# Display the astyle version and command for debugging
"$ASTYLE" --version && {
echo Command: $ASTYLE $ASTYLE_FLAGS
"$ASTYLE" $ASTYLE_FLAGS
}

View File

@ -35,9 +35,9 @@ int
g_is_term(void);
int send_channel_data(int chan_id, const char *data, int size);
int send_rail_drawing_orders(char* data, int size);
int send_rail_drawing_orders(char *data, int size);
int main_cleanup(void);
int add_timeout(int msoffset, void (*callback)(void* data), void* data);
int add_timeout(int msoffset, void (*callback)(void *data), void *data);
#ifndef GSET_UINT8
#define GSET_UINT8(_ptr, _offset, _data) \

View File

@ -27,10 +27,10 @@
int devredir_init(void);
int devredir_deinit(void);
int devredir_data_in(struct stream* s, int chan_id, int chan_flags,
int devredir_data_in(struct stream *s, int chan_id, int chan_flags,
int length, int total_length);
int devredir_get_wait_objs(tbus* objs, int* count, int* timeout);
int devredir_get_wait_objs(tbus *objs, int *count, int *timeout);
int devredir_check_wait_objs(void);
/* misc stuff */

View File

@ -16,20 +16,20 @@
* limitations under the License.
*/
/* FIFO implementation to store a pointer to a user struct */
/* FIFO implementation to store a pointer to a user struct */
typedef struct fifo
{
long* user_data;
long *user_data;
int rd_ptr;
int wr_ptr;
int entries;
} FIFO;
int fifo_init(FIFO* fp, int num_entries);
int fifo_deinit(FIFO* fp);
int fifo_is_empty(FIFO* fp);
int fifo_insert(FIFO* fp, void* data);
void* fifo_remove(FIFO* fp);
void* fifo_peek(FIFO* fp);
int fifo_init(FIFO *fp, int num_entries);
int fifo_deinit(FIFO *fp);
int fifo_is_empty(FIFO *fp);
int fifo_insert(FIFO *fp, void *data);
void *fifo_remove(FIFO *fp);
void *fifo_peek(FIFO *fp);

View File

@ -105,18 +105,18 @@ struct irp
void *user_data;
};
IRP * devredir_irp_new(void);
IRP *devredir_irp_new(void);
/* As above, but allocates sufficent space for the specified
* pathname, and copies it in to the pathname field */
IRP * devredir_irp_with_pathname_new(const char *pathname);
IRP *devredir_irp_with_pathname_new(const char *pathname);
/* As above, but specifies a pathname length with pathname
* initially set to "". Use if you need to modify the pathname
* significantly */
IRP * devredir_irp_with_pathnamelen_new(unsigned int pathnamelen);
IRP *devredir_irp_with_pathnamelen_new(unsigned int pathnamelen);
int devredir_irp_delete(IRP *irp);
IRP * devredir_irp_find(tui32 completion_id);
IRP * devredir_irp_find_by_fileid(tui32 FileId);
IRP * devredir_irp_get_last(void);
IRP *devredir_irp_find(tui32 completion_id);
IRP *devredir_irp_find_by_fileid(tui32 FileId);
IRP *devredir_irp_get_last(void);
void devredir_irp_dump(void);
#endif /* end ifndef __IRP_H */

View File

@ -28,10 +28,10 @@ rail_init(void);
int
rail_deinit(void);
int
rail_data_in(struct stream* s, int chan_id, int chan_flags,
rail_data_in(struct stream *s, int chan_id, int chan_flags,
int length, int total_length);
int
rail_xevent(void* xevent);
rail_xevent(void *xevent);
int rail_request_title(int window_id);
#endif

View File

@ -122,16 +122,16 @@ int scard_send_list_readers(void *user_data,
int scard_send_get_status_change(void *user_data,
char *context, int context_bytes,
int wide, tui32 timeout,
tui32 num_readers, READER_STATE* rsa);
tui32 num_readers, READER_STATE *rsa);
int scard_send_connect(void *user_data,
char *context, int context_bytes, int wide,
READER_STATE* rs);
READER_STATE *rs);
int scard_send_reconnect(void *user_data,
char *context, int context_bytes,
char *card, int card_bytes,
READER_STATE* rs);
READER_STATE *rs);
int scard_send_begin_transaction(void *user_data,
char *context, int context_bytes,
@ -166,7 +166,7 @@ int scard_send_cancel(void *user_data,
char *context, int context_bytes);
int scard_send_get_attrib(void *user_data, char *card, int card_bytes,
READER_STATE* rs);
READER_STATE *rs);
/*
* Notes:

View File

@ -52,10 +52,10 @@
int sound_init(void);
int sound_deinit(void);
int sound_get_wait_objs(tbus* objs, int* count, int* timeout);
int sound_get_wait_objs(tbus *objs, int *count, int *timeout);
int sound_check_wait_objs(void);
int sound_data_in(struct stream* s, int chan_id, int chan_flags,
int sound_data_in(struct stream *s, int chan_id, int chan_flags,
int length, int total_length);
#endif

View File

@ -33,7 +33,7 @@ xcommon_get_local_time(void);
int
xcommon_init(void);
int
xcommon_get_wait_objs(tbus* objs, int* count, int* timeout);
xcommon_get_wait_objs(tbus *objs, int *count, int *timeout);
int
xcommon_check_wait_objs(void);
void

View File

@ -77,13 +77,15 @@
#define SESMAN_CFG_SESS_POLICY_UBDI_S "UBDI"
#define SESMAN_CFG_SESS_POLICY_UBDC_S "UBDC"
enum SESMAN_CFG_SESS_POLICY_BITS {
enum SESMAN_CFG_SESS_POLICY_BITS
{
SESMAN_CFG_SESS_POLICY_D = 0x01,
SESMAN_CFG_SESS_POLICY_I = 0x02,
SESMAN_CFG_SESS_POLICY_C = 0x04
};
enum SESMAN_CFG_SESS_POLICY {
enum SESMAN_CFG_SESS_POLICY
{
SESMAN_CFG_SESS_POLICY_DFLT = 0,
SESMAN_CFG_SESS_POLICY_UBD = SESMAN_CFG_SESS_POLICY_D,
SESMAN_CFG_SESS_POLICY_UBI = SESMAN_CFG_SESS_POLICY_I,
@ -226,22 +228,22 @@ struct config_sesman
* @var auth_file_path
* @brief Auth file path
*/
char* auth_file_path;
char *auth_file_path;
/**
* @var vnc_params
* @brief Xvnc additional parameter list
*/
struct list* vnc_params;
struct list *vnc_params;
/**
* @var rdp_params
* @brief X11rdp additional parameter list
*/
struct list* rdp_params;
struct list *rdp_params;
/**
* @var xorg_params
* @brief Xorg additional parameter list
*/
struct list* xorg_params;
struct list *xorg_params;
/**
* @var log
* @brief Log configuration struct
@ -262,12 +264,12 @@ struct config_sesman
* @var env_names
* @brief environment variable name list
*/
struct list* env_names;
struct list *env_names;
/**
* @var env_values
* @brief environment variable value list
*/
struct list* env_values;
struct list *env_values;
};
/**
@ -279,7 +281,7 @@ struct config_sesman
* @post pass return value to config_free() to prevent memory leaks
*
*/
struct config_sesman*
struct config_sesman *
config_read(const char *sesman_ini);
/**

View File

@ -37,7 +37,7 @@
* @return a struct SCP_CONNECTION* object on success, NULL otherwise
*
*/
struct SCP_CONNECTION*
struct SCP_CONNECTION *
scp_connection_create(int sck);
/**
@ -47,6 +47,6 @@ scp_connection_create(int sck);
*
*/
void
scp_connection_destroy(struct SCP_CONNECTION* c);
scp_connection_destroy(struct SCP_CONNECTION *c);
#endif

View File

@ -37,59 +37,59 @@
* @return a struct SCP_SESSION* object on success, NULL otherwise
*
*/
struct SCP_SESSION*
struct SCP_SESSION *
scp_session_create(void);
int
scp_session_set_type(struct SCP_SESSION* s, tui8 type);
scp_session_set_type(struct SCP_SESSION *s, tui8 type);
int
scp_session_set_version(struct SCP_SESSION* s, tui32 version);
scp_session_set_version(struct SCP_SESSION *s, tui32 version);
int
scp_session_set_height(struct SCP_SESSION* s, tui16 h);
scp_session_set_height(struct SCP_SESSION *s, tui16 h);
int
scp_session_set_width(struct SCP_SESSION* s, tui16 w);
scp_session_set_width(struct SCP_SESSION *s, tui16 w);
int
scp_session_set_bpp(struct SCP_SESSION* s, tui8 bpp);
scp_session_set_bpp(struct SCP_SESSION *s, tui8 bpp);
int
scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr);
scp_session_set_rsr(struct SCP_SESSION *s, tui8 rsr);
int
scp_session_set_locale(struct SCP_SESSION* s, const char *str);
scp_session_set_locale(struct SCP_SESSION *s, const char *str);
int
scp_session_set_username(struct SCP_SESSION* s, const char *str);
scp_session_set_username(struct SCP_SESSION *s, const char *str);
int
scp_session_set_password(struct SCP_SESSION* s, const char *str);
scp_session_set_password(struct SCP_SESSION *s, const char *str);
int
scp_session_set_domain(struct SCP_SESSION* s, const char *str);
scp_session_set_domain(struct SCP_SESSION *s, const char *str);
int
scp_session_set_program(struct SCP_SESSION* s, const char *str);
scp_session_set_program(struct SCP_SESSION *s, const char *str);
int
scp_session_set_directory(struct SCP_SESSION* s, const char *str);
scp_session_set_directory(struct SCP_SESSION *s, const char *str);
int
scp_session_set_client_ip(struct SCP_SESSION* s, const char *str);
scp_session_set_client_ip(struct SCP_SESSION *s, const char *str);
int
scp_session_set_hostname(struct SCP_SESSION* s, const char *str);
scp_session_set_hostname(struct SCP_SESSION *s, const char *str);
int
scp_session_set_addr(struct SCP_SESSION* s, int type, const void* addr);
scp_session_set_addr(struct SCP_SESSION *s, int type, const void *addr);
int
scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display);
scp_session_set_display(struct SCP_SESSION *s, SCP_DISPLAY display);
int
scp_session_set_errstr(struct SCP_SESSION* s, const char *str);
scp_session_set_errstr(struct SCP_SESSION *s, const char *str);
int
scp_session_set_guid(struct SCP_SESSION *s, const tui8 *guid);
@ -101,6 +101,6 @@ scp_session_set_guid(struct SCP_SESSION *s, const tui8 *guid);
*
*/
void
scp_session_destroy(struct SCP_SESSION* s);
scp_session_destroy(struct SCP_SESSION *s);
#endif

View File

@ -39,7 +39,7 @@
*
*/
int
scp_tcp_force_recv(int sck, char* data, int len);
scp_tcp_force_recv(int sck, char *data, int len);
/**
*
@ -51,7 +51,7 @@ scp_tcp_force_recv(int sck, char* data, int len);
*
*/
int
scp_tcp_force_send(int sck, char* data, int len);
scp_tcp_force_send(int sck, char *data, int len);
/**
*
@ -63,6 +63,6 @@ scp_tcp_force_send(int sck, char* data, int len);
*
*/
int
scp_tcp_bind(int sck, char* addr, char* port);
scp_tcp_bind(int sck, char *addr, char *port);
#endif

View File

@ -66,8 +66,8 @@
struct SCP_CONNECTION
{
int in_sck;
struct stream* in_s;
struct stream* out_s;
struct stream *in_s;
struct stream *out_s;
};
struct SCP_SESSION
@ -79,19 +79,19 @@ struct SCP_SESSION
tui8 bpp;
tui8 rsr;
char locale[18];
char* username;
char* password;
char* hostname;
char *username;
char *password;
char *hostname;
tui8 addr_type;
tui32 ipv4addr;
tui8 ipv6addr[16];
SCP_DISPLAY display;
char* errstr;
struct SCP_MNG_DATA* mng;
char* domain;
char* program;
char* directory;
char* client_ip;
char *errstr;
struct SCP_MNG_DATA *mng;
char *domain;
char *program;
char *directory;
char *client_ip;
tui8 guid[16];
};

View File

@ -39,7 +39,7 @@
*
*/
enum SCP_CLIENT_STATES_E
scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
scp_v0c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
/* server API */
/**
@ -52,7 +52,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
*
*/
enum SCP_SERVER_STATES_E
scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk);
scp_v0s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk);
/**
*
@ -61,7 +61,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk);
*
*/
enum SCP_SERVER_STATES_E
scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d, const tui8 *guid);
scp_v0s_allow_connection(struct SCP_CONNECTION *c, SCP_DISPLAY d, const tui8 *guid);
/**
*
@ -70,7 +70,7 @@ scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d, const tui8 *gu
*
*/
enum SCP_SERVER_STATES_E
scp_v0s_deny_connection(struct SCP_CONNECTION* c);
scp_v0s_deny_connection(struct SCP_CONNECTION *c);
/**
* @brief send reply to an authentication request
@ -79,6 +79,6 @@ scp_v0s_deny_connection(struct SCP_CONNECTION* c);
* @return
*/
enum SCP_SERVER_STATES_E
scp_v0s_replyauthentication(struct SCP_CONNECTION* c, unsigned short int value);
scp_v0s_replyauthentication(struct SCP_CONNECTION *c, unsigned short int value);
#endif

View File

@ -32,32 +32,32 @@
/* client API */
/* 001 */
enum SCP_CLIENT_STATES_E
scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
scp_v1c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
/* 004 */
enum SCP_CLIENT_STATES_E
scp_v1c_resend_credentials(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
scp_v1c_resend_credentials(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
/* 021 */
enum SCP_CLIENT_STATES_E
scp_v1c_pwd_change(struct SCP_CONNECTION* c, char* newpass);
scp_v1c_pwd_change(struct SCP_CONNECTION *c, char *newpass);
/* 022 */
enum SCP_CLIENT_STATES_E
scp_v1c_pwd_change_cancel(struct SCP_CONNECTION* c);
scp_v1c_pwd_change_cancel(struct SCP_CONNECTION *c);
/* 041 */
enum SCP_CLIENT_STATES_E
scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
struct SCP_DISCONNECTED_SESSION** s);
scp_v1c_get_session_list(struct SCP_CONNECTION *c, int *scount,
struct SCP_DISCONNECTED_SESSION **s);
/* 043 */
enum SCP_CLIENT_STATES_E
scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
scp_v1c_select_session(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
SCP_SID sid);
/* 044 */
enum SCP_CLIENT_STATES_E
scp_v1c_select_session_cancel(struct SCP_CONNECTION* c);
scp_v1c_select_session_cancel(struct SCP_CONNECTION *c);
#endif

View File

@ -32,7 +32,7 @@
/* client API */
/* 001 */
enum SCP_CLIENT_STATES_E
scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
scp_v1c_mng_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
/* 004 * /
enum SCP_CLIENT_STATES_E
@ -49,7 +49,7 @@ scp_v1c_pwd_change_cancel(struct SCP_CONNECTION* c);
/* 041 */
enum SCP_CLIENT_STATES_E
scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
struct SCP_DISCONNECTED_SESSION** s);
scp_v1c_mng_get_session_list(struct SCP_CONNECTION *c, int *scount,
struct SCP_DISCONNECTED_SESSION **s);
#endif

View File

@ -42,7 +42,7 @@
* that should be free()d
*/
enum SCP_SERVER_STATES_E
scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk);
scp_v1s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk);
/**
*
@ -53,35 +53,35 @@ scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk);
*/
/* 002 */
enum SCP_SERVER_STATES_E
scp_v1s_deny_connection(struct SCP_CONNECTION* c, const char *reason);
scp_v1s_deny_connection(struct SCP_CONNECTION *c, const char *reason);
enum SCP_SERVER_STATES_E
scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
scp_v1s_request_password(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
const char *reason);
/* 020 */
enum SCP_SERVER_STATES_E
scp_v1s_request_pwd_change(struct SCP_CONNECTION* c, char* reason, char* npw);
scp_v1s_request_pwd_change(struct SCP_CONNECTION *c, char *reason, char *npw);
/* 023 */
enum SCP_SERVER_STATES_E
scp_v1s_pwd_change_error(struct SCP_CONNECTION* c, char* error, int retry, char* npw);
scp_v1s_pwd_change_error(struct SCP_CONNECTION *c, char *error, int retry, char *npw);
/* 030 */
enum SCP_SERVER_STATES_E
scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d);
scp_v1s_connect_new_session(struct SCP_CONNECTION *c, SCP_DISPLAY d);
/* 032 */
enum SCP_SERVER_STATES_E
scp_v1s_connection_error(struct SCP_CONNECTION* c, const char *error);
scp_v1s_connection_error(struct SCP_CONNECTION *c, const char *error);
/* 040 */
enum SCP_SERVER_STATES_E
scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt,
struct SCP_DISCONNECTED_SESSION* ds, SCP_SID* sid);
scp_v1s_list_sessions(struct SCP_CONNECTION *c, int sescnt,
struct SCP_DISCONNECTED_SESSION *ds, SCP_SID *sid);
/* 046 was: 031 struct SCP_DISCONNECTED_SESSION* ds, */
enum SCP_SERVER_STATES_E
scp_v1s_reconnect_session(struct SCP_CONNECTION* c, SCP_DISPLAY d);
scp_v1s_reconnect_session(struct SCP_CONNECTION *c, SCP_DISPLAY d);
#endif

View File

@ -40,7 +40,7 @@
* that should be free()d
*/
enum SCP_SERVER_STATES_E
scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s);
scp_v1s_mng_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s);
/**
*
@ -50,7 +50,7 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s);
*/
/* 002 */
enum SCP_SERVER_STATES_E
scp_v1s_mng_allow_connection(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
scp_v1s_mng_allow_connection(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
/**
*
@ -61,7 +61,7 @@ scp_v1s_mng_allow_connection(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
*/
/* 003 */
enum SCP_SERVER_STATES_E
scp_v1s_mng_deny_connection(struct SCP_CONNECTION* c, const char *reason);
scp_v1s_mng_deny_connection(struct SCP_CONNECTION *c, const char *reason);
/**
*
@ -71,8 +71,8 @@ scp_v1s_mng_deny_connection(struct SCP_CONNECTION* c, const char *reason);
*/
/* 006 */
enum SCP_SERVER_STATES_E
scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
int sescnt, struct SCP_DISCONNECTED_SESSION* ds);
scp_v1s_mng_list_sessions(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
int sescnt, struct SCP_DISCONNECTED_SESSION *ds);
// SCP_SID* sid);
#endif

View File

@ -42,6 +42,6 @@
* It this memory needs to be g_free()d
*
*/
enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s);
enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s);
#endif

View File

@ -39,7 +39,7 @@
* @param socket the connection socket
*
*/
void*
scp_process_start(void* sck);
void *
scp_process_start(void *sck);
#endif

View File

@ -38,6 +38,6 @@
*
*/
void
scp_v0_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
#endif

View File

@ -36,6 +36,6 @@
*
*/
void
scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
#endif

View File

@ -36,6 +36,6 @@
*
*/
void
scp_v1_mng_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
#endif

View File

@ -81,8 +81,8 @@ struct session_item
struct session_chain
{
struct session_chain* next;
struct session_item* item;
struct session_chain *next;
struct session_item *item;
};
/**
@ -91,11 +91,11 @@ struct session_chain
* @return session data or 0
*
*/
struct session_item*
struct session_item *
session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip);
#ifndef session_find_item
#define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f);
#define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f);
#endif
/**
@ -137,7 +137,7 @@ session_sigkill_all(void);
* @return a pointer to the session descriptor on success, NULL otherwise
*
*/
struct session_item*
struct session_item *
session_get_bypid(int pid);
/**
@ -147,7 +147,7 @@ session_get_bypid(int pid);
* @return a pointer to the session descriptor on success, NULL otherwise
*
*/
struct SCP_DISCONNECTED_SESSION*
struct SCP_DISCONNECTED_SESSION *
session_get_byuser(const char *user, int *cnt, unsigned char flags);
/**

View File

@ -59,7 +59,7 @@ sig_sesman_session_end(int sig);
* @brief signal handling thread
*
*/
void*
sig_handler_thread(void* arg);
void *
sig_handler_thread(void *arg);
#endif

View File

@ -37,7 +37,7 @@
*
*/
int
tcp_force_recv(int sck, char* data, int len);
tcp_force_recv(int sck, char *data, int len);
/**
*
@ -49,7 +49,7 @@ tcp_force_recv(int sck, char* data, int len);
*
*/
int
tcp_force_send(int sck, char* data, int len);
tcp_force_send(int sck, char *data, int len);
/**
*
@ -61,6 +61,6 @@ tcp_force_send(int sck, char* data, int len);
*
*/
int
tcp_bind(int sck, char* addr, char* port);
tcp_bind(int sck, char *addr, char *port);
#endif

View File

@ -17,19 +17,20 @@
#include "utils.h"
namespace Ui {
class MainWindow;
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
private:
Ui::MainWindow *ui;
void *wtsChannel;
QSystemTrayIcon *trayIcon;
@ -44,9 +45,9 @@ private:
int initWtsChannel();
int deinitWtsChannel();
void setStatusMsg(QString msg);
void closeEvent(QCloseEvent * event);
void closeEvent(QCloseEvent *event);
private slots:
private slots:
void onBtnRefreshClicked();
void onBtnUnmountClicked();
void onActionQuit();

View File

@ -14,73 +14,73 @@
typedef struct stream
{
char* data; /* holds stream data */
char* pos; /* current read/write position */
char *data; /* holds stream data */
char *pos; /* current read/write position */
int size; /* number of bytes in data */
} STREAM;
#define qstream_new(_s, _size) \
do \
{ \
do \
{ \
(_s).data = (char *) malloc(_size); \
(_s).pos = (_s).data; \
(_s).size = (_size); \
} \
while (0)
} \
while (0)
#define qstream_new_zero(_s, _size) \
do \
{ \
do \
{ \
(_s).data = (char *) calloc((_size), 1); \
(_s).pos = (_s).data; \
(_s).size = (_size); \
} \
while (0)
} \
while (0)
#define qstream_free(_s) \
do \
{ \
do \
{ \
if ((_s)->data) \
free((_s)->data); \
} \
while (0)
} \
while (0)
#define qstream_set_pos(_s, _p) \
do \
{ \
do \
{ \
(_s)->pos = (_s)->data + (_p); \
} \
while (0)
} \
while (0)
#define qstream_inc_pos(_s, _v) \
do \
{ \
do \
{ \
(_s)->pos += (_v); \
} \
while (0)
} \
while (0)
#define qstream_rd_u8(_s, _v) \
do \
{ \
do \
{ \
(_v) = *((unsigned char *) ((_s)->pos)); \
(_s)->pos++; \
} \
while (0)
} \
while (0)
#define qstream_rd_u16(_s, _v) \
do \
{ \
do \
{ \
(_v) = (unsigned short) \
( \
(*((unsigned char *) ((_s)->pos + 0)) << 0) | \
(*((unsigned char *) ((_s)->pos + 1)) << 8) \
); \
(_s)->pos += 2; \
} while (0)
} while (0)
#define qstream_rd_u32(_s, _v) \
do \
{ \
do \
{ \
(_v) = (unsigned int) \
( \
(*((unsigned char *) ((_s)->pos + 0)) << 0) | \
@ -89,27 +89,27 @@ do \
(*((unsigned char *) ((_s)->pos + 3)) << 24) \
); \
(_s)->pos += 4; \
} while (0)
} while (0)
#define qstream_wr_u8(_s, _v) \
do \
{ \
do \
{ \
*((_s)->pos) = (unsigned char) (_v); \
(_s)->pos++; \
} while (0)
} while (0)
#define qstream_wr_u16(_s, _v) \
do \
{ \
do \
{ \
*((_s)->pos) = (unsigned char) ((_v) >> 0); \
(_s)->pos++; \
*((_s)->pos) = (unsigned char) ((_v) >> 8); \
(_s)->pos++; \
} while (0)
} while (0)
#define qstream_wr_u32(_s, _v) \
do \
{ \
do \
{ \
*((_s)->pos) = (unsigned char) ((_v) >> 0); \
(_s)->pos++; \
*((_s)->pos) = (unsigned char) ((_v) >> 8); \
@ -118,7 +118,7 @@ do \
(_s)->pos++; \
*((_s)->pos) = (unsigned char) ((_v) >> 24); \
(_s)->pos++; \
} while (0)
} while (0)
/* list of commands we support; this list should match the one in */
/* NeutrinoRDP channels/tcutils/tcutils_main.h */
@ -141,7 +141,7 @@ enum TCU_UMOUNT_ERROR
class Utils
{
public:
public:
Utils();
static int getMountList(void *wtsChannel, QList<QListWidgetItem *> *itemList);
static int unmountDevice(void *wtsChannel, QString device, QStatusBar *statusBar);

View File

@ -199,8 +199,8 @@ START_TEST(test_strnjoin__when_always__then_doesnt_write_beyond_end_of_destinati
{
/* setup */
const char *src[] = { "a","b","c"};
char result[5+1+1]; /* a-b-c + term null + guard value */
const char *src[] = { "a", "b", "c"};
char result[5 + 1 + 1]; /* a-b-c + term null + guard value */
/* test */

View File

@ -20,19 +20,19 @@
class Decoder : public QObject
{
Q_OBJECT
public:
public:
explicit Decoder(QObject *parent = 0);
int init(QString filename);
//int deinit();
//int setWindow(QRectangle rect);
private:
private:
void *channel;
QRect mainWindowGeometry;
signals:
signals:
public slots:
public slots:
void onGeometryChanged(QRect *geometry);
};

View File

@ -22,8 +22,8 @@
/* ffmpeg related stuff */
extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
#define VCR_PLAY 1
@ -36,18 +36,18 @@ class DemuxMedia : public QObject
{
Q_OBJECT
public:
public:
explicit DemuxMedia(QObject *parent = 0, QQueue<MediaPacket *> *videoQueue = 0,
void *channel = 0, int stream_id = 101);
void setVcrOp(int op);
int clear();
public slots:
public slots:
void startDemuxing();
void onMediaSeek(int value);
private:
private:
QMutex vcrMutex;
int vcrFlag;
void *channel;
@ -65,10 +65,10 @@ private:
void updateMediaPos();
signals:
signals:
void onMediaRestarted();
signals:
signals:
void onElapsedtime(int val); /* in hundredth of a sec */
};

View File

@ -3,22 +3,23 @@
#include <QDialog>
namespace Ui {
class DlgAbout;
namespace Ui
{
class DlgAbout;
}
class DlgAbout : public QDialog
{
Q_OBJECT
public:
public:
explicit DlgAbout(QWidget *parent = 0);
~DlgAbout();
private:
private:
Ui::DlgAbout *ui;
private slots:
private slots:
void onOk();
};

View File

@ -38,8 +38,8 @@
/* ffmpeg related stuff */
extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
#define VCR_PLAY 1
@ -57,17 +57,17 @@ class MainWindow : public QMainWindow
{
Q_OBJECT
public:
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
signals:
signals:
void onGeometryChanged(int x, int y, int width, int height);
public slots:
public slots:
void onSliderValueChanged(int value);
private slots:
private slots:
void on_actionOpen_Media_File_triggered();
void on_actionExit_triggered();
@ -84,12 +84,12 @@ private slots:
void onVolSliderValueChanged(int value);
protected:
protected:
void resizeEvent(QResizeEvent *e);
void closeEvent(QCloseEvent *e);
void moveEvent(QMoveEvent *e);
private:
private:
Ui::MainWindow *ui;
/* for UI */

View File

@ -3,7 +3,7 @@
class MediaPacket
{
public:
public:
MediaPacket();
void *av_pkt;

View File

@ -21,15 +21,15 @@
/* ffmpeg related stuff */
extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
class OurInterface : public QObject
{
Q_OBJECT
public:
public:
explicit OurInterface(QObject *parent = 0);
/* public methods */
@ -45,14 +45,14 @@ public:
void setVcrOp(int op);
int setVolume(int volume);
public slots:
public slots:
void onGeometryChanged(int x, int y, int width, int height);
signals:
signals:
void on_ErrorMsg(QString title, QString msg);
void onMediaDurationInSeconds(int duration);
private:
private:
/* private stuff */

View File

@ -19,8 +19,8 @@
/* ffmpeg related stuff */
extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
#define VCR_PLAY 1
@ -33,7 +33,7 @@ class PlayAudio : public QObject
{
Q_OBJECT
public:
public:
explicit PlayAudio(QObject *parent = 0,
QQueue<MediaPacket *> *audioQueue = 0,
QMutex *sendMutex = 0,
@ -42,10 +42,10 @@ public:
void setVcrOp(int op);
public slots:
public slots:
void play();
private:
private:
QQueue<MediaPacket *> *audioQueue;
QMutex *sendMutex;
QMutex vcrMutex;

View File

@ -20,8 +20,8 @@
/* ffmpeg related stuff */
extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
#define VCR_PLAY 1
@ -34,7 +34,7 @@ class PlayVideo : public QObject
{
Q_OBJECT
public:
public:
explicit PlayVideo(QObject *parent = 0,
QQueue<MediaPacket *> *videoQueue = 0,
QMutex *sendMutex = 0,
@ -46,29 +46,29 @@ public:
//void setVcrOp(int op);
//void onMediaRestarted();
public slots:
public slots:
void play();
//signals:
// void onElapsedtime(int val); /* in hundredth of a sec */
//signals:
// void onElapsedtime(int val); /* in hundredth of a sec */
private:
private:
QQueue<MediaPacket *> *videoQueue;
// int vcrFlag;
// QMutex vcrMutex;
// int vcrFlag;
// QMutex vcrMutex;
QMutex *sendMutex;
// QMutex posMutex;
// int64_t la_seekPos; /* locked access; must hold posMutex */
// QMutex posMutex;
// int64_t la_seekPos; /* locked access; must hold posMutex */
void *channel;
int stream_id;
int fps;
// int64_t elapsedTime; /* elapsed time in usecs since play started */
// int64_t pausedTime; /* time at which stream was paused */
// bool isStopped;
// int64_t elapsedTime; /* elapsed time in usecs since play started */
// int64_t pausedTime; /* time at which stream was paused */
// bool isStopped;
// void updateMediaPos();
// void clearVideoQ();
// void updateMediaPos();
// void clearVideoQ();
};
#endif // PLAYVIDEO_H

View File

@ -1133,8 +1133,9 @@ dynamic_monitor_data(intptr_t id, int chan_id, char *data, int bytes)
/* redraw */
xrdp_bitmap_invalidate(wm->screen, 0);
struct xrdp_mod* v = wm->mm->mod;
if (v != 0) {
struct xrdp_mod *v = wm->mm->mod;
if (v != 0)
{
v->mod_server_version_message(v);
v->mod_server_monitor_resize(v, session_width, session_height);
v->mod_server_monitor_full_invalidate(v, session_width, session_height);

View File

@ -53,11 +53,11 @@ struct xrdp_mod
int (*mod_frame_ack)(struct xrdp_mod *v, int flags, int frame_id);
int (*mod_suppress_output)(struct xrdp_mod *v, int suppress,
int left, int top, int right, int bottom);
int (*mod_server_monitor_resize)(struct xrdp_mod* v,
int (*mod_server_monitor_resize)(struct xrdp_mod *v,
int width, int height);
int (*mod_server_monitor_full_invalidate)(struct xrdp_mod* v,
int (*mod_server_monitor_full_invalidate)(struct xrdp_mod *v,
int width, int height);
int (*mod_server_version_message)(struct xrdp_mod* v);
int (*mod_server_version_message)(struct xrdp_mod *v);
tintptr mod_dumby[100 - 14]; /* align, 100 minus the number of mod
functions above */
/* server functions */

View File

@ -337,7 +337,9 @@ xrdpvr_get_frame(void **av_pkt_ret, int *is_video_frame, int *delay_in_us)
//printf("xrdpvr_get_frame:\n");
/* alloc an AVPacket */
if ((av_pkt = (AVPacket *) malloc(sizeof(AVPacket))) == NULL)
{
return -1;
}
/* read one frame into AVPacket */
if (av_read_frame(g_psi.p_format_ctx, av_pkt) < 0)
@ -491,7 +493,7 @@ xrdpvr_play_frame(void *channel, int stream_id, int *videoTimeout,
bsfc = g_psi.bsfc;
while (bsfc != 0)
{
new_pkt= av_pkt;
new_pkt = av_pkt;
error = av_bitstream_filter_filter(bsfc, g_psi.p_video_codec_ctx, 0,
&new_pkt.data, &new_pkt.size,
av_pkt.data, av_pkt.size,
@ -801,7 +803,7 @@ xrdpvr_create_metadata_file(void *channel, char *filename)
int len;
int fd;
if ((fd = open(filename , O_RDONLY)) < 0)
if ((fd = open(filename, O_RDONLY)) < 0)
{
return -1;
}

View File

@ -51,11 +51,11 @@ struct mod
int (*mod_frame_ack)(struct mod *v, int flags, int frame_id);
int (*mod_suppress_output)(struct mod *v, int suppress,
int left, int top, int right, int bottom);
int (*mod_server_monitor_resize)(struct mod* v,
int (*mod_server_monitor_resize)(struct mod *v,
int width, int height);
int (*mod_server_monitor_full_invalidate)(struct mod* v,
int (*mod_server_monitor_full_invalidate)(struct mod *v,
int width, int height);
int (*mod_server_version_message)(struct mod* v);
int (*mod_server_version_message)(struct mod *v);
tintptr mod_dumby[100 - 14]; /* align, 100 minus the number of mod
functions above */
/* server functions */