list.c File Reference

#include "cgi.h"

Include dependency graph for list.c:

Go to the source code of this file.

Functions

void PrintAdminForm (EZSSTREAM *htmlout, char *db, char *pwd)
int GenerateReport (EZSSTREAM *htmlout, FILE *db, CGINameValue *data, char *dbname, char *querytext, char *password, unsigned long range_count, unsigned long range_start)
int GenerateForm (EZSSTREAM *htmlout, CGINameValue *data, char *dbname, int record, char *password)
int FormatHTML (char *progname, char *file)
int PrintPassword (EZSSTREAM *htmlout, CGINameValue *Params)
unsigned long CharToUL (char *str, unsigned long defalt)
int CGImain (char *progname, CGINameValue *Params, EZSSTREAM *htmlout)
int PrintCSS (EZSSTREAM *htmlout)
int PrintQueryForm (EZSSTREAM *htmlout, char *dbname, char *password)
int PrintRangeLinks (EZSSTREAM *htmlout, char *dbname, char *password, unsigned long range_count, unsigned long range_start)
int PrintRecords (EZSSTREAM *htmlout, FILE *db, CGINameValue *data, char *dbname, char *query, char *password, unsigned long range_count, unsigned long range_start, char *Comparison, char *lastfieldname, int flags)
int GenerateTableHeader (EZSSTREAM *htmlout, CGINameValue *data, char *lastfieldname)


Function Documentation

int CGImain char *  progname,
CGINameValue Params,
EZSSTREAM htmlout
 

  • _PAGE stores the page currently being viewed
  • _PAGENEXT is a FIFO of the pages to go to. New pages are appended
  • _PAGEBACK is a LIFO for the "Previous" button. New pages are prepended

For both of these lists, the "current" value is taken from the beginning of the comma-delimited values.

Definition at line 44 of file list.c.

References CGI_ALLOW_READ, CharToUL(), DATABASE, DatabaseClose(), DatabaseFFD(), DatabaseOpen(), DatabaseReadRecord(), DeleteNVP(), ExpandLocalPath(), GenerateForm(), GenerateReport(), GetFieldValue, GetSecurityFlags(), GetSetting(), HTMLEscape(), HTMLPrintf(), HTMLWrite(), LogError(), MAXPATH, NULL, NULLSTR, PrintAdminForm(), ReadINIFileSection(), RenameField(), SendCGIHeader(), and strnicmp().

