Jabber WindowGram Client (JWGC)

Introduction Screenshots Installation Downloads
Documentation Browse Source Resources Project Site

Stable Version
-none-

Latest Version
beta5



Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

xrevstack.c

Go to the documentation of this file.
00001 /*
00002  *      Copyright (c) 1989 by the Massachusetts Institute of Technology.
00003  *      For copying and distribution information, see the file
00004  *      "mit-copyright.h".
00005  *
00006  *      Modified for jwgc by Daniel Henninger.
00007  */
00008 
00009 #include "mit-copyright.h"
00010 
00011 #ifndef X_DISPLAY_MISSING
00012 
00013 #ifndef TRUEREVSTACK
00014 #include "X_gram.h"
00015 
00016 x_gram *bottom_gram = NULL;
00017 x_gram *unlinked = NULL;
00018 int reverse_stack = 0;
00019 
00020 void 
00021 add_to_bottom(gram)
00022         x_gram *gram;
00023 {
00024         if (bottom_gram) {
00025                 bottom_gram->below = gram;
00026                 gram->below = NULL;
00027                 gram->above = bottom_gram;
00028                 bottom_gram = gram;
00029         }
00030         else {
00031                 gram->above = NULL;
00032                 gram->below = NULL;
00033                 bottom_gram = gram;
00034         }
00035 }
00036 
00037 /* ARGSUSED */
00038 void 
00039 pull_to_top(gram)
00040         x_gram *gram;
00041 {
00042 }
00043 
00044 /* ARGSUSED */
00045 void 
00046 push_to_bottom(gram)
00047         x_gram *gram;
00048 {
00049 }
00050 
00051 void 
00052 delete_gram(gram)
00053         x_gram *gram;
00054 {
00055         if (gram == bottom_gram) {
00056                 if (gram->above) {
00057                         bottom_gram = gram->above;
00058                         bottom_gram->below = NULL;
00059                 }
00060                 else {
00061                         bottom_gram = NULL;
00062                 }
00063         }
00064         else if (gram == unlinked) {
00065                 if (gram->above) {
00066                         unlinked = gram->above;
00067                         unlinked->below = NULL;
00068                 }
00069                 else {
00070                         unlinked = NULL;
00071                 }
00072         }
00073         else {
00074                 if (gram->above)
00075                         gram->above->below = gram->below;
00076                 gram->below->above = gram->above;
00077         }
00078 
00079         /*
00080          * fix up above & below pointers so that calling delete_gram again is
00081          * safe
00082          */
00083         gram->below = gram;
00084         gram->above = gram;
00085 }
00086 
00087 void 
00088 unlink_gram(gram)
00089         x_gram *gram;
00090 {
00091         delete_gram(gram);
00092 
00093         if (unlinked) {
00094                 unlinked->below = gram;
00095                 gram->below = NULL;
00096                 gram->above = unlinked;
00097                 unlinked = gram;
00098         }
00099         else {
00100                 gram->above = NULL;
00101                 gram->below = NULL;
00102                 unlinked = gram;
00103         }
00104 }
00105 
00106 #endif
00107 
00108 #ifdef TRUEREVSTACK
00109 
00110 #include "X_gram.h"
00111 #include "main.h"
00112 #include <stdio.h>
00113 
00114 x_gram *bottom_gram = NULL;
00115 static x_gram *top_gram = NULL;
00116 
00117 void 
00118 pull_to_top(gram)
00119         x_gram *gram;
00120 {
00121         if (gram == top_gram) {
00122                 /* already here */
00123                 return;
00124         }
00125         else if (top_gram == NULL) {
00126                 /* no grams at all.  Make gram both top and bottom */
00127                 top_gram = gram;
00128                 bottom_gram = gram;
00129         }
00130         else if (gram == bottom_gram) {
00131                 /* bottom gram is special case */
00132                 bottom_gram = bottom_gram->above;
00133                 bottom_gram->below = NULL;
00134                 top_gram->above = gram;
00135                 gram->below = top_gram;
00136                 top_gram = gram;
00137         }
00138         else {
00139                 /* normal case of a gram in the middle */
00140                 gram->above->below = gram->below;
00141                 gram->below->above = gram->above;
00142                 top_gram->above = gram;
00143                 gram->below = top_gram;
00144                 gram->above = NULL;
00145                 top_gram = gram;
00146         }
00147 }
00148 
00149 void 
00150 push_to_bottom(gram)
00151         x_gram *gram;
00152 {
00153         if (gram == bottom_gram) {
00154                 /* already here */
00155                 return;
00156         }
00157         else if (bottom_gram == NULL) {
00158                 /* no grams at all.  Make gram both top and bottom */
00159                 gram->above = NULL;
00160                 gram->below = NULL;
00161                 top_gram = gram;
00162                 bottom_gram = gram;
00163         }
00164         else if (gram == top_gram) {
00165                 /* top gram is special case */
00166                 top_gram = top_gram->below;
00167                 top_gram->above = NULL;
00168                 bottom_gram->below = gram;
00169                 gram->above = bottom_gram;
00170                 bottom_gram = gram;
00171         }
00172         else {
00173                 /* normal case of a gram in the middle */
00174                 gram->above->below = gram->below;
00175                 gram->below->above = gram->above;
00176                 bottom_gram->below = gram;
00177                 gram->above = bottom_gram;
00178                 gram->below = NULL;
00179                 bottom_gram = gram;
00180         }
00181 }
00182 
00183 void 
00184 unlink_gram(gram)
00185         x_gram *gram;
00186 {
00187         if (top_gram == bottom_gram) {
00188                 /* the only gram in the stack */
00189                 top_gram = NULL;
00190                 bottom_gram = NULL;
00191         }
00192         else if (gram == top_gram) {
00193                 top_gram = gram->below;
00194                 top_gram->above = NULL;
00195         }
00196         else if (gram == bottom_gram) {
00197                 bottom_gram = gram->above;
00198                 bottom_gram->below = NULL;
00199         }
00200         else {
00201                 gram->above->below = gram->below;
00202                 gram->below->above = gram->above;
00203         }
00204 }
00205 
00206 void 
00207 add_to_bottom(gram)
00208         x_gram *gram;
00209 {
00210         if (bottom_gram == NULL) {
00211                 gram->above = NULL;
00212                 gram->below = NULL;
00213                 top_gram = gram;
00214                 bottom_gram = gram;
00215         }
00216         else {
00217                 bottom_gram->below = gram;
00218                 gram->above = bottom_gram;
00219                 gram->below = NULL;
00220                 bottom_gram = gram;
00221         }
00222 }
00223 
00224 #endif                          /* TRUEREVSTACK */
00225 
00226 #endif                          /* X_DISPLAY_MISSING */


Last updated at Tue Dec 18 21:07:42 PST 2007. This site and project hosted by...SourceForge.net Logo
Source Perspective by Fisheye