📄 init.c
字号:
printf("Unknown switch '%s'\n",argv[__argc]); return -1; } break; } case 'd': { debug("Setting mode to BACKUP_DAEMON\n"); /*set mode to DAEMON*/ conf__mode=DAEMON; break; } case 'f': { debug("Disabling curses interface\n"); conf__curses=0; break; } case 'm': { debug("Allowing multiple volumes if needed\n"); /* enable multiple volumes */ conf__allow_multiple=1; debug("expecting next argument to be length data\n"); /*prepare data reception*/ prev_switch='m'; break; } case 'y': { debug("expecting next argument to be retry data\n"); /*prepare data reception*/ prev_switch='y'; break; } case 'b': { debug("Including special files in archive\n"); /* Indicate that we want all files, also special files */ conf__special_files=1; break; } case 'c': { debug("Using compression\n"); /*set mode to DAEMON*/ conf__compress=1; /*maybe a tool name*/ prev_switch='c'; break; } case 'e': { debug("Archive is not verified\n"); /*set mode to DAEMON*/ conf__verify=0; break; } case 'g': { /* enable debug */ enable_dbg=1; debug("Debug enable via '-g' switch\n"); break; } case 'n': { debug("Ignoring time info\n"); /*Ignore time-info*/ conf__ignore_time_info=1; break; } case 'a': { debug("Expecting next argument to be device or filename data\n"); /*prepare data reception*/ prev_switch='a'; break; } case 'h': { debug("Expecting next argument to be remote host shell application\n"); /*prepare data reception*/ prev_switch='h'; break; } case 'i': { debug("Expecting next argument to be archive id\n"); /*set flag to indicate that we are just updating the archive info*/ conf__update_archiveinfo=1; /*prepare data reception*/ prev_switch='i'; break; } case 'j': { debug("Expecting next argument to be scriptname or command\n"); /*prepare data reception*/ prev_switch='j'; break; } case 'k': { debug("Expecting next argument to be scriptname or command\n"); /*prepare data reception*/ prev_switch='k'; break; } case 'l': { errcode=255; printf("List not yet implemented.. Please use tar directly.\n"); return -1; } case 'r': { errcode=255; printf("Restore not yet implemented.. Please use tar directly.\n"); return -1; } case 'o': { debug("Follow symlinks\n"); /*indicate the request*/ conf__follow_symlinks=1; break; } case 'q': { debug("Create copy of targets on a filesystem\n"); conf__type=FILECOPY; break; } case 's': { debug("Do not resolve old archive-info\n"); /*indicate the request*/ conf__skip_old_archiveinfo=1; break; } case 'p': { debug("expecting next argument to be nice data\n"); /*prepare data reception*/ prev_switch='p'; break; } case 't': { debug("expecting next argument to be time data\n"); /*prepare data reception*/ prev_switch='t'; break; } case 'u': { debug("Archive should be updated, not created\n"); /*set the requested tar action*/ conf__tar_action='u'; break; } case 'v': { debug("Write archive to a CDR\n"); conf__type=CDR; break; } case 'w': { debug("Write archive to a CDRW\n"); conf__type=CDRW; break; } case 'z': { debug("Write archive to a iso file\n"); conf__type=ISO; break; } case 'x': { debug("Expecting next argument to be exclude list\n"); /*prepare data reception*/ prev_switch='x'; break; } default: { errcode=1; printf("Unknown switch '-%c'\n",argv[__argc][1]); return -1; } } } else if(argv[__argc][0]=='-' && prev_switch!=0) { debug("argument %u is switch but data was expected\n",__argc); /*tell the user that some data must be given*/ errcode=4; printf("Switch '-%c' must be followed by a string with the requested setting\n",prev_switch); printf("Try 'sitback -h' to get help.\n"); return -1; } else { debug("argument %u is data\n",__argc); /*if we do not expect any data (not a previous switch), then it must be the script name*/ if(prev_switch==0) { /*do we have a previous script name*/ if(conf__script_name[0]!='\0') { printf("More than one script name given on the command line..\n"); debug("Already has a script name.\n"); return -1; } else { /*make sure the script name does not exceed 50 characters*/ if(strlen(argv[__argc])>50) { debug("Script name is too long\n"); errcode=3; printf("Unexpected argument '%s'. Script name exceeds 50 characters\n",argv[__argc]); return -1; } /*read the script name*/ strcpy(conf__script_name,argv[__argc]); debug("Script name is '%s'\n",conf__script_name); } } else { debug("data is '%s'\n",argv[__argc]); /*read data depending upon the previous switch*/ switch(prev_switch) { case 'c': { if(!strcasecmp(argv[__argc],"BZIP2")) conf__compressor=BZIP2; else if(!strcasecmp(argv[__argc],"GZIP")) conf__compressor=GZIP; else if(!strcasecmp(argv[__argc],"COMPRESS")) conf__compressor=COMPRESS; else if(!strcasecmp(argv[__argc],"ZIP")) conf__compressor=ZIP; else { printf("Unknown compression tool '%s'\n",argv[__argc]); errcode=55; return -1; } break; } case 'h': { debug("Reading data for remote shell application\n"); /*make sure we did not get to much data. */ if(strlen(argv[__argc])>255) { errcode=6; printf("The remote shell string is too long\n"); return -1; } /*parse the time-string*/ strcpy(conf__rsh,argv[__argc]); break; } case 't': { debug("Reading data for time switch\n"); /*make sure we did not get to much data. Dont rely on strlen yet*/ if(memchr(argv[__argc],'\0',0xFFFFFFFE)==NULL) { errcode=6; printf("The time string is too long\n"); return -1; } /*ok, now we can do strlen*/ /*parse the time-string*/ if(__parse_timestring(argv[__argc])) { errcode=7; return -1; } break; } case 'y': { debug("Reading data for retry counter\n"); /*get the retry count*/ if(argv[__argc][0]<'0' || argv[__argc][0]>'9') { errcode=51; printf("Retry count '%c' is not a number\n",argv[__argc][0]); return -1; } if(argv[__argc][1]!='\0') { errcode=52; printf("Retry count should be in the range [0;9]\n"); return -1; } conf__retry=argv[__argc][0]-'0'; conf__retry++; debug("Retry count is %d\n",conf__retry-1); break; } case 'l': { debug("Reading data for volume-length switch\n"); /*get the volume length*/ val=strtol(argv[__argc],&suffix,10); /*make sure we got a valid number*/ if(val==0) { errcode=5; printf("Volume length of 0 bytes is not allowed\n"); return -1; } if(!strcmp(argv[__argc],suffix)) { errcode=5; printf("Invalid volume length. (not a decimal number)\n"); return -1; } /*adjust the value to fit the -l tar switch*/ if(*suffix=='k' || *suffix=='K') val=val; else if(*suffix=='m' || *suffix=='M') val=val*1024; else { if(val%1024) { /*check if we did not get a valid number of bytes*/ errcode=5; printf("Volume length must be X*1024 bytes\n"); return -1; } /*calculate block-count*/ val/=1024; } /*store the block-count*/ conf__volume_length=val; debug("Volume-length is %ld*1024\n",val); /* Setting a volume length, enables multiple volumes */ conf__allow_multiple=1; break; } case 'p': { debug("Reading data for nice adjust\n"); /* read the adjustment and silently correct range overflows */ sscanf(argv[__argc],"%d",&conf__nice); if(conf__nice<-20) conf__nice=-20; if(conf__nice>19) conf__nice=19; debug("nice adjust is %d\n",conf__nice); break; } case 'a': { /*make sure we did not get to much data. Dont rely on strlen yet*/ if(strlen(argv[__argc])>256) { errcode=6; printf("The device/filename string is too long. Maximum 256 characters\n"); return -1; } /* store the device or filename */ strcpy(conf__org_archive,argv[__argc]); strcpy(conf__archive,argv[__argc]); debug("Archive name is \"%s\"\n",conf__archive); /* check if the device is remote */ if(strchr(conf__archive,':')!=NULL) { /* do we have a username */ if(strchr(conf__archive,'@')!=NULL) { p=conf__archive; while(*p!='@') p++; memcpy(conf__ruser,conf__archive,p-conf__archive); conf__ruser[p-conf__archive]='\0'; p++; } else { strcpy(conf__ruser,__get_local_user()); p=conf__archive; } /* extract the host name */ strcpy(conf__rhost,p); p=conf__rhost; while(*p!=':') p++; *p='\0';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -