load.sgm 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <!-- $XConsortium: load.sgm /main/6 1996/09/08 20:22:56 rws $ -->
  2. <!-- (c) Copyright 1995 Digital Equipment Corporation. -->
  3. <!-- (c) Copyright 1995 Hewlett-Packard Company. -->
  4. <!-- (c) Copyright 1995 International Business Machines Corp. -->
  5. <!-- (c) Copyright 1995 Sun Microsystems, Inc. -->
  6. <!-- (c) Copyright 1995 Novell, Inc. -->
  7. <!-- (c) Copyright 1995 FUJITSU LIMITED. -->
  8. <!-- (c) Copyright 1995 Hitachi. -->
  9. <![ %CDE.C.CDE; [<RefEntry Id="CDEMX.XCDI.MAN270.rsml.1">]]>
  10. <![ %CDE.C.XO; [<RefEntry Id="XCDI.MAN270.rsml.1">]]>
  11. <RefMeta>
  12. <RefEntryTitle>ttmedia_load</RefEntryTitle>
  13. <ManVolNum>library call</ManVolNum>
  14. </RefMeta>
  15. <RefNameDiv>
  16. <RefName><Function>ttmedia_load</Function></RefName>
  17. <RefPurpose>send a Display, Edit or Compose request
  18. </RefPurpose>
  19. </RefNameDiv>
  20. <!-- $XConsortium: load.sgm /main/6 1996/09/08 20:22:56 rws $-->
  21. <!-- CDE Common Source Format, Version 1.0.0-->
  22. <!-- (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company-->
  23. <!-- (c) Copyright 1993, 1994, 1995 International Business Machines Corp.-->
  24. <!-- (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.-->
  25. <!-- (c) Copyright 1993, 1994, 1995 Novell, Inc.-->
  26. <RefSynopsisDiv>
  27. <FuncSynopsis Remap="ANSI">
  28. <FuncSynopsisInfo>#include &lt;Tt/tttk.h>
  29. </FuncSynopsisInfo>
  30. <FuncDef>Tt_message <Function>ttmedia_load</Function></FuncDef>
  31. <ParamDef>Tt_message <Parameter>context</Parameter></ParamDef>
  32. <ParamDef>Ttmedia_load_msg_cb <Parameter>cb</Parameter></ParamDef>
  33. <ParamDef>void *<Parameter>clientdata</Parameter></ParamDef>
  34. <ParamDef>Tttk_op <Parameter>op</Parameter></ParamDef>
  35. <ParamDef>const char *<Parameter>media_type</Parameter></ParamDef>
  36. <ParamDef>const unsigned char *<Parameter>contents</Parameter></ParamDef>
  37. <ParamDef>int <Parameter>len</Parameter></ParamDef>
  38. <ParamDef>const char *<Parameter>file</Parameter></ParamDef>
  39. <ParamDef>const char *<Parameter>docname</Parameter></ParamDef>
  40. <ParamDef>int <Parameter>send</Parameter></ParamDef>
  41. </FuncSynopsis>
  42. </RefSynopsisDiv>
  43. <RefSect1>
  44. <Title>DESCRIPTION</Title>
  45. <Para>The
  46. <Function>ttmedia_load</Function> function
  47. is used to create and optionally send a Media Exchange request
  48. to display, edit or compose a document.
  49. </Para>
  50. <Para>The
  51. <Emphasis>cb</Emphasis> argument will be passed
  52. <Emphasis>clientdata</Emphasis> when the reply is received, or when intermediate versions
  53. of the document are checkpointed through
  54. <Symbol Role="Message">Deposit</Symbol> requests.
  55. The
  56. <Symbol Role="Variable">op</Symbol> argument must be one of
  57. <SystemItem Class="Constant">TTME_DISPLAY</SystemItem>, <SystemItem Class="Constant">TTME_EDIT</SystemItem> or
  58. <SystemItem Class="Constant">TTME_COMPOSE</SystemItem>. The
  59. <Emphasis>media_type</Emphasis> argument names the data format of the document, and is usually the
  60. primary determinant of which application will be chosen to
  61. handle the request.
  62. The
  63. <Emphasis>contents</Emphasis> and
  64. <Emphasis>len</Emphasis> arguments specify the document; if they are
  65. <SystemItem Class="Constant">NULL</SystemItem> and zero, respectively, and
  66. <Symbol Role="Variable">file</Symbol> is not
  67. <SystemItem Class="Constant">NULL</SystemItem>, then the document is assumed to be contained in
  68. <Symbol Role="Variable">file</Symbol>. If
  69. <Emphasis>docname</Emphasis> is not
  70. <SystemItem Class="Constant">NULL</SystemItem>, then
  71. <Function>ttmedia_load</Function> uses it as the title of the document.
  72. If
  73. <Emphasis>send</Emphasis> is True, the message is sent before being returned.
  74. </Para>
  75. <Para>The
  76. <Symbol Role="Variable">context</Symbol> argument describes the environment to use.
  77. If
  78. <Symbol Role="Variable">context</Symbol> is not zero, messages created by
  79. <Function>ttmedia_load</Function> inherit from
  80. <Symbol Role="Variable">context</Symbol> all contexts whose slotname begins with the characters
  81. <SystemItem Class="Constant">ENV_</SystemItem>.</Para>
  82. <Para>The
  83. <StructName Role="typedef">Ttmedia_load_msg_cb</StructName> argument is a callback defined as:
  84. </Para>
  85. <InformalExample Remap="indent">
  86. <ProgramListing>Tt_message (*Ttmedia_load_msg_cb)(Tt_message <Emphasis>msg</Emphasis>,
  87. void *<Emphasis>clientdata</Emphasis>),
  88. Tttk_op <Symbol Role="Variable">op</Symbol>,
  89. unsigned char *<Emphasis>contents</Emphasis>,
  90. int <Emphasis>len</Emphasis>,
  91. char *<Symbol Role="Variable">file</Symbol>);
  92. </ProgramListing>
  93. </InformalExample>
  94. <Para>The
  95. <Emphasis>msg</Emphasis> argument is the
  96. reply to the load request, or a
  97. <Symbol Role="Message">Deposit</Symbol> request with a
  98. <Emphasis>messageID</Emphasis> argument naming the identifier (see
  99. &cdeman.tt.message.id;) of the load request.
  100. In the latter case, the client
  101. program becomes responsible for either failing or replying
  102. to the request.
  103. In either case,
  104. <Emphasis>msg</Emphasis> should be destroyed after being processed.
  105. </Para>
  106. <Para>The
  107. <Symbol Role="Variable">op</Symbol> argument is the
  108. op of
  109. <Emphasis>msg</Emphasis>. It must be either
  110. <SystemItem Class="Constant">TTME_DEPOSIT</SystemItem> or the
  111. <Symbol Role="Variable">op</Symbol> passed to
  112. &cdeman.ttmedia.load;.</Para>
  113. <Para>The
  114. <Emphasis>contents</Emphasis>, <Emphasis>len</Emphasis> and
  115. <Symbol Role="Variable">file</Symbol> arguments represent the
  116. contents of the arriving document.
  117. If
  118. <Emphasis>len</Emphasis> is zero, then the document is contained in
  119. <Symbol Role="Variable">file</Symbol>. If
  120. <Emphasis>contents</Emphasis> or
  121. <Symbol Role="Variable">file</Symbol> are non-
  122. <SystemItem Class="Constant">NULL</SystemItem>, they can be freed using
  123. <Function>tt_free</Function>.</Para>
  124. <Para>The
  125. <Emphasis>clientdata</Emphasis> argument is the
  126. <Emphasis>clientdata</Emphasis> passed to
  127. <Function>ttmedia_load</Function>.</Para>
  128. </RefSect1>
  129. <RefSect1>
  130. <Title>RETURN VALUE</Title>
  131. <Para>Upon successful completion, the
  132. <Function>ttmedia_load</Function> function returns the request it was asked to build;
  133. otherwise, it returns an error pointer.
  134. The application can use
  135. &cdeman.tt.ptr.error; to extract one of the following
  136. <StructName Role="typedef">Tt_status</StructName> values from the returned handle:
  137. </Para>
  138. <VariableList>
  139. <VarListEntry>
  140. <Term>TT_ERR_NOMEM</Term>
  141. <ListItem>
  142. <Para>There is insufficient memory available to perform the function.
  143. </Para>
  144. </ListItem>
  145. </VarListEntry>
  146. <VarListEntry>
  147. <Term>TT_ERR_NOMP</Term>
  148. <ListItem>
  149. <Para>The
  150. &cdeman.ttsession; process is not running and the ToolTalk service cannot restart it.
  151. </Para>
  152. </ListItem>
  153. </VarListEntry>
  154. <VarListEntry>
  155. <Term>TT_ERR_OVERFLOW</Term>
  156. <ListItem>
  157. <Para>The ToolTalk service has more active messages than it can handle.
  158. (The maximum number of active messages is
  159. implementation specific, but is at least 2000.)
  160. </Para>
  161. </ListItem>
  162. </VarListEntry>
  163. <VarListEntry>
  164. <Term>TT_ERR_PROCID</Term>
  165. <ListItem>
  166. <Para>The specified process identifier is out of date or invalid.
  167. </Para>
  168. </ListItem>
  169. </VarListEntry>
  170. </VariableList>
  171. </RefSect1>
  172. <RefSect1>
  173. <Title>APPLICATION USAGE</Title>
  174. <Para>After the request created by
  175. <Function>ttmedia_load</Function> is sent, the application will probably want to use
  176. <Function>ttdt_subcontract_manage</Function> immediately afterwards to manage the standard interactions with the
  177. handler of the request.
  178. </Para>
  179. <Para>A
  180. <StructName Role="typedef">Ttmedia_load_msg_cb</StructName> callback should return
  181. <SystemItem Class="Constant">NULL</SystemItem> if it processes
  182. <Emphasis>msg</Emphasis> successfully, or a
  183. <Function>tt_error_pointer</Function> cast to
  184. <StructName Role="typedef">Tt_message</StructName> if processing results in an error.
  185. It should return the
  186. <Emphasis>msg</Emphasis> if it does not consume it, in which case
  187. the ToolTalk service
  188. will pass
  189. <SystemItem Class="Constant">TT_CALLBACK_CONTINUE</SystemItem> down the call stack, so that
  190. <Emphasis>msg</Emphasis> will be offered to other callbacks or (more likely) be returned
  191. from
  192. &cdeman.tt.message.receive;. Applications will rarely want
  193. <Emphasis>msg</Emphasis> to get processed by other callbacks or in the main event loop.
  194. </Para>
  195. </RefSect1>
  196. <RefSect1>
  197. <Title>EXAMPLES</Title>
  198. <Para>This is the typical algorithm of a
  199. <StructName Role="typedef">Ttmedia_load_msg_cb</StructName>:</Para>
  200. <InformalExample Remap="indent">
  201. <ProgramListing>Tt_message
  202. myLoadMsgCB(Tt_message msg,
  203. void *clientData,
  204. Tttk_op op,
  205. unsigned char *contents,
  206. int len,
  207. char *file)
  208. {
  209. if (len > 0) {
  210. /* Replace data with len bytes in contents */
  211. } else if (file != 0) {
  212. /* Replace data with data read from file */
  213. }
  214. if (op == TTME_DEPOSIT) {
  215. tt_message_reply(msg);
  216. }
  217. tttk_message_destroy(msg);
  218. return 0;
  219. }
  220. </ProgramListing>
  221. </InformalExample>
  222. </RefSect1>
  223. <RefSect1>
  224. <Title>SEE ALSO</Title>
  225. <Para>&cdeman.Tt.tttk.h;, &cdeman.ttmedia.load.reply;, &cdeman.ttmedia.ptype.declare;, &cdeman.ttmedia.Deposit;, &cdeman.tt.free;, &cdeman.tt.message.receive;.</Para>
  226. </RefSect1>
  227. </RefEntry>
  228. <!--fickle 1.12 mancsf-to-docbook 1.2 08/07/95 23:18:47-->