Networking Forums

Networking Forums > Computer Networking > Linux Networking > subnet calculations with vgsubnet.c

Reply
Thread Tools Display Modes

subnet calculations with vgsubnet.c

 
 
ericmatteson2003november@hotmail.com
Guest
Posts: n/a

 
      10-21-2006, 06:37 PM
This vgsubnet.c subnet mask calculator program
uses a scrolling terminal with a font and uses
zackvga.h published elsewhere on the Internet.
zackvga.h and its helper file is similar to vga.h
zackmain(int,char**) is used instead of main in this program
vgsubnet.c is next */
// beginning of vgsubnet.c
// October 20,2006
// Copyright 2006 by Eric Matteson
// Permission is granted to copy this vgsubnet.c source
// code and to publish it on the Internet and to
// use it at least for non profit use.
// Eric Matteson vgsubnet.c Linux test program
// not any more gcc -Wall vgsubnet.c -lvga -o vgsubnet.out
// #include<vga.h>
#include"zackvga.h"
// gcc -Wall vgsubnet.c -L/usr/X11R6/lib -lX11 -o vgsubnet.out
// ./vgsubnet.out
char ttscroll[2000];
char cwln[99];
char fonthold[1024];
char thintel[307200];
int cvhd[] = { 128,64,32,16,8,4,2,1 };
unsigned char cpald[] = {0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,255,255,255 };
long long ltarg,ltarb,ltard;
long long ipchris,ipgreg,llcraig,llreese;
long long aareese,aacraig,aasubsize,snmask;
// GraphicsContext* avscreen;
int itarget,prevmode,jkeyctr,djkey,imasize;
int cvdl,cvrl,cvwi,iptaken,ipused;
int iecrg,iereese;
int glkeypos[1];
// -------------------------------------------------------
int lidoskey(long long kkll,char* klinuxcm);
// -------------------------------------------------------
long long ldivmodi(long long lnumer,long long ldenom,int lnzrem);
void lprint(char* lpcres,int psp,int pwid,int pibase,
long long lpnrlg);
int idigitcc(char* cdigitcc,int idigitsu);
long long lreadc(int rsp,int rwid,int ribase,char* rreadc);
void lclear(int learln,char* cclearable);
void liscroll(char* cscrollable);
// -------------------------------------------------------
int divmodi(int jnumer,int jdenom,int nzjrem);
void fslone(int* fsld,int fslterm);
char fonone(int fnlterm);
void el(int ab,int al,int t1,int t2,int t3,int t4,
int t5,int t6,int t7,int t8);
void flstart();
void sixthin(int sixrox,int sixroy,int vertoy,char* sixchr);
void thinpage(char* dscrollable);
int snlreadnz(char* snlroll,int* snlpos);
long long llicram(int licroff,int licrmany,long long* licrray);
void lluncram(long long *lucra,int lucrof,int lucmany,
long long lucfrom);
long long readip(char* ripscroll);
void showip(char* sipscroll,long long sipbig);
int getipinfo(long long lgipa,int gipsel);
long long maskmake(int mmquan);
void linto1921(char* lt1921,char* linfrom);
int bentlog(long long lbenchk);
int rizeroes(long long lrizchk);
long long bentexp(int bepower);
// -------------------------------------------------------
// int main()
int zackmain(int tempdeli,char** tempnonc)
{
int runmode,lilopct,lolopct,cvll;
// runmode=G640x480x16;
runmode=G640x480x2;
itarget=256;
aareese=0L;
aacraig=0L;
aasubsize=0L;
imasize=32;
ltarb=(long long)itarget;
flstart();
vga_init();
prevmode=vga_getcurrentmode();
ltarg=(long long)prevmode;
// liscroll(ttscroll);
// lprint(ttscroll,1921,17,16,ltarg);
jkeyctr=0;
ltarg=(long long)runmode;
// liscroll(ttscroll);
// lprint(ttscroll,1921,17,16,ltarg);
if(vga_hasmode(runmode))
{
vga_setmode(runmode);
// avscreen = gl_allocatecontext();
// gl_getcontext(avscreen);
// gl_setcontextvgavirtual(runmode);
// depth = 2
// not in library gl_setpallettecolors(0,16,cpald);
// gl_clearscreen(0);
itarget=0-8;
ltarg=(long long)itarget;
// 0586 to 66 temporary is next assume 6*7 screen 480*350
iptaken=32;
ipused=iptaken;
liscroll(ttscroll);
linto1921(ttscroll,"Eric Matteson vgsubnet.c October 20, 2006!");
liscroll(ttscroll);
linto1921(ttscroll,"calculation of subnet mask!");
liscroll(ttscroll);
linto1921(ttscroll,"Enter network address!");
liscroll(ttscroll);
thinpage(ttscroll);
glkeypos[0]=0;
while(snlreadnz(ttscroll,glkeypos) == 0);
ipgreg=0L;
ipchris=readip(ttscroll);
liscroll(ttscroll);
showip(ttscroll,ipchris);
if(ipchris < 0L)
{
liscroll(ttscroll);
linto1921(ttscroll,"*** ERROR *** INVALID IP ADDRESS!");
}
liscroll(ttscroll);
itarget=getipinfo(ipchris,1);
if((itarget >= 65)&&(itarget <= 67)&&(ipchris >= 0L))
{
*(ttscroll + 1920)=(char)itarget;
liscroll(ttscroll);
if(itarget == 65)iptaken=8;
if(itarget == 66)iptaken=16;
if(itarget == 67)iptaken=24;
ipused=32-rizeroes(ipchris);
if(iptaken > ipused)ipused=iptaken;
ltarg=(long long)ipused;
lprint(ttscroll,1921,2,10,ltarg);
liscroll(ttscroll);
ipgreg=maskmake(iptaken);
showip(ttscroll,ipgreg);
}
liscroll(ttscroll);
linto1921(ttscroll,"Enter number of subnetworks that are needed!");
liscroll(ttscroll);
thinpage(ttscroll);
glkeypos[0]=0;
while(snlreadnz(ttscroll,glkeypos) == 0);
llcraig=lreadc(1921,9,10,ttscroll);
liscroll(ttscroll);
linto1921(ttscroll,"Enter number of hosts per subnetwork!");
liscroll(ttscroll);
thinpage(ttscroll);
glkeypos[0]=0;
while(snlreadnz(ttscroll,glkeypos) == 0);
llreese=lreadc(1921,9,10,ttscroll);
liscroll(ttscroll);
// -------------------------- calculate subnet mask
iecrg=bentlog(llcraig);
iereese=bentlog(llreese);
if((ipused + iecrg + iereese) <= 32)
{
aacraig=bentexp(iecrg);
aareese=bentexp(32 - (ipused + iecrg));
imasize=iecrg+ipused;
}
snmask=maskmake(imasize);
aasubsize=(maskmake(32)-snmask)+1L;
linto1921(ttscroll,"aacraig aareese snmask aasubsize!");
liscroll(ttscroll);
linto1921(ttscroll,"Number of usable subnets!");
liscroll(ttscroll);
lprint(ttscroll,1921,10,10,aacraig);
liscroll(ttscroll);
linto1921(ttscroll,"Maximum number of usable hosts per subnet!");
liscroll(ttscroll);
lprint(ttscroll,1921,8,10,aareese);
liscroll(ttscroll);
linto1921(ttscroll,"Calculated subnet mask!");
liscroll(ttscroll);
showip(ttscroll,snmask);
liscroll(ttscroll);
linto1921(ttscroll,"Increment between subnets!");
liscroll(ttscroll);
lprint(ttscroll,1921,8,10,aasubsize);
// ------
liscroll(ttscroll);
linto1921(ttscroll,"press any key to quit!");
thinpage(ttscroll);
itarget=0-8;
while(itarget < 1)
{
ltarg=(long long)vga_getkey();
itarget=lidoskey(ltarg,"v");
}
// depth = 2
vga_setmode(prevmode);
}
// depth = 1
// end has mode
return 0;
}
// depth = 0
// end main
// Test Library for LINUX C
// ---------------------------------------------
// LINUX KEYBOARD TRANSLATOR TOP
int lidoskey(long long kkll,char* klinuxcm)
{
int klinuxmm;
int lidoskrs;
klinuxmm = (int)(*(klinuxcm));
lidoskrs=131072;
if(klinuxmm == (int)'v')
{
// klinuxcm == "v" for int vga_getkey() within <vga.h>
if((kkll >= lreadc(1,1,16,"0"))&&(kkll <= lreadc(1,2,16,"7E")))
{
lidoskrs=(int)kkll;
}
if(kkll == lreadc(1,2,16,"7F"))lidoskrs=8;
// -----------------------------------------------------
if(kkll == lreadc(1,8,16,"1B5B317E"))lidoskrs=512+71;
if(kkll == lreadc(1,8,16,"001B5B41"))lidoskrs=512+72;
if(kkll == lreadc(1,8,16,"1B5B357E"))lidoskrs=512+73;
if(kkll == lreadc(1,8,16,"001B5B44"))lidoskrs=512+75;
if(kkll == lreadc(1,8,16,"001B5B43"))lidoskrs=512+77;
if(kkll == lreadc(1,8,16,"1B5B347E"))lidoskrs=512+79;
if(kkll == lreadc(1,8,16,"001B5B42"))lidoskrs=512+80;
if(kkll == lreadc(1,8,16,"1B5B367E"))lidoskrs=512+81;
if(kkll == lreadc(1,8,16,"1B5B327E"))lidoskrs=512+82;
if(kkll == lreadc(1,8,16,"1B5B337E"))lidoskrs=512+83;
// -----------------------------------------------------
}
return lidoskrs;
}
// end of int lidoskey(long long,char*)
// BOTTOM OF LINUX KEY TRANSLATOR
// -----------------------------------------
// begin long long from to char* library routines
long long ldivmodi(long long lnumer,long long ldenom,int lnzrem)
{
long long lfrac,lprod,lrem,lldzur;
int cmpzz;
cmpzz=0;
lldzur=(long long)cmpzz;
lfrac=lnumer/ldenom;
lprod=lfrac*ldenom;
lrem=lnumer-lprod;
if(lrem < lldzur)
{
lfrac=lfrac+1;
lprod=lfrac*ldenom;
lrem=lnumer-lprod;
}
if(lnzrem > cmpzz)lfrac=lrem;
return lfrac;
}
// depth = 0
void lprint(char* lpcres,int psp,int pwid,int pibase,
long long lpnrlg)
{
// psp is starting position starting at 1
// pwid is number of digits to print to character array
// pibase is number base of result. Use 10 if no other
/// base is needed.
// *lpcres is pointer to character array
// that will recieve result.
long long lpgrlg,plbase,ldigit;
int pctr,psub,peg,idigit;
peg=0;
plbase=(long long)peg;
pctr=1;
ldigit=(long long)pctr;
lpgrlg=lpnrlg;
if(lpnrlg < plbase)
{
lpgrlg=plbase-(lpnrlg+ldigit);
// depth = 2
peg=1;
}
pctr=pwid;
// depth = 1
plbase=(long long)pibase;
while(pctr > 0)
{
psub=(psp-1)+(pctr-1);
ldigit=ldivmodi(lpgrlg,plbase,1);
lpgrlg=ldivmodi(lpgrlg,plbase,0);
idigit=(int)ldigit;
if(peg > 0)idigit=((pibase-1)-idigit);
idigit=idigit+48;
if(idigit > 57)idigit=idigit+7;
*(lpcres + psub)=(char)idigit;
pctr=pctr-1;
}
// depth = 1
}
// depth = 0
int idigitcc(char* cdigitcc,int idigitsu)
{
int rdigitcc,cmpdigit;
rdigitcc=257;
cmpdigit=(int)(*(cdigitcc + idigitsu));
if((cmpdigit >= 48)&&(cmpdigit <= 57))rdigitcc=cmpdigit-48;
if((cmpdigit >= 65)&&(cmpdigit <= 70))rdigitcc=cmpdigit-55;
if((cmpdigit >= 97)&&(cmpdigit <= 102))rdigitcc=cmpdigit-87;
return rdigitcc;
}
// depth = 0
long long lreadc(int rsp,int rwid,int ribase,char* rreadc)
{
// rsp is starting position beginning at 1
// rwid is maximum width of checkable character data
// ribase is number base that is used.
// *rreadc is character array that contains ascii source of
// implied number
long long lreadl,rlbase,lrrdigit;
int irdigit,irctr,irlsub,irallow;
rlbase=(long long)(0 - ribase);
if(ribase >= 0)rlbase=(long long)ribase;
irallow=1;
irctr=0;
lreadl=(long long)irctr;
while(irallow > 0)
{
irlsub=(rsp-1)+irctr;
if(idigitcc(rreadc,irlsub)<16)irallow=0;
if(irallow > 0)
{
irctr=irctr+1;
// depth = 3
if(irctr >= rwid)irallow=0;
}
}
// depth = 1
irallow=0;
if(irctr < rwid)irallow=1;
while(irallow > 0)
{
irlsub=(rsp-1)+irctr;
irdigit=idigitcc(rreadc,irlsub);
if(irdigit > 15)irallow=0;
if(irallow > 0)
{
lrrdigit=(long long)irdigit;
// depth = 3
lreadl=lreadl*rlbase;
lreadl=lreadl+lrrdigit;
irctr=irctr+1;
if(irctr >= rwid)irallow=0;
}
}
if(ribase < 0)lreadl=(long long)(irlsub + 1);
return lreadl;
}
// end of lreadc
// end of long long to from char* library
// begin character scrolling up
// learln is between 1 and 25
void lclear(int learln,char* cclearable)
{
int lclctr,lclsub;
lclctr=0;
while(lclctr < 80)
{
lclsub=((learln-1)*80)+lclctr;
*(cclearable + lclsub)='\40';
lclctr=lclctr+1;
}
}
// depth = 0
void liscroll(char* cscrollable)
{
int lisoctr,lisictr,lisihl,lisihr;
lisoctr=0;
while(lisoctr < 24)
{
lisictr=0;
while(lisictr < 80)
{
lisihl=(lisoctr * 80)+lisictr;
lisihr=lisihl+80;
*(cscrollable + lisihl) = *(cscrollable + lisihr);
lisictr = lisictr + 1;
}
lisoctr=lisoctr+1;
}
lclear(25,cscrollable);
}
// end of character scrolling up
// font get subroutines
// REM bitmap header
// REM 0 00 2 "BM"
// REM 02 4 bfsize
// REM 06 2 2r1
// REM 08 2 2r2
// REM 0a 4 bfoffbits to start of bitmap
// REM 0e 4 bisize of header
// REM 18 12 4 biwidth IN PIXELS
// REM 22 16 4 biheight IN PIXELS
// REM 1a 2 biplanes srt to 0001
// REM 28 1c 2 bibitcount = {1,4,8,24}
// REM 1e 4 bicompression must be 0 for normal
// REM 22 4 bisize size of image or 0
// REM 26 4 bixpelspermeter
// REM 2a 4 biypelspermeter
// REM 46 2e 4 biclrused is number of colors used while > 0
// AND [1C]=8
// REM 32 4 biclrimportant or 0
// REM 54 36 4*[1C] or 0 for [1C]==24 COLORTABLE BGR0 BGR0
// REM bitmap is in upside down format after colortable each
// line of dwords
int divmodi(int jnumer,int jdenom,int nzjrem)
{
int resmodi,jprod,jrem,jfrac;
jfrac=jnumer/jdenom;
jprod=jdenom*jfrac;
jrem=jnumer-jprod;
if(jrem < 0)
{
jfrac=jfrac-1;
jprod=jdenom*jfrac;
jrem=jnumer-jprod;
}
resmodi=jfrac;
if(nzjrem != 0)resmodi=jrem;
return resmodi;
}
void fslone(int* fsld,int fslterm)
{
int fslbase,fslnumer,fslfrac,fslrem;
int islctr,ixlrem;
islctr=10;
fslbase=islctr;
fslnumer=fslterm;
islctr=5;
while(islctr >= 0)
{
fslfrac=divmodi(fslnumer,fslbase,0);
fslrem=divmodi(fslnumer,fslbase,1);
fslnumer=fslfrac;
ixlrem=fslrem;
*(fsld+islctr)=ixlrem;
islctr=islctr-1;
}
*(fsld+6)=0;
*(fsld+7)=0;
}
// depth = 0
char fonone(int fnlterm)
{
int mfectr,mferes;
int fonb[8];
char afononeres;
fslone(fonb,fnlterm);
mferes=0;
mfectr=0;
while(mfectr < 8)
{
mferes=mferes+mferes;
mferes=mferes+fonb[mfectr];
mfectr=mfectr+1;
}
afononeres=(char)mferes;
return afononeres;
}
// depth = 0
void el(int ab,int au,int t1,int t2,int t3,
int t4,int t5,int t6,int t7,int t8)
{
int elibase,elobase,elopar;
elibase=(ab-1000)+(au-10);
elibase=elibase*8;
elobase=(divmodi(elibase,64,0))*64;
elopar=divmodi(elibase,64,63);
elobase=elobase+divmodi(elopar,8,0);
fonthold[elobase]=fonone(t1);
fonthold[elobase+8]=fonone(t2);
fonthold[elobase+16]=fonone(t3);
fonthold[elobase+24]=fonone(t4);
fonthold[elobase+32]=fonone(t5);
fonthold[elobase+40]=fonone(t6);
fonthold[elobase+48]=fonone(t7);
fonthold[elobase+56]=fonone(t8);
}
// end of font get subroutines
// depth = 0
void flstart()
{
// open source font below by (E-Mail Removed)
// 4 * 5 character in minimum 5 * 6 box 6 * 7 reccomended
// saved in a 6 * 8 pattern for 8 * 8 pattern depth = unknown
// db 2g000000,2g000000,2g000000,2g000000,
// 2g000000,2g000000,2g000000,2g000000
// db 2g0xxxx0
// db 2g0xxxx0
// db 2g0xxxx0
// db 2g0xxxx0
// db 2g0xxxx0
// db 2g000000
// db 2g000000
int ab;
ab=0;
while(ab < 307200)
{
thintel[ab]='\0';
ab=ab+1;
}
ab=0;
while(ab < 2000)
{
ttscroll[ab]='\40';
ab=ab+1;
}
ab=1000;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,12,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,13,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,14,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,15,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1008;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,12,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,13,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,14,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,15,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1016;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,12,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,13,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,14,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,15,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1024;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,12,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,13,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,14,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,15,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1032;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2000000,2001000,2010010,2001010,2011110,2 011100,
2000110,2001100);
el(ab,12,2000000,2001000,2011010,2011110,2010100,2 010100,
2011010,2000100);
el(ab,13,2000000,2001100,2000000,2001010,2011110,2 001100,
2010110,2000000);
el(ab,14,2000000,2000000,2000000,2011110,2001010,2 001010,
2010010,2000000);
el(ab,15,2000000,2001100,2000000,2010100,2011110,2 001110,
2011110,2000000);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1040;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2000110,2011000,2010110,2001100,2000000,2 000000,
2000000,2000010);
el(ab,12,2001000,2000100,2001100,2001100,2000000,2 000000,
2000000,2000100);
el(ab,13,2001000,2000100,2011110,2011110,2000000,2 011100,
2000000,2001000);
el(ab,14,2001000,2000100,2001100,2001100,2001100,2 000000,
2001100,2001000);
el(ab,15,2000110,2011000,2011010,2001100,2000100,2 000000,
2001100,2010000);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1048;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2011110,2000100,2011110,2011110,2010010,2 011110,
2011110,2011110);
el(ab,12,2010010,2001100,2000010,2000010,2010010,2 010000,
2010000,2000010);
el(ab,13,2010010,2000100,2011110,2011110,2011110,2 011110,
2011110,2000010);
el(ab,14,2010010,2000100,2010000,2000010,2000010,2 000010,
2010010,2000010);
el(ab,15,2011110,2000100,2011110,2011110,2000010,2 011110,
2011110,2000010);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1056;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2011110,2011110,2000000,2000000,2000110,2 000000,
2011000,2001100);
el(ab,12,2010010,2010010,2001100,2001100,2001100,2 011110,
2001100,2010010);
el(ab,13,2011110,2011110,2000000,2000000,2011000,2 000000,
2000110,2000100);
el(ab,14,2010010,2000010,2001100,2001100,2001100,2 011110,
2001100,2000000);
el(ab,15,2011110,2011110,2000000,2000100,2000110,2 000000,
2011000,2000100);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1064;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2001100,2011110,2011100,2011110,2011000,2 011110,
2011110,2001110);
el(ab,12,2010010,2010010,2010010,2010000,2010100,2 010000,
2010000,2010000);
el(ab,13,2000110,2011110,2011100,2010000,2010010,2 011110,
2011110,2011100);
el(ab,14,2001010,2010010,2010010,2010000,2010100,2 010000,
2010000,2010010);
el(ab,15,2001110,2010010,2011100,2011110,2011000,2 011110,
2010000,2001110);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1072;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2010010,2001110,2000010,2010010,2010000,2 011000,
2010010,2001100);
el(ab,12,2010010,2000100,2000010,2010100,2010000,2 011000,
2011010,2010010);
el(ab,13,2011110,2000100,2000010,2011000,2010000,2 010110,
2011010,2010010);
el(ab,14,2010010,2000100,2000010,2010100,2010000,2 010110,
2010110,2000010);
el(ab,15,2010010,2001110,2011110,2010010,2011110,2 010010,
2010010,2001100);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1080;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2011110,2001100,2011100,2001100,2011110,2 010010,
2010010,2010010);
el(ab,12,2010010,2010010,2010010,2010000,2001000,2 010010,
2010010,2011010);
el(ab,13,2011110,2010100,2011110,2011110,2001000,2 010010,
2010100,2011010);
el(ab,14,2010000,2001000,2010100,2000010,2001000,2 010010,
2010100,2000110);
el(ab,15,2010000,2000110,2010110,2001100,2001000,2 011110,
2001000,2000110);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1088;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2010010,2010010,2001110,2001100,2010000,2 001100,
2000100,2000000);
el(ab,12,2001010,2010010,2000010,2001000,2010000,2 000100,
2001010,2000000);
el(ab,13,2001100,2001100,2001100,2001000,2001000,2 000100,
2000000,2000000);
el(ab,14,2010100,2001100,2010000,2001000,2000100,2 000100,
2000000,2000000);
el(ab,15,2010010,2001100,2011100,2001100,2000010,2 001100,
2000000,2011110);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1096;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2010000,2011110,2010000,2000000,2000010,2 011110,
2001110,2001110);
el(ab,12,2001000,2000010,2010000,2001110,2000010,2 010010,
2001000,2010010);
el(ab,13,2000000,2011110,2011100,2001000,2011110,2 011110,
2001100,2001110);
el(ab,14,2000000,2010010,2010010,2001000,2010010,2 010000,
2001000,2000010);
el(ab,15,2000000,2011110,2011100,2001110,2011110,2 011110,
2001000,2011100);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1104;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2010000,2001000,2000000,2001010,2000000,2 001110,
2000000,2000000);
el(ab,12,2010000,2000000,2000000,2001100,2010000,2 001010,
2010010,2001100);
el(ab,13,2011110,2001000,2000100,2001000,2010000,2 010010,
2011010,2010010);
el(ab,14,2010010,2001000,2000100,2001100,2010000,2 010010,
2010110,2010010);
el(ab,15,2010010,2001000,2011100,2001010,2011100,2 000000,
2010010,2001100);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1112;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2000000,2011100,2000000,2001100,2000000,2 000000,
2000000,2000000);
el(ab,12,2001110,2010100,2001110,2001000,2001110,2 010010,
2010010,2010100);
el(ab,13,2001010,2011100,2001000,2001110,2000100,2 010010,
2010100,2010100);
el(ab,14,2001110,2001000,2001000,2000010,2000100,2 011110,
2001000,2011100);
el(ab,15,2001000,2000110,2001000,2001100,2000100,2 000000,
2000000,2001100);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
ab=1120;
el(ab,10,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,11,2000000,2000000,2000000,2000110,2001000,2 011000,
2001010,2000000);
el(ab,12,2010010,2001010,2001110,2000100,2001000,2 001000,
2010100,2000000);
el(ab,13,2001100,2001010,2000100,2001100,2000000,2 001100,
2000000,2000000);
el(ab,14,2001100,2000100,2001000,2000100,2001000,2 001000,
2000000,2000000);
el(ab,15,2010010,2000100,2011100,2000110,2001000,2 011000,
2000000,2000000);
el(ab,16,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
el(ab,17,2000000,2000000,2000000,2000000,2000000,2 000000,
2000000,2000000);
// end of font
}
// end of font loader void flstart()
// depth = 0
// prepare to display font;
void sixthin(int sixrox,int sixroy,int vertoy,char* sixchr)
{
int tixprod,sixbhr,tixctr,tiyprod,tiyres,tiyrem,tixbas e;
int tixprop;
char rychr;
rychr = *(sixchr+(sixrox+((vertoy-1)*80)));
sixbhr = (int)rychr;
if((sixbhr < 0)||(sixbhr > 127))sixbhr = 32;
tixctr=0;
tiyprod=(sixbhr*8)+sixroy;
// sixrox is location within *sixchr of character
// sixroy is line number within individual text line 0-6
// vertoy is line number 1 to 25
rychr = fonthold[tiyprod];
tiyres = (int)rychr;
if(tiyres < 0)tiyres=tiyres+256;
tixbase=sixrox*6;
while(tixctr < 6)
{
tixprod=tixbase+tixctr;
tiyres=tiyres+tiyres;
// depth = 2
tiyrem=15;
if(tiyres > 255)
{
tiyres=tiyres-256;
tiyrem=0;
}
tixprop=((vertoy-1) * 640 * 7)+(sixroy * 640)+tixprod;
thintel[tixprop]=(char)tiyrem;
// depth = 2
tixctr=tixctr+1;
}
}
// depth = 0
void thinpage(char* dscrollable)
{
int pgrox,pgroy,pgtoy;
pgtoy=1;
while(pgtoy <= 25)
{
pgrox=0;
while(pgrox < 80)
{
pgroy=0;
while(pgroy <= 6)
{
sixthin(pgrox,pgroy,pgtoy,dscrollable);
// depth = 4
pgroy=pgroy+1;
}
pgrox=pgrox+1;
}
pgtoy=pgtoy+1;
}
cvwi=480;
cvwi=divmodi(cvwi,8,0);
pgtoy=0;
while(pgtoy < 175)
{
pgrox=0;
while(pgrox < cvwi)
{
cvdl=0;
pgroy=0;
while(pgroy < 8)
{
cvrl=(int)thintel[(pgtoy * 640) + (pgrox * 8)+pgroy];
if(cvrl != 0)cvdl=cvdl | cvhd[pgroy];
pgroy=pgroy+1;
}
cwln[pgrox]=(char)cvdl;
pgrox=pgrox+1;
}
vga_drawscansegment(cwln,0,pgtoy+pgtoy,cvwi);
vga_drawscansegment(cwln,0,pgtoy+pgtoy+1,cvwi);
pgtoy=pgtoy+1;
}
}
// -----------------
// depth = 0
int snlreadnz(char* snlroll,int* snlpos)
{
long long lsnlr;
int isnlr,isnlbot,isnlctr,isnlsub;
isnlbot=0;
isnlctr = *snlpos;
isnlr=20;
lsnlr=(long long)0;
isnlsub=1920+isnlctr;
while(isnlr != 0)
{
isnlr=vga_getkey();
}
while(isnlr == 0)
{
isnlr=vga_getkey();
}
while(isnlr != 0)
{
lsnlr=lsnlr*(long long)256;
lsnlr=lsnlr+(long long)isnlr;
isnlr=vga_getkey();
}
if((lsnlr >= 0L)&&(lsnlr <= 127L))
{
// depth = 2
isnlr=(int)lsnlr;
if((isnlr > 31)&&(isnlr < 127)&&(isnlctr < 80))
{
*(snlroll + isnlsub)=(char)isnlr;
*snlpos = isnlctr + 1;
}
if((isnlr == 8)||(isnlr == 127))
{
if(isnlctr > 0)
{
isnlctr=isnlctr-1;
isnlsub=isnlsub-1;
*snlpos=isnlctr;
}
*(snlroll + isnlsub)=(char)32;
}
if((isnlr == 10)||(isnlr == 13)||(isnlctr >= 79))
{
isnlbot=1;
}
}
thinpage(snlroll);
return isnlbot;
}
long long llicram(int licroff,int licrmany,long long* licrray)
{
long long llicres,llicterm,llicbase;
int licrtr,liczub,licneg;
licneg=256;
llicbase=(long long)licneg;
licrtr=0;
llicres=(long long)licrtr;
liczub=licrtr+licroff;
llicterm = *(licrray + liczub);
if((llicterm >= 0L)&&(llicterm <= 127L))licneg=0;
while(licrtr < licrmany)
{
liczub=licrtr+licroff;
llicterm=255L-(*(licrray + liczub));
if(licneg == 0)llicterm = *(licrray + liczub);
llicres = llicres * llicbase;
llicres = llicres + llicterm;
licrtr=licrtr+1;
}
if(licneg != 0)llicres = (long long)(0-1) - llicres;
return llicres;
}
void lluncram(long long *lucra,int lucrof,int lucmany,
long long lucfrom)
{
long long llicbase,lltop,llrem,llurev;
int lucneg,luczub,lucrtr;
lucneg=1;
lucrtr=0;
luczub=255;
llrem=(long long)lucrtr;
llurev=(long long)luczub;
luczub=1;
llicbase=(long long)luczub;
lltop=llrem-(lucfrom+llicbase);
if(lucfrom >= llrem)
{
lltop=lucfrom;
lucneg=0;
}
luczub=256;
llicbase=(long long)luczub;
lucrtr=lucmany-1;
while(lucrtr >= 0)
{
luczub=lucrtr+lucrof;
llrem=llurev-ldivmodi(lltop,llicbase,1);
if(lucneg == 0)llrem=ldivmodi(lltop,llicbase,1);
lltop=ldivmodi(lltop,llicbase,0);
*(lucra + luczub)=llrem;
lucrtr=lucrtr-1;
}
}
long long readip(char* ripscroll)
{
long long ripterm,ripres,ripbase,ripnase;
long long ripfive[5];
int ripctr,ripbub,ripfail;
ripctr=0;
ripres=(long long)ripctr;
ripbub=10;
ripbase=(long long)ripbub;
ripnase=ripres-ripbase;
ripbub=1;
ripfive[0]=ripres;
ripfail=0;
while(ripctr < 4)
{
if(ripfail == 0)
{
ripterm=lreadc((1920+ripbub),80,10,ripscroll);
ripbub=(int)lreadc((1920+ripbub),80,(0-10),ripscroll)-1920;
if(ripbub > 75)ripfail=1;
if(ripterm > 255L)ripfail=1;
ripfive[ripctr+1]=ripterm;
}
ripctr=ripctr+1;
}
ripres=ripnase;
if(ripfail == 0)ripres=llicram(0,5,ripfive);
return ripres;
}
void showip(char* sipscroll,long long sipbig)
{
long long sipfour[4];
int sipctr,sipwid,sipx,sipterm;
lluncram(sipfour,0,4,sipbig);
sipx=1921;
sipctr=0;
while(sipctr < 4)
{
sipterm=(int)sipfour[sipctr];
sipwid=1;
if(sipterm > 9)sipwid=2;
if(sipterm > 99)sipwid=3;
lprint(sipscroll,sipx,sipwid,10,(sipfour[sipctr]));
sipx=sipx+(sipwid-1);
if(sipctr < 3)(*(sipscroll + sipx))=(char)46;
sipx=sipx+2;
sipctr=sipctr+1;
}
}
int getipinfo(long long lgipa,int gipsel)
{
long long lgipfour[4];
int gipres,gipmsb;
lluncram(lgipfour,0,4,lgipa);
gipres=0;
if(gipsel == 1)
{
gipmsb=(int)lgipfour[0];
if((gipmsb >= 0)&&(gipmsb <= 126))gipres=65;
if((gipmsb >= 128)&&(gipmsb <= 191))gipres=66;
if((gipmsb >= 192)&&(gipmsb <= 223))gipres=67;
}
return gipres;
}
long long maskmake(int mmquan)
{
long long mmares,mmashift;
int mmactr;
mmactr=1;
mmashift=(long long)mmactr;
mmactr=0;
mmares=(long long)mmactr;
while(mmactr < 31)
{
mmashift=mmashift+mmashift;
mmactr=mmactr+1;
}
mmactr=0;
while(mmactr < mmquan)
{
mmares=mmares+mmashift;
mmashift=mmashift >> 1;
mmactr=mmactr+1;
}
return mmares;
}
void linto1921(char* lt1921,char* linfrom)
{
int tct,ltoctr,ltoallow;
ltoallow=1;
ltoctr=0;
while(ltoallow > 0)
{
tct=(int)(*(linfrom + ltoctr));
if(tct == 33)ltoallow=0;
if(tct < 32)ltoallow=0;
if(ltoallow > 0)
{
*(lt1921 + (1920+ltoctr))=(char)tct;
ltoctr=ltoctr+1;
if(ltoctr > 79)ltoallow=0;
}
}
}
int bentlog(long long lbenchk)
{
long long lbencmp,lbensl;
int lbenallow,lbenctr;
lbenctr=0;
lbenallow=1;
lbencmp=lbenchk+2L;
lbensl=1L;
while(lbenallow > 0)
{
if(lbensl >= lbencmp)lbenallow=0;
if(lbenallow > 0)
{
lbensl=lbensl+lbensl;
lbenctr=lbenctr+1;
if(lbenctr > 65)lbenallow=0;
}
}
return lbenctr;
}
int rizeroes(long long lrizchk)
{
long long lrizcmp,lrizsl;
int irizreopen,rizallow;
irizreopen=0;
lrizcmp=lrizchk;
rizallow=1;
lrizsl=1L;
while(rizallow > 0)
{
if((lrizcmp & lrizsl) != 0L)rizallow=0;
if(rizallow > 0)
{
lrizsl=lrizsl+lrizsl;
irizreopen=irizreopen+1;
if(irizreopen > 31)rizallow=0;
}
}
return irizreopen;
}
long long bentexp(int bepower)
{
long long berez;
int bectr;
berez=1L;
bectr=0;
while(bectr < bepower)
{
berez=berez+berez;
bectr=bectr+1;
}
berez=berez-2L;
if(berez < 0L)berez=0L;
return berez;
}
// end of vgsubnet.c
/* after end of vgsubnet.c
vgsubnet.c requires zackvga.h to compile
click below to get the required zackvga.h header
http://groups.google.com/group/comp....e=source&hl=en
that link will ask you to click on one additional link
to get its helper file wgslater.c
for three files altogether.
Eric Matteson
ericmatteson2003novemb...@hotmail.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Routing - Computers on either subnet have problems finding PCs on the other subnet ZZYZX Windows Networking 2 03-26-2011 01:01 AM
WiMAX throughput calculations Hany Kamal Broadband 0 05-27-2008 05:46 PM
VPN Clients and subnet, NOT the usual "255.255.255.255 subnet mask" question! snowdog_2112 Windows Networking 4 09-09-2006 01:35 AM
subnet to subnet routing question S James Linux Networking 0 09-04-2003 03:37 PM
Wireless network range calculations Graham Wireless Internet 7 07-11-2003 01:54 AM



1 2 3 4 5 6 7 8 9 10 11