预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共24页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

Readme:将两个文件list.h和ls.c文件放入linux下同一目录下,gcc编译,之后就可以通过./可执行文件名-选项参数运行了。本程序实现大部分ls的功能,在ubuntu16.04下测试可用,大家有什么不懂的欢迎探讨。qq:280438369 List.h文件代码内容如下: #ifndef_LINUX_LIST_H #define_LINUX_LIST_H /* *Simpledoublylinkedlistimplementation. * *Someoftheinternalfunctions("__xxx")areusefulwhen *manipulatingwholelistsratherthansingleentries,as *sometimeswealreadyknowthenext/preventriesandwecan *generatebettercodebyusingthemdirectlyratherthan *usingthegenericsingle-entryroutines. */ structlist_head{ structlist_head*next,*prev; }; #defineLIST_HEAD_INIT(name){&(name),&(name)} #defineLIST_HEAD(name)\ structlist_headname=LIST_HEAD_INIT(name) #defineINIT_LIST_HEAD(ptr)do{\ (ptr)->next=(ptr);(ptr)->prev=(ptr);\ }while(0) /* *Insertanewentrybetweentwoknownconsecutiveentries. * *Thisisonlyforinternallistmanipulationwhereweknow *theprev/nextentriesalready! */ static__inline__void__list_add(structlist_head*new, structlist_head*prev, structlist_head*next) { next->prev=new; new->next=next; new->prev=prev; prev->next=new; } /** *list_add-addanewentry *@new:newentrytobeadded *@head:listheadtoadditafter * *Insertanewentryafterthespecifiedhead. *Thisisgoodforimplementingstacks. */ static__inline__voidlist_add(structlist_head*new,structlist_head*head) { __list_add(new,head,head->next); } /** *list_add_tail-addanewentry *@new:newentrytobeadded *@head:listheadtoadditbefore * *Insertanewentrybeforethespecifiedhead. *Thisisusefulforimplementingqueues. */ static__inline__voidlist_add_tail(structlist_head*new,structlist_head*head) { __list_add(new,head->prev,head); } /* *Deletealistentrybymakingtheprev/nextentries *pointtoeachother. * *Thisisonlyforinternallistmanipulationwhereweknow *theprev/nextentriesalready! */ static__inline__void__list_del(structlist_head*prev, structlist_head*next) { next->prev=prev; prev->next=next; } /** *list_del-deletesentryfromlist. *@entry:theelementtodeletefromthelist. *Note:list_emptyonentrydoesnotreturntrueafterthis,theentryisinanundefinedstate.