Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
a1739b10
Commit
a1739b10
authored
17 years ago
by
rds
Browse files
Options
Downloads
Patches
Plain Diff
xremote reorganisation
parent
086fd6a9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/zmapView/zmapViewRemoteReceive.c
+866
-0
866 additions, 0 deletions
src/zmapView/zmapViewRemoteReceive.c
src/zmapView/zmapViewRemoteSend.c
+248
-0
248 additions, 0 deletions
src/zmapView/zmapViewRemoteSend.c
with
1114 additions
and
0 deletions
src/zmapView/zmapViewRemoteReceive.c
0 → 100755
+
866
−
0
View file @
a1739b10
This diff is collapsed.
Click to expand it.
src/zmapView/zmapViewRemoteSend.c
0 → 100755
+
248
−
0
View file @
a1739b10
/* File: zmapViewRemoteSend.c
* Author: Roy Storey (rds@sanger.ac.uk)
* Copyright (c) 2007: Genome Research Ltd.
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* originally written by:
*
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
* Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk
*
* Description:
*
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited: Jul 16 15:51 2007 (rds)
* Created: Mon Jul 16 13:48:20 2007 (rds)
* CVS info: $Id: zmapViewRemoteSend.c,v 1.1 2007-07-18 13:49:28 rds Exp $
*-------------------------------------------------------------------
*/
#include
<string.h>
#include
<ZMap/zmapUtils.h>
#include
<ZMap/zmapUtilsXRemote.h>
#include
<zmapView_P.h>
static
void
send_client_command
(
ZMapXRemoteObj
client
,
ZMapXMLParser
parser
,
GString
*
command_string
,
ZMapXMLTagHandler
tag_handler
);
static
int
xml_event_to_buffer
(
ZMapXMLWriter
writer
,
char
*
xml
,
int
len
,
gpointer
user_data
);
/* xml event callbacks */
static
gboolean
xml_zmap_start_cb
(
gpointer
user_data
,
ZMapXMLElement
element
,
ZMapXMLParser
parser
);
static
gboolean
xml_response_start_cb
(
gpointer
user_data
,
ZMapXMLElement
element
,
ZMapXMLParser
parser
);
static
gboolean
xml_error_end_cb
(
gpointer
user_data
,
ZMapXMLElement
element
,
ZMapXMLParser
parser
);
static
gboolean
xml_zmap_end_cb
(
gpointer
user_data
,
ZMapXMLElement
element
,
ZMapXMLParser
parser
);
static
ZMapXMLUtilsEventStackStruct
wrap_start_G
[]
=
{
{
ZMAPXML_START_ELEMENT_EVENT
,
"zmap"
,
ZMAPXML_EVENT_DATA_NONE
,
{
0
}},
{
ZMAPXML_ATTRIBUTE_EVENT
,
"action"
,
ZMAPXML_EVENT_DATA_QUARK
,
{
NULL
}},
{
0
}
},
wrap_end_G
[]
=
{
{
ZMAPXML_END_ELEMENT_EVENT
,
"zmap"
,
ZMAPXML_EVENT_DATA_NONE
,
{
0
}},
{
0
}
};
static
ZMapXMLObjTagFunctionsStruct
response_starts_G
[]
=
{
{
"zmap"
,
xml_zmap_start_cb
},
{
"response"
,
xml_response_start_cb
},
{
NULL
,
NULL
}
};
static
ZMapXMLObjTagFunctionsStruct
response_ends_G
[]
=
{
{
"zmap"
,
xml_zmap_end_cb
},
{
"error"
,
xml_error_end_cb
},
{
NULL
,
NULL
}
};
static
gboolean
view_remote_send_debug_G
=
FALSE
;
gboolean
zmapViewRemoteSendCommand
(
ZMapView
view
,
char
*
action
,
GArray
*
xml_events
,
ZMapXMLObjTagFunctions
start_handlers
,
ZMapXMLObjTagFunctions
end_handlers
,
gpointer
*
handler_data
)
{
ZMapXRemoteObj
xremote
;
gboolean
yield
=
FALSE
;
if
((
xremote
=
view
->
xremote_client
))
{
ZMapXMLTagHandlerWrapperStruct
wrapper_data
=
{
NULL
};
ZMapXMLTagHandlerStruct
common_data
=
{
FALSE
,
NULL
};
ZMapXMLUtilsEventStack
wrap_ptr
;
ZMapXMLWriter
xml_creator
;
ZMapXMLParser
parser
;
GString
*
full_text
=
g_string_sized_new
(
512
);
wrapper_data
.
tag_handler
=
&
common_data
;
wrapper_data
.
user_data
=
handler_data
;
parser
=
zMapXMLParserCreate
(
&
wrapper_data
,
FALSE
,
FALSE
);
if
(
!
xml_events
)
xml_events
=
g_array_sized_new
(
FALSE
,
FALSE
,
sizeof
(
ZMapXMLWriterEventStruct
),
5
);
wrap_ptr
=
&
wrap_start_G
[
1
];
wrap_ptr
->
value
.
s
=
action
;
xml_events
=
zMapXMLUtilsAddStackToEventsArrayStart
(
&
wrap_start_G
[
0
],
xml_events
);
xml_events
=
zMapXMLUtilsAddStackToEventsArray
(
&
wrap_end_G
[
0
],
xml_events
);
xml_creator
=
zMapXMLWriterCreate
(
xml_event_to_buffer
,
full_text
);
if
(
!
start_handlers
)
start_handlers
=
&
response_starts_G
[
0
];
if
(
!
end_handlers
)
end_handlers
=
&
response_ends_G
[
0
];
zMapXMLParserSetMarkupObjectTagHandlers
(
parser
,
start_handlers
,
end_handlers
);
if
((
zMapXMLWriterProcessEvents
(
xml_creator
,
xml_events
))
==
ZMAPXMLWRITER_OK
)
{
send_client_command
(
xremote
,
parser
,
full_text
,
&
common_data
);
}
else
zMapLogWarning
(
"%s"
,
"Error processing events"
);
zMapXMLWriterDestroy
(
xml_creator
);
zMapXMLParserDestroy
(
parser
);
yield
=
common_data
.
handled
;
}
return
yield
;
}
static
void
send_client_command
(
ZMapXRemoteObj
client
,
ZMapXMLParser
parser
,
GString
*
command_string
,
ZMapXMLTagHandler
tag_handler
)
{
char
*
command
=
command_string
->
str
;
char
*
response
=
NULL
;
int
result
;
if
(
view_remote_send_debug_G
)
{
zMapLogWarning
(
"xremote sending cmd with length %d"
,
command_string
->
len
);
zMapLogWarning
(
"xremote cmd = %s"
,
command
);
}
if
((
result
=
zMapXRemoteSendRemoteCommand
(
client
,
command
,
&
response
))
==
ZMAPXREMOTE_SENDCOMMAND_SUCCEED
)
{
char
*
xml_only
=
NULL
;
int
code
=
0
;
gboolean
parses_ok
=
FALSE
,
error_response
=
FALSE
;
zMapXRemoteResponseSplit
(
client
,
response
,
&
code
,
&
xml_only
);
if
((
zMapXRemoteResponseIsError
(
client
,
response
)))
error_response
=
TRUE
;
/* You can do dummy tests of xml by setting xml_only to point to a string of xml
* that you have defined. */
if
((
parses_ok
=
zMapXMLParserParseBuffer
(
parser
,
xml_only
,
strlen
(
xml_only
)))
!=
TRUE
)
{
if
(
view_remote_send_debug_G
)
zMapLogWarning
(
"Parsing error : %s"
,
zMapXMLParserLastErrorMsg
(
parser
));
tag_handler
->
handled
=
FALSE
;
}
else
if
(
error_response
==
TRUE
)
{
zMapWarning
(
"Failed to get successful response from external program.
\n
"
"Code: %d
\n
Response: %s"
,
code
,
(
tag_handler
->
error_message
?
tag_handler
->
error_message
:
xml_only
));
tag_handler
->
handled
=
FALSE
;
}
}
else
if
(
view_remote_send_debug_G
)
zMapLogWarning
(
"Failed sending xremote command. Code = %d"
,
result
);
return
;
}
static
int
xml_event_to_buffer
(
ZMapXMLWriter
writer
,
char
*
xml
,
int
len
,
gpointer
user_data
)
{
GString
*
buffer
=
(
GString
*
)
user_data
;
g_string_append_len
(
buffer
,
xml
,
len
);
return
len
;
}
static
gboolean
xml_zmap_start_cb
(
gpointer
user_data
,
ZMapXMLElement
element
,
ZMapXMLParser
parser
)
{
if
(
view_remote_send_debug_G
)
zMapLogWarning
(
"%s"
,
"In zmap Start Handler"
);
return
TRUE
;
}
static
gboolean
xml_response_start_cb
(
gpointer
user_data
,
ZMapXMLElement
element
,
ZMapXMLParser
parser
)
{
ZMapXMLTagHandlerWrapper
wrapper
=
(
ZMapXMLTagHandlerWrapper
)
user_data
;
ZMapXMLTagHandler
message_data
=
wrapper
->
tag_handler
;
ZMapXMLAttribute
handled_attribute
=
NULL
;
gboolean
is_handled
=
FALSE
;
if
((
handled_attribute
=
zMapXMLElementGetAttributeByName
(
element
,
"handled"
))
&&
(
message_data
->
handled
==
FALSE
))
{
is_handled
=
zMapXMLAttributeValueToBool
(
handled_attribute
);
message_data
->
handled
=
is_handled
;
}
return
TRUE
;
}
static
gboolean
xml_error_end_cb
(
gpointer
user_data
,
ZMapXMLElement
element
,
ZMapXMLParser
parser
)
{
ZMapXMLTagHandlerWrapper
wrapper
=
(
ZMapXMLTagHandlerWrapper
)
user_data
;
ZMapXMLTagHandler
message_data
=
wrapper
->
tag_handler
;
ZMapXMLElement
mess_element
=
NULL
;
if
((
mess_element
=
zMapXMLElementGetChildByName
(
element
,
"message"
))
&&
!
message_data
->
error_message
&&
mess_element
->
contents
->
str
)
{
message_data
->
error_message
=
g_strdup
(
mess_element
->
contents
->
str
);
}
return
TRUE
;
}
static
gboolean
xml_zmap_end_cb
(
gpointer
user_data
,
ZMapXMLElement
element
,
ZMapXMLParser
parser
)
{
if
(
view_remote_send_debug_G
)
zMapLogWarning
(
"In zmap %s Handler."
,
"End"
);
return
TRUE
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment