This file is indexed.

/usr/share/doc/libnjb-doc/examples/settime.c is in libnjb-doc 2.2.7~dfsg0-3ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "common.h"
#include <string.h>

static char *prompt (const char *prompt, char *buffer, size_t bufsz, int required)
{
  char *cp, *bp;
  
  while (1) {
    fprintf(stdout, "%s> ", prompt);
    if ( fgets(buffer, bufsz, stdin) == NULL ) {
      if (ferror(stdin)) {
	perror("fgets");
      } else {
	fprintf(stderr, "EOF on stdin\n");
      }
      return NULL;
    }
    
    cp= strrchr(buffer, '\n');
    if ( cp != NULL ) *cp= '\0';
    
    bp= buffer;
    while ( bp != cp ) {
      if ( *bp != ' ' && *bp != '\t' ) return bp;
      bp++;
    }
    
    if (! required) return bp;
  }
}

static void dumptime(njb_time_t *time)
{
  if (time != NULL) {
    switch(time->weekday) {
    case 0:
      printf("Sunday ");
      break;
    case 1:
      printf("Monday ");
      break;
    case 2:
      printf("Tuesday ");
      break;
    case 3:
      printf("Wednesday ");
      break;
    case 4:
      printf("Thursday ");
      break;
    case 5:
      printf("Friday ");
      break;
    case 6:
      printf("Saturday ");
    }
    /* OK this is the way we write dates
     * in Sweden, you may change it if you
     * don't like it!
     */
    printf("%u-%.2u-%.2u ", time->year, 
	   time->month, time->day);
    printf("%.2u:%.2u:%.2u\n", time->hours, 
	   time->minutes, time->seconds);
  }
}


int main(int argc, char **argv)
{
  njb_t njbs[NJB_MAX_DEVICES], *njb;
  extern char *optarg;
  int opt;
  int n, debug;
  njb_time_t *time;
  char *pnum;
  char num[80];
  
  debug = 0;
  while ((opt = getopt(argc, argv, "D:")) != -1) {
    switch (opt) {
    case 'D':
      debug = atoi(optarg);
      break;
    default:
      fprintf(stderr, "usage: settime [ -D debuglvl ]\n");
      return 1;
    }
  }
  
  if (debug)
    NJB_Set_Debug(debug);

  if (NJB_Discover(njbs, 0, &n) == -1) {
    fprintf(stderr, "could not locate any jukeboxes\n");
    return 1;
  } 
  
  if (n == 0) {
    fprintf(stderr, "no NJB devices found\n");
    return 0;
  }
  
  njb = njbs;
  
  if (NJB_Open(njb) == -1) {
    NJB_Error_Dump(njb,stderr);
    return 1;
  }

  if (NJB_Capture(njb) == -1) {
    NJB_Error_Dump(njb,stderr);
    return 1;
  }
  
  time = NJB_Get_Time(njb);
  
  printf("The time on the jukebox is:\n");
  dumptime(time);
  
  printf("\nNew time (old values preserved if left blank):\n");
  
  if ( (pnum= prompt("Year:", num, 80, 0)) == NULL ) return 1;
  if ( strlen(pnum) ) {
    time->year= (u_int16_t) strtoul(pnum, 0, 10);
  }
  
  if ( (pnum= prompt("Month (1-12):", num, 80, 0)) == NULL ) return 1;
  if ( strlen(pnum) ) {
    time->month= (u_int16_t) strtoul(pnum, 0, 10);
  }
  
  if ( (pnum= prompt("Day:", num, 80, 0)) == NULL ) return 1;
  if ( strlen(pnum) ) {
    time->day= (u_int16_t) strtoul(pnum, 0, 10);
  }
  
  if ( (pnum= prompt("Weekday (0-6):", num, 80, 0)) == NULL ) return 1;
  if ( strlen(pnum) ) {
    time->weekday= (u_int16_t) strtoul(pnum, 0, 10);
  }
  
  if ( (pnum= prompt("Hours (0-23):", num, 80, 0)) == NULL ) return 1;
  if ( strlen(pnum) ) {
    time->hours= (u_int16_t) strtoul(pnum, 0, 10);
  }
  
  if ( (pnum= prompt("Minutes (0-59):", num, 80, 0)) == NULL ) return 1;
  if ( strlen(pnum) ) {
    time->minutes= (u_int16_t) strtoul(pnum, 0, 10);
  }
  
  if ( (pnum= prompt("Seconds (0-59):", num, 80, 0)) == NULL ) return 1;
  if ( strlen(pnum) ) {
    time->seconds= (u_int16_t) strtoul(pnum, 0, 10);
  }
  
  printf("The time on the jukebox is being set to:\n");
  dumptime(time);
  
  if (NJB_Set_Time(njb, time) == -1) {
    NJB_Error_Dump(njb,stderr);
  }
  
  NJB_Destroy_Time(time);
  
  NJB_Release(njb);
  
  NJB_Close(njb);
  return 0;
}