Unix 编程环境                        计算机学院网络工程 11 班 horizon                          第一次上机练习 
                                    } 
                    } 
                    else 
                    if(argv[i][1]=='h') 
                    { 
                                order[4]=1; 
                                i++;             
                                if(i
Unix 编程环境                        计算机学院网络工程 11 班 horizon                          第一次上机练习 
                } 
                if(order[4]==1 && h==-1) 
                { 
                printf("Wrong order!\n"); 
                return; 
                } 
                if(order[5]==1 && m==-1) 
                { 
                printf("Wrong order!\n"); 
                return; 
                } 
                time(&tp);/*获取当前时间*/ 
                ret = stat(path, &st);/*获取信息*/ 
 
                /*处理 order 的信息*/ 
                if(ret == 0) /*成功读取 path 信息*/ 
                { 
                    if(S_ISDIR(st.st_mode)) /*如果是 dir*/ 
                    { 
                      dir = opendir(path); 
                      if (dir == NULL) /*Unreadable*/ 
                      { 
                        printf("Open directory \"%s\": %s (ERROR %d)\n",path, strerror(errno), errno); 
                        return 1; 
                        } 
                      while ((entry = readdir(dir)) != NULL) /*一直读,直至文件结束*/ 
                        { 
                          strcpy(path1,path); 
                          strcat(path1, "/"); 
                          strcat(path1, entry->d_name); 
                          stat(path1, &st); 
 
                          if(order[1]==0) /*不是-r*/ 
                          { 
                              if(order[2]==1) /*-a*/ 
                              { 
                                if(order[3]==1 && order[4]==1) /*-l 和-h*/ 
                                { 
                                  if((st.st_size<=h) && (st.st_size>=l)) 
                                      if(order[5]==1){    /*-m*/ 
                                          if(((tp-st.st_mtime)/86400+1)<=m) 
                                              printf("%s \n", entry->d_name);} 
                                          else /*no -m*/ 
                                              printf("%s \n", entry->d_name); 
 
5 
Unix 编程环境                        计算机学院网络工程 11 班 horizon                          第一次上机练习 
                                } 
                                else if(order[3]==1 && order[4]==0) 
                                { 
                                  if(st.st_size>=l) 
                                      if(order[5]==1){ 
                                          if(((tp-st.st_mtime)/86400+1)<=m) 
                                              printf("%s \n", entry->d_name);} 
                                      else 
                                          printf("%s \n", entry ->d_name); 
                                } 
                                else if(order[3]==0 && order[4]==1) 
                                { 
                                  if(st.st_size<=m) 
                                      if(order[5]==1){ 
                                              if(((tp-st.st_mtime)/86400+1)<=m) 
                                                      printf("%s \n", entry->d_name);} 
                                        else 
                                          printf("%s \n", entry->d_name); 
                                } 
                                else if(order[3]==0 && order[4]==0) 
                                { 
                                    if(order[5]==1){ 
                                        if(((tp-st.st_mtime)/86400+1)<=m) 
                                              printf("%s \n", entry->d_name);} 
                                        else 
                                              printf("%s \n", entry->d_name); 
                                } 
                              } 
                              else 
                              { 
                                if(order[3]==1 && order[4]==1) 
                                { 
                                  if((st.st_size<=h) && (st.st_size>=l) && entry->d_name[0]!='.') 
                                        if(order[5]==1){ 
                                            if(((tp-st.st_mtime)/86400+1)<=m) 
                                                printf("%s \n", entry->d_name);} 
                                            else 
                                                printf("%s \n", entry->d_name); 
                                } 
                                else if(order[3]==1 && order[4]==0) 
                                { 
                                  if(st.st_size>=l && entry->d_name[0]!='.') 
                                      if(order[5]==1){ 
                                            if(((tp-st.st_mtime)/86400+1)<=m) 
 
6 
Unix 编程环境                        计算机学院网络工程 11 班 horizon                          第一次上机练习 
                                                  printf("%s \n", entry->d_name);} 
                                      else 
                                          printf("%s \n", entry->d_name); 
                                } 
                                else if(order[3]==0 && order[4]==1) 
                                { 
                                  if(st.st_size<=m && entry->d_name[0]!='.') 
                                      if(order[5]==1){ 
                                        if(((tp-st.st_mtime)/86400+1)<=m) 
                                              printf("%s \n", entry->d_name);} 
                                      else 
                                        printf("%s \n", entry->d_name); 
                                } 
                                else if(order[3]==0 && order[4]==0) 
                                { 
                                  if(entry->d_name[0]!='.') 
                                    if(order[5]==1){ 
                                      if(((tp-st.st_mtime)/86400+1)<=m) 
                                          printf("%s \n", entry->d_name);} 
                                    else 
                                      printf("%s \n", entry->d_name); 
                                } 
                                                } 
                                }/*order[1]=0 end*/ 
                                }/*while*/ 
                                closedir(dir); 
                    }/*is DIR*/ 
 
                else/*not a dir*/ 
                { 
                  /*Change path into filename*/ 
                  for(i=0,j=0;path[i]!='\0';i++) 
                                if(path[i]=='/') 
                                    j++; 
                  k=j; 
                  for(j=0,i=0;j-r*/ 
                  if(order[2]==1) 
 
7 
Unix 编程环境                        计算机学院网络工程 11 班 horizon                          第一次上机练习 
                      { 
                        if(order[3]==1 && order[4]==1) 
                        { 
                          if((st.st_size<=h) && (st.st_size>=l)) 
                                      if(order[5]==1){ 
                                          if(((tp-st.st_mtime)/86400+1)<=m) 
                                              printf("%s \n", path);} 
                                      else 
                                          printf("%s \n", path); 
                        } 
                        else if(order[3]==1 && order[4]==0) 
                        { 
                          if(st.st_size>=l) 
                                      if(order[5]==1){ 
                                          if(((tp-st.st_mtime)/86400+1)<=m) 
                                              printf("%s \n", path);} 
                                      else 
                                          printf("%s \n", path); 
                        } 
                        else if(order[3]==0 && order[4]==1) 
                        { 
                          if(st.st_size<=m) 
                              if(order[5]==1){ 
                                              if(((tp-st.st_mtime)/86400+1)<=m) 
                                                              printf("%s \n", path);} 
                              else 
                                              printf("%s \n", path); 
                        } 
                        else if(order[3]==0 && order[4]==0) 
                        { 
                          if(order[5]==1){ 
                                  if(((tp-st.st_mtime)/86400+1)<=m) 
                                          printf("%s \n", path);} 
                          else 
                                printf("%s \n", path); 
                        } 
                      } 
                      else 
                      { 
                        if(order[3]==1 && order[4]==1) 
                        { 
                          if((st.st_size<=h) && (st.st_size>=l) && path[0]!='.') 
                            if(order[5]==1){ 
                                          if(((tp-st.st_mtime)/86400+1)<=m) 
 
8