00046 {/* security level depends on what you're trying to do */
00047  char * dbname = GetFieldValue(Params,"DATABASE");
00048  char * password = GetFieldValue(Params,"_PASSWORD");
00049  char * action = GetFieldValue(Params,"_ACTION");
00050  char * query = GetFieldValue(Params,"_QUERY");
00051  unsigned long range_count = CharToUL(GetFieldValue(Params,"_COUNT"),50);
00052  unsigned long range_start = CharToUL(GetFieldValue(Params,"_START"),0);
00053  int record = atoi(GetFieldValue(Params,"_ROWID"));
00054  int ret=0;
00055  int iaction=0;
00056  char databasefile[MAXPATH];
00057  char fn[MAXPATH];
00058  CGINameValue* config=0;
00059  int Security=0;
00060  DATABASE* db=0;
00061  CGINameValue * data=0;
00062 
00063 #ifdef CGI_ALLOW
00064  Security = GetSecurityFlags(progname,GetFieldValue(Params,"HOST"),dbname,password);
00065 #else
00066  Security = GetSecurityFlags(progname,0,dbname,password);
00067 #endif
00068  /* Use a standard header. */
00069  SendCGIHeader(htmlout,NULL);
00070 
00071  if (!*action || !*dbname || !(Security & CGI_ALLOW_READ))
00072  {
00073   PrintAdminForm(htmlout,dbname,password);
00074   return 0;
00075  }
00076 
00077  RenameField(Params,"DATABASE",0);
00078 
00079  {
00080     ExpandLocalPath(progname,fn,dbname,".ini");
00081     config = ReadINIFileSection(fn,"DATABASE",0);
00082    if (config == NULL)
00083    {
00084     HTMLWrite(htmlout,progname);
00085     HTMLWrite(htmlout,": A configuration file was not found. "
00086                      "Please check your server setup and try again.<P>\n");
00087     PrintAdminForm(htmlout,dbname,password);
00088     LogError("\nCould not open config file");
00089     LogError(fn);
00090     return 21;
00091    }
00092  }
00093 
00094  {
00095    char * c;
00096    memset(databasefile,0,MAXPATH);
00097 
00098    c = GetSetting(config,"SAVEDATANAME",NULLSTR);
00099 
00100    if (c[0] == 0) /* use the default name, "database.asc" */
00101     ExpandLocalPath(progname,databasefile,dbname,".asc");
00102    else /* use the filename from the config file, but in the current directory */
00103     ExpandLocalPath(progname,databasefile,c,NULLSTR);
00104  }
00105 
00106  ret = 0;
00107  if (!strnicmp(action,"VIEW",4))   iaction=4;
00108  else if (!strnicmp(action,"LIST",4))   iaction=7;
00109  else
00110    {
00111     HTMLWrite(htmlout,"Invalid command: ");
00112     HTMLEscape(htmlout,action);
00113     return 30;
00114    }
00115 
00116  if (!DatabaseOpen(databasefile,&db,&data,0,0))
00117  {
00118     HTMLWrite(htmlout,"Unable to open the data file: ");
00119     HTMLEscape(htmlout,dbname);
00120     LogError("\nCould not open the data file in LIST ");
00121     LogError(databasefile);
00122     return 3;
00123  }
00124 
00125  if (iaction == 7)
00126   {
00127    ret = GenerateReport(htmlout,db, data, dbname, query, password, range_count, range_start);
00128   }
00129  else if (iaction == 4 && record > 0) /* view */
00130  {
00131   DatabaseFFD(db,record-1);
00132 
00133   if (DatabaseReadRecord(db,data,0))
00134    {
00135     ret = GenerateForm(htmlout, data, dbname, record, password);
00136    }
00137   else
00138    {
00139     HTMLPrintf(htmlout,"Row (%d) does not exist in the database.",record);
00140     ret = 8;
00141    }
00142  } /* ret == 0 */
00143 
00144  DatabaseClose(db,data);
00145  DeleteNVP(config);
00146  return ret;
00147 }

unsigned long CharToUL char *  str,
unsigned long  defalt
 

Definition at line 311 of file list.c.

Referenced by CGImain().

00312 {
00313 
00314     long rslt = 0;
00315 
00316     if(!str)
00317         return defalt;
00318 
00319     if(*str)
00320         rslt = atol(str);
00321 
00322     if(rslt <= 0)
00323         return defalt;
00324     else
00325         return (unsigned long)rslt;
00326 }

int FormatHTML char *  progname,
char *  file
 

int GenerateForm EZSSTREAM htmlout,
CGINameValue data,
char *  dbname,
int  record,
char *  password
 

Definition at line 530 of file list.c.

References HTMLEscape(), HTMLPrintf(), HTMLWrite(), CGINameValue::name, PrintCSS(), and PrintQueryForm().

Referenced by CGImain().

00532                    : print, else view 4/edit 5/copy 6 */
00533 {
00534    unsigned long x = 0;
00535 
00536     /* Start HTML */
00537     /* Start HTML HEAD */
00538     HTMLWrite(htmlout,"<HTML>\n");
00539     HTMLWrite(htmlout,"<HEAD>\n");
00540 
00541     /* Write the CSS */
00542     PrintCSS(htmlout);
00543 
00544     HTMLWrite(htmlout,"</HEAD>\n\n"); /* End HTML HEAD */
00545 
00546     /* Start HTML BODY */
00547     HTMLWrite(htmlout,"<BODY>\n");
00548 
00549     HTMLPrintf(htmlout,"<H2>Viewing record %d</H2>", record);
00550 
00551     /* Write the Query form */
00552     PrintQueryForm(htmlout,dbname,password);
00553 
00554 
00555     HTMLWrite(htmlout,"<HR>\n");
00556 
00557 
00558     HTMLWrite(htmlout,"<TABLE>\n");
00559 
00560     for(x=0; data[x].name; x++)
00561     {
00562         if (x%2)
00563             HTMLWrite(htmlout,"<TR CLASS=\"LIGHT\">\n");
00564         else
00565             HTMLWrite(htmlout,"<TR CLASS=\"DARK\">\n");
00566 
00567         //name
00568         HTMLWrite(htmlout,"<TD>");
00569         HTMLWrite(htmlout,data[x].name);
00570         HTMLWrite(htmlout,"</TD>\n");
00571 
00572         //value
00573         HTMLWrite(htmlout,"<TD>");
00574         if (data[x].value)
00575             HTMLEscape(htmlout,data[x].value);
00576         else
00577             HTMLWrite(htmlout,"&nbsp;");
00578         HTMLWrite(htmlout,"</TD>\n");
00579     }
00580 
00581     HTMLWrite(htmlout,"</TABLE>\n\n");
00582 
00583 
00584     /* Print the list recrods Link */
00585     /*
00586     HTMLWrite(htmlout,"<FORM METHOD=GET>\n");
00587     HTMLWrite(htmlout,"<INPUT TYPE=HIDDEN NAME=_ACTION VALUE=LIST>");
00588     HTMLWrite(htmlout,"<INPUT TYPE=HIDDEN NAME=DATABASE VALUE=\"");
00589     HTMLWrite(htmlout,dbname);
00590     HTMLWrite(htmlout,"\">\n");
00591 
00592     HTMLWrite(htmlout,"<INPUT TYPE=HIDDEN NAME=_PASSWORD VALUE=\"");
00593     HTMLWrite(htmlout,password);
00594     HTMLWrite(htmlout,"\">");
00595     HTMLWrite(htmlout,"<P><INPUT TYPE=SUBMIT VALUE=\"List records\">");
00596 
00597     HTMLWrite(htmlout,"\n</FORM>");
00598     */
00599 
00600 
00601     HTMLWrite(htmlout,"</BODY>\n</HTML>\n\n"); /* End HTML BODY and HTML */
00602 
00603     return 0;
00604 }

