Cover V05, I02
Article
Figure 1
Figure 2
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Sidebar 1
Sidebar 2
Sidebar 3

feb96.tar


Listing 3: seluser(char*)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "latool.h"

/*
* AUTHOR: Charles C. Bundy IV
* VERS  : $Id$
*
* seluser(char *)
* Reads a password file and builds an HTML selectable
* list of all login names on system.  If you aren't
* using NIS or DNS the default BSD/Unix file is
* '/etc/passwd'.
*/

void seluser(passfile)
char *passfile;
{
char line[255], *ch;
FILE *fp;
char username[10];
char *RCSID;

/*
* Try to open the programmer specified file
*/
fp = fopen(passfile, "r");
if (fp == NULL)
/*
* Ooops, can't open passfile! Try the Unix default
*/
fp = fopen("/etc/passwd","r");

if (fp != NULL)
{
printf("<SELECT NAME=\"ut_name\">\n");
fgets(line,250,fp);
strcpy(username, (char*) strtok(line,":"));
printf("<OPTION SELECTED> %s", username);

fgets(line,250,fp);
strcpy(username, (char*) strtok(line,":"));
while (!feof(fp))
{
printf("<OPTION> %s", username);
fgets(line,250,fp);
strcpy(username, (char*) strtok(line,":"));
}

printf("</SELECT>");
}
fclose(fp);

RCSID = "$Id$";
}

/* End of File */