ÇÁ·Î±×·¡¹Ö

 3206, 4/161 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   ai3rg43
   [c¾ð¾î] ¸®´ª½ºC Áú¹®µå¸³´Ï´Ù.

http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_programming&no=2935 [º¹»ç]


µ¶ÇÐÀ¸·Î ¸®´ª½ºC°øºÎ ½ÃÀÛÇߴµ¥¿ä. ¹®Á¦¸¦ Ç®´Ù ¸·Çô¼­¿ä. Çؼ®°¡´ÉÇϽŠºÐ ÄÚµåÇؼ® Á» ºÎŹµå¸³´Ï´Ù.

#include <stdio.h>
#include <errno.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <string.h>

extern const char *fmt_mode(mode_t mode);
const char *fmt_mode(mode_t mode)
{
static char result[11];
strcpy(result, "----------");
if (S_ISDIR(mode))
    result[0] = 'd';
else if (S_ISCHR(mode))
    result[0] = 'c';
else if (S_ISBLK(mode))
    result[0] = 'b';
else if (S_ISREG(mode))
    result[0] = '-';
else if (S_ISFIFO(mode))
    result[0] = 'p';
else if (S_ISLNK(mode))
    result[0] = 'l';
else if (S_ISSOCK(mode))
    result[0] = 's';
else
    return result;

if ((mode & S_IRUSR) != 0)
    result[1] = 'r';
if ((mode & S_IWUSR) != 0)
    result[2] = 'w';

switch (mode & (S_ISUID|S_IXUSR)) {
case S_ISUID|S_IXUSR:
   result[3] = 's';
   break;
case S_ISUID:
   result[3] = 'S';
   break;
case S_IXUSR:
   result[3] = 'x';
   break;
}
if ((mode & S_IRGRP) != 0)
   result[4] = 'r';
if ((mode & S_IWGRP) != 0)
   result[5] = 'w';
switch (mode & (S_ISGID|S_IXGRP)) {
case S_ISGID|S_IXGRP:
   result[6] = 's';
   break;
case S_ISGID:
   result[6] = 'S';
   break;
case S_IXGRP:
  result[6] = 'x';
  break;
}
if ((mode & S_IROTH) != 0)
  result[7] = 'r';
if ((mode & S_IWOTH) != 0)
  result[8] = 'w';
switch (mode & (S_ISVTX|S_IXOTH)) {
case S_ISVTX|S_IXOTH:
  result[9] = 't';
  break;
case S_ISVTX:
  result[9] = 'T';
  break;
case S_IXOTH:
  result[9] = 'x';
  break;
}
return result;
}
char *myname;
int process(char *dir);
int main(int argc, char **argv)
{
   int i;
   int errs = 0;

   myname = argv[0];

   if (argc == 1)
       errs = process(".");
   else
         for (i = 1; i < argc; i++)
               errs += process(argv[i]);
   return (errs != 0);
}


int
process(char *dir)
{
    DIR *dp;
    struct dirent *ent;
    struct stat sbuf;
    char fullname[PATH_MAX];

    if ((dp = opendir(dir)) == NULL) {
         fprintf(stderr, "%s: %s: cannot open for reading: %s\n",myname, dir, strerror(errno));
         return 1;
    }
    errno = 0;
    while ((ent = readdir(dp)) != NULL) {

  
    sprintf(fullname, "%s/%s", dir, ent->d_name);
    if (stat(fullname, & sbuf) < 0) {
          fprintf(stderr, "stat: %s: %s\n",ent->d_name, strerror(errno));
          continue;
    }
  
    printf("%8ld %s %lu %s\n", ent->d_ino, fmt_mode(sbuf.st_mode),sbuf.st_nlink, fullname);
}
if (errno != 0) {
    fprintf(stderr, "%s: %s: reading or stating directory entries: %s\n",myname, dir, strerror(errno));
    return 1;
}
if (closedir(dp) != 0) {
   fprintf(stderr, "%s: %s: closedir: %s\n",myname, dir, strerror(errno));
   return 1;
}
return 0;
}

  Hit : 3774     Date : 2011/04/05 01:31



    