int GenerateReport EZSSTREAM htmlout,
FILE *  db,
CGINameValue data,
char *  dbname,
char *  querytext,
char *  password,
unsigned long  range_count,
unsigned long  range_start
 

Definition at line 462 of file list.c.

References CGIFREE, GenerateTableHeader(), HTMLWrite(), NULLSTR, PrintCSS(), PrintQueryForm(), PrintRangeLinks(), PrintRecords(), and strdup().

Referenced by CGImain().

00466 {
00467     /*CGINameValue * query = ReadPairedString(querytext,';',0);  */
00468 
00469     char * lastfieldname = NULLSTR;
00470     int flags = 0;
00471     //int i=0;
00472     char * Comparison = strdup(query);
00473 
00474     /* check inputs */
00475     if(!data) return -1;
00476 
00477 
00478     /* Start HTML */
00479     /* Start HTML HEAD */
00480     HTMLWrite(htmlout,"<HTML>\n");
00481     HTMLWrite(htmlout,"<HEAD>\n");
00482 
00483     /* Write the CSS */
00484     PrintCSS(htmlout);
00485 
00486     HTMLWrite(htmlout,"</HEAD>\n\n"); /* End HTML HEAD */
00487 
00488     /* Start HTML BODY */
00489     HTMLWrite(htmlout,"<BODY>\n");
00490 
00491     HTMLWrite(htmlout,"<h3>EZSurvey Database List</h3>\n");
00492 
00493     /* Write the Query form */
00494     PrintQueryForm(htmlout,dbname,password);
00495 
00496     HTMLWrite(htmlout,"<HR>\n");
00497 
00498     //Print the range links.
00499     PrintRangeLinks(htmlout, dbname, password, range_count, range_start);
00500 
00501     /* Write the table and the header row. */
00502     HTMLWrite(htmlout,"<TABLE CLASS=\"LIST\">\n");
00503     GenerateTableHeader(htmlout,data,lastfieldname);
00504 
00505     /* Write all of the records.*/
00506     PrintRecords(htmlout,db,data,dbname,query,password,range_count,range_start,Comparison,lastfieldname,flags);
00507 
00508     HTMLWrite(htmlout,"\n</TABLE>\n\n\n");
00509 
00510     //Print the range links.
00511     PrintRangeLinks(htmlout, dbname, password, range_count, range_start);
00512 
00513     /* Write the Query form */
00514     // PrintQueryForm(htmlout,dbname,password);
00515 
00516 
00517     HTMLWrite(htmlout,"</BODY>\n</HTML>\n\n"); /* End HTML BODY and HTML */
00518 
00519     CGIFREE(Comparison);
00520     /*if (query != NULL) DeleteNVP(query);   */
00521     return 0;
00522 }

int GenerateTableHeader EZSSTREAM htmlout,
CGINameValue data,
char *  lastfieldname
 

