📄 init.c
字号:
/* extract the host name */ strcpy(conf__rhost,p); p=conf__rhost; while(*p!=':') p++; *p='\0'; /* done */ debug("Archive is remote. Host name is '%s', user name is '%s'\n",conf__rhost,conf__ruser); } else { debug("Archive is local\n"); } /*next command*/ p=end; } /*Keyword 'FILE'*/ if(!strncasecmp(p,"TARGET=",7)) { debug("found keyword 'TARGET' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!='\r') end++; /*add this file or directory to the list*/ p+=7; prev_char=*end; *end='\0'; if(__add_file(p)==-1) { __free_filelist(); /*dont forget to cleanup any previous entry's in the list*/ free(buffer); errcode=13; /*error message has been given by the __add_file() function*/ return -1; } *end=prev_char; /*next command*/ p=end; } /*Keyword 'PRINTERNAME'*/ if(!strncasecmp(p,"REPORTPRINTER=",14)) { debug("found keyword 'REPORTPRINTER' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*make sure the string dont exceed 256 characters*/ if((end-p-14)>256) { free(buffer); errcode=6; sprintf(strn,"REPORTPRINTER string in script is too long. Maximum 256 characters\n"); UI__Warning(strn); return -1; } /*set the printername*/ memcpy(conf__report_printer,p+14,end-p-14); conf__report_printer[end-p-14]='\0'; debug("report printername set to \"%s\"\n",conf__report_printer); /*next command*/ p=end; } /*Keyword 'FILENAME'.*/ if(!strncasecmp(p,"REPORTFILE=",11)) { debug("found keyword 'REPORTFILE' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*make sure the string dont exceed 256 characters*/ if((end-p-11)>256) { free(buffer); errcode=6; sprintf(strn,"REPORTFILE string in script is too long. Maximum 256 characters\n"); UI__Warning(strn); return -1; } /*set report filename*/ memcpy(conf__report_name,p+11,end-p-11); conf__report_name[end-p-11]='\0'; debug("report filename set to \"%s\"\n",conf__report_name); /*next command*/ p=end; } /*Keyword 'SMBUSER'*/ if(!strncasecmp(p,"SMBUSER=",8)) { debug("found keyword 'SMBUSER' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*make sure the string dont exceed 256 characters*/ if((end-p-8)>20) { free(buffer); errcode=6; sprintf(strn,"SMBUSER string in script is too long. Maximum 20 characters\n"); UI__Warning(strn); return -1; } /*set the printertype*/ memcpy(conf__smb_user,p+8,end-p-8); conf__smb_user[end-p-8]='\0'; debug("smbuser set to \"%s\"\n",conf__smb_user); /*next command*/ p=end; } /*Keyword 'SMBPASSWORD'*/ if(!strncasecmp(p,"SMBPASSWORD=",12)) { debug("found keyword 'SMBPASSWORD' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*make sure the string dont exceed 256 characters*/ if((end-p-12)>20) { free(buffer); errcode=6; sprintf(strn,"SMBPASSWD string in script is too long. Maximum 20 characters\n"); UI__Warning(strn); return -1; } /*set the printertype*/ memcpy(conf__smb_passwd,p+12,end-p-12); conf__smb_passwd[end-p-10]='\0'; debug("smbpasswd set to \"%s\"\n",conf__smb_passwd); /*next command*/ p=end; } /*Keyword 'COMPRESSOR=GZIP'*/ if(!strncasecmp(p,"COMPRESSOR=GZIP",15)) { /*force gzip compression*/ if(conf__compressor==0) conf__compressor=GZIP; /*end of command*/ while(*p!='\0' && *p!='\n' && *p!=' ' && *p!='\r') p++; } /*Keyword 'COMPRESSOR=BZIP2'*/ if(!strncasecmp(p,"COMPRESSOR=BZIP2",16)) { /*force gzip compression*/ if(conf__compressor==0) conf__compressor=BZIP2; /*end of command*/ while(*p!='\0' && *p!='\n' && *p!=' ' && *p!='\r') p++; } /*Keyword 'COMPRESSOR=ZIP'*/ if(!strncasecmp(p,"COMPRESSOR=ZIP",14)) { /*force zip compression*/ if(conf__compressor==0) conf__compressor=ZIP; /*end of command*/ while(*p!='\0' && *p!='\n' && *p!=' ' && *p!='\r') p++; } /*Keyword 'COMPRESSOR=COMPRESS'*/ if(!strncasecmp(p,"COMPRESSOR=COMPRESS",19)) { /*force gzip compression*/ if(conf__compressor==0) conf__compressor=COMPRESS; /*end of command*/ while(*p!='\0' && *p!='\n' && *p!=' ' && *p!='\r') p++; } /*Keyword 'COMPRESSION=YES'*/ if(!strncasecmp(p,"COMPRESSION=YES",15)) { debug("found keyword 'COMPRESSION=YES' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*Use compression*/ conf__compress=1; /*next command*/ p=end; } /*Keyword 'COMPRESSION=NO'*/ if(!strncasecmp(p,"COMPRESSION=NO",14)) { debug("found keyword 'COMPRESSION=NO' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*Dont use compression*/ if(conf__compress) { debug("Command line request for compression overrides COMPRESSION=NO in script\n"); } else conf__compress=0; /*next command*/ p=end; } /*Keyword 'NO VERIFY'*/ if(!strncasecmp(p,"VERIFY=NO",9)) { debug("found keyword 'VERIFY=NO' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /* dont verify archive */ conf__verify=0; /*next command*/ p=end; } /*Keyword 'VERIFY=YES'*/ if(!strncasecmp(p,"VERIFY=YES",10)) { debug("found keyword 'VERIFY=YES' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*dont override the command-line request for skipping verification*/ if(conf__verify==0) { debug("not overriding command-line request for no verification\n"); } else conf__verify=1; /*next command*/ p=end; } /*Keyword 'VERIFY=STRICT'*/ if(!strncasecmp(p,"VERIFY=STRICT",13)) { debug("found keyword 'VERIFY=STRICT' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*dont override the command-line request for skipping verification*/ if(conf__verify==0) { debug("not overriding command-line request for no verification\n"); } else conf__verify=2; /*next command*/ p=end; } /*Keyword 'VERIFY=LAZY'*/ if(!strncasecmp(p,"VERIFY=LAZY",11)) { debug("found keyword 'VERIFY=LAZY' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*dont override the command-line request for skipping verification*/ if(conf__verify==0) { debug("not overriding command-line request for no verification\n"); } else conf__verify=3; /*next command*/ p=end; } /*Keyword 'MULTIPLE VOLUMES'*/ if(!strncasecmp(p,"MULTIPLE VOLUMES",16)) { debug("found keyword 'MULTIPLE VOLUMES' at position %d\n",p-buffer); /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!='\r') end++; /* Allow multiple volumes */ conf__allow_multiple=1; /*next command*/ p=end; } /*Keyword 'LENGTH'*/ if(!strncasecmp(p,"VOLUMELENGTH=",13)) { debug("found keyword 'VOLUMELENGTH' at position %d\n",p-buffer); /*get the volume-length*/ val=strtol(p+13,&suffix,10); /*make sure we got a valid number*/ if(val==0) { errcode=5; UI__Warning("Volume length of 0 bytes is not allowed\n"); return -1; } if(!memcmp(p+13,suffix,1)) { errcode=5; UI__Warning("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; UI__Warning("Volume length must be X*1024 bytes\n"); return -1; } /*calculate block-count*/ val/=1024; } /*store the block-count*/ if(conf__volume_length==0) { conf__volume_length=(int) val; debug("Volume length is %d\n",conf__volume_length); conf__allow_multiple=1; } else { debug("Will not override volumelength from command-line\n"); } /*end of command*/ end=p; while(*end!='\0' && *end!='\n' && *end!=' ' && *end!='\r') end++; /*next command*/ p=end; } /*Keyword 'RETRY'*/ if(!strncasecmp(p,"RETRY=",6)) { debug("found keyword 'RETRY' at position %d\n",p-buffer); /*check if the retry count is valid*/ if(p[6]<'0' || p[6]>'9') { errcode=51; sprintf(strn,"Retry count '%c' is not a number\n",p[6]); UI__Warning(strn); return -1; } if(p[7]!='\n' && p[7]!=' ' && p[7]!='\0') { errcode=52; sprintf(strn,"Retry count should be in the range [0;9]\n"); UI__Warning(strn); return -1; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -