#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
+#include <moira_schema.h>
#include <ctype.h>
#include <stdio.h>
FILE *in;
struct entry *e;
int i, wait = 0;
- char buf[BUFSIZ], *file = NULL;
+ char buf[80], *file = NULL;
EXEC SQL BEGIN DECLARE SECTION;
char *db = "moira";
EXEC SQL END DECLARE SECTION;
{
printf("Next");
fflush(stdout);
- gets(buf);
+ fgets(buf, sizeof(buf), stdin);
}
}
void process_entry(struct entry *e)
{
int changed, nochange, encrypted;
- char buf[BUFSIZ], *from, *to;
+ char buf[MAX_FIELD_WIDTH], *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
char *first, *last, *middle, *eid, *sid, *name, *rdept;
char *rtitle, *rophone, *rhphone, *prog;
- char class[9], haddr[128], hphone[33], ophone[33], dept[33], raddr[128];
- char dfirst[17], dlast[17], dmiddle[17];
+ char class[USERS_TYPE_SIZE], haddr[USERS_HOME_ADDR_SIZE];
+ char hphone[USERS_HOME_PHONE_SIZE], ophone[USERS_OFFICE_PHONE_SIZE];
+ char dept[USERS_DEPARTMENT_SIZE], raddr[USERS_XADDRESS_SIZE];
+ char dfirst[USERS_FIRST_SIZE], dlast[USERS_LAST_SIZE];
+ char dmiddle[USERS_MIDDLE_SIZE];
int id, status, who;
EXEC SQL END DECLARE SECTION;
who = WHO;
prog = PROG;
first = e->first;
- if (strlen(first) > 16)
- first[16] = '\0';
+ if (strlen(first) > USERS_FIRST_SIZE - 1)
+ first[USERS_FIRST_SIZE - 1] = '\0';
last = e->last;
- if (strlen(last) > 16)
- last[16] = '\0';
+ if (strlen(last) > USERS_LAST_SIZE - 1)
+ last[USERS_LAST_SIZE - 1] = '\0';
middle = e->middle;
+ if (strlen(middle) > USERS_MIDDLE_SIZE - 1)
+ middle[USERS_MIDDLE_SIZE - 1] = '\0';
eid = e->eid;
sid = e->id;
id = 0;
{
if (haddr[0] == ' ')
{
- strncpy(haddr, buf, 80);
- haddr[80] = '\0';
+ strncpy(haddr, buf, USERS_HOME_ADDR_SIZE - 1);
+ haddr[USERS_HOME_ADDR_SIZE - 1] = '\0';
changed++;
}
- else if (strncmp(strtrim(haddr), buf, 80))
+ else if (strncmp(strtrim(haddr), buf, USERS_HOME_ADDR_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(haddr), buf, 80))
+ if (strncmp(strtrim(haddr), buf, USERS_HOME_ADDR_SIZE - 1))
changed++;
- strncpy(haddr, buf, 80);
- haddr[80] = '\0';
+ strncpy(haddr, buf, USERS_HOME_ADDR_SIZE - 1);
+ haddr[USERS_HOME_ADDR_SIZE - 1] = '\0';
}
from = e->dphone;
to = buf;
{
if (hphone[0] == ' ')
{
- strncpy(hphone, buf, 16);
- hphone[16] = '\0';
+ strncpy(hphone, buf, USERS_HOME_PHONE_SIZE - 1);
+ hphone[USERS_HOME_PHONE_SIZE - 1] = '\0';
}
- else if (strncmp(strtrim(hphone), buf, 16))
+ else if (strncmp(strtrim(hphone), buf, USERS_HOME_PHONE_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(hphone), buf, 16))
+ if (strncmp(strtrim(hphone), buf, USERS_HOME_PHONE_SIZE - 1))
changed++;
- strncpy(hphone, buf, 16);
- hphone[16] = '\0';
+ strncpy(hphone, buf, USERS_HOME_PHONE_SIZE - 1);
+ hphone[USERS_HOME_PHONE_SIZE - 1] = '\0';
}
from = e->mphone;
to = buf;
{
if (ophone[0] == ' ')
{
- strncpy(ophone, buf, 12);
- ophone[12] = '\0';
+ strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+ ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
}
- else if (strncmp(strtrim(ophone), buf, 12))
+ else if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(ophone), buf, 12))
+ if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
changed++;
- strncpy(ophone, buf, 12);
- ophone[12] = '\0';
+ strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+ ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
}
e->course = e->course;
if (newfinger)
{
if (dept[0] == ' ')
{
- strncpy(dept, e->course, 12);
- dept[12] = '\0';
+ strncpy(dept, e->course, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
}
- else if (strncmp(strtrim(dept), e->course, 11))
+ else if (strncmp(strtrim(dept), e->course, USERS_DEPARTMENT_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(dept), e->course, 11))
+ if (strncmp(strtrim(dept), e->course, USERS_DEPARTMENT_SIZE - 1))
changed++;
- strncpy(dept, e->course, 12);
- dept[12] = '\0';
+ strncpy(dept, e->course, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
}
sid = e->id;
name = e->name;
char buf[512], *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
int id, uid, who;
- char *last, *first, *class, *middle, login[9], *sid, fullname[65], *prog;
- char haddr[81], hphone[17], ophone[13], dept[24], *title, raddr[81], *name;
+ char *last, *first, *class, *middle, login[USERS_LOGIN_SIZE], *sid;
+ char fullname[USERS_FULLNAME_SIZE], *prog;
+ char haddr[USERS_HOME_ADDR_SIZE], hphone[USERS_HOME_PHONE_SIZE];
+ char ophone[USERS_OFFICE_PHONE_SIZE], dept[USERS_DEPARTMENT_SIZE];
+ char *title, raddr[USERS_XADDRESS_SIZE], *name;
EXEC SQL END DECLARE SECTION;
who = WHO;
strcat(buf, " ");
strcat(buf, e->state);
}
- strncpy(haddr, buf, 80);
+ strncpy(haddr, buf, USERS_HOME_ADDR_SIZE - 1);
+ haddr[USERS_HOME_ADDR_SIZE - 1] = '\0';
from = e->dphone;
to = buf;
while (*from)
from++;
}
*to = '\0';
- strncpy(hphone, buf, 16);
+ strncpy(hphone, buf, USERS_HOME_PHONE_SIZE - 1);
+ hphone[USERS_HOME_PHONE_SIZE - 1] = '\0';
from = e->mphone;
to = buf;
while (*from)
from++;
}
*to = '\0';
- strncpy(ophone, buf, 12);
- strncpy(dept, e->course, 12);
+ strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+ ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
+ strncpy(dept, e->course, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
id = set_next_users_id(0);
uid = set_next_uid(1);