Definition at line 428 of file list.c.

References HTMLWrite(), CGINameValue::name, and stricmp().

Referenced by GenerateReport().

00429 {
00430     unsigned long i=0;
00431 
00432     HTMLWrite(htmlout,"<TR><TH COLSPAN=2>Row Actions");
00433 
00434     for (i=0; data[i].name; i++)
00435     {
00436         char * c;
00437         c=strchr(data[i].name,'_');
00438         if (c) *c = 0;
00439         if (data[i].name[0] == 0) continue;
00440 
00441         if (stricmp(lastfieldname,data[i].name))
00442         {
00443             HTMLWrite(htmlout,"<TH>");
00444             HTMLWrite(htmlout,data[i].name);
00445             HTMLWrite(htmlout,"</TH>");
00446         }
00447 
00448         lastfieldname = data[i].name;
00449 
00450     }
00451     HTMLWrite(htmlout,"</TR>");
00452 
00453 
00454     return 0;
00455 }

void PrintAdminForm EZSSTREAM htmlout,
char *  db,
char *  pwd
 

Definition at line 611 of file list.c.

References HTMLPrintf(), HTMLWrite(), and PrintCSS().

Referenced by CGImain().

00612 {
00613     char* warning_color = "#FF0000";
00614 
00615     /* Start HTML */
00616     /* Start HTML HEAD */
00617     HTMLWrite(htmlout,"<HTML>\n");
00618     HTMLWrite(htmlout,"<HEAD>\n");
00619 
00620     /* Write the CSS */
00621 
00622 
00623     PrintCSS(htmlout);
00624 
00625     HTMLWrite(htmlout,"</HEAD>\n\n"); /* End HTML HEAD */
00626 
00627     /* Start HTML BODY */
00628     HTMLWrite(htmlout,"<BODY>\n");
00629 
00630 
00631     HTMLWrite(htmlout, "<FORM method=\"post\" ACCEPT-CHARSET=\"UTF-8\"><h4>To view a database or report, please choose an option:</h4>\n");
00632 
00633     HTMLWrite(htmlout, "<TABLE>\n");
00634 
00635     HTMLWrite(htmlout, "<TR><TD CLASS=\"OPTION\">");
00636     HTMLPrintf(htmlout, "Database:<font color=\"%s\">*</font>",warning_color);
00637     HTMLWrite(htmlout, "</TD><TD CLASS=\"OPTION\">");
00638     HTMLPrintf(htmlout,"<input name=\"DATABASE\" VALUE=\"%s\">\n",db);
00639     HTMLWrite(htmlout, "</TD></TR>\n");
00640 
00641 
00642     HTMLWrite(htmlout, "<TR><TD CLASS=\"OPTION\">");
00643     HTMLPrintf(htmlout,"Query:");
00644     HTMLWrite(htmlout, "</TD><TD CLASS=\"OPTION\">");
00645     HTMLWrite(htmlout, "<INPUT NAME=\"_QUERY\">");
00646     HTMLWrite(htmlout, " (<b>field</b>=<i>value</i>&amp;<b>field</b>=<i>value</i>)");
00647     HTMLWrite(htmlout, "</TD></TR>\n");
00648 
00649     HTMLWrite(htmlout, "<TR><TD CLASS=\"OPTION\">");
00650     HTMLPrintf(htmlout, "Password:<font color=\"%s\">*</font>",warning_color);
00651     HTMLWrite(htmlout, "</TD><TD CLASS=\"OPTION\">");
00652     HTMLPrintf(htmlout,"<INPUT TYPE=\"PASSWORD\" NAME=\"_PASSWORD\" VALUE=\"%s\">",pwd);
00653     HTMLWrite(htmlout, " (to use multiple passwords, separate them with commas)");
00654     HTMLWrite(htmlout, "</TD></TR>\n");
00655 
00656     HTMLWrite(htmlout, "<TR><TD CLASS=\"OPTION\">");
00657     HTMLWrite(htmlout, "<INPUT TYPE=\"HIDDEN\" NAME=\"_ACTION\" VALUE=\"LIST\">");
00658     HTMLWrite(htmlout, "<INPUT TYPE=\"SUBMIT\" VALUE=\"List records\">");
00659     HTMLWrite(htmlout, "</TD></TR>\n");
00660 
00661 
00662     HTMLWrite(htmlout, "</TABLE>\n\n");
00663 
00664 
00665     HTMLWrite(htmlout, "</FORM>\n");
00666     HTMLWrite(htmlout, "<HR>&copy; 2002 by Raosoft, Inc. All Rights Reserved.");
00667 
00668 
00669     HTMLWrite(htmlout,"</BODY>\n</HTML>\n\n"); /* End HTML BODY and HTML */
00670 }

