| 1 |
<HTML> |
| 2 |
<HEAD> |
| 3 |
<TITLE>PG programs (Appendix 17)</TITLE> |
| 4 |
</HEAD> |
| 5 |
<BODY BACKGROUND="/back_fbb.jpg"> |
| 6 |
<P> |
| 7 |
<IMG SRC="/fbb.gif" WIDTH="32" HEIGHT="32"> |
| 8 |
<H1 ALIGN=Center> |
| 9 |
PG programs<SMALL>.</SMALL> |
| 10 |
</H1> |
| 11 |
<P ALIGN=Center> |
| 12 |
(Appendix 17) |
| 13 |
<P> |
| 14 |
<PRE><BIG><B>PG programs development.</B></BIG> |
| 15 |
|
| 16 |
PG programs are in the PG subdirectory. They are small programs allowing |
| 17 |
interactivity with the user. |
| 18 |
|
| 19 |
COM or EXE programs can be called. |
| 20 |
|
| 21 |
PG programs must be little as the amount of memory is limited and fast |
| 22 |
because the multitasking is stopped during its activity. |
| 23 |
|
| 24 |
To run a PG program and start a session, the user must type the command PG |
| 25 |
followed by the name of the program. The PG command alone gives the content |
| 26 |
of the PG subdirectory. The PG program is particularly developed for FBB |
| 27 |
software but can be an interface to a standard program. |
| 28 |
|
| 29 |
Each time a complete line (up to the return character) is received, the PG |
| 30 |
program is called with some arguments including a level number. This number |
| 31 |
is incremented each time the program is called in the same PG session. The |
| 32 |
first time the level number will be 0. |
| 33 |
|
| 34 |
The line arguments given to the PG program are : |
| 35 |
|
| 36 |
- Callsign (format as F6FBB-8). |
| 37 |
- Level number (0 is the first time, up to 99). |
| 38 |
- Flags of the user (binary number as user's mask of <A HREF="fmtinit.htm">INIT.SRV</A>). |
| 39 |
- Record number of the user in <A HREF="fmtinf.htm">INF.SYS</A>. |
| 40 |
- Received data (each word is a new argument). |
| 41 |
|
| 42 |
The PG program ends with an exit value. This value is very important and |
| 43 |
tells the BBS what to do : |
| 44 |
|
| 45 |
0 : end of session and return to the BBS menu. |
| 46 |
1 : the program will be called again and the level number is incremented. |
| 47 |
2 : the user will be disconnected. |
| 48 |
3 : the receive data will be sent as a BBS command and return to BBS. |
| 49 |
4 : the receive data will be sent as a BBS command, level incremented. |
| 50 |
5 : the program will be called again, but the level is not incremented. |
| 51 |
|
| 52 |
The data sent by the PG program to the standard output will be sent to the |
| 53 |
user. This allows a real interactivity between the user and the PG program. |
| 54 |
|
| 55 |
Here is an example of a small program : |
| 56 |
|
| 57 |
/* |
| 58 |
* TST_PG.C |
| 59 |
* |
| 60 |
* Little test program of "PG" command for FBB BBS software. |
| 61 |
* |
| 62 |
* (C) F6FBB 1991. |
| 63 |
* |
| 64 |
* FBB software 5.14 and up. |
| 65 |
* |
| 66 |
* |
| 67 |
* This program echoes to the user what he types |
| 68 |
* or executes a BBS command preceded by "CMD" |
| 69 |
* until "BYE" is received |
| 70 |
*/ |
| 71 |
|
| 72 |
#include <stdio.h> |
| 73 |
|
| 74 |
main(int argc, char **argv) |
| 75 |
{ |
| 76 |
int i; |
| 77 |
int level = atoi(argv[2]); /* Get level from argument list */ |
| 78 |
|
| 79 |
/* and transform it to integer */ |
| 80 |
if (level == 0) { /* Is level equal to 0 ? */ |
| 81 |
/* This is the first call */ |
| 82 |
printf("Hello %s, type BYE when you want to stop !\n", argv[1]); |
| 83 |
return(1); /* program will be called again */ |
| 84 |
} |
| 85 |
else { |
| 86 |
strupr(argv[5]); /* Capitalise the first word */ |
| 87 |
if (strcmp(argv[5], "BYE") == 0) { /* is BYE received ? */ |
| 88 |
printf("Ok, bye-bye\n"); |
| 89 |
return(0); /* Yes, go on BBS */ |
| 90 |
} |
| 91 |
else if (strcmp(argv[5], "CMD") == 0) { /* is CMD received ? */ |
| 92 |
for (i = 6 ; i < argc ; i++) /* List line arguments */ |
| 93 |
printf("%s ", argv[i]); /* sent by user */ |
| 94 |
putchar('\n'); |
| 95 |
for (i = 6 ; i < argc ; i++) /* List line arguments */ |
| 96 |
printf("%s ", argv[i]); /* sent by user */ |
| 97 |
putchar('\n'); |
| 98 |
return(4); /* Yes, send command */ |
| 99 |
} |
| 100 |
else { |
| 101 |
printf("You told me : "); /* These are other lines */ |
| 102 |
for (i = 5 ; i < argc ; i++) /* List line arguments */ |
| 103 |
printf("%s ", argv[i]); /* sent by user */ |
| 104 |
putchar('\n'); |
| 105 |
return(1); /* No, call again program */ |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
<A HREF="doc.htm"><IMG SRC="/contents.gif" WIDTH="108" HEIGHT="28"></A> |
| 116 |
|
| 117 |
<A HREF="/"><IMG SRC="../button_home.gif" WIDTH="90" HEIGHT="29"></A> |
| 118 |
|
| 119 |
<FONT COLOR="#800000">This page was last updated <!--#config timefmt="%d-%b-%y"--><!--#echo var="LAST_MODIFIED"--></FONT> |
| 120 |
|
| 121 |
</PRE> |
| 122 |
</BODY></HTML> |