root/nt/ddeclient.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. DdeCallback
  2. main

     1 /* Simple client interface to DDE servers.
     2    Copyright (C) 1998, 2001-2023 Free Software Foundation, Inc.
     3 
     4 This file is part of GNU Emacs.
     5 
     6 GNU Emacs is free software: you can redistribute it and/or modify
     7 it under the terms of the GNU General Public License as published by
     8 the Free Software Foundation, either version 3 of the License, or (at
     9 your option) any later version.
    10 
    11 GNU Emacs is distributed in the hope that it will be useful,
    12 but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 GNU General Public License for more details.
    15 
    16 You should have received a copy of the GNU General Public License
    17 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    18 
    19 #define DEFER_MS_W32_H
    20 #include <config.h>
    21 
    22 #include <windows.h>
    23 #include <ddeml.h>
    24 #include <stdlib.h>
    25 #include <stdio.h>
    26 
    27 HDDEDATA CALLBACK DdeCallback (UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, DWORD_PTR,
    28                                DWORD_PTR);
    29 
    30 HDDEDATA CALLBACK
    31 DdeCallback (UINT uType, UINT uFmt, HCONV hconv,
    32              HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
    33              DWORD_PTR dwData1, DWORD_PTR dwData2)
    34 {
    35   return ((HDDEDATA) NULL);
    36 }
    37 
    38 #define DdeCommand(str)         \
    39         DdeClientTransaction (str, strlen (str)+1, HConversation, (HSZ)NULL, \
    40                               CF_TEXT, XTYP_EXECUTE, 30000, NULL)
    41 
    42 int
    43 main (int argc, char *argv[])
    44 {
    45   DWORD idDde = 0;
    46   HCONV HConversation;
    47   HSZ   Server;
    48   HSZ   Topic = 0;
    49   char  command[1024];
    50 
    51   if (argc < 2)
    52     {
    53       fprintf (stderr, "usage: ddeclient server [topic]\n");
    54       exit (1);
    55     }
    56 
    57   DdeInitialize (&idDde, (PFNCALLBACK)DdeCallback, APPCMD_CLIENTONLY, 0);
    58 
    59   Server = DdeCreateStringHandle (idDde, argv[1], CP_WINANSI);
    60   if (argc > 2)
    61     Topic = DdeCreateStringHandle (idDde, argv[2], CP_WINANSI);
    62 
    63   HConversation = DdeConnect (idDde, Server, Topic, NULL);
    64   if (HConversation != 0)
    65     {
    66       while (fgets (command, sizeof(command), stdin) != NULL)
    67         DdeCommand (command);
    68 
    69       DdeDisconnect (HConversation);
    70     }
    71 
    72   DdeFreeStringHandle (idDde, Server);
    73   if (Topic)
    74     DdeFreeStringHandle (idDde, Topic);
    75   DdeUninitialize (idDde);
    76 
    77   return (0);
    78 }

/* [<][>][^][v][top][bottom][index][help] */