void saveValues(){ fdelete("l.txt"); fdelete("r.txt"); char writebuf[5]; settings = fopen("l.txt", "w"); if (-leftdraw < 1000){ sprintf(writebuf, "0%d", -leftdraw); fputs(writebuf, settings); } else { sprintf(writebuf, "%d", -leftdraw); fputs(writebuf, settings); } fclose(settings); settings = fopen("r.txt", "w"); if (rightdraw < 1000){ sprintf(writebuf, "0%d", rightdraw); fputs(writebuf, settings); } else { sprintf(writebuf, "%d", rightdraw); fputs(writebuf, settings); } fclose(settings); }
/*---------------------------------------------------------------------------- * Delete a File *---------------------------------------------------------------------------*/ static void cmd_delete (char *par) { char *fname,*next,dir; fname = get_entry (par, &next); if (fname == NULL) { printf ("\nFilename missing.\n"); return; } dir = 0; if (*(fname + strlen(fname) - 1) == '\\') { dir = 1; } if (fdelete (fname) == 0) { if (dir) { printf ("\nDirectory %s deleted.\n",fname); } else { printf ("\nFile %s deleted.\n",fname); } } else { if (dir) { printf ("\nDirectory %s not found or not empty.\n",fname); } else { printf ("\nFile %s not found.\n",fname); } } }
BOOL ftp_fdelete (U8 *fname) { /* Delete a file, return __TRUE on success. */ if (fdelete((char *)fname) == 0) { return (__TRUE); } return (__FALSE); }
void SPI_FLASH_Delete_All_Files (void) { FINFO file_info; file_info.fileID = 0; while(ffind("*.*", &file_info) == 0) { fdelete((const char*)file_info.name); } }
BOOL ftp_fdelete (U8 *fname) { /* Delete a file, return __TRUE on success. */ if (fdelete((char *)fname) == 0) { if (ANIMATION_PLAY && strcmp(AnimationFileName, (const char *)fname + 1) == 0) { Animation_Stop(); } return (__TRUE); } return (__FALSE); }
/* * The region we're filling is the region from dot to mark. * We cut out that region and then put it back in filled. * The cut out part is saved in the ldelete call and the * reinstalled region is noted in addedregion, so that yank() * can delete it and restore the saved part. */ int fillregion(UCS *qstr, REGION *addedregion) { long c, sz, last_char = 0; int i, j, qlen, same_word, spaces, word_len, word_ind, line_len, ww; int starts_midline = 0; int ends_midline = 0; int offset_into_start; LINE *line_before_start, *lp; UCS line_last, word[NSTRING]; REGION region; /* if region starts midline insert a newline */ if(curwp->w_doto > 0 && curwp->w_doto < llength(curwp->w_dotp)) starts_midline++; /* if region ends midline insert a newline at end */ if(curwp->w_marko > 0 && curwp->w_marko < llength(curwp->w_markp)) ends_midline++; /* cut the paragraph into our fill buffer */ fdelete(); if(!getregion(®ion, curwp->w_markp, curwp->w_marko)) return(FALSE); if(!ldelete(region.r_size, finsert)) return(FALSE); line_before_start = lback(curwp->w_dotp); offset_into_start = curwp->w_doto; if(starts_midline) lnewline(); /* Now insert it back wrapped */ spaces = word_len = word_ind = line_len = same_word = 0; qlen = qstr ? ucs4_strlen(qstr) : 0; /* Beginning with leading quoting... */ if(qstr){ i = 0; while(qstr[i]){ ww = wcellwidth(qstr[i]); line_len += (ww >= 0 ? ww : 1); linsert(1, qstr[i++]); } line_last = ' '; /* no word-flush space! */ } /* remove first leading quotes if any */ if(starts_midline) i = 0; else for(i = qlen; (c = fremove(i)) == ' ' || c == TAB; i++){ linsert(1, line_last = (UCS) c); line_len += ((c == TAB) ? (~line_len & 0x07) + 1 : 1); } /* then digest the rest... */ while((c = fremove(i++)) >= 0){ last_char = c; switch(c){ case '\n' : /* skip next quote string */ j = 0; while(j < qlen && ((c = fremove(i+j)) == qstr[j] || c == ' ')) j++; i += j; if(!spaces) spaces++; same_word = 0; break; case TAB : case ' ' : spaces++; same_word = 0; break; default : if(spaces){ /* flush word? */ if((line_len - qlen > 0) && line_len + word_len + 1 > fillcol && ((ucs4_isspace(line_last)) || (linsert(1, ' '))) && (line_len = fpnewline(qstr))) line_last = ' '; /* no word-flush space! */ if(word_len){ /* word to write? */ if(line_len && !ucs4_isspace(line_last)){ linsert(1, ' '); /* need padding? */ line_len++; } line_len += word_len; for(j = 0; j < word_ind; j++) linsert(1, line_last = word[j]); if(spaces > 1 && strchr(".?!:;\")", line_last)){ linsert(2, line_last = ' '); line_len += 2; } word_len = word_ind = 0; } spaces = 0; } if(word_ind + 1 >= NSTRING){ /* Magic! Fake that we output a wrapped word */ if((line_len - qlen > 0) && !same_word++){ if(!ucs4_isspace(line_last)) linsert(1, ' '); line_len = fpnewline(qstr); } line_len += word_len; for(j = 0; j < word_ind; j++) linsert(1, word[j]); word_len = word_ind = 0; line_last = ' '; } word[word_ind++] = (UCS) c; ww = wcellwidth((UCS) c); word_len += (ww >= 0 ? ww : 1); break; } } if(word_len){ if((line_len - qlen > 0) && (line_len + word_len + 1 > fillcol)){ if(!ucs4_isspace(line_last)) linsert(1, ' '); (void) fpnewline(qstr); } else if(line_len && !ucs4_isspace(line_last)) linsert(1, ' '); for(j = 0; j < word_ind; j++) linsert(1, word[j]); } if(last_char == '\n') lnewline(); if(ends_midline) (void) fpnewline(qstr); /* * Calculate the size of the region that was added. */ swapmark(0,1); /* mark current location after adds */ addedregion->r_linep = lforw(line_before_start); addedregion->r_offset = offset_into_start; lp = addedregion->r_linep; sz = llength(lp) - addedregion->r_offset; if(lforw(lp) != curwp->w_markp->l_fp){ lp = lforw(lp); while(lp != curwp->w_markp->l_fp){ sz += llength(lp) + 1; lp = lforw(lp); } } sz -= llength(curwp->w_markp) - curwp->w_marko; addedregion->r_size = sz; swapmark(0,1); if(ends_midline){ /* * We want to back up to the end of the original * region instead of being here after the added newline. */ curwp->w_doto = 0; backchar(0, 1); unmarkbuffer(); markregion(1); } return(TRUE); }
int setquotelevelinregion(int quotelevel, REGION *addedregion) { int i, standards_based = 0; int quote_chars = 0, backuptoprevline = 0; int starts_midline = 0, ends_midline = 0, offset_into_start; long c, sz; UCS qstr_def1[] = { '>', ' ', 0}, qstr_def2[] = { '>', 0}; LINE *lp, *line_before_start; REGION region; if(curbp->b_mode&MDVIEW) /* don't allow this command if */ return(rdonly()); /* we are in read only mode */ if(!glo_quote_str || !ucs4_strcmp(glo_quote_str, qstr_def1) || !ucs4_strcmp(glo_quote_str, qstr_def2)) standards_based++; if(!standards_based){ emlwrite("Quote level setting only works with standard \"> \" quotes", NULL); return(FALSE); } /* if region starts midline insert a newline */ if(curwp->w_doto > 0 && curwp->w_doto < llength(curwp->w_dotp)) starts_midline++; /* if region ends midline insert a newline at end */ if(curwp->w_marko > 0 && curwp->w_marko < llength(curwp->w_markp)){ ends_midline++; backuptoprevline++; /* count quote chars for re-insertion */ for(i = 0; i < llength(curwp->w_markp); ++i) if(lgetc(curwp->w_markp, i).c != '>') break; quote_chars = i; } else if(curwp->w_marko == 0) backuptoprevline++; /* find the size of the region */ getregion(®ion, curwp->w_markp, curwp->w_marko); /* cut the paragraph into our fill buffer */ fdelete(); if(!ldelete(region.r_size, finsert)) return(FALSE); line_before_start = lback(curwp->w_dotp); offset_into_start = curwp->w_doto; /* if region starts midline add a newline */ if(starts_midline) lnewline(); i = 0; while(fremove(i) >= 0){ /* remove all quote strs from current line */ if(standards_based){ while((c = fremove(i)) == '>') i++; if(c == ' ') i++; } else{ } /* insert quotelevel quote strs */ if(standards_based){ linsert(quotelevel, '>'); if(quotelevel > 0) linsert(1, ' '); } else{ } /* put back the actual line */ while((c = fremove(i++)) >= 0 && c != '\n') linsert(1, (UCS) c); if(c == '\n') lnewline(); } /* if region ends midline add a newline */ if(ends_midline){ lnewline(); if(quote_chars){ linsert(quote_chars, '>'); if(curwp->w_doto < llength(curwp->w_dotp) && lgetc(curwp->w_dotp, curwp->w_doto).c != ' ') linsert(1, ' '); } } /* * Calculate the size of the region that was added. */ swapmark(0,1); /* mark current location after adds */ addedregion->r_linep = lforw(line_before_start); addedregion->r_offset = offset_into_start; lp = addedregion->r_linep; sz = llength(lp) - addedregion->r_offset; if(lforw(lp) != curwp->w_markp->l_fp){ lp = lforw(lp); while(lp != curwp->w_markp->l_fp){ sz += llength(lp) + 1; lp = lforw(lp); } } sz -= llength(curwp->w_markp) - curwp->w_marko; addedregion->r_size = sz; swapmark(0,1); /* * This puts us at the end of the quoted region instead * of on the following line. This makes it convenient * for the user to follow a quotelevel adjustment with * a Justify if desired. */ if(backuptoprevline){ curwp->w_doto = 0; backchar(0, 1); } if(ends_midline){ /* doesn't need fixing otherwise */ unmarkbuffer(); markregion(1); } return (TRUE); }
void main() { int n,num,num1,flag=0; while(1) { clrscr(); printf("\n\t\t****** DOUBLY LINKED LIST OPERATION ******\n"); printf("\t\t......______________________________......\n"); printf("\nWELCOME,WHAT YOU WANT TO DO ?::"); printf("\n_____________________________\n\n"); printf("\nINSERTION --PRESS 1\n"); printf("\nDELETION --PRESS 2\n"); printf("\nSEARCH --PRESS 3\n"); printf("\nCOUNT --PRESS 4\n"); printf("\nDISPLAY(F) --PRESS 5\n"); printf("\nDISPLAY(R) --PRESS 6\n"); printf("\nEXIT --PRESS 7\n"); printf("\n\nENTER YOUR CHOICE::\n"); scanf("%d",&n); switch(n) { case 1: while(1) { flag=0; clrscr(); printf("INSERT A NODE ::\n"); printf("\t\tAT FIRST -PRESS 1.\n"); printf("\t\tAFTER A NODE -PRESS 2.\n"); printf("\t\tBEFORE A NODE -PRESS 3.\n"); printf("\t\tAT LAST -PRESS 4.\n"); printf("\t\tEXIT FROM HERE-PRESS 5.\n"); printf("\n\nENTER YOUR CHOICE::\n"); scanf("%d",&n); switch(n) { case 1: printf("\nENTER A ELEMENT FOR INSERTION\n"); scanf("%d",&num); finsert(num); printf("\n%d IS INSERT AT FIRST PROPERLY\n",num); break; case 2: printf("\nENTER A ELEMENT FOR INSERTION\n"); scanf("%d",&num); printf("AFTER WHICH ELEMENT YOU WANT TO INSERT\n"); scanf("%d",&num1); ainsert(num,num1); break; case 3: printf("ENTER A ELEMENT FOR INSERTION\n"); scanf("%d",&num); printf("BEFORE WHICH ELEMENT YOU WANT TO INSERT\n"); scanf("%d",&num1); binsert(num,num1); break; case 4: printf("ENTER AN ELEMENT FOR INSERT IN LAST\n"); scanf("%d",&num); linsert(num); break; case 5: printf("\nTHANK YOU FOR USING INSERT OPERETION\n"); flag=1; break; } getch(); if(flag==1) break; } break; case 2: while(1) { flag=0; clrscr(); printf("DELETE A NODE ::\n"); printf("\t\tAT FIRST -PRESS 1.\n"); printf("\t\tAFTER A NODE -PRESS 2.\n"); printf("\t\tBEFORE A NODE -PRESS 3.\n"); printf("\t\tAT LAST -PRESS 4.\n"); printf("\t\tEXACT A NODE -PRESS 5.\n"); printf("\t\tEXIT FROM HERE-PRESS 6.\n"); printf("\n\nENTER YOUR CHOICE::\n"); scanf("%d",&n); switch(n) { case 1: fdelete(); break; case 2: printf("\nENTER AFTER WHICH ELEMENT YOU WANT TO DELETE A NODE\n"); scanf("%d",&num); adelete(num); break; case 3: printf("\nENTER BEFORE WHICH ELEMENT YOU WANT TO DELETE A NODE\n"); scanf("%d",&num); bdelete(num); break; case 4: ldelete(); break; case 5: printf("WHICH ELEMENT CONTAIN NODE YOU WANT TO DELETE:\n"); scanf("%d",&num); edelete(num); break; case 6: printf("THANK YOU FOR USING DELETE OPERETION"); flag=1; break; } getch(); if(flag==1) break; } break; case 3: printf("WHICH ELEMENT YOU WANT TO SEARCH ?"); scanf("%d",&num); search(num); break; case 4: num=count(); printf("AT PRESENT LINKLIST CONTAIN %d NODES\n",num); break; case 5: fdisplay(); break; case 6: rdisplay(); break; case 7: printf("\n\nTHANK YOU FOR USING THIS PROGRAM\n"); getch(); exit(0); } getch(); } }
/* * This should be called to backup our identification + IP into flash */ void dtp_backup_id(void) { auto int offset, len, retval; auto unsigned long temp; auto File f, *F; F = &f; main_id.top = 0xa5; main_id._my_ip_addr = my_ip_addr; main_id._sin_mask = sin_mask; main_id.gate_ip = lookup_gateway(); /* backup: main_id */ printf("dtp_backup_id()...\n"); if(fcreate(F, NextBackupFile)) { /* Error! File allready exists? */ goto backup_error; } /* write out the new version number */ BackupVersion++; printf("\tBackupVersion == %ld\n",BackupVersion); if(4 != fwrite(F, (char *)&BackupVersion, 4)) { goto backup_error; } /* write out the length of the config table */ temp = sizeof(main_id); printf("\tsizeof(main_id) == %ld\n",temp); if(4 != fwrite(F, (char *)&temp, 4)) { goto backup_error; } /* write out the actual config table */ offset = 0; len = sizeof(main_id); while(offset < len) { retval = fwrite(F, (char *)&(main_id.top) + offset, len - offset); if(retval < 1) { /* error - no room */ goto backup_error; } offset += retval; } /* write out the length of the spec table */ temp = SSPEC_MAXSPEC * sizeof(ServerSpec); printf("\tsizeof(ServerSpec[]) == %ld\n",temp); if(4 != fwrite(F, (char *)&temp, 4)) { goto backup_error; } /* write the actual spec table */ offset = 0; len = SSPEC_MAXSPEC * sizeof(ServerSpec); while(offset < len) { retval = fwrite(F, (char *)&(server_spec[0]) + offset, len - offset); if(retval < 1) { /* error - no room */ goto backup_error; } offset += retval; } fclose(F); /* remove the old file, if it exists */ if(255 == NextBackupFile) { fdelete(254); NextBackupFile = 254; } else { fdelete(255); NextBackupFile = 255; } return; backup_error: fclose(F); /* should we format the fs here? */ printf("ERROR: No room to backup config table in flash FS!\n"); return; }
int main() { int rc; // Return code from filesystem functions File f1; // Demo file handle static char buf[1024]; // General-purpose buffer. if (!LX_2_USE) { printf("The specified device (LX# %d) does not exist. Change LX_2_USE.\n", (int)LX_2_USE); exit(1); } else printf("Using device LX# %d...\n", (int)LX_2_USE); /* * Step 1: initialize the filesystem. A real application must * decide whether to format a new flash device, or just start * up an existing filesystem. Formatting should not normally * be needed unless, say, a user commands it. A factory-fresh * flash device will usually be all erased so there is no need * to format. Likewise, a flash with completely random data * will be recognised as such and automatically formatted. */ rc = fs_init(0,0); if (rc) { printf("Could not initialize filesystem, error number %d\n", errno); exit(2); } /* * Step 2: format the filesystem if requested. Note that formatting * must be done _after_ the call to fs_init(). * * This demo initially asks whether the flash should be formatted * via the stdio connection. */ printf("Do you want to:\n"); printf(" <enter> re-use existing filesystem -or-\n"); printf(" F <enter> format the filesystem logical extent?\n"); gets(buf); if (toupper(buf[0]) == 'F') { rc = lx_format(LX_2_USE, 0); if (rc) { printf("Format failed, error code %d\n", errno); exit(3); } } /* * Step 3: open a file for writing if it already exists, or * create it if it does not. Note that creation automatically * opens the file for writing if it does not exist. If it * does exist, then EEXIST will be returned in errno. */ printf("Capacity of LX# %d is approximately %ld\n", (int)LX_2_USE, fs_get_lx_size(LX_2_USE, 0, 0)); fs_set_lx(LX_2_USE, LX_2_USE); rc = fcreate(&f1, MY_FILE_NAME); if (rc && errno == EEXIST) { printf("File %d exists: shall I delete it? (y/n)\n", (int)MY_FILE_NAME); gets(buf); if (toupper(buf[0]) == 'Y') { fdelete(MY_FILE_NAME); rc = fcreate(&f1, MY_FILE_NAME); } else rc = fopen_wr(&f1, MY_FILE_NAME); } if (rc) { printf("Couldn't create/open file %d: errno = %d\n", (int)MY_FILE_NAME, errno); exit(3); } do_it_again: /* * Seek to the end of the file then print the current length. */ fseek(&f1, 0, SEEK_END); printf("File length is %ld\n", ftell(&f1)); /* * Add some data to the end. */ strcpy(buf, "Test pattern ________"); rc = fwrite(&f1, buf, strlen(buf)); if (rc < strlen(buf)) { printf("Append operation failed, error code %d\n", errno); // but we keep going... } printf("After append operation...\n"); print_file(&f1); /* * Seek backwards and overwrite something. */ fseek(&f1, -7, SEEK_END); sprintf(buf, "%ld", ftell(&f1)); rc = fwrite(&f1, buf, strlen(buf)); if (rc < strlen(buf)) { printf("Overwrite operation failed, error code %d\n", errno); // but we keep going... } printf("After overwrite operation...\n"); print_file(&f1); /* * Delete some data from the start. */ rc = fshift(&f1, DELETE_AMOUNT, buf); if (rc == 0) { printf("Shift operation failed, error code %d\n", errno); // but we keep going... } printf("After shifting out %d chars...\n", rc); print_file(&f1); buf[rc] = 0; printf("...and the deleted data was '%s'\n", buf); /* * Another round, anyone? */ printf("Are you having too much fun? (y/n)\n"); gets(buf); if (toupper(buf[0]) == 'Y') goto do_it_again; return 0; }
/* * This is the general command execution routine. It handles the fake binding * of all the keys to "self-insert". It also clears out the "thisflag" word, * and arranges to move it to the "lastflag", so that the next command can * look at it. Return the status of command. */ int execute(UCS c, int f, int n) { KEYTAB *ktp; int status, ww; ktp = (Pmaster) ? &keytab[0] : &pkeytab[0]; while (ktp->k_fp != NULL) { if (ktp->k_code == c) { if(lastflag&CFFILL){ curwp->w_flag |= WFMODE; if(Pmaster == NULL) sgarbk = TRUE; } thisflag = 0; status = (*ktp->k_fp)(f, n); if((lastflag & CFFILL) && !(thisflag & CFFILL)) fdelete(); if((lastflag & CFFLBF) && !(thisflag & CFFLBF)) kdelete(); lastflag = thisflag; /* * Reset flag saying wrap should open a new line whenever * we execute a command (as opposed to just typing in text). * However, if that command leaves us in the same line on the * screen, then don't reset. */ if(curwp->w_flag & (WFMOVE | WFHARD)) curbp->b_flag |= BFWRAPOPEN; /* wrap should open new line */ return (status); } ++ktp; } if(lastflag & CFFILL) /* blat unusable fill data */ fdelete(); if(lastflag & CFFLBF) kdelete(); if (VALID_KEY(c)) { /* Self inserting. */ if (n <= 0) { /* Fenceposts. */ lastflag = 0; return (n<0 ? FALSE : TRUE); } thisflag = 0; /* For the future. */ /* do the appropriate insertion */ /* pico never does C mode, this is simple */ status = linsert(n, c); /* * Check to make sure we didn't go off of the screen * with that character. Take into account tab expansion. * If so wrap the line... */ if(curwp->w_bufp->b_mode & MDWRAP){ int j, wid; wid = 0; for(j = 0; j < llength(curwp->w_dotp); j++) if(ucs4_isspace(lgetc(curwp->w_dotp, j).c)){ if(lgetc(curwp->w_dotp, j).c == TAB){ ++wid; while(wid & 0x07) ++wid; } else ++wid; } else{ ww = wcellwidth((UCS) lgetc(curwp->w_dotp, j).c); wid += (ww >= 0 ? ww : 1); if(wid > fillcol){ wrapword(); break; } } } lastflag = thisflag; return (status); } unknown_command(c); lastflag = 0; /* Fake last flags. */ return (FALSE); }
void cgi_process_data (U8 code, U8 *dat, U16 len) { /* This function is called by HTTP server to process the returned Data */ /* for the CGI Form POST method. It is called on SUBMIT from the browser. */ /* Parameters: */ /* code - callback context code */ /* 0 = www-url-encoded form data */ /* 1 = filename for file upload (0-terminated string) */ /* 2 = file upload raw data */ /* 3 = end of file upload (file close requested) */ /* 4 = any xml encoded POST data (single or last stream) */ /* 5 = the same as 4, but with more xml data to follow */ /* Use http_get_content_type() to check the content type */ /* dat - pointer to POST received data */ /* len - received data length */ static FILE *f = NULL; U32 n; U8 *var,*p; BOOL format_flash = FALSE; BOOL settings_save = FALSE; BOOL sntp_time_configurations_load = FALSE; RTC_Time rtc_time; BOOL rtc_save = FALSE; BOOL add_admin = FALSE, add_user = FALSE; BOOL save_user = FALSE, delete_user = FALSE, delete_users = FALSE; BOOL save_admin = FALSE, delete_admin = FALSE; int admin_number = 0; int user_number = 0; USER *user = malloc(sizeof(USER)); ADMIN *admin = malloc(sizeof(ADMIN)); static FINFO file_info; //ADMIN *admin = malloc(sizeof(ADMIN)); //USER *user = malloc(sizeof(USER)); switch (code) { case 0: /* Url encoded form data received. */ break; case 1: /* Filename for file upload received as encoded by the browser. */ /* It might contain an absolute path to a file from the sending */ /* host. Open a file for writing. */ var = dat; /* Remove path info from filename, keep only the name. */ for (p = dat; *p; p++) { if (*p == '\\') var = p + 1; } if (*var == 0) { /* Send was clicked but a filename was not selected. */ return; } /* Filename is OK, initialize the card. */ if (finit(NULL) != 0) { f = NULL; return; } /* Files will be stored to the root directory of SD card. */ f = fopen ((const char *)var,"w"); return; case 2: /* File content data received. Write data to a file. */ /* This function will be called several times with */ /* code 2 when a big file is being uploaded. */ if (f != NULL) { /* Write in 512 byte blocks. This is the optimal way for */ /* the FAT FS with caching enabled. For cache buffer */ /* size of 4KB the file write speed is 1.2 MByte/sec. */ while ((n = len) > 0) { if (n > 512) n = 512; fwrite (dat,1,n,f); dat += n; len -= n; } } return; case 3: /* File upload finished. Close a file. */ if (f != NULL) { fclose (f); } return; default: /* Ignore all other codes. */ return; } if (len == 0) { /* No data or all items (radio, checkbox) are off. */ return; } var = (U8 *)alloc_mem (40); do { /* Parse all returned parameters. */ dat = http_get_var (dat, var, 40); if (var[0] != 0) { if (str_scomp(var, (const U8*)"file_delete=") == TRUE) { // FILE DELETE fdelete((const char *)var+12); } else if (str_scomp(var, (const U8*)"format_flash=yes") == TRUE) { // FORMAT FLASH format_flash = TRUE; } else if (str_scomp(var, (const U8*)"ani_file_delete=") == TRUE) { // ANIMATION FILE DELETE if (fdelete((const char *)var+16) == 0) { if (ANIMATION_PLAY && strcmp(AnimationFileName, (const char *)var+16) == 0) { Animation_Stop(); } } } else if (str_scomp(var, (const U8*)"delete_all_ani=yes") == TRUE) { while (ffind("*.ani", &file_info) == 0) { fdelete((const char*)file_info.name); } } // USERS & ADMINS COMMANDS if(str_scomp(var, (const U8*)"delete_user="******"%d", &user_number); delete_user = TRUE; } else if(str_scomp(var, (const U8*)"delete_users=") == TRUE) { delete_users = TRUE; } else if(str_scomp(var, (const U8*)"save_user="******"%d", &user_number); save_user = TRUE; } else if (str_scomp(var, (const U8*)"add_user=yes") == TRUE) { add_user = TRUE; } if(str_scomp(var, (const U8*)"delete_admin=") == TRUE) { sscanf((const char *)var+12, "%d", &admin_number); delete_admin = TRUE; } else if(str_scomp(var, (const U8*)"save_admin=") == TRUE) { sscanf((const char *)var+10, "%d", &admin_number); save_admin = TRUE; } else if (str_scomp(var, (const U8*)"add_admin=yes") == TRUE) { add_admin = TRUE; } if(str_scomp(var, (const U8*)"username="******"password="******"first_name=") == TRUE) { strcpy(user->First_Name, (const char *)var+11); } else if(str_scomp(var, (const U8*)"last_name=") == TRUE) { strcpy(user->Last_Name, (const char *)var+10); } else if(str_scomp(var, (const U8*)"email=") == TRUE) { strcpy(user->Email, (const char *)var+6); strcpy(admin->Email, (const char *)var+6); } // SNTP TIME COMMANDS if(str_scomp(var, (const U8*)"sntp_time_load=yes") == TRUE) { sntp_time_configurations_load = TRUE; settings_save = TRUE; } else if(str_scomp(var, (const U8*)"sntp_ip_1_0=") == TRUE) { sscanf((const char *)var+12, "%d", (int*)&SNTP_Server_IP_1[0]); } else if(str_scomp(var, (const U8*)"sntp_ip_1_1=") == TRUE) { sscanf((const char *)var+12, "%d", (int*)&SNTP_Server_IP_1[1]); } else if(str_scomp(var, (const U8*)"sntp_ip_1_2=") == TRUE) { sscanf((const char *)var+12, "%d", (int*)&SNTP_Server_IP_1[2]); } else if(str_scomp(var, (const U8*)"sntp_ip_1_3=") == TRUE) { sscanf((const char *)var+12, "%d", (int*)&SNTP_Server_IP_1[3]); } else if(str_scomp(var, (const U8*)"sntp_ip_2_0=") == TRUE) { sscanf((const char *)var+12, "%d", (int*)&SNTP_Server_IP_2[0]); } else if(str_scomp(var, (const U8*)"sntp_ip_2_1=") == TRUE) { sscanf((const char *)var+12, "%d", (int*)&SNTP_Server_IP_2[1]); } else if(str_scomp(var, (const U8*)"sntp_ip_2_2=") == TRUE) { sscanf((const char *)var+12, "%d", (int*)&SNTP_Server_IP_2[2]); } else if(str_scomp(var, (const U8*)"sntp_ip_2_3=") == TRUE) { sscanf((const char *)var+12, "%d", (int*)&SNTP_Server_IP_2[3]); } // TIME COMMANDS if(str_scomp(var, (const U8*)"time_format=") == TRUE) { strcpy(SETTINGS_DATA[TIME_FORMAT], (const char *)var+12); settings_save = TRUE; } else if(str_scomp(var, (const U8*)"date_format=") == TRUE) { strcpy(SETTINGS_DATA[DATE_FORMAT], (const char *)var+12); settings_save = TRUE; } else if(str_scomp(var, (const U8*)"timezone_offset_select=") == TRUE) { TIME_ZONE_OFFSET_SELECTED_VALUE = atoi((const char *)var+23); settings_save = TRUE; } // MANUAL TIME COMMANDS if(str_scomp(var, (const U8*)"manual_time=") == TRUE) { sscanf((const char *)var+12, "%d:%d", (int*)&rtc_time.Hour, (int*)&rtc_time.Min); rtc_save = TRUE; settings_save = TRUE; } else if(str_scomp(var, (const U8*)"manual_date=") == TRUE) { sscanf((const char *)var+12, "%d-%d-%d", (int*)&rtc_time.Year, (int*)&rtc_time.Mon, (int*)&rtc_time.Mday); rtc_save = TRUE; settings_save = TRUE; } // ANIMATION if(str_scomp(var, (const U8*)"animation_start=") == TRUE) { AnimationFileName = (char *)malloc(strlen((const char *)var)-15); strcpy(AnimationFileName, (const char *)var+16); Animation_Start(); } else if(str_scomp(var, (const U8*)"animation_stop=yes") == TRUE) { Animation_Stop(); } } } while (dat); free_mem ((OS_FRAME *)var); if (format_flash == TRUE) { SPI_FLASH_Delete_All_Files(); } else if (sntp_time_configurations_load == TRUE) { SNTP_Load_Time(); } else if (rtc_save == TRUE) { TIME_ZONE_OFFSET_SELECTED_VALUE = 0; RTC_Set_Time(rtc_time); } else if(save_user == TRUE) { if(USERS_Check_User(user) == USER_Warning_OK) { strcpy((&Users[user_number])->Username, user->Username); strcpy((&Users[user_number])->Password, user->Password); strcpy((&Users[user_number])->First_Name, user->First_Name); strcpy((&Users[user_number])->Last_Name, user->Last_Name); strcpy((&Users[user_number])->Email, user->Email); USERS_Save(); } } else if(save_admin == TRUE) { if(ADMINS_Check_Admin(admin) == ADMIN_Warning_OK) { strcpy((&Admins[admin_number])->Username, admin->Username); strcpy((&Admins[admin_number])->Password, admin->Password); strcpy((&Admins[admin_number])->Email, admin->Email); ADMINS_Save(); } } else if(delete_user == TRUE) { USERS_Remove_User_By_Index(user_number); } else if(delete_admin == TRUE) { ADMINS_Remove_Admin_By_Index(admin_number); } else if (add_admin == TRUE) { ADMINS_Add_Admin(admin); } else if (add_user == TRUE) { USERS_Add_User(user); } else if(delete_users == TRUE) { USERS_Remove_All(); } if (settings_save == TRUE) { SETTINGS_Save(); } free(user); free(admin); }