int PrintCSS EZSSTREAM htmlout  ) 
 

Definition at line 184 of file list.c.

References HTMLWrite().

Referenced by GenerateForm(), GenerateReport(), and PrintAdminForm().

00185 {
00186 
00187     /* Use CSS */
00188     HTMLWrite(htmlout,"<style type=\"text/css\">\n");
00189 
00190     HTMLWrite(htmlout,"BODY\n{\n");
00191     HTMLWrite(htmlout,"background-color: white;\n");
00192     HTMLWrite(htmlout,"font-family: courier;\n");
00193     HTMLWrite(htmlout,"font-size: 100%;\n");
00194     HTMLWrite(htmlout,"color: #000000;\n");
00195     HTMLWrite(htmlout,"}\n\n");
00196 
00197     HTMLWrite(htmlout,"TABLE\n{\n");
00198     HTMLWrite(htmlout,"border-collapse: collapse;\n");
00199     HTMLWrite(htmlout,"}\n\n");
00200 
00201     HTMLWrite(htmlout,"TR\n{\n");
00202     HTMLWrite(htmlout,"font-size: 100%;\n");
00203     HTMLWrite(htmlout,"border: thin solid #000000;\n");
00204     HTMLWrite(htmlout,"}\n\n");
00205 
00206     HTMLWrite(htmlout,"TR.DARK\n{\n");
00207     HTMLWrite(htmlout,"background-color: lightcyan;\n");
00208     HTMLWrite(htmlout,"}\n\n");
00209 
00210     HTMLWrite(htmlout,"TR.LIGHT\n{\n");
00211     HTMLWrite(htmlout,"background-color: lightyellow;\n");
00212     HTMLWrite(htmlout,"}\n\n");
00213 
00214     HTMLWrite(htmlout,"TH\n{\n");
00215     HTMLWrite(htmlout,"font-size: 50%;\n");
00216     HTMLWrite(htmlout,"border-width: thin;\n");
00217     HTMLWrite(htmlout,"border-style: solid;\n");
00218     HTMLWrite(htmlout,"border-color: #000000;\n");
00219     HTMLWrite(htmlout,"padding: 3px;\n");
00220     HTMLWrite(htmlout,"}\n\n");
00221 
00222     HTMLWrite(htmlout,"TD\n{\n");
00223     HTMLWrite(htmlout,"font-size: 50%;\n");
00224     HTMLWrite(htmlout,"border-width: thin;\n");
00225     HTMLWrite(htmlout,"border-style: solid;\n");
00226     HTMLWrite(htmlout,"border-color: slategray;\n");
00227     HTMLWrite(htmlout,"text-align: center;\n");
00228     HTMLWrite(htmlout,"}\n\n");
00229 
00230     HTMLWrite(htmlout,"TD.INDEX\n{\n");
00231     HTMLWrite(htmlout,"color: #FF0000;\n");
00232     HTMLWrite(htmlout,"font-size: 30%;\n");
00233     HTMLWrite(htmlout,"font-weight: bold;\n");
00234     HTMLWrite(htmlout,"}\n\n");
00235 
00236     HTMLWrite(htmlout,"TD.QUERY\n{\n");
00237     HTMLWrite(htmlout,"color: #000000;\n");
00238     HTMLWrite(htmlout,"border-color: #FFFFFF;\n");
00239     HTMLWrite(htmlout,"}\n\n");
00240 
00241     HTMLWrite(htmlout,"TD.OPTION\n{\n");
00242     HTMLWrite(htmlout,"color: #000000;\n");
00243     HTMLWrite(htmlout,"border-color: #FFFFFF;\n");
00244     HTMLWrite(htmlout,"text-align: left;\n");
00245     HTMLWrite(htmlout,"}\n\n");
00246 
00247     HTMLWrite(htmlout,"TABLE.LIST\n{\n");
00248     HTMLWrite(htmlout,"border-width: thin;\n");
00249     HTMLWrite(htmlout,"border-style: solid;\n");
00250     HTMLWrite(htmlout,"border-color: #000000;\n");
00251     HTMLWrite(htmlout,"}\n\n");
00252 
00253     HTMLWrite(htmlout,"</style>\n"); /* End CSS */
00254 
00255     return 0;
00256 }

