обновка
parent
bb5efa3893
commit
be382be864
|
@ -42,17 +42,16 @@ int main()
|
|||
printf("\nselect:%d \n", selectFunc(selects, conditions));*/
|
||||
|
||||
printDataBase();
|
||||
parceLine("insert last_nm=Ulanovsky, first_nm=George, curse_id=2, lab_id=1, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:40:23, result=[]");
|
||||
|
||||
//parceLine("insert last_nm=Baranova, first_nm=Genya, curse_id=3, lab_id=6, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
parceLine("insert last_nm=Ulanovsky, first_nm=George, curse_id=2, lab_id=2, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
parceLine("insert last_nm=Ulanovsky, first_nm=George, curse_id=2, lab_id=1, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
parceLine("insert last_nm=Ulanovsky, first_nm=George, curse_id=1, lab_id=3, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
parceLine("insert last_nm=Ulanovsky, first_nm=George, curse_id=2, lab_id=4, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
parceLine("insert last_nm=Ulanovsky, first_nm=George, curse_id=3, lab_id=6, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
|
||||
parceLine("insert last_nm=Baranova, first_nm=Varvara, curse_id=3, lab_id=6, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
printDataBase();
|
||||
parceLine("insert last_nm=Ulanovsky, first_nm=George, curse_id=3, lab_id=5, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
parceLine("insert last_nm=Ulanovsky, first_nm=Grisha, curse_id=3, lab_id=6, start_tm=2000.10.10!22:1:20, end_tm=2000.10.10!23:0:20, result=[]");
|
||||
printDataBase();
|
||||
printDataBase();
|
||||
parceLine("uniq first_nm");
|
||||
printDataBase();
|
||||
parceLine("exit");
|
||||
|
|
|
@ -38,9 +38,9 @@ typedef struct _dbElement
|
|||
// ID ëàáîðàòîðíîé
|
||||
int lab_id;
|
||||
// Âðåìÿ íà÷àëà òåñòèðîâàíèÿ
|
||||
time_t* start_tm;
|
||||
time_t start_tm;
|
||||
// Âðåìÿ îêîí÷àíèÿ òåñòèðîâàíèÿ
|
||||
time_t* end_tm;
|
||||
time_t end_tm;
|
||||
// Ìíîæåñòâî: ïðîéäåííûå òåñòû (99)
|
||||
int* result;
|
||||
// Ñëåäóþùèé ýëåìåíò ñïèñêà
|
||||
|
@ -260,13 +260,21 @@ int putElementToDB(char* lastName, char* firstName, int course, int labID, time_
|
|||
if (newElement == NULL)
|
||||
return ALLOC_FAILURE;
|
||||
mallocCount++;
|
||||
newElement->first_nm = firstName;
|
||||
newElement->last_nm = lastName;
|
||||
|
||||
char* family = (char*)malloc(sizeof(char) * strlen(lastName));
|
||||
strcpy(family, lastName);
|
||||
mallocCount++;
|
||||
char* name = (char*)malloc(sizeof(char) * strlen(firstName));
|
||||
strcpy(name, firstName);
|
||||
mallocCount++;
|
||||
|
||||
newElement->first_nm = name;
|
||||
newElement->last_nm = family;
|
||||
newElement->curse_id = course;
|
||||
newElement->lab_id = labID;
|
||||
newElement->result = results;
|
||||
newElement->start_tm = startTime;
|
||||
newElement->end_tm = endTime;
|
||||
newElement->start_tm = *startTime;
|
||||
newElement->end_tm = *endTime;
|
||||
newElement->nextElement = NULL;
|
||||
|
||||
if (head != NULL)
|
||||
|
@ -312,8 +320,8 @@ void printElement(DataBaseElement* elem)
|
|||
{
|
||||
printf("Element:\n\tName: %s %s\n\tCourse: %d, lab N%d\n\t",
|
||||
elem->first_nm, elem->last_nm, elem->curse_id, elem->lab_id);
|
||||
printf("%s\t", asctime(gmtime(elem->start_tm)));
|
||||
printf("%s\tResults\n", asctime(gmtime(elem->end_tm)));
|
||||
printf("%s\t", asctime(gmtime(&(elem->start_tm))));
|
||||
printf("%s\tResults\n", asctime(gmtime(&(elem->end_tm))));
|
||||
/*for (int i = 0; i < 99; i++)
|
||||
{
|
||||
printf("%d ", elem->result[i]);
|
||||
|
@ -354,6 +362,7 @@ int deleteNonUniqElements(char whatToDelete[7])
|
|||
if (!whatToDelete[6] || isResultsSame(tmp, tmp2))
|
||||
{
|
||||
needToDel[currInd] = 1;
|
||||
//printf("%d currind, %d, %d\n", currInd,tmp->lab_id, tmp2->lab_id);
|
||||
}
|
||||
// Äîáàâèòü ñðàâíåíèå ïî òåñòàì
|
||||
tmp2 = tmp2->nextElement;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
malloc:76
|
||||
malloc:78
|
||||
relloc:0
|
||||
calloc:0
|
||||
free:75
|
||||
free:65
|
|
@ -75,21 +75,22 @@ int parceField(char* line, int* _field_num, char** _string, int* _int, time_t**
|
|||
case 5:
|
||||
*_field_num = field_num;
|
||||
time_t result = 0;
|
||||
int year = 0, month = 0, day = 0, hour = 0, min = 0;
|
||||
if (sscanf(st2, "%4d.%2d.%2d!%2d:%2d", &year, &month, &day, &hour, &min) == 5) {
|
||||
int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0;
|
||||
if (sscanf(st2, "%4d.%2d.%2d!%2d:%2d:%2d", &year, &month, &day, &hour, &min, &sec) == 6) {
|
||||
struct tm breakdown = { 0 };
|
||||
breakdown.tm_year = year - 1900; /* years since 1900 */
|
||||
breakdown.tm_mon = month - 1;
|
||||
breakdown.tm_mday = day;
|
||||
breakdown.tm_hour = hour;
|
||||
breakdown.tm_hour = hour+3;
|
||||
breakdown.tm_min = min;
|
||||
breakdown.tm_sec = sec;
|
||||
|
||||
if ((result = mktime(&breakdown)) == (time_t)-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
puts(ctime(&result));
|
||||
|
||||
//puts(ctime(&result));
|
||||
//printf("%s %d\n", formateTime(&result), result);
|
||||
(*_time) = &result;
|
||||
return 1;
|
||||
}
|
||||
|
@ -167,7 +168,7 @@ void parceLine(char* input)
|
|||
int ints[2] = { 0,0 };
|
||||
int f_num = -1;
|
||||
int _int = -1;
|
||||
time_t* tim = NULL, * start = NULL, * end=NULL;
|
||||
time_t* tim = NULL, start = 0, end=0;
|
||||
int stroks[99];
|
||||
|
||||
if (lixCount != 0) {
|
||||
|
@ -205,10 +206,10 @@ void parceLine(char* input)
|
|||
ints[1] = _int;
|
||||
break;
|
||||
case 4:
|
||||
start = tim;
|
||||
start = *tim;
|
||||
break;
|
||||
case 5:
|
||||
end = tim;
|
||||
end = *tim;
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
|
@ -225,7 +226,7 @@ void parceLine(char* input)
|
|||
error(input); exit(100);
|
||||
}
|
||||
}
|
||||
putElementToDB(family, name, ints[0], ints[1], start, end, stroks);
|
||||
putElementToDB(family, name, ints[0], ints[1], &start, &end, stroks);
|
||||
break;
|
||||
case 5: //uniq
|
||||
if (lixCount > 7) {
|
||||
|
|
Loading…
Reference in New Issue