¸Û¸Û Á˼ÛÇÏÁö¸¸ Áú¹®ÀÌ ¸íÈ®ÇÏÁö¾Ê¾Æ¼­ ´äº¯À» µå¸®±â°¡ ¾î·Æ³×¿ä.. 2011/04/05  
3146   c¾ð¾î ±âÃÊ°¡ ¾î´ÀÁ¤µµ µÇ¾úÀ»¶§.[1]     ÁÁÀºÇÏ·ç
09/09 2743
3145   ÆÄÀ̽ãÀº ¾îµû ½á¸Ô´Â°ÅÁÒ?[1]     aad3365
09/11 3295
3144   C¾ð¾î Áú¹®ÇÒ°Ô¿ä.[1]     abcd941212
02/12 2600
3143   Æ÷ÀÎÅÍ¿¡´ëÇØ..     Abek_wolf
01/28 3740
3142   Æ÷ÀÎÅÍ ¿©·¯°¡Áö Áú¹®;;     Abek_wolf
01/29 3472
3141   ÇÔ¼ö¿¡¼­[10]     Abek_wolf
01/29 3501
3140   Á¶¾ðÁ» ºÎŹµå¸³´Ï´Ù...     addplus
03/06 2632
3139     [re] CÇÁ·Î±×·¡¹Ö ´äº¯Á»..     admin
09/04 6921
3138     [re] ºÒ¹ýÀÎÁö ¾Ë·ÁÁÖ¼¼¿ä     admin
09/05 6932
3137   ´Ù¿î·Îµå°Ô½ÃÆÇ¿¡¿ä..back track À̶õÆÄÀÏÀº ¸ÓÁÒ '¤Ñ'?     adult_child
11/06 2865
3136 ºñ¹Ð±ÛÀÔ´Ï´Ù  c¾ð¾î ¼Ò¼ö °ª     adwefq
04/29 0
3135   ¹®ÀÚ¿­ ¹è¿­»ç¿ëÇؼ­ µ¡¼ÀÇϴ°ŠÀß ¸ð¸£°Ú¾î¿ä[1]     ÃÊ¿ìÃÊ¿ì
12/04 7478
3134   ÄÄÆÄÀÏÇÒ¶§ÀÇ ¿¡·¯¸Þ¼¼Áö(Hellow ÇÁ·Î±×·¥)[9]     agape_hatred
07/15 3369
3133   HellowÇÁ·Î±×·¥ º¯Çü¼Ò½º[8]     agape_hatred
07/15 3427
3132   ¼Ò½ºÁ» ¼öÁ¤Á» ÇØ ÁÖ¼¼¿ä[2]     agape_hatred
08/29 3061
3131   [C¾ð¾î] 2Â÷¿ø ¹è¿­°ú ¹®ÀÚ¿­ÀÇ ÀúÀå°ü°è¿Í printfÀÇ Ãâ·Â¹æ½Ä     agmlwn
01/29 12781
3130   2ÀÇ n½Â Ãâ·ÂÇÏ´Â°É ¸¸µå´Âµ¥¿ä..;[2]     ahotsuna
09/18 4569
3129   Ãʺ¸ÀûÀÎ Áú¹®....[1]     ahuramazda
07/16 3649
  [c¾ð¾î] ¸®´ª½ºC Áú¹®µå¸³´Ï´Ù.[1]     ai3rg43
04/05 3773
3127   C¾ð¾î ¹®ÀÚ¿­ ÀÔ·Â °ü·ÃÇؼ­ Áú¹®ÀÔ´Ï´Ù.[5]     ÃÏÀÇÀü·«
04/18 4193
[1][2][3] 4 [5][6][7][8][9][10]..[161]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org