int PrintPassword EZSSTREAM htmlout,
CGINameValue Params
 

Definition at line 160 of file list.c.

References HTMLWrite(), and stricmp().

00161 {
00162  int i;
00163  HTMLWrite(htmlout,"<FORM METHOD=POST ACCEPT-CHARSET=\"UTF-8\">\n");
00164  for (i=0; Params[i].name; i++)
00165   {
00166    if (!stricmp(Params[i].name,"_PASSWORD")) continue;
00167 
00168    HTMLWrite(htmlout,"<INPUT TYPE=HIDDEN VALUE=\"");
00169    HTMLWrite(htmlout,Params[i].value);
00170    HTMLWrite(htmlout,"\">\n");
00171   }
00172 
00173   HTMLWrite(htmlout,"Password: <INPUT NAME=_PASSWORD TYPE=PASSWORD>\n");
00174   HTMLWrite(htmlout,"<INPUT TYPE=SUBMIT>\n");
00175   HTMLWrite(htmlout,"</FORM>\n");
00176   return 0;
00177 }

int PrintQueryForm EZSSTREAM htmlout,
char *  dbname,
char *  password
 

Definition at line 263 of file list.c.

References HTMLPrintf(), and HTMLWrite().

Referenced by GenerateForm(), and GenerateReport().

00264 {
00265 
00266     /* Write the Query form */
00267 
00268     HTMLWrite(htmlout, "<TABLE><TR><TD CLASS=\"QUERY\">");
00269 
00270     HTMLPrintf(htmlout,"<FORM ACCEPT-CHARSET=\"UTF-8\"><INPUT TYPE=HIDDEN NAME=DATABASE VALUE=\"%s\">\n",dbname);
00271     HTMLPrintf(htmlout,"<INPUT TYPE=HIDDEN NAME=_PASSWORD VALUE=\"%s\">\n",password);
00272     HTMLWrite(htmlout, " Query: <INPUT NAME=_QUERY>");
00273     HTMLWrite(htmlout, "<INPUT TYPE=SUBMIT NAME=_ACTION VALUE=\"List records\">\n");
00274     HTMLWrite(htmlout, "</FORM>\n\n");
00275 
00276     HTMLWrite(htmlout, "</TD><TD CLASS=\"QUERY\">");
00277 
00278     /* Write the Start over form */
00279     HTMLWrite(htmlout, "<FORM ACCEPT-CHARSET=\"UTF-8\">\n<INPUT TYPE=SUBMIT NAME=_ACTION VALUE=\"Start over\"></FORM>\n");
00280 
00281 
00282     HTMLWrite(htmlout, "</TD></TABLE>");
00283 
00284     HTMLWrite(htmlout, "(<b>field</b>=<i>value</i>&<b>field</b>=<i>value</i>) wildcards are _ and %\n");
00285 
00286 
00287     return 0;
00288 }

int PrintRangeLinks EZSSTREAM htmlout,
char *  dbname,
char *  password,
unsigned long  range_count,
unsigned long  range_start
 

Definition at line 294 of file list.c.

References HTMLPrintf(), and HTMLWrite().

Referenced by GenerateReport().

00296 {
00297 
00298 
00299     HTMLPrintf(htmlout,"<a href=\"?DATABASE=%s&_PASSWORD=%s&_ACTION=LIST&_COUNT=%i&_START=%i\">Back</a>",dbname,password,range_count,range_start-range_count);
00300     HTMLWrite(htmlout, " | ");
00301     HTMLPrintf(htmlout,"<a href=\"?DATABASE=%s&_PASSWORD=%s&_ACTION=LIST&_COUNT=%i&_START=%i\">Next</a>",dbname,password,range_count,range_start+range_count);
00302 
00303     return 0;
00304 }

int PrintRecords EZSSTREAM htmlout,
FILE *  db,
CGINameValue data,
char *  dbname,
char *  query,
char *  password,
unsigned long  range_count,
unsigned long  range_start,
char *  Comparison,
char *  lastfieldname,
int  flags
 

Definition at line 332 of file list.c.

References DatabaseReadRecord(), EvaluateLogic(), HTMLEscape(), HTMLPrintf(), HTMLWrite(), CGINameValue::name, stricmp(), and CGINameValue::value.

