Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. typedef string FileName<30>;
  2. struct Output {
  3.     FileName list_of_files<100>;
  4.     int errorCode;
  5. };
  6.  
  7. program MYPROG {
  8.     version MYVERS {
  9.         Output getFileList(string) = 1;
  10.     } = 1;
  11. } = 0x20000013;
  12.  
  13. // in server
  14. Output * getfilelist_1_svc(char ** direName, struct svc_req * rp)
  15. {
  16.     static Output output;
  17.  
  18.     output.list_of_files.list_of_files_val = malloc(sizeof(char *)*100);
  19.     u_int i = 0;
  20.     for (i = 0; i < 100; ++i)
  21.         output.list_of_files.list_of_files_val[i] = malloc(sizeof(char) * 30);
  22.  
  23.     DIR * mDir;
  24.     struct dirent * entry;
  25.     int count = 0;
  26.  
  27.     mDir = opendir(*direName);
  28.     while ((entry = readdir(mDir)) != NULL) {
  29.         if (entry->d_type == DT_REG) {
  30.             strcpy(output.list_of_files.list_of_files_val[count], entry->d_name);
  31.             count++;
  32.             output.list_of_files.list_of_files_len = count;
  33.         }
  34.         closedir(mDir);
  35.     }
  36.  
  37.     return &output;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement