int read_lc(struct picture *pict){ int i,j,zx,zy; pict->xres=X_RES*zoom; pict->yres=Y_RES*zoom; pict->bps=1; pict->gray=gray; pict->buffer=malloc(X_RES*Y_RES*((gray)?1:3)*zoom*zoom); unsigned char *lbuf=pict->buffer; LCD_Init(); for(i=0; i<Y_RES; i++) { for(zx=0; zx<zoom; zx++) { for(j=0; j<X_RES; j++) { if(raw[j][i]) { for(zy=0; zy<zoom; zy++) { if(gray) { *(lbuf++)=0xFF; } else { *(lbuf++)=pixcolor.red; *(lbuf++)=pixcolor.green; *(lbuf++)=pixcolor.blue; } } } else { lbuf+=((gray)?1:3)*zoom; } } } } LCD_Close(); pict->colormap=(struct fb_cmap*)malloc(sizeof(struct fb_cmap)); pict->colormap->red=(__u16*)malloc(sizeof(__u16)*(1<<pict->bps)); pict->colormap->green=(__u16*)malloc(sizeof(__u16)*(1<<pict->bps)); pict->colormap->blue=(__u16*)malloc(sizeof(__u16)*(1<<pict->bps)); pict->colormap->transp=(__u16*)malloc(sizeof(__u16)*(1<<pict->bps)); pict->colormap->start=0; pict->colormap->len=1<<pict->bps; pict->colormap->red[1]=0xFF<<8; pict->colormap->green[1]=0xFF<<8; pict->colormap->blue[1]=0xFF<<8; pict->colormap->transp[0]=0xFF<<8; return 0; }
int main (void) { int loop=0, werbung=0, tnet=-1,blit=0,cnum=-1,tv,wflag=1,runtime=0, mut=0, vol=0, tmin=15; char tstr[40],zapchan[40],msgchan[40]; FILE *fh1; time_t t1,t2,t3,t4; printf("Blockad Version %s\n",P_VERSION); if (!ReadConf()) { printf("Blockad <Configuration failed>\n"); } else { if((fh1=fopen(FLG_FILE,"r"))!=NULL) { if(fgets(zapchan, sizeof(zapchan), fh1)) { Trim_String(zapchan); if(fgets(tstr, sizeof(tstr), fh1)) { sscanf(tstr,"%d",&cnum); if(fgets(tstr, sizeof(tstr), fh1)) { sscanf(tstr,"%d",&rezap); if(fgets(msgchan, sizeof(msgchan), fh1)) { Trim_String(msgchan); } else { sprintf(msgchan,"Unbekannt"); } if(fgets(tstr, sizeof(tstr), fh1)) { if(sscanf(tstr,"%d",&vol)==1) { if(volume) { if(fgets(tstr, sizeof(tstr), fh1)) { if(sscanf(tstr,"%d",&mut)!=1) { mut=0; } } } } } if(fgets(tstr, sizeof(tstr), fh1)) { if(sscanf(tstr,"%d",&tmin)!=1) { tmin=15; } } } } else { rezap=420; } loop=1; if(cnum<0) { inet=-1; } } fclose(fh1); } time(&t1); t4=t3=t1; #ifdef HAVE_DBOX_HARDWARE LCD_Init(); #endif if(inet>=0) { if(Open_Socket()==-1) { inet=-1; } } while(loop) { time(&t2); if(inet>=0) { tnet=-1; if(inet>=0) { tv=Check_Socket(cnum,&werbung); if(!werbung) { if((t2-t4)>tmin) { Do_Rezap(zapchan,vol,mut); loop=0; } } else { t4=t2; } if(tv>=0) { tnet=inet; } } inet=tnet; } if(loop) { if((fh1=fopen(FLG_FILE,"r"))!=NULL) { fclose(fh1); if(inet>=0) { if(wflag) { fh1=fopen(STS_FILE,"w"); fprintf(fh1,"%s\n",msgchan); fprintf(fh1,"Auto\n"); fclose(fh1); wflag=0; } if(t3!=t2) { sprintf(tstr,"%s",(blit^=1)?" ":" WZ"); #ifdef HAVE_DBOX_HARDWARE LCD_Read(); LCD_draw_string(97, 13, tstr); LCD_update(); #endif t3=t2; } sleep(1); } else { runtime=t2-t1; if(runtime>rezap) { Do_Rezap(zapchan,vol,mut); loop=0; } else { if(t3!=t2) { runtime=rezap-runtime; sprintf(tstr,"%2d:%02d",runtime/60,runtime%60); fh1=fopen(STS_FILE,"w"); fprintf(fh1,"%s\n",msgchan); fprintf(fh1,"%s\n",tstr); fclose(fh1); #ifdef HAVE_DBOX_HARDWARE LCD_Read(); LCD_draw_string(81, 13, tstr); LCD_update(); #endif sleep(1); t3=t2; } } } } else { loop=0; } } } } #ifdef HAVE_DBOX_HARDWARE LCD_Close(); #endif if(inet>=0) { Close_Socket(); } sprintf(tstr,"cd /tmp\nrm blockads.*"); system(tstr); return 0; }