<commit_before><commit_msg>chmod: add implementation<commit_after>#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>

struct option longopts [] = {
    {"help", no_argument, 0, 'h'},
    {"verbose", no_argument, 0, 'v'},
    {"changes", no_argument, 0, 'c'},
    {0,0,0,0}
};

int main (int argc, char *argv[]) {

    int h = 0;
    int v = 0;
    int c = 0;
    int i = 0;


    while ((i = getopt_long(argc, argv, "hvc", longopts, NULL)) != -1){

        switch (i){

            case 'h':
                h = 1;
                break;

            case 'v':
                v = 1;
                break;

            case 'c':
                c = 1;
                break;

            case '?':
            if (isprint (optopt))
              fprintf (stderr, "Unknown option `-%c'.\n", optopt);
            else
              fprintf (stderr,"Unknown option character! `\\x%x'.\n", optopt);

                return 1;

            default:
                return 1;
        }
    }
    if (argc < 3){
      fprintf(stderr, "chmod error\n");
      exit(EXIT_FAILURE);
    }

    if (h == 1) {
      printf("usage: chmod[OPTION]... MODE[MODE]...file ...\n" \
              "  ----- Options -----\n" \
              "  -v\tWarns what will be made and when action is done.\n" \
              "  -c\tTells what has been made once the action is completed.\n");
    }

    char *permission = argv[optind];
    char *buf = argv[optind+1];
    int x;

    if (strlen(permission) != 4 | (permission[0] - '0') != 0 | (permission[1] - '0') > 7
        | (permission[2] - '0') > 7 | (permission[3]  - '0' )> 7) {
          printf("%c\n", permission[3]);
      printf("input error \n");
      exit(EXIT_FAILURE);
    }

    if(buf == NULL){
      printf("no path entered \n");
    }

    if (v == 1){
      printf("the file %s will be given a %s authorization \n", argv[3], argv[2]);
    }

    x = strtol(permission, 0, 8);
    if(chmod (buf,x) < 0){
      fprintf(stderr, "chmod error\n");
      exit(EXIT_FAILURE);
    }

    if (v == 1){
      printf("operation completed \n");
    }

    if (c == 1){
      printf("the file %s has been given a %s authorization \n", argv[3], argv[2]);
    }
    return EXIT_SUCCESS;
}
{'fraction_non_alphanumeric': 0.17587719298245613, 'fraction_numerical': 0.01929824561403509, 'mean_word_length': 1.6492450638792102, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7339045', 'n_tokens_mistral': 818, 'n_tokens_neox': 776, 'n_words': 215}