Referenced by GenerateReport().

00337 {
00338 
00339     unsigned long record = 0;       /* The record number in the database. */
00340     unsigned long row = 0;          /* The dark-light row indicator. */
00341     unsigned long i=0;              /* The column counter. */
00342     unsigned long j=0;              /* The index of the one we are on. */
00343     unsigned long range_max = range_start + range_count;
00344 
00345 
00346     /*char* format =
00347                 "<FORM><INPUT TYPE=\"HIDDEN\" NAME=\"_PASSWORD\" VALUE=\"%s\" />"
00348                 "<INPUT TYPE=\"HIDDEN\" NAME=\"DATABASE\" VALUE=\"%s\" />"
00349                 "<INPUT TYPE=\"HIDDEN\" NAME=\"_ROWID\" VALUE=\"%d\" />"
00350                 "<INPUT TYPE=\"SUBMIT\" NAME=\"_ACTION\" VALUE=\"View\" /></FORM>";
00351     */
00352     char* format = "<a href=\"?_PASSWORD=%s&DATABASE=%s&_ROWID=%d&_ACTION=View\">View</a>";
00353 
00354     /* check the inputs */
00355     if(!data) return -1;
00356     if(!dbname) return -1;
00357 
00358 
00359     for(j=0; j<range_max; j++)
00360     {
00361         DatabaseReadRecord(db,data,&flags);
00362 
00363 
00364         record ++;
00365         if(j<range_start) continue;
00366         if (flags) continue;
00367 
00368         strcpy(Comparison,query);
00369         if (!EvaluateLogic(Comparison,data,0)) continue;
00370         /* if (!DatabaseEvalQuery(data, query, 0)) continue; */
00371 
00372         /* keep track of the row number */
00373 
00374         /* Start the row */
00375         if (++row%2)
00376             HTMLWrite(htmlout,"\n<TR CLASS=\"LIGHT\">\n");
00377         else
00378             HTMLWrite(htmlout,"\n<TR CLASS=\"DARK\">\n");
00379 
00380         /* Write the index number */
00381         HTMLWrite(htmlout,"<TD>");
00382         HTMLPrintf(htmlout,format,password,dbname,record);
00383         HTMLPrintf(htmlout,"</TD>\n",record);
00384 
00385         HTMLPrintf(htmlout,"<TD CLASS=\"INDEX\">");
00386         HTMLPrintf(htmlout,"%d",record);
00387         HTMLPrintf(htmlout,"</TD>\n",record);
00388 
00389         /*Write each cell of the record*/
00390         for (i = 0 ; data[i].name; i++)
00391         {
00392             if (data[i].name[0] == 0) continue;
00393 
00394 
00395             /* The td tag is not needed when looking at multiple choice questions. */
00396             if(stricmp(lastfieldname,data[i].name))
00397                 HTMLWrite(htmlout,"<TD>");
00398             else
00399                 HTMLWrite(htmlout,",");
00400 
00401             /*Write the cell's data */
00402             if(data[i].value)
00403                 //HTMLWrite(htmlout,data[i].value);
00404                 HTMLEscape(htmlout,data[i].value);
00405             else
00406                 HTMLWrite(htmlout,"&nbsp;"); /* ensure that the table cell appears */
00407 
00408             /* The td tag is not needed when looking at multiple choice questions. */
00409             //if(stricmp(lastfieldname,data[i].name))
00410             //  HTMLPrintf(htmlout,"</TD>\n",record);
00411 
00412 
00413             lastfieldname = data[i].name;
00414         }
00415 
00416         HTMLWrite(htmlout,"</TR>\n\n"); /*End Record*/
00417 
00418     }
00419 
00420     return 0;
00421 }



Raosoft, Inc.
Raosoft EZReport, EZSurvey, InterForm, RapidReport, Raosoft, and SurveyWin are registered trademarks of Raosoft, Inc. Page contents © 1996-2007 by Raosoft, Inc. You may use and modify this file for your own use, but may not distribute it or derivative works without the prior written consent of Raosoft, Inc. This software is provided "as is," and Raosoft makes no warranty, express or implied, of fitness for a particular application. Every measure has been taken to anticipate risks inherent to computer networks, but we cannot guarantee safety or reliability of this program in every situation.
Tel: 206-525-4025 (US) Email: raosoft@raosoft.com
http://www.raosoft.com/