10 struct CtdlServerHandle CtdlAppHandle;
11 struct CtdlServInfo CtdlAppServInfo;
16 void logoff(exitcode) {
21 * Programs linked against the Citadel server extension library need to
22 * be called with the following arguments:
23 * 0 - program name (as always)
24 * 1 - server address (usually 127.0.0.1)
25 * 2 - server port number
26 * 3 - internal program secret
30 * 7 - associated client session
40 /* We're really not interested in stdio */
45 /* Bail out if someone tries to run this thing manually */
46 if (argc < 3) exit(1);
48 /* Zeroing out the server handle neatly sets the values of
49 * CtdlAppHandle to sane default values
51 bzero(&CtdlAppHandle, sizeof(struct CtdlServerHandle));
53 /* Now parse the command-line arguments fed to us by the server */
54 for (a=0; a<argc; ++a) switch(a) {
55 case 1: strcpy(CtdlAppHandle.ServerAddress, argv[a]);
57 case 2: CtdlAppHandle.ServerPort = atoi(argv[a]);
59 case 3: strcpy(CtdlAppHandle.ipgmSecret, argv[a]);
61 case 4: strcpy(CtdlAppHandle.UserName, argv[a]);
63 case 5: strcpy(CtdlAppHandle.Password, argv[a]);
65 case 6: strcpy(CtdlAppHandle.InitialRoom, argv[a]);
67 case 7: CtdlAppHandle.AssocClientSession = atoi(argv[a]);
71 /* Connect to the server */
73 attach_to_server(argc, argv);
75 if (buf[0] != '2') exit(1);
77 /* Set up the server environment to our liking */
79 CtdlInternalGetServInfo(&CtdlAppServInfo, 0);
81 sprintf(buf, "IDEN 0|5|006|CitadelAPI Client");
85 if (strlen(CtdlAppHandle.ipgmSecret) > 0) {
86 sprintf(buf, "IPGM %s", CtdlAppHandle.ipgmSecret);
91 if (strlen(CtdlAppHandle.UserName) > 0) {
92 sprintf(buf, "USER %s", CtdlAppHandle.UserName);
95 sprintf(buf, "PASS %s", CtdlAppHandle.Password);
100 sprintf(buf, "GOTO %s", CtdlAppHandle.InitialRoom);
104 serv_puts("GOTO _BASEROOM_");
108 /* Now do the loop. */
111 /* Clean up gracefully and exit. */
117 int CtdlGetLastError() {
122 int CtdlSendExpressMessage(char *ToUser, char *MsgText) {
125 if (strlen(ToUser) + strlen(MsgText) > 248) {
126 CtdlErrno = ERROR + TOO_BIG;
130 sprintf(buf, "SEXP %s|%s", ToUser, MsgText);
134 CtdlErrno = atoi(buf);
135 if (CtdlErrno == OK) CtdlErrno = 0;