ritwik12 / Virtual-Assistant

A linux based Virtual assistant on Artificial Intelligence in C
GNU General Public License v3.0
128 stars 95 forks source link

Issue [#78] Refactored init_config.c #79

Closed aurochs-angels closed 4 years ago

aurochs-angels commented 4 years ago
ritwik12 commented 4 years ago

@aurochs-angels Thanks a lot for your PR, Let me review.

ritwik12 commented 4 years ago

Related to #78

ritwik12 commented 4 years ago

@aurochs-angels Sorry for late review but I was out of town and was lil busy before that.

ritwik12 commented 4 years ago

@aurochs-angels I am not sure why but I can see errors in src/response.c and src/requests.c while compiling your code. You have not changed those files but I guess your changes in main.c are causing it. Can you please check.

src/requests.c: In function 'main':
src/requests.c:12:7: error: 'str' undeclared (first use in this function)
 fgets(str, 1000, stdin);
       ^
src/requests.c:12:7: note: each undeclared identifier is reported only once for each function it appears in
In file included from main.c:50:0:
src/response.c:21:11: error: 'location' undeclared (first use in this function)
     fgets(location, 1000, stdin);
           ^
src/response.c:33:5: error: 'len' undeclared (first use in this function)
     len = strlen(str);
     ^
src/response.c:34:13: error: 'youtube' undeclared (first use in this function)
     strncpy(youtube, str + 19, len);
             ^
src/response.c:37:5: error: 'start' undeclared (first use in this function)
     start = malloc(strlen(youtube) + 1);
     ^
src/response.c:40:5: error: 'pv' undeclared (first use in this function)
     pv = 0; //previous character
     ^
src/response.c:41:10: error: 'd' undeclared (first use in this function)
     for (d = c = 0; youtube[c]; ++c) {
          ^
src/response.c:41:14: error: 'c' undeclared (first use in this function)
     for (d = c = 0; youtube[c]; ++c) {
              ^
src/response.c:66:42: error: 'HOME_DIR' undeclared (first use in this function)
     sprintf(sys_cmd, "%s%s%s", sys_cmd1, HOME_DIR, "media/");
                                          ^
src/response.c:70:11: error: 'songs' undeclared (first use in this function)
     fgets(songs, 1000, stdin);
           ^
src/response.c:71:37: error: 'M_P' undeclared (first use in this function)
     sprintf(song, "%s %smedia/\%s", M_P, HOME_DIR, songs);
                                     ^
src/response.c:77:11: error: 'cal' undeclared (first use in this function)
     fgets(cal, 1000, stdin);
           ^
src/response.c:123:15: error: 'search' undeclared (first use in this function)
         fgets(search, 1000, stdin);
ritwik12 commented 4 years ago

@aurochs-angels That's strange though as these are just variable initializations. Please check once

aurochs-angels commented 4 years ago

Fixed:

ritwik12 commented 4 years ago

@aurochs-angels Thanks, let me check.

ritwik12 commented 4 years ago

@aurochs-angels I can see few errors while compiling your code. Please check.

[ritsharm@ritsharm-ld1 ~/git/pr_config/Virtual-Assistant]$ gcc main.c src/init_config.c $(pkg-config --libs --cflags libcurl) -lssl -lcrypto -ljson-c -std=gnu11
/tmp/ccbL5kBQ.o:(.bss+0x0): multiple definition of `len'
/tmp/ccnL9q84.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
aurochs-angels commented 4 years ago

Was caused by a conflicting include. Added an include guard, cleaned up comments, moved vars to where they are actually used. My compile is now clean again, can you please check?

ritwik12 commented 4 years ago

Yes, let me @aurochs-angels

ritwik12 commented 4 years ago

@aurochs-angels Thanks !!

ritwik12 commented 3 years ago

@all-contributors please add @aurochs-angels for code

allcontributors[bot] commented 3 years ago

@ritwik12

I've put up a pull request to add @aurochs-angels! :tada: