Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 12495 Details for
Bug 21826
Ebuild for kpnadsl4linux-1.10 with patches to ao. fix the restart feature
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
patch adslstatus.c
adslstatus.c.patch (text/plain), 13.45 KB, created by
Sam
on 2003-05-28 08:00:53 UTC
(
hide
)
Description:
patch adslstatus.c
Filename:
MIME Type:
Creator:
Sam
Created:
2003-05-28 08:00:53 UTC
Size:
13.45 KB
patch
obsolete
>*** adslstatus.c Fri Apr 25 14:29:37 2003 >--- new/adslstatus.c.new Fri Apr 25 14:15:08 2003 >*************** >*** 19,24 **** >--- 19,25 ---- > version 0.11 workaround for 4Gb overflow in counters in /proc/net/dev > version 0.12 error in recovery from abort on pppd > marker since last status request added on Cyberdude47's request >+ version 0.13 moved logging to /var/log/adsl4linux <sambesselink@planet.nl> > */ > > #ifdef HAVE_CONFIG_H >*************** >*** 68,78 **** > > while(fgets(buffer, 254, f)) > { if (strstr(buffer,"ppp0")!=NULL) >! { found = 1; > strcpy(pppBuf,buffer); > count = sscanf(buffer, "%*[ \t]%5[a-zA-Z0-9]%*1[:]%lf%*d%*d%*d%*d%*d%*d%*d%lf", (char *) &device, &received, &sent); >! break; >! } > } > fclose(f); > if (!found) >--- 69,79 ---- > > while(fgets(buffer, 254, f)) > { if (strstr(buffer,"ppp0")!=NULL) >! { found = 1; > strcpy(pppBuf,buffer); > count = sscanf(buffer, "%*[ \t]%5[a-zA-Z0-9]%*1[:]%lf%*d%*d%*d%*d%*d%*d%*d%lf", (char *) &device, &received, &sent); >! break; >! } > } > fclose(f); > if (!found) >*************** >*** 91,97 **** > { > /* logging must be started */ > /* first create a logfile for the current connection >! the timestamp is found in the create time of ppp-mxstream.pid > */ > > FILE *fp; >--- 92,98 ---- > { > /* logging must be started */ > /* first create a logfile for the current connection >! the timestamp is found in the create time of ppp-mxstream.pid > */ > > FILE *fp; >*************** >*** 102,108 **** > > strftime((char *) &buffer2, 100, "%Y-%m-%d %H:%M:%S", localtime(&st.st_ctime)); > fp = fopen(CURRSESSFILE,"rt"); >! if (fp) > { fgets(buffer,80,fp); > fclose(fp); > if (strncmp(buffer,buffer2,19)==0) >--- 103,109 ---- > > strftime((char *) &buffer2, 100, "%Y-%m-%d %H:%M:%S", localtime(&st.st_ctime)); > fp = fopen(CURRSESSFILE,"rt"); >! if (fp) > { fgets(buffer,80,fp); > fclose(fp); > if (strncmp(buffer,buffer2,19)==0) >*************** >*** 117,123 **** > fclose(fp); > } > } >! } > fp = fopen(CURRSESSFILE,"wt"); > if (fp) > { fprintf(fp,"%s %s %14.0f %14.0f",buffer2,buffer2,received,sent); >--- 118,124 ---- > fclose(fp); > } > } >! } > fp = fopen(CURRSESSFILE,"wt"); > if (fp) > { fprintf(fp,"%s %s %14.0f %14.0f",buffer2,buffer2,received,sent); >*************** >*** 126,137 **** > } > else > { fprintf(stderr,"\nFailed to create %s\n",CURRSESSFILE); >! return 1; > } > /* check for existence of daily counters */ > strftime((char *) &szToday, 79, "%Y-%m-%d", localtime(&st.st_ctime)); > if ( (fp = fopen(TODAYFILE,"rt"))) >! { fgets(buffer,80,fp); > fclose(fp); > if (strncmp(szToday,buffer,10)==0) > { /* same day */ >--- 127,138 ---- > } > else > { fprintf(stderr,"\nFailed to create %s\n",CURRSESSFILE); >! return 1; > } > /* check for existence of daily counters */ > strftime((char *) &szToday, 79, "%Y-%m-%d", localtime(&st.st_ctime)); > if ( (fp = fopen(TODAYFILE,"rt"))) >! { fgets(buffer,80,fp); > fclose(fp); > if (strncmp(szToday,buffer,10)==0) > { /* same day */ >*************** >*** 141,150 **** > sendToday = strtod(ptr, (char **) &ptr); > } > } >! else > { /* daily counters are from other day, caused by stop and restart next day so do some recovery */ > if ( (fp=fopen(DAILYLOG,"at") )) >! { double s,r; > char *ptr; > ptr = strchr(buffer,' '); > r = strtod(ptr, (char **) &ptr); >--- 142,151 ---- > sendToday = strtod(ptr, (char **) &ptr); > } > } >! else > { /* daily counters are from other day, caused by stop and restart next day so do some recovery */ > if ( (fp=fopen(DAILYLOG,"at") )) >! { double s,r; > char *ptr; > ptr = strchr(buffer,' '); > r = strtod(ptr, (char **) &ptr); >*************** >*** 154,160 **** > fclose(fp); > } > } >! } > if ((fp = fopen(TODAYFILE,"wt"))) > { fprintf(fp,"%s %14.0f %14.0f %14.0f %14.0f",szToday,recToday,sendToday,0.0,0.0); > fclose(fp); >--- 155,161 ---- > fclose(fp); > } > } >! } > if ((fp = fopen(TODAYFILE,"wt"))) > { fprintf(fp,"%s %14.0f %14.0f %14.0f %14.0f",szToday,recToday,sendToday,0.0,0.0); > fclose(fp); >*************** >*** 174,180 **** > } > if ( (fp=fopen(THISMONTHFILE,"wt"))) > { fprintf(fp,"%s %14.0f %14.0f",szMonth,0.0,0.0); >! fclose(fp); > } > } > } >--- 175,181 ---- > } > if ( (fp=fopen(THISMONTHFILE,"wt"))) > { fprintf(fp,"%s %14.0f %14.0f",szMonth,0.0,0.0); >! fclose(fp); > } > } > } >*************** >*** 182,188 **** > { /* create a monthcounter */ > if ( (fp=fopen(THISMONTHFILE,"wt"))) > { fprintf(fp,"%s %14.0f %14.0f",szMonth,0.0,0.0); >! fclose(fp); > } > } > /* create a marker file */ >--- 183,189 ---- > { /* create a monthcounter */ > if ( (fp=fopen(THISMONTHFILE,"wt"))) > { fprintf(fp,"%s %14.0f %14.0f",szMonth,0.0,0.0); >! fclose(fp); > } > } > /* create a marker file */ >*************** >*** 191,204 **** > { fprintf(fp,"%14.0f %14.0f",0.0,0.0); > fclose(fp); > } >! fprintf(stdout,"ADSL4Linux logging started:\n"); > return 0; > > } > > > int statuslogging() >! { > /* at first check if logging is enabled and that the logging belongs to current connection */ > FILE *fp; > char buffer[256],buffer2[256]; >--- 192,205 ---- > { fprintf(fp,"%14.0f %14.0f",0.0,0.0); > fclose(fp); > } >! fprintf(stdout,"ADSL4Linux connection logging started.\n"); > return 0; > > } > > > int statuslogging() >! { > /* at first check if logging is enabled and that the logging belongs to current connection */ > FILE *fp; > char buffer[256],buffer2[256]; >*************** >*** 213,230 **** > double sentMonth = 0.0; > double markRec = 0.0; > double markSent = 0.0; >! int duration,days,hours,minutes,seconds, totalhours; >! > strftime((char *) &buffer2, 100, "%Y-%m-%d %H:%M:%S", localtime(&st.st_ctime)); > fp = fopen(CURRSESSFILE,"rt"); >! if (fp) > { fgets(buffer,80,fp); > fclose(fp); > if (strncmp(buffer,buffer2,19)!=0) > { fprintf(stderr,"ADSL4Linux logging for old connection still active\n"); > return 0; > } >! } > else > { fprintf(stderr,"\nADSL4Linux logging is not started!\n"); > return 0; >--- 214,231 ---- > double sentMonth = 0.0; > double markRec = 0.0; > double markSent = 0.0; >! int duration,days,hours,minutes,seconds,totalhours; >! > strftime((char *) &buffer2, 100, "%Y-%m-%d %H:%M:%S", localtime(&st.st_ctime)); > fp = fopen(CURRSESSFILE,"rt"); >! if (fp) > { fgets(buffer,80,fp); > fclose(fp); > if (strncmp(buffer,buffer2,19)!=0) > { fprintf(stderr,"ADSL4Linux logging for old connection still active\n"); > return 0; > } >! } > else > { fprintf(stderr,"\nADSL4Linux logging is not started!\n"); > return 0; >*************** >*** 251,260 **** > markSent = sent - markSent; > markRec = received - markRec; > } >! else > { markRec = received; > markSent = sent; >! } > if (uid==0 && ( fp=fopen(MARKERFILE,"wt"))) > { fprintf(fp,"%14.0f %14.0f",received,sent); > fclose(fp); >--- 252,262 ---- > markSent = sent - markSent; > markRec = received - markRec; > } >! else > { markRec = received; > markSent = sent; >! } >! > if (uid==0 && ( fp=fopen(MARKERFILE,"wt"))) > { fprintf(fp,"%14.0f %14.0f",received,sent); > fclose(fp); >*************** >*** 269,275 **** > memset(szToday,0,80); > strftime((char *) &szToday, 79, "%Y-%m-%d", localtime(&tmNow)); > if ( (fp = fopen(TODAYFILE,"rt"))) >! { fgets(buffer,80,fp); > fclose(fp); > strncpy(szToday,buffer,10); > ptr = strchr(buffer,' '); >--- 271,277 ---- > memset(szToday,0,80); > strftime((char *) &szToday, 79, "%Y-%m-%d", localtime(&tmNow)); > if ( (fp = fopen(TODAYFILE,"rt"))) >! { fgets(buffer,80,fp); > fclose(fp); > strncpy(szToday,buffer,10); > ptr = strchr(buffer,' '); >*************** >*** 277,283 **** > sendToday = strtod(ptr, (char **) &ptr); > recPrevToday = strtod(ptr, (char **) &ptr); > sendPrevToday = strtod(ptr, (char **) &ptr); >! } > diffRec = received - recPrevToday; > diffSent = sent - sendPrevToday; > if ( diffRec < 0.0) diffRec += FOURGB; >--- 279,286 ---- > sendToday = strtod(ptr, (char **) &ptr); > recPrevToday = strtod(ptr, (char **) &ptr); > sendPrevToday = strtod(ptr, (char **) &ptr); >! } >! > diffRec = received - recPrevToday; > diffSent = sent - sendPrevToday; > if ( diffRec < 0.0) diffRec += FOURGB; >*************** >*** 292,304 **** > memset(szMonth,0,80); > strftime((char *) &szMonth, 79, "%Y-%m", localtime(&tmNow)); > if ( (fp = fopen(THISMONTHFILE,"rt"))) >! { fgets(buffer,80,fp); > fclose(fp); > strncpy(szMonth,buffer,7); > ptr = strchr(buffer,' '); > recMonth = strtod(ptr, (char **) &ptr); > sentMonth = strtod(ptr, (char **) &ptr); >! } > fprintf(stdout,"\nStatus for month %s\n",szMonth); > fprintf(stdout,"Bytes received %s\n",showAmount(recMonth+diffRec,szMonth)); > fprintf(stdout,"Bytes sent %s\n",showAmount(sentMonth+diffSent,szMonth)); >--- 295,307 ---- > memset(szMonth,0,80); > strftime((char *) &szMonth, 79, "%Y-%m", localtime(&tmNow)); > if ( (fp = fopen(THISMONTHFILE,"rt"))) >! { fgets(buffer,80,fp); > fclose(fp); > strncpy(szMonth,buffer,7); > ptr = strchr(buffer,' '); > recMonth = strtod(ptr, (char **) &ptr); > sentMonth = strtod(ptr, (char **) &ptr); >! } > fprintf(stdout,"\nStatus for month %s\n",szMonth); > fprintf(stdout,"Bytes received %s\n",showAmount(recMonth+diffRec,szMonth)); > fprintf(stdout,"Bytes sent %s\n",showAmount(sentMonth+diffSent,szMonth)); >*************** >*** 347,373 **** > > strftime((char *) &buffer2, 100, "%Y-%m-%d %H:%M:%S", localtime(&st.st_ctime)); > fp = fopen(CURRSESSFILE,"rt"); >! if (fp) > { fgets(szCurrent,80,fp); > fclose(fp); > if (strncmp(szCurrent,buffer2,19)!=0) > return 0; // old connection log >! } > else >! return 0; // logging not running > > /* Get todays info */ > memset(szToday,0,80); > strftime((char *) &buffer2, 79, "%Y-%m-%d", localtime(&tmNow)); > if ( (fp = fopen(TODAYFILE,"rt"))) >! { fgets(szToday,80,fp); > fclose(fp); > ptr = strchr(szToday,' '); > recToday = strtod(ptr, (char **) &ptr); > sendToday = strtod(ptr, (char **) &ptr); > recPrevToday = strtod(ptr, (char **) &ptr); > sendPrevToday = strtod(ptr, (char **) &ptr); >! } > diffRec = received - recPrevToday; > diffSent = sent - sendPrevToday; > if ( diffRec < 0.0) diffRec += FOURGB; >--- 350,376 ---- > > strftime((char *) &buffer2, 100, "%Y-%m-%d %H:%M:%S", localtime(&st.st_ctime)); > fp = fopen(CURRSESSFILE,"rt"); >! if (fp) > { fgets(szCurrent,80,fp); > fclose(fp); > if (strncmp(szCurrent,buffer2,19)!=0) > return 0; // old connection log >! } > else >! return 0; // logging not running > > /* Get todays info */ > memset(szToday,0,80); > strftime((char *) &buffer2, 79, "%Y-%m-%d", localtime(&tmNow)); > if ( (fp = fopen(TODAYFILE,"rt"))) >! { fgets(szToday,80,fp); > fclose(fp); > ptr = strchr(szToday,' '); > recToday = strtod(ptr, (char **) &ptr); > sendToday = strtod(ptr, (char **) &ptr); > recPrevToday = strtod(ptr, (char **) &ptr); > sendPrevToday = strtod(ptr, (char **) &ptr); >! } > diffRec = received - recPrevToday; > diffSent = sent - sendPrevToday; > if ( diffRec < 0.0) diffRec += FOURGB; >*************** >*** 377,388 **** > memset(szMonth,0,80); > strftime((char *) &buffer2, 79, "%Y-%m", localtime(&tmNow)); > if ( (fp = fopen(THISMONTHFILE,"rt"))) >! { fgets(szMonth,80,fp); > fclose(fp); > ptr = strchr(szMonth,' '); > recMonth = strtod(ptr, (char **) &ptr); > sentMonth = strtod(ptr, (char **) &ptr); >! } > > /* update the current session */ > fp = fopen(CURRSESSFILE,"wt"); >--- 380,391 ---- > memset(szMonth,0,80); > strftime((char *) &buffer2, 79, "%Y-%m", localtime(&tmNow)); > if ( (fp = fopen(THISMONTHFILE,"rt"))) >! { fgets(szMonth,80,fp); > fclose(fp); > ptr = strchr(szMonth,' '); > recMonth = strtod(ptr, (char **) &ptr); > sentMonth = strtod(ptr, (char **) &ptr); >! } > > /* update the current session */ > fp = fopen(CURRSESSFILE,"wt"); >*************** >*** 410,418 **** > if ( (fp = fopen(TODAYFILE,"wt"))) > { fprintf(fp,"%s %14.0f %14.0f %14.0f %14.0f",buffer2,diffRec+recToday,diffSent+sendToday,received,sent); > fclose(fp); >! } > >! /* update monthly counters */ > strftime((char *) &buffer2, 79, "%Y-%m", localtime(&tmNow)); > if (strncmp(szMonth,buffer2,7)!=0) > { memset(buffer,0,80); >--- 413,421 ---- > if ( (fp = fopen(TODAYFILE,"wt"))) > { fprintf(fp,"%s %14.0f %14.0f %14.0f %14.0f",buffer2,diffRec+recToday,diffSent+sendToday,received,sent); > fclose(fp); >! } > >! /* update monthly counters */ > strftime((char *) &buffer2, 79, "%Y-%m", localtime(&tmNow)); > if (strncmp(szMonth,buffer2,7)!=0) > { memset(buffer,0,80); >*************** >*** 425,433 **** > sentMonth=-diffSent; > } > if ( (fp = fopen(THISMONTHFILE,"wt"))) >! { fprintf(fp,"%s %14.0f %14.0f",buffer2,recMonth+diffRec,sentMonth+diffSent); > fclose(fp); >! } > > return 0; > } >--- 428,436 ---- > sentMonth=-diffSent; > } > if ( (fp = fopen(THISMONTHFILE,"wt"))) >! { fprintf(fp,"%s %14.0f %14.0f",buffer2,recMonth+diffRec,sentMonth+diffSent); > fclose(fp); >! } > > return 0; > } >*************** >*** 435,447 **** > int stoplogging() > { > FILE *fp; >! char buffer[100]; > > /* update all counters */ > usagelogging(); > statuslogging(); > fp = fopen(CURRSESSFILE,"rt"); >! if (fp) > { fgets(buffer,80,fp); > fclose(fp); > fp = fopen(SESSIONLOG,"at"); >--- 438,450 ---- > int stoplogging() > { > FILE *fp; >! char buffer[100]; > > /* update all counters */ > usagelogging(); > statuslogging(); > fp = fopen(CURRSESSFILE,"rt"); >! if (fp) > { fgets(buffer,80,fp); > fclose(fp); > fp = fopen(SESSIONLOG,"at");
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 21826
:
12488
|
12489
|
12490
|
12491
|
12492
|
12493
|
12494
| 12495 |
12496