max_stars_repo_path
stringlengths
2
976
max_stars_repo_name
stringlengths
5
109
max_stars_count
float64
0
191k
id
stringlengths
1
7
content
stringlengths
1
11.6M
score
float64
-0.83
3.86
int_score
int64
0
4
Code/Framework/AzFramework/AzFramework/Archive/ZipDirCacheFactory.h
BreakerOfThings/o3de
11
7998683
/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ // This is the class that can read the directory from Zip file, // and store it into the directory cache #pragma once #include <AzFramework/Archive/IArchive.h> namespace AZ::IO::ZipDir { class Cache; // an instance of this class is temporarily created on stack to initialize the CZipFile instance class CacheFactory { public: enum { // open RW cache in read-only mode FLAGS_READ_ONLY = 1, // do not compact RW-cached zip upon destruction FLAGS_DONT_COMPACT = 1 << 1, // if this is set, then the zip paths won't be memorized in the cache objects FLAGS_DONT_MEMORIZE_ZIP_PATH = 1 << 2, // if this is set, the archive will be created anew (the existing file will be overwritten) FLAGS_CREATE_NEW = 1 << 3, // if this is set, zip path will be searched inside other zips FLAGS_READ_INSIDE_PAK = 1 << 7, }; // initializes the internal structures // nFlags can have FLAGS_READ_ONLY flag, in this case the object will be opened only for reading CacheFactory(InitMethod nInitMethod, uint32_t nFlags = 0); ~CacheFactory(); // the new function creates a new cache CachePtr New(const char* szFileName); protected: // reads the zip file into the file entry tree. bool ReadCache(Cache& rwCache); void Clear(); // reads everything and prepares the maps bool Prepare(); // searches for CDREnd record in the given file bool FindCDREnd();// throw(ErrorEnum); // uses the found CDREnd to scan the CDR and probably the Zip file itself // builds up the m_mapFileEntries bool BuildFileEntryMap();// throw (ErrorEnum); // give the CDR File Header entry, reads the local file header to validate and determine where // the actual file lies // This function can actually modify strFilePath variable, make sure you use a copy of the real path. void AddFileEntry(char* strFilePath, const ZipFile::CDRFileHeader* pFileHeader, const SExtraZipFileData& extra);// throw (ErrorEnum); // initializes the actual data offset in the file in the fileEntry structure // searches to the local file header, reads it and calculates the actual offset in the file void InitDataOffset(FileEntryBase& fileEntry, const ZipFile::CDRFileHeader* pFileHeader); // seeks in the file relative to the starting position void Seek(uint32_t nPos, int nOrigin = 0); // throw int64_t Tell(); // throw bool Read(void* pDest, uint32_t nSize); // throw bool ReadHeaderData(void* pDest, uint32_t nSize); // throw protected: AZStd::string m_szFilename; CZipFile m_fileExt; InitMethod m_nInitMethod; uint32_t m_nFlags; ZipFile::CDREnd m_CDREnd; size_t m_nZipFileSize; uint32_t m_nCDREndPos; // position of the CDR End in the file // Map: Relative file path => file entry info using FileEntryMap = AZStd::map<AZStd::string, ZipDir::FileEntryBase>; FileEntryMap m_mapFileEntries; FileEntryTree m_treeFileEntries; AZStd::vector<uint8_t> m_CDR_buffer; bool m_bBuildFileEntryMap; bool m_bBuildFileEntryTree; bool m_bBuildOptimizedFileEntry; ZipFile::EHeaderEncryptionType m_encryptedHeaders; ZipFile::EHeaderSignatureType m_signedHeaders; ZipFile::CryCustomEncryptionHeader m_headerEncryption; ZipFile::CrySignedCDRHeader m_headerSignature; ZipFile::CryCustomExtendedHeader m_headerExtended; }; }
1.804688
2
generic_macros.h
MadRubicant/libuniversity
0
7998691
#ifndef GENERIC_MACROS_H #define GENERIC_MACROS_H #define _TOKENPASTE(x, y) x ## y // This nets us 27 levels of macro recursion depth #define _EMPTY() #define _DEFER(id) id _EMPTY() #define _OBSTRUCT(...) __VA_ARGS__ _DEFER(_EMPTY)() #define _EXPAND(...) __VA_ARGS__ #define _EVAL2(...) __VA_ARGS__ #define _EVAL1(...) _EVAL2(_EVAL2(_EVAL2(__VA_ARGS__))) #define _EVAL(...) _EVAL1(_EVAL1(_EVAL1(__VA_ARGS__))) #define RAW_STRING(x) #x #define STRING(x) RAW_STRING(x) #endif
1.546875
2
remoting/client/display/gl_helpers.h
zealoussnow/chromium
2,151
7998699
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef REMOTING_CLIENT_DISPLAY_GL_HELPERS_H_ #define REMOTING_CLIENT_DISPLAY_GL_HELPERS_H_ #include "base/macros.h" #include "remoting/client/display/sys_opengl.h" namespace remoting { // Compiles a shader and returns the reference to the shader if it succeeds. GLuint CompileShader(GLenum shader_type, const char* shader_source); // Creates a program with the given reference to the vertex shader and fragment // shader. returns the reference of the program if it succeeds. GLuint CreateProgram(GLuint vertex_shader, GLuint fragment_shader); // Creates and returns the texture names if it succeeds. GLuint CreateTexture(); // Creates a GL_ARRAY_BUFFER and fills it with |data|. Returns the reference to // the buffer. GLuint CreateBuffer(const void* data, int size); } // namespace remoting #endif // REMOTING_CLIENT_DISPLAY_GL_HELPERS_H_
1.101563
1
thirdparty/wnlib/acc/complex/wncplx.h
rbarzic/MAGICAL
0
7998707
/**************************************************************************** COPYRIGHT NOTICE: The source code in this directory is provided free of charge to anyone who wants it. It is in the public domain and therefore may be used by anybody for any purpose. It is provided "AS IS" with no warranty of any kind whatsoever. For further details see the README files in the wnlib parent directory. AUTHOR: <NAME> ****************************************************************************/ #ifndef wncplxH #define wncplxH typedef struct wn_cplx_struct *wn_cplx; struct wn_cplx_struct { double real,imag; }; EXTERN void wn_cplx_make(wn_cplx *pnumber); EXTERN void wn_cplx_copy(wn_cplx out,wn_cplx in); EXTERN void wn_cplx_enter(wn_cplx c); EXTERN void wn_cplx_print(wn_cplx c); EXTERN void wn_cplx_add(wn_cplx result,wn_cplx c1,wn_cplx c2); EXTERN void wn_cplx_subtract(wn_cplx result,wn_cplx c1,wn_cplx c2); EXTERN void wn_cplx_multiply(wn_cplx result,wn_cplx c1,wn_cplx c2); EXTERN void wn_cplx_divide(wn_cplx result,wn_cplx c1,wn_cplx c2); EXTERN void wn_cplx_reciprical(wn_cplx result,wn_cplx c); EXTERN double wn_cplx_norm_squared(wn_cplx c); EXTERN double wn_cplx_norm(wn_cplx c); EXTERN void wn_cplx_to_polar(double *pr,double *ptheta,wn_cplx c); EXTERN void wn_polar_to_cplx(wn_cplx c,double r,double theta); EXTERN void wn_cplx_make_vect(wn_cplx **pvector,int len_i); EXTERN void wn_cplx_copy_vect(wn_cplx out[],wn_cplx in[],int len_i); EXTERN void wn_cplx_conjugate_vect ( register wn_cplx *vector, int len_i ); #endif
0.878906
1
samples/llvm_primes_1000.c
mattmurante/bpf-graal-truffle
1
7998715
#import "primes_1000.c" #import <stdio.h> int main() { int prime = calc_primes(); printf("%x\n",prime); return 0; }
1.296875
1
GUI/source/cvodesim.c
dchandran/evolvenetworks
1
7998723
#include "cvodesim.h" #include "opt.h" /* * The differential equations function * @param: time * @param: current values of the variables * @param: derviatives array used as the return array * @param: any other data pointer that is needed for the simulation */ static void (*_ODEFUNC)(double, double*, double*, void*) = NULL; /* * relative error tolerance * absolute error tolerance */ double RelTol = 0, AbsTol = 1.0e-5; int ODE_POSITIVE_VALUES_ONLY = 0; /* * set the flags * @param: only positive values */ void ODEflags(int i) { ODE_POSITIVE_VALUES_ONLY = i; } /* * @param: relative error tolerance allowed * @param: absolute error tolerance allowed */ void ODEtolerance(double relerr,double abserr) { RelTol = relerr; AbsTol = abserr; } /**/ typedef struct { void (*ODEfunc)(double, double*, double*, void*); void *userData; EventFunction * eventFunctions; int numEvents; } UserFunction; static void * _PARAMS = NULL; static double * _DU = NULL; static double _FMIN(int n, double * x) { int i=0; double sumsq = 0.0; _ODEFUNC(0.0,x,_DU,_PARAMS); for (i=0; i < n; ++i) { sumsq += _DU[i]*_DU[i]; } return sumsq; } /* f routine. Compute f(t,u). */ static int _FODE(realtype t, N_Vector u, N_Vector udot, void * userFunc) { realtype *udata, *dudata; UserFunction * info; udata = NV_DATA_S(u); dudata = NV_DATA_S(udot); info = (UserFunction*) userFunc; if ((*info).ODEfunc != NULL) ((*info).ODEfunc)(t,udata,dudata,(*info).userData); return (0); } /* Check function return value... opt == 0 means SUNDIALS function allocates memory so check if returned NULL pointer opt == 1 means SUNDIALS function returns a flag so check if flag >= 0 opt == 2 means function allocates memory so check if returned NULL pointer */ static int check_flag(void *flagvalue, char *funcname, int opt) { int *errflag; /* Check if SUNDIALS function returned NULL pointer - no memory allocated */ if (opt == 0 && flagvalue == NULL) { //fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", // funcname); return(1); } /* Check if flag < 0 */ else if (opt == 1) { errflag = (int *) flagvalue; if (*errflag < 0) { //fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", // funcname, *errflag); return(1); }} /* Check if function returned NULL pointer - no memory allocated */ else if (opt == 2 && flagvalue == NULL) { //fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", // funcname); return(1); } return(0); } /*temporaily saves pointers to event functions*/ static EventFunction * EventFunctionPointers = 0; static int NumEventFunctions = 0; static int _EventFunction(realtype t,N_Vector y, realtype *gout, void * g_data) { int i; EventFunction event; realtype *u; UserFunction * info; u = NV_DATA_S(y); info = (UserFunction*) g_data; for (i=0; i < (*info).numEvents; ++i) { event = (*info).eventFunctions[i]; if (event != NULL) { gout[i] = event(t,u,(*info).userData); printf("test event %lf\n",gout[i]); } } return (0); } /* The following is to convert a propensity function and stoichiometry to an ode function*/ static double * StoichiometryMatrix = 0; static int numReactions = 0; static int numVars = 0; static double * rates = 0; static void (*propensityFunction)(double, double*,double*,void*) = NULL; static void odeFunc( double time, double * u, double * du, void * udata ) { int i,j; propensityFunction(time, u, rates, udata); for (i=0; i < numVars; ++i) { du[i] = 0; for (j=0; j < numReactions; ++j) { if (getValue(StoichiometryMatrix,numReactions,i,j) != 0) du[i] += rates[j]*getValue(StoichiometryMatrix,numReactions,i,j); } } } /*End of converting propensity + stoichiometry to ode*/ /* * The Simulate function using Cvode (double precision) * /param number of species (rows of stoichiometry matrix) * /param number of reactions (columns of stoichiometry matrix) * /param stoichiometry matrix as one array, arranged as { row1, row2, row3... }, where each row is for one species * /param pointer to propensity function -- f(time, y-values, rates) --- assign values to the rates array * /param intial values for species * /param start time * /param end time * /param time increments for the simulation * /param user data type for storing other information * /return one dimentional array -- { row1, row2...}, where each row contains {time1,x1,x2,....}. Use getValue(y,n,i,j) if needed */ double * ODEsim2(int m, int n, double * N, void (*f)(double, double*,double*,void*), double *x0, double startTime, double endTime, double dt, void * dataptr) { double * y; StoichiometryMatrix = N; propensityFunction = f; numReactions = n; numVars = m; rates = (double*) malloc(n * sizeof(double)); y = ODEsim(m,x0,&odeFunc,startTime,endTime,dt,dataptr); free(rates); return(y); } /* * Gets jacobian matrix of the system at the given point * /param number of species (rows of stoichiometry matrix) * /param number of reactions (columns of stoichiometry matrix) * /param stoichiometry matrix as one array, arranged as { row1, row2, row3... }, where each row is for one species * /param pointer to propensity function -- f(time, y-values, rates) --- assign values to the rates array * /param: array of values (point where Jacobian will be calculated) * /param: additional parameters needed for ode function * /ret: 2D array made into linear array -- use getValue(array,N,i,j) */ double* jacobian2(int m, int n, double * N, void (*f)(double,double*,double*,void*), double * point, void * params) { double * y; StoichiometryMatrix = N; propensityFunction = f; numReactions = n; numVars = m; rates = (double*) malloc(n * sizeof(double)); y = jacobian(m,point,&odeFunc,params); free(rates); return(y); } /* * Bring a system to steady state * /param number of species (rows of stoichiometry matrix) * /param number of reactions (columns of stoichiometry matrix) * /param stoichiometry matrix as one array, arranged as { row1, row2, row3... }, where each row is for one species * /param pointer to propensity function -- f(time, y-values, rates) --- assign values to the rates array * /param: array of initial values * /param: minimum allowed value * /param: maximum time for simulation * /param: the difference in time to use for estimating steady state * /ret: array of values */ double* steadyState2(int m, int n, double * N, void (*f)(double,double*,double*,void*), double * initialValues, void * params, double minerr, double maxtime, double delta) { double * y; StoichiometryMatrix = N; propensityFunction = f; numReactions = n; numVars = m; rates = (double*) malloc(n * sizeof(double)); y = steadyState(m, initialValues, &odeFunc, params, minerr, maxtime, delta); free(rates); return(y); } /* * Find the rates of change after simulating for the given amount of time * /param number of species (rows of stoichiometry matrix) * /param number of reactions (columns of stoichiometry matrix) * /param stoichiometry matrix as one array, arranged as { row1, row2, row3... }, where each row is for one species * /param pointer to propensity function -- f(time, y-values, rates) --- assign values to the rates array * /param: array of initial values * /param: time for simulation * /ret: array of values */ double* getDerivatives2(int m, int n, double * N, void (*f)(double,double*,double*,void*), double * initValues, double startTime, double endTime, double stepSize, void * params) { double * y; StoichiometryMatrix = N; propensityFunction = f; numReactions = n; numVars = m; rates = (double*) malloc(n * sizeof(double)); y = getDerivatives(m, initValues, &odeFunc, startTime, endTime, stepSize, params); free(rates); return(y); } /* * The Simulate function using Cvode (double precision) * @param: number of variables * @param: array of initial values * @param: ode function pointer * @param: start time for the simulation * @param: ending time for the simulation * @param: time increments for the simulation * @param: user data type for storing other information * @ret: 2D array with time in the first column and values in the rest */ double* ODEsim(int N, double* initialValues, void (*odefnc)(double,double*,double*,void*), double startTime, double endTime, double stepSize, void * params) { double reltol, abstol, t, tout, * data; void * cvode_mem = 0; N_Vector u; int flag, i, j, M; UserFunction * funcData; realtype * udata; t = 0.0; tout = 0.0; reltol = 0.0; abstol = 1.0e-5; if (startTime < 0) startTime = 0; if (endTime < startTime) { return 0; } if ( (2*stepSize) > (endTime-startTime) ) stepSize = (endTime - startTime)/2.0; /*setup tolerance*/ reltol = RelTol; abstol = AbsTol; /*setup ode func*/ _ODEFUNC = odefnc; _PARAMS = params; if (N < 1) { return (0); } /*no variables in the system*/ u = N_VNew_Serial(N); /* Allocate u vector */ if(check_flag((void*)u, "N_VNew_Serial", 0)) { return(0); } /* Initialize u vector */ udata = NV_DATA_S(u); if (initialValues != NULL) for (i=0; i < N; ++i) udata[i] = initialValues[i]; /* allocate output matrix */ M = (int)((endTime - startTime) / stepSize); data = (double*) malloc ((N+1) * (M+1) * sizeof(double) ); /* setup CVODE */ cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON); if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(0); flag = CVodeMalloc(cvode_mem, _FODE, 0, u, CV_SS, reltol, &abstol); if (check_flag(&flag, "CVodeMalloc", 1)) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); if (data) free(data); return(0); } funcData = (UserFunction*) malloc( sizeof(UserFunction) ); (*funcData).ODEfunc = odefnc; (*funcData).userData = params; flag = CVodeSetFdata(cvode_mem, funcData); if(check_flag(&flag, "CVodeSetFdata", 1)) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); if (data) free(data); return(0); } flag = CVBand(cvode_mem, N, 0, N-1); if (check_flag(&flag, "CVBand", 1)) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); if (data) free(data); return(0); } if (NumEventFunctions > 0) { (*funcData).eventFunctions = EventFunctionPointers; (*funcData).numEvents = NumEventFunctions; flag = CVodeRootInit(cvode_mem, NumEventFunctions, _EventFunction, funcData); //setup event functions EventFunctionPointers = 0; NumEventFunctions = 0; } /* setup for simulation */ startTime = 0.0; t = startTime; tout = startTime; i = 0; /*main simulation loop*/ while ((tout <= endTime) && (i <= M)) { /*store data*/ if (data) { getValue(data,N+1,i,0) = t; for (j=0; j < N; ++j) { if (ODE_POSITIVE_VALUES_ONLY && (NV_DATA_S(u))[j] < 0) //special for bio networks { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); if (data) free(data); data = 0; return 0; } else getValue(data,N+1,i,j+1) = (NV_DATA_S(u))[j]; //normal case } } ++i; tout = t + stepSize; flag = CVode(cvode_mem, tout, u, &t, CV_NORMAL); if (check_flag(&flag, "CVode", 1)) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); if (data) free(data); data = 0; return 0; } } CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); return(data); /*return outptus*/ } /* * Gets jacobian matrix of the system at the given point * @param: number of variables * @param: array of values (point where Jacobian will be calculated) * @param: ode function pointer * @param: additional parameters needed for ode function * @ret: 2D array made into linear array -- use getValue(array,N,i,j) */ double* jacobian(int N, double * point, void (*odefnc)(double,double*,double*,void*), void * params) { int i,j; double dx, * dy0, * dy1, * J; if (odefnc == 0 || point == 0) return (0); J = (double*) malloc( N*N*sizeof(double)); dx = 1.0e-5; dy0 = (double*) malloc( N*sizeof(double) ); dy1 = (double*) malloc( N*sizeof(double) ); for (i=0; i < N; ++i) { point[i] -= dx; //x = x0-h odefnc(1.0,point,dy0,params); //dy0 = f(x-h) point[i] += 2*dx; //x = x0+h odefnc(1.0,point,dy1,params); //dy1 = f(x+h) point[i] -= dx; //x = x0 for (j=0; j < N; ++j) { getValue(J,N,j,i) = (dy1[j] - dy0[j])/(dx+dx); // J[j,i] = f(x+h) - f(x-h) / 2h } } free (dy0); free (dy1); return (J); } /* * Bring a system to steady state * @param: number of variables * @param: array of initial values * @param: ode function pointer * @param: maximum allowed value * @ret: array of values */ double* steadyState(int N, double * initialValues, void (*odefnc)(double,double*,double*,void*), void * params, double maxerr, double maxtime, double delta) { int i; double fopt; double * ss = (double*)(malloc(N * sizeof(double))); for (i=0; i < N; ++i) { ss[i] = initialValues[i]; } _ODEFUNC = odefnc; _PARAMS = params; _DU = (double*)(malloc(N * sizeof(double))); if (NelderMeadSimplexMethod(N, _FMIN, ss, 10.00, &fopt, 1000.0, AbsTol) == success) { } else { free(ss); ss = 0; } free(_DU); /*double * J = jacobian(N, ss, odefnc, params); //get jacobian at steady state if (J) { double * wr = 0, * wi = 0; //wr = real component, wi = imaginary component int k = eigenvalues(J,N,&wr,&wi); //get eigenvalues of J in wr and wi free(J); int stablePt = 1; if (k) //if everything is ok (CLAPACK) { for (j=0; j<N; ++j) if (wr[j] >= 0) //this is not a stable point { stablePt = 0; break; } free(wr); free(wi); if (stablePt) { break; //stable point found } } }*/ return ss; } /* { double t0, t, tout, startTime, endTime, stepSize, reltol, abstol, err, temp, * ss; void * cvode_mem; N_Vector u; int flag, i, j; realtype * udata, * u0; UserFunction * funcData; startTime = 0; endTime = maxtime; stepSize = 0.1; reltol = 0.0; abstol = 1.0e-5; t = 0.0; tout = 0.0; cvode_mem = 0; reltol = RelTol; abstol = AbsTol; _ODEFUNC = odefnc; if (N < 1) return (0); u = N_VNew_Serial(N); if(check_flag((void*)u, "N_VNew_Serial", 0)) return(0); ss = (double*) malloc (N * sizeof(double) ); udata = NV_DATA_S(u); u0 = (realtype*) malloc(N*sizeof(realtype)); if (initialValues != NULL) for (i=0; i < N; ++i) udata[i] = u0[i] = initialValues[i]; cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON); if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(0); flag = CVodeMalloc(cvode_mem, _FODE, 0, u, CV_SS, reltol, &abstol); if (check_flag(&flag, "CVodeMalloc", 1)) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); if (ss) free(ss); if (u0) free(u0); return(0); } funcData = malloc( sizeof(UserFunction) ); (*funcData).ODEfunc = odefnc; (*funcData).userData = params; flag = CVodeSetFdata(cvode_mem, funcData); if(check_flag(&flag, "CVodeSetFdata", 1)) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); if (ss) free(ss); if (u0) free(u0); return(0); } flag = CVBand(cvode_mem, N, 0, N-1); if (check_flag(&flag, "CVBand", 1)) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); if (ss) free(ss); if (u0) free(u0); return(0); } if (NumEventFunctions > 0) { (*funcData).eventFunctions = EventFunctionPointers; (*funcData).numEvents = NumEventFunctions; flag = CVodeRootInit(cvode_mem, NumEventFunctions, _EventFunction, funcData); //setup event functions EventFunctionPointers = 0; NumEventFunctions = 0; } t0 = 0.0; startTime = 0.0; t = startTime; tout = startTime; i = 0; err = maxerr + 1; while (tout <= endTime) { tout = t + stepSize; flag = CVode(cvode_mem, tout, u, &t, CV_NORMAL); if (check_flag(&flag, "CVode", 1)) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); if (ss) free(ss); if (u0) free(u0); ss = 0; u0 = 0; return 0; } if (ss && (tout - t0) >= delta) //measure difference between y[t] - y[t-delta] { t0 = tout; err = ( (NV_DATA_S(u))[0] - u0[0] )*( (NV_DATA_S(u))[0] - u0[0] ); for (j=0; j < N; ++j) { temp = ( (NV_DATA_S(u))[j] - u0[j] )*( (NV_DATA_S(u))[j] - u0[j] ); if (temp > err) err = temp; //max value from all dx/dt ss[j] = u0[j] = (NV_DATA_S(u))[j]; //next y points if (ODE_POSITIVE_VALUES_ONLY && (NV_DATA_S(u))[j] < 0) { CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); if (ss) free(ss); if (u0) free(u0); ss = 0; u0 = 0; return 0; } } } if (err <= maxerr) { break; } } if (tout >= endTime) //steady state not reached in the given amount of time { if (ss) free(ss); if (u0) free(u0); ss = 0; u0 = 0; } if (u0) free(u0); CVodeFree(&cvode_mem); N_VDestroy_Serial(u); free(funcData); return(ss); }*/ /* * Find the rates of change after simulating for the given amount of time * @param: number of variables * @param: array of initial values * @param: ode function pointer * @param: time for simulation * @ret: array of values */ double* getDerivatives(int N, double * initialValues, void (*odefnc)(double,double*,double*,void*), double startTime, double endTime, double stepSize, void * params) { double * y, * dy; int i, sz; y = ODEsim(N,initialValues,odefnc,startTime,endTime,stepSize,params); if (y == 0) return 0; sz = (int)((endTime-startTime)/stepSize); dy = (double*) malloc(N * sizeof(double)); for (i=0; i < N; ++i) { dy[i] = ( getValue(y,1+N,sz,1+i) - getValue(y,1+N,sz - 1,1+i) )/ stepSize; } free(y); return(dy); /*return outptus*/ } /*! * \brief set events for the system * \param number of events * \param array with pointers to event functions */ void ODEevents(int numEvents, EventFunction * events) { EventFunctionPointers = events; NumEventFunctions = numEvents; } /* * print a linearized 2D table to a file */ void writeToFile(char* filename, double* data, int rows, int cols) { int i,j; FILE * out; out = fopen(filename,"w"); for (i=0; i < rows; ++i) { fprintf(out, "%lf",getValue(data,cols,i,0)); for (j=1; j < cols; ++j) fprintf(out, "\t%lf",getValue(data,cols,i,j)); fprintf(out, "\n"); } fclose(out); }
1.9375
2
dep/acelite/ace/Unbounded_Set.h
muscnx/Mangos021SD2
42
7998731
// -*- C++ -*- //============================================================================= /** * @file Unbounded_Set.h * * $Id: Unbounded_Set.h 91743 2010-09-13 18:24:51Z johnnyw $ * * @author <NAME> <<EMAIL>> */ //============================================================================= #ifndef ACE_UNBOUNDED_SET_H #define ACE_UNBOUNDED_SET_H #include /**/ "ace/pre.h" #include "ace/Unbounded_Set_Ex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_Allocator; /** * @struct ACE_Unbounded_Set_Default_Comparator * @brief Simple comparator that evaluates equality using == operator. */ template<typename T> struct ACE_Unbounded_Set_Default_Comparator { bool operator() (const T&lhs, const T&rhs) const; }; template<typename T> class ACE_Unbounded_Set; /** * @class ACE_Unbounded_Set_Iterator * @brief Compatibility wrapper for ACE_Unbounded_Set_Ex_Iterator. */ template <typename T> class ACE_Unbounded_Set_Iterator : public ACE_Unbounded_Set_Ex_Iterator<T, ACE_Unbounded_Set_Default_Comparator<T> > { public: typedef ACE_Unbounded_Set_Ex_Iterator<T, ACE_Unbounded_Set_Default_Comparator<T> > base_type; // = Initialization method. ACE_Unbounded_Set_Iterator (ACE_Unbounded_Set<T> &s, bool end = false); ACE_Unbounded_Set_Iterator (const base_type &s); }; /** * @class ACE_Unbounded_Set_Const_Iterator * @brief Compatibility wrapper for ACE_Unbounded_Set_Ex_Const_Iterator. */ template <class T> class ACE_Unbounded_Set_Const_Iterator : public ACE_Unbounded_Set_Ex_Const_Iterator<T, ACE_Unbounded_Set_Default_Comparator<T> > { public: typedef ACE_Unbounded_Set_Ex_Const_Iterator<T, ACE_Unbounded_Set_Default_Comparator<T> > base_type; // = Initialization method. ACE_Unbounded_Set_Const_Iterator (const ACE_Unbounded_Set<T> &s, bool end = false); ACE_Unbounded_Set_Const_Iterator (const base_type &s); }; /** * @class ACE_Unbounded_Set * @brief Compatibility wrapper for ACE_Unbounded_Set_Ex. */ template<typename T> class ACE_Unbounded_Set : public ACE_Unbounded_Set_Ex<T, ACE_Unbounded_Set_Default_Comparator<T> > { public: ACE_Unbounded_Set (ACE_Allocator *alloc = 0); }; ACE_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) #include "ace/Unbounded_Set.inl" #endif /* __ACE_INLINE__ */ #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "ace/Unbounded_Set.cpp" #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("Unbounded_Set.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #include /**/ "ace/post.h" #endif /* ACE_UNBOUNDED_SET_H */
1.65625
2
ds/security/services/smartcrd/tools/sctest/inc/log.h
npocmaka/Windows-Server-2003
17
7998739
/*++ Copyright (C) Microsoft Corporation, 2000 Module Name: Log Abstract: This module implements the logging capabilities of SCTest. Author: <NAME> (ericperl) 06/07/2000 Environment: Win32 Notes: ?Notes? --*/ #ifndef _Log_H_DEF_ #define _Log_H_DEF_ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include <wchar.h> #include <tchar.h> #include <stdio.h> #ifndef _LPCBYTE_DEFINED #define _LPCBYTE_DEFINED typedef const BYTE *LPCBYTE; #endif #define LOGBUFFERSIZE 4096 typedef struct { TCHAR *szLogCrt; // Current pointer in the buffer TCHAR szLogBuffer[LOGBUFFERSIZE]; // Buffering of the log } LOGCONTEXT, *PLOGCONTEXT; void LogInit( IN LPCTSTR szLogName, IN BOOL fVerbose ); void LogClose( ); void LogLock( ); void LogUnlock( ); PLOGCONTEXT LogStart( ); void LogStop( IN PLOGCONTEXT pLogCtx, IN BOOL fExpected = TRUE ); void LogString2FP( IN FILE *fp, IN LPCSTR szMsg ); void LogString2FP( IN FILE *fp, IN LPCWSTR szMsg ); void LogThisOnly( IN LPCSTR szMsg, IN BOOL fExpected = TRUE ); void LogThisOnly( IN LPCWSTR szMsg, IN BOOL fExpected = TRUE ); PLOGCONTEXT LogStart( IN LPCTSTR szFunctionName, IN DWORD dwGLE, IN DWORD dwExpected, IN LPSYSTEMTIME pxStartST, IN LPSYSTEMTIME pxEndST ); PLOGCONTEXT LogVerification( IN LPCTSTR szFunctionName, IN BOOL fSucceeded ); void LogNiceError( IN PLOGCONTEXT pLogCtx, IN DWORD dwRet, IN LPCTSTR szHeader = NULL ); void LogString( IN PLOGCONTEXT pLogCtx, IN LPCSTR szS ); void LogString( IN PLOGCONTEXT pLogCtx, IN LPCWSTR szS ); void LogString( IN PLOGCONTEXT pLogCtx, IN LPCSTR szHeader, IN LPCSTR szS ); void LogString( IN PLOGCONTEXT pLogCtx, IN LPCWSTR szHeader, IN LPCWSTR szS ); void LogMultiString( IN PLOGCONTEXT pLogCtx, IN LPCSTR szMS, IN LPCSTR szHeader = NULL ); void LogMultiString( IN PLOGCONTEXT pLogCtx, IN LPCWSTR szMS, IN LPCWSTR szHeader = NULL ); void LogBinaryData( IN PLOGCONTEXT pLogCtx, IN LPCBYTE rgData, IN DWORD dwSize, IN LPCTSTR szHeader = NULL ); void LogDWORD( IN PLOGCONTEXT pLogCtx, IN DWORD dwDW, IN LPCTSTR szHeader = NULL ); void LogPtr( IN PLOGCONTEXT pLogCtx, IN LPCVOID lpv, IN LPCTSTR szHeader ); void LogDecimal( IN PLOGCONTEXT pLogCtx, IN DWORD dwDW, IN LPCTSTR szHeader = NULL ); void LogResetCounters( ); DWORD LogGetErrorCounter( ); #endif // _Log_H_DEF_
1.125
1
Pod/Classes/Projection/MOBProjectionEPSG4958.h
jkdubr/Proj4
3
7998747
#import "MOBProjection.h" @interface MOBProjectionEPSG4958 : MOBProjection @end
0.013611
0
DlgResizeCanvas.h
GeorgRottensteiner/Painter
0
7998755
#if !defined(AFX_DLGRESIZECANVAS_H__BAE82D28_C9E3_468F_8958_B58EF4F0B00D__INCLUDED_) #define AFX_DLGRESIZECANVAS_H__BAE82D28_C9E3_468F_8958_B58EF4F0B00D__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // DlgResizeCanvas.h : header file // #include "resource.h" class DocumentInfo; class CDlgResizeCanvas : public CDialog { // Construction public: CDlgResizeCanvas(CWnd* pParent = NULL); // standard constructor DocumentInfo* m_pDocInfo; int m_NewWidth, m_NewHeight; bool m_CenterH, m_CenterV; // Dialog Data //{{AFX_DATA(CDlgResizeCanvas) enum { IDD = IDD_DIALOG_RESIZE_CANVAS }; CEdit m_EditNewHeight; CEdit m_EditNewWidth; CEdit m_EditHoehe; CEdit m_EditBreite; CButton m_CheckCenterV; CButton m_CheckCenterH; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDlgResizeCanvas) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CDlgResizeCanvas) virtual BOOL OnInitDialog(); virtual void OnOK(); //}}AFX_MSG DECLARE_MESSAGE_MAP() public: afx_msg void OnEnChangeEditNeueBreite(); }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DLGRESIZECANVAS_H__BAE82D28_C9E3_468F_8958_B58EF4F0B00D__INCLUDED_)
1.0625
1
Fig4.7.c
Rukeith/example-C
0
7998763
int main (void) { int grade; int aCount = 0; int bCount = 0; int cCount = 0; int dCount = 0; int fCount = 0; printf( "Enter the letter grades.\n"); printf( "Enter the EOF character to end input.\n"); while ((grade = getchar()) != EOF){ switch (grade){ case 'A': case 'a': ++aCount; break; case 'B': case 'b': ++bCount; break; case 'C': case 'c': ++cCount; break; case 'D': case 'd': ++dCount; break; case 'F': case 'f': ++fCount; break; case '\n': case '\t': case ' ': break; default: printf( "Incorrect letter grade entered." ); printf( " Enter a new grade.\n" ); break; } }
2.28125
2
GLEX_globals.h
sschuberth/glex2
0
7998771
#ifndef GLEX_GLOBALS_H #define GLEX_GLOBALS_H // Missing from GL_EXT_texture3D: #ifndef GL_TEXTURE_BINDING_3D_EXT #define GL_TEXTURE_BINDING_3D_EXT 0x806A #endif // Introduced by GL_ARB_shader_objects: typedef char GLcharARB; typedef unsigned int GLhandleARB; // Introduced by GL_ARB_vertex_buffer_object: typedef ptrdiff_t GLintptrARB; typedef ptrdiff_t GLsizeiptrARB; // Introduced by VERSION_2_0: typedef char GLchar; #endif // GLEX_GLOBALS_H
0.429688
0
AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/AlipayARUPOrigin.h
ceekay1991/AliPayForDebug
5
7998779
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by <NAME>. // #import <objc/NSObject.h> @class NSString; @interface AlipayARUPOrigin : NSObject { NSString *_uploadID; NSString *_scheme; NSString *_ip; NSString *_hostName; NSString *_port; NSString *_biztype; NSString *_token; unsigned long long _encyptType; } @property(nonatomic) unsigned long long encyptType; // @synthesize encyptType=_encyptType; @property(retain, nonatomic) NSString *token; // @synthesize token=_token; @property(retain, nonatomic) NSString *biztype; // @synthesize biztype=_biztype; @property(readonly, nonatomic) NSString *port; // @synthesize port=_port; @property(readonly, nonatomic) NSString *hostName; // @synthesize hostName=_hostName; @property(readonly, nonatomic) NSString *ip; // @synthesize ip=_ip; @property(readonly, nonatomic) NSString *scheme; // @synthesize scheme=_scheme; - (void).cxx_destruct; - (id)getUploadID; - (id)initWithScheme:(id)arg1 hostName:(id)arg2 ip:(id)arg3 port:(id)arg4 token:(id)arg5 encyptType:(unsigned long long)arg6 error:(id *)arg7; @end
0.925781
1
tests/c-tests/basic_lexicon.c
ilovejs/traildb_rep
1,118
7998787
#include <stdlib.h> #include <assert.h> #include <string.h> #include <traildb.h> #include "tdb_test.h" static uint8_t uuid[16]; int main(int argc, char** argv) { /* note that the order of values1, values2, values3 makes a difference here: We want to insert a longer string first (len(blue) > len(red)) since the small case of judy_str_map reorders these strings (red comes before blue). We want to test that this case is handled correctly. */ const char *fields[] = {"a", "b"}; const char *values1[] = {"blue", "blue1"}; const uint64_t lengths1[] = {4, 5}; const char *values2[] = {"red", "red1"}; const uint64_t lengths2[] = {3, 4}; const char *values3[] = {"0123456789", "red1"}; const uint64_t lengths3[] = {10, 4}; const char *p; uint64_t len; tdb_cons* c = tdb_cons_init(); test_cons_settings(c); assert(tdb_cons_open(c, getenv("TDB_TMP_DIR"), fields, 2) == 0); tdb_cons_add(c, uuid, 0, values1, lengths1); tdb_cons_add(c, uuid, 0, values2, lengths2); tdb_cons_add(c, uuid, 0, values3, lengths3); assert(tdb_cons_finalize(c) == 0); tdb_cons_close(c); tdb *t = tdb_init(); assert(tdb_open(t, getenv("TDB_TMP_DIR")) == 0); assert(tdb_lexicon_size(t, 0) == 0); assert(tdb_lexicon_size(t, 1) == 4); assert(tdb_lexicon_size(t, 2) == 3); p = tdb_get_value(t, 1, 0, &len); assert(len == 0); assert(memcmp(p, "", len) == 0); p = tdb_get_value(t, 1, 1, &len); assert(len == 4); assert(memcmp(p, "blue", len) == 0); p = tdb_get_value(t, 1, 2, &len); assert(len == 3); assert(memcmp(p, "red", len) == 0); p = tdb_get_value(t, 1, 3, &len); assert(len == 10); assert(memcmp(p, "0123456789", len) == 0); p = tdb_get_value(t, 2, 0, &len); assert(len == 0); assert(memcmp(p, "", len) == 0); p = tdb_get_value(t, 2, 1, &len); assert(len == 5); assert(memcmp(p, "blue1", len) == 0); p = tdb_get_value(t, 2, 2, &len); assert(len == 4); assert(memcmp(p, "red1", len) == 0); return 0; }
1.78125
2
EpicForceTools/commonlib/BSplineBasis.h
MacgyverLin/MagnumEngine
1
7998795
/////////////////////////////////////////////////////////////////// // Copyright(c) 2011-, EpicForce Entertainment Limited // // Author : <NAME> // Module : EpicForceEngine // Date : 19/Aug/2011 // /////////////////////////////////////////////////////////////////// #ifndef _BSplineBasis_h_ #define _BSplineBasis_h_ #include "Stage.h" #include "EMath.h" #include "InputStream.h" #include "OutputStream.h" #include "EMath.h" namespace EpicForce { class BSplineBasis { public: BSplineBasis (); // Open uniform or periodic uniform. The knot array is internally // generated with equally spaced elements. BSplineBasis (int iNumCtrlPoints, int iDegree, bool bOpen); void Create (int iNumCtrlPoints, int iDegree, bool bOpen); // Open nonuniform. The knot array must have n-d elements. The elements // must be nondecreasing. Each element must be in [0,1]. The caller is // responsible for deleting afKnot. An internal copy is made, so to // dynamically change knots you must use the SetKnot function. BSplineBasis (int iNumCtrlPoints, int iDegree, const float* afKnot); void Create (int iNumCtrlPoints, int iDegree, const float* afKnot); virtual ~BSplineBasis (); int GetNumCtrlPoints () const; int GetDegree () const; bool IsOpen () const; bool IsUniform () const; // The knot values can be changed only if the basis function is nonuniform // and the input index is valid (0 <= i <= n-d-1). If these conditions // are not satisfied, GetKnot returns MAX_REAL. void SetKnot (int i, float fKnot); float GetKnot (int i) const; // access basis functions and their derivatives float GetD0 (int i) const; float GetD1 (int i) const; float GetD2 (int i) const; float GetD3 (int i) const; // evaluate basis functions and their derivatives void Compute (float fTime, unsigned int uiOrder, int& riMinIndex, int& riMaxIndex) const; protected: int Initialize (int iNumCtrlPoints, int iDegree, bool bOpen); float** Allocate () const; void Deallocate (float** aafArray); // Determine knot index i for which knot[i] <= rfTime < knot[i+1]. int GetKey (float& rfTime) const; int m_iNumCtrlPoints; // n+1 int m_iDegree; // d float* m_afKnot; // knot[n+d+2] bool m_bOpen, m_bUniform; // Storage for the basis functions and their derivatives first three // derivatives. The basis array is always allocated by the constructor // calls. A derivative basis array is allocated on the first call to a // derivative member function. float** m_aafBD0; // bd0[d+1][n+d+1] mutable float** m_aafBD1; // bd1[d+1][n+d+1] mutable float** m_aafBD2; // bd2[d+1][n+d+1] mutable float** m_aafBD3; // bd3[d+1][n+d+1] }; } #endif
1.585938
2
Archived/v1/WCDistractionFreeXcodePlugin/Headers/PlugIns/IDEiPhoneSupport/DVTDevicesWindowDetailViewController-Protocol.h
wokalski/Distraction-Free-Xcode-plugin
25
7998803
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by <NAME>. // #import "DVTInvalidation.h" @class DVTDevice; @protocol DVTDevicesWindowDetailViewController <DVTInvalidation> @property(retain) DVTDevice *device; @optional - (void)detailViewDidDisappear; - (void)detailViewDidAppear; @end
0.214844
0
bethe-xxz/recursive.h
robhagemans/bethe-solver
0
7998811
#ifndef RECURSIVE_H #define RECURSIVE_H #include "generic.h" #include "quantity.h" #include "scan.h" extern const char* exc_IndexTooHigh; extern const char* exc_NegativeIndex; extern const char* exc_NegativeInterval; extern const char* exc_IntervalOverlap; /** scan interval structure **/ class Interval { public: long long int start; long long int stop; long long int number_calculated; long long int number_accepted; // interval's total, not average, contribution (i.e. sum divided by max_sum); REAL contribution; Interval& operator+= (const Interval& plus); Interval& operator-= (const Interval& minus); Interval operator- (const Interval& minus) const; }; extern const Interval NO_INTERVAL; // outputting an Interval ostream& operator<< (ostream& stream, const Interval& interval); // inputting an Interval istream& operator>> (istream& stream, Interval& interval) ; class BaseRecord { public: BaseData base_data; Interval summary; vector<Interval> intervals; }; /** sort intervals according to begin value **/ inline bool intervalLessThan (const Interval& a, const Interval& b) { return (a.start < b.start); } /** class scanintervals **/ class ScanIntervals { public: vector< BaseRecord > records; public: ScanIntervals() : records() {}; ~ScanIntervals(void) { clear(); }; inline void clear(void) { // for (int i=0; i<records.size();++i) delete records[i].p_base; records.clear(); }; void insert (const BaseData& base_data, Interval new_interval); void merge (const ScanIntervals& with_intervals); void consolidate (void); bool includes (const BaseData& base_data, const Interval& new_interval) const; bool includes (const BaseData& base_data, const long long int id) const; Interval summary(const BaseData& base_data, const long long int id_start=NO_ID, const long long int id_stop=NO_ID) const; REAL averageContribution(const BaseData& base_data, const long long int id_start=NO_ID, const long long int id_stop=NO_ID) const; inline long long int highestId (const BaseData& base_data, const long long int id_start=NO_ID, const long long int id_stop=NO_ID) const { long long int last = summary (base_data, id_start, id_stop).stop; if (NO_ID==last) return NO_ID; else return last-1; }; inline REAL contribution(const BaseData& base_data, const long long int id_start=NO_ID, const long long int id_stop=NO_ID) const { return summary (base_data, id_start, id_stop).contribution; }; inline long long int numberCalculated (const BaseData& base_data, const long long int id_start=NO_ID, const long long int id_stop=NO_ID) const { return summary (base_data, id_start, id_stop).number_calculated; }; inline long long int numberAccepted (const BaseData& base_data, const long long int id_start=NO_ID, const long long int id_stop=NO_ID) const { return summary (base_data, id_start, id_stop).number_accepted; }; Interval summary(void) const; REAL contribution (void) const; long long int numberCalculated (void) const; long long int numberAccepted (void) const; inline REAL averageContribution(void) const { return contribution()/(1.0*numberCalculated()); }; // outputting a ScanIntervals ostream& write (ostream& stream) const; void write (const string file_name) const; // inputting a ScanIntervals (merge with existing) istream& read (istream& stream); void read (const string file_name); protected: BaseRecord* recordForBase (const BaseData& base_data); const BaseRecord* recordForBase (const BaseData& base_data) const; BaseRecord* addBase (const BaseData& base_data); }; /** sort bases **/ class BaseComparator { public: ScanIntervals* intervals; BaseComparator (ScanIntervals* p_intervals) : intervals(p_intervals) {}; inline int operator() (const BaseData& a, const BaseData& b) const { return a.numberFreedoms() < b.numberFreedoms(); }; }; void sortBases (vector<BaseData>& a, const int leftmost, const int rightmost, const BaseComparator& less_than); /** class Engine **/ class Engine { public: ScanIntervals last_scan; ScanIntervals all_scan; AddFunc& record; Quantity& quantity; const REAL deviation_threshold; Stopwatch calculation_time; Stopwatch total_time; // running variables int countdown; Base* p_base; State* p_state_start; // MAX_INT seconds is about 1600 years, so this should suffice int max_seconds; public: // create engine Engine (AddFunc& the_record, Quantity& the_quantity, const REAL the_deviation_threshold); // destructor. ~Engine(void) {}; // scan recursively over a set of bases bool scan (vector<BaseData>& p_bases, const REAL contribution_threshold, const REAL threshold_factor); protected: // resursive part of scan algorithm void scanRecursive (const REAL contribution_threshold, int current_sector = NOT_SET, int current_particle = NOT_SET); // terminates recursion void scanInnermostHole (State* const p_state, const int start_hole, const int stop_hole); // scan a single state void scanState(State* const p_state, Interval& scan_result); }; #endif
2.109375
2
FindSecret/Classes/Native/mscorlib_System_Collections_Generic_KeyValuePair_2_561304395.h
GodIsWord/NewFindSecret
0
7998819
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "mscorlib_System_ValueType3640485471.h" // UnityEngine.AnimationClip struct AnimationClip_t2318505987; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Collections.Generic.KeyValuePair`2<UnityEngine.AnimationClip,UnityEngine.AnimationClip> struct KeyValuePair_2_t561304395 { public: // TKey System.Collections.Generic.KeyValuePair`2::key AnimationClip_t2318505987 * ___key_0; // TValue System.Collections.Generic.KeyValuePair`2::value AnimationClip_t2318505987 * ___value_1; public: inline static int32_t get_offset_of_key_0() { return static_cast<int32_t>(offsetof(KeyValuePair_2_t561304395, ___key_0)); } inline AnimationClip_t2318505987 * get_key_0() const { return ___key_0; } inline AnimationClip_t2318505987 ** get_address_of_key_0() { return &___key_0; } inline void set_key_0(AnimationClip_t2318505987 * value) { ___key_0 = value; Il2CppCodeGenWriteBarrier(&___key_0, value); } inline static int32_t get_offset_of_value_1() { return static_cast<int32_t>(offsetof(KeyValuePair_2_t561304395, ___value_1)); } inline AnimationClip_t2318505987 * get_value_1() const { return ___value_1; } inline AnimationClip_t2318505987 ** get_address_of_value_1() { return &___value_1; } inline void set_value_1(AnimationClip_t2318505987 * value) { ___value_1 = value; Il2CppCodeGenWriteBarrier(&___value_1, value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
1.085938
1
substitutionC.h
JAlvarezJarreta/ortheus
3
7998827
/* * Copyright (C) 2008-2011 by <NAME> (<EMAIL>) * * Released under the MIT license, see LICENSE.txt */ #ifndef SUBSTITUTIONC_H_ #define SUBSTITUTIONC_H_ #include <math.h> #include "fastCMaths.h" #include "commonC.h" //subtitution stuff #define GAP 1000 //just dna right now struct SubModel { float *forward; float *backward; float *stationaryDistribution; int64_t alphabetSize; }; struct SubModel *constructSubModel(float *forward, float *backward, float *stationaryDistribution, int64_t alphabetSize); void destructSubModel(struct SubModel *subModel); ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //library functions for dealing with wV ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// void copyWV(float *wVX, float *wVY, int64_t alphabetSize); void transformWVByDistance(float *wV, float *subMatrix, float *result, int64_t alphabetSize); void multiplyWV(float *wVX, float *wVY, float *result, int64_t alphabetSize); void normaliseWV_GiveFac(float *wV, float *result, float normFac, int64_t alphabetSize); void normaliseWV(float *wV, float *result, int64_t alphabetSize); float combineWV(float *wVX, float *wVY, int64_t alphabetSize); float sumWV(float *wV, int64_t alphabetSize); void addWV(float *wVX, float *wVY, float *result, int64_t alphabetSize); float * dNAMap_IUPACToWVFn(char i); int64_t subMatCo(int64_t i, int64_t j, int64_t alphabetSize); ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //substitution matrix functions ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// float *hKY(float distance, float freqA, float freqC, float freqG, float freqT, float transitionTransversionRatio); struct SubModel *constructHKYSubModel(float distance, float freqA, float freqC, float freqG, float freqT, float transitionTransversionRatio); float *jukesCantor(float d); struct SubModel *constructJukesCantorSubModel(float distance); float *reverseSubMatrixInPlace(float *wV, int64_t alphabetSize); ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //misc functions ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// float jukesCantorCorrection(float distance); void kimuraCorrection(float transitionsPerSite, float transversionsPerSite, float *correctedTransitionsPerSite, float *correctedTransversionsPerSite); #endif /*SUBSTITUTIONC_H_*/
1.671875
2
mpeg/psi/desc_02.h
larixsoft/bitstream
48
7998835
/***************************************************************************** * desc_02.h: ISO/IEC 13818-1 Descriptor 0x02 (Video stream descriptor) ***************************************************************************** * Copyright (C) 2011 Unix Solutions Ltd. * * Authors: <NAME> <<EMAIL>> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *****************************************************************************/ /* * Normative references: * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) */ #ifndef __BITSTREAM_MPEG_DESC_02_H__ #define __BITSTREAM_MPEG_DESC_02_H__ #include <bitstream/common.h> #include <bitstream/mpeg/psi/descriptors.h> #ifdef __cplusplus extern "C" { #endif /***************************************************************************** * Descriptor 0x02: Video stream descriptor *****************************************************************************/ #define DESC02_HEADER_SIZE (DESC_HEADER_SIZE + 1) static inline void desc02_init(uint8_t *p_desc) { desc_set_tag(p_desc, 0x02); desc_set_length(p_desc, DESC02_HEADER_SIZE - DESC_HEADER_SIZE); } static inline bool desc02_get_multiple_frame_rate(const uint8_t *p_desc) { return (p_desc[2] & 0x80) == 0x80; } static inline void desc02_set_multiple_frame_rate(uint8_t *p_desc, bool b_multiple_frame_rate) { p_desc[2] = b_multiple_frame_rate ? (p_desc[2] | 0x80) : (p_desc[2] &~ 0x80); } static inline uint8_t desc02_get_frame_rate_code(const uint8_t *p_desc) { return (p_desc[2] & 0x78) >> 3; /* 1xxxx111 */ } static inline void desc02_set_frame_rate_code(uint8_t *p_desc, uint8_t i_frame_rate_code) { p_desc[2] = (p_desc[2] & 0x87) | (i_frame_rate_code & 0x0f) << 3; } static inline const char *desc02_get_frame_rate_txt(const uint8_t frame_rate_code) { return frame_rate_code == 0 ? "forbidden" : frame_rate_code == 1 ? "23.976" : frame_rate_code == 2 ? "24.00" : frame_rate_code == 3 ? "25.00" : frame_rate_code == 4 ? "29.97" : frame_rate_code == 5 ? "30.00" : frame_rate_code == 6 ? "50.00" : frame_rate_code == 7 ? "59.94" : frame_rate_code == 8 ? "60.00" : "reserved"; } static inline bool desc02_get_mpeg1_only_flag(const uint8_t *p_desc) { return (p_desc[2] & 0x04) == 0x04; } static inline void desc02_set_mpeg1_only_flag(uint8_t *p_desc, bool b_mpeg1_only_flag) { p_desc[2] = b_mpeg1_only_flag ? (p_desc[2] | 0x04) : (p_desc[2] &~ 0x04); if (b_mpeg1_only_flag) desc_set_length(p_desc, DESC02_HEADER_SIZE - DESC_HEADER_SIZE); else desc_set_length(p_desc, (DESC02_HEADER_SIZE + 2) - DESC_HEADER_SIZE); } static inline bool desc02_get_constraint_parameter(const uint8_t *p_desc) { return (p_desc[2] & 0x02) == 0x02; } static inline void desc02_set_constraint_parameter(uint8_t *p_desc, bool b_constraint_parameter) { p_desc[2] = b_constraint_parameter ? (p_desc[2] | 0x02) : (p_desc[2] &~ 0x02); } static inline bool desc02_get_still_picture(const uint8_t *p_desc) { return (p_desc[2] & 0x01) == 0x01; } static inline void desc02_set_still_picture(uint8_t *p_desc, bool b_still_picture) { p_desc[2] = b_still_picture ? (p_desc[2] | 0x01) : (p_desc[2] &~ 0x01); } static inline uint8_t desc02_get_profile(const uint8_t *p_desc) { return p_desc[3] >> 4; } static inline void desc02_set_profile(uint8_t *p_desc, uint8_t i_profile) { p_desc[3] = ((i_profile & 0x0f) << 4) | (p_desc[3] & 0x0f); } static inline const char *desc02_get_profile_txt(const uint8_t profile) { return profile == 1 ? "High" : profile == 2 ? "Spatially Scalable" : profile == 3 ? "SNR Scalable" : profile == 4 ? "Main" : profile == 5 ? "Simple" : "Reserved"; } static inline uint8_t desc02_get_level(const uint8_t *p_desc) { return p_desc[3] & 0x0f; } static inline void desc02_set_level(uint8_t *p_desc, uint8_t i_level) { p_desc[3] = (p_desc[3] & 0xf0) | (i_level & 0x0f); } static inline const char *desc02_get_level_txt(const uint8_t level) { return level == 4 ? "High" : level == 6 ? "High 1440" : level == 8 ? "Main" : level == 10 ? "Low" : "Reserved"; } static inline uint8_t desc02_get_chroma_format(const uint8_t *p_desc) { return p_desc[4] >> 6; } static inline void desc02_set_chroma_format(uint8_t *p_desc, uint8_t i_chroma_format) { p_desc[4] = (i_chroma_format << 6) | (p_desc[4] & 0x20) | 0x1f; } static inline const char *desc02_get_chroma_format_txt(const uint8_t chroma_format) { return chroma_format == 0 ? "reserved" : chroma_format == 1 ? "4:2:0" : chroma_format == 2 ? "4:2:2" : chroma_format == 3 ? "4:4:4" : "unknown"; } static inline bool desc02_get_frame_rate_extension(const uint8_t *p_desc) { return (p_desc[4] & 0x20) == 0x20; } static inline void desc02_set_frame_rate_extension(uint8_t *p_desc, bool b_frame_rate_extension) { p_desc[4] = (b_frame_rate_extension ? (p_desc[4] | 0x20) : (p_desc[4] &~ 0x20)) | 0x1f; } static inline bool desc02_validate(const uint8_t *p_desc) { if (desc02_get_mpeg1_only_flag(p_desc)) return desc_get_length(p_desc) >= DESC02_HEADER_SIZE - DESC_HEADER_SIZE; else return desc_get_length(p_desc) >= (DESC02_HEADER_SIZE + 2) - DESC_HEADER_SIZE; } static inline void desc02_print(const uint8_t *p_desc, f_print pf_print, void *opaque, print_type_t i_print_type) { switch (i_print_type) { case PRINT_XML: if (desc02_get_mpeg1_only_flag(p_desc)) { pf_print(opaque, "<VIDEO_STREAM_DESC multiple_frame_rate=\"%u\" frame_rate_code=\"%u\" frame_rate_txt=\"%s\"" " mpeg1_only=\"%u\" constraint_parameter=\"%u\" still_picture=\"%u\"/>", desc02_get_multiple_frame_rate(p_desc), desc02_get_frame_rate_code(p_desc), desc02_get_frame_rate_txt(desc02_get_frame_rate_code(p_desc)), desc02_get_mpeg1_only_flag(p_desc), desc02_get_constraint_parameter(p_desc), desc02_get_still_picture(p_desc) ); } else { pf_print(opaque, "<VIDEO_STREAM_DESC multiple_frame_rate=\"%u\" frame_rate_code=\"%u\" frame_rate_txt=\"%s\"" " mpeg1_only=\"%u\" constraint_parameter=\"%u\" still_picture=\"%u\"" " profile=\"%u\" profile_txt=\"%s\" level=\"%u\" level_txt=\"%s\"" " chroma_format=\"%u\" chroma_format_txt=\"%s\"" " frame_rate_extension=\"%u\"/>", desc02_get_multiple_frame_rate(p_desc), desc02_get_frame_rate_code(p_desc), desc02_get_frame_rate_txt(desc02_get_frame_rate_code(p_desc)), desc02_get_mpeg1_only_flag(p_desc), desc02_get_constraint_parameter(p_desc), desc02_get_still_picture(p_desc), desc02_get_profile(p_desc), desc02_get_profile_txt(desc02_get_profile(p_desc)), desc02_get_level(p_desc), desc02_get_level_txt(desc02_get_level(p_desc)), desc02_get_chroma_format(p_desc), desc02_get_chroma_format_txt(desc02_get_chroma_format(p_desc)), desc02_get_frame_rate_extension(p_desc) ); } break; default: if (desc02_get_mpeg1_only_flag(p_desc)) { pf_print(opaque, " - desc 02 video_stream multiple_frame_rate=%u frame_rate_code=%u frame_rate_txt=\"%s\"" " mpeg1_only=%u constraint_parameter=%u still_picture=%u", desc02_get_multiple_frame_rate(p_desc), desc02_get_frame_rate_code(p_desc), desc02_get_frame_rate_txt(desc02_get_frame_rate_code(p_desc)), desc02_get_mpeg1_only_flag(p_desc), desc02_get_constraint_parameter(p_desc), desc02_get_still_picture(p_desc) ); } else { pf_print(opaque, " - desc 02 video_stream multiple_frame_rate=%u frame_rate_code=%u frame_rate_txt=\"%s\"" " mpeg1_only=%u constraint_parameter=%u still_picture=%u" " profile=%u profile_txt=\"%s\" level=%u level_txt=\"%s\"" " chroma_format=%u chroma_format_txt=\"%s\"" " frame_rate_extension=%u", desc02_get_multiple_frame_rate(p_desc), desc02_get_frame_rate_code(p_desc), desc02_get_frame_rate_txt(desc02_get_frame_rate_code(p_desc)), desc02_get_mpeg1_only_flag(p_desc), desc02_get_constraint_parameter(p_desc), desc02_get_still_picture(p_desc), desc02_get_profile(p_desc), desc02_get_profile_txt(desc02_get_profile(p_desc)), desc02_get_level(p_desc), desc02_get_level_txt(desc02_get_level(p_desc)), desc02_get_chroma_format(p_desc), desc02_get_chroma_format_txt(desc02_get_chroma_format(p_desc)), desc02_get_frame_rate_extension(p_desc) ); } } } #ifdef __cplusplus } #endif #endif
0.875
1
include/llvm/Target/TargetAsmParser.h
weimingtom/llvm-lua_vc9
0
7998843
//===-- llvm/Target/TargetAsmParser.h - Target Assembly Parser --*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_TARGET_TARGETPARSER_H #define LLVM_TARGET_TARGETPARSER_H namespace llvm { class MCInst; class StringRef; class Target; class SMLoc; class AsmToken; class MCParsedAsmOperand; template <typename T> class SmallVectorImpl; /// TargetAsmParser - Generic interface to target specific assembly parsers. class TargetAsmParser { TargetAsmParser(const TargetAsmParser &); // DO NOT IMPLEMENT void operator=(const TargetAsmParser &); // DO NOT IMPLEMENT protected: // Can only create subclasses. TargetAsmParser(const Target &); /// TheTarget - The Target that this machine was created for. const Target &TheTarget; public: virtual ~TargetAsmParser(); const Target &getTarget() const { return TheTarget; } /// ParseInstruction - Parse one assembly instruction. /// /// The parser is positioned following the instruction name. The target /// specific instruction parser should parse the entire instruction and /// construct the appropriate MCInst, or emit an error. On success, the entire /// line should be parsed up to and including the end-of-statement token. On /// failure, the parser is not required to read to the end of the line. // /// \param Name - The instruction name. /// \param NameLoc - The source location of the name. /// \param Operands [out] - The list of parsed operands, this returns /// ownership of them to the caller. /// \return True on failure. virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, SmallVectorImpl<MCParsedAsmOperand*> &Operands) = 0; /// ParseDirective - Parse a target specific assembler directive /// /// The parser is positioned following the directive name. The target /// specific directive parser should parse the entire directive doing or /// recording any target specific work, or return true and do nothing if the /// directive is not target specific. If the directive is specific for /// the target, the entire line is parsed up to and including the /// end-of-statement token and false is returned. /// /// \param DirectiveID - the identifier token of the directive. virtual bool ParseDirective(AsmToken DirectiveID) = 0; /// MatchInstruction - Recognize a series of operands of a parsed instruction /// as an actual MCInst. This returns false and fills in Inst on success and /// returns true on failure to match. virtual bool MatchInstruction(const SmallVectorImpl<MCParsedAsmOperand*> &Operands, MCInst &Inst) = 0; }; } // End llvm namespace #endif
1.507813
2
rtos/mbed-os/targets/TARGET_GWT/TARGET_GAP9/driver/gap_bench.h
VishalSharma0309/gap_sdk
1
7998851
/* * Copyright (c) 2018, GreenWaves Technologies, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, this list * of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * o Neither the name of GreenWaves Technologies, Inc. nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _GAP_BENCH_H_ #define _GAP_BENCH_H_ #include "gap_common.h" #include "gap_cluster.h" #include "gap_dmamchan.h" #include <stdlib.h> typedef struct _testresult_t { int time; int errors; } testresult_t; typedef struct _testcase_t { char *name; void (*test)(testresult_t* result, void (*start)(), void (*stop)()); } testcase_t; // Flag for disabling the printf output uint32_t enable_printf = 1; static uint32_t run_suite_error = 1; void bench_disable_printf(void) { enable_printf = 0; } void bench_timer_start(void) { } void bench_timer_stop(void) { } void bench_timer_reset(void) { } void print_result(testcase_t *test, testresult_t *result) { printf("== test: %s -> ", test->name); if (result->errors == 0) printf("success, "); else printf("fail, "); printf("nr. of errors: %d", result->errors); if(result->time == 0) printf("\n"); else printf(", execution time: %d\n", result->time); } void print_summary(unsigned int errors) { if(enable_printf) { printf("==== SUMMARY: "); if (errors == 0) { printf("SUCCESS\n"); } else { printf("FAIL\n"); } } } void run_benchmark(testcase_t *test, testresult_t *result) { result->errors = 0; bench_timer_reset(); test->test(result, bench_timer_start, bench_timer_stop); result->time = 0; } int run_suite(testcase_t *tests) { // figure out how many tests should be run int num = 0; while(tests[num].name != 0) num++; run_suite_error = 0; int i; // perform the tests for (i = 0; i < num; i++) { testresult_t result; run_benchmark(&tests[i], &result); if(enable_printf) print_result(&tests[i], &result); run_suite_error += result.errors; } print_summary(run_suite_error); return run_suite_error; } void check_uint32(testresult_t* result, const char* fail_msg, uint32_t actual, uint32_t expected) { if(actual != expected) { result->errors += 1; if(enable_printf) printf("%s: Actual %X, expected %X\n", fail_msg, (unsigned int) actual, (unsigned int)expected); } } void test_suite_entry(void *arg) { CLUSTER_CoresFork((void *)run_suite, arg); } void bench_cluster_forward(testcase_t *testcases) { /* Cluster Start - Power on, 9th core seperation disable */ CLUSTER_Start(0, CLUSTER_CORES_NUM, 0); /* FC send a task to Cluster */ CLUSTER_SendTask(0, test_suite_entry, (void*)testcases, 0); /* Cluster Stop - Power down */ CLUSTER_Stop(0); } #endif /*_GAP_BENCH_H_*/
1.125
1
macOS/10.13/AVFoundation.framework/AVAVVideoSettingsVideoOutputSettings.h
onmyway133/Runtime-Headers
30
7998859
/* Generated by RuntimeBrowser Image: /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation */ @interface AVAVVideoSettingsVideoOutputSettings : AVVideoOutputSettings <AVReencodedVideoSettingsForFig> { NSDictionary * _VTCleanApertureDictionary; NSDictionary * _VTPixelAspectRatioDictionary; NSDictionary * _adaptedVideoCompressionProperties; } @property (nonatomic, readonly) unsigned int videoCodecType; @property (nonatomic, readonly) NSDictionary *videoCompressionProperties; @property (nonatomic, readonly) NSDictionary *videoEncoderSpecification; + (BOOL)_validateVideoCompressionProperties:(id)arg1 againstSupportedPropertyDictionary:(id)arg2 forCodecType:(id)arg3 exceptionReason:(id*)arg4; + (id)_videoOutputSettingsWithVideoSettingsDictionary:(id)arg1 exceptionReason:(id*)arg2; + (id)eligibleOutputSettingsDictionaryKeys; - (BOOL)canFullySpecifyOutputFormatReturningReason:(id*)arg1; - (id)cleanApertureDictionary; - (void)dealloc; - (BOOL)encoderIsAvailableOnCurrentSystemReturningError:(id*)arg1; - (int)height; - (id)initWithAVVideoSettingsDictionary:(id)arg1 exceptionReason:(id*)arg2; - (id)initWithTrustedAVVideoSettingsDictionary:(id)arg1; - (id)pixelAspectRatioDictionary; - (unsigned int)videoCodecType; - (id)videoCompressionProperties; - (id)videoEncoderSpecification; - (int)width; - (BOOL)willYieldCompressedSamples; @end
0.875
1
kernel/list.h
mido3ds/soso
1
7998867
#ifndef LIST_H #define LIST_H #include "common.h" #define List_Foreach(listNode, list) for (ListNode* listNode = list->head; NULL != listNode ; listNode = listNode->next) typedef struct ListNode { struct ListNode* previous; struct ListNode* next; void* data; } ListNode; typedef struct List { struct ListNode* head; struct ListNode* tail; } List; List* List_Create(); void List_Clear(List* list); void List_Destroy(List* list); List* List_CreateClone(List* list); BOOL List_IsEmpty(List* list); void List_Append(List* list, void* data); void List_Prepend(List* list, void* data); ListNode* List_GetFirstNode(List* list); ListNode* List_GetLastNode(List* list); ListNode* List_FindFirstOccurrence(List* list, void* data); int List_FindFirstOccurrenceIndex(List* list, void* data); int List_GetCount(List* list); void List_RemoveNode(List* list, ListNode* node); void List_RemoveFirstNode(List* list); void List_RemoveLastNode(List* list); void List_RemoveFirstOccurrence(List* list, void* data); typedef struct Stack { List* list; } Stack; Stack* Stack_Create(); void Stack_Clear(Stack* stack); void Stack_Destroy(Stack* stack); BOOL Stack_IsEmpty(Stack* stack); void Stack_Push(Stack* stack, void* data); void* Stack_Pop(Stack* stack); typedef struct Queue { List* list; } Queue; Queue* Queue_Create(); void Queue_Clear(Queue* queue); void Queue_Destroy(Queue* queue); BOOL Queue_IsEmpty(Queue* queue); void Queue_Enqueue(Queue* queue, void* data); void* Queue_Dequeue(Queue* stack); #endif // LIST_H
1.960938
2
Project4/functions_util.h
AndrewSpano/University_OS_Projects
3
7998875
#ifndef __FUNCTIONS_UTIL__ #define __FUNCTIONS_UTIL__ #include "structs.h" #include "list.h" void insert_pair_into_block(Block* block, char* insert_name, off_t insert_offset, size_t fns); int insert_pair(int fd, hole_map* holes, MDS* mds, char* insert_name, off_t insert_offset, size_t block_size, size_t fns); int shift_pairs_to_the_left(char* name, uint remaining_pairs, size_t size_of_pair, size_t fns); int remove_pair(Block* block, char* remove_name, size_t fns); int directory_data_block_Is_Full(Block* block, size_t block_size, size_t fns); int directory_data_block_Is_Empty(Block* block); off_t get_offset(Block* block, char* target_name, size_t fns); off_t find_hole(hole_map* holes, size_t my_size); int shift_holes_to_the_left(hole_map* holes, uint hole_position); int shift_holes_to_the_right(hole_map* holes, uint hole_position); uint number_of_sub_entities_in_directory(MDS* current_directory, size_t fns); off_t directory_get_offset(int fd, MDS* directory, size_t block_size, size_t fns, char* target_name); int name_exists_in_directory(int fd, MDS* directory, size_t block_size, size_t fns, char* target_name); off_t get_offset_from_path(int fd, superblock* my_superblock, Stack_List* list, char original_path[]); int get_legit_name_from_path(int fd, superblock* my_superblock, Stack_List* list, char original_path[], char* legit_name); int copy_from_linux_to_cfs(int fd, superblock* my_superblock, hole_map* holes, MDS* imported_file, int linux_file_fd, size_t linux_file_size); int copy_from_cfs_to_linux(int fd, superblock* my_superblock, MDS* source, int linux_file_fd); int remove_MDS_blocks(int fd, superblock* my_superblock, hole_map* holes, MDS* remove_entity); int remove_pair_from_directory(int fd, superblock* my_superblock, hole_map* holes, MDS* parent_entity, off_t parent_offset, off_t remove_offset); #endif
1.726563
2
GrandDB_Test/Classes/Other/Tool/AndyCategory/NSTimer+Andy.h
lyandy/GrandDB_Test
2
7998883
// // NSTimer+Andy.h // AndyCategory_Test // // Created by 李扬 on 2016/12/26. // Copyright © 2016年 andyshare. All rights reserved. // #import <Foundation/Foundation.h> @interface NSTimer (Andy) + (NSTimer *)andy_timerWithTimeInterval:(NSTimeInterval)ti repeats:(BOOL)yesOrNo handler:(void(^)(void))handler; + (NSTimer *)andy_scheduledTimerWithTimeInterval:(NSTimeInterval)ti repeats:(BOOL)yesOrNo handler:(void(^)(void))handler; @end
1.023438
1
vm-cmp/fs/vfs.save/src/vfs_functions.c
kifferltd/open-mika
41
7998891
/************************************************************************** * Copyright (c) 2001 by Acunia N.V. All rights reserved. * * * * This software is copyrighted by and is the sole property of Acunia N.V. * * and its licensors, if any. All rights, title, ownership, or other * * interests in the software remain the property of Acunia N.V. and its * * licensors, if any. * * * * This software may only be used in accordance with the corresponding * * license agreement. Any unauthorized use, duplication, transmission, * * distribution or disclosure of this software is expressly forbidden. * * * * This Copyright notice may not be removed or modified without prior * * written consent of Acunia N.V. * * * * Acunia N.V. reserves the right to modify this software without notice. * * * * Acunia N.V. * * <NAME> 35 <EMAIL> * * 3000 Leuven http://www.acunia.com * * Belgium - EUROPE * * * * Modifications copyright (c) 2004 by <NAME>, /k/ Embedded Java * * Solutions. All rights reserved. * * * **************************************************************************/ #include "wonka.h" #include "ts-mem.h" #include "threads.h" #include "oswald.h" #include "vfs.h" #include "vfs_errno.h" #include "vfs_fcntl.h" #include <stdlib.h> // #include <e2fs_prototypes.h> /* Shouldn't be here -> need to fix vfs_opendir */ /* W = write D = devices S = symlinks ~ = plus minus C = context W int link(const char *oldpath, const char *newpath); > Only needed to make hard links W int rename(const char *oldpath, const char *newpath); ? int fcntl(int fd, int cmd); ? int fcntl(int fd, int cmd, long arg); ? int fcntl(int fd, int cmd, struct flock * lock); S int symlink(const char *oldpath, const char *newpath); S int readlink(const char *path, char *buf, size_t bufsiz); S int lstat(const char *file_name, struct stat *buf); FILE *freopen (const char *path, const char *mode, FILE *stream); int fileno( FILE *stream); int getdents(unsigned int fd, struct dirent *dirp, unsigned int count); ~ int scandir(const char *dir, struct dirent ***namelist, int (*select)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **)); int ungetc(int c, FILE *stream); // W void setbuf(FILE *stream, char *buf); // W void setbuffer(FILE *stream, char *buf, size_tsize); // W void setlinebuf(FILE *stream); // W int setvbuf(FILE *stream, char *buf, int mode , size_t size); > No buffers yet, so no use for these functions... */ /* -------------------------------------------------------------------------------------------------------- * * Here are the highlevel functions, which mimic the normal C functions * * --------------------------------------------------------------------------------------------------------*/ int vfs_open(const w_ubyte *filename, const w_word flags, const w_word mode) { vfs_dir_entry dir_entry = NULL; vfs_dir_entry dir; vfs_inode inode; vfs_file file; int result = 0; w_ubyte *name, *path; vfs_lock(); path = allocMem((w_size)(strlen(filename) + 1)); strcpy(path, filename); name = strrchr(path, '/'); if(name != NULL) { *name = '\0'; name++; } woempa(4, "%s in %s\n", name, path); vfs_set_errno(0); if((vfs_lookup_fullpath(dir_entry_list, filename) != NULL) && ((flags & (VFS_O_CREAT & VFS_O_EXCL)) != 0)) { vfs_set_errno(EEXIST); /* Check if this name isn't already in use */ result = -1; /* While VFS_O_CREAT and VFS_O_EXCL are used */ } if((result == 0) && ((dir = vfs_lookup_fullpath(dir_entry_list, path)) == NULL)) { vfs_set_errno(ENOENT); /* Check if the path exists */ result = -1; } if((result == 0) && !(VFS_S_ISDIR(dir->inode->flags))) { /* Check if path is a directory */ vfs_set_errno(ENOTDIR); result = -1; } if((result == 0) && ((dir->inode->sb->flags & VFS_MOUNT_RW) == 0) && ((flags & VFS_O_WRONLY) != 0)) { vfs_set_errno(EROFS); /* Check if fs is read/write while file is */ result = -1; /* being opened for writing */ } if((result == 0) && ((dir->inode->flags & VFS_FF_W) == 0) && ((flags & (VFS_O_CREAT | VFS_O_WRONLY | VFS_O_RDWR)) != 0)) { vfs_set_errno(EACCES); /* Check if directory is writeable while */ result = -1; /* file is being opened for writing */ } if((result == 0) && ((dir->inode->flags & VFS_FF_R) == 0) && ((flags & (VFS_O_RDONLY | VFS_O_RDWR)) != 0)) { vfs_set_errno(EACCES); /* Check if directory is readable while */ result = -1; /* file is being opened for reading */ } if(result == 0) { dir_entry = vfs_lookup_fullpath(dir_entry_list, filename); /* Lookup the dir_entry for the name */ if(dir_entry != NULL) { /* Is a directory entry found ? */ if(((dir_entry->inode->flags & VFS_FF_W) == 0) && (flags & (VFS_O_WRONLY | VFS_O_RDWR))) { vfs_set_errno(EACCES); result = -1; } if(((dir_entry->inode->flags & VFS_FF_R) == 0) && (flags & (VFS_O_RDONLY | VFS_O_RDWR))) { vfs_set_errno(EACCES); result = -1; } if((result == 0) && ((flags & VFS_O_TRUNC) == VFS_O_TRUNC)) dir_entry->inode->inode_ops->truncate(dir_entry->inode); } else { /* No directory entry found -> create one */ if((flags & VFS_O_CREAT) == VFS_O_CREAT) { dir_entry = allocMem(sizeof(vfs_Dir_Entry)); inode = allocMem(sizeof(vfs_Inode)); memset(dir_entry, 0, sizeof(vfs_Dir_Entry)); memset(inode, 0, sizeof(inode)); dir_entry->name = allocMem((w_size)(strlen(name) + 1)); /* Allocate memory for the name */ strcpy(dir_entry->name, name); /* Copy the name */ dir_entry->inode = inode; /* Put the inode in the dir_entry */ dir_entry->mount = inode; dir_entry->parent = dir; /* Add the parent */ dir_entry->child_list = NULL; dir_entry->next_entry = dir->child_list; /* Add the dir_entry to the childlist */ dir->child_list = dir_entry; /* of the parent (dir) */ inode->flags = mode; inode->sb = dir->inode->sb; inode->inode_ops = dir->inode->inode_ops; vfs_set_errno(inode->inode_ops->create(inode, dir_entry)); if(vfs_get_errno() != 0) { /* Creation failed, cleanup a bit */ result = -1; dir->child_list = dir_entry->child_list; releaseMem(inode); releaseMem(dir_entry); } } else { result = -1; vfs_set_errno(ENOENT); /* Check if the path exists */ } } } if(result == 0) { file = allocMem(sizeof(vfs_File)); /* Allocate some memory */ file->file_desc = (file_list == NULL ? 1 : file_list->file_desc + 1); /* File descriptor is the next in line, or 1 */ /* if there wasn't already an open file */ file->dir_entry = dir_entry; /* Store the directory entry */ if((flags & VFS_O_APPEND) == VFS_O_APPEND) file->position = file->dir_entry->inode->size; /* Positioning at the end */ else file->position = 0; /* Start reading/writing at position 0 */ file->flags = flags; file->next = file_list; /* Add the file to the list of open files */ file_list = file; result = file->file_desc; } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ int vfs_creat(const w_ubyte *pathname, w_word mode) { return vfs_open(pathname, VFS_O_CREAT | VFS_O_WRONLY | VFS_O_TRUNC, mode); } /* --------------------------------------------------------------------------------------------------------*/ int vfs_close(const int file_desc) { vfs_file file; vfs_file temp; int result = -1; /* Default to 'not successful' */ vfs_lock(); file = file_list; woempa(4, "%d\n", file_desc); /* OLA: Should flush buffers to the device for writable files */ vfs_set_errno(0); /* Clear errno */ if(file_list->file_desc == file_desc) { /* Is the first entry the one to be closed ? */ file_list = file_list->next; /* yep, remove it from the list */ releaseMem(file); /* Release memory */ result = 0; /* No errors */ } else { while((file != NULL) && (file->next != NULL)) { /* Is there a next file ? */ if(file->next->file_desc == file_desc) { /* Found it */ temp = file->next; file->next = (file->next == NULL ? NULL : file->next->next); releaseMem(temp); /* Release memory */ result = 0; /* No errors */ } file = file->next; /* Go to the next file */ } } if(result == -1) vfs_set_errno(EBADF); /* If result = -1, the descriptor was wrong */ vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ int vfs_read(const int file_desc, w_void *buffer, const w_word count) { int result = -1; /* Default to 'not successful' */ vfs_file file; /* The open file list */ vfs_dir_entry dir_entry; vfs_inode inode; w_word begin, end, pos, block_size; w_word block_nr; w_word dest_offset, src_offset, size; w_ubyte *block_buffer; vfs_lock(); file = file_list; woempa(4, "fd:%d, %d bytes\n", file_desc, count); vfs_set_errno(0); /* Clear errno */ while(file != NULL && file->file_desc != file_desc) file = file->next; if((file != NULL) && ((file->flags & (VFS_O_RDONLY | VFS_O_RDWR)) != 0)) { dir_entry = file->dir_entry; inode = dir_entry->inode; if((inode->flags & VFS_FF_DIR) == VFS_FF_DIR) { vfs_set_errno(EISDIR); } else { memset(buffer, 0, count); block_size = inode->sb->block_size; block_buffer = allocMem((w_size)block_size); begin = file->position; end = begin + count; if(end > inode->size) end = inode->size; woempa(3, "begin: %d end: %d\n", begin, end); block_nr = begin / block_size; pos = block_nr * block_size; dest_offset = 0; src_offset = 0; while(pos < end) { /* OLA: Now a block of data is read into a seperate buffer than the destination */ /* Speed can be improved by writing directly to the destination buffer. Tricky part */ /* is that getblock() fetches a whole block regardless if we need the beginning of */ /* that block -> possible by reading the whole block and then copy the needed part */ /* over the beginning. Same problem arises with the end... Don't know a good solution (yet) */ /* Also possible way to improve speed : Add a certain amount of blockbuffers into the */ /* the open file structure, and read in blocks ahead */ inode->inode_ops->get_block(inode, block_buffer, block_nr); size = block_size; if(pos < begin) { src_offset = begin % block_size; size = block_size - src_offset; } else { src_offset = 0; } if(end < pos + block_size) { size = end % block_size; if(size > count) size = count; } woempa(1, "block_nr: %6d src: %6d dest: %6d size: %6d\n", block_nr, src_offset, dest_offset, size); memcpy((w_ubyte *)((w_word)buffer + dest_offset), (w_ubyte *)((w_word)block_buffer + src_offset), size); dest_offset += size; block_nr++; pos += block_size; } result = end - begin; file->position = end; releaseMem(block_buffer); } } else { vfs_set_errno(EBADF); } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ int vfs_write(const int file_desc, const w_void *buffer, const w_word count) { int result = -1; /* Default to 'not successful' */ vfs_file file; /* The open file list */ vfs_dir_entry dir_entry; vfs_inode inode; w_word begin, end, pos, block_size; w_word block_nr; w_word dest_offset, src_offset, size; w_ubyte *block_buffer; vfs_lock(); result = -1; /* Default to 'not successful' */ file = file_list; woempa(4, "%p fd:%d, %d bytes\n", currentWonkaThread, file_desc, count); vfs_set_errno(0); /* Clear errno */ while(file != NULL && file->file_desc != file_desc) file = file->next; if((file != NULL) && ((file->flags & (VFS_O_WRONLY | VFS_O_RDWR)) != 0)) { dir_entry = file->dir_entry; inode = dir_entry->inode; if((inode->flags & VFS_FF_DIR) == VFS_FF_DIR) { vfs_set_errno(EISDIR); } else { block_size = inode->sb->block_size; block_buffer = allocMem((w_size)block_size); if((file->flags & VFS_O_APPEND) == VFS_O_APPEND) file->position = inode->size; /* If file is open with append, make sure we write */ /* at the end of the file */ begin = file->position; end = begin + count; if(end > inode->size) inode->size = end; /* File can grow */ woempa(2, "inode %d, begin %d, end %d\n", inode->nr, begin, end); block_nr = begin / block_size; pos = block_nr * block_size; dest_offset = 0; src_offset = 0; while((pos < end) && (vfs_get_errno() == 0)) { size = block_size; if(pos < begin) { src_offset = begin % block_size; size = block_size - src_offset; } else { src_offset = 0; } if(end < pos + block_size) { size = end % block_size; if(size > count) size = count; } if(src_offset != 0) { /* If offset is different than zero, read in the buffer first */ inode->inode_ops->get_block(inode, block_buffer, block_nr); } woempa(3, "block_nr: %6d src: %6d dest: %6d size: %6d\n", block_nr, src_offset, dest_offset, size); memcpy((w_ubyte*)((w_word)block_buffer + src_offset), (w_ubyte *)((w_word)buffer + dest_offset), size); vfs_set_errno(inode->inode_ops->put_block(inode, block_buffer, block_nr)); /* OLA: Should return the number of bytes actually written */ dest_offset += size; block_nr++; pos += block_size; } result = end - begin; file->position = end; releaseMem(block_buffer); } } else { vfs_set_errno(EBADF); } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ long vfs_lseek(const int file_desc, const long offset, const w_word whence) { vfs_file file; w_long result = -1; vfs_lock(); file = file_list; woempa(4, "fd:%d, offset:%d, whence:%d\n", file_desc, offset, whence); vfs_set_errno(0); /* Clear errno */ while(file != NULL && file->file_desc != file_desc) file = file->next; /* Locate the file structure */ if(file != NULL) { /* File structure found ? */ switch(whence) { /* Which kind of position ? */ case SEEK_SET: result = 0; file->position = offset; /* Set to offset */ break; case SEEK_CUR: result = 0; file->position += offset; /* Go to position + offset */ break; case SEEK_END: result = 0; file->position += offset + file->dir_entry->inode->size; /* Go to EOF + offset */ break; default: vfs_set_errno(EINVAL); /* Default: Bad interval */ break; } } else { vfs_set_errno(EBADF); /* Filedescriptor not found... */ } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ vfs_DIR *vfs_opendir(const w_ubyte *name) { vfs_dir_entry dir_entry = NULL; vfs_DIR *result = NULL; w_ubyte *buffer; w_ubyte *ptr; vfs_low_dir_entry lowlevel_dirent; char *ename; vfs_inode inode; vfs_lock(); woempa(4, "%s\n", name); ename = allocMem(255); /* OLA: Fixed size.... */ vfs_set_errno(0); dir_entry = vfs_lookup_fullpath(dir_entry_list, name); /* Lookup the dir_entry for the name */ if(dir_entry != NULL) /* Is a directory entry found ? */ if((dir_entry->inode->flags & VFS_FF_DIR) != VFS_FF_DIR) vfs_set_errno(ENOTDIR); else { /* Not found, read in from the fs */ if(dir_entry->inode != dir_entry->mount) { inode = dir_entry->mount; } else { inode = dir_entry->inode; } buffer = allocMem((w_size)inode->size); ptr = buffer; inode->inode_ops->read_dir(inode, buffer); lowlevel_dirent = (vfs_low_dir_entry)ptr; while(lowlevel_dirent->inode != 0 && lowlevel_dirent->name_length != 0) { memset(ename, 0, 255); /* OLA: Fixed length -> danger <NAME> ! danger ! */ strncpy(ename, lowlevel_dirent->name, lowlevel_dirent->name_length); vfs_lookup_entry(dir_entry, ename); ptr += lowlevel_dirent->entry_length; lowlevel_dirent = (vfs_low_dir_entry)ptr; } releaseMem(buffer); /* Continue */ result = allocMem(sizeof(vfs_DIR)); /* Allocate memory for the dir descriptor */ result->head = dir_entry; /* Make head point to the parent directory */ result->current = dir_entry->child_list; /* Current = the first child */ result->next = DIR_list; /* Add this descriptor to the list of open dirs */ DIR_list = result; } else vfs_set_errno(ENOENT); /* No directory entry -> file does not exist */ releaseMem(ename); vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_closedir(vfs_DIR *dir) { vfs_DIR *dir_list; int result = -1; /* Default to 'not successful' */ vfs_lock(); dir_list = DIR_list; woempa(4, "%s\n", dir->head->name); vfs_set_errno(0); /* Clear errno */ if(DIR_list == dir) { /* Is dir the first entry in the dir list ? */ DIR_list = DIR_list->next; /* Remove it from the list */ releaseMem(dir); /* Release memory */ result = 0; /* Mission accomplished */ } else { while(dir_list != NULL && dir_list->next != NULL) { /* Is there a next DIR ? */ if(dir_list->next == dir) { /* Found it */ dir_list->next = dir->next; /* Remove it from the list */ releaseMem(dir); /* Release memory */ result = 0; /* Mission accomplished */ } dir_list = dir_list->next; /* Go to the next entry in the list */ } } if(result == -1) vfs_set_errno(EBADF); /* Mission failed ? -> Bad descriptor */ vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ vfs_dirent *vfs_readdir(vfs_DIR *dir) { vfs_dirent *result = NULL; /* Default to 'no more entries' */ vfs_lock(); woempa(4, "%s\n", dir->head->name); if(dir->current != NULL) { /* See if dir is valid */ strcpy(dir->dir_ent.d_name, dir->current->name); /* Get the name from current and put it in the dirent */ dir->current = dir->current->next_entry; /* Current points to the next entry */ result = &dir->dir_ent; /* Return the dirent */ } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_void vfs_rewinddir(vfs_DIR *dir) { vfs_lock(); dir->current = dir->head->child_list; /* Current points back to the first child (entry) */ vfs_unlock(); } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_telldir(vfs_DIR *dir) { vfs_dir_entry dir_entry; int result = -1; w_word offset = 0; vfs_lock(); dir_entry = dir->head->child_list; while((dir->current != dir_entry) && (dir_entry->next_entry != NULL)) { dir_entry = dir_entry->next_entry; offset++; } if(dir_entry == dir->current) result = offset; vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_void vfs_seekdir(vfs_DIR *dir, w_word offset) { vfs_dir_entry dir_entry; w_word count; vfs_lock(); dir_entry = dir->head->child_list; for(count=0; count < offset && dir_entry->next_entry != NULL; count++) dir_entry = dir_entry->next_entry; dir->current = dir_entry; vfs_unlock(); } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_alphasort(struct vfs_dirent **a, struct vfs_dirent **b) { return strcmp((char *)((struct vfs_dirent *)(*a)->d_name), (char *)((struct vfs_dirent *)(*b)->d_name)); } /* --------------------------------------------------------------------------------------------------------*/ // w_word vfs_scandir(const w_ubyte *dir, struct vfs_dirent ***namelist, // w_word (*select)(const struct vfs_dirent *), // w_word (*compar)(const struct vfs_dirent **, const struct vfs_dirent **)) { /* OLA: Still need to fill this is... */ // return 0; //} /* --------------------------------------------------------------------------------------------------------*/ int vfs_stat(const w_ubyte *filename, struct vfs_STAT *buf) { vfs_dir_entry dir_entry; int result = -1; /* Default to 'not successful' */ vfs_lock(); woempa(4, "%s\n", filename); vfs_set_errno(0); /* Clear errno */ dir_entry = vfs_lookup_fullpath(dir_entry_list, filename); /* Lookup the dir_entry for the name */ if(dir_entry != NULL) { /* Is a directory entry found ? */ result = 0; buf->st_dev = 0; /* device */ buf->st_ino = dir_entry->inode->nr; /* inode */ buf->st_mode = dir_entry->inode->flags; /* protection */ buf->st_size = dir_entry->inode->size; /* total size, in bytes */ buf->st_blksize = dir_entry->inode->sb->block_size; /* blocksize for filesystem I/O */ } else { vfs_set_errno(ENOENT); /* No directory entry -> file does not exist */ } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fstat(int file_desc, struct vfs_STAT *buf) { vfs_dir_entry dir_entry; vfs_file file; int result = -1; /* Default to 'not successful' */ vfs_lock(); file = file_list; woempa(4, "%d\n", file_desc); vfs_set_errno(0); /* Clear errno */ while(file != NULL && file->file_desc != file_desc) file = file->next; /* Look for the right file structure */ if(file != NULL) { /* file stucture found ? */ dir_entry = file->dir_entry; result = 0; buf->st_dev = 0; /* device */ buf->st_ino = dir_entry->inode->nr; /* inode */ buf->st_mode = dir_entry->inode->flags; /* protection */ buf->st_size = dir_entry->inode->size; /* total size, in bytes */ buf->st_blksize = dir_entry->inode->sb->block_size; /* blocksize for filesystem I/O */ } else { vfs_set_errno(EBADF); /* No file found ?-> Bad file descriptor */ } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ vfs_FILE *vfs_fopen (const w_ubyte *path, const w_ubyte *mode) { vfs_FILE *stream = NULL; int file_desc; w_word flags = 0; vfs_lock(); woempa(4, "start path: %s, mode: %s\n", path, mode); if(strcmp(mode, "r") == 0) flags = VFS_O_RDONLY; if(strcmp(mode, "r+") == 0) flags = VFS_O_RDWR; if(strcmp(mode, "w") == 0) flags = VFS_O_CREAT | VFS_O_TRUNC | VFS_O_WRONLY; if(strcmp(mode, "w+") == 0) flags = VFS_O_CREAT | VFS_O_TRUNC | VFS_O_RDWR; if(strcmp(mode, "a") == 0) flags = VFS_O_CREAT | VFS_O_APPEND | VFS_O_WRONLY; if(strcmp(mode, "a+") == 0) flags = VFS_O_CREAT | VFS_O_APPEND | VFS_O_RDWR; file_desc = vfs_open(path, flags, VFS_FF_R | VFS_FF_W); if(file_desc != -1) { /* Valid filedes ? */ stream = allocMem(sizeof(vfs_FILE)); /* Allocate memory */ stream->file_desc = file_desc; /* Store the file descriptor */ stream->mode = allocMem((w_size)strlen(mode)+1); /* Allocate memory to store the mode */ strcpy(stream->mode, mode); /* Copy the mode to the stream */ stream->error = 0; stream->next = FILE_list; /* Add this stream to the open streams list */ } vfs_unlock(); return stream; } /* --------------------------------------------------------------------------------------------------------*/ vfs_FILE *vfs_fdopen (int file_desc, const w_ubyte *mode) { vfs_file file; vfs_FILE *stream = NULL; w_word flags = 0; vfs_lock(); file = file_list; woempa(4, "fd: %d, mode: %s\n", file_desc, mode); if(strcmp(mode, "r") == 0) flags = VFS_O_RDONLY; if(strcmp(mode, "r+") == 0) flags = VFS_O_RDWR; if(strcmp(mode, "w") == 0) flags = VFS_O_CREAT | VFS_O_TRUNC | VFS_O_WRONLY; if(strcmp(mode, "w+") == 0) flags = VFS_O_CREAT | VFS_O_TRUNC | VFS_O_RDWR; if(strcmp(mode, "a") == 0) flags = VFS_O_CREAT | VFS_O_APPEND | VFS_O_WRONLY; if(strcmp(mode, "a+") == 0) flags = VFS_O_CREAT | VFS_O_APPEND | VFS_O_RDWR; vfs_set_errno(0); while(file != NULL && file->file_desc != file_desc) file = file->next; file->flags = flags; if(file != NULL) { /* File structure found ? */ stream = allocMem(sizeof(vfs_FILE)); /* Allocate memory */ stream->file_desc = file_desc; /* Store the file descriptor */ stream->mode = allocMem((w_size)strlen(mode)+1); /* Allocate memory to store the mode */ strcpy(stream->mode, mode); /* Copy the mode to the stream */ stream->error = 0; stream->next = FILE_list; /* Add this stream to the open streams list */ } else { vfs_set_errno(EBADF); /* Filedescriptor not found... */ } vfs_unlock(); return stream; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fclose(vfs_FILE *stream) { vfs_FILE *streams; int result = -1; /* Default to 'not successful' */ vfs_lock(); woempa(4, "\n"); streams = FILE_list; vfs_fflush(stream); /* Flush unwritten buffers to the device */ vfs_set_errno(0); if(streams == stream) { /* First entry is to be closed */ streams = streams->next; releaseMem(stream); result = 0; } else { while(streams != NULL && streams->next != NULL) { /* Is there a next stream ? */ if(streams->next == stream) { /* Found it */ streams->next = (streams->next == NULL ? NULL : streams->next->next); // vfs_close(stream->file_desc); /* Close the file */ releaseMem(stream); /* Release the memory */ result = 0; } streams = streams->next; } } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ int vfs_fseek(vfs_FILE *stream, long offset, w_word whence) { vfs_file file; int result = -1; vfs_lock(); file = file_list; woempa(4, "offset: %d, whence: %d\n", offset, whence); vfs_set_errno(0); /* Clear errno */ while(file != NULL && file->file_desc != stream->file_desc) file = file->next; /* Locate the file structure */ if(file != NULL) { /* File structure found ? */ switch(whence) { /* Which kind of position ? */ case SEEK_SET: result = 0; file->position = offset; /* Set to offset */ break; case SEEK_CUR: result = 0; file->position += offset; /* Go to position + offset */ break; case SEEK_END: result = 0; file->position += offset + file->dir_entry->inode->size; /* Go to EOF + offset */ break; default: vfs_set_errno(EINVAL); /* Default: Bad interval */ break; } } else { vfs_set_errno(EBADF); /* Filedescriptor not found... */ } if(file->position >= file->dir_entry->inode->size) { stream->error = VFS_STREAM_EOF; } /* Set the eof flag if needed */ vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_rewind(vfs_FILE *stream) { woempa(4, "\n"); return vfs_fseek(stream, 0, SEEK_SET); } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_ftell(vfs_FILE *stream) { vfs_file file; int result = -1; vfs_lock(); file = file_list; woempa(4, "\n"); while(file != NULL && file->file_desc != stream->file_desc) file = file->next; /* Locate the file structure */ if(file != NULL) { /* File structure found ? */ result = file->position; } else { vfs_set_errno(EBADF); /* Filedescriptor not found... */ } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fgetpos(vfs_FILE *stream, vfs_fpos_t *pos) { int result = -1; vfs_lock(); woempa(4, "\n"); *pos = vfs_ftell(stream); if(*pos != -1) result = 0; vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fsetpos(vfs_FILE *stream, vfs_fpos_t *pos) { woempa(4, "\n"); return vfs_fseek(stream, *pos, SEEK_SET); } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fread(w_void *ptr, w_word size, w_word nmemb, vfs_FILE *stream) { w_word result = 0; vfs_lock(); woempa(4, "\n"); if(!(stream->error && VFS_STREAM_EOF)) { result = vfs_read(stream->file_desc, ptr, size * nmemb); if(result < nmemb * size) stream->error |= VFS_STREAM_EOF; /* If we get less than we asked, */ /* end-of-file is reached */ } vfs_unlock(); return result / size; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fwrite(const w_void *ptr, w_word size, w_word nmemb, vfs_FILE *stream) { w_word result = 0; vfs_lock(); woempa(4, "\n"); /* flags are checked by the vfs_write function */ result = vfs_write(stream->file_desc, ptr, size * nmemb); vfs_unlock(); return result / size; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_feof(vfs_FILE *stream) { woempa(4, "\n"); vfs_lock(); vfs_unlock(); return (stream->error && VFS_STREAM_EOF); } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_ferror(vfs_FILE *stream) { woempa(4, "\n"); vfs_lock(); vfs_unlock(); return (stream->error & VFS_STREAM_ERROR); } /* --------------------------------------------------------------------------------------------------------*/ w_void vfs_clearerr(vfs_FILE *stream) { woempa(4, "\n"); vfs_lock(); stream->error = 0; vfs_unlock(); } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fgetc(vfs_FILE *stream) { w_ubyte result; woempa(4, "\n"); vfs_lock(); vfs_fread((w_void *)&result, 1, 1, stream); vfs_unlock(); return (w_word)result; } /* --------------------------------------------------------------------------------------------------------*/ w_ubyte *vfs_fgets(w_ubyte *s, w_word size, vfs_FILE *stream) { w_word count = 0; w_ubyte *ptr; w_ubyte c = 0; woempa(4, "\n"); vfs_lock(); ptr = s; while((count < size) && (!vfs_feof(stream)) && (c != '\n') && (c != '\0')) { vfs_fread(ptr, 1, 1, stream); c = *ptr; count++; ptr++; } ptr--; memcpy(ptr, "\0", 1); vfs_unlock(); if(count != 0) return s; else return NULL; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_getc(vfs_FILE *stream) { /* Copy of vfs_fgetc */ w_ubyte result; woempa(4, "\n"); vfs_lock(); vfs_fread((w_void *)&result, 1, 1, stream); vfs_unlock(); return (w_word)result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fputc(w_int c, vfs_FILE *stream) { w_ubyte result = c; /* OLA: EOF ? */ woempa(4, "%c\n", c); vfs_lock(); vfs_fwrite((w_ubyte *)&result, 1, 1, stream); vfs_unlock(); return (w_word)result; /* OLA: Should check if the char is indeed written */ } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fputs(const w_ubyte *s, vfs_FILE *stream) { woempa(4, "%s\n", s); return vfs_fwrite(s, 1, strlen(s), stream); } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_putc(w_word c, vfs_FILE *stream) { /* Copy of vfs_fputc */ w_ubyte result = c; /* OLA: EOF ? */ woempa(4, "%c\n", c); vfs_lock(); vfs_fwrite((w_ubyte *)&result, 1, 1, stream); vfs_unlock(); return (w_word)result; /* OLA: Should check if the char is indeed written */ } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fflush(vfs_FILE *stream) { vfs_file file; /* The open file list */ vfs_dir_entry dir_entry; vfs_inode inode; vfs_lock(); file = file_list; woempa(4, "\n"); vfs_set_errno(0); /* Clear errno */ while(file != NULL && file->file_desc != stream->file_desc) file = file->next; if(file != NULL) { dir_entry = file->dir_entry; inode = dir_entry->inode; vfs_flush_dir_entry(dir_entry_list); // Flush the entire filesystem inode->sb->super_ops->flush(inode->sb); } vfs_unlock(); return 0; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_mkdir(const w_ubyte *pathname, w_word mode) { w_ubyte *name; w_ubyte *path; vfs_dir_entry dir_entry = NULL; vfs_dir_entry new_dir; vfs_inode inode; int result = 0; vfs_lock(); path = allocMem((w_size)(strlen(pathname) + 1)); strcpy(path, pathname); name = strrchr(path, '/'); if(name != NULL) { *name = '\0'; name++; } woempa(4, "%s in %s\n", name, path); if(vfs_lookup_fullpath(dir_entry_list, pathname) != NULL) { /* Check if this name isn't already in use */ vfs_set_errno(EEXIST); result = -1; } if((result == 0) && ((dir_entry = vfs_lookup_fullpath(dir_entry_list, path)) == NULL)) { /* Check if the path exists */ vfs_set_errno(ENOENT); result = -1; } if((result == 0) && !(VFS_S_ISDIR(dir_entry->inode->flags))) { /* Check if path is a directory */ vfs_set_errno(ENOTDIR); result = -1; } if((result == 0) && ((dir_entry->inode->sb->flags & VFS_MOUNT_RW) == 0)) { /* Check if fs is read/write */ vfs_set_errno(EROFS); result = -1; } if((result == 0) && ((dir_entry->inode->flags & VFS_FF_W) == 0)) { /* Check if directory is writeable */ vfs_set_errno(EACCES); result = -1; } if(result == 0) { /* All oki, make a directory */ new_dir = allocMem(sizeof(vfs_Dir_Entry)); inode = allocMem(sizeof(vfs_Inode)); memset(new_dir, 0, sizeof(vfs_Dir_Entry)); memset(inode, 0, sizeof(inode)); new_dir->name = allocMem((w_size)(strlen(name) + 1)); strcpy(new_dir->name, name); new_dir->inode = inode; new_dir->mount = inode; new_dir->parent = dir_entry; new_dir->child_list = dir_entry->child_list; dir_entry->child_list = new_dir; inode->flags = mode; inode->sb = dir_entry->inode->sb; inode->inode_ops = dir_entry->inode->inode_ops; inode->inode_ops->mkdir(inode, new_dir); } releaseMem(path); vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_rmdir(const w_ubyte *pathname){ w_ubyte *name; w_ubyte *path; vfs_dir_entry dir_entry; vfs_dir_entry temp; int result = 0; w_word i; vfs_DIR *DIR; vfs_lock(); path = allocMem((w_size)(strlen(pathname) + 1)); strcpy(path, pathname); name = strrchr(path, '/'); if(name != NULL) { *name = '\0'; name++; } woempa(4, "%s in %s\n", name, path); if((dir_entry = vfs_lookup_fullpath(dir_entry_list, pathname)) == NULL) { /* Check if this name is in use */ vfs_set_errno(ENOENT); result = -1; } if((result == 0) && !(VFS_S_ISDIR(dir_entry->inode->flags))) { /* Check if name is a directory */ vfs_set_errno(ENOTDIR); result = -1; } if((result == 0) && ((dir_entry->inode->sb->flags & VFS_MOUNT_RW) == 0)) { /* Check if fs is read/write */ vfs_set_errno(EROFS); result = -1; } if((result == 0) && ((dir_entry->parent->inode->flags & VFS_FF_W) == 0)) { /* Check if parent directory is writeable */ vfs_set_errno(EACCES); result = -1; } if(result == 0) { /* Check if dir is empty */ if(dir_entry->child_list == NULL) { /* Childeren are not known -> read them */ DIR = vfs_opendir(pathname); vfs_closedir(DIR); } i = 0; temp = dir_entry->child_list; while(temp != NULL) { temp = temp->next_entry; i++; } if(i != 2) { vfs_set_errno(ENOTEMPTY); result = -1; woempa(3, "directory is not empty.\n"); } } if(result == 0) { /* All oki, remove a directory */ dir_entry->inode->inode_ops->rmdir(dir_entry->parent->inode, dir_entry); dir_entry->inode->sb->super_ops->flush(dir_entry->parent->inode->sb); vfs_cleanup_dir_entry(dir_entry); /* Clear the childeren */ dir_entry_list->total_entries--; /* Remove this dir_entry from the parents child list */ temp = dir_entry->parent->child_list; if(temp == dir_entry) { dir_entry->parent->child_list = dir_entry->next_entry; releaseMem(dir_entry); } else { while(temp != NULL && temp->next_entry != NULL) { if(temp->next_entry == dir_entry) { temp->next_entry = dir_entry->next_entry; releaseMem(dir_entry); } temp = temp->next_entry; } } } releaseMem(path); vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_unlink(const w_ubyte *pathname) { w_ubyte *name; w_ubyte *path; vfs_dir_entry dir_entry; vfs_dir_entry temp; int result = 0; vfs_lock(); path = allocMem((w_size)(strlen(pathname) + 1)); strcpy(path, pathname); name = strrchr(path, '/'); if(name != NULL) { *name = '\0'; name++; } woempa(4, "%s in %s\n", name, path); if((dir_entry = vfs_lookup_fullpath(dir_entry_list, pathname)) == NULL) { /* Check if this name is in use */ vfs_set_errno(ENOENT); result = -1; } if((result == 0) && (VFS_S_ISDIR(dir_entry->inode->flags))) { /* Check if name is a directory */ vfs_set_errno(EPERM); result = -1; } if((result == 0) && ((dir_entry->inode->sb->flags & VFS_MOUNT_RW) == 0)) { /* Check if fs is read/write */ vfs_set_errno(EROFS); result = -1; } if((result == 0) && ((dir_entry->parent->inode->flags & VFS_FF_W) == 0)) { /* Check if parent directory is writeable */ vfs_set_errno(EACCES); result = -1; } if(result == 0) { /* All oki, remove a directory */ dir_entry->inode->sb->super_ops->unlink_inode(dir_entry->parent->inode, dir_entry); dir_entry->inode->sb->super_ops->flush(dir_entry->parent->inode->sb); dir_entry_list->total_entries--; /* Remove this dir_entry from the parents child list */ temp = dir_entry->parent->child_list; if(temp == dir_entry) { dir_entry->parent->child_list = dir_entry->next_entry; releaseMem(dir_entry); } else { while(temp != NULL && temp->next_entry != NULL) { if(temp->next_entry == dir_entry) { temp->next_entry = dir_entry->next_entry; releaseMem(dir_entry); } temp = temp->next_entry; } } } releaseMem(path); vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_chmod(const w_ubyte *path, w_word mode) { int result = -1; vfs_dir_entry dir_entry; vfs_lock(); dir_entry = vfs_lookup_fullpath(dir_entry_list, path); woempa(4, "path: %s, mode: %d\n", path, mode); vfs_set_errno(0); if(dir_entry != NULL) { if((dir_entry->inode->sb->flags & VFS_MOUNT_RW) == VFS_MOUNT_RW) { dir_entry->inode->flags = mode; result = 0; } else { vfs_set_errno(EROFS); } } else { vfs_set_errno(ENOENT); } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_fchmod(int file_desc, w_word mode) { int result = -1; vfs_file file; /* The open file list */ vfs_lock(); file = file_list; woempa(4, "fd: %d, mode: %d\n", file_desc, mode); vfs_set_errno(0); /* Clear errno */ while(file != NULL && file->file_desc != file_desc) file = file->next; if(file != NULL) { if((file->dir_entry->inode->sb->flags & VFS_MOUNT_RW) == VFS_MOUNT_RW) { file->dir_entry->inode->flags = mode; result = 0; } else { vfs_set_errno(EROFS); } } else { vfs_set_errno(EBADF); } vfs_unlock(); return result; } /* --------------------------------------------------------------------------------------------------------*/ w_word vfs_rename(const w_ubyte *oldpath, const w_ubyte *newpath) { #ifdef CRAP vfs_dir_entry dir_entry; vfs_dir_entry dir; vfs_inode inode; vfs_file file; w_word result = 0; w_ubyte *name, *path; path = allocMem((w_size)(strlen(filename) + 1)); strcpy(path, filename); name = strrchr(path, '/'); if(name != NULL) { *name = '\0'; name++; } woempa(4, "%s in %s\n", name, path); vfs_set_errno(0); if((vfs_lookup_fullpath(dir_entry_list, filename) != NULL) && ((flags & (VFS_O_CREAT & VFS_O_EXCL)) != 0)) { vfs_set_errno(EEXIST); /* Check if this name isn't already in use */ result = -1; /* While VFS_O_CREAT and VFS_O_EXCL are used */ } if((result == 0) && ((dir = vfs_lookup_fullpath(dir_entry_list, path)) == NULL)) { vfs_set_errno(ENOENT); /* Check if the path exists */ result = -1; } if((result == 0) && !(VFS_S_ISDIR(dir->inode->flags))) { /* Check if path is a directory */ vfs_set_errno(ENOTDIR); result = -1; } if((result == 0) && ((dir->inode->sb->flags & VFS_MOUNT_RW) == 0) && ((flags & VFS_O_WRONLY) != 0)) { vfs_set_errno(EROFS); /* Check if fs is read/write while file is */ result = -1; /* being opened for writing */ } if((result == 0) && ((dir->inode->flags & VFS_FF_W) == 0) && ((flags & (VFS_O_CREAT | VFS_O_WRONLY | VFS_O_RDWR)) != 0)) { vfs_set_errno(EACCES); /* Check if directory is writeable while */ result = -1; /* file is being opened for writing */ } if((result == 0) && ((dir->inode->flags & VFS_FF_R) == 0) && ((flags & (VFS_O_RDONLY | VFS_O_RDWR)) != 0)) { vfs_set_errno(EACCES); /* Check if directory is readable while */ result = -1; /* file is being opened for reading */ } if(result == 0) { dir_entry = vfs_lookup_fullpath(dir_entry_list, filename); /* Lookup the dir_entry for the name */ if(dir_entry != NULL) { /* Is a directory entry found ? */ if(((dir_entry->inode->flags & VFS_FF_W) == 0) && (flags & (VFS_O_WRONLY | VFS_O_RDWR))) { vfs_set_errno(EACCES); result = -1; } if(((dir_entry->inode->flags & VFS_FF_R) == 0) && (flags & (VFS_O_RDONLY | VFS_O_RDWR))) { vfs_set_errno(EACCES); result = -1; } if((flags & VFS_O_TRUNC) == VFS_O_TRUNC) dir_entry->inode->inode_ops->truncate(dir_entry->inode); } else { /* No directory entry found -> create one */ if((flags & VFS_O_CREAT) == VFS_O_CREAT) { dir_entry = allocMem(sizeof(vfs_Dir_Entry)); inode = allocMem(sizeof(vfs_Inode)); memset(dir_entry, 0, sizeof(vfs_Dir_Entry)); memset(inode, 0, sizeof(inode)); dir_entry->name = allocMem((w_size)(strlen(name) + 1)); /* Allocate memory for the name */ strcpy(dir_entry->name, name); /* Copy the name */ dir_entry->inode = inode; /* Put the inode in the dir_entry */ dir_entry->parent = dir; /* Add the parent */ dir_entry->child_list = dir->child_list; /* Add the dir_entry to the childlist */ dir->child_list = dir_entry; /* of the parent (dir) */ inode->flags = mode; inode->sb = dir->inode->sb; inode->inode_ops = dir->inode->inode_ops; inode->inode_ops->create(inode, dir_entry); } } } if(result == 0) { file = allocMem(sizeof(vfs_File)); /* Allocate some memory */ file->file_desc = (file_list == NULL ? 1 : file_list->file_desc + 1); /* File descriptor is the next in line, or 1 */ /* if there wasn't already an open file */ file->dir_entry = dir_entry; /* Store the directory entry */ if((flags & VFS_O_APPEND) == VFS_O_APPEND) file->position = file->dir_entry->inode->size; /* Positioning at the end */ else file->position = 0; /* Start reading/writing at position 0 */ file->flags = flags; file->next = file_list; /* Add the file to the list of open files */ file_list = file; result = file->file_desc; } return result; w_ubyte *name; w_ubyte *path; vfs_dir_entry dir_entry; vfs_dir_entry temp; w_word result = 0; path = allocMem((w_size)(strlen(pathname) + 1)); strcpy(path, pathname); name = strrchr(path, '/'); if(name != NULL) { *name = '\0'; name++; } woempa(3, "%s in %s\n", name, path); if((dir_entry = vfs_lookup_fullpath(dir_entry_list, pathname)) == NULL) { /* Check if this name is in use */ errno = ENOENT; result = -1; } if((result == 0) && (S_ISDIR(dir_entry->inode->flags))) { /* Check if name is a directory */ errno = EPERM; result = -1; } if((result == 0) && ((dir_entry->inode->sb->flags & VFS_MOUNT_RW) == 0)) { /* Check if fs is read/write */ errno = EROFS; result = -1; } if((result == 0) && ((dir_entry->parent->inode->flags & VFS_FF_W) == 0)) { /* Check if parent directory is writeable */ errno = EACCES; result = -1; } if(result == 0) { /* All oki, remove a directory */ dir_entry->inode->sb->super_ops->unlink_inode(dir_entry->parent->inode, dir_entry); dir_entry_list->total_entries--; /* Remove this dir_entry from the parents child list */ temp = dir_entry->parent->child_list; if(temp == dir_entry) { dir_entry->parent->child_list = dir_entry->next_entry; releaseMem(dir_entry); } else { while(temp != NULL && temp->next_entry != NULL) { if(temp->next_entry == dir_entry) { temp->next_entry = dir_entry->next_entry; releaseMem(dir_entry); } temp = temp->next_entry; } } } releaseMem(path); return result; #endif }
1.320313
1
ckuusr.c
caseymillsdavis/kermit
0
7998899
#ifdef SSHTEST #define SSHBUILTIN #endif /* SSHTEST */ #include "ckcsym.h" char *userv = "User Interface 9.0.299, 9 Jun 2011"; /* C K U U S R -- "User Interface" for C-Kermit (Part 1) */ /* Authors: <NAME> <<EMAIL>>, The Kermit Project, Columbia University, New York City <NAME> <<EMAIL>> Secure Endpoints Inc., New York City Copyright (C) 1985, 2011, Trustees of Columbia University in the City of New York. All rights reserved. See the C-Kermit COPYING.TXT file or the copyright text in the ckcmai.c module for disclaimer and permissions. */ /* Originally the entire user interface was in one module, ckuusr.c. Over the years it has been split into many modules: ckuus2.c, ckuus3.c, ..., ckuus7.c. ckuus2.c contains the HELP command parser and help-text strings; ckuusy.c contains the UNIX-style command-line interface; ckuusx.c contains routines needed by both the command-line interface and the interactive command parser. */ /* The ckuus*.c modules depend on the existence of C library features like fopen, fgets, feof, (f)printf, argv/argc, etc. Other functions that are likely to vary among different platforms -- like setting terminal modes or interrupts -- are invoked via calls to functions that are defined in the system- dependent modules, ck?[ft]io.c. The command line parser processes any arguments found on the command line, as passed to main() via argv/argc. The interactive parser uses the facilities of the cmd package (developed for this program, but usable by any program). Any command parser may be substituted for this one. The only requirements for the Kermit command parser are these: . Set parameters via global variables like duplex, speed, ttname, etc. See ckcmai.c for the declarations and descriptions of these variables. . If a command can be executed without the use of Kermit protocol, then execute the command directly and set the variable sstate to 0. Examples include 'set' commands, local directory listings, the 'connect' command. . If a command requires the Kermit protocol, set the following variables: sstate string data 'x' (enter server mode) (none) 'r' (send a 'get' command) cmarg, cmarg2 'v' (enter receive mode) cmarg2 'g' (send a generic command) cmarg 's' (send files) nfils, cmarg & cmarg2 OR cmlist 'c' (send a remote host command) cmarg cmlist is an array of pointers to strings. cmarg, cmarg2 are pointers to strings. nfils is an integer. cmarg can be a filename string (possibly wild), or a pointer to a prefabricated generic command string, or a pointer to a host command string. cmarg2 is an "as-name" - the name to send file(s) under, or the name under which to store incoming file(s); must not be wild. A null or empty value means to use the file's own name. cmlist is a list of filenames, such as passed via argv. nfils is an integer, interpreted as follows: -1: filespec (possibly wild) in cmarg, must be expanded internally. 0: send from stdin (standard input). >0: number of files to send, from cmlist. The screen() function is used to update the screen during file transfer. The tlog() function writes to a transaction log. The debug() function writes to a debugging log. The intmsg() and chkint() functions provide the user i/o for interrupting file transfers. */ /* Includes */ #ifdef MULTINET #define MULTINET_OLD_STYLE /* Leave select prototype undefined */ #endif /* MULTINET */ #include "ckcdeb.h" #include "ckcasc.h" #include "ckcker.h" #include "ckcnet.h" /* Network symbols */ #include "ckuusr.h" #include "ckcxla.h" int g_fncact = -1; /* Needed for NOICP builds */ int noinit = 0; /* Flag for skipping init file */ int nscanfile = SCANFILEBUF; int rcdactive = 0; /* RCD active */ int keepallchars = 0; /* See cmfld() */ int locus = 1; /* Current LOCUS is LOCAL */ #ifdef OS2 int autolocus = 2; /* Automatic LOCUS switching: ASK */ #else /* OS2 */ int autolocus = 1; /* Automatic LOCUS switching enabled */ #endif /* OS2 */ #ifndef NOICP #ifdef CKLEARN #ifdef VMS #include <time.h> /* For CKLEARN */ #endif /* VMS */ #endif /* CKLEARN */ #ifdef OS2 #ifndef NT #define INCL_NOPM #define INCL_VIO /* Needed for ckocon.h */ #include <os2.h> #undef COMMENT #else #define APIRET ULONG #include <windows.h> #include <tapi.h> #include "cknwin.h" #include "ckntap.h" /* CK_TAPI definition */ #endif /* NT */ #include "ckowin.h" #include "ckocon.h" extern int tcp_avail; extern bool viewonly; extern int k95stdout; extern int tt_scroll; #ifndef NOTERM extern tt_status[VNUM]; #endif /* NOTERM */ int display_demo = 1; #include "ckossh.h" #ifdef KUI #include "ikui.h" #endif /* KUI */ #endif /* OS2 */ int optlines = 0; int didsetlin = 0; #ifdef NEWFTP extern int ftpget, ftpisopen(), doftpres(); _PROTOTYP(int doftptyp,(int)); _PROTOTYP(VOID doftpglobaltype,(int)); #endif /* NEWFTP */ #ifdef VMS extern int batch; #endif /* VMS */ #ifdef datageneral #include <packets:common.h> #define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd) #endif /* datageneral */ extern int xcmdsrc, hints, cmflgs, whyclosed; char * hlptok = NULL; #ifdef CK_TTGWSIZ /* Whether to use more-prompting */ int xaskmore = 1; /* Momentary setting */ int saveask = 1; /* Permanent setting */ #else int xaskmore = 0; int saveask = 0; #endif /* CK_TTGWSIZ */ #ifndef NOCSETS extern int nfilc; extern struct keytab fcstab[]; extern int fcharset; #endif /* NOCSETS */ char * g_pswd = NULL; int g_pcpt = -1; int g_pflg = -1; extern int cmd_rows, cmd_cols; #ifdef CKROOT extern int ckrooterr; #endif /* CKROOT */ extern int inserver, filepeek; #ifdef CKLEARN FILE * learnfp = NULL; char * learnfile = NULL; int learning = 0; #endif /* CKLEARN */ #ifndef NOXFER extern int atcapr, atdiso, nfils, moving, protocol, sendmode, epktflg, size, sndsrc, server, displa, fncnv, fnspath, fnrpath, xfermode, urpsiz, spsizf, spsiz, spsizr, spmax, wslotr, prefixing, fncact, reliable, setreliable; #ifdef IKSDCONF extern int iksdcf; #endif /* IKSDCONF */ #ifdef CK_LOGIN extern int isguest; #endif /* CK_LOGIN */ extern CK_OFF_T sendstart; extern char *cmarg, *cmarg2, **cmlist, *dftty; extern struct keytab fntab[]; extern int nfntab; extern struct ck_p ptab[NPROTOS]; int sndcmd = 0; /* Last command was a SEND-class command. */ int g_xfermode = -1; int g_proto = -1; int g_urpsiz = -1; int g_spsizf = -1; int g_spsiz = -1; int g_spsizr = -1; int g_spmax = -1; int g_wslotr = -1; int g_prefixing = -1; int g_fncnv = -1; int g_fnspath = -1; int g_fnrpath = -1; int g_fnact = -1; int g_displa = -1; int g_spath = -1; int g_rpath = -1; char * g_sfilter = NULL; char * g_rfilter = NULL; extern int patterns; #ifdef PATTERNS extern char *txtpatterns[], *binpatterns[]; int g_patterns = -1; #endif /* PATTERNS */ int g_skipbup = -1; #ifdef PIPESEND extern int usepipes, pipesend; extern char * sndfilter; #endif /* PIPESEND */ #ifndef NOSPL extern int sndxlo, sndxhi, sndxin; #endif /* NOSPL */ extern char fspec[]; /* Most recent filespec */ extern int fspeclen; /* Length of fspec[] buffer */ #ifndef NOFRILLS extern int rmailf; /* MAIL command items */ extern char optbuf[]; #endif /* NOFRILLS */ extern int en_cpy, en_cwd, en_del, en_dir, en_fin, en_get, en_bye, en_mai, en_pri, en_hos, en_ren, en_sen, en_spa, en_set, en_typ, en_who, en_ret, en_xit, en_mkd, en_rmd, en_asg; #ifndef NOMSEND /* Multiple SEND */ extern char *msfiles[]; int filesinlist = 0; /* And ADD ... */ extern struct filelist * filehead; extern struct filelist * filetail; extern struct filelist * filenext; extern int addlist; #endif /* NOMSEND */ static struct keytab addtab[] = { #ifdef PATTERNS { "binary-patterns", ADD_BIN, 0 }, #endif /* PATTERNS */ #ifndef NOMSEND { "send-list", ADD_SND, 0 }, #endif /* NOMSEND */ #ifdef PATTERNS { "text-patterns", ADD_TXT, 0 }, #endif /* PATTERNS */ { "", 0, 0 } }; static int naddtab = sizeof(addtab)/sizeof(struct keytab) - 1; #ifndef NOCSETS struct keytab assoctab[] = { { "file-character-set", ASSOC_FC, 0 }, { "transfer-character-set", ASSOC_TC, 0 }, { "xfer-character-set", ASSOC_TC, CM_INV } }; static int nassoc = sizeof(assoctab)/sizeof(struct keytab); extern int afcset[MAXFCSETS+1]; /* Character-set associations */ extern int axcset[MAXTCSETS+1]; #endif /* NOCSETS */ #ifndef ADDCMD #ifndef NOMSEND #define ADDCMD #endif /* NOMSEND */ #ifndef ADDCMD #ifdef PATTERNS #define ADDCMD #endif /* PATTERNS */ #endif /* ADDCMD */ #endif /* ADDCMD */ #endif /* NOXFER */ /* External Kermit Variables, see ckmain.c for description. */ extern xx_strp xxstring; extern long xvernum; extern int local, xitsta, binary, msgflg, escape, duplex, quiet, tlevel, pflag, zincnt, ckxech, carrier, what, nopush, haveline, bye_active; #ifdef TNCODE extern int debses; extern char tn_msg[]; #endif /* TNCODE */ int sleepcan = 1; int g_binary = -1; int g_recursive = -1; int g_matchdot = -1; extern int nolinks; extern long vernum; extern char *versio, *copyright[]; extern char *ckxsys; #ifndef NOHELP extern char *introtxt[]; extern char *newstxt[]; #endif /* NOHELP */ #ifndef OS2 #ifndef UNIX extern char *PWDCMD; #endif /* UNIX */ extern char *WHOCMD; #endif /* OS2 */ extern char ttname[]; extern CHAR sstate; extern int network; /* Have active network connection */ extern int nettype; /* Type of network */ extern int ttnproto; /* NET_TCPB protocol */ #ifndef NODIAL extern int dialsta, dialatmo, dialcon, dialcq; /* DIAL status, etc. */ #endif /* NODIAL */ #ifdef CK_APC extern int apcactive, apcstatus; #endif /* CK_APC */ #ifndef NOPUSH #ifndef NOFRILLS extern char editor[]; extern char editopts[]; extern char editfile[]; #endif /* NOFRILLS */ #endif /* NOPUSH */ #ifdef BROWSER extern char browser[]; /* Web browser application */ extern char browsopts[]; /* Web browser options */ extern char browsurl[]; /* Most recent URL */ #endif /* BROWSER */ #ifndef NOFTP char ftpapp[CKMAXPATH+1] = { NUL, NUL }; /* ftp executable */ char ftpopts[128] = { NUL, NUL }; /* ftp command-line options */ #endif /* NOFTP */ extern struct keytab onoff[]; /* On/Off keyword table */ #ifdef CK_TMPDIR int f_tmpdir = 0; /* Directory changed temporarily */ char savdir[TMPDIRLEN]; /* For saving current directory */ #endif /* CK_TMPDIR */ int activecmd = -1; /* Keyword index of active command */ int doconx = -1; /* CONNECT-class command active */ int ooflag = 0; /* User-settable on/off flag */ int rcflag = 0; /* Pointer to home directory string */ int repars, /* Reparse needed */ techo = 0; /* Take echo */ int secho = 1; /* SCRIPT echo */ int xitwarn = /* Warn about open connection on exit */ #ifdef NOWARN 0 #else 1 #endif /* NOWARN */ ; struct keytab onoffsw[] = { { "/off", 0, 0 }, { "/on", 1, 0 } }; #ifdef CKEXEC struct keytab redirsw[] = { { "/redirect", 1, 0 } }; #endif /* CKEXEC */ #ifndef NOXMIT /* Variables for TRANSMIT command */ int xmitx = 1; /* Whether to echo during TRANSMIT */ int xmitf = 0; /* Character to fill empty lines */ int xmitl = 0; /* 0 = Don't send linefeed too */ int xmitp = LF; /* Host line prompt */ int xmits = 0; /* Use shift-in/shift-out, 0 = no */ int xmitw = 0; /* Milliseconds to pause during TRANSMIT */ int xmitt = 1; /* Seconds to wait for each char to echo */ int xmita = 1; /* Action upon timeout */ #define XMI_BIN 1 #define XMI_TXT 2 #define XMI_CMD 3 #define XMI_TRA 4 #define XMI_VRB 5 #define XMI_QUI 6 #define XMI_NOW 7 #define XMI_NOE 8 static struct keytab xmitsw[] = { /* TRANSMIT command options */ { "/binary", XMI_BIN, 0 }, #ifdef PIPESEND { "/command", XMI_CMD, CM_INV|CM_PSH }, #endif /* PIPESEND */ { "/noecho", XMI_NOE, 0 }, { "/nowait", XMI_NOW, 0 }, #ifdef PIPESEND { "/pipe", XMI_CMD, 0 }, #endif /* PIPESEND */ #ifdef COMMENT { "/quiet", XMI_QUI, 0 }, #endif /* COMMENT */ { "/text", XMI_TXT, 0 }, { "/transparent", XMI_TRA, 0 }, #ifdef COMMENT { "/verbose", XMI_VRB, 0 }, #endif /* COMMENT */ { "", 0, 0 } }; #define NXMITSW sizeof(xmitsw)/sizeof(struct keytab) - 1 static int nxmitsw = NXMITSW; #endif /* NOXMIT */ /* Declarations from ck?fio.c module */ extern char *SPACMD, *SPACM2; /* SPACE commands */ /* Command-oriented items */ #ifdef DCMDBUF extern char *cmdbuf; /* Command buffers */ extern char *atmbuf; extern char *line; /* Character buffer for anything */ extern char *tmpbuf; /* Short temporary string buffer */ extern int *ifcmd; extern int *intime; extern int *inpcas; #else extern char cmdbuf[]; /* Command buffers */ extern char atmbuf[]; extern char line[]; /* Character buffer for anything */ extern char tmpbuf[]; /* Temporary buffer */ extern int ifcmd[]; extern int intime[]; extern int inpcas[]; #endif /* DCMDBUF */ #ifndef NOSPL extern char * prstring[]; #endif /* NOSPL */ char *lp; /* Pointer to line buffer */ #ifndef NOSPL int vareval = 1; /* Evaluation method */ int unkmacro = 0; /* Flag for in ON_UNKNOWN_COMMAND */ int oldeval = 0; char evalbuf[33]; /* EVALUATE result */ extern char * inpbuf; /* Buffer for INPUT and REINPUT */ char *inpbp; /* And pointer to same */ int m_found; /* MINPUT result */ int i_active = 0; /* INPUT command is active */ char *ms[MINPMAX]; /* Pointers to MINPUT strings */ static int mpinited = 0; /* Flag they have been initialized */ static int mp[MINPMAX]; /* and MINPUT flags */ extern int fndiags, fnerror, fnsuccess; /* Function diagnostics */ #ifndef NOSEXP char * lastsexp = NULL; /* S-Expressions */ char * sexpval = NULL; int sexpecho = SET_AUTO; #endif /* NOSEXP */ #endif /* NOSPL */ char psave[PROMPTL] = { NUL }; /* For saving & restoring prompt */ extern int success; /* Command success/failure flag */ extern int cmdlvl; /* Current position in command stack */ #ifndef NOSPL int /* SET INPUT parameters. */ /* Note, INPUT TIMEOUT, intime[], is on the command-level stack. */ inbufsize = 0, /* INPUT buffer size */ indef = 1, /* default timeout, seconds */ inecho = 1, /* 1 = echo on */ inautodl = 0, /* INPUT autodownload */ inintr = 1, /* INPUT interrupion allowed */ insilence = 0; /* 0 = no silence constraint */ #ifdef CKFLOAT CKFLOAT inscale = 1.0; /* Timeout scale factor */ #endif /* CKFLOAT */ #ifdef OS2 int interm = 1; /* Terminal emulator displays input */ #endif /* OS2 */ int maclvl = -1; /* Macro nesting level */ int mecho = 0; /* Macro echo, 0 = don't */ char varnam[6]; /* For variable names */ extern int macargc[]; /* ARGC from macro invocation */ extern char *m_arg[MACLEVEL][NARGS]; /* Stack of macro arguments */ extern char *mrval[]; extern char **a_ptr[]; /* Array pointers */ extern int a_dim[]; /* Array dimensions */ extern int a_link[]; #ifdef DCMDBUF extern struct cmdptr *cmdstk; /* The command stack itself */ #else extern struct cmdptr cmdstk[]; /* The command stack itself */ #endif /* DCMDBUF */ long ck_alarm = 0; /* SET ALARM value */ char alrm_date[24] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ' }; char alrm_time[24] = { ' ',' ',' ',' ',' ',' ',' ' }; struct keytab inputsw[] = { { "/clear", INPSW_CLR, 0 }, { "/count", INPSW_COU, CM_ARG }, { "/nomatch", INPSW_NOM, 0 }, { "/nowrap", INPSW_NOW, 0 } }; static int ninputsw = sizeof(inputsw)/sizeof(struct keytab); /* The following should be reconciled with the above */ #ifdef COMMENT /* INPUT switches not used yet... */ static struct keytab inswtab[] = { #ifdef COMMENT { "/assign", IN_ASG, CM_ARG }, #endif /* COMMENT */ { "/autodownload", IN_ADL, CM_ARG }, { "/case", IN_CAS, CM_ARG }, { "/echo", IN_ECH, CM_ARG }, { "/interrupts", IN_NOI, CM_ARG }, { "/silence", IN_SIL, CM_ARG }, #ifdef COMMENT { "/pattern", IN_PAT, CM_ARG }, #endif /* COMMENT */ { "", 0, 0 } }; static int ninswtab = (sizeof(inswtab) / sizeof(struct keytab)) - 1; #endif /* COMMENT */ #endif /* NOSPL */ static int x, y, z = 0; /* Local workers */ static char *s; #ifdef CK_MINPUT static char c1chars[] = { /* C1 control chars escept NUL */ 001,002,003,004,005,006,007,010,011,012,013,014,015,016,017,020, 021,022,023,024,025,026,027,030,031,032,033,034,035,036,037 }; #endif /* CK_MINPUT */ #define xsystem(s) zsyscmd(s) /* Top-Level Interactive Command Keyword Table */ /* Keywords must be in lowercase and in alphabetical order. */ struct keytab cmdtab[] = { #ifndef NOPUSH { "!", XXSHE, CM_INV|CM_PSH }, /* Shell escape */ #else { "!", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOPUSH */ { "#", XXCOM, CM_INV }, /* Comment */ #ifndef NOSPL { "(", XXSEXP,CM_INV }, /* S-Expression */ { ".", XXDEF, CM_INV }, /* Assignment */ { ":", XXLBL, CM_INV }, /* Label */ #endif /* NOSPL */ #ifdef CK_REDIR #ifndef NOPUSH { "<", XXFUN, CM_INV|CM_PSH }, /* REDIRECT */ #else { "<", XXNOTAV, CM_INV|CM_PSH }, /* REDIRECT */ #endif /* NOPUSH */ #endif /* CK_REDIR */ #ifndef NOPUSH { "@", XXSHE, CM_INV|CM_PSH }, /* DCL escape */ #else { "@", XXNOTAV, CM_INV|CM_PSH }, /* DCL escape */ #endif /* NOPUSH */ #ifdef CK_RECALL { "^", XXREDO,CM_INV|CM_NOR }, /* Synonym for REDO */ #endif /* CK_RECALL */ #ifndef NOSPL { "_asg", XXASX, CM_INV }, /* Used internally by FOR, etc */ { "_assign", XXASX, CM_INV }, /* Used internally by FOR, etc */ { "_decrement", XX_DECR, CM_INV }, { "_define", XXDFX, CM_INV }, /* Used internally by FOR, etc */ { "_evaluate", XX_EVAL, CM_INV }, { "_forward", XXXFWD, CM_INV }, /* Used internally by SWITCH */ { "_getargs", XXGTA, CM_INV }, /* Used internally by FOR, etc */ { "_increment", XX_INCR, CM_INV }, { "_putargs", XXPTA, CM_INV }, /* Used internally by FOR, etc */ { "_undefine", XXUNDFX, CM_INV }, #endif /* NOSPL */ { "about", XXVER, CM_INV }, /* Synonym for VERSION */ #ifndef NOSPL #ifdef NEWFTP { "account", XXACCT, CM_INV }, /* (FTP) Account */ #endif /* NEWFTP */ #ifdef ADDCMD { "add", XXADD, 0 }, /* ADD */ #endif /* ADDCMD */ #ifndef NODIAL { "answer", XXANSW, CM_LOC }, /* ANSWER the phone */ #else { "answer", XXNOTAV, CM_INV|CM_LOC }, /* ANSWER the phone */ #endif /* NODIAL */ { "apc", XXAPC, 0 }, /* Application Program Command */ #ifndef NOSPL { "array", XXARRAY, 0 }, /* Array operations */ #endif /* NOSPL */ { "ascii", XXASC, CM_INV }, /* == SET FILE TYPE TEXT */ { "asg", XXASS, CM_INV }, /* Invisible synonym for ASSIGN */ { "ask", XXASK, 0 }, /* ASK for text, assign to variable */ { "askq", XXASKQ,0 }, /* ASK quietly (no echo) */ #ifndef NOSPL { "ass", XXASS, CM_INV|CM_ABR }, /* ASSIGN */ { "assert", XXASSER, CM_INV }, /* ASSERT */ { "assign", XXASS, 0 }, /* ASSIGN */ #endif /* NOSPL */ #ifndef NOXFER #ifndef NOCSETS { "associate", XXASSOC, 0 }, /* ASSOCIATE */ #else { "associate", XXNOTAV, CM_INV }, /* ASSOCIATE */ #endif /* NOCSETS */ #endif /* NOXFER */ #ifdef CK_KERBEROS #ifdef CK_AUTHENTICATION { "authenticate",XXAUTH, 0 }, /* Authentication */ #else { "authenticate",XXAUTH, CM_INV }, #endif /* CK_AUTHENTICATION */ #endif /* CK_KERBEROS */ #endif /* NOSPL */ #ifndef NOFRILLS { "back", XXBACK, 0 }, /* BACK to previous directory */ #else { "back", XXNOTAV,CM_INV }, #endif /* NOFRILLS */ { "beep", XXBEEP,CM_INV }, /* BEEP */ #ifndef NOXFER { "binary", XXBIN, CM_INV }, /* == SET FILE TYPE BINARY */ #endif /* NOXFER */ #ifndef NOFRILLS { "bug", XXBUG, CM_INV }, /* BUG report instructions */ #else { "bug", XXNOTAV, CM_INV }, #endif /* NOFRILLS */ #ifdef BROWSER { "browse", XXBROWS, CM_PSH|CM_LOC }, /* BROWSE (start browser) */ #else { "browse", XXNOTAV, CM_INV|CM_PSH|CM_LOC }, #endif /* BROWSER */ #ifndef NOXFER { "bye", XXBYE, 0 }, /* BYE to remote server */ #endif /* NOXFER */ #ifndef NOLOCAL { "c", XXCON, CM_INV|CM_ABR|CM_LOC }, /* (CONNECT) */ #endif /* NOLOCAL */ #ifndef NOFRILLS { "cat", XXCAT, CM_INV }, /* Invisible synonym for TYPE */ #endif /* NOFRILLS */ #ifndef NOSPL #ifndef NOXFER { "cautious", XXCAU, CM_INV }, #endif /* NOXFER */ #endif /* NOSPL */ { "cd", XXCWD, 0 }, /* Change Directory */ { "cdup", XXCDUP, CM_INV }, /* Change Directory Up */ #ifndef NOXFER #ifdef PIPESEND { "cget", XXCGET, CM_INV|CM_PSH }, /* CGET */ #else { "cget", XXNOTAV, CM_INV|CM_PSH }, /* CGET */ #endif /* PIPESEND */ #endif /* NOXFER */ { "ch", XXCHK, CM_INV|CM_ABR }, { "check", XXCHK, 0 }, /* CHECK for a feature */ #ifdef CK_PERMS #ifdef UNIX { "chmod", XXCHMOD, 0 }, /* CHMOD */ #else { "chmod", XXNOTAV, CM_INV }, #endif /* UNIX */ #else { "chmod", XXNOTAV, CM_INV }, #endif /* CK_PERMS */ #ifdef CKROOT { "chroot", XXCHRT, CM_INV }, /* CHROOT */ #endif /* CKROOT */ { "ckermit", XXKERMI, CM_INV }, /* CKERMIT (like KERMIT) */ { "cl", XXCLO, CM_ABR|CM_INV }, #ifndef NOFRILLS { "clear", XXCLE, 0 }, /* CLEAR input and/or device buffer */ #else { "clear", XXNOTAV, CM_INV }, #endif /* NOFRILLS */ { "close", XXCLO, 0 }, /* CLOSE a log or other file */ { "cls", XXCLS, CM_INV }, /* Clear Screen (CLS) */ { "comment", XXCOM, CM_INV }, /* Introduce a comment */ #ifndef NOLOCAL { "connect", XXCON, CM_LOC }, /* Begin terminal connection */ #else { "connect", XXNOTAV, CM_LOC }, #endif /* NOLOCAL */ { "continue", XXCONT, CM_INV }, /* CONTINUE */ #ifndef NOFRILLS #ifdef ZCOPY { "co", XXCPY, CM_INV|CM_ABR }, { "cop", XXCPY, CM_INV|CM_ABR }, { "copy", XXCPY, 0 }, /* COPY a file */ #else { "copy", XXNOTAV, CM_INV }, #endif /* ZCOPY */ { "copyright", XXCPR, CM_INV }, /* COPYRIGHT */ #ifdef ZCOPY { "cp", XXCPY, CM_INV }, /* COPY a file */ #endif /* ZCOPY */ #ifndef NOLOCAL #ifndef OS2 { "cq", XXCQ, CM_INV|CM_LOC }, /* CQ (connect quietly) */ #endif /* OS2 */ #endif /* NOLOCAL */ #ifndef NOXFER #ifdef PIPESEND { "creceive", XXCREC,CM_INV|CM_PSH }, /* RECEIVE to a command */ { "csend", XXCSEN,CM_INV|CM_PSH }, /* SEND from command */ #else { "creceive", XXNOTAV,CM_INV|CM_PSH }, { "csend", XXNOTAV,CM_INV|CM_PSH }, #endif /* PIPESEND */ #endif /* NOXFER */ #endif /* NOFRILLS */ { "cwd", XXCWD, CM_INV }, /* Traditional synonym for cd */ #ifndef NOSPL { "date", XXDATE, 0 }, /* DATE */ { "dcl", XXDCL, CM_INV }, /* DECLARE an array (see ARRAY) */ { "debug", XXDEBUG, 0 }, /* Print a debugging msg [9.0] */ { "declare", XXDCL, CM_INV }, /* DECLARE an array (see ARRAY) */ { "decrement", XXDEC, 0 }, /* DECREMENT a numeric variable */ { "define", XXDEF, 0 }, /* DEFINE a macro or variable */ #else { "date", XXNOTAV, CM_INV }, { "dcl", XXNOTAV, CM_INV }, { "declare", XXNOTAV, CM_INV }, { "decrement", XXNOTAV, CM_INV }, { "define", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOFRILLS { "delete", XXDEL, 0 }, /* DELETE a file */ #else { "delete", XXNOTAV, CM_INV }, #endif /* NOFRILLS */ #ifndef NODIAL { "dial", XXDIAL, CM_LOC }, /* DIAL a phone number */ #else { "dial", XXNOTAV, CM_INV|CM_LOC }, #endif /* NODIAL */ #ifdef NT { "dialer", XXDIALER, CM_INV }, /* K95 Dialer */ #endif /* NT */ { "directory", XXDIR, 0 }, /* DIRECTORY of files */ #ifndef NOFRILLS #ifndef NOSERVER { "disable", XXDIS, 0 }, /* DISABLE a server function */ #else { "disable", XXNOTAV, CM_INV }, #endif /* NOSERVER */ #endif /* NOFRILLS */ #ifndef NOSPL { "do", XXDO, 0 }, /* DO (execute) a macro */ #else { "do", XXNOTAV, CM_INV }, #endif /* NOSPL */ { "e", XXEXI, CM_INV|CM_ABR }, #ifndef NOFRILLS #ifndef NOXFER { "e-packet", XXERR, CM_INV }, /* Send an Error-Packet */ #endif /* NOXFER */ #endif /* NOFRILLS */ { "echo", XXECH, 0 }, /* ECHO text */ #ifndef NOFRILLS #ifndef NOPUSH { "edit", XXEDIT, CM_PSH }, /* EDIT */ #else { "edit", XXNOTAV, CM_INV|CM_PSH }, /* EDIT */ #endif /* NOPUSH */ #endif /* NOFRILLS */ { "eightbit", XXEIGHT, CM_INV }, /* EIGHTBIT */ #ifndef NOSPL { "else", XXELS, CM_INV }, /* ELSE part of IF statement */ #else { "else", XXNOTAV, CM_INV }, /* ELSE part of IF statement */ #endif /* NOSPL */ #ifndef NOSERVER #ifndef NOFRILLS { "enable", XXENA, 0 }, /* ENABLE a server function */ #else { "enable", XXNOTAV, CM_INV }, #endif /* NOFRILLS */ #endif /* NOSERVER */ #ifndef NOSPL { "end", XXEND, 0 }, /* END command file or macro */ #else { "end", XXNOTAV, CM_INV }, #endif /* NOSPL */ { "erase", XXDEL, CM_INV }, /* Synonym for DELETE */ #ifndef NOSPL { "evaluate", XXEVAL, 0 }, /* EVALUATE */ #else { "evaluate", XXNOTAV, CM_INV }, #endif /* NOSPL */ { "ex", XXEXI, CM_INV|CM_ABR }, /* Let "ex" still be EXIT */ #ifdef CKEXEC { "exec", XXEXEC, CM_INV|CM_LOC }, /* exec() */ #else { "exec", XXNOTAV, CM_INV|CM_LOC }, #endif /* CKEXEC */ { "exit", XXEXI, 0 }, /* EXIT from C-Kermit */ { "extended-options", XXXOPTS,CM_INV|CM_HLP }, /* Extended-Options */ #ifdef OS2 { "extproc", XXCOM, CM_INV }, /* Dummy command for OS/2 */ #endif /* OS2 */ #ifndef NOXFER { "f", XXFIN, CM_INV|CM_ABR }, /* Invisible abbrev for FIN */ #endif /* NOXFER */ #ifndef NOSPL { "fail", XXFAIL, CM_INV }, /* FAIL */ #ifndef NOXFER { "fast", XXFAST, CM_INV }, #endif /* NOXFER */ #ifdef CKCHANNELIO { "fclose", XXF_CL, CM_INV }, /* FCLOSE */ { "fcount", XXF_CO, CM_INV }, /* FCOUNT */ { "fflush", XXF_FL, CM_INV }, /* FFLUSH */ #endif /* CKCHANNELIO */ #ifndef NOXFER { "fi", XXFIN, CM_INV|CM_ABR }, /* FINISH */ #endif /* NOXFER */ #ifdef CKCHANNELIO { "file", XXFILE, 0 }, /* FILE */ #endif /* CKCHANNELIO */ #endif /* NOSPL */ #ifndef NOXFER { "fin", XXFIN, CM_INV|CM_ABR }, /* FINISH */ #endif /* NOXFER */ #ifndef UNIXOROSK { "find", XXGREP, 0 }, /* FIND (grep) */ #else { "find", XXGREP,CM_INV }, #endif /* UNIXOROSK */ #ifndef NOXFER { "finish", XXFIN, 0 }, /* FINISH */ #endif /* NOXFER */ #ifdef TCPSOCKET { "firewall", XXFIREW, CM_INV|CM_HLP }, #endif /* TCPSOCKET */ #ifdef CKCHANNELIO { "flist", XXF_LI, CM_INV }, /* FLIST */ { "fopen", XXF_OP, CM_INV }, /* FOPEN */ #endif /* CKCHANNELIO */ #ifndef NOSPL { "fo", XXFOR, CM_INV|CM_ABR }, /* Invisible abbrev for... */ { "for", XXFOR, 0 }, /* FOR loop */ { "forward", XXFWD, CM_INV }, /* FORWARD */ #endif /* NOSPL */ #ifndef NOFRILLS { "fot", XXDIR, CM_INV }, /* "fot" = "dir" (for Chris) */ #endif /* NOFRILLS */ #ifdef CKCHANNELIO { "fread", XXF_RE, CM_INV }, /* FREAD */ { "frewind", XXF_RW, CM_INV }, /* FREWIND */ { "fseek", XXF_SE, CM_INV }, /* FSEEK */ { "fstatus", XXF_ST, CM_INV }, /* FSTATUS */ #endif /* CKCHANNELIO */ #ifdef TCPSOCKET #ifndef NOFTP #ifdef SYSFTP #ifndef NOPUSH { "ftp", XXFTP, CM_INV|CM_PSH|CM_LOC }, /* System FTP */ #else { "ftp", XXNOTAV, CM_INV|CM_PSH|CM_LOC }, #endif /* NOPUSH */ #else /* SYSFTP */ { "ftp", XXFTP, 0 }, /* Built-in FTP */ #endif /* SYSFTP */ #else /* NOFTP */ { "ftp", XXNOTAV, CM_INV }, /* No FTP */ #endif /* NOFTP */ #endif /* TCPSOCKET */ #ifndef NOSPL { "function", XXFUNC, CM_INV|CM_HLP }, /* (for HELP FUNCTION) */ #endif /* NOSPL */ #ifdef CKCHANNELIO { "fwrite", XXF_WR, CM_INV }, /* FWRITE */ #endif /* CKCHANNELIO */ #ifndef NOXFER { "g", XXGET, CM_INV|CM_ABR }, /* Invisible abbrev for GET */ #ifndef NOSPL { "ge", XXGET, CM_INV|CM_ABR }, /* Ditto */ #endif /* NOSPL */ { "get", XXGET, 0 }, /* GET */ #endif /* NOXFER */ #ifndef NOSPL { "getc", XXGETC, 0 }, /* GETC */ #ifdef OS2 { "getkeycode", XXGETK, 0 }, /* GETKEYCODE */ #endif /* OS2 */ #ifndef NOFRILLS { "getok", XXGOK, 0 }, /* GETOK (ask for Yes/No/OK) */ #endif /* NOFRILLS */ #endif /* NOSPL */ #ifndef NOSPL { "goto", XXGOTO,0 }, /* GOTO label in take file or macro */ #endif /* NOSPL */ #ifdef UNIXOROSK { "grep", XXGREP,0 }, /* GREP (find) */ #else { "grep", XXGREP,CM_INV }, /* GREP (find) */ #endif /* UNIXOROSK */ { "h", XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */ { "he", XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */ #ifndef NOFRILLS { "head", XXHEAD, 0 }, #endif /* NOFRILLS */ #ifndef NOLOCAL { "hangup", XXHAN, CM_LOC }, /* HANGUP the connection */ #endif /* NOLOCAL */ { "hdirectory", XXHDIR, CM_INV }, /* DIR sorted by size biggest first */ { "HELP", XXHLP, 0 }, /* Display HELP text */ #ifndef NOHTTP #ifdef TCPSOCKET { "http", XXHTTP, 0 }, /* HTTP operations */ #endif /* TCPSOCKET */ #endif /* NOHTTP */ #ifndef NOSPL { "i", XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */ { "if", XXIF, 0 }, /* IF ( condition ) command */ #ifdef TCPSOCKET { "iksd", XXIKSD, CM_INV }, /* Make connection to IKSD */ #else { "iksd", XXNOTAV, CM_INV }, #endif /* TCPSOCKET */ { "in", XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */ { "increment", XXINC, 0 }, /* Increment a numeric variable */ { "input", XXINP, 0 }, /* INPUT text from comm device */ #endif /* NOSPL */ #ifndef NOHELP { "int", XXINT, CM_INV|CM_ABR }, { "intr", XXINT, CM_INV|CM_ABR }, { "INTRO", XXINT, 0 }, { "introduction",XXINT, CM_INV }, /* Print introductory text */ #else { "intro", XXNOTAV, CM_INV }, { "introduction",XXNOTAV, CM_INV }, #endif /* NOHELP */ #ifdef OS2 { "k95", XXKERMI, CM_INV }, /* Hmmm what's this... */ #endif /* OS2 */ #ifndef NOSPL { "kcd", XXKCD, 0 }, #endif /* NOSPL */ { "kermit", XXKERMI, CM_INV }, #ifdef OS2 #ifndef NOKVERBS { "kverb", XXKVRB, CM_INV|CM_HLP }, /* Keyboard verb */ #endif /* NOKVERBS */ #endif /* OS2 */ #ifndef NOFRILLS { "l", XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */ #endif /* NOFRILLS */ { "lcd", XXLCWD, CM_INV }, { "lcdup", XXLCDU, CM_INV }, { "lcwd", XXLCWD, CM_INV }, { "ldelete", XXLDEL, CM_INV }, { "ldirectory", XXLDIR, CM_INV }, #ifdef CKLEARN { "learn", XXLEARN, 0 }, /* LEARN - automatic script writing */ #else { "learn", XXNOTAV, CM_INV }, #endif /* CKLEARN */ { "li", XXLNOUT, CM_INV|CM_ABR }, { "LICENSE", XXCPR, 0 }, /* LICENSE */ #ifndef NOSPL { "lineout", XXLNOUT, 0 }, /* LINEOUT = OUTPUT + eol */ #endif /* NOSPL */ #ifdef NT { "link", XXLINK, 0 }, /* LINK source destination */ #endif /* NT */ { "lmkdir", XXLMKD, CM_INV }, { "lmv", XXLREN, CM_INV }, #ifndef NOFRILLS { "lo", XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */ #endif /* NOFRILLS */ #ifndef NOSPL { "local", XXLOCAL, CM_INV }, /* LOCAL variable declaration */ #else { "local", XXNOTAV, CM_INV }, #endif /* NOSPL */ { "locus", XXLOCU, CM_INV|CM_HLP }, /* "help locus" */ { "log", XXLOG, 0 }, /* Open a log file */ { "login", XXLOGIN, 0 }, /* (REMOTE) LOGIN to server or IKSD */ { "logout", XXLOGOUT, 0 }, /* LOGOUT from server or IKSD */ #ifndef NOFRILLS #ifndef NODIAL { "lookup", XXLOOK, 0 }, /* LOOKUP */ #else { "lookup", XXNOTAV, CM_INV }, #endif /* NODIAL */ { "lpwd", XXLPWD, CM_INV }, { "lrename", XXLREN, CM_INV }, { "lrmdir", XXLRMD, CM_INV }, #ifdef UNIXOROSK { "ls", XXLS, CM_INV|CM_PSH }, /* UNIX ls command */ #else { "ls", XXDIR, CM_INV }, /* Invisible synonym for DIR */ #endif /* UNIXOROSK */ #ifndef NOXFER { "mail", XXMAI, 0 }, /* Send a file as e-mail */ #endif /* NOXFER */ #ifndef NOHELP { "manual", XXMAN, CM_PSH }, /* MAN(UAL) */ #else { "manual", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOHELP */ #endif /* NOFRILLS */ #ifdef CK_MKDIR { "md", XXMKDIR, CM_INV }, /* Synonym for MKDIR */ #endif /* CK_MKDIR */ { "message", XXMSG, 0 }, /* Print debugging message */ #ifdef CK_MINPUT { "minput", XXMINP, 0 }, /* MINPUT */ #else { "minput", XXNOTAV, CM_INV }, #endif /* CK_MINPUT */ #ifndef NOMSEND { "mget", XXMGET, 0 }, /* MGET */ #else { "mget", XXNOTAV, CM_INV }, #endif /* NOMSEND */ #ifdef CK_MKDIR { "mkdir", XXMKDIR, 0 }, /* MKDIR */ #else { "mkdir", XXNOTAV, CM_INV }, #endif /* CK_MKDIR */ #ifndef NOXFER #ifndef NOMSEND { "mmove", XXMMOVE, 0 }, /* MMOVE */ #else { "mmove", XXNOTAV, CM_INV }, #endif /* NOMSEND */ #endif /* NOXFER */ #ifndef NOFRILLS { "more", XXMORE, CM_INV }, /* MORE */ #endif /* NOFRILLS */ #ifndef NOXFER { "move", XXMOVE, 0 }, /* MOVE */ #endif /* NOXFER */ #ifndef NOSPL { "mpause", XXMSL, CM_INV }, /* Millisecond sleep */ #else { "mpause", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOXFER #ifndef NOMSEND { "mput", XXMSE, CM_INV }, /* MPUT = MSEND */ { "ms", XXMSE, CM_INV|CM_ABR }, { "msend", XXMSE, 0 }, /* Multiple SEND */ #else { "mput", XXNOTAV, CM_INV }, { "msend", XXNOTAV, CM_INV }, #endif /* NOMSEND */ #endif /* NOXFER */ { "msg", XXMSG, CM_INV }, /* Print debugging message */ #ifndef NOSPL { "msleep", XXMSL, 0 }, /* Millisecond sleep */ #else { "msleep", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOFRILLS { "mv", XXREN, CM_INV }, /* Synonym for rename */ #endif /* NOFRILLS */ #ifndef NOHELP { "news", XXNEW, CM_INV }, /* Display NEWS of new features */ #else { "news", XXNOTAV, CM_INV }, #endif /* NOHELP */ { "nolocal", XXNLCL, CM_INV }, /* Disable SET LINE / SET HOST */ { "nopush", XXNPSH, CM_INV }, /* Disable PUSH command/features */ #ifdef OS2 { "noscroll", XXNSCR, CM_INV }, /* Disable scroll operations */ #endif /* OS2 */ #ifndef NOSPL { "o", XXOUT, CM_INV|CM_ABR }, /* Invisible synonym for OUTPUT */ { "open", XXOPE, 0 }, /* OPEN file for reading or writing */ #else { "open", XXOPE, CM_INV }, /* OPEN */ #endif /* NOSPL */ #ifndef NOHELP { "options", XXOPTS,CM_INV|CM_HLP }, /* Options */ #endif /* NOHELP */ { "orientation", XXORIE, 0 }, #ifndef NOSPL { "output", XXOUT, 0 }, /* OUTPUT text to comm device */ #else { "output", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifdef ANYX25 #ifndef IBMX25 { "pad", XXPAD, CM_LOC }, /* X.3 PAD commands */ #endif /* IBMX25 */ #endif /* ANYX25 */ #ifdef NEWFTP { "passive", XXPASV, CM_INV }, /* (FTP) PASSIVE */ #endif /* NEWFTP */ #ifndef NOHELP { "patterns", XXPAT,CM_INV|CM_HLP }, /* Pattern syntax */ #endif /* NOHELP */ #ifndef NOSPL { "pause", XXPAU, 0 }, /* Sleep for specified interval */ #else { "pause", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NODIAL { "pdial", XXPDIA, CM_LOC }, /* PDIAL (partial dial) */ #else { "pdial", XXNOTAV, CM_INV|CM_LOC }, #endif /* NODIAL */ #ifdef TCPSOCKET #ifndef NOPUSH { "ping", XXPNG, CM_INV|CM_PSH|CM_LOC }, /* PING */ #else { "ping", XXNOTAV, CM_INV|CM_PSH|CM_LOC }, #endif /* NOPUSH */ #endif /* TCPSOCKET */ #ifdef NETCMD #ifndef NOPUSH { "pipe", XXPIPE, CM_PSH }, /* PIPE */ #else { "pipe", XXNOTAV, CM_INV|CM_PSH }, /* PIPE */ #endif /* NOPUSH */ #endif /* NETCMD */ #ifndef NOSPL { "pop", XXEND, CM_INV }, /* Invisible synonym for END */ #endif /* NOSPL */ #ifndef NOFRILLS { "print", XXPRI, 0 }, /* PRINT a file locally */ #endif /* NOFRILLS */ { "prompt", XXPROMP, CM_INV }, /* Go interactive (from script) */ #ifndef NOXFER #ifdef CK_RESEND { "psend", XXPSEN, CM_INV }, /* PSEND */ #else { "psend", XXNOTAV, CM_INV }, #endif /* CK_RESEND */ #endif /* NOXFER */ #ifdef NETPTY { "pty", XXPTY, CM_PSH }, /* PTY */ #else { "pty", XXNOTAV, CM_INV|CM_PSH }, #endif /* NETPTY */ #ifndef NOPUSH { "pu", XXSHE, CM_INV|CM_ABR|CM_PSH }, /* PU = PUSH */ #endif /* NOPUSH */ #ifdef CKPURGE { "purge", XXPURGE, 0 }, /* PURGE (real) */ #else #ifdef VMS { "purge", XXPURGE, 0 }, /* PURGE (fake) */ #else { "purge", XXNOTAV, CM_INV }, #endif /* VMS */ #endif /* CKPURGE */ #ifndef NOPUSH { "push", XXSHE, CM_PSH }, /* PUSH command (like RUN, !) */ #else { "push", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOPUSH */ #ifndef NOXFER { "put", XXSEN, CM_INV }, /* PUT = SEND */ #endif /* NOXFER */ #ifdef UNIX #ifndef NOPUTENV { "putenv", XXPUTE, CM_INV }, /* PUTENV */ #endif /* NOPUTENV */ #endif /* UNIX */ { "pwd", XXPWD, 0 }, /* Print Working Directory */ { "q", XXQUI, CM_INV|CM_ABR }, /* Invisible synonym for QUIT */ #ifndef NOXFER { "query", XXRQUE,CM_INV }, /* (= REMOTE QUERY) */ #endif /* NOXFER */ { "quit", XXQUI, 0 }, /* QUIT from program = EXIT */ #ifndef NOXFER { "r", XXREC, CM_INV|CM_ABR }, /* Inv synonym for RECEIVE */ #endif /* NOXFER */ #ifndef NOXFER { "rasg", XXRASG, CM_INV }, /* REMOTE ASSIGN */ { "rassign", XXRASG, CM_INV }, /* ditto */ { "rcd", XXRCWD, CM_INV }, /* REMOTE CD */ { "rcdup", XXRCDUP,CM_INV }, /* REMOTE CD */ { "rcopy", XXRCPY, CM_INV }, /* REMOTE COPY */ { "rcwd", XXRCWD, CM_INV }, /* REMOTE CWD */ { "rdelete", XXRDEL, CM_INV }, /* REMOTE DELETE */ { "rdirectory", XXRDIR, CM_INV }, /* REMODE DIRECTORY */ #endif /* NOXFER */ #ifndef NOSPL { "read", XXREA, 0 }, /* READ a line from a file */ #else { "read", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOXFER { "receive", XXREC, 0 }, /* RECEIVE files */ #endif /* NOXFER */ #ifndef NODIAL { "red", XXRED, CM_INV|CM_ABR|CM_LOC }, /* Inv syn for REDIAL */ { "redi", XXRED, CM_INV|CM_ABR|CM_LOC }, /* ditto */ { "redial", XXRED, CM_LOC }, /* REDIAL last DIAL number */ #else { "red", XXNOTAV, CM_INV|CM_LOC }, { "redi", XXNOTAV, CM_INV|CM_LOC }, { "redial", XXNOTAV, CM_INV|CM_LOC }, #endif /* NODIAL */ #ifdef CK_REDIR #ifdef OS2 #ifndef NOPUSH { "redirect", XXFUN, CM_INV|CM_PSH }, /* REDIRECT */ #else { "redirect", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOPUSH */ #else /* OS2 */ #ifndef NOPUSH { "redirect", XXFUN, CM_PSH }, /* REDIRECT */ #else { "redirect", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOPUSH */ #endif /* OS2 */ #endif /* CK_REDIR */ #ifdef CK_RECALL { "redo", XXREDO, CM_NOR }, /* REDO */ #else { "redo", XXNOTAV, CM_INV }, #endif /* CK_RECALL */ #ifndef NOXFER #ifdef CK_RESEND { "reget", XXREGET, 0 }, /* REGET */ #else { "reget", XXNOTAV, CM_INV }, #endif /* CK_RESEND */ #endif /* NOXFER */ #ifndef NOSPL { "reinput", XXREI, CM_INV }, /* REINPUT (from INPUT buffer) */ #else { "reinput", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOXFER #ifdef ADDCMD { "rem", XXREM, CM_INV|CM_ABR }, { "remo", XXREM, CM_INV|CM_ABR }, #endif /* ADDCMD */ { "remote", XXREM, 0 }, /* Send REMOTE command to server */ #endif /* NOXFER */ #ifdef ADDCMD { "remove", XXREMV,0 }, /* REMOVE (something from a list) */ #else { "remove", XXNOTAV, CM_INV }, #endif /* ADDCMD */ #ifndef NOFRILLS #ifndef NORENAME { "rename", XXREN, 0 }, /* RENAME a local file */ #else { "rename", XXNOTAV, CM_INV }, #endif /* NORENAME */ { "replay", XXTYP, CM_INV }, /* REPLAY (for now, just type) */ #endif /* NOFRILLS */ #ifndef NOXFER #ifdef CK_RESEND { "rep", XXTYP, CM_INV|CM_ABR }, /* REPLAY abbreviation */ { "reput", XXRSEN, CM_INV }, /* REPUT = RESEND */ { "res", XXRSEN, CM_INV|CM_ABR }, /* RESEND */ { "rese", XXRSEN, CM_INV|CM_ABR }, /* RESEND */ { "resend", XXRSEN, 0 }, /* RESEND */ #else { "reput", XXNOTAV, CM_INV }, { "res", XXNOTAV, CM_INV }, { "rese", XXNOTAV, CM_INV }, { "resend", XXNOTAV, CM_INV }, #endif /* CK_RESEND */ #endif /* NOXFER */ { "reset", XXRESET, CM_INV }, /* RESET */ #ifdef CK_RESEND #ifndef NOSPL { "ret", XXRET, CM_INV|CM_ABR }, #endif /* NOSPL */ #endif /* CK_RESEND */ #ifndef NOXFER { "retrieve", XXRETR, CM_INV }, /* RETRIEVE */ #endif /* NOXFER */ #ifndef NOSPL { "return", XXRET, 0 }, /* RETURN from a function */ #else { "return", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOXFER { "rexit", XXRXIT, CM_INV }, /* REMOTE EXIT */ #endif /* NOXFER */ #ifdef CK_REXX #ifndef NOPUSH { "rexx", XXREXX, CM_PSH }, /* Execute a Rexx command */ #else { "rexx", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOPUSH */ #endif /* CK_REXX */ #ifndef NOXFER { "rhelp", XXRHLP, CM_INV }, /* REMOTE HELP */ { "rhost", XXRHOS, CM_INV }, /* REMOTE HOST */ { "rkermit", XXRKER, CM_INV }, /* REMOTE KERMIT */ #endif /* NOXFER */ #ifdef TCPSOCKET { "rlogin", XXRLOG, CM_LOC }, /* Make an Rlogin connection */ #else { "rlogin", XXNOTAV, CM_INV|CM_LOC }, #endif /* TCPSOCKET */ #ifndef NOFRILLS { "rm", XXDEL, CM_INV }, /* Invisible synonym for delete */ #endif /* NOFRILLS */ #ifdef CK_MKDIR { "rmdir", XXRMDIR, 0 }, /* RMDIR */ #else { "rmdir", XXNOTAV, CM_INV }, #endif /* CK_MKDIR */ #ifndef NOXFER { "rmessage", XXRMSG, CM_INV }, /* REMOTE MESSAGE */ { "rmkdir", XXRMKD, CM_INV }, /* REMOTE MKDIR */ { "rmsg", XXRMSG, CM_INV }, /* REMOTE MESSAGE */ #ifndef NOSPL { "robust", XXROB, CM_INV }, #else { "robust", XXNOTAV, CM_INV }, #endif /* NOSPL */ { "rprint", XXRPRI, CM_INV }, /* REMOTE PRINT */ { "rpwd", XXRPWD, CM_INV }, /* REMOTE PWD */ { "rquery", XXRQUE, CM_INV }, /* REMOTE QUERY */ #endif /* NOXFER */ #ifdef CK_RECALL { "rr", XXREDO, CM_INV|CM_NOR }, #endif /* CK_RECALL */ #ifndef NOXFER { "rrename", XXRREN, CM_INV }, /* REMOTE RENAME */ { "rrmdir", XXRRMD, CM_INV }, /* REMOTE REMDIR */ { "rset", XXRSET, CM_INV }, /* REMOTE SET */ { "rspace", XXRSPA, CM_INV }, /* REMOTE SPACE */ { "rtype", XXRTYP, CM_INV }, /* REMOTE TYPE */ #endif /* NOXFER */ #ifndef NOPUSH { "run", XXSHE, CM_PSH }, /* RUN a program or command */ #else { "run", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOPUSH */ #ifndef NOXFER { "rwho", XXRWHO, CM_INV }, /* REMOTE WHO */ { "s", XXSEN, CM_INV|CM_ABR }, /* Invisible synonym for send */ #endif /* NOXFER */ #ifndef NOSETKEY #ifdef OS2 { "save", XXSAVE, 0 }, /* SAVE something */ #else { "save", XXSAVE, CM_INV }, #endif /* OS2 */ #else { "save", XXNOTAV, CM_INV }, #endif /* NOSETKEY */ #ifndef NOSCRIPT { "sc", XXLOGI, CM_INV|CM_ABR|CM_LOC }, { "scr", XXLOGI, CM_INV|CM_ABR|CM_LOC }, #endif /* NOSCRIPT */ { "screen", XXSCRN, 0 }, /* SCREEN actions */ #ifndef NOSCRIPT { "script", XXLOGI, CM_LOC }, /* Expect-Send-style script line */ #else { "script", XXNOTAV, CM_INV|CM_LOC }, #endif /* NOSCRIPT */ { "search", XXGREP,CM_INV }, /* Synonym for GREP and FIND */ #ifndef NOXFER { "send", XXSEN, 0 }, /* Send (a) file(s) */ #ifndef NOSERVER { "server", XXSER, 0 }, /* Be a SERVER */ #else { "server", XXNOTAV, CM_INV }, #endif /* NOSERVER */ #endif /* NOXFER */ { "set", XXSET, 0 }, /* SET parameters */ #ifndef NOSPL #ifndef NOSEXP { "sexpression", XXSEXP, CM_INV|CM_HLP }, /* SEXPR */ #endif /* NOSEXP */ #ifdef SFTP_BUILTIN { "sftp", XXSFTP, 0 }, /* SFTP */ #endif /* SFTP_BUILTIN */ #ifndef NOSHOW { "sh", XXSHO, CM_INV|CM_ABR }, /* SHOW parameters */ #endif /* NOSHOW */ { "shift", XXSHIFT, 0 }, /* SHIFT args */ #else { "shift", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOSHOW { "show", XXSHO, 0 }, /* SHOW parameters */ #else { "show", XXNOTAV, CM_INV }, #endif /* NOSHOW */ #ifdef NEWFTP { "site", XXSITE, CM_INV }, /* (FTP) SITE */ #endif /* NEWFTP */ #ifdef SSHBUILTIN { "skermit", XXSKRM, 0 }, /* SKERMIT */ #endif /* SSHBUILTIN */ #ifndef NOSPL #ifndef NOFRILLS { "sleep", XXPAU, CM_INV }, /* SLEEP for specified interval */ #endif /* NOFRILLS */ #endif /* NOSPL */ #ifndef NOSPL { "sort", XXSORT, CM_INV }, /* (see ARRAY) */ #else { "sort", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef MAC #ifndef NOFRILLS { "sp", XXSPA, CM_INV|CM_ABR }, { "spa", XXSPA, CM_INV|CM_ABR }, #endif /* NOFRILLS */ { "space", XXSPA, 0 }, /* Show available disk SPACE */ #endif /* MAC */ #ifndef NOFRILLS #ifndef NOPUSH { "spawn", XXSHE, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */ #else { "spawn", XXNOTAV, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */ #endif /* NOPUSH */ #endif /* NOFRILLS */ #ifdef ANYSSH { "ssh", XXSSH, 0 }, #endif /* ANYSSH */ #ifndef NOXFER { "sta", XXSTA, CM_INV|CM_ABR }, { "stat", XXSTA, CM_INV|CM_ABR }, { "statistics", XXSTA, 0 }, /* Display file transfer stats */ #endif /* NOXFER */ { "status", XXSTATUS,0 }, /* Show status of previous command */ #ifndef NOSPL { "stop", XXSTO, 0 }, /* STOP all take files and macros */ { "succeed", XXSUCC, CM_INV }, /* SUCCEED */ #else { "stop", XXNOTAV, CM_INV }, { "succeed", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOFRILLS { "SUPPORT", XXBUG, 0 }, /* Tech support instructions */ #else { "support", XXNOTAV, CM_INV }, #endif /* NOFRILLS */ #ifndef NOJC { "suspend", XXSUS, CM_PSH }, /* SUSPEND C-Kermit (UNIX only) */ #else { "suspend", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOJC */ #ifndef NOSPL { "switch", XXSWIT, 0 }, /* SWITCH */ #else { "switch", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifdef CK_TAPI { "ta", XXTAK, CM_INV|CM_ABR }, /* (because of TAPI) */ #endif /* CK_TAPI */ #ifndef NOFRILLS { "tail", XXTAIL, 0 }, /* Display end of a local file */ #endif /* NOFRILLS */ { "take", XXTAK, 0 }, /* TAKE commands from a file */ #ifdef CK_TAPI { "tapi", XXTAPI, CM_LOC }, /* Microsoft TAPI commands */ #else { "tapi", XXNOTAV, CM_INV|CM_LOC }, #endif /* CK_TAPI */ #ifndef NOFRILLS #ifdef TCPSOCKET { "tel", XXTEL, CM_INV|CM_ABR|CM_LOC }, { "telnet", XXTEL, CM_LOC }, /* TELNET (TCP/IP only) */ { "telopt", XXTELOP, CM_INV }, /* TELOPT (ditto) */ #else { "tel", XXNOTAV, CM_INV|CM_LOC }, { "telnet", XXNOTAV, CM_INV|CM_LOC }, { "telopt", XXNOTAV, CM_INV }, #endif /* TCPSOCKET */ #ifdef OS2 { "terminal", XXTERM, CM_INV|CM_LOC }, /* == SET TERMINAL TYPE */ #else { "terminal", XXTERM, CM_INV }, #endif /* OS2 */ #endif /* NOFRILLS */ #ifndef NOXFER { "text", XXASC, CM_INV }, /* == SET FILE TYPE TEXT */ #endif /* NOXFER */ { "touch", XXTOUC, 0 }, /* TOUCH */ #ifndef NOSPL { "trace", XXTRACE, 0 }, /* TRACE */ #else { "trace", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOCSETS { "translate", XXXLA, 0 }, /* TRANSLATE local file char sets */ #else { "translate", XXNOTAV, CM_INV }, #endif /* NOCSETS */ #ifndef NOXMIT { "transmit", XXTRA, 0 }, /* Send (upload) a file, no protocol */ #else { "transmit", XXNOTAV, CM_INV }, #endif /* NOXMIT */ #ifndef NOFRILLS { "type", XXTYP, 0 }, /* Display a local file */ #endif /* NOFRILLS */ #ifndef NOSPL { "undcl", XXUNDCL, CM_INV }, { "undeclare", XXUNDCL, 0 }, /* UNDECLARE an array */ { "undefine", XXUNDEF, 0 }, /* UNDEFINE a variable or macro */ #else { "undcl", XXNOTAV, CM_INV }, { "undeclare", XXNOTAV, CM_INV }, { "undefine", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifdef NEWFTP { "user", XXUSER, CM_INV }, /* (FTP) USER */ #endif /* NEWFTP */ { "version", XXVER, 0 }, /* VERSION-number display */ #ifdef OS2 { "viewonly", XXVIEW, CM_LOC }, /* VIEWONLY Terminal Mode */ #endif /* OS2 */ { "void", XXVOID, 0 }, /* VOID */ #ifndef NOSPL { "wait", XXWAI, 0 }, /* WAIT */ #else { "wait", XXNOTAV, CM_INV }, #endif /* NOSPL */ { "wdirectory", XXWDIR, CM_INV }, /* Like TOPS-20, reverse chron order */ { "wermit", XXKERMI, CM_INV }, #ifndef NOXFER { "where", XXWHERE, 0 }, /* WHERE (did my file go?) */ #endif /* NOXFER */ #ifndef NOSPL { "while", XXWHI, 0 }, /* WHILE loop */ #else { "while", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef OS2 #ifndef MAC #ifndef NOFRILLS { "who", XXWHO, CM_PSH }, /* WHO's logged in? */ #endif /* NOFRILLS */ #endif /* MAC */ #endif /* OS2 */ #ifndef NOHELP { "wildcards", XXWILD,CM_INV|CM_HLP }, /* Wildcard syntax */ #endif /* NOHELP */ #ifndef NOSPL { "wr", XXWRI, CM_INV|CM_ABR }, { "wri", XXWRI, CM_INV|CM_ABR }, { "writ", XXWRI, CM_INV|CM_ABR }, { "write", XXWRI, 0 }, /* WRITE characters to a file */ { "write-line", XXWRL, CM_INV }, /* WRITE a line to a file */ { "writeln", XXWRL, CM_INV }, /* Pascalisch synonym for write-line */ #else { "wr", XXNOTAV, CM_INV }, { "wri", XXNOTAV, CM_INV }, { "writ", XXNOTAV, CM_INV }, { "write", XXNOTAV, CM_INV }, { "write-line", XXNOTAV, CM_INV }, { "writeln", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOFRILLS { "xecho", XXXECH,0 }, /* XECHO */ #endif /* NOFRILLS */ #ifndef NOSPL { "xif", XXIFX, CM_INV }, /* Extended IF command (obsolete) */ #else { "xif", XXNOTAV, CM_INV }, #endif /* NOSPL */ #ifndef NOCSETS { "xlate", XXXLA, CM_INV }, /* Synonym for TRANSLATE */ #else { "xlate", XXNOTAV, CM_INV }, #endif /* NOCSETS */ #ifndef NOXMIT { "xm", XXTRA, CM_INV|CM_ABR }, /* Avoid conflict with XMESSAGE */ #else { "xm", XXNOTAV, CM_INV|CM_ABR }, /* Synonym for TRANSMIT */ #endif /* NOXMIT */ { "xmessage", XXXMSG, 0 }, /* Print debugging message */ #ifndef NOXMIT { "xmit", XXTRA, CM_INV }, /* Synonym for TRANSMIT */ #else { "xmit", XXNOTAV, CM_INV }, #endif /* NOXMIT */ #ifndef OS2 #ifndef NOJC { "z", XXSUS, CM_INV|CM_PSH }, /* Synonym for SUSPEND */ #else { "z", XXNOTAV, CM_INV|CM_PSH }, #endif /* NOJC */ #endif /* OS2 */ #ifndef NOSPL { "{", XXMACRO, CM_INV }, /* Immediate macro */ #endif /* NOSPL */ { "", 0, 0 } }; int ncmd = (sizeof(cmdtab) / sizeof(struct keytab)) - 1; /* NOTE: Tokens must also be entered above into cmdtab[]. */ char toktab[] = { #ifndef NOPUSH '!', /* Shell escape */ #endif /* NOPUSH */ '#', /* Comment */ #ifndef NOSPL '(', /* S-Expression */ '.', /* Assignment */ #endif /* NOSPL */ ';', /* Comment */ #ifndef NOSPL ':', /* Label */ #endif /* NOSPL */ #ifndef NOPUSH #ifdef CK_REDIR '<', /* REDIRECT */ #endif /* CK_REDIR */ '@', /* DCL escape */ #endif /* NOPUSH */ #ifdef CK_RECALL '^', /* Command recall */ #endif /* CK_RECALL */ #ifndef NOSPL '{', /* Immediate macro */ #endif /* NOSPL */ '\0' /* End of this string */ }; int xxdot = 0; /* Used with "." token */ struct keytab yesno[] = { /* Yes/No keyword table */ { "no", 0, 0 }, { "ok", 1, 0 }, { "yes", 1, 0 } }; int nyesno = (sizeof(yesno) / sizeof(struct keytab)); /* Save keyword table */ struct keytab savtab[] = { #ifdef OS2 { "command", XSCMD, 0 }, #else #ifdef CK_RECALL { "command", XSCMD, 0 }, #endif /* CK_RECALL */ #endif /* OS2 */ #ifndef NOSETKEY { "keymap", XSKEY, 0 }, #endif /* NOSETKEY */ #ifdef OS2 { "terminal", XSTERM, 0 }, #endif /* OS2 */ { "", 0, 0 } }; int nsav = (sizeof(savtab) / sizeof(struct keytab)) - 1; /* Parameter keyword table */ struct keytab prmtab[] = { { "alarm", XYALRM, 0 }, #ifdef COMMENT /* SET ANSWER not implemented yet */ #ifndef NODIAL { "answer", XYANSWER,0 }, #endif /* NODIAL */ #endif /* COMMENT */ { "ask-timer", XYTIMER, 0 }, #ifndef NOXFER { "attributes", XYATTR, 0 }, #endif /* NOXFER */ #ifdef CK_AUTHENTICATION { "authentication", XYAUTH, 0 }, #else /* CK_AUTHENTICATION */ #ifdef CK_SSL { "authentication", XYAUTH, 0 }, #endif /* CK_SSL */ #endif /* CK_AUTHENTICATION */ { "b", XYBACK, CM_INV|CM_ABR|CM_PSH }, { "ba", XYBACK, CM_INV|CM_ABR|CM_PSH }, #ifdef VMS { "background", XYBACK, CM_INV|CM_PSH }, { "batch", XYBACK, CM_PSH }, #else { "background", XYBACK, CM_PSH }, { "batch", XYBACK, CM_INV|CM_PSH }, #endif /* VMS */ #ifndef NOLOCAL { "baud", XYSPEE, CM_INV|CM_LOC }, #endif /* NOLOCAL */ { "bell", XYBELL, 0 }, #ifndef NOXFER { "block-check", XYCHKT, 0 }, #endif /* NOXFER */ #ifdef OS2 #ifdef BPRINT { "bprinter", XYBDCP, CM_INV }, #endif /* BPRINT */ #endif /* OS2 */ #ifdef BROWSER { "browser", XYBROWSE,CM_PSH|CM_LOC }, #endif /* BROWSER */ #ifndef NOXFER #ifdef DYNAMIC { "buffers", XYBUF, 0 }, #endif /* DYNAMIC */ #endif /* NOXFER */ #ifndef NOLOCAL #ifndef MAC { "carrier-watch", XYCARR, CM_LOC }, #endif /* MAC */ #endif /* NOLOCAL */ #ifndef NOSPL { "case", XYCASE, 0 }, #endif /* NOSPL */ { "cd", XYCD, 0 }, #ifndef NOXFER { "cl", XYCLEAR, CM_INV|CM_ABR }, { "cle", XYCLEAR, CM_INV|CM_ABR }, { "clea", XYCLEAR, CM_INV|CM_ABR }, { "clear", XYCLEAR, CM_INV|CM_ABR }, { "clear-channel", XYCLEAR, 0 }, { "clearchannel", XYCLEAR, CM_INV }, #endif /* NOXFER */ #ifndef NOLOCAL { "close-on-disconnect", XYDISC, CM_INV|CM_LOC }, #endif /* NOLOCAL */ { "cmd", XYCMD, CM_INV }, { "command", XYCMD, 0 }, #ifdef CK_SPEED { "con", XYQCTL, CM_INV|CM_ABR }, #endif /* CK_SPEED */ { "console", XYCMD, CM_INV }, #ifdef CK_SPEED { "control-character",XYQCTL, 0 }, #endif /* CK_SPEED */ #ifndef NOSPL { "count", XYCOUN, 0 }, #endif /* NOSPL */ #ifndef NOXFER { "d", XYDELA, CM_INV|CM_ABR }, { "de", XYDELA, CM_INV|CM_ABR }, #endif /* NOXFER */ { "debug", XYDEBU, 0 }, #ifdef VMS { "default", XYDFLT, 0 }, #else #ifndef MAC { "default", XYDFLT, CM_INV }, #endif /* MAC */ #endif /* VMS */ #ifndef NOXFER { "delay", XYDELA, 0 }, { "destination", XYDEST, 0 }, #endif /* NOXFER */ #ifndef NODIAL { "di", XYDIAL, CM_INV|CM_ABR|CM_LOC }, { "dia", XYDIAL, CM_INV|CM_ABR|CM_LOC }, { "dial", XYDIAL, CM_LOC }, #endif /* NODIAL */ #ifdef OS2 { "dialer", XYDLR, CM_INV }, #endif /* OS2 */ #ifndef NOLOCAL { "disconnect", XYDISC, CM_LOC }, { "duplex", XYDUPL, CM_LOC }, #endif /* NOLOCAL */ #ifndef NOPUSH #ifndef NOFRILLS { "editor", XYEDIT, CM_PSH }, #endif /* NOFRILLS */ #endif /* NOPUSH */ #ifdef CK_CTRLZ { "eof", XYEOF, CM_INV }, #endif /* CK_CTRLZ */ #ifndef NOLOCAL { "escape-character", XYESC, CM_LOC }, #endif /* NOLOCAL */ #ifndef NOSPL { "evaluate", XYEVAL, CM_INV }, #endif /* NOSPL */ { "exit", XYEXIT, 0 }, #ifndef NOXFER #ifdef CK_XYZ #ifndef NOPUSH #ifndef XYZ_INTERNAL { "external-protocol",XYEXTRN, 0 }, #endif /* XYZ_INTERNAL */ #endif /* NOPUSH */ #endif /* CK_XYZ */ { "f-ack-bug", XYFACKB, CM_INV }, { "f-ack-path", XYFACKP, CM_INV }, #endif /* NOXFER */ { "file", XYFILE, 0 }, { "fl", XYFLOW, CM_INV|CM_ABR }, #ifndef NOSPL { "flag", XYFLAG, 0 }, #endif /* NOSPL */ #ifdef TCPSOCKET #ifndef SYSFTP #ifndef NOFTP { "ft", XYFTPX, CM_INV|CM_ABR }, { "ftp", XYFTPX, 0 }, #endif /* NOFTP */ #endif /* SYSFTP */ #endif /* TCPSOCKET */ #ifdef BROWSER { "ftp-client", XYFTP, CM_PSH }, #endif /* BROWSER */ { "flow-control", XYFLOW, 0 }, #ifndef NOSPL { "function", XYFUNC, 0 }, #endif /* NOSPL */ #ifdef NEWFTP { "get-put-remote", XYGPR, 0 }, #endif /* NEWFTP */ #ifdef KUI { "gui", XYGUI, 0 }, #endif /* KUI */ { "handshake", XYHAND, 0 }, { "hints", XYHINTS, 0 }, #ifdef NETCONN { "host", XYHOST, CM_LOC }, #endif /* NETCONN */ #ifndef NOSPL { "i", XYINPU, CM_INV|CM_ABR }, #endif /* NOSPL */ #ifdef IKSD { "iks", XYIKS, 0 }, #else { "iks", XYIKS, CM_INV }, #endif /* IKSD */ #ifndef NOSPL { "in", XYINPU, CM_INV|CM_ABR }, #endif /* NOSPL */ #ifndef NOXFER { "incomplete", XYIFD, CM_INV }, #endif /* NOXFER */ #ifndef NOSPL { "input", XYINPU, 0 }, #endif /* NOSPL */ #ifndef NOSETKEY { "key", XYKEY, 0 }, #endif /* NOSETKEY */ { "l", XYLINE, CM_INV|CM_ABR }, #ifndef NOCSETS { "language", XYLANG, 0 }, #endif /* NOCSETS */ #ifndef NOLOCAL { "line", XYLINE, CM_LOC }, { "local-echo", XYLCLE, CM_INV|CM_LOC }, #endif /* NOLOCAL */ #ifdef LOCUS { "locus", XYLOCUS, 0 }, #endif /* LOCUS */ #ifndef NOSPL { "login", XYLOGIN, CM_LOC }, #endif /* NOSPL */ #ifndef NOSPL { "macro", XYMACR, 0 }, #endif /* NOSPL */ { "match", XYMATCH, 0 }, #ifdef COMMENT #ifdef VMS { "messages", XYMSGS, 0 }, #endif /* VMS */ #endif /* COMMENT */ #ifndef NODIAL { "modem", XYMODM, CM_LOC }, #endif /* NODIAL */ #ifndef NOLOCAL #ifdef OS2MOUSE { "mouse", XYMOUSE, 0 }, #endif /* OS2MOUSE */ #endif /* NOLOCAL */ #ifdef OS2 { "mskermit", XYMSK, 0 }, #endif /* OS2 */ #ifdef NETCONN { "network", XYNET, CM_LOC }, #endif /* NETCONN */ #ifndef NOSPL { "output", XYOUTP, 0 }, #endif /* NOSPL */ { "options", XYOPTS, 0 }, { "pause", XYSLEEP, CM_INV }, #ifdef ANYX25 #ifndef IBMX25 { "pad", XYPAD, CM_LOC }, #endif /* IBMX25 */ #endif /* ANYX25 */ { "parity", XYPARI, 0 }, #ifndef NOLOCAL #ifdef OS2 { "port", XYLINE, CM_LOC }, #else { "port", XYLINE, CM_INV|CM_LOC }, #endif /* OS2 */ #endif /* NOLOCAL */ #ifndef NOFRILLS { "pr", XYPROM, CM_INV|CM_ABR }, { "printer", XYPRTR, 0 }, #endif /* NOFRILLS */ #ifdef OS2 { "priority", XYPRTY, 0 }, #endif /* OS2 */ #ifdef CK_SPEED { "prefixing", XYPREFIX, 0 }, #endif /* CK_SPEED */ #ifndef NOFRILLS { "prompt", XYPROM, 0 }, #endif /* NOFRILLS */ #ifndef NOXFER { "protocol", XYPROTO, 0 }, #endif /* NOXFER */ { "q", XYQUIE, CM_INV|CM_ABR }, #ifndef NOXFER { "q8flag", XYQ8FLG, CM_INV }, #endif /* NOXFER */ #ifdef QNX { "qnx-port-lock", XYQNXPL, 0 }, #else { "qnx-port-lock", XYQNXPL, CM_INV }, #endif /* QNX */ { "quiet", XYQUIE, 0 }, #ifndef NOXFER { "rec", XYRECV, CM_INV|CM_ABR }, { "receive", XYRECV, 0 }, { "recv", XYRECV, CM_INV }, #endif /* NOXFER */ { "reliable", XYRELY, 0 }, { "rename", XY_REN, 0 }, #ifndef NOXFER { "repeat", XYREPT, 0 }, { "retry-limit", XYRETR, 0 }, #endif /* NOXFER */ #ifdef CKROOT { "root", XYROOT, 0 }, #endif /* CKROOT */ #ifndef NOSCRIPT { "script", XYSCRI, CM_LOC }, #endif /* NOSCRIPT */ #ifndef NOXFER { "send", XYSEND, 0 }, #ifndef NOLOCAL #ifndef NOSERVER { "ser", XYSERV, CM_INV|CM_ABR }, #endif /* NOSERVER */ #endif /* NOXFER */ { "serial", XYSERIAL,CM_LOC }, #endif /* NOLOCAL */ #ifndef NOSERVER { "server", XYSERV, 0 }, #endif /* NOSERVER */ #ifdef SESLIMIT #ifndef NOLOCAL { "session-l", XYSESS, CM_INV|CM_ABR }, #endif /* NOLOCAL */ { "session-limit", XYLIMIT, CM_INV|CM_LOC }, /* Session Limit */ #endif /* SESLIMIT */ #ifndef NOLOCAL { "session-log", XYSESS, CM_LOC }, #endif /* NOLOCAL */ #ifndef NOSPL #ifndef NOSEXP { "sexpression", XYSEXP, CM_INV }, #endif /* NOSEXP */ #endif /* NOSPL */ { "sleep", XYSLEEP, 0 }, #ifndef NOLOCAL { "speed", XYSPEE, CM_LOC }, #endif /* NOLOCAL */ #ifdef ANYSSH { "ssh", XYSSH, 0 }, #endif /* ANYSSH */ #ifndef NOSPL { "startup-file", XYSTARTUP, CM_INV }, #endif /* NOSPL */ #ifndef NOLOCAL #ifdef HWPARITY { "stop-bits", XYSTOP, CM_LOC }, #else #ifdef TN_COMPORT { "stop-bits", XYSTOP, CM_LOC }, #endif /* TN_COMPORT */ #endif /* HWPARITY */ #endif /* NOLOCAL */ #ifndef NOXFER #ifdef STREAMING { "streaming", XYSTREAM, 0 }, #endif /* STREAMING */ #endif /* NOXFER */ #ifndef NOJC { "suspend", XYSUSP, CM_PSH }, #endif /* NOJC */ #ifdef CKSYSLOG { "syslog", XYSYSL, CM_INV }, #endif /* CKSYSLOG */ { "take", XYTAKE, 0 }, #ifdef CK_TAPI { "tapi", XYTAPI, CM_LOC }, #endif /* CK_TAPI */ #ifndef NOTCPOPTS #ifdef TCPSOCKET { "tcp", XYTCP, CM_LOC }, #endif /* TCPSOCKET */ #endif /* NOTCPOPTS */ #ifdef TNCODE { "tel", XYTEL, CM_INV|CM_ABR }, { "telnet", XYTEL, 0 }, { "telopt", XYTELOP, 0 }, #endif /* TNCODE */ #ifndef NOSPL { "temp-directory", XYTMPDIR,0 }, #endif /* NOSPL */ #ifndef NOLOCAL { "terminal", XYTERM, CM_LOC }, #endif /* NOLOCAL */ #ifdef OS2 { "title", XYTITLE, CM_LOC }, #endif /* OS2 */ #ifdef TLOG { "transaction-log", XYTLOG, 0 }, #endif /* TLOG */ #ifndef NOXFER { "transfer", XYXFER, 0 }, #endif /* NOXFER */ #ifndef NOXMIT { "transmit", XYXMIT, 0 }, #endif /* NOXMIT */ #ifndef NOXFER #ifndef NOCSETS { "unknown-char-set", XYUNCS, 0 }, #endif /* NOCSETS */ #ifndef NOSPL { "variable-evaluation", XYVAREV, CM_INV }, #endif /* NOSPL */ #endif /* NOXFER */ { "wait", XYSLEEP, CM_INV }, #ifndef NOPUSH #ifdef UNIX { "wildcard-expansion", XYWILD, 0 }, #endif /* UNIX */ #endif /* NOPUSH */ #ifdef NT { "w", XYWIND, CM_INV|CM_ABR }, { "wi", XYWIND, CM_INV|CM_ABR }, { "win", XYWIND, CM_INV|CM_ABR }, #endif /* NT */ { "window-size", XYWIND, 0 }, #ifdef NT { "win95", XYWIN95, 0 }, #endif /* NT */ #ifdef ANYX25 { "x.25", XYX25, CM_LOC }, { "x25", XYX25, CM_INV|CM_LOC }, #endif /* ANYX25 */ { "xfer", XYXFER, CM_INV }, #ifndef NOXMIT { "xmit", XYXMIT, CM_INV }, #endif /* NOXMIT */ { "", 0, 0 } }; int nprm = (sizeof(prmtab) / sizeof(struct keytab)) - 1; /* How many */ struct keytab scntab[] = { /* Screen commands */ { "clear", SCN_CLR, 0 }, { "cleol", SCN_CLE, 0 }, { "move-to", SCN_MOV, 0 } }; int nscntab = (sizeof(scntab) / sizeof(struct keytab)); /* How many */ #ifdef ANYSSH /* SSH command table */ #ifdef SSHBUILTIN int ssh_pf_lcl_n = 0, ssh_pf_rmt_n = 0; struct ssh_pf ssh_pf_lcl[32] = { 0, NULL, 0 }; /* SSH Port Forwarding */ struct ssh_pf ssh_pf_rmt[32] = { 0, NULL, 0 }; /* structs... */ extern char * ssh_hst, * ssh_cmd, * ssh_prt; extern int ssh_ver, ssh_xfw; char * ssh_tmpuid = NULL, *ssh_tmpcmd = NULL, *ssh_tmpport = NULL, * ssh_tmpstr = NULL; int sshk_type = SSHKT_2D, /* SSH KEY CREATE /TYPE:x */ sshk_bits = 1024, /* SSH KEY CREATE /BITS:n */ sshk_din = SKDF_OSSH, /* SSH KEY DISPLAY /IN-FORMAT: */ sshk_dout = SKDF_OSSH; /* SSH KEY DISPLAY /OUT-FORMAT: */ char * sshk1_comment = NULL, /* SSH V1 COMMENT */ * sshkp_old = NULL, /* Old key passphrase */ * sshkp_new = NULL, /* New key passphrase */ * sshkc_pass = NULL, /* KEY CREATE /PASS:xxx */ * sshkc_comm = NULL, /* KEY CREATE /V1-RSA-COMMENT:xxx */ * sshd_file = NULL, /* DISPLAY file */ * sshk_file = NULL; /* SSH CREATE KEY file */ static struct keytab sshclr[] = { { "local-port-forward", SSHC_LPF, 0 }, { "remote-port-forward", SSHC_RPF, 0 }, { "", 0, 0 } }; static int nsshclr = (sizeof(sshclr) / sizeof(struct keytab)) - 1; struct keytab sshopnsw[] = { { "/command", SSHSW_CMD, CM_ARG }, { "/password", SSHSW_PWD, CM_ARG }, { "/subsystem", SSHSW_SUB, CM_ARG }, { "/user", SSHSW_USR, CM_ARG }, { "/version", SSHSW_VER, CM_ARG }, { "/x11-forwarding", SSHSW_X11, CM_ARG }, { "", 0, 0 } }; int nsshopnsw = (sizeof(sshopnsw) / sizeof(struct keytab)) - 1; static struct keytab sshkwtab[] = { { "add", XSSH_ADD, 0 }, { "agent", XSSH_AGT, 0 }, { "clear", XSSH_CLR, 0 }, { "forward-local-port", XSSH_FLP, CM_INV }, { "forward-remote-port", XSSH_FRP, CM_INV }, { "key", XSSH_KEY, 0 }, { "open", XSSH_OPN, 0 }, { "v2", XSSH_V2, 0 }, { "", 0, 0 } }; static int nsshcmd = (sizeof(sshkwtab) / sizeof(struct keytab)) - 1; static struct keytab ssh2tab[] = { { "rekey", XSSH2_RKE, 0 }, { "", 0, 0 } }; static int nssh2tab = (sizeof(ssh2tab) / sizeof(struct keytab)); static struct keytab addfwd[] = { /* SET SSH ADD command table */ { "local-port-forward", SSHF_LCL, 0 }, { "remote-port-forward", SSHF_RMT, 0 }, { "", 0, 0 } }; static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1; static struct keytab sshagent[] = { /* SET SSH AGENT command table */ { "add", SSHA_ADD, 0 }, { "delete", SSHA_DEL, 0 }, { "list", SSHA_LST, 0 }, { "", 0, 0 } }; static int nsshagent = (sizeof(sshagent) / sizeof(struct keytab)) - 1; static struct keytab sshagtsw[] = { /* SET SSH AGENT LIST switch table */ { "/fingerprint", SSHASW_FP, 0 }, { "", 0, 0 } }; static int nsshagtsw = (sizeof(sshagtsw) / sizeof(struct keytab)) - 1; static struct keytab sshkey[] = { /* SET SSH KEY command table */ { "change-passphrase", SSHK_PASS, 0 }, { "create", SSHK_CREA, 0 }, { "display", SSHK_DISP, 0 }, { "v1", SSHK_V1, 0 }, { "", 0, 0 } }; static int nsshkey = (sizeof(sshkey) / sizeof(struct keytab)) - 1; static struct keytab sshkv1[] = { /* SET SSH KEY V1 command table */ { "set-comment", 1, 0 } }; static struct keytab sshkpsw[] = { /* SET SSH KEY PASSPHRASE table */ { "/new-passphrase", 2, CM_ARG }, { "/old-passphrase", 1, CM_ARG } }; static struct keytab sshkcrea[] = { /* SSH KEY CREATE table */ { "/bits", SSHKC_BI, CM_ARG }, { "/passphrase", SSHKC_PP, CM_ARG }, { "/type", SSHKC_TY, CM_ARG }, { "/v1-rsa-comment", SSHKC_1R, CM_ARG } }; static int nsshkcrea = (sizeof(sshkcrea) / sizeof(struct keytab)); static struct keytab sshkcty[] = { /* SSH KEY CREATE /TYPE:xxx */ { "srp", SSHKT_SRP, 0 }, { "v1-rsa", SSHKT_1R, 0 }, { "v2-dsa", SSHKT_2D, 0 }, { "v2-rsa", SSHKT_2R, 0 } }; static int nsshkcty = (sizeof(sshkcty) / sizeof(struct keytab)); static struct keytab sshdswi[] = { /* SET SSH KEY DISPLAY /switches */ { "/format", SSHKD_OUT, CM_ARG } }; static int nsshdswi = (sizeof(sshdswi) / sizeof(struct keytab)); #ifdef COMMENT static struct keytab sshdifmt[] = { /* SSH KEY DISPLAY /IN-FORMAT: */ { "openssh", SKDF_OSSH, 0 }, { "ssh.com", SKDF_SSHC, 0 } }; static int nsshdifmt = (sizeof(sshdifmt) / sizeof(struct keytab)); #endif /* COMMENT */ static struct keytab sshdofmt[] = { /* SSH KEY DISPLAY /IN-FORMAT: */ { "fingerprint", SKDF_FING, 0 }, { "ietf", SKDF_IETF, 0 }, { "openssh", SKDF_OSSH, 0 }, { "ssh.com", SKDF_SSHC, 0 } }; static int nsshdofmt = (sizeof(sshdofmt) / sizeof(struct keytab)); static struct keytab sshkermit[] = { /* SKERMIT */ { "open", SKRM_OPN, 0 } }; static int nsshkermit = (sizeof(sshkermit) / sizeof(struct keytab)); struct keytab sshkrmopnsw[] = { { "/password", SSHSW_PWD, CM_ARG }, { "/user", SSHSW_USR, CM_ARG }, { "/version", SSHSW_VER, CM_ARG }, { "", 0, 0 } }; int nsshkrmopnsw = (sizeof(sshkrmopnsw) / sizeof(struct keytab)) - 1; #endif /* SSHBUILTIN */ #ifdef SFTP_BUILTIN static struct keytab sftpkwtab[] = { /* SFTP */ { "cd", SFTP_CD, 0 }, { "chgrp", SFTP_CHGRP, 0 }, { "chmod", SFTP_CHMOD, 0 }, { "chown", SFTP_CHOWN, 0 }, { "delete", SFTP_RM, 0 }, { "dir", SFTP_DIR, 0 }, { "get", SFTP_GET, 0 }, { "mkdir", SFTP_MKDIR, 0 }, { "open", SFTP_OPN, 0 }, { "put", SFTP_PUT, 0 }, { "pwd", SFTP_PWD, 0 }, { "rename", SFTP_REN, 0 }, { "rm", SFTP_RM, CM_INV }, { "rmdir", SFTP_RMDIR, 0 }, { "symlink", SFTP_LINK, 0 }, { "version", SFTP_VER, 0 } }; static int nsftpkwtab = (sizeof(sftpkwtab) / sizeof(struct keytab)); #endif /* SFTP_BUILTIN */ #endif /* ANYSSH */ #ifdef NETCONN struct keytab netkey[] = { /* SET NETWORK table */ { "directory", XYNET_D, 0 }, { "type", XYNET_T, 0 } }; int nnetkey = (sizeof(netkey) / sizeof(struct keytab)); struct keytab netcmd[] = { /* These are the network types. */ #ifdef NETCMD { "command", NET_CMD, CM_INV }, /* Command */ #endif /* NETCMD */ #ifdef DECNET /* DECnet / PATHWORKS */ { "decnet", NET_DEC, 0 }, #endif /* DECNET */ #ifdef NETDLL { "dll", NET_DLL, CM_INV }, /* DLL to be loaded */ #endif /* NETDLL */ #ifdef NETFILE { "file", NET_FILE, CM_INV }, /* FILE (real crude) */ #endif /* NETFILE */ #ifdef NPIPE /* Named Pipes */ { "named-pipe", NET_PIPE, 0 }, #endif /* NPIPE */ #ifdef CK_NETBIOS { "netbios", NET_BIOS, 0 }, /* NETBIOS */ #endif /* CK_NETBIOS */ #ifdef DECNET /* DECnet / PATHWORKS (alias) */ { "pathworks", NET_DEC, CM_INV }, #endif /* DECNET */ #ifdef NETCMD { "pipe", NET_CMD, 0 }, /* Pipe */ #endif /* NETCMD */ #ifdef NETPTY { "pseudoterminal",NET_PTY, 0 }, /* Pseudoterminal */ #endif /* NETPTY */ #ifdef NETPTY { "pty", NET_PTY, CM_INV }, /* Inv syn for pseudoterm */ #endif /* NETPTY */ #ifdef SSHBUILTIN { "ssh", NET_SSH, 0 }, #endif /* SSHBUILTIN */ #ifdef SUPERLAT { "superlat", NET_SLAT, 0 }, /* Meridian Technologies' SuperLAT */ #endif /* SUPERLAT */ #ifdef TCPSOCKET /* TCP/IP sockets library */ { "tcp/ip", NET_TCPB, 0 }, #endif /* TCPSOCKET */ #ifdef SUPERLAT { "tes32", NET_SLAT, 0 }, /* Emulux TES32 */ #endif /* SUPERLAT */ #ifdef ANYX25 /* X.25 */ #ifdef SUNX25 { "x", NET_SX25, CM_INV|CM_ABR }, { "x.25", NET_SX25, 0 }, { "x25", NET_SX25, CM_INV }, #else #ifdef STRATUSX25 { "x", NET_VX25, CM_INV|CM_ABR }, { "x.25", NET_VX25, 0 }, { "x25", NET_VX25, CM_INV }, #endif /* STRATUSX25 */ #endif /* SUNX25 */ #ifdef IBMX25 { "x", NET_IX25, CM_INV|CM_ABR }, { "x.25", NET_IX25, CM_INV }, { "x25", NET_IX25, CM_INV }, #endif /* IBMX25 */ #ifdef HPX25 { "x", NET_IX25, CM_INV|CM_ABR }, { "x.25", NET_IX25, 0 }, { "x25", NET_IX25, CM_INV }, #endif /* HPX25 */ #endif /* ANYX25 */ { "", 0, 0 } }; int nnets = (sizeof(netcmd) / sizeof(struct keytab)); #ifndef NOTCPOPTS #ifdef TCPSOCKET /* TCP options */ struct keytab tcpopt[] = { { "address", XYTCP_ADDRESS, 0 }, #ifdef CK_DNS_SRV { "dns-service-records", XYTCP_DNS_SRV, 0 }, #endif /* CK_DNS_SRV */ #ifdef SO_DONTROUTE { "dontroute", XYTCP_DONTROUTE, 0 }, #endif /* SO_DONTROUTE */ #ifndef NOHTTP { "http-proxy", XYTCP_HTTP_PROXY, 0 }, #endif /* NOHTTP */ #ifdef SO_KEEPALIVE { "keepalive", XYTCP_KEEPALIVE, 0 }, #endif /* SO_KEEPALIVE */ #ifdef SO_LINGER { "linger", XYTCP_LINGER, 0 }, #endif /* SO_LINGER */ #ifdef TCP_NODELAY { "nagle", XYTCP_NAGLE, CM_INV }, { "nodelay", XYTCP_NODELAY, 0 }, #endif /* TCP_NODELAY */ { "reverse-dns-lookup", XYTCP_RDNS, 0 }, #ifdef SO_RCVBUF { "recvbuf", XYTCP_RECVBUF, 0 }, #endif /* SO_RCVBUF */ #ifdef SO_SNDBUF { "sendbuf", XYTCP_SENDBUF, 0 }, #endif /* SO_SNDBUF */ #ifdef NT #ifdef CK_SOCKS { "socks-server", XYTCP_SOCKS_SVR, 0 }, #endif /* CK_SOCKS */ #endif /* NT */ #ifdef VMS #ifdef DEC_TCPIP { "ucx-port-bug", XYTCP_UCX, 0 }, #endif /* DEC_TCPIP */ #endif /* VMS */ { "",0,0 } }; int ntcpopt = (sizeof(tcpopt) / sizeof(struct keytab)); #endif /* TCPSOCKET */ #endif /* NOTCPOPTS */ #endif /* NETCONN */ #ifdef OS2 /* K95 Manual Chapter Table -- Keep these two tables in sync! */ static char * linktbl[] = { /* Internal links in k95.htm */ "#top", /* 00 */ "#what", /* 01 */ "#install", /* 02 */ "#start", /* 03 */ "#dialer", /* 04 */ "#entries", /* 05 */ "#command", /* 06 */ "#terminal", /* 07 */ "#transfer", /* 08 */ "#hostmode" /* 09 */ }; static struct keytab chaptbl[] = { { "Command-Screen", 6, 0 }, { "Contents", 0, 0 }, { "Dialer-Entries", 5, 0 }, { "File-Transfer", 8, 0 }, { "Getting-Started", 3, 0 }, { "Host-Mode", 9, 0 }, { "Installation", 2, 0 }, { "Terminal-Emulation", 7, 0 }, { "Using-The-Dialer", 4, 0 }, { "What-Is-K95", 1, 0 }, { "", 0, 0 } }; static int nchaptbl = (sizeof(chaptbl) / sizeof(struct keytab) - 1); #endif /* OS2 */ #ifndef NOXFER /* Remote Command Table */ struct keytab remcmd[] = { #ifndef NOSPL { "as", XZASG, CM_INV|CM_ABR }, { "asg", XZASG, CM_INV }, { "assign", XZASG, 0 }, #endif /* NOSPL */ { "cd", XZCWD, 0 }, { "cdup", XZCDU, CM_INV }, { "copy", XZCPY, 0 }, { "cwd", XZCWD, CM_INV }, { "delete", XZDEL, 0 }, { "directory", XZDIR, 0 }, { "e", XZXIT, CM_ABR|CM_INV }, { "erase", XZDEL, CM_INV }, { "exit", XZXIT, 0 }, { "help", XZHLP, 0 }, #ifndef NOPUSH { "host", XZHOS, 0 }, #endif /* NOPUSH */ #ifndef NOFRILLS { "kermit", XZKER, 0 }, { "l", XZLGI, CM_ABR|CM_INV }, { "lo", XZLGI, CM_ABR|CM_INV }, { "log", XZLGI, CM_ABR|CM_INV }, { "login", XZLGI, 0 }, { "logout", XZLGO, 0 }, { "message", XZMSG, 0 }, { "mkdir", XZMKD, 0 }, { "print", XZPRI, 0 }, #endif /* NOFRILLS */ { "pwd", XZPWD, 0 }, #ifndef NOSPL { "query", XZQUE, 0 }, #endif /* NOSPL */ { "rename", XZREN, 0 }, { "rmdir", XZRMD, 0 }, { "set", XZSET, 0 }, { "space", XZSPA, 0 }, #ifndef NOFRILLS { "type", XZTYP, 0 }, { "who", XZWHO, 0 }, #endif /* NOFRILLS */ { "", 0, 0} }; int nrmt = (sizeof(remcmd) / sizeof(struct keytab)) - 1; #endif /* NOXFER */ struct keytab logtab[] = { #ifdef CKLOGDIAL { "connections", LOGM, CM_INV }, { "cx", LOGM, 0 }, #endif /* CKLOGDIAL */ #ifdef DEBUG { "debugging", LOGD, 0 }, #endif /* DEBUG */ { "packets", LOGP, 0 }, #ifndef NOLOCAL { "session", LOGS, 0 }, #endif /* NOLOCAL */ #ifdef TLOG { "transactions", LOGT, 0 }, #endif /* TLOG */ { "", 0, 0 } }; int nlog = (sizeof(logtab) / sizeof(struct keytab)) - 1; struct keytab writab[] = { #ifndef NOSPL { "append-file", LOGW, CM_INV }, #endif /* NOSPL */ { "debug-log", LOGD, 0 }, { "error", LOGE, 0 }, #ifndef NOSPL { "file", LOGW, 0 }, #endif /* NOSPL */ { "packet-log", LOGP, 0 }, { "screen", LOGX, 0 }, #ifndef NOLOCAL { "session-log", LOGS, 0 }, #endif /* NOLOCAL */ { "sys$output", LOGX, CM_INV }, { "t", LOGT, CM_ABR|CM_INV }, /* Because of a typo in */ { "tr", LOGT, CM_ABR|CM_INV }, /* the book... */ { "tra", LOGT, CM_ABR|CM_INV }, { "tran", LOGT, CM_ABR|CM_INV }, { "trans", LOGT, CM_ABR|CM_INV }, { "transa", LOGT, CM_ABR|CM_INV }, { "transac", LOGT, CM_ABR|CM_INV }, { "transact", LOGT, CM_ABR|CM_INV }, { "transacti", LOGT, CM_ABR|CM_INV }, { "transactio", LOGT, CM_ABR|CM_INV }, { "transaction", LOGT, CM_ABR|CM_INV }, { "transaction-log", LOGT, 0 }, { "transactions", LOGT, CM_INV } }; int nwri = (sizeof(writab) / sizeof(struct keytab)); static struct keytab clrtab[] = { /* Keywords for CLEAR command */ #ifndef NOSPL { "alarm", CLR_ALR, 0 }, #ifdef CK_APC { "apc", CLR_APC, 0 }, #endif /* CK_APC */ #ifdef PATTERNS { "binary-patterns", CLR_BIN, 0 }, #endif /* PATTERNS */ { "both", CLR_DEV|CLR_INP, CM_INV }, #endif /* NOSPL */ #ifdef OS2 { "command-screen", CLR_CMD, 0 }, #endif /* OS2 */ #ifndef NOSPL { "device", CLR_DEV, CM_INV|CM_ABR }, { "device-and-input", CLR_DEV|CLR_INP, 0 }, #endif /* NOSPL */ { "device-buffer", CLR_DEV, 0 }, #ifndef NODIAL { "dial-status", CLR_DIA, 0 }, #endif /* NODIAL */ #ifndef NOSPL { "input-buffer", CLR_INP, 0 }, #endif /* NOSPL */ { "keyboard-buffer", CLR_KBD, 0 }, { "send-list", CLR_SFL, 0 }, #ifdef OS2 { "scr", CLR_SCL, CM_INV|CM_ABR }, #endif /* OS2 */ { "screen", CLR_SCR, 0 }, #ifdef OS2 { "scrollback", CLR_SCL, CM_INV }, { "terminal-screen", CLR_TRM, 0 }, #endif /* OS2 */ #ifdef PATTERNS { "text-patterns", CLR_TXT, 0 }, #endif /* PATTERNS */ { "", 0, 0 } }; int nclear = (sizeof(clrtab) / sizeof(struct keytab)) - 1; struct keytab clstab[] = { /* Keywords for CLOSE command */ #ifndef NOSPL { "!read", LOGR, CM_INV }, { "!write", LOGW, CM_INV }, #ifndef NOPUSH #endif /* NOPUSH */ #endif /* NOSPL */ #ifndef NOSPL { "append-file", LOGW, CM_INV }, #endif /* NOSPL */ #ifndef NOLOCAL { "connection", 9999, 0 }, #endif /* NOLOCAL */ #ifdef CKLOGDIAL { "cx-log", LOGM, 0 }, #endif /* CKLOGDIAL */ #ifdef DEBUG { "debug-log", LOGD, 0 }, #endif /* DEBUG */ { "host", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */ { "line", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */ { "p", LOGP, CM_INV|CM_ABR }, { "packet-log", LOGP, 0 }, { "port", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */ #ifndef NOSPL { "read-file", LOGR, 0 }, #endif /* NOSPL */ #ifndef NOLOCAL { "session-log", LOGS, 0 }, #endif /* NOLOCAL */ #ifdef TLOG { "t", LOGT, CM_ABR|CM_INV }, /* Because of a typo in */ { "tr", LOGT, CM_ABR|CM_INV }, /* the book... */ { "tra", LOGT, CM_ABR|CM_INV }, { "tran", LOGT, CM_ABR|CM_INV }, { "trans", LOGT, CM_ABR|CM_INV }, { "transa", LOGT, CM_ABR|CM_INV }, { "transac", LOGT, CM_ABR|CM_INV }, { "transact", LOGT, CM_ABR|CM_INV }, { "transacti", LOGT, CM_ABR|CM_INV }, { "transactio", LOGT, CM_ABR|CM_INV }, { "transaction", LOGT, CM_ABR|CM_INV }, { "transaction-log", LOGT, 0 }, { "transactions", LOGT, CM_INV }, #endif /* TLOG */ #ifndef NOSPL { "write-file", LOGW, 0 }, #endif /* NOSPL */ { "", 0, 0 } }; int ncls = (sizeof(clstab) / sizeof(struct keytab)) - 1; /* SHOW command arguments */ #ifndef NOSHOW struct keytab shotab[] = { #ifndef NOSPL { "alarm", SHALRM, 0 }, { "arg", SHARG, CM_INV|CM_ABR }, { "arguments", SHARG, 0 }, { "args", SHARG, CM_INV }, { "arrays", SHARR, 0 }, #endif /* NOSPL */ #ifndef NOCSETS { "associations", SHASSOC, 0 }, #endif /* NOCSETS */ #ifndef NOXFER { "attributes", SHATT, 0 }, #endif /* NOXFER */ #ifdef CK_AUTHENTICATION { "authentication", SHOAUTH, CM_INV }, #endif /* CK_AUTHENTICATION */ #ifndef NOPUSH #ifdef BROWSER { "browser", SHBROWSE, CM_PSH|CM_LOC }, #endif /* BROWSER */ #endif /* NOPUSH */ { "cd", SHCD, 0 }, { "character-sets", SHCSE, 0 }, { "cmd", SHCMD, CM_INV }, #ifndef NOLOCAL { "com", SHCOM, CM_INV|CM_ABR }, { "comm", SHCOM, CM_INV|CM_ABR }, { "communications", SHCOM, 0 }, #endif /* NOLOCAL */ { "command", SHCMD, 0 }, { "connection", SHCONNX, 0 }, #ifdef CK_SPEED { "control-prefixing", SHCTL, 0 }, #endif /* CK_SPEED */ #ifdef CKLOGDIAL { "cx", SHCONNX, CM_INV }, #endif /* CKLOGDIAL */ #ifndef NOSPL { "count", SHCOU, 0 }, #endif /* NOSPL */ { "d", SHDIA, CM_INV|CM_ABR }, #ifdef VMS { "default", SHDFLT, 0 }, #else { "default", SHDFLT, CM_INV }, #endif /* VMS */ #ifndef NODIAL { "dial", SHDIA, CM_LOC }, #endif /* NODIAL */ { "double/ignore",SHDBL, 0 }, #ifndef NOPUSH #ifndef NOFRILLS { "editor", SHEDIT, CM_PSH }, #endif /* NOFRILLS */ #endif /* NOPUSH */ #ifndef NOLOCAL { "escape", SHESC, CM_LOC }, #endif /* NOLOCAL */ { "exit", SHEXI, 0 }, { "extended-options", SHXOPT, CM_INV }, { "features", SHFEA, 0 }, { "file", SHFIL, 0 }, #ifndef NOLOCAL { "flow-control", SHOFLO, 0 }, #endif /* NOLOCAL */ #ifdef BROWSER { "ftp", SHOFTP, CM_PSH|CM_LOC }, #else #ifndef NOFTP #ifndef SYSFTP #ifdef TCPSOCKET { "ftp", SHOFTP, 0 }, /* (built-in ftp) */ #endif /* TCPSOCKET */ #endif /* SYSFTP */ #endif /* NOFTP */ #endif /* BROWSER */ #ifndef NOSPL { "functions", SHFUN, 0 }, { "globals", SHVAR, 0 }, #endif /* NOSPL */ #ifdef KUI { "gui", SHOGUI, 0 }, #endif /* KUI */ #ifdef CK_RECALL { "history", SHHISTORY, 0 }, #endif /* CK_RECALL */ { "ignore/double",SHDBL, CM_INV }, { "iksd", SHOIKS, CM_INV }, #ifndef NOSPL { "input", SHINP, 0 }, #endif /* NOSPL */ #ifndef NOSETKEY { "k", SHKEY, CM_INV|CM_ABR }, { "key", SHKEY, 0 }, #ifndef NOKVERBS { "kverbs", SHKVB, 0 }, #endif /* NOKVERBS */ #endif /* NOSETKEY */ #ifdef CK_LABELED { "labeled-file-info", SHLBL, 0 }, #endif /* CK_LABELED */ #ifndef NOCSETS { "languages", SHLNG, 0 }, #endif /* NOCSETS */ { "logs", SHLOG, 0 }, #ifndef NOSPL { "macros", SHMAC, 0 }, #endif /* NOSPL */ #ifndef NODIAL { "modem", SHMOD, CM_LOC }, #else { "modem-signals",SHCOM, CM_INV|CM_LOC }, #endif /* NODIAL */ #ifndef NOLOCAL #ifdef OS2MOUSE { "mouse", SHMOU, CM_LOC }, #endif /* OS2MOUSE */ #endif /* NOLOCAL */ #ifdef NETCONN { "network", SHNET, CM_LOC }, #else { "network", SHNET, CM_INV|CM_LOC }, #endif /* NETCONN */ { "options", SHOPTS, 0 }, #ifndef NOSPL { "output", SHOUTP, CM_INV }, #endif /* NOSPL */ #ifdef ANYX25 #ifndef IBMX25 { "pad", SHPAD, CM_LOC }, #endif /* IBMX25 */ #endif /* ANYX25 */ { "parameters", SHPAR, CM_INV }, #ifdef PATTERNS { "patterns", SHOPAT, 0 }, #endif /* PATTERNS */ { "printer", SHPRT, 0 }, #ifdef CK_SPEED { "prefixing", SHCTL, CM_INV }, #endif /* CK_SPEED */ #ifndef NOXFER { "protocol", SHPRO, 0 }, #endif /* NOXFER */ { "rename", SHOREN, 0 }, #ifndef NOSPL { "scripts", SHSCR, CM_LOC }, #endif /* NOSPL */ { "send-list", SHSFL, 0 }, #ifndef NOSERVER { "server", SHSER, 0 }, #endif /* NOSERVER */ #ifndef NOSEXP { "sexpression", SHSEXP, 0 }, #endif /* NOSEXP */ #ifdef ANYSSH { "ssh", SHOSSH, 0 }, #endif /* ANYSSH */ { "stack", SHSTK, 0 }, { "status", SHSTA, 0 }, #ifdef STREAMING { "streaming", SHOSTR, 0 }, #endif /* STREAMING */ #ifndef NOLOCAL #ifdef OS2 { "tabs", SHTAB, CM_INV|CM_LOC }, #endif /* OS2 */ #ifdef CK_TAPI { "tapi", SHTAPI, CM_LOC }, { "tapi-comm", SHTAPI_C, CM_INV|CM_LOC }, { "tapi-location", SHTAPI_L, CM_INV|CM_LOC }, { "tapi-modem", SHTAPI_M, CM_INV|CM_LOC }, #endif /* CK_TAPI */ { "tcp", SHTCP, CM_LOC }, #ifdef TNCODE { "tel", SHTEL, CM_INV|CM_ABR }, { "telnet", SHTEL, 0 }, { "telopt", SHTOPT, 0 }, #endif /* TNCODE */ { "terminal", SHTER, CM_LOC }, #endif /* NOLOCAL */ #ifndef NOXMIT { "tr", SHXMI, CM_INV|CM_ABR }, { "tra", SHXMI, CM_INV|CM_ABR }, { "tran", SHXMI, CM_INV|CM_ABR }, { "trans", SHXMI, CM_INV|CM_ABR }, #endif /* NOXMIT */ #ifndef NOXFER { "transfer", SHOXFER, 0 }, #endif /* NOXFER */ #ifndef NOXMIT { "transmit", SHXMI, 0 }, #endif /* NOXMIT */ #ifdef CK_TRIGGER { "trigger", SHTRIG, CM_LOC }, #endif /* CK_TRIGGER */ #ifndef NOSETKEY #ifndef NOKVERBS #ifdef OS2 { "udk", SHUDK, CM_LOC }, #endif /* OS2 */ #endif /* NOKVERBS */ #endif /* NOSETKEY */ #ifndef NOSPL { "variables", SHBUI, 0 }, #endif /* NOSPL */ #ifndef NOFRILLS { "versions", SHVER, 0 }, #endif /* NOFRILLS */ #ifdef OS2 { "vscrn", SHVSCRN, CM_INV|CM_LOC }, #endif /* OS2 */ { "xfer", SHOXFER, CM_INV }, #ifndef NOXMIT { "xmit", SHXMI, CM_INV }, #endif /* NOXMIT */ { "", 0, 0 } }; int nsho = (sizeof(shotab) / sizeof(struct keytab)) - 1; #endif /* NOSHOW */ #ifdef ANYX25 #ifndef IBMX25 struct keytab padtab[] = { /* PAD commands */ { "clear", XYPADL, 0 }, { "interrupt", XYPADI, 0 }, { "reset", XYPADR, 0 }, { "status", XYPADS, 0 } }; int npadc = (sizeof(padtab) / sizeof(struct keytab)); #endif /* IBMX25 */ #endif /* ANYX25 */ #ifndef NOSERVER static struct keytab kmstab[] = { { "both", 3, 0 }, { "local", 1, 0 }, { "remote", 2, 0 } }; static struct keytab enatab[] = { /* ENABLE commands */ { "all", EN_ALL, 0 }, #ifndef NOSPL { "as", EN_ASG, CM_INV|CM_ABR }, { "asg", EN_ASG, CM_INV }, { "assign", EN_ASG, 0 }, #endif /* NOSPL */ #ifndef datageneral { "bye", EN_BYE, 0 }, #endif /* datageneral */ { "cd", EN_CWD, 0 }, #ifdef ZCOPY { "copy", EN_CPY, 0 }, #endif /* ZCOPY */ { "cwd", EN_CWD, CM_INV }, { "delete", EN_DEL, 0 }, { "directory", EN_DIR, 0 }, { "enable", EN_ENA, CM_INV }, { "exit", EN_XIT, 0 }, { "finish", EN_FIN, 0 }, { "get", EN_GET, 0 }, { "host", EN_HOS, 0 }, { "mail", EN_MAI, 0 }, { "mkdir", EN_MKD, 0 }, { "print", EN_PRI, 0 }, #ifndef NOSPL { "query", EN_QUE, 0 }, #endif /* NOSPL */ { "rename", EN_REN, 0 }, { "retrieve", EN_RET, CM_INV }, { "rmdir", EN_RMD, 0 }, { "send", EN_SEN, 0 }, { "set", EN_SET, 0 }, { "space", EN_SPA, 0 }, { "type", EN_TYP, 0 }, { "who", EN_WHO, 0 } }; static int nena = (sizeof(enatab) / sizeof(struct keytab)); #endif /* NOSERVER */ struct keytab txtbin[] = { { "all", 2, 0 }, { "binary", 1, 0 }, { "text", 0, 0 } }; #ifndef NOXFER static struct keytab sndtab[] = { /* SEND command options */ { "/after", SND_AFT, CM_ARG }, #ifndef NOSPL { "/array", SND_ARR, CM_ARG }, #endif /* NOSPL */ { "/as-name", SND_ASN, CM_ARG }, { "/b", SND_BIN, CM_INV|CM_ABR }, { "/before", SND_BEF, CM_ARG }, { "/binary", SND_BIN, 0 }, #ifdef CALIBRATE { "/c", SND_CMD, CM_INV|CM_ABR }, { "/calibrate", SND_CAL, CM_INV|CM_ARG }, #endif /* CALIBRATE */ { "/command", SND_CMD, CM_PSH }, { "/delete", SND_DEL, 0 }, #ifdef UNIXOROSK { "/dotfiles", SND_DOT, 0 }, #endif /* UNIXOROSK */ { "/except", SND_EXC, CM_ARG }, #ifdef PIPESEND { "/filter", SND_FLT, CM_ARG|CM_PSH }, #endif /* PIPESEND */ { "/filenames", SND_NAM, CM_ARG }, #ifdef CKSYMLINK { "/followlinks", SND_LNK, 0 }, #endif /* CKSYMLINK */ #ifdef VMS { "/image", SND_IMG, 0 }, #else { "/image", SND_BIN, CM_INV }, #endif /* VMS */ #ifdef CK_LABELED { "/labeled", SND_LBL, 0 }, #endif /* CK_LABELED */ { "/larger-than", SND_LAR, CM_ARG }, { "/listfile", SND_FIL, CM_ARG }, #ifndef NOFRILLS { "/mail", SND_MAI, CM_ARG }, #endif /* NOFRILLS */ #ifdef CK_TMPDIR { "/move-to", SND_MOV, CM_ARG }, #endif /* CK_TMPDIR */ { "/nobackupfiles", SND_NOB, 0 }, #ifdef UNIXOROSK { "/nodotfiles", SND_NOD, 0 }, #endif /* UNIXOROSK */ #ifdef CKSYMLINK { "/nofollowlinks", SND_NLK, 0 }, #endif /* CKSYMLINK */ { "/not-after", SND_NAF, CM_ARG }, { "/not-before", SND_NBE, CM_ARG }, { "/pathnames", SND_PTH, CM_ARG }, { "/print", SND_PRI, CM_ARG }, #ifdef CK_XYZ { "/protocol", SND_PRO, CM_ARG }, #else { "/protocol", SND_PRO, CM_ARG|CM_INV }, #endif /* CK_XYZ */ { "/quiet", SND_SHH, 0 }, { "/recover", SND_RES, 0 }, #ifdef RECURSIVE /* Systems where we do recursion */ { "/recursive", SND_REC, 0 }, #else #ifdef VMS /* Systems that do recursion themselves without our assistance */ /* if we give them the right kind of wildcard */ { "/recursive", SND_REC, 0 }, #else #ifdef datageneral { "/recursive", SND_REC, 0 }, #else { "/recursive", SND_REC, CM_INV }, #endif /* datageneral */ #endif /* VMS */ #endif /* RECURSIVE */ { "/rename-to", SND_REN, CM_ARG }, { "/since", SND_AFT, CM_INV|CM_ARG }, { "/smaller-than", SND_SMA, CM_ARG }, { "/starting-at", SND_STA, CM_ARG }, #ifndef NOFRILLS { "/su", SND_ASN, CM_ARG|CM_INV|CM_ABR }, { "/sub", SND_ASN, CM_ARG|CM_INV|CM_ABR }, { "/subject", SND_ASN, CM_ARG }, #endif /* NOFRILLS */ #ifdef RECURSIVE { "/subdirectories", SND_REC, CM_INV }, #endif /* RECURSIVE */ { "/text", SND_TXT, 0 }, { "/transparent", SND_XPA, 0 }, { "/type", SND_TYP, CM_ARG } }; #define NSNDTAB sizeof(sndtab)/sizeof(struct keytab) static int nsndtab = NSNDTAB; #ifndef NOMSEND static struct keytab msndtab[] = { /* MSEND options */ { "/after", SND_AFT, CM_ARG }, { "/before", SND_BEF, CM_ARG }, { "/binary", SND_BIN, 0 }, { "/delete", SND_DEL, 0 }, { "/except", SND_EXC, CM_ARG }, { "/filenames", SND_NAM, CM_ARG }, #ifdef CKSYMLINK { "/followlinks", SND_LNK, 0 }, #endif /* CKSYMLINK */ #ifdef VMS { "/image", SND_IMG, 0 }, #else { "/image", SND_BIN, CM_INV }, #endif /* VMS */ #ifdef CK_LABELED { "/labeled", SND_LBL, 0 }, #endif /* CK_LABELED */ { "/larger-than", SND_LAR, CM_ARG }, { "/list", SND_FIL, CM_ARG }, #ifndef NOFRILLS { "/mail", SND_MAI, CM_ARG }, #endif /* NOFRILLS */ #ifdef CK_TMPDIR { "/move-to", SND_MOV, CM_ARG }, #endif /* CK_TMPDIR */ #ifdef CKSYMLINK { "/nofollowlinks", SND_NLK, 0 }, #endif /* CKSYMLINK */ { "/not-after", SND_NAF, CM_ARG }, { "/not-before", SND_NBE, CM_ARG }, { "/pathnames", SND_PTH, CM_ARG }, { "/print", SND_PRI, CM_ARG }, #ifdef CK_XYZ { "/protocol", SND_PRO, CM_ARG }, #endif /* CK_XYZ */ { "/quiet", SND_SHH, 0 }, { "/recover", SND_RES, 0 }, { "/rename-to", SND_REN, CM_ARG }, { "/since", SND_AFT, CM_INV|CM_ARG }, { "/smaller-than", SND_SMA, CM_ARG }, { "/starting-at", SND_STA, CM_ARG }, #ifndef NOFRILLS { "/subject", SND_ASN, CM_ARG }, #endif /* NOFRILLS */ { "/text", SND_TXT, 0 }, { "/transparent", SND_XPA, 0 }, { "/type", SND_TYP, CM_ARG } }; #define NMSNDTAB sizeof(msndtab)/sizeof(struct keytab) static int nmsndtab = NMSNDTAB; #endif /* NOMSEND */ #endif /* NOXFER */ /* CONNECT command switches */ #define CONN_II 0 /* Idle interval */ #define CONN_IS 1 /* Idle string */ #define CONN_IL 2 /* Idle limit */ #define CONN_NV 3 /* Non-Verbose */ #define CONN_TL 4 /* Time limit */ #define CONN_TS 5 /* Trigger string */ #define CONN_AS 6 /* Asynchronous */ #define CONN_SY 7 /* Synchronous */ #define CONN_MAX 7 /* Number of CONNECT switches */ #ifndef NOLOCAL static struct keytab conntab[] = { #ifdef OS2 { "/asynchronous", CONN_AS, CM_INV }, #endif /* OS2 */ #ifdef XLIMITS { "/idle-interval", CONN_II, CM_ARG }, { "/idle-limit", CONN_IL, CM_ARG }, { "/idle-string", CONN_IS, CM_ARG }, { "/quietly", CONN_NV, CM_INV }, #else { "/quietly", CONN_NV, 0 }, #endif /* XLIMITS */ #ifdef OS2 { "/synchronous", CONN_SY, CM_INV }, #endif /* OS2 */ #ifdef XLIMITS { "/time-limit", CONN_TL, CM_ARG }, #endif /* XLIMITS */ #ifdef CK_TRIGGER { "/trigger", CONN_TS, CM_ARG }, #endif /* CK_TRIGGER */ { "",0,0 } }; #define NCONNTAB sizeof(conntab)/sizeof(struct keytab) static int nconntab = NCONNTAB; #endif /* NOLOCAL */ #ifndef NOXFER static struct keytab stattab[] = { /* STATISTICS command switches */ { "/brief", 1, 0 }, { "/verbose", 0, 0 } }; #endif /* NOXFER */ #ifndef NOSPL #ifdef COMMENT struct mtab mactab[MAC_MAX] = { /* Preinitialized macro table */ { NULL, NULL, 0 } }; #else struct mtab *mactab; /* Dynamically allocated macro table */ #endif /* COMMENT */ int nmac = 0; struct keytab mackey[MAC_MAX]; /* Macro names as command keywords */ #endif /* NOSPL */ #ifndef NOSPL #ifdef OS2 struct keytab beeptab[] = { /* Beep options */ { "error", BP_FAIL, 0 }, { "information", BP_NOTE, 0 }, { "warning", BP_WARN, 0 } }; int nbeeptab = sizeof(beeptab)/sizeof(struct keytab); /* CLEAR COMMMAND-SCREEN options */ #define CLR_C_ALL 0 #define CLR_C_BOL 1 #define CLR_C_BOS 2 #define CLR_C_EOL 3 #define CLR_C_EOS 4 #define CLR_C_LIN 5 #define CLR_C_SCR 6 struct keytab clrcmdtab[] = { { "all", CLR_C_ALL, 0 }, { "bol", CLR_C_BOL, 0 }, { "bos", CLR_C_BOS, 0 }, { "eol", CLR_C_EOL, 0 }, { "eos", CLR_C_EOS, 0 }, { "line", CLR_C_LIN, 0 }, { "scrollback", CLR_C_SCR, 0 } }; int nclrcmd = sizeof(clrcmdtab)/sizeof(struct keytab); #endif /* OS2 */ #endif /* NOSPL */ #ifdef COMMENT /* Not used at present */ static struct keytab pagetab[] = { { "/more", 1, CM_INV }, { "/nopage", 0, 0 }, { "/page", 1, 0 } }; int npagetab = sizeof(pagetab)/sizeof(struct keytab); #endif /* COMMENT */ #define TYP_NOP 0 /* /NOPAGE */ #define TYP_PAG 1 /* /PAGE */ #define TYP_HEA 2 /* /HEAD:n */ #define TYP_TAI 3 /* /TAIL:n */ #define TYP_PAT 4 /* /MATCH:pattern */ #define TYP_WID 5 /* /WIDTH:cols */ #define TYP_COU 6 /* /COUNT */ #define TYP_OUT 7 /* /OUTPUT:file */ #define TYP_PFX 8 /* /PREFIX:string */ #ifdef UNICODE #define TYP_XIN 9 /* /TRANSLATE-FROM:charset */ #define TYP_XUT 10 /* /TRANSLATE-TO:charset */ #define TYP_XPA 11 /* /TRANSPARENT */ #endif /* UNICODE */ #ifdef KUI #define TYP_GUI 12 /* /GUI:title */ #define TYP_HIG 13 /* /HEIGHT:rows */ #endif /* KUI */ #define TYP_NUM 14 /* /NUMBER */ static struct keytab typetab[] = { /* TYPE command switches */ { "/count", TYP_COU, 0 }, #ifdef UNICODE { "/character-set", TYP_XIN, CM_ARG }, #endif /* UNICODE */ #ifdef KUI { "/gui", TYP_GUI, CM_ARG }, #endif /* KUI */ { "/head", TYP_HEA, CM_ARG }, #ifdef KUI { "/height", TYP_HIG, CM_ARG }, #endif /* KUI */ { "/match", TYP_PAT, CM_ARG }, #ifdef CK_TTGWSIZ { "/more", TYP_PAG, CM_INV }, { "/nopage", TYP_NOP, 0 }, { "/number", TYP_NUM, 0 }, { "/output", TYP_OUT, CM_ARG }, { "/page", TYP_PAG, 0 }, #endif /* CK_TTGWSIZ */ { "/prefix", TYP_PFX, CM_ARG }, { "/tail", TYP_TAI, CM_ARG }, #ifdef UNICODE { "/translate-to", TYP_XUT, CM_ARG }, { "/transparent", TYP_XPA, 0 }, #endif /* UNICODE */ { "/width", TYP_WID, CM_ARG }, #ifdef UNICODE { "/xlate-to", TYP_XUT, CM_INV|CM_ARG }, #endif /* UNICODE */ { "", 0, 0 } }; int ntypetab = sizeof(typetab)/sizeof(struct keytab) - 1; int typ_page = -1; /* TYPE /[NO]PAGE default */ int typ_wid = -1; #ifndef NOSPL #define TRA_ALL 999 /* TRACE command */ #define TRA_ASG 0 #define TRA_CMD 1 int tra_asg = 0; int tra_cmd = 0; static struct keytab tracetab[] = { /* TRACE options */ { "all", TRA_ALL, 0 }, { "assignments", TRA_ASG, 0 }, { "command-level", TRA_CMD, 0 } }; static int ntracetab = sizeof(tracetab)/sizeof(struct keytab); #endif /* NOSPL */ #ifndef NOSHOW VOID showtypopts() { printf(" TYPE "); if (typ_page > -1) { prtopt(&optlines,typ_page ? "/PAGE" : "/NOPAGE"); } else prtopt(&optlines,"(no options set)"); if (typ_wid > -1) { ckmakmsg(tmpbuf,TMPBUFSIZ,"/WIDTH:",ckitoa(typ_wid),NULL,NULL); prtopt(&optlines,tmpbuf); } prtopt(&optlines,""); } #endif /* NOSHOW */ #ifdef LOCUS /* isauto == 1 if locus is being switched automatically */ VOID setlocus(x, isauto) int x, isauto; { extern int quitting; if (x) x = 1; if (x && locus) return; if (!x && !locus) return; /* Get here if it actually needs to be changed */ #ifdef OS2 if (isauto && /* Automatically switching */ !quitting && /* not exiting */ autolocus == 2) { /* and AUTOLOCUS is set to ASK */ char locmsg[300]; ckmakmsg(locmsg,300, "Switching Locus to ", x ? "LOCAL" : "REMOTE", " for file management commands\n" "such as CD, DIRECTORY, DELETE, RENAME. Type HELP SET\n" "LOCUS at the K-95> prompt for further info. Use the\n" #ifdef KUI "Actions menu or SET LOCUS command to disable automatic\n" "Locus switching or to disable these queries.", #else /* KUI */ "SET LOCUS command to disable automatic locus switching\n" "or to disable these queries.", #endif /* KUI */ NULL); if (uq_ok(locmsg,"OK to switch Locus?",3,NULL,1)) { locus = x; #ifdef KUI KuiSetProperty(KUI_LOCUS,x,0); #endif /* KUI */ return; } } else { #endif /* OS2 */ if (isauto && msgflg && !quitting) printf("Switching LOCUS for file-management commands to %s %s.\n", x ? "LOCAL" : "REMOTE", "(HELP LOCUS for info)" ); locus = x; #ifdef OS2 #ifdef KUI KuiSetProperty(KUI_LOCUS,x,0); #endif /* KUI */ } #endif /* OS2 */ } VOID setautolocus(x) int x; { autolocus = x; #ifdef KUI KuiSetProperty(KUI_AUTO_LOCUS,x,0); #endif /* KUI */ } #endif /* LOCUS */ int settypopts() { /* Set TYPE option defaults */ int xp = -1; int c, getval; while (1) { if ((y = cmswi(typetab,ntypetab,"Switch","",xxstring)) < 0) { if (y == -3) break; else return(y); } c = cmgbrk(); if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) { printf("?This switch does not take an argument\n"); return(-9); } switch (y) { case TYP_NOP: xp = 0; break; case TYP_PAG: xp = 1; break; case TYP_WID: if (getval) if ((x = cmnum("Column at which to truncate", ckitoa(cmd_cols),10,&y,xxstring)) < 0) return(x); typ_wid = y; break; default: printf("?Sorry, this option can not be set\n"); return(-9); } } if ((x = cmcfm()) < 0) /* Get confirmation */ return(x); if (xp > -1) typ_page = xp; /* Confirmed, save defaults */ return(success = 1); } /* Forward declarations of functions local to this module */ #ifdef UNIX _PROTOTYP (int douchmod, ( void ) ); #endif /* UNIX */ #ifdef CKPURGE _PROTOTYP (int dopurge, ( void ) ); #endif /* CKPURGE */ #ifndef NOSPL _PROTOTYP (int doundef, ( int ) ); _PROTOTYP (int doask, ( int ) ); _PROTOTYP (int dodef, ( int ) ); _PROTOTYP (int doelse, ( void ) ); _PROTOTYP (int dofor, ( void ) ); #endif /* NOSPL */ #ifndef NODIAL _PROTOTYP (int dodial, ( int ) ); #endif /* NODIAL */ _PROTOTYP (int dodel, ( void ) ); _PROTOTYP (int dopaus, ( int ) ); #ifndef NOPUSH #ifdef TCPSOCKET _PROTOTYP (int doping, ( void ) ); _PROTOTYP (int doftp, ( void ) ); #endif /* TCPSOCKET */ #endif /* NOPUSH */ #ifndef NORENAME #ifndef NOFRILLS _PROTOTYP (int dorenam, ( void ) ); #endif /* NOFRILLS */ #endif /* NORENAME */ #ifdef ZCOPY _PROTOTYP (int docopy, ( void ) ); #endif /* ZCOPY */ #ifdef NT _PROTOTYP (int dolink, ( void )); #endif /* NT */ #ifdef CK_REXX _PROTOTYP (int dorexx, ( void ) ); #endif /* CK_REXX */ #ifdef TNCODE static struct keytab telcmd[] = { { "abort", TN_ABORT, CM_INV }, /* Emotionally toned - don't show */ { "ao", TN_AO, 0 }, { "ayt", TN_AYT, 0 }, { "break", BREAK, 0 }, { "cancel",TN_ABORT, 0 }, { "dmark", TN_DM, 0 }, { "do", DO, 0 }, { "dont", DONT, 0 }, { "ec", TN_EC, 0 }, { "el", TN_EL, 0 }, { "eof", TN_EOF, 0 }, { "eor", TN_EOR, 0 }, #ifdef CK_KERBEROS #ifdef KRB5 #define TN_FWD 1 { "forward", TN_FWD, CM_INV }, #endif /* KRB5 */ #endif /* CK_KERBEROS */ { "ga", TN_GA, 0 }, { "ip", TN_IP, 0 }, { "nop", TN_NOP, 0 }, { "sak", TN_SAK, CM_INV }, { "sb", SB, 0 }, { "se", SE, 0 }, { "susp", TN_SUSP, 0 }, { "will", WILL, 0 }, { "wont", WONT, 0 } }; static int ntelcmd = (sizeof(telcmd) / sizeof(struct keytab)); static struct keytab tnopts[] = { #ifdef CK_AUTHENTICATION { "auth", TELOPT_AUTHENTICATION, 0 }, #else { "auth", TELOPT_AUTHENTICATION, CM_INV }, #endif /* CK_AUTHENTICATION */ { "binary", TELOPT_BINARY, 0 }, #ifdef TN_COMPORT { "c", TELOPT_COMPORT, CM_INV|CM_ABR}, { "co", TELOPT_COMPORT, CM_INV|CM_ABR}, { "com", TELOPT_COMPORT, CM_INV|CM_ABR}, { "com-port-control", TELOPT_COMPORT, 0 }, { "comport-control", TELOPT_COMPORT, CM_INV}, #else /* TN_COMPORT */ { "com-port-control", TELOPT_COMPORT, CM_INV }, { "comport-control", TELOPT_COMPORT, CM_INV}, #endif /* TN_COMPORT */ { "echo", TELOPT_ECHO, 0 }, #ifdef CK_ENCRYPTION { "encrypt", TELOPT_ENCRYPTION, 0 }, #else { "encrypt", TELOPT_ENCRYPTION, CM_INV }, #endif /* CK_ENCRYPTION */ #ifdef CK_FORWARD_X { "forward-x", TELOPT_FORWARD_X, 0 }, #else { "forward-x", TELOPT_FORWARD_X, CM_INV }, #endif /* CK_FORWARD_X */ #ifdef IKS_OPTION { "kermit", TELOPT_KERMIT, 0 }, #else { "kermit", TELOPT_KERMIT, CM_INV }, #endif /* IKS_OPTION */ { "lflow", TELOPT_LFLOW, CM_INV }, { "logout", TELOPT_LOGOUT, CM_INV }, #ifdef CK_NAWS { "naws", TELOPT_NAWS, 0 }, #else { "naws", TELOPT_NAWS, CM_INV }, #endif /* CK_NAWS */ #ifdef CK_ENVIRONMENT { "new-environment", TELOPT_NEWENVIRON, 0 }, #else { "new-environment", TELOPT_NEWENVIRON, CM_INV }, #endif /* CK_ENVIRONMENT */ { "pragma-heartbeat",TELOPT_PRAGMA_HEARTBEAT, CM_INV }, { "pragma-logon", TELOPT_PRAGMA_LOGON, CM_INV }, { "pragma-sspi", TELOPT_SSPI_LOGON, CM_INV }, { "sak", TELOPT_IBM_SAK, CM_INV }, #ifdef CK_SNDLOC { "send-location", TELOPT_SNDLOC, 0 }, #else { "send-location", TELOPT_SNDLOC, CM_INV }, #endif /* CK_SNDLOC */ { "sga", TELOPT_SGA, 0 }, #ifdef CK_SSL { "start-tls", TELOPT_START_TLS, 0 }, #else { "start-tls", TELOPT_START_TLS, CM_INV }, #endif /* CK_SSL */ { "ttype", TELOPT_TTYPE, 0 }, #ifdef CK_ENVIRONMENT { "xdisplay-location", TELOPT_XDISPLOC, 0 }, #else { "xdisplay-location", TELOPT_XDISPLOC, CM_INV }, #endif /* CK_ENVIRONMENT */ { "", 0, 0 } }; static int ntnopts = (sizeof(tnopts) / sizeof(struct keytab)) - 1; static struct keytab tnsbopts[] = { #ifdef CK_NAWS { "naws", TELOPT_NAWS, 0 }, #endif /* CK_NAWS */ { "", 0, 0 } }; static int ntnsbopts = (sizeof(tnsbopts) / sizeof(struct keytab)) - 1; #endif /* TNCODE */ #ifdef TCPSOCKET #ifndef NOPUSH #ifdef SYSFTP int doftp() { /* (External) FTP command */ char *p, *f; /* (See doxftp() for internal one) */ int x; if (network) /* If we have a current connection */ ckstrncpy(line,ttname,LINBUFSIZ); /* get the host name */ else *line = '\0'; /* as default host */ for (p = line; *p; p++) /* Remove ":service" from end. */ if (*p == ':') { *p = '\0'; break; } if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0) return(x); if (nopush) { printf("?Sorry, FTP command disabled\n"); return(success = 0); } /* Construct FTP command */ #ifdef VMS #ifdef MULTINET /* TGV MultiNet */ ckmakmsg(line,LINBUFSIZ,"multinet ftp ",s,NULL,NULL); #else ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL); #endif /* MULTINET */ #else /* Not VMS */ #ifdef OS2ORUNIX #ifndef NOFTP f = ftpapp; if (!f) f = ""; if (!f[0]) f = "ftp"; ckmakmsg(line,LINBUFSIZ,f," ",s,NULL); #ifdef OS2 p = line + strlen(ftpapp); while (p != line) { if (*p == '/') *p = '\\'; p--; } #endif /* OS2 */ #else /* NOFTP */ ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL); #endif /* NOFTP */ #else /* OS2ORUNIX */ ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL); #endif /* OS2ORUNIX */ #endif /* VMS */ conres(); /* Make console normal */ #ifdef DEC_TCPIP printf("\n"); /* Prevent prompt-stomping */ #endif /* DEC_TCPIP */ x = zshcmd(line); concb((char)escape); return(success = x); } #endif /* SYSFTP */ int doping() { /* PING command */ char *p; /* just runs ping program */ int x; if (network) /* If we have a current connection */ ckstrncpy(line,ttname,LINBUFSIZ); /* get the host name */ else *line = '\0'; /* as default host to be pinged. */ for (p = line; *p; p++) /* Remove ":service" from end. */ if (*p == ':') { *p = '\0'; break; } if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0) return(x); if (nopush) { printf("?Sorry, PING command disabled\n"); return(success = 0); } /* Construct PING command */ #ifdef VMS #ifdef MULTINET /* TGV MultiNet */ ckmakmsg(line,LINBUFSIZ,"multinet ping ",s," /num=1",NULL); #else ckmakmsg(line,LINBUFSIZ,"ping ",s," 56 1",NULL); /* Other VMS TCP/IP's */ #endif /* MULTINET */ #else /* Not VMS */ ckmakmsg(line,LINBUFSIZ,"ping ",s,NULL,NULL); #endif /* VMS */ conres(); /* Make console normal */ #ifdef DEC_TCPIP printf("\n"); /* Prevent prompt-stomping */ #endif /* DEC_TCPIP */ x = zshcmd(line); concb((char)escape); return(success = x); } #endif /* NOPUSH */ #endif /* TCPSOCKET */ static VOID doend(x) int x; { #ifndef NOSPL /* Pop from all FOR/WHILE/XIF/SWITCH's */ debug(F101,"doend maclvl 1","",maclvl); while ((maclvl > 0) && (m_arg[maclvl-1][0]) && (cmdstk[cmdlvl].src == CMD_MD) && (!strncmp(m_arg[maclvl-1][0],"_xif",4) || !strncmp(m_arg[maclvl-1][0],"_for",4) || !strncmp(m_arg[maclvl-1][0],"_whi",4) || !strncmp(m_arg[maclvl-1][0],"_swi",4))) { debug(F110,"END popping",m_arg[maclvl-1][0],0); dogta(XXPTA); /* Put args back */ popclvl(); /* Pop up two levels */ popclvl(); debug(F101,"doend maclvl 2","",maclvl); } if (maclvl > -1) { if (mrval[maclvl]) /* Free previous retval if any */ free(mrval[maclvl]); mrval[maclvl] = malloc(16); /* Room for up to 15 digits */ if (mrval[maclvl]) /* Record current retval */ ckmakmsg(mrval[maclvl],16,ckitoa(x),NULL,NULL,NULL); } #endif /* NOSPL */ popclvl(); /* Now pop out of macro or TAKE file */ #ifndef NOSPL #ifdef DEBUG if (deblog) { debug(F101,"END maclvl 3","",maclvl); debug(F111,"END mrval[maclvl]",mrval[maclvl],maclvl); debug(F111,"END mrval[maclvl+1]",mrval[maclvl+1],maclvl+1); } #endif /* DEBUG */ #endif /* NOSPL */ } #ifdef CKROOT int dochroot() { if ((x = cmdir("Name of new root directory","",&s,xxstring)) < 0) { if (x == -3) { printf("?Directory name required\n"); return(-9); } return(x); } ckstrncpy(line,s,LINBUFSIZ); s = line; if ((x = cmcfm()) < 0) return(x); s = brstrip(s); x = zsetroot(s); if (x < 0) { char * m = NULL; switch (x) { case -1: case -2: m = "Not a directory"; break; case -3: m = "Internal error"; break; case -4: m = "Access denied"; break; case -5: m = "Off limits"; break; } if (m) printf("%s: \"%s\"\n", m, s); return(m ? -9 : -2); } else { nopush = 1; return(success = 1); } } #endif /* CKROOT */ #ifndef NOXFER static char * asnbuf = NULL; /* As-name buffer pointer */ char sndxnam[] = { "_array_x_" }; /* (with replaceable x!) */ /* The new SEND command, replacing BSEND, CSEND, PSEND, etc etc. Call with cx = top-level keyword value. Returns: < 0 On parse error. 0 On other type of failure (e.g. requested operation not allowed). 1 On success with sstate set to 's' so protocol will begin. */ /* D O X S E N D -- Parse SEND and related commands with switches */ int doxsend(cx) int cx; { int c, i, n, wild, confirmed = 0; /* Workers */ int x, y; /* of the world... */ int getval = 0; /* Whether to get switch value */ extern char * snd_move; /* Directory to move sent files to */ extern char * snd_rename; /* What to rename sent files to */ extern char * filefile; /* File containing filenames to send */ extern int xfiletype; /* Send only text (or binary) files */ extern struct keytab pathtab[]; /* PATHNAMES option keywords */ extern int npathtab; /* How many of them */ extern int recursive; /* Recursive directory traversal */ extern int rprintf; /* REMOTE PRINT flag */ extern int fdispla; /* TRANSFER DISPLAY setting */ extern int skipbup; /* Skip backup files when sending */ struct stringint pv[SND_MAX+1]; /* Temporary array for switch values */ struct FDB sf, sw, fl, cm; /* FDBs for each parse function */ int mlist = 0; /* Flag for MSEND or MMOVE */ char * m; /* For making help messages */ extern struct keytab protos[]; /* File transfer protocols */ extern int xfrxla, g_xfrxla, nprotos; extern char sndbefore[], sndafter[], *sndexcept[]; /* Selection criteria */ extern char sndnbefore[], sndnafter[]; extern CK_OFF_T sndsmaller, sndlarger, calibrate; #ifndef NOSPL int range[2]; /* Array range */ char ** ap = NULL; /* Array pointer */ int arrayx = -1; /* Array index */ #endif /* NOSPL */ #ifdef NEWFTP if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) { if (cx == XXMAI) { printf("?Sorry, No MAIL with FTP\n"); return(-9); } return(doftpput(cx,0)); } #endif /* NEWFTP */ for (i = 0; i <= SND_MAX; i++) { /* Initialize switch values */ pv[i].sval = NULL; /* to null pointers */ pv[i].ival = -1; /* and -1 int values */ pv[i].wval = (CK_OFF_T)-1; /* and -1 wide values */ } #ifndef NOSPL range[0] = -1; range[1] = -1; sndxin = -1; /* Array index */ #endif /* NOSPL */ sndarray = NULL; /* Array pointer */ #ifdef UNIXOROSK g_matchdot = matchdot; /* Match dot files */ #endif /* UNIXOROSK */ g_recursive = recursive; /* Recursive sending */ recursive = 0; /* Save global value, set local */ debug(F101,"xsend entry fncnv","",fncnv); /* Preset switch values based on top-level command that called us */ switch (cx) { case XXMSE: /* MSEND */ mlist = 1; break; case XXCSEN: /* CSEND */ pv[SND_CMD].ival = 1; break; case XXMMOVE: /* MMOVE */ mlist = 1; case XXMOVE: /* MOVE */ pv[SND_DEL].ival = 1; break; case XXRSEN: /* RESEND */ pv[SND_BIN].ival = 1; /* Implies /BINARY */ pv[SND_RES].ival = 1; break; case XXMAI: /* MAIL */ pv[SND_MAI].ival = 1; break; } /* Set up chained parse functions... */ cmfdbi(&sw, /* First FDB - command switches */ _CMKEY, /* fcode */ "Filename, or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ #ifdef NOMSEND nsndtab, /* addtl numeric data 1: tbl size */ #else mlist ? nmsndtab : nsndtab, /* addtl numeric data 1: tbl size */ #endif /* NOMSEND */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ #ifdef NOMSEND sndtab, /* Keyword table */ #else mlist ? msndtab : sndtab, #endif /* NOMSEND */ &sf /* Pointer to next FDB */ ); cmfdbi(&sf, /* 2nd FDB - file to send */ _CMIFI, /* fcode */ "File(s) to send", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nolinks, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, mlist ? &cm : &fl ); cmfdbi(&fl, /* 3rd FDB - command to send from */ _CMFLD, /* fcode */ "Command", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, &cm ); cmfdbi(&cm, /* 4th FDB - Confirmation */ _CMCFM, /* fcode */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ NULL, NULL, NULL ); while (1) { /* Parse 0 or more switches */ x = cmfdb(&sw); /* Parse something */ debug(F101,"xsend cmfdb","",x); if (x < 0) /* Error */ goto xsendx; /* or reparse needed */ if (cmresult.fcode != _CMKEY) /* Break out if not a switch */ break; /* They gave a switch, but let's see how they terminated it. If they ended it with : or =, then we must parse a value. If they ended it with anything else, then we must NOT parse a value. */ c = cmgbrk(); /* Get break character */ getval = (c == ':' || c == '='); /* to see how they ended the switch */ if (getval && !(cmresult.kflags & CM_ARG)) { printf("?This switch does not take arguments\n"); x = -9; goto xsendx; } if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); x = -9; goto xsendx; } n = cmresult.nresult; /* Numeric result = switch value */ debug(F101,"xsend switch","",n); switch (n) { /* Process the switch */ case SND_CMD: /* These take no args */ if (nopush) { printf("?Sorry, system command access is disabled\n"); x = -9; goto xsendx; } #ifdef PIPESEND else if (sndfilter) { printf( "?Sorry, no SEND /COMMAND or CSEND when SEND FILTER selected\n"); x = -9; goto xsendx; } #endif /* PIPESEND */ sw.hlpmsg = "Command, or switch"; /* Change help message */ pv[n].ival = 1; /* Just set the flag */ pv[SND_ARR].ival = 0; break; case SND_REC: /* /RECURSIVE */ recursive = 2; /* Set the real variable */ pv[SND_PTH].ival = PATH_REL; /* Give them relative pathnames */ pv[n].ival = 1; /* Just set the flag */ break; case SND_RES: /* /RECOVER (resend) */ pv[SND_ARR].ival = 0; pv[SND_BIN].ival = 1; /* Implies /BINARY */ case SND_NOB: /* /NOBACKUP */ case SND_DEL: /* /DELETE */ case SND_SHH: /* /QUIET */ pv[n].ival = 1; /* Just set the flag */ break; #ifdef UNIXOROSK /* Like recursive, these are set immediately because they affect cmifi() */ case SND_DOT: /* /DOTFILES */ matchdot = 1; break; case SND_NOD: /* /NODOTFILES */ matchdot = 0; break; #endif /* UNIXOROSK */ /* File transfer modes - each undoes the others */ case SND_BIN: /* Binary */ case SND_TXT: /* Text */ case SND_IMG: /* Image */ case SND_LBL: /* Labeled */ pv[SND_BIN].ival = 0; pv[SND_TXT].ival = 0; pv[SND_IMG].ival = 0; pv[SND_LBL].ival = 0; pv[n].ival = 1; break; #ifdef CKSYMLINK case SND_LNK: case SND_NLK: nolinks = (n == SND_NLK) ? 2 : 0; cmfdbi(&sf, /* Redo cmifi() */ _CMIFI, /* fcode */ "File(s) to send", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nolinks, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, mlist ? &cm : &fl ); break; #endif /* CKSYMLINK */ case SND_EXC: /* Excludes */ if (!getval) break; if ((x = cmfld("Pattern","",&s,xxstring)) < 0) { if (x == -3) { printf("?Pattern required\n"); x = -9; } goto xsendx; } if (pv[n].sval) free(pv[n].sval); y = strlen(s); if (y > 256) { printf("?Pattern too long - 256 max\n"); x = -9; goto xsendx; } pv[n].sval = malloc(y+1); if (pv[n].sval) { strcpy(pv[n].sval,s); /* safe */ pv[n].ival = 1; } break; case SND_MOV: /* MOVE after */ case SND_REN: /* RENAME after */ if (!getval) break; if ((x = cmfld(n == SND_MOV ? "device and/or directory for source file after sending" : "new name for source file after sending", "", &s, n == SND_MOV ? xxstring : NULL )) < 0) { if (x == -3) { printf("%s\n", n == SND_MOV ? "?Destination required" : "?New name required" ); x = -9; } goto xsendx; } if (pv[n].sval) free(pv[n].sval); s = brstrip(s); y = strlen(s); if (y > 0) { pv[n].sval = malloc(y+1); if (pv[n].sval) { strcpy(pv[n].sval,s); /* safe */ pv[n].ival = 1; } } break; case SND_SMA: /* Smaller / larger than */ case SND_LAR: { CK_OFF_T w; if (!getval) break; if ((x = cmnumw("Size in bytes","0",10,&w,xxstring)) < 0) goto xsendx; pv[n].wval = w; break; } case SND_AFT: /* Send /AFTER:date-time */ case SND_BEF: /* Send /BEFORE:date-time */ case SND_NAF: /* Send /NOT-AFTER:date-time */ case SND_NBE: /* Send /NOT-BEFORE:date-time */ if (!getval) break; if ((x = cmdate("File date-time","",&s,0,xxstring)) < 0) { if (x == -3) { printf("?Date-time required\n"); x = -9; } goto xsendx; } if (pv[n].sval) free(pv[n].sval); pv[n].sval = malloc((int)strlen(s)+1); if (pv[n].sval) { strcpy(pv[n].sval,s); /* safe */ pv[n].ival = 1; } break; case SND_MAI: /* Send as mail (= MAIL) */ #ifdef IKSD if (inserver && !ENABLED(en_mai)) { printf("?Sorry, sending files as mail is disabled\n"); return(-9); } #endif /* IKSD */ pv[n].ival = 1; if (!getval) break; if ((x = cmfld("e-mail address","",&s,xxstring)) < 0) { if (x == -3) { printf("?address required\n"); x = -9; } goto xsendx; } s = brstrip(s); if (pv[n].sval) free(pv[n].sval); pv[n].sval = malloc((int)strlen(s)+1); if (pv[n].sval) strcpy(pv[n].sval,s); /* safe */ break; case SND_PRI: /* Send to be printed (REMOTE PRINT) */ #ifdef IKSD if (inserver && !ENABLED(en_mai)) { printf("?Sorry, sending files for printing is disabled\n"); return(-9); } #endif /* IKSD */ pv[n].ival = 1; if (!getval) break; if ((x = cmfld("Print options","",&s,xxstring)) < 0) if (x != -3) goto xsendx; s = brstrip(s); if (pv[n].sval) free(pv[n].sval); pv[n].sval = malloc((int)strlen(s)+1); if (pv[n].sval) strcpy(pv[n].sval,s); /* safe */ break; case SND_ASN: /* As-name */ debug(F101,"xsend /as-name getval","",getval); if (!getval) break; if ((x = cmfld("Name to send under","",&s,NULL)) < 0) { if (x == -3) { printf("?name required\n"); x = -9; } goto xsendx; } s = brstrip(s); if ((y = strlen(s)) > 0) { if (pv[n].sval) free(pv[n].sval); pv[n].sval = malloc(y+1); if (pv[n].sval) { strcpy(pv[n].sval,s); /* safe */ pv[n].ival = 1; } } break; case SND_STA: { /* Starting position (= PSEND) */ CK_OFF_T w; if (!getval) break; if ((x = cmnumw("0-based position","0",10,&w,xxstring)) < 0) goto xsendx; pv[n].wval = w; break; } case SND_PRO: /* Protocol to use */ if (!getval) break; if ((x = cmkey(protos,nprotos,"File-transfer protocol","", xxstring)) < 0) { if (x == -3) { printf("?name of protocol required\n"); x = -9; } goto xsendx; } pv[n].ival = x; break; #ifdef PIPESEND case SND_FLT: /* Filter */ debug(F101,"xsend /filter getval","",getval); if (!getval) break; if ((x = cmfld("Filter program to send through","",&s,NULL)) < 0) { if (x == -3) s = ""; else goto xsendx; } if (*s) s = brstrip(s); y = strlen(s); for (x = 0; x < y; x++) { /* Make sure they included "\v(...)" */ if (s[x] != '\\') continue; if (s[x+1] == 'v') break; } if (x == y) { printf( "?Filter must contain a replacement variable for filename.\n" ); x = -9; goto xsendx; } pv[n].ival = 1; if (pv[n].sval) { free(pv[n].sval); pv[n].sval = NULL; } if ((y = strlen(s)) > 0) { if ((pv[n].sval = malloc(y+1))) strcpy(pv[n].sval,s); /* safe */ } break; #endif /* PIPESEND */ case SND_PTH: /* Pathnames */ if (!getval) { pv[n].ival = PATH_REL; break; } if ((x = cmkey(pathtab,npathtab,"","absolute",xxstring)) < 0) goto xsendx; pv[n].ival = x; break; case SND_NAM: /* Filenames */ if (!getval) break; if ((x = cmkey(fntab,nfntab,"","converted",xxstring)) < 0) goto xsendx; debug(F101,"xsend /filenames","",x); pv[n].ival = x; break; #ifdef CALIBRATE case SND_CAL: { /* /CALIBRATE */ CK_OFF_T w; if (getval) { if ((x = cmnumw("number of Kbytes to send", "1024",10,&w,xxstring)) < 0) goto xsendx; } else w = (CK_OFF_T)1024; pv[n].wval = w; pv[SND_ARR].ival = 0; break; } #endif /* CALIBRATE */ case SND_FIL: /* Name of file containing filnames */ if (!getval) break; if ((x = cmifi("Name of file containing list of filenames", "",&s,&y,xxstring)) < 0) { if (x == -3) { printf("?Filename required\n"); x = -9; } goto xsendx; } else if (y) { printf("?Wildcards not allowed\n"); x = -9; goto xsendx; } if (pv[n].sval) free(pv[n].sval); if (s) if (*s) { if ((pv[n].sval = malloc((int)strlen(s)+1))) { strcpy(pv[n].sval,s); pv[n].ival = 1; pv[SND_ARR].ival = 0; } } break; #ifndef NOSPL case SND_ARR: /* SEND /ARRAY: */ if (!getval) break; ap = NULL; if ((x = cmfld("Array name (a single letter will do)", "", &s, NULL )) < 0) { if (x == -3) break; else return(x); } if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) { printf("?Bad array: %s\n",s); return(-9); } if (!(ap = a_ptr[x])) { printf("?No such array: %s\n",s); return(-9); } pv[n].ival = 1; pv[SND_CMD].ival = 0; /* Undo any conflicting ones... */ pv[SND_RES].ival = 0; pv[SND_CAL].ival = 0; pv[SND_FIL].ival = 0; arrayx = x; break; #endif /* NOSPL */ case SND_XPA: /* /TRANSPARENT */ pv[n].ival = 1; break; case SND_TYP: /* Only files of given type */ if (!getval) break; if ((x = cmkey(txtbin,3,"","all",xxstring)) < 0) goto xsendx; pv[n].ival = (x == 2) ? -1 : x; break; default: printf("?Unexpected switch value - %d\n",cmresult.nresult); x = -9; goto xsendx; } } debug(F101,"xsend cmresult fcode","",cmresult.fcode); #ifdef COMMENT /* List switch parsing results in debug log */ for (i = 0; i <= SND_MAX; i++) { ckmakmsg(line,LINBUFSIZ,"xsend switch ",ckitoa(i),NULL,NULL); debug(F111,line, pv[i].sval, pv[i].ival); } #endif /* COMMENT */ /* Now we have all switches, plus maybe a filename or command, or nothing */ #ifdef PIPESEND if (protocol != PROTO_K && pv[SND_CMD].ival > 0) { printf("?Sorry, %s works only with Kermit protocol\n", (cx == XXCSEN) ? "CSEND" : "SEND /COMMAND"); x = -9; goto xsendx; } if (pv[SND_RES].ival > 0 || /* /RECOVER */ pv[SND_STA].wval > 0) { /* or /STARTING */ if (sndfilter || pv[SND_FLT].ival > 0) { printf("?Sorry, no /RECOVER or /START if SEND FILTER selected\n"); x = -9; goto xsendx; } } #endif /* PIPESEND */ cmarg = ""; cmarg2 = ""; line[0] = NUL; s = line; wild = 0; switch (cmresult.fcode) { /* How did we get out of switch loop */ case _CMIFI: /* Input filename */ ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */ if (pv[SND_ARR].ival > 0) cmarg2 = line; else wild = cmresult.nresult; /* Wild flag */ if (!recursive && !wild) nolinks = 0; break; case _CMFLD: /* Field */ /* Only allowed with /COMMAND and /ARRAY */ if (pv[SND_CMD].ival < 1 && pv[SND_ARR].ival < 1) { #ifdef CKROOT if (ckrooterr) printf("?Off limits: %s\n",cmresult.sresult); else #endif /* CKROOT */ printf("?%s - \"%s\"\n", iswild(cmresult.sresult) ? "No files match" : "File not found", cmresult.sresult ); x = -9; goto xsendx; } ckstrncpy(line,cmresult.sresult,LINBUFSIZ); if (pv[SND_ARR].ival > 0) cmarg2 = line; break; case _CMCFM: /* Confirmation */ /* s = ""; */ confirmed = 1; break; default: printf("?Unexpected function code: %d\n",cmresult.fcode); x = -9; goto xsendx; } debug(F110,"xsend string",s,0); debug(F101,"xsend confirmed","",confirmed); /* Save and change protocol and transfer mode */ /* Global values are restored in main parse loop */ g_proto = protocol; /* Save current global protocol */ g_urpsiz = urpsiz; g_spsizf = spsizf; g_spsiz = spsiz; g_spsizr = spsizr; g_spmax = spmax; g_wslotr = wslotr; g_prefixing = prefixing; g_fncact = fncact; g_fncnv = fncnv; g_fnspath = fnspath; g_fnrpath = fnrpath; g_xfrxla = xfrxla; if (pv[SND_PRO].ival > -1) { /* Change according to switch */ protocol = pv[SND_PRO].ival; if (ptab[protocol].rpktlen > -1) /* copied from initproto() */ urpsiz = ptab[protocol].rpktlen; if (ptab[protocol].spktflg > -1) spsizf = ptab[protocol].spktflg; if (ptab[protocol].spktlen > -1) { spsiz = ptab[protocol].spktlen; if (spsizf) spsizr = spmax = spsiz; } if (ptab[protocol].winsize > -1) wslotr = ptab[protocol].winsize; if (ptab[protocol].prefix > -1) prefixing = ptab[protocol].prefix; if (ptab[protocol].fnca > -1) fncact = ptab[protocol].fnca; if (ptab[protocol].fncn > -1) fncnv = ptab[protocol].fncn; if (ptab[protocol].fnsp > -1) fnspath = ptab[protocol].fnsp; if (ptab[protocol].fnrp > -1) fnrpath = ptab[protocol].fnrp; } debug(F101,"xsend protocol","",protocol); if (pv[SND_NOB].ival > -1) { /* /NOBACKUP (skip backup file) */ g_skipbup = skipbup; skipbup = 1; } if (pv[SND_REC].ival > 0) /* /RECURSIVE */ recursive = 2; if (pv[SND_TYP].ival > -1) { /* /TYPE */ xfiletype = pv[SND_TYP].ival; if (xfiletype == 2) xfiletype = -1; } g_binary = binary; /* Save global transfer mode */ #ifdef PATTERNS g_patterns = patterns; /* Save FILE PATTERNS setting */ #endif /* PATTERNS */ if (pv[SND_BIN].ival > 0) { /* Change according to switch */ /* If they said /BINARY they mean /BINARY */ patterns = 0; /* So no pattern-based switching */ g_xfermode = xfermode; /* or automatic transfer mode */ xfermode = XMODE_M; binary = XYFT_B; debug(F101,"doxsend /BINARY xfermode","",xfermode); } else if (pv[SND_TXT].ival > 0) { /* Ditto for /TEXT */ patterns = 0; g_xfermode = xfermode; xfermode = XMODE_M; binary = XYFT_T; debug(F101,"doxsend /TEXT xfermode","",xfermode); } else if (pv[SND_IMG].ival > 0) { #ifdef VMS binary = XYFT_I; #else binary = XYFT_B; #endif /* VMS */ } #ifdef CK_LABELED else if (pv[SND_LBL].ival > 0) { binary = XYFT_L; } #endif /* CK_LABELED */ debug(F101,"xsend binary","",binary); if (pv[SND_XPA].ival > 0) /* /TRANSPARENT */ xfrxla = 0; /* Don't translate character sets */ /* Check for legal combinations of switches, filenames, etc */ #ifdef PIPESEND if (pv[SND_CMD].ival > 0) { /* COMMAND - strip any braces */ debug(F110,"SEND /COMMAND before stripping",s,0); s = brstrip(s); debug(F110,"SEND /COMMAND after stripping",s,0); if (!*s) { printf("?Sorry, a command to send from is required\n"); x = -9; goto xsendx; } cmarg = s; } #endif /* PIPESEND */ /* Set up /MOVE and /RENAME */ if (pv[SND_DEL].ival > 0 && (pv[SND_MOV].ival > 0 || pv[SND_REN].ival > 0)) { printf("?Sorry, /DELETE conflicts with /MOVE or /RENAME\n"); x = -9; goto xsendx; } #ifdef CK_TMPDIR if (pv[SND_MOV].ival > 0) { int len; char * p = pv[SND_MOV].sval; #ifdef CK_LOGIN if (isguest) { printf("?Sorry, /MOVE-TO not available to guests\n"); x = -9; goto xsendx; } #endif /* CK_LOGIN */ len = strlen(p); if (!isdir(p)) { /* Check directory */ #ifdef CK_MKDIR char * s = NULL; s = (char *)malloc(len + 4); if (s) { strcpy(s,p); /* safe */ #ifdef datageneral if (s[len-1] != ':') { s[len++] = ':'; s[len] = NUL; } #else if (s[len-1] != '/') { s[len++] = '/'; s[len] = NUL; } #endif /* datageneral */ s[len++] = 'X'; s[len] = NUL; x = zmkdir(s); free(s); if (x < 0) { printf("?Can't create \"%s\"\n",p); x = -9; goto xsendx; } } #else printf("?Directory \"%s\" not found\n",p); x = -9; goto xsendx; #endif /* CK_MKDIR */ } zfnqfp(p,LINBUFSIZ,tmpbuf); makestr(&snd_move,tmpbuf); } #endif /* CK_TMPDIR */ if (pv[SND_REN].ival > 0) { /* /RENAME */ char * p = pv[SND_REN].sval; #ifdef CK_LOGIN if (isguest) { printf("?Sorry, /RENAME-TO not available to guests\n"); x = -9; goto xsendx; } #endif /* CK_LOGIN */ if (!p) p = ""; if (!*p) { printf("?New name required for /RENAME\n"); x = -9; goto xsendx; } p = brstrip(p); #ifndef NOSPL /* If name given is wild, rename string must contain variables */ if (wild) { char * s = tmpbuf; x = TMPBUFSIZ; zzstring(p,&s,&x); if (!strcmp(tmpbuf,p)) { printf( "?/RENAME for file group must contain variables such as \\v(filename)\n" ); x = -9; goto xsendx; } } #endif /* NOSPL */ makestr(&snd_rename,p); } /* Handle /RECOVER and /START */ #ifdef CK_RESEND if (pv[SND_RES].ival > 0 && binary != XYFT_B && !filepeek #ifdef PATTERNS && !patterns #else #ifdef VMS /* VMS sets text/binary automatically later when it opens the file */ && 0 #endif /* VMS */ #endif /* PATTERNS */ ) { printf("?Sorry, /BINARY required\n"); x = -9; goto xsendx; } if (pv[SND_STA].wval > 0) { /* /START */ if (wild) { printf("?Sorry, wildcards not permitted with /START\n"); x = -9; goto xsendx; } if (sizeof(int) < 4) { printf("?Sorry, this command needs at least 32-bit integers\n"); x = -9; goto xsendx; } #ifdef CK_XYZ if (protocol != PROTO_K) { printf("?Sorry, SEND /START works only with Kermit protocol\n"); x = -9; goto xsendx; } #endif /* CK_XYZ */ } #ifdef CK_XYZ if (pv[SND_RES].ival > 0) { if (protocol != PROTO_K && protocol != PROTO_Z) { printf( "Sorry, /RECOVER is possible only with Kermit or ZMODEM protocol\n" ); x = -9; goto xsendx; } } #endif /* CK_XYZ */ #endif /* CK_RESEND */ if (protocol == PROTO_K) { if ((pv[SND_MAI].ival > 0 || /* MAIL */ pv[SND_PRI].ival > 0 || /* PRINT */ pv[SND_RES].ival > 0 /* RESEND */ ) && (!atdiso || !atcapr)) { /* Disposition attribute off? */ printf("?Sorry, ATTRIBUTE DISPOSITION must be ON\n"); x = -9; goto xsendx; } } #ifdef CK_XYZ if (wild && (protocol == PROTO_X || protocol == PROTO_XC)) { printf( "Sorry, you can only send one file at a time with XMODEM protocol\n" ); x = -9; goto xsendx; } #endif /* CK_XYZ */ if (!confirmed) { /* CR not typed yet, get more fields */ char *m; if (mlist) { /* MSEND or MMOVE */ nfils = 0; /* We already have the first one */ #ifndef NOMSEND msfiles[nfils++] = line; /* Store pointer */ lp = line + (int)strlen(line) + 1; /* Point past it */ debug(F111,"xsend msend",msfiles[nfils-1],nfils-1); while (1) { /* Get more filenames */ char *p; if ((x = cmifi("Names of files to send, separated by spaces", "", &s,&y,xxstring)) < 0) { if (x != -3) goto xsendx; if ((x = cmcfm()) < 0) goto xsendx; break; } msfiles[nfils++] = lp; /* Got one, count it, point to it, */ p = lp; /* remember pointer, */ while ((*lp++ = *s++)) /* and copy it into buffer */ if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */ printf("?MSEND list too long\n"); line[0] = NUL; x = -9; goto xsendx; } debug(F111,"xsend msend",msfiles[nfils-1],nfils-1); if (nfils == 1) fspec[0] = NUL; /* Take care of \v(filespec) */ #ifdef ZFNQFP zfnqfp(p,TMPBUFSIZ,tmpbuf); p = tmpbuf; #endif /* ZFNQFP */ if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) { strcat(fspec,p); /* safe */ strcat(fspec," "); /* safe */ } else #ifdef COMMENT printf("WARNING - \\v(filespec) buffer overflow\n"); #else debug(F101,"doxsend filespec buffer overflow","",0); #endif /* COMMENT */ } #endif /* NOMSEND */ } else { /* Regular SEND */ char *p; int y; nfils = -1; if (pv[SND_MAI].ival > 0) m = (pv[SND_MAI].sval) ? "e-mail address (optional)" : "e-mail address (required)"; else if (pv[SND_PRI].ival > 0) m = "printer options (optional)"; else if (wild) m = "\nOptional as-name template containing replacement variables \ like \\v(filename)"; else m = "Optional name to send it with"; if ((x = cmtxt(m,"",&p,NULL)) < 0) goto xsendx; if (!p) p = ""; if (*p) { /* If some text was given... */ p = brstrip(p); /* Replace /AS-NAME: value if any */ if ((y = strlen(p)) > 0) { if (pv[SND_MAI].ival > 0) { makestr(&pv[SND_MAI].sval, p); } else { if (pv[SND_ASN].sval) free(pv[SND_ASN].sval); pv[SND_ASN].sval = malloc(y+1); if (pv[SND_ASN].sval) { strcpy(pv[SND_ASN].sval,p); /* safe */ pv[SND_ASN].ival = 1; } } } } } } /* Set cmarg2 from as-name, however we got it. */ if (pv[SND_ASN].ival > 0 && pv[SND_ASN].sval && !*cmarg2) { int x; x = strlen(line); ckstrncpy(line+x+2,pv[SND_ASN].sval,LINBUFSIZ-x-1); cmarg2 = line+x+2; debug(F110,"doxsend cmarg2",cmarg2,0); } #ifndef NOFRILLS if ((pv[SND_MAI].ival > 0) && (pv[SND_PRI].ival > 0)) { printf("Sorry, /MAIL and /PRINT are conflicting options\n"); x = -9; goto xsendx; } n = 0; /* /MAIL or /PRINT? */ if (pv[SND_MAI].ival > 0) n = SND_MAI; else if (pv[SND_PRI].ival > 0) n = SND_PRI; if (n) { /* Yes... */ #ifdef DEBUG char * p; if (n == SND_MAI) p = "/MAIL"; else p = "/PRINT"; debug(F111,"xsend",p,n); #endif /* DEBUG */ #ifdef CK_XYZ if (protocol != PROTO_K) { printf("Sorry, %s available only with Kermit protocol\n", (n == SND_MAI) ? "/MAIL" : "/PRINT" ); x = -9; goto xsendx; } #endif /* CK_XYZ */ debug(F101,"xsend print/mail wild","",wild); *optbuf = NUL; /* Wipe out any old options */ s = pv[n].sval; /* mail address or print switch val */ if (!s) s = ""; debug(F110,"doxsend mail address or printer options",s,0); if (n == SND_MAI && !*s) { printf("?E-mail address required\n"); x = -9; goto xsendx; } else if ((int)strlen(s) > 94) { /* Ensure legal size */ printf("?%s too long\n", (n == SND_MAI) ? "E-mail address" : "Print option string" ); x = -9; goto xsendx; } ckstrncpy(optbuf,s,OPTBUFLEN); /* OK, copy to option buffer */ cmarg = line; /* File to send */ if (n == SND_MAI) { debug(F110,"xsend mailing",cmarg,0); debug(F110,"xsend address:",optbuf,0); rmailf = 1; } else { debug(F110,"xsend printing",cmarg,0); debug(F110,"xsend options",optbuf,0); rprintf = 1; } } #endif /* NOFRILLS */ #ifdef CALIBRATE if (pv[SND_CAL].wval > 0) { /* Handle /CALIBRATE */ if (confirmed) { calibrate = pv[SND_CAL].wval * (CK_OFF_T)1024; sndsrc = -9; nfils = 1; wild = 0; #ifndef NOMSEND addlist = 0; #endif /* NOMSEND */ ckstrncpy(line,"CALIBRATION",LINBUFSIZ); s = cmarg = line; if (!cmarg2) cmarg2 = ""; debug(F110,"doxsend cmarg2 calibrate",cmarg2,0); } else if (line[0]) { calibrate = 0; pv[SND_CAL].ival = 0; pv[SND_CAL].wval = 0; } } #endif /* CALIBRATE */ if (pv[SND_FIL].ival > 0) { if (confirmed && !calibrate) { if (zopeni(ZMFILE,pv[SND_FIL].sval) < 1) { debug(F110,"xsend can't open",pv[SND_FIL].sval,0); printf("?Failure to open %s\n",filefile); x = -9; goto xsendx; } makestr(&filefile,pv[SND_FIL].sval); /* Open, remember name */ debug(F110,"xsend opened",filefile,0); wild = 1; } } /* SEND alone... */ #ifndef NOSPL if (confirmed && pv[SND_ARR].ival > 0) { if (!*cmarg2) { sndxnam[7] = (char)((arrayx == 1) ? 64 : arrayx + ARRAYBASE); cmarg2 = sndxnam; } cmarg = ""; goto sendend; } #endif /* NOSPL */ if (confirmed && !line[0] && !filefile && !calibrate) { #ifndef NOMSEND if (filehead) { /* OK if we have a SEND-LIST */ nfils = filesinlist; sndsrc = nfils; /* Like MSEND */ addlist = 1; /* But using a different list... */ filenext = filehead; goto sendend; } #endif /* NOMSEND */ printf("?Filename required but not given\n"); x = -9; goto xsendx; } /* Not send-list or array */ #ifndef NOMSEND addlist = 0; /* Don't use SEND-LIST. */ filenext = NULL; #endif /* NOMSEND */ if (mlist) { /* MSEND or MMOVE */ #ifndef NOMSEND cmlist = msfiles; /* List of files to send */ sndsrc = nfils; cmarg2 = ""; sendstart = (CK_OFF_T)0; #endif /* NOMSEND */ #ifdef PIPESEND pipesend = 0; #endif /* PIPESEND */ } else if (filefile) { /* File contains list of filenames */ s = ""; cmarg = ""; cmarg2 = ""; line[0] = NUL; nfils = 1; sndsrc = 1; } else if (!calibrate && pv[SND_ARR].ival < 1 && pv[SND_CMD].ival < 1) { nfils = sndsrc = -1; /* Not MSEND, MMOVE, /LIST, or /ARRAY */ if ( /* or /COMMAND */ #ifndef NOFRILLS !rmailf && !rprintf /* Not MAIL or PRINT */ #else 1 #endif /* NOFRILLS */ ) { CK_OFF_T y = (CK_OFF_T)1; if (!wild) y = zchki(s); if (y < (CK_OFF_T)0) { printf("?Read access denied - \"%s\"\n", s); x = -9; goto xsendx; } if (s != line) /* We might already have done this. */ ckstrncpy(line,s,LINBUFSIZ); /* Copy of string just parsed. */ else debug(F110,"doxsend line=s",line,0); cmarg = line; /* File to send */ } zfnqfp(cmarg,fspeclen,fspec); } if (!mlist) { /* For all but MSEND... */ #ifdef PIPESEND if (pv[SND_CMD].ival > 0) /* /COMMAND sets pipesend flag */ pipesend = 1; debug(F101,"xsend /COMMAND pipesend","",pipesend); if (pipesend && filefile) { printf("?Invalid switch combination\n"); x = -9; goto xsendx; } #endif /* PIPESEND */ #ifndef NOSPL /* If as-name given and filespec is wild, as-name must contain variables */ debug(F111,"doxsend cmarg2 wild",cmarg2,wild); if (wild && *cmarg2) { char * s = tmpbuf; x = TMPBUFSIZ; zzstring(cmarg2,&s,&x); if (!strcmp(tmpbuf,cmarg2)) { printf( "?As-name for file group must contain variables such as \\v(filename)\n" ); x = -9; goto xsendx; } } #endif /* NOSPL */ /* Strip braces from as-name */ debug(F110,"xsend cmarg2 before stripping",cmarg2,0); cmarg2 = brstrip(cmarg2); debug(F110,"xsend filename",cmarg,0); debug(F110,"xsend as-name",cmarg2,0); /* Copy as-name to a safe place */ if (asnbuf) { free(asnbuf); asnbuf = NULL; } if ((y = strlen(cmarg2)) > 0) { asnbuf = (char *) malloc(y + 1); if (asnbuf) { strcpy(asnbuf,cmarg2); /* safe */ cmarg2 = asnbuf; } else cmarg2 = ""; } #ifdef CK_RESEND debug(F111,"xsend pv[SND_STA].ival","",pv[SND_STA].ival); if (pv[SND_STA].wval > (CK_OFF_T)-1) { /* /START position */ if (wild) { printf("?/STARTING-AT may not be used with multiple files.\n"); x = -9; goto xsendx; } else sendstart = pv[SND_STA].wval; } else sendstart = (CK_OFF_T)0; debug(F101,"xsend /STARTING","",sendstart); #endif /* CK_RESEND */ } sendend: /* Common successful exit */ moving = 0; if (pv[SND_SHH].ival > 0) { /* SEND /QUIET... */ g_displa = fdispla; fdispla = 0; debug(F101,"xsend display","",fdispla); } #ifndef NOSPL /* SEND /ARRAY... */ if (pv[SND_ARR].ival > 0) { if (!ap) { x = -2; goto xsendx; } /* (shouldn't happen) */ if (range[0] == -1) /* If low end of range not specified */ range[0] = 1; /* default to 1 */ if (range[1] == -1) /* If high not specified */ range[1] = a_dim[arrayx]; /* default to size of array */ if ((range[0] < 0) || /* Check range */ (range[0] > a_dim[arrayx]) || (range[1] < range[0]) || (range[1] > a_dim[arrayx])) { printf("?Bad array range - [%d:%d]\n",range[0],range[1]); x = -9; goto xsendx; } sndarray = ap; /* Array pointer */ sndxin = arrayx; /* Array index */ sndxlo = range[0]; /* Array range */ sndxhi = range[1]; sndxnam[7] = (char)((sndxin == 1) ? 64 : sndxin + ARRAYBASE); #ifdef COMMENT printf("SENDING FROM ARRAY: &%c[]...\n", /* debugging */ (sndxin == 1) ? 64 : sndxin + ARRAYBASE); printf("Lo=%d\nHi=%d\n", sndxlo, sndxhi); printf("cmarg=[%s]\ncmarg2=[%s]\n", cmarg, cmarg2); while ((x = agnbyte()) > -1) { putchar((char)x); } return(1); #endif /* COMMENT */ } #endif /* NOSPL */ if (pv[SND_ARR].ival < 1) { /* File selection & disposition... */ if (pv[SND_DEL].ival > 0) /* /DELETE was specified */ moving = 1; debug(F101,"xsend /DELETE","",moving); if (pv[SND_AFT].ival > 0) /* Copy SEND criteria */ ckstrncpy(sndafter,pv[SND_AFT].sval,19); if (pv[SND_BEF].ival > 0) ckstrncpy(sndbefore,pv[SND_BEF].sval,19); if (pv[SND_NAF].ival > 0) ckstrncpy(sndnafter,pv[SND_NAF].sval,19); if (pv[SND_NBE].ival > 0) ckstrncpy(sndnbefore,pv[SND_NBE].sval,19); if (pv[SND_EXC].ival > 0) makelist(pv[SND_EXC].sval,sndexcept,NSNDEXCEPT); if (pv[SND_SMA].wval > (CK_OFF_T)-1) sndsmaller = pv[SND_SMA].wval; if (pv[SND_LAR].wval > (CK_OFF_T)-1) sndlarger = pv[SND_LAR].wval; if (pv[SND_NAM].ival > -1) { g_fncnv = fncnv; /* Save global value */ fncnv = pv[SND_NAM].ival; debug(F101,"xsend fncnv","",fncnv); } if (pv[SND_PTH].ival > -1) { g_spath = fnspath; /* Save global values */ fnspath = pv[SND_PTH].ival; #ifndef NZLTOR if (fnspath != PATH_OFF) { g_fncnv = fncnv; /* Bad bad... */ fncnv = XYFN_C; } #endif /* NZLTOR */ debug(F101,"xsend fnspath","",fnspath); debug(F101,"xsend fncnv","",fncnv); } } #ifdef PIPESEND if (pv[SND_FLT].ival > 0) { makestr(&sndfilter,pv[SND_FLT].sval); debug(F110,"xsend /FILTER", sndfilter, 0); } #endif /* PIPESEND */ #ifdef CK_APC /* MOVE not allowed in APCs */ if (moving && (apcactive == APC_LOCAL || apcactive == APC_REMOTE) && !(apcstatus & APC_UNCH)) return(success = 0); #endif /* CK_APC */ #ifdef IKS_OPTION if ( #ifdef CK_XYZ protocol == PROTO_K && #endif /* CK_XYZ */ !iks_wait(KERMIT_REQ_START,1)) { printf("?A Kermit Server is not available to process this command.\n"); printf("?Start a RECEIVE command to complement this command.\n"); } #endif /* IKS_OPTION */ #ifdef IKSD #ifdef CK_LOGIN if (moving && inserver && isguest) { printf("?File deletion not allowed for guests.\n"); return(-9); } #endif /* CK_LOGIN */ #endif /* IKSD */ sstate = 's'; /* Set start state to SEND */ sndcmd = 1; #ifdef CK_RESEND if (pv[SND_RES].ival > 0) /* Send sendmode appropriately */ sendmode = SM_RESEND; else if (pv[SND_STA].ival > 0) sendmode = SM_PSEND; else #endif /* CK_RESEND */ if (mlist) sendmode = SM_MSEND; else sendmode = SM_SEND; #ifdef MAC what = W_SEND; scrcreate(); #endif /* MAC */ if (local && pv[SND_SHH].ival != 0) { /* If in local mode, */ displa = 1; /* turn on file transfer display */ } x = 0; xsendx: /* Common exit, including failure */ debug(F101,"doxsend sndsrc","",sndsrc); for (i = 0; i <= SND_MAX; i++) { /* Free malloc'd memory */ if (pv[i].sval) free(pv[i].sval); } return(x); } #endif /* NOXFER */ #ifndef NOLOCAL /* D O X C O N N -- CONNECT command parsing with switches */ #ifdef XLIMITS #define XLIMORTRIGGER #else #ifdef CK_TRIGGER #define XLIMORTRIGGER #endif /* CK_TRIGGER */ #endif /* XLIMITS */ #ifdef CKTIDLE int tt_idlelimit = 0; /* Terminal idle limit */ int tt_idleact = IDLE_RET; /* Terminal idle action */ #endif /* CKTIDLE */ #ifdef OS2 /* K95 only: */ extern int tt_idlesnd_tmo; /* Idle interval */ int tt_timelimit = 0; /* Time limit, 0 = none */ extern char * /* Parse results - strings: */ tt_idlesnd_str; /* Idle string */ #endif /* OS2 */ #ifdef CK_TRIGGER extern char *tt_trigger[]; extern CHAR *tt_trmatch[]; extern char *triggerval; static char *g_tt_trigger[TRIGGERS]; #endif /* CK_TRIGGER */ #ifdef OS2 static int g_tt_idlesnd_tmo, g_tt_timelimit; /* For saving and restoring */ static int g_tt_idlelimit, g_tt_saved = 0; static char * g_tt_idlesnd_str; /* global settings */ #endif /* OS2 */ static struct stringint pv[CONN_MAX+1]; VOID resconn() { int i; #ifdef OS2 if ( g_tt_saved ) { tt_idlelimit = g_tt_idlelimit; tt_idlesnd_tmo = g_tt_idlesnd_tmo; tt_timelimit = g_tt_timelimit; tt_idlesnd_str = g_tt_idlesnd_str; g_tt_saved = 0; } #endif /* OS2 */ #ifdef CK_TRIGGER for (i = 0; i < TRIGGERS; i++) tt_trigger[i] = g_tt_trigger[i]; #endif /* CK_TRIGGER */ for (i = 0; i <= CONN_MAX; i++) { /* Free malloc'd memory */ if (pv[i].sval) free(pv[i].sval); pv[i].sval = NULL; } } int doxconn(cx) int cx; { int c, i, n; /* Workers */ int x, y; int getval = 0; /* Whether to get switch value */ int async = 0; /* Make an async connect */ struct FDB sw, cm; /* FDBs for each parse function */ extern FILE * tfile[]; extern char * macp[]; #ifdef OS2 g_tt_idlesnd_tmo = tt_idlesnd_tmo; /* Save global settings */ g_tt_timelimit = tt_timelimit; g_tt_idlelimit = tt_idlelimit; g_tt_idlesnd_str = tt_idlesnd_str; g_tt_saved = 1; #endif /* OS2 */ #ifdef CK_TRIGGER if (!tt_trigger[0]) { /* First initialization */ for (i = 1; i < TRIGGERS; i++) tt_trigger[i] = NULL; } for (i = 0; i < TRIGGERS; i++) g_tt_trigger[i] = tt_trigger[i]; if (triggerval) { free(triggerval); triggerval = NULL; } #endif /* CK_TRIGGER */ for (i = 0; i <= CONN_MAX; i++) { /* Initialize switch values */ pv[i].sval = NULL; /* to null pointers */ pv[i].ival = -1; /* and -1 int values */ pv[i].wval = (CK_OFF_T)-1; } if (cx == XXCQ) /* CQ == CONNECT /QUIETLY */ pv[CONN_NV].ival = 1; /* Set up chained parse functions... */ cmfdbi(&sw, /* First FDB - command switches */ _CMKEY, /* fcode */ "Switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nconntab, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ conntab, /* Keyword table */ &cm /* Pointer to next FDB */ ); cmfdbi(&cm, /* 2nd FDB - Confirmation */ _CMCFM, /* fcode */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ NULL, NULL, NULL ); while (1) { /* Parse 0 or more switches */ x = cmfdb(&sw); /* Parse switch or confirmation */ debug(F101,"doxconn cmfdb","",x); if (x < 0) { /* Error */ if (x == -9 || x == -2) printf("?No switches match - \"%s\"\n",atmbuf); goto xconnx; /* or reparse needed */ } if (cmresult.fcode != _CMKEY) /* Break out if not a switch */ break; c = cmgbrk(); /* Get break character */ getval = (c == ':' || c == '='); /* to see how they ended the switch */ if (getval && !(cmresult.kflags & CM_ARG)) { printf("?This switch does not take arguments\n"); x = -9; goto xconnx; } if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); return(-9); } n = cmresult.nresult; /* Numeric result = switch value */ debug(F101,"doxconn switch","",n); switch (n) { /* Process the switch */ #ifdef OS2 case CONN_AS: /* Asynchronous */ pv[CONN_AS].ival = 1; pv[CONN_SY].ival = 0; break; case CONN_SY: /* Synchronous */ pv[CONN_SY].ival = 1; pv[CONN_AS].ival = 0; break; #endif /* OS2 */ case CONN_NV: /* Non-verbal */ pv[n].ival = 1; break; #ifdef XLIMITS case CONN_II: /* Idle-interval */ case CONN_IL: /* Idle-limit */ case CONN_TL: /* Time-limit */ if (!getval) break; if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0) goto xconnx; pv[n].ival = y; break; case CONN_IS: /* Idle-string */ #endif /* XLIMITS */ #ifdef CK_TRIGGER case CONN_TS: /* Trigger-string */ #endif /* CK_TRIGGER */ #ifdef XLIMORTRIGGER if (!getval) break; if ((x = cmfld("String (enclose in braces if it contains spaces)", "",&s,xxstring)) < 0) { if (x == -3) { printf("?String required\n"); x = -9; } goto xconnx; } if (n != CONN_TS) s = brstrip(s); if ((y = strlen(s)) > 0) { if (pv[n].sval) free(pv[n].sval); pv[n].sval = malloc(y+1); if (pv[n].sval) { strcpy(pv[n].sval,s); /* safe */ pv[n].ival = 1; } } break; #endif /* XLIMORTRIGGER */ default: printf("?Unexpected switch value - %d\n",cmresult.nresult); x = -9; goto xconnx; } } debug(F101,"doxconn cmresult.fcode","",cmresult.fcode); if (cmresult.fcode != _CMCFM) { printf("?Unexpected function code: %d\n",cmresult.fcode); x = -9; goto xconnx; } /* Command was confirmed so we can pre-pop command level. */ /* This is so CONNECT module won't think we're executing a script */ /* if CONNECT was the final command in the script. */ if (cmdlvl > 0) prepop(); #ifdef OS2 /* Make results available globally */ if (pv[CONN_IL].ival > -1) /* Idle limit */ tt_idlelimit = pv[CONN_IL].ival; if (pv[CONN_II].ival > -1) /* Idle limit */ tt_idlesnd_tmo = pv[CONN_II].ival; if (pv[CONN_IS].sval) /* Idle string */ if (tt_idlesnd_str = (char *)malloc((int)strlen(pv[CONN_IS].sval)+1)) strcpy(tt_idlesnd_str,pv[CONN_IS].sval); /* safe */ if (pv[CONN_TL].ival > -1) /* Session limit */ tt_timelimit = pv[CONN_TL].ival; async = (pv[CONN_AS].ival > 0 || pv[CONN_SY].ival <= 0 && cmdlvl == 0) ? 1 : 0; #endif /* OS2 */ #ifdef CK_TRIGGER if (pv[CONN_TS].sval) /* Trigger strings */ makelist(pv[CONN_TS].sval,tt_trigger,TRIGGERS); for (i = 0; i < TRIGGERS; i++) /* Trigger match pointers */ tt_trmatch[i] = NULL; if (triggerval) { /* Reset trigger value */ free(triggerval); triggerval = NULL; } #endif /* CK_TRIGGER */ #ifdef SSHCMD /* 2010/03/01... The previous connection was through the external ssh client and now, with that connection closed, the user says "connect" and expects a new connection to be made to the same host, because that's how all the other connection methods work, so (and this is quite a hack)... */ if (!ckstrcmp("ssh ",ttname,4,0)) { /* Previous "host" was "ssh blah" */ _PROTOTYP (int redossh, ( void ) ); extern int ttyfd; if (ttyfd < 0) { /* And connection is no longer open */ int xx; xx = redossh(); /* So redo the SSH connection */ if (xx < 0) return(xx); goto xconnx; } } #endif /* SSHCMD */ x = doconect((pv[CONN_NV].ival > 0) ? 1 : 0, async); { int xx; debug(F101,"doxconn doconect returns","",x); if ((xx = ttchk()) < 0) dologend(); debug(F101,"doxconn ttchk returns","",xx); } #ifdef CK_TRIGGER debug(F111,"doxconn doconect triggerval",triggerval,x); #endif /* CK_TRIGGER */ xconnx: /* Back from CONNECT -- Restore global settings */ if (!async) resconn(); success = (x > 0) ? 1 : 0; return(x); } #endif /* NOLOCAL */ #ifdef ADDCMD /* cx == XXADD or XXREMV */ /* fc == ADD_BIN or ADD_TXT */ static int doadd(cx,fc) int cx, fc; { #ifdef PATTERNS char * tmp[FTPATTERNS]; char **p = NULL; int i, j, k, n = 0, x = 0, last; #endif /* PATTERNS */ if (cx != XXADD && cx != XXREMV) { printf("?Unexpected function code: %d\n",cx); return(-9); } #ifdef PATTERNS while (n < FTPATTERNS) { /* Collect new patterns */ tmp[n] = NULL; if ((x = cmfld("Pattern","",&s,xxstring)) < 0) break; ckstrncpy(line,s,LINBUFSIZ); s = brstrip(line); makestr(&(tmp[n++]),s); } if (x == -3) x = cmcfm(); if (x < 0) goto xdoadd; p = (fc == ADD_BIN) ? binpatterns : txtpatterns; /* Which list */ last = 0; for (i = 0; i < FTPATTERNS; i++) { /* Find last one in list */ if (!p[i]) { last = i; break; } } if (cx == XXADD) { /* Adding */ if (last + n > FTPATTERNS) { /* Check if too many */ printf("?Too many patterns - %d is the maximum\n", FTPATTERNS); goto xdoadd; } for (i = 0; i < n; i++) { /* Copy in the new ones. */ for (j = 0, x = 0; x == 0 && j < last ; j++ ) x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */ if (x == 0) makestr(&(p[last++]),tmp[i]); } makestr(&(p[last]),NULL); /* Null-terminate the list */ x = 1; goto xdoadd; /* Done */ } else if (cx == XXREMV) { /* Remove something(s) */ int j, k; if (last == 0) /* List is empty */ goto xdoadd; /* Nothing to remove */ for (i = 0; i < n; i++) { /* i = Patterns they typed */ for (j = 0; j < last; j++) { /* j = Patterns in list */ /* Change this to ckstrcmp()... */ if (filecase) x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */ else x = ckstrcmp(tmp[i],p[j],-1,0); /* Case-independent match */ if (x) { /* This one matches */ makestr(&(p[j]),NULL); /* Free it */ for (k = j; k < last; k++) /* Move the rest up */ p[k] = p[k+1]; p[k] = NULL; /* Erase last one */ if (!p[k]) break; } } } } xdoadd: /* Common exit */ for (i = 0; i < n; i++) if (tmp[i]) free(tmp[i]); return(x); #endif /* PATTERNS */ } /* ADD SEND-LIST */ static int addsend(cx) int cx; { #ifndef NOMSEND extern struct keytab fttab[]; extern int nfttyp; struct filelist * flp; char * fmode = ""; int xmode = 0; int xbinary = 0; #endif /* NOMSEND */ #ifdef NOMSEND printf("?Sorry, ADD/REMOVE SEND-LIST not available.\n"); return(-9); #endif /* NOMSEND */ if (cx == XXREMV) { printf("?Sorry, REMOVE SEND-LIST not implemented yet.\n"); return(-9); } #ifndef NOMSEND #ifndef XYZ_INTERNAL if (protocol != PROTO_K) { printf("?Sorry, ADD SEND-LIST does not work with external protocols\n"); return(-9); } #endif /* XYZ_INTERNAL */ x = cmifi("File specification to add","", &s,&y,xxstring); if (x < 0) { if (x == -3) { printf("?A file specification is required\n"); return(-9); } else return(x); } ckstrncpy(tmpbuf,s,TMPBUFSIZ); s = tmpbuf; if (filesinlist == 0) /* Take care of \v(filespec) */ fspec[0] = NUL; zfnqfp(s,LINBUFSIZ,line); s = line; if (((int)strlen(fspec) + (int)strlen(s) + 1) < fspeclen) { strcat(fspec,s); /* safe */ strcat(fspec," "); /* safe */ } else printf("WARNING - \\v(filespec) buffer overflow\n"); xbinary = binary; if ((patterns || filepeek) /* FILE PATTERNS or SCAN is ON */ #ifdef CK_LABELED && binary != XYFT_L /* And not if FILE TYPE LABELED */ #endif /* CK_LABELED */ #ifdef VMS && binary != XYFT_I /* or FILE TYPE IMAGE */ #endif /* VMS */ ) { int k, x; x = -1; k = scanfile(line,&x,nscanfile); if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T; } fmode = gfmode(xbinary,0); if ((x = cmkey(fttab,nfttyp, "type of file transfer", fmode, xxstring)) < 0) return(x); xmode = x; cmarg2 = ""; if ((x = cmfld(y ? "\nAs-name template containing replacement variables such as \\v(filename)" : "Name to send it with", "",&s,NULL)) < 0) if (x != -3) return(x); #ifndef NOSPL if (y && *s) { char * p = tmpbuf; x = TMPBUFSIZ; zzstring(s,&p,&x); if (!strcmp(tmpbuf,s)) { printf( "?As-name for file group must contain variables such as \\v(filename)\n" ); return(-9); } } #endif /* NOSPL */ ckstrncpy(tmpbuf,s,TMPBUFSIZ); cmarg2 = tmpbuf; if ((x = cmcfm()) < 0) return(x); flp = (struct filelist *) malloc(sizeof(struct filelist)); if (flp) { if (filetail) filetail->fl_next = flp; filetail = flp; if (!filehead) filehead = flp; x = (int) strlen(line); /* Length of filename */ s = (char *) malloc(x + 1); if (s) { strcpy(s,line); /* safe */ flp->fl_name = s; flp->fl_mode = xmode; x = (int) strlen(cmarg2); /* Length of as-name */ if (x < 1) { flp->fl_alias = NULL; } else { s = (char *) malloc(x + 1); if (s) { strcpy(s,cmarg2); /* safe */ flp->fl_alias = s; } else { printf("Sorry, can't allocate space for as-name"); return(-9); } } flp->fl_next = NULL; filesinlist++; /* Count this node */ return(success = 1); /* Finished adding this node */ } else { printf("Sorry, can't allocate space for name"); return(-9); } } else { printf("Sorry, can't allocate file list node"); return(-9); } #endif /* NOMSEND */ } #endif /* ADDCMD */ #ifndef NOHTTP /* HTTP ops... */ #ifdef TCPSOCKET #define HTTP_GET 0 /* GET */ #define HTTP_PUT 1 /* PUT */ #define HTTP_POS 2 /* POST */ #define HTTP_IDX 3 /* INDEX */ #define HTTP_HED 4 /* HEAD */ #define HTTP_DEL 5 /* DELETE */ #define HTTP_CON 6 /* CONNECT */ #define HTTP_OPN 7 /* OPEN */ #define HTTP_CLS 8 /* CLOSE */ static struct keytab httptab[] = { { "close", HTTP_CLS, 0 }, { "connect", HTTP_CON, 0 }, { "delete", HTTP_DEL, 0 }, { "get", HTTP_GET, 0 }, { "head", HTTP_HED, 0 }, { "index", HTTP_IDX, 0 }, { "open", HTTP_OPN, 0 }, { "put", HTTP_PUT, 0 }, { "post", HTTP_POS, 0 } }; static int nhttptab = sizeof(httptab)/sizeof(struct keytab); /* HTTP switches */ #define HT_SW_AG 0 /* /AGENT */ #define HT_SW_HD 1 /* /HEADER */ #define HT_SW_US 2 /* /USER */ #define HT_SW_PW 3 /* /PASSWORD */ #define HT_SW_AR 4 /* /ARRAY */ #define HT_SW_TP 5 /* /TOSCREEN */ static struct keytab httpswtab[] = { { "/agent", HT_SW_AG, CM_ARG }, #ifndef NOSPL { "/array", HT_SW_AR, CM_ARG }, #endif /* NOSPL */ { "/header", HT_SW_HD, CM_ARG }, { "/password", HT_SW_PW, CM_ARG }, { "/toscreen", HT_SW_TP, 0 }, { "/user", HT_SW_US, CM_ARG }, { "", 0, 0 } }; static int nhttpswtab = sizeof(httpswtab)/sizeof(struct keytab) - 1; /* HTTP PUT/POST switches */ #define HT_PP_MT 0 /* /MIME-TYPE */ static struct keytab httpptab[] = { { "/mime-type", HT_PP_MT, CM_ARG }, { "", 0, 0 } }; static int nhttpptab = sizeof(httpptab)/sizeof(struct keytab) - 1; #define HTTP_MAXHDR 8 static int xdohttp(action, lfile, rf, dfile, agent, hdr, user, pass, mime, array, type) int action; char *lfile, *rf, *dfile, *agent, *hdr, *user, *pass, *mime, array; int type; /* xdohttp */ { int i, rc = 0; char * hdrlist[HTTP_MAXHDR]; char rfile[CKMAXPATH+1]; extern int httpfd; /* Check for a valid state to execute the command */ if (inserver) { printf("?The HTTP command may not be used from the IKS\r\n"); } else if (httpfd == -1) { if (http_reopen() < 0) printf("?No connection\n"); else rc = 1; } else { rc = 1; } /* If the command is not valid, exit with failure */ if (rc == 0) return(success = 0); if (action != HTTP_CON && rf[0] != '/') { rfile[0] = '/'; ckstrncpy(&rfile[1],rf,CKMAXPATH); } else { ckstrncpy(rfile,rf,CKMAXPATH); } for (i = 0; i < HTTP_MAXHDR; i++) /* Initialize header list */ hdrlist[i] = NULL; makelist(hdr,hdrlist,HTTP_MAXHDR); /* Make header list */ #ifdef BETADEBUG for (i = 0; i < nhttptab; i++) /* Find action keyword */ if (httptab[i].kwval == action) break; if (i == nhttptab) { /* Shouldn't happen... */ printf("?Invalid action - %d\n",action); return(0); /* Failure */ } printf("HTTP action: %s\n",httptab[i].kwd); printf(" Agent: %s\n",agent ? agent : "(null)"); if (hdrlist[1]) { printf(" Header list: 1. %s\n",hdrlist[0]); for (i = 1; i < HTTP_MAXHDR && hdrlist[i]; i++) printf("%15d. %s\n",i+1,hdrlist[i]); } else printf(" Header: %s\n",hdrlist[0] ? hdrlist[0] : "(null)"); printf(" User: %s\n",user ? user : "(null)"); #ifdef COMMENT printf(" Password: %<PASSWORD>",pass ? pass : "(null)"); #endif /* COMMENT */ #ifndef NOSPL if (array) printf(" Array: \\%%%c[]\n", array); else printf(" Array: (none)\n"); #endif /* NOSPL */ if (action == HTTP_PUT || action == HTTP_POS) printf(" Mime-type: %s\n",mime ? mime : "(null)"); printf(" Local file: %s\n",lfile ? lfile : "(null)"); printf(" Remote file: %s\n",rfile ? rfile : "(null)"); printf(" Destination file: %s\n",dfile ? dfile : "(null)"); #endif /* BETADEBUG */ /* The http_xxxx() functions return 0 on success, -1 on failure */ switch (action) { case HTTP_CON: { extern int ttyfd; rc = http_connect(httpfd,agent,hdrlist,user,pass,array,rfile); break; } case HTTP_DEL: rc = http_delete(agent,hdrlist,user,pass,array,rfile); break; case HTTP_GET: rc = http_get(agent,hdrlist,user,pass,array,lfile,rfile,type); break; case HTTP_HED: rc = http_head(agent,hdrlist,user,pass,array,lfile,rfile,type); break; case HTTP_PUT: rc = http_put(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile, type); break; case HTTP_POS: rc = http_post(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile, type); break; case HTTP_IDX: rc = http_index(agent,hdrlist,user,pass,array,lfile,rfile,type); break; default: rc = -1; } return(rc == 0 ? 1 : 0); /* Success is set by caller */ } #endif /* TCPSOCKET */ #endif /* NOHTTP */ #ifndef NOSPL /* ARRAY ops... */ static struct keytab arraytab[] = { { "clear", ARR_CLR, 0 }, { "copy", ARR_CPY, 0 }, { "dcl", ARR_DCL, CM_INV }, { "declare", ARR_DCL, 0 }, { "destroy", ARR_DST, CM_INV }, { "equate", ARR_EQU, CM_INV }, { "link", ARR_EQU, 0 }, { "resize", ARR_RSZ, 0 }, { "set", ARR_SET, 0 }, #ifndef NOSHOW { "show", ARR_SHO, 0 }, #endif /* NOSHOW */ { "sort", ARR_SRT, 0 }, { "undeclare", ARR_DST, 0 }, { "", 0, 0 } }; static int narraytab = sizeof(arraytab)/sizeof(struct keytab) - 1; #ifdef CKLEARN static struct keytab learnswi[] = { { "/close", 2, 0 }, { "/off", 0, 0 }, { "/on", 1, 0 } }; #endif /* CKLEARN */ int arrayitoa(x) int x; { /* Array index to array letter */ if (x == 1) return(64); else if (x < 0 || x > (122 - ARRAYBASE)) return(-1); else return(x + ARRAYBASE); } int arrayatoi(c) int c; { /* Array letter to array index */ if (c == 64) c = 96; if (c > 63 && c < 91) c += 32; if (c < ARRAYBASE || c > 122) return(-1); return(c - ARRAYBASE); } static int /* Declare an array */ dodcl(cx) int cx; { int i, n, v, lo, hi, rc = 0; int isdynamic = 0; char tmpbuf[64]; char ** p = NULL; char tmp[64]; /* Local temporary string buffer */ if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */ if (y == -3) { printf("?Array name required\n"); return(-9); } else return(y); } ckstrncpy(line,s,LINBUFSIZ); s = line; x = arraybounds(s,&lo,&hi); /* Check syntax and get bounds */ debug(F111,"dodcl arraybounds",s,x); if (x < 0) { /* Error - Maybe it's a variable */ char * p; /* whose value is an array name */ int n; p = tmpbuf; n = 63; p[0] = NUL; if (s[0] == CMDQ && s[1] == '&') s++; if (zzstring(s,&p,&n) > -1) { s = tmpbuf; x = arraybounds(s,&lo,&hi); debug(F111,"dodcl arraybounds 2",s,x); } if (x < 0) { printf("?Bad array name - \"%s\"\n",s); return(-9); } } debug(F101,"dodcl hi","",hi); debug(F101,"dodcl lo","",lo); debug(F101,"dodcl lo+1","",lo+1); if (lo == -1 && hi == -1) { /* Have good array name and bounds */ isdynamic = 1; n = CMDBL / 5; } else if (hi > -1) { printf("?Segment notation not allowed in array declarations\n"); return(-9); } else if ((lo+1) < 0) { debug(F101,"dodcl underflow","",lo+1); printf("?Dimension underflow\n"); return(-9); } else n = lo; x = arrayitoa(x); if (cx == XXUNDCL) { n = 0; v = 0; if ((y = cmcfm()) < 0) return(y); } else { p = (char **)malloc(sizeof(char **)*(n+1)); if (!p) { printf("?Memory allocation error\n"); return(-9); } v = 0; /* Highest initialized member */ p[0] = NULL; /* Element 0 */ keepallchars = 1; while (n > 0 && v < n) { /* Parse initializers */ p[v+1] = NULL; ckmakxmsg(tmp, 64, "Initial value for \\&", ckctoa((char)x), "[", ckitoa(v+1), "]", NULL,NULL,NULL,NULL,NULL,NULL,NULL ); rc = cmfld((char *)tmp,"",&s,xxstring); /* Get field */ if (rc < 0) { /* Error... */ if (rc == -3) { /* Empty element */ if (cmflgs == 1) /* because end of line? */ break; /* Yes, done initializing */ else /* No, it's just empty */ continue; /* Go on to next one. */ } else { /* Other parse error */ goto dclx; /* Go free temp pointers */ } } rc = 1; if (v == 0 && !strcmp(s,"=")) /* Skip the = sign. */ continue; s = brstrip(s); /* Strip any braces */ makestr(&(p[++v]),s); } keepallchars = 0; if ((y = cmtxt("Carriage return to confirm","",&s,NULL)) < 0) return(y); if (isdynamic) n = v; } if (dclarray((char)x,n) < 0) { /* Declare the array */ printf("?Declare failed\n"); goto dclx; } for (i = 1; i <= v; i++) { /* Add any initial values */ tmp[0] = '&'; ckmakmsg(&tmp[1],63,ckctoa((char)x),"[",ckitoa(i),"]"); if (addmac(tmp,p[i]) < 0) { printf("Array initialization error: %s %s\n",tmp,p[i]); rc = -9; goto dclx; } } dclx: if (p) { for (i = 1; i <= v; i++) if (p[i]) free(p[i]); free((char *)p); } debug(F101,"DCL rc","",rc); return(success = rc); } static int rszarray() { int i, x, y, n, lo, hi, islink = -1; char c, * s, ** ap = NULL; if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */ if (x == -3) { printf("?Array name required\n"); return(-9); } else return(x); } ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */ s = line; x = arraybounds(s,&lo,&hi); if (x < 0) { /* Parse the name, get index */ printf("?Bad array reference - \"%s\"\n", s); return(-9); } if (lo < 0 && hi < 0) { y = cmnum("New size","",10,&lo,xxstring); if (y < 0) { if (y == -3) printf("?New size required\n"); return(y); } } if ((y = cmcfm()) < 0) return(y); if (a_link[x] > -1) { /* Link? */ islink = x; /* Yes follow it */ x = a_link[x]; /* and remember */ } if (!a_ptr[x]) { printf("?Array not declared - \"%s\"\n", s); return(-9); } if (lo < 0) { printf("?New size required\n"); return(-9); } if (hi > -1) { printf("?Array segments not allowed for this operation\n"); return(-9); } c = arrayitoa(x); /* Get array letter */ if (c == '@') { /* Argument vector array off limits */ printf("?Sorry, \\&@[] is read-only\n"); return(-9); } if (lo == 0) { /* If new size is 0... */ dclarray(c,0); /* Undeclare the array */ return(success = 1); } n = a_dim[x]; /* Current size */ ap = (char **) malloc((lo+1) * sizeof(char *)); /* New array */ y = (n < lo) ? n : lo; for (i = 0; i <= y; i++) /* Copy the part that fits */ ap[i] = a_ptr[x][i]; if (n < lo) { /* If original array smaller */ for (; i <= lo; i++) /* initialize extra elements in */ ap[i] = NULL; /* new array to NULL. */ } else if (n > lo) { /* If new array smaller */ for (; i <= lo; i++) /* deallocate leftover elements */ makestr(&(a_ptr[x][i]),NULL); /* from original array. */ } free((char *)a_ptr[x]); /* Free original array list */ a_ptr[x] = ap; /* Replace with new one */ a_dim[x] = lo; /* Record the new dimension */ if (islink > -1) { /* Was this a link? */ a_ptr[islink] = ap; /* If so point to the resized array */ a_dim[islink] = lo; } else { /* If not are there links to here? */ for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */ if (i != x && a_link[i] == x) { /* Find and update them */ a_ptr[i] = ap; a_dim[i] = lo; } } } return(success = 1); } static int copyarray() { int i, j, x1, lo1, hi1, x2, lo2, hi2, whole = 0; char c1, c2, * a1, * a2; if ((y = cmfld("Name of source array","",&s,NULL)) < 0) return(y); ckstrncpy(line,s,LINBUFSIZ); a1 = line; if ((x1 = arraybounds(a1,&lo1,&hi1)) < 0) { printf("?Bad array reference - \"%s\"\n", a1); return(-9); } else if (!a_ptr[x1]) { printf("?Array not declared - \"%s\"\n", a1); return(-9); } c1 = arrayitoa(x1); if ((y = cmfld("Name of destination array","",&s,NULL)) < 0) return(y); ckstrncpy(tmpbuf,s,TMPBUFSIZ); a2 = tmpbuf; if ((x2 = arraybounds(a2,&lo2,&hi2)) < 0) { printf("?Bad array reference - \"%s\"\n", a2); return(-9); } c2 = arrayitoa(x2); if ((x = cmcfm()) < 0) return(x); if (c2 == '@') { /* Argument vector array off limits */ printf("?Sorry, \\&@[] is read-only\n"); return(-9); } if (lo1 < 0 && lo2 < 0 && hi1 < 0 && hi2 < 0) /* Special case for */ whole = 1; /* whole array... */ if (lo1 < 0) lo1 = whole ? 0 : 1; /* Supply lower bound of source */ if (hi1 < 0) hi1 = a_dim[x1]; /* Supply upper bound of source */ if (lo2 < 0) lo2 = whole ? 0 : 1; /* Lower bound of target */ if (hi2 < 0) hi2 = lo2 + hi1 - lo1; /* Upper bound of target */ if (a_ptr[x2]) { /* Target array is already declared? */ if (hi2 > a_dim[x2]) /* If upper bound out of range */ hi2 = a_dim[x2]; /* shrink to fit */ } else { /* Otherwise... */ x2 = dclarray(c2, hi2); /* declare the target array */ } for (i = lo1, j = lo2; i <= hi1 && j <= hi2; i++,j++) { /* Copy */ makestr(&(a_ptr[x2][j]),a_ptr[x1][i]); } return(success = 1); } static int /* Undeclare an array */ unarray() { int x, y, n, rc = 0; char c, * s; if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */ if (y == -3) { printf("?Array name required\n"); return(-9); } else return(y); } ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */ s = line; if ((y = cmcfm()) < 0) return(y); if ((x = arraybounds(s,&y,&n)) < 0) { /* Parse the name, get index */ printf("?Bad array reference - \"%s\"\n", s); return(-9); } if (y > 0 || n > 0) { printf("?Partial arrays can not be destroyed\n"); return(-9); } c = arrayitoa(x); /* Get array letter */ if (a_ptr[x]) { /* If array is declared */ if (c == '@') { /* Argument vector array off limits */ printf("?Sorry, \\&@[] is read-only\n"); return(-9); } rc = dclarray(c,-1); /* Undeclare the array */ } else /* It wasn't declared */ rc = 1; if (rc > -1) { /* Set return code and success */ success = 1; rc = 1; } else { success = 0; printf("?Failed - destroy \"\\&%c[]\"\n", c); rc = -9; } return(rc); } static int clrarray(cx) int cx; { int i, x, lo, hi; char c, * s, * val = NULL; if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */ if (x == -3) { printf("?Array name required\n"); return(-9); } else return(x); } ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */ s = line; if (cx == ARR_SET) { /* SET */ if ((x = cmtxt("Value","",&val,xxstring)) < 0) return(x); ckstrncpy(tmpbuf,val,TMPBUFSIZ); /* Value to set */ val = tmpbuf; if (!*val) val = NULL; } else if ((x = cmcfm()) < 0) /* CLEAR */ return(x); if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the name */ printf("?Bad array reference - \"%s\"\n", s); return(-9); } c = arrayitoa(x); /* Get array letter */ if (!a_ptr[x]) { /* If array is declared */ printf("?Array %s is not declared\n", s); return(-9); } else if (c == '@') { /* Argument vector array off limits */ printf("?Sorry, \\&@[] is read-only\n"); return(-9); } if (lo < 0) lo = 0; if (hi < 0) hi = a_dim[x]; for (i = lo; i <= hi; i++) /* Clear/Set selected range */ makestr(&(a_ptr[x][i]),val); return(success = 1); } extern char **aa_ptr[CMDSTKL][28]; extern int aa_dim[CMDSTKL][28]; static int /* Create symbolic link to an array */ linkarray() { int i = 0, x, y, lo, hi, flag = 0; char c, * s, * p; if ((x = cmfld("Array name not currently in use","",&s,NULL)) < 0) { if (x == -3) { printf("?Array name required\n"); return(-9); } else return(x); } ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of link name */ s = line; if ((x = cmfld("Name of existing array","",&p,xxstring)) < 0) { if (x == -3) { printf("?Array name required\n"); return(-9); } else return(x); } ckstrncpy(tmpbuf,p,TMPBUFSIZ); /* Make safe copy of array name */ p = tmpbuf; if ((x = cmcfm()) < 0) return(x); if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the link name */ printf("?Bad array reference - \"%s\"\n", s); return(-9); } if (a_ptr[x]) { /* Must not already exist */ c = arrayitoa(x); printf("?Array already exists: \\&%c[]\n", c); return(-9); } if (lo > -1 || hi > -1) { printf("?Sorry, whole arrays only: %s\n",s); return(-9); } if ((y = arraybounds(p,&lo,&hi)) < 0) { /* Parse the array name */ printf("?Bad array reference - \"%s\"\n", s); return(-9); } if (lo > -1 || hi > -1) { printf("?Sorry, whole arrays only: %s\n",p); return(-9); } if (x == y) { for (i = cmdlvl; i >= 0; i--) if (aa_ptr[i][x]) { flag++; break; } } if (flag) { a_ptr[x] = aa_ptr[i][y]; /* Link to saved copy */ a_dim[x] = aa_dim[i][y]; } else { /* Otherwise... */ c = arrayitoa(y); /* Check if it's declared */ if (!a_ptr[y]) { printf("?Array is not declared: \\&%c[]\n", c); return(-9); } if (a_link[y] > -1) { /* And if it's a link itself */ printf("?Links to links not allowed: \\&%c[]\n", c); return(-9); } a_ptr[x] = a_ptr[y]; /* All OK, make the link */ a_dim[x] = a_dim[y]; } a_link[x] = y; return(success = 1); } #endif /* NOSPL */ #ifndef NOCSETS static char * dcsetname = NULL; /* Get Display Character-Set Name */ char * getdcset() { char * s; int y; #ifdef PCFONTS extern int tt_font, ntermfont; extern struct keytab term_font[]; #endif /* PCFONTS */ s = ""; #ifdef OS2 y = os2getcp(); /* Default is current code page */ switch (y) { case 437: s = "cp437"; break; case 850: s = "cp850"; break; case 852: s = "cp852"; break; case 857: s = "cp857"; break; case 858: s = "cp858"; break; case 862: s = "cp862"; break; case 866: s = "cp866"; break; case 869: s = "cp869"; break; case 1250: s = "cp1250"; break; case 1251: s = "cp1251"; break; case 1252: s = "cp1252"; break; case 1253: s = "cp1253"; break; case 1254: s = "cp1254"; break; case 1255: s = "cp1255"; break; case 1256: s = "cp1256"; break; case 1257: s = "cp1257"; break; case 1258: s = "cp1258"; break; } #ifdef PCFONTS /* If the user has loaded a font with SET TERMINAL FONT then we want to change the default code page to the font that was loaded. */ if (tt_font != TTF_ROM) { for (y = 0; y < ntermfont; y++ ) { if (term_font[y].kwval == tt_font) { s = term_font[y].kwd; break; } } } #endif /* PCFONTS */ #else /* OS2 */ #ifdef COMMENT /* Hack not needed as of C-Kermit 7.1 */ if (fcharset == FC_1LATIN) { s = "latin1-iso"; /* Hack to avoid reporting "cp1252" */ } else { /* Report current file character set */ #endif /* COMMENT */ for (y = 0; y <= nfilc; y++) if (fcstab[y].kwval == fcharset) { s = fcstab[y].kwd; break; } #ifdef COMMENT } #endif /* COMMENT */ #endif /* OS2 */ makestr(&dcsetname,s); /* Return stable pointer */ return((char *)dcsetname); } #endif /* NOCSETS */ #ifndef NOFRILLS static int doclear() { if ((x = cmkey(clrtab,nclear,"item to clear", #ifdef NOSPL "device-buffer" #else "device-and-input" #endif /* NOSPL */ ,xxstring)) < 0) return(x); #ifndef NOSPL #ifdef OS2 if (x == CLR_CMD || x == CLR_TRM) { if ((z = cmkey(clrcmdtab,nclrcmd,"how much screen to clear\n", "all",xxstring)) < 0) return(z); } #endif /* OS2 */ #endif /* NOSPL */ if ((y = cmcfm()) < 0) return(y); /* Clear device input buffer if requested */ y = (x & CLR_DEV) ? ttflui() : 0; if (x & CLR_SCR) /* CLEAR SCREEN */ y = ck_cls(); /* (= SCREEN CLEAR = CLS) */ if (x & CLR_KBD) { /* CLEAR KEYBOARD */ int n; n = conchk(); y = 0; while (n-- > 0 && (y = coninc(0) > -1)) ; y = (y > -1) ? 0 : -1; } #ifndef NOSPL /* Clear INPUT command buffer if requested */ if (x & CLR_INP) { for (z = 0; z < inbufsize; z++) inpbuf[z] = NUL; inpbp = inpbuf; y = 0; } #ifdef CK_APC if (x & CLR_APC) { debug(F101,"Executing CLEAR APC","",apcactive); apcactive = 0; y = 0; } #endif /* CK_APC */ if (x & CLR_ALR) { setalarm(0L); y = 0; } #endif /* NOSPL */ #ifdef PATTERNS if (x & (CLR_TXT|CLR_BIN)) { int i; for (i = 0; i < FTPATTERNS; i++) { if (x & CLR_TXT) makestr(&txtpatterns[i],NULL); if (x & CLR_BIN) makestr(&binpatterns[i],NULL); } y = 0; } #endif /* PATTERNS */ #ifndef NODIAL if (x & CLR_DIA) { dialsta = DIA_UNK; y = 0; } #endif /* NODIAL */ #ifndef NOMSEND if (x & CLR_SFL) { /* CLEAR SEND-LIST */ if (filehead) { struct filelist * flp, * next; flp = filehead; while (flp) { if (flp->fl_name) free(flp->fl_name); if (flp->fl_alias) free(flp->fl_alias); next = flp->fl_next; free((char *)flp); flp = next; } } filesinlist = 0; filehead = NULL; filetail = NULL; addlist = 0; y = 0; } #endif /* NOMSEND */ #ifdef OS2 #ifndef NOLOCAL switch (x) { case CLR_SCL: clearscrollback(VTERM); break; case CLR_CMD: switch ( z ) { case CLR_C_ALL: clear(); break; case CLR_C_BOS: clrboscr_escape(VCMD,SP); break; case CLR_C_BOL: clrbol_escape(VCMD,SP); break; case CLR_C_EOL: clrtoeoln(VCMD,SP); break; case CLR_C_EOS: clreoscr_escape(VCMD,SP); break; case CLR_C_LIN: clrline_escape(VCMD,SP); break; case CLR_C_SCR: clearscrollback(VCMD); break; default: printf("Not implemented yet, sorry.\n"); break; } break; #ifndef NOTERM case CLR_TRM: switch ( z ) { case CLR_C_ALL: if (VscrnGetBufferSize(VTERM) > 0 ) { VscrnScroll(VTERM, UPWARD, 0, VscrnGetHeight(VTERM)-(tt_status[VTERM]?2:1), VscrnGetHeight(VTERM) - (tt_status[VTERM]?1:0), TRUE, SP ); cleartermscreen(VTERM); } break; case CLR_C_BOS: clrboscr_escape(VTERM,SP); break; case CLR_C_BOL: clrbol_escape(VTERM,SP); break; case CLR_C_EOL: clrtoeoln(VTERM,SP); break; case CLR_C_EOS: clreoscr_escape(VTERM,SP); break; case CLR_C_LIN: clrline_escape(VTERM,SP); break; case CLR_C_SCR: clearscrollback(VTERM); break; default: printf("Not implemented yet, sorry.\n"); break; } break; #endif /* NOTERM */ } y = 0; #endif /* NOLOCAL */ #endif /* OS2 */ return(success = (y == 0)); } #endif /* NOFRILLS */ #ifndef NOSPL static int doeval(cx) int cx; { char *p; char vnambuf[VNAML], * vnp = NULL; /* These must be on the stack */ if (!oldeval) { if ((y = cmfld("Variable name","",&s, ((cx == XX_EVAL) ? xxstring : NULL))) < 0) { if (y == -3) { printf("?Variable name required\n"); return(-9); } else return(y); } ckstrncpy(vnambuf,s,VNAML); /* Make a copy. */ vnp = vnambuf; if (vnambuf[0] == CMDQ && (vnambuf[1] == '%' || vnambuf[1] == '&')) vnp++; y = 0; if (*vnp == '%' || *vnp == '&') { if ((y = parsevar(vnp,&x,&z)) < 0) return(y); } } if ((x = cmtxt("Integer arithmetic expression","",&s,xxstring)) < 0) return(x); p = evala(s); if (!p) p = ""; if (oldeval && *p) printf("%s\n", p); ckstrncpy(evalbuf,p,32); if (!oldeval) return(success = addmac(vnambuf,p)); else return(success = *p ? 1 : 0); } #endif /* NOSPL */ #ifdef TNCODE static int dotelopt() { if ((x = cmkey(telcmd, ntelcmd, "TELNET command", "", xxstring)) < 0 ) return(x); switch (x) { case WILL: case WONT: case DO: case DONT: if ((y = cmkey(tnopts,ntnopts,"TELNET option","",xxstring)) < 0) return(y); if ((z = cmcfm()) < 0) return(z); switch (x) { case WILL: if (TELOPT_UNANSWERED_WILL(y)) return(success = 0); break; case WONT: if (TELOPT_UNANSWERED_WONT(y)) return(success = 0); break; case DO: if (TELOPT_UNANSWERED_DO(y)) return(success = 0); break; case DONT: if (TELOPT_UNANSWERED_DONT(y)) return(success = 0); break; } if (local) { success = ((tn_sopt(x,y) > -1) ? 1 : 0); } else { printf("ff%02x%02x\n",x,y); success = 1; } if (success) { switch (x) { case WILL: TELOPT_UNANSWERED_WILL(y) = 1; break; case WONT: if ( TELOPT_ME(y) ) TELOPT_UNANSWERED_WONT(y) = 1; break; case DO: TELOPT_UNANSWERED_DO(y) = 1; break; case DONT: if ( TELOPT_ME(y) ) TELOPT_UNANSWERED_DONT(y) = 1; break; } if (tn_wait("XXTELOP") < 0) { tn_push(); success = 0; } } return(success); case SB: if ((y=cmkey(tnsbopts,ntnsbopts,"TELNET option","",xxstring)) < 0) return(y); switch (y) { case TELOPT_NAWS: /* Some compilers require switch() to have at least 1 case */ #ifdef CK_NAWS TELOPT_SB(TELOPT_NAWS).naws.x = 0; TELOPT_SB(TELOPT_NAWS).naws.y = 0; if (local) return(success = ((tn_snaws() > -1) ? 1 : 0)); else return(success = 0); #else return(success = 0); #endif /* CK_NAWS */ } return(success = 0); #ifdef CK_KERBEROS #ifdef KRB5 case TN_FWD: success = (kerberos5_forward() == AUTH_SUCCESS); return(success); #endif /* KRB5 */ #endif /* CK_KERBEROS */ default: if ((z = cmcfm()) < 0) return(z); #ifndef NOLOCAL if (local) { CHAR temp[3]; if (network && IS_TELNET()) { /* TELNET */ temp[0] = (CHAR) IAC; temp[1] = x; temp[2] = NUL; success = (ttol((CHAR *)temp,2) > -1 ? 1 : 0); if (tn_deb || debses || deblog) { /* TN_MSG_LEN is in ckctel.h */ ckmakmsg(tn_msg,256,"TELNET SENT ",TELCMD(x),NULL,NULL); debug(F101,tn_msg,"",x); if (debses || tn_deb) tn_debug(tn_msg); } return(success); } return(success = 0); } else { #endif /* NOLOCAL */ printf("ff%02x\n",x); return(success = 1); #ifndef NOLOCAL } #endif /* NOLOCAL */ } } #endif /* TNCODE */ #ifndef NOPUSH #ifndef NOFRILLS static int doedit() { #ifdef OS2 char * p = NULL; #endif /* OS2 */ if (!editor[0]) { s = getenv("EDITOR"); if (s) ckstrncpy(editor,s,CKMAXPATH); editor[CKMAXPATH] = NUL; if (!editor[0]) { printf("?Editor not defined - use SET EDITOR to define\n"); return(-9); } } ckstrncpy(tmpbuf,editfile,TMPBUFSIZ); /* cmiofi() lets us parse the name of an existing file, or the name of a nonexistent file to be created. */ x = cmiofi("File to edit", (char *)tmpbuf, &s, &y, xxstring); debug(F111,"edit",s,x); if (x < 0 && x != -3) return(x); if (x == -3) { tmpbuf[0] = NUL; } else { ckstrncpy(tmpbuf,s,TMPBUFSIZ); } if ((z = cmcfm()) < 0) return(z); if (y) { printf("?A single file please\n"); return(-9); } if (nopush) { printf("?Sorry, editing not allowed\n"); return(success = 0); } if (tmpbuf[0]) { /* Get full path in case we change directories between EDIT commands */ zfnqfp(tmpbuf, CKMAXPATH, editfile); editfile[CKMAXPATH] = NUL; #ifdef OS2 p = editfile; /* Flip the stupid slashes */ while (*p) { if (*p == '/') *p = '\\'; p++; } #endif /* OS2 */ } else editfile[0] = NUL; if (editfile[0]) { if (zchki(editfile) < (CK_OFF_T)0 && zchko(editfile) < 0) { printf("?Access denied: %s\n",editfile); return(-9); } } x = 0; if (editopts[0]) { #ifdef OS2 x = ckindex("%1",(char *)editopts,0,0,1); if (x > 0) editopts[x] = 's'; else #endif /* OS2 */ x = ckindex("%s",(char *)editopts,0,0,1); } if (((int)strlen(editopts) + (int)strlen(editfile) + 1) < TMPBUFSIZ) { if (x) sprintf(tmpbuf,editopts,editfile); else sprintf(tmpbuf,"%s %s",editopts,editfile); } s = line; ckmakmsg(s,LINBUFSIZ,editor," ",tmpbuf,NULL); #ifdef OS2 p = s + strlen(editor); /* And again with the slashes */ while (p != s) { if (*p == '/') *p = '\\'; p--; } #endif /* OS2 */ conres(); x = zshcmd(s); concb((char)escape); return(x); } #endif /* NOFRILLS */ #endif /* NOPUSH */ #ifdef BROWSER static int dobrowse() { #ifdef OS2 char * p = NULL; #endif /* OS2 */ if (nopush) { printf("?Sorry, browsing not allowed\n"); return(success = 0); } #ifndef NT /* Windows lets the Shell Execute the URL if no Browser is defined */ if (!browser[0]) { s = getenv("BROWSER"); if (s) ckstrncpy(browser,s,CKMAXPATH); browser[CKMAXPATH] = NUL; if (!browser[0]) { printf("?Browser not defined - use SET BROWSER to define\n"); return(-9); } } #endif /* NT */ ckstrncpy(tmpbuf,browsurl,TMPBUFSIZ); if ((x = cmtxt("URL",(char *)browsurl,&s,xxstring)) < 0) return(x); ckstrncpy(browsurl,s,4096); x = 0; if (browsopts[0]) { #ifdef OS2 x = ckindex("%1",(char *)browsopts,0,0,1); if (x > 0) browsopts[x] = 's'; else #endif /* OS2 */ x = ckindex("%s",(char *)browsopts,0,0,1); } if (((int)strlen(browsopts) + (int)strlen(browsurl) + 1) < TMPBUFSIZ) { if (x) sprintf(tmpbuf,browsopts,browsurl); else sprintf(tmpbuf,"%s %s",browsopts,browsurl); } #ifdef NT if (!browser[0]) return(success = Win32ShellExecute(browsurl)); #endif /* NT */ s = line; ckmakmsg(s,LINBUFSIZ,browser," ",tmpbuf,NULL); #ifdef OS2 p = line + strlen(browser); /* Flip slashes */ while (p != line) { if (*p == '/') *p = '\\'; p--; } #endif /* OS2 */ conres(); x = zshcmd(s); concb((char)escape); return(x); } #endif /* BROWSER */ #ifdef CK_RECALL static int doredo() { /* Find a previous cmd and redo it */ extern int on_recall, in_recall; int x; char * p; if ((x = cmtxt( "pattern, or first few characters of a previous command", "*",&s,xxstring)) < 0) return(x); ckstrncpy(line,s,LINBUFSIZ); x = strlen(s); s = line; if (*s == '{') { /* Braces disable adding * to end */ if (s[x-1] == '}') { s[x-1] = NUL; s++; x--; } } else { /* No braces, add * to end. */ s[x] = '*'; s[x+1] = NUL; } while (x > 0 && s[x] == '*' && s[x-1] == '*') s[x--] = NUL; if (!on_recall || !in_recall) { printf("?Sorry, command recall can't be used now.\n"); return(-9); } if ((p = cmgetcmd(s))) { /* Look for it history buffer */ ckmakmsg(cmdbuf,CMDBL,p,"\r",NULL,NULL); /* Copy to command buffer */ if (!quiet) /* Echo it */ printf("%s\n",cmdbuf); cmaddnext(); /* Force re-add to history buffer */ return(cmflgs = -1); /* Force reparse */ } else { printf("?Sorry - \"%s\" not found\n", s); return(-9); } } #endif /* CK_RECALL */ #ifndef NOXFER #ifndef NOCSETS static int doassoc() { /* ASSOCIATE */ extern struct keytab tcstab[]; extern int ntcs; if ((x = cmkey(assoctab, nassoc, "", "", xxstring)) < 0 ) return(x); switch (x) { /* Associate what? */ case ASSOC_TC: /* Transfer character-set... */ if ((x = cmkey(tcstab, ntcs, "transfer character-set name","",xxstring)) < 0) return(x); if ((y = cmkey(fcstab, nfilc, "with file character-set","", xxstring)) < 0) if (y != -3) return(y); if ((z = cmcfm()) < 0) return(z); axcset[x] = y; return(success = 1); case ASSOC_FC: /* File character-set... */ if ((x = cmkey(fcstab, nfilc, "file character-set name","",xxstring)) < 0) return(x); if ((y = cmkey(tcstab, ntcs, "with transfer character-set","", xxstring)) < 0) if (y != -3) return(y); if ((z = cmcfm()) < 0) return(z); afcset[x] = y; return(success = 1); default: return(-2); } } #endif /* NOCSETS */ #endif /* NOXFER */ #ifndef NOHELP static int domanual() { #ifdef OS2 if ((x = cmcfm()) < 0) return(x); if (nopush) { printf("?Sorry, access to system commands is disabled.\n"); return(-9); } y = mxlook(mactab,"manual",nmac); if (y > -1) { z = maclvl; /* Save the current maclvl */ dodo(y,NULL,cmdstk[cmdlvl].ccflgs); /* Run the macro */ while (maclvl > z) { debug(F101,"XXMAN loop maclvl 1","",maclvl); sstate = (CHAR) parser(1); debug(F101,"XXMAN loop maclvl 2","",maclvl); if (sstate) proto(); } debug(F101,"XXMAN loop exit maclvl","",maclvl); return(success); } return(success = 0); #else if ((x = cmtxt( #ifdef UNIX "Carriage return to confirm the command, or manual topic", #else "Carriage return to confirm the command, or help topic", #endif /* UNIX */ "kermit", &s, xxstring ) ) < 0) return(x); #endif /* OS2 */ #ifdef UNIX ckmakmsg(tmpbuf,TMPBUFSIZ,"man ",s,NULL,NULL); #else ckmakmsg(tmpbuf,TMPBUFSIZ,"help ",s,NULL,NULL); #endif /* UNIX */ debug(F110,"MANUAL",tmpbuf,0); if (nopush) { printf("?Sorry, access to system commands is disabled.\n"); return(-9); } else { conres(); /* Restore the console */ success = zshcmd(tmpbuf); concb((char)escape); /* Restore CBREAK mode */ return(success); } } #endif /* NOHELP */ #ifndef NOHTTP #ifdef TCPSOCKET static struct keytab sslswtab[] = { { "/ssl", 1, 0 }, { "/tls", 1, 0 } }; #ifndef NOURL struct urldata http_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL}; #endif /* NOURL */ static int dohttp() { /* HTTP */ struct FDB sw, kw, fi; int n, getval, allinone = 0; char c, * p; char rdns[128]; char * http_agent = NULL; /* Parse results */ char * http_hdr = NULL; char * http_user = NULL; char * http_pass = NULL; char * http_mime = NULL; char * http_lfile = NULL; char * http_rfile = NULL; char * http_dfile = NULL; char http_array = NUL; int http_action = -1; char * http_host = NULL; char * http_srv = NULL; int http_ssl = 0; static char * http_d_agent = NULL; static char * http_d_user = NULL; static char * http_d_pass = NULL; static int http_d_type = 0; int http_type = http_d_type; #ifdef OS2 p = "Kermit 95"; /* Default user agent */ #else p = "C-Kermit"; #endif /* OS2 */ makestr(&http_agent,p); makestr(&http_mime,"text/HTML"); /* MIME type default */ rdns[0] = '\0'; cmfdbi(&sw, /* 1st FDB - general switches */ _CMKEY, /* fcode */ "OPEN, CLOSE, GET, HEAD, PUT, INDEX, or POST,\n or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nhttpswtab, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ httpswtab, /* Keyword table */ &kw /* Pointer to next FDB */ ); cmfdbi(&kw, /* 2nd FDB - commands */ _CMKEY, /* fcode */ "Command", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nhttptab, /* addtl numeric data 1: tbl size */ 0, /* addtl numeric data 2: 0 = keyword */ xxstring, /* Processing function */ httptab, /* Keyword table */ NULL /* Pointer to next FDB */ ); while (1) { x = cmfdb(&sw); /* Parse something */ if (x < 0) /* Error */ goto xhttp; n = cmresult.nresult; if (cmresult.fdbaddr == &kw) /* Command - exit this loop */ break; c = cmgbrk(); /* Switch... */ getval = (c == ':' || c == '='); x = -9; if (getval && !(cmgkwflgs() & CM_ARG)) { printf("?This switch does not take an argument\n"); goto xhttp; } switch (cmresult.nresult) { /* Handle each switch */ case HT_SW_TP: /* /TOSCREEN */ http_type = 1; break; case HT_SW_AG: /* /AGENT */ if (getval) { if ((x = cmfld("User agent",p,&s,xxstring)) < 0) goto xhttp; } else { s = p; } makestr(&http_agent,s); break; case HT_SW_HD: /* /HEADER */ s = NULL; if (getval) { if ((x = cmfld("Header line","",&s,xxstring)) < 0) { if (x == -3) s = NULL; else goto xhttp; } } makestr(&http_hdr,s); break; case HT_SW_US: /* /USER */ s = NULL; if (getval) { if ((x = cmfld("User ID","",&s,xxstring)) < 0) { if (x == -3) s = ""; else goto xhttp; } } makestr(&http_user,s); break; case HT_SW_PW: /* /PASSWORD */ debok = 0; s = NULL; if (getval) { if ((x = cmfld("Password","",&s,xxstring)) < 0) goto xhttp; } makestr(&http_pass,s); break; #ifndef NOSPL case HT_SW_AR: { /* /ARRAY: */ char * s2, array = NUL; if (!getval) { printf("?This switch requires an argument\n"); x = -9; goto xhttp; } if ((x = cmfld("Array name (a single letter will do)", "", &s, NULL )) < 0) { if (x == -3) { printf("?Array name required\n"); x = -9; goto xhttp; } else goto xhttp; } if (!*s) { printf("?Array name required\n"); x = -9; goto xhttp; } s2 = s; if (*s == CMDQ) s++; if (*s == '&') s++; if (!isalpha(*s)) { printf("?Bad array name - \"%s\"\n",s2); x = -9; goto xhttp; } array = *s++; if (isupper(array)) array = tolower(array); if (*s && (*s != '[' || *(s+1) != ']')) { printf("?Bad array name - \"%s\"\n",s2); http_array = NUL; x = -9; goto xhttp; } http_array = array; break; } #endif /* NOSPL */ default: x = -2; goto xhttp; } } http_action = n; /* Save the action */ if (http_action == HTTP_PUT || http_action == HTTP_POS) { cmfdbi(&sw, /* 1st FDB - switch */ _CMKEY, /* fcode */ "Local filename\n Or switch", /* help */ "", /* default */ "", /* addtl string data */ nhttpptab, /* keyword table size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ httpptab, /* Keyword table */ &fi /* Pointer to next FDB */ ); cmfdbi(&fi, /* 2nd FDB - filename */ _CMIFI, /* fcode */ "Local filename", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); while (1) { x = cmfdb(&sw); if (x < 0) goto xhttp; /* Free any malloc'd temp strings */ n = cmresult.nresult; if (cmresult.fcode != _CMKEY) break; c = cmgbrk(); /* Switch... */ getval = (c == ':' || c == '='); if (getval && !(cmgkwflgs() & CM_ARG)) { printf("?This switch does not take an argument\n"); x = -9; goto xhttp; } switch (n) { case HT_PP_MT: s = "text/HTML"; if (getval) { if ((x = cmfld("MIME type", "text/HTML",&s,xxstring)) < 0) goto xhttp; } makestr(&http_mime,s); break; default: x = -2; goto xhttp; } } makestr(&http_lfile,cmresult.sresult); n = ckindex("/",http_lfile,-1,1,0); if (n) p = &http_lfile[n]; else p = http_lfile; if ((x = cmfld("URL or remote filename",p,&s,xxstring)) < 0) { if (x == -3) { printf("?%s what?\n",(http_action == HTTP_PUT) ? "Put" : "Post"); x = -9; } goto xhttp; } if (!*s) s = NULL; makestr(&http_rfile,s); if ((x = cmtxt("Response filename","",&s,xxstring)) < 0) { if (x != -3) goto xhttp; } if (*s) makestr(&http_dfile,s); } switch (http_action) { case HTTP_DEL: /* DELETE */ if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) { if (x == -3) { printf("?Delete what?\n"); x = -9; } goto xhttp; } makestr(&http_rfile,s); break; case HTTP_CON: /* CONNECT */ if ((x = cmfld("Remote host[:port]","",&s,xxstring)) < 0) { if (x == -3) { printf("?Remote host[:port] is required\n"); x = -9; } goto xhttp; } makestr(&http_rfile,s); break; case HTTP_HED: { /* HEAD */ char buf[CKMAXPATH+1]; if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) { if (x == -3) { printf("?Head of what?\n"); x = -9; } goto xhttp; } makestr(&http_rfile,s); if (http_array || http_type) { /* Default result filename */ p = ""; /* None if /ARRAY or /TOSCREEN */ } else { n = ckindex("/",http_rfile,-1,1,0); /* Otherwise strip path */ if (n) /* and add ".head" */ p = &http_rfile[n]; else p = http_rfile; ckmakmsg(buf,CKMAXPATH,p,".head",NULL,NULL); p = buf; } if ((x = cmofi("Local filename",p,&s,xxstring)) < 0) { if (x != -3) goto xhttp; } makestr(&http_lfile,s); break; } case HTTP_GET: /* GET */ case HTTP_IDX: { /* INDEX */ extern int wildena; int tmp; char * lfile = ""; if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) { if (x == -3) { printf("?Get what?\n"); x = -9; } goto xhttp; } makestr(&http_rfile,s); if (http_action == HTTP_GET && !http_type) zstrip(http_rfile,&lfile); /* URLs often contain question marks or other metacharacters */ /* cmofi() doesn't like them */ tmp = wildena; wildena = 0; if ((x = cmofi("Local filename",lfile,&s,xxstring)) < 0) { wildena = tmp; if (x != -3) goto xhttp; } wildena = tmp; makestr(&http_lfile,s); break; } case HTTP_OPN: { int sslswitch = 0; #ifdef CK_SSL struct FDB sw, fl; cmfdbi(&sw, _CMKEY, /* fcode */ "IP host name or address, or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 2, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ sslswtab, /* Keyword table */ &fl /* Pointer to next FDB */ ); cmfdbi(&fl, /* 2nd FDB - host */ _CMFLD, /* fcode */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); x = cmfdb(&sw); /* Parse switch or host */ if (x < 0) /* Error */ goto xhttp; if (cmresult.fcode == _CMFLD) { /* Host */ s = cmresult.sresult; /* Set up expected pointer */ goto havehost; /* Go parse rest of command */ } sslswitch = 1; /* /SSL or /TLS switch - set flag */ #endif /* CK_SSL */ /* Parse host */ if ((x = cmfld("URL, hostname, or ip-address","",&s,xxstring)) < 0) { if (x == -3) { printf("?Open what?\n"); x = -9; } goto xhttp; } havehost: /* Come here with s -> host */ #ifdef CK_URL x = urlparse(s,&http_url); /* Was a URL given? */ if (x < 1) { /* Not a URL */ #endif /* CK_URL */ makestr(&http_host,s); if ((x = cmfld("Service name or port number", sslswitch ? "https" : "http",&s,xxstring)) < 0) goto xhttp; else makestr(&http_srv,s); #ifdef CK_URL } else if (ckstrcmp(http_url.svc,"http",-1,0) && /* Non-HTTP URL */ ckstrcmp(http_url.svc,"https",-1,0)) { printf("?Non-HTTP URL\n"); x = -9; goto xhttp; } else { /* Have HTTP URL */ makestr(&http_srv, http_url.svc); makestr(&http_user,http_url.usr); makestr(&http_pass,http_url.psw); makestr(&http_host,http_url.hos); if (http_url.por) makestr(&http_srv,http_url.por); makestr(&http_rfile,http_url.pth); } if (http_rfile) { /* Open, GET, and Close */ printf("?Directory/file path not allowed in HTTP OPEN URL\n"); x = -9; goto xhttp; } if (!ckstrcmp("https",http_srv,-1,0) || sslswitch || !ckstrcmp("443",http_srv,-1,0)) http_ssl = 1; #endif /* CK_URL */ break; } case HTTP_CLS: break; } if ((x = cmcfm()) < 0) goto xhttp; if (http_action == HTTP_OPN) { x = (http_open(http_host,http_srv,http_ssl,rdns,128,http_agent) == 0); if (x) { if (!quiet) { if (rdns[0]) printf("Connected to %s [%s]\r\n",http_host,rdns); else printf("Connected to %s\r\n",http_host); } if (http_agent) { if (http_d_agent) free(http_d_agent); http_d_agent = http_agent; http_agent = NULL; } if (http_user) { if (http_d_user) free(http_d_user); http_d_user = http_user; http_user = NULL; } if (http_pass) { if (http_d_pass) { memset(http_d_pass,0,strlen(http_d_pass)); free(http_d_pass); } http_d_pass = http_pass; http_pass = NULL; } http_d_type = http_type; } else { if (!quiet) printf("?HTTP Connection failed.\r\n"); } } else if (http_action == HTTP_CLS) { if (http_d_agent) { free(http_d_agent); http_d_agent = NULL; } if (http_d_user) { free(http_d_user); http_d_user = NULL; } if (http_d_pass) { memset(http_d_pass,0,strlen(http_d_pass)); free(http_d_pass); http_d_pass = NULL; } http_d_type = 0; x = (http_close() == 0); } if ((http_action != HTTP_CLS) && (http_action != HTTP_CON) && http_rfile) { /* Remote file is URL? */ /* All-in-one actions when a URL is given... */ #ifdef CK_URL if (urlparse(http_rfile,&http_url) > 0) { /* Have URL? */ if (ckstrcmp(http_url.svc,"http",-1,0) && /* It's an HTTP URL? */ ckstrcmp(http_url.svc,"https",-1,0)) { printf("?Non-HTTP URL\n"); x = -9; goto xhttp; } else { /* Yes, collect the pieces */ makestr(&http_srv, http_url.svc); makestr(&http_user,http_url.usr); makestr(&http_pass,http_url.psw); makestr(&http_host,http_url.hos); if (http_url.por) makestr(&http_srv,http_url.por); makestr(&http_rfile,http_url.pth); } if (!http_rfile) { /* Still have a path? */ makestr(&http_rfile,"/"); } if (!ckstrcmp("https",http_srv,-1,0) || /* Check for SSL/TLS */ !ckstrcmp("443",http_srv,-1,0)) http_ssl = 1; if (http_isconnected()) /* Close any open HTTP connection */ http_close(); if (http_pass == NULL && http_d_pass != NULL) makestr(&http_pass,http_d_pass); x = (http_open(http_host, http_srv,http_ssl,rdns,128,http_d_agent) == 0); if (x < 0) { x = 0; goto xhttp; } allinone = 1; } #endif /* CK_URL */ if (http_pass == NULL && http_d_pass != NULL) makestr(&http_pass,http_d_pass); if (http_action == HTTP_OPN && allinone) { http_action = HTTP_GET; } x = xdohttp(http_action, http_lfile, http_rfile, http_dfile, http_agent ? http_agent : http_d_agent, http_hdr, http_user ? http_user : http_d_user, http_pass ? http_pass : http_d_pass, http_mime, http_array, http_type ); if (allinone) x = (http_close() == 0); } xhttp: if (http_agent) free(http_agent); if (http_hdr) free(http_hdr); if (http_user) free(http_user); if (http_pass) { memset(http_pass,0,strlen(http_pass)); free(http_pass); } if (http_mime) free(http_mime); if (http_lfile) free(http_lfile); if (http_rfile) free(http_rfile); if (http_dfile) free(http_dfile); if (http_host) free(http_host); if (http_srv) free(http_srv); if (x > -1) success = x; return(x); } #endif /* TCPSOCKET */ #endif /* NOHTTP */ #ifndef NOSPL static int dotrace() { int on = 1; struct FDB sw, kw; cmfdbi(&sw, /* 1st FDB - switch */ _CMKEY, /* fcode */ "Trace object;\n Or switch", /* help */ "", /* default */ "", /* addtl string data */ 2, /* keyword table size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ onoffsw, /* Keyword table */ &kw /* Pointer to next FDB */ ); cmfdbi(&kw, /* 2nd FDB - Trace object */ _CMKEY, /* fcode */ "Trace object", /* help */ "all", /* default */ "", /* addtl string data */ ntracetab, /* keyword table size */ 0, /* addtl numeric data 2: 0 = keyword */ xxstring, /* Processing function */ tracetab, /* Keyword table */ NULL /* Pointer to next FDB */ ); if ((x = cmfdb(&sw)) < 0) return(x); if (cmresult.fdbaddr == &sw) { on = cmresult.nresult; if ((x = cmkey(tracetab, ntracetab,"","all",xxstring)) < 0) return(x); } else { x = cmresult.nresult; } if ((y = cmcfm()) < 0) return(y); switch (x) { case TRA_ASG: tra_asg = on; break; case TRA_CMD: tra_cmd = on; break; case TRA_ALL: tra_asg = on; tra_cmd = on; break; default: return(-2); } printf("TRACE %s\n", on ? "ON" : "OFF"); return(success = 1); } #endif /* NOSPL */ static int doprompt() { extern int xcmdsrc; if ((x = cmtxt("Optional message","",&s,xxstring)) < 0) return(x); #ifdef NOSPL printf("?Sorry, PROMPT requires script programming language\n"); return(-9); #else debug(F101,"Prompt cmdlvl","",cmdlvl); cmdlvl++; if (cmdlvl > CMDSTKL) { printf("?Command stack overflow: %d\n",cmdlvl); cmdlvl--; return(-9); } xcmdsrc = CMD_KB; cmdstk[cmdlvl].src = CMD_KB; /* Say we're at the prompt */ cmdstk[cmdlvl].lvl = 0; cmdstk[cmdlvl].ccflgs = cmdstk[cmdlvl-1].ccflgs; if (tra_cmd) printf("[%d] +P: \"(prompt)\"\n",cmdlvl); concb((char)escape); if (!quiet) printf( "(Recursive command prompt: Resume script with CONTINUE, STOP to stop...)\n" ); if (*s) { /* If prompt given */ makestr(&(prstring[cmdlvl-1]),cmgetp()); /* Save current prompt */ cmsetp(s); /* Set new one */ } return(success = 1); #endif /* NOSPL */ } #ifdef CKLEARN VOID learncmd(s) char *s; { /* Record commands in learned script */ char buf[64]; int i, k; if (learnfp && learning) { /* Only if open and on */ k = ckstrncpy(buf,s,64); for (i = 0; i < k; i++) { /* Get top-level command keyword */ if (buf[i] <= SP) { buf[i] = NUL; break; } } k = lookup(cmdtab,buf,ncmd,NULL); /* Look it up */ if (k == XXCON || k == XXLEARN) /* Don't record CONNECT or LEARN */ return; if (k == XXTEL) { fputs("SET HOST /NETWORK:TCP",learnfp); fputs(&s[i],learnfp); fputs(" TELNET /TELNET",learnfp); fputs("\nIF FAIL STOP 1 Connection failed\n",learnfp); } else { fputs(s,learnfp); fputs("\n",learnfp); } } } #endif /* CKLEARN */ #ifdef SSHCMD /* 2010/03/01... Reopen a connection that was made with an external ssh client after it has been closed. */ int redossh() { int x, netsave; x = nettype; debug(F111,"redossh nettype",ttname,nettype); if ((y = setlin(XXSSH,0,1)) < 0) { if (errno) printf("?%s\n",ck_errstr()); else return(y); nettype = x; /* Failed, restore net type. */ success = 0; return(y); } netsave = x; return(y); } #endif /* SSHCMD */ /* Like hmsga() in ckuus2.c but takes a single substitution parameter, s2, which replaces every occurrence of "%s" in the first argument. Added to print text containing the copyright year, so the year doesn't have to be hardwired into lots of scattered text strings. */ int /* Print an array of lines, */ #ifdef CK_ANSIC hmsgaa(char *s[], char *s2) /* pausing at end of each screen. */ #else hmsgaa(s,s2) char *s[]; char *s2; #endif /* CK_ANSIC */ { extern int hmtopline; #ifdef OS2 extern int tt_rows[], tt_cols[]; #else /* OS2 */ extern int tt_rows, tt_cols; #endif /* OS2 */ int x, y, i, j, k, n; if ((x = cmcfm()) < 0) return(x); #ifdef CK_TTGWSIZ #ifdef OS2 ttgcwsz(); #else /* OS2 */ /* Check whether window size changed */ if (ttgwsiz() > 0) { if (tt_rows > 0 && tt_cols > 0) { cmd_rows = tt_rows; cmd_cols = tt_cols; } } #endif /* OS2 */ #endif /* CK_TTGWSIZ */ printf("\n"); /* Start off with a blank line */ n = (hmtopline > 0) ? hmtopline : 1; /* Line counter */ for (i = 0; *s[i]; i++) { printf((char *)s[i],s2); /* Print a line. */ printf("\n"); y = (int)strlen(s[i]); k = 1; for (j = 0; j < y; j++) /* See how many newlines were */ if (s[i][j] == '\n') k++; /* in the string... */ n += k; if (n > (cmd_rows - 3) && *s[i+1]) /* After a screenful, give them */ if (!askmore()) return(0); /* a "more?" prompt. */ else n = 0; } printf("\n"); return(0); } /* D O C M D -- Do a command */ /* Returns: -2: user typed an illegal command -1: reparse needed 0: parse was successful (even tho command may have failed). */ #ifdef DEBUG int cmdstats[256] = { -1, -1 }; #endif /* DEBUG */ int docmd(cx) int cx; { extern int nolocal, cmkwflgs; debug(F101,"docmd entry, cx","",cx); activecmd = cx; doconx = ((activecmd == XXCON) || (activecmd == XXTEL) || (activecmd == XXRLOG) || (activecmd == XXPIPE) || (activecmd == XXIKSD) || (activecmd == XXPTY)); /* Originally all commands were handled with a big switch() statement, but eventually this started blowing up compilers. Now we have a series of separate if statements and small switches, with the commands that are most commonly executed in scipts and loops coming first, to speed up compute-bound scripts. */ #ifdef DEBUG if (cmdstats[0] == -1) { /* Count commands */ int i; /* for tuning... */ for (i = 0; i < 256; i++) cmdstats[i] = 0; } #endif /* DEBUG */ switch (cx) { case -4: /* EOF */ #ifdef OSK if (msgflg) printf("\n"); #else if (msgflg) printf("\r\n"); #endif /* OSK */ doexit(GOOD_EXIT,xitsta); case -3: /* Null command */ return(0); case -9: /* Like -2, but errmsg already done */ case -1: /* Reparse needed */ return(cx); case -6: /* Special */ case -2: /* Error, maybe */ #ifndef NOSPL /* Maybe they typed a macro name. Let's look it up and see. */ if (cx == -6) /* If they typed CR */ ckstrncat(cmdbuf,"\015",CMDBL); /* add it back to command buffer. */ if (ifcmd[cmdlvl] == 2) /* Watch out for IF commands. */ ifcmd[cmdlvl]--; repars = 1; /* Force reparse */ cmres(); cx = XXDO; /* Try DO command */ #else return(cx); #endif /* NOSPL */ default: if (cx < 0) return(cx); break; } #ifdef DEBUG if (cx < 256) cmdstats[cx]++; #endif /* DEBUG */ if ((cmkwflgs & CM_PSH) #ifndef NOPUSH && nopush #endif /* NOPUSH */ ) { printf("?Access to system disabled\n"); return(-9); } if ((cmkwflgs & CM_LOC) #ifndef NOLOCAL && nolocal #endif /* NOLOCAL */ ) { printf("?Connections disabled\n"); return(-9); } #ifndef NOSPL /* Used in FOR loops */ if (cx == XX_INCR || cx == XXINC || /* _INCREMENT, INCREMENT */ cx == XX_DECR || cx == XXDEC) /* _DECREMENT, DECREMENT */ return(doincr(cx)); /* Define (or change the definition of) a macro or variable */ if (cx == XXUNDEF || cx == XXUNDFX) { #ifdef IKSD if (inserver && !ENABLED(en_asg)) { printf("?Sorry, DEFINE/ASSIGN disabled\n"); return(-9); } #endif /* IKSD */ return(doundef(cx)); /* [_]UNDEFINE */ } if (cx == XXDEF || cx == XXASS || cx == XXDFX || cx == XXASX) { #ifdef IKSD if (inserver && !ENABLED(en_asg)) { printf("?Sorry, DEFINE/ASSIGN disabled\n"); return(-9); } #endif /* IKSD */ if (atmbuf[0] == '.' && !atmbuf[1]) /* "." entered as keyword */ xxdot = 1; /* i.e. with space after it... */ return(dodef(cx)); /* DEFINE, ASSIGN, etc... */ } /* IF, WHILE, and friends */ if (cx == XXIF || cx == XXIFX || cx == XXWHI || cx == XXASSER) { return(doif(cx)); } if (cx == XXSWIT) { /* SWITCH */ return(doswitch()); } /* GOTO, FORWARD, and _FORWARD (used internally by FOR, WHILE, etc) */ if (cx == XXGOTO || cx == XXFWD || cx == XXXFWD) { /* GOTO or FORWARD */ /* Note, here we don't set SUCCESS/FAILURE flag */ #ifdef COMMENT if ((y = cmfld("label","",&s,xxstring)) < 0) { if (y == -3) { if (cx != XXXFWD) { printf("?Label name required\n"); return(-9); } } else return(y); } ckstrncpy(tmpbuf,s,TMPBUFSIZ); if ((x = cmcfm()) < 0) return(x); #else if ((y = cmtxt("label","",&s,xxstring)) < 0) { if (y == -3) { if (cx != XXXFWD) { printf("?GOTO: Label name required: \"%s\" \"%s\"\n", atmbuf, cmdbuf); return(-9); } } else return(y); } ckstrncpy(tmpbuf,brstrip(s),TMPBUFSIZ); #endif /* COMMENT */ s = tmpbuf; debug(F111,"GOTO target",s,cx); return(dogoto(s,cx)); } if (cx == XXDO || cx == XXMACRO) { /* DO (a macro) */ char mnamebuf[16]; /* (buffer for controlled temp name) */ struct FDB kw, fl; int mx; /* Macro index (on stack!) */ debug(F101,"XXMACRO 0",line,cx); if (cx == XXDO) { if (nmac == 0) { printf("\n?No macros defined\n"); return(-9); } for (y = 0; y < nmac; y++) { /* copy the macro table into a */ mackey[y].kwd = mactab[y].kwd; /* regular keyword table */ mackey[y].kwval = y; /* with value = pointer to macro tbl */ mackey[y].flgs = mactab[y].flgs; } cmfdbi(&kw, /* First FDB - macro name */ _CMKEY, /* fcode */ "Macro", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nmac, /* addtl numeric data 1: tbl size */ 0, /* addtl numeric data 2: 0 = cmkey */ xxstring, /* Processing function */ mackey, /* Keyword table */ &fl /* Pointer to next FDB */ ); cmfdbi(&fl, /* 2nd FDB - for "{" */ _CMFLD, /* fcode */ "", /* hlpmsg */ "", "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); x = cmfdb(&kw); /* Parse something */ if (x < 0) { /* Error */ if (x == -3) { printf("?Macro name required\n"); return(-9); } else return(x); } if (cmresult.fcode == _CMKEY) { extern int mtchanged; char * macroname = NULL; /* In case args include an \fexec() that changes the macro table */ mx = x; /* Save macro index on stack */ mtchanged = 0; /* Mark state of macro table */ makestr(&macroname,mactab[mx].kwd); /* Save name */ if ((y = cmtxt("optional arguments","",&s,xxstring)) < 0) return(y); /* Get macro args */ if (mtchanged) { /* Macro table changed? */ mx = mlook(mactab,macroname,nmac); /* Look up name again */ } if (macroname) free(macroname); return(dodo(mx,s,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1); } ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* _CMFLD */ if (atmbuf[0] == '{') { if ((y = cmcfm()) < 0) return(y); } } else { /* XXMACRO ("immediate macro") */ int k = 0; line[k++] = '{'; line[k++] = SP; line[k] = NUL; debug(F111,"XXMACRO A",line,k); if ((y = cmtxt("Braced list of commands","",&s,xxstring)) < 0) return(y); k = ckstrncpy(line+k,s,LINBUFSIZ-k); debug(F111,"XXMACRO B",line,k); } x = strlen(line); if ((line[0] == '{' && line[x-1] != '}') || line[0] == '}') return(-2); if (line[0] != '{' && line[x-1] != '}') { /* Unknown command. If ON_UNKNOWN_COMMAND macro is defined, */ /* parse args and then execute it, but only if it is not */ /* already active. */ int k = -1; if (!unkmacro) { k = mxlook(mactab,"on_unknown_command",nmac); } if (k > -1) { ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ); z = maclvl; /* Save the current maclvl */ if ((y = cmtxt("text","",&s,xxstring)) < 0) return(y); ckstrncat(tmpbuf," ",TMPBUFSIZ); ckstrncat(tmpbuf,s,TMPBUFSIZ); unkmacro = 1; debug(F110,"ON_UNKNOWN_COMMAND",s,0); dodo(k,tmpbuf,cmdstk[cmdlvl].ccflgs); /* Run the macro */ while (maclvl > z) { sstate = (CHAR) parser(1); if (sstate) proto(); } debug(F101,"UNKMAC loop exit maclvl","",maclvl); unkmacro = 0; return(success); } if (x > 0) printf("?Not a command or macro name: \"%s\"\n",line); else printf("?Not a command or macro name.\n"); return(-9); } s = brstrip(line); sprintf(mnamebuf," ..tmp:%03d",cmdlvl); /* safe (16) */ x = addmac(mnamebuf,s); return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1); } if (cx == XXLBL) { /* LABEL */ if ((x = cmfld("label","",&s,xxstring)) < 0) { if (x == -3) { #ifdef COMMENT printf("?LABEL: Label name required: \"%s\"\n", cmdbuf); return(-9); #else s = ""; #endif /* COMMENT */ } else return(x); } debug(F111,"LABEL",s,x); if ((x = cmcfm()) < 0) return(x); return(0); } if (cx == XXEVAL || cx == XX_EVAL) /* _EVALUATE, EVALUATE */ return(doeval(cx)); #ifndef NOSEXP if (cx == XXSEXP) { /* Lisp-like S-Expression */ struct stringarray * q; char /* *p, *r, */ *tmp, *m; int i, k, n, quote = 0, contd = 0, size = 0, len = 0; extern int sexprc, sexppv; tmp = tmpbuf; /* Buffer to collect SEXP */ tmpbuf[0] = NUL; /* Clear it */ size = TMPBUFSIZ; /* Capacity of buffer */ sexprc = -1; /* Assume bad input */ n = 0; /* Paren balance counter */ while (1) { /* Allow SEXP on multiple lines */ m = contd ? "Continuation of S-Expression" : "S-Expression (\"help sexp\" for details)"; x = cmtxt(m,"",&s,xxstring); if (x < 0) return(x); if (!*s) /* Needed for (=) and (:) */ s = cmdbuf+1; /* I can't explain why. */ k = ckmakmsg(tmp, size, contd ? " " : "(", s, NULL, NULL); if (k < 1) { printf("?SEXP too long - %d max\n",TMPBUFSIZ); return(-9); } debug(F111,contd ? "sexp contd" : "sexp",s,k); for (i = len; i < len+k; i++) { /* Check balance */ if (!quote && tmpbuf[i] == CMDQ) { quote = 1; continue; } if (quote) { quote = 0; continue; } if (tmpbuf[i] == '(') n++; else if (tmpbuf[i] == ')') n--; } if (n == 0) { /* Break when balanced */ break; } if (n < 0) { /* Too many right parens */ printf("?Unbalanced S-Expression: \"%s\"\n",tmpbuf); return(-9); } contd++; /* Need more right parens */ cmini(ckxech); /* so keep parsing */ tmp += k; /* adjust buffer pointer */ size -= k; /* and capacity */ len += k; /* and length so far */ } s = tmpbuf; makestr(&lastsexp,s); q = cksplit(1,SEXPMAX,s,NULL,NULL,8,0,0); /* Precheck for > 1 SEXP */ debug(F101,"sexp split","",q->a_size); if (q->a_size == 1) { /* We should get exactly one back */ char * result, * dosexp(); sexprc = 0; /* Reset out-of-band return code */ result = dosexp(s); /* Get result */ debug(F111,"sexp result",result,sexprc); if (sexprc == 0) { /* Success */ /* Echo the result if desired */ if ((!xcmdsrc && sexpecho != SET_OFF) || sexpecho == SET_ON) printf(" %s\n",result ? result : ""); makestr(&sexpval,result); success = sexppv > -1 ? sexppv : 1; return(success); } } if (sexprc < 0) printf("?Invalid S-Expression: \"%s\"\n",lastsexp); return(-9); } #endif /* NOSEXP */ #endif /* NOSPL */ if (cx == XXECH || cx == XXXECH || cx == XXVOID #ifndef NOSPL || cx == XXAPC #endif /* NOSPL */ ) { /* ECHO or APC */ if ((x = cmtxt((cx == XXECH || cx == XXXECH) ? "Text to be echoed" : ((cx == XXVOID) ? "Text" : "Application Program Command text"), "", &s, xxstring ) ) < 0) return(x); if (!s) s = ""; #ifdef COMMENT /* This is to preserve the pre-8.0 behavior but it's too confusing */ x = strlen(s); x = (x > 1) ? ((s[0] == '"' && s[x-1] == '"') ? 1 : 0) : 0; #endif /* COMMENT */ s = brstrip(s); /* Strip braces and doublequotes */ if (cx == XXECH) { /* ECHO */ #ifndef NOSPL if (!fndiags || fnsuccess) { #endif /* NOSPL */ #ifdef COMMENT /* The "if (x)" business preserves previous behavior */ /* by putting back the doublequotes if they were included. */ if (x) printf("\"%s\"\n",s); else #endif /* COMMENT */ printf("%s\n",s); #ifndef NOSPL } #endif /* NOSPL */ } else if (cx == XXXECH) { /* XECHO */ if (x) printf("\"%s\"",s); else printf("%s",s); #ifdef UNIX fflush(stdout); #endif /* UNIX */ } else if (cx == XXAPC) { /* APC */ #ifdef CK_APC if (apcactive == APC_LOCAL || (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))) return(success = 0); #endif /* CK_APC */ if (!local) { printf("%c_%s%c\\",ESC,s,ESC); #ifdef UNIX fflush(stdout); #endif /* UNIX */ } else { /* Local mode - have connection */ #ifndef NOSPL if (ckmakxmsg(tmpbuf, /* Form APC string in buffer */ TMPBUFSIZ, ckctoa((char)ESC), ckctoa('_'), s, ckctoa((char)ESC), ckctoa('\\'), NULL,NULL,NULL,NULL,NULL,NULL,NULL ) > 0) return(success = dooutput(tmpbuf, XXOUT)); printf("?Too long\n"); return(-9); #else printf("%c_%s%c\\",ESC,s,ESC); #endif /* NOSPL */ } } return(success = 1); } #ifndef NOSPL /* Copy macro args from/to two levels up, used internally by _floop et al. */ if (cx == XXGTA || cx == XXPTA) { /* _GETARGS, _PUTARGS */ int x; debug(F101,"docmd XXGTA","",XXGTA); debug(F101,"docmd cx","",cx); debug(F101,"docmd XXGTA maclvl","",maclvl); x = dogta(cx); debug(F101,"docmd dogta returns","",x); debug(F101,"docmd dogta maclvl","",maclvl); return(x); } #endif /* NOSPL */ #ifndef NOSPL #ifdef CKCHANNELIO if (cx == XXFILE) return(dofile(cx)); else if (cx == XXF_RE || cx == XXF_WR || cx == XXF_OP || cx == XXF_CL || cx == XXF_SE || cx == XXF_RW || cx == XXF_FL || cx == XXF_LI || cx == XXF_ST || cx == XXF_CO) return(dofile(cx)); #endif /* CKCHANNELIO */ /* ASK, ASKQ, READ */ if (cx == XXASK || cx == XXASKQ || cx == XXREA || cx == XXRDBL || cx == XXGETC || cx == XXGETK) { return(doask(cx)); } #endif /* NOSPL */ #ifndef NOFRILLS #ifndef NOHELP if (cx == XXBUG) { /* BUG */ if ((x = cmcfm()) < 0) return(x); return(dobug()); } #endif /* NOHELP */ #endif /* NOFRILLS */ #ifndef NOXFER if (cx == XXBYE) { /* BYE */ extern int ftp_cmdlin; if ((x = cmcfm()) < 0) return(x); #ifdef NEWFTP if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) { extern int stayflg, ftp_fai; success = ftpbye(); if (ftp_cmdlin && !stayflg && !local) doexit(ftp_fai ? BAD_EXIT : GOOD_EXIT,-1); else return(success); } #endif /* NEWFTP */ if (!local) { printf("?No connection - use EXIT to quit.\n"); return(-9); } #ifdef CK_XYZ if (protocol != PROTO_K) { printf("?Sorry, BYE only works with Kermit protocol\n"); return(-9); } #endif /* CK_XYZ */ #ifdef IKS_OPTION if ( #ifdef CK_XYZ protocol == PROTO_K && #endif /* CK_XYZ */ !iks_wait(KERMIT_REQ_START,1)) { printf( "?A Kermit Server is not available to process this command\n"); return(-9); /* Correct the return code */ } #endif /* IKS_OPTION */ bye_active = 1; sstate = setgen('L',"","",""); if (local) ttflui(); /* If local, flush tty input buffer */ return(0); } #endif /* NOXFER */ if (cx == XXBEEP) { /* BEEP */ int x; #ifdef OS2 int y; if ((y = cmkey(beeptab, nbeeptab, "which kind of beep", "information", xxstring)) < 0 ) return (y); if ((x = cmcfm()) < 0) return(x); bleep((short)y); /* y is one of the BP_ values */ #else /* OS2 */ if ((x = cmcfm()) < 0) return(x); #ifndef NOSPL bleep(BP_NOTE); #else putchar('\07'); #endif /* NOSPL */ #endif /* OS2 */ return(0); } #ifndef NOFRILLS if (cx == XXCLE) /* CLEAR */ return(success = doclear()); #endif /* NOFRILLS */ if (cx == XXCOM) { /* COMMENT */ if ((x = cmtxt("Text of comment line","",&s,NULL)) < 0) return(x); /* Don't change SUCCESS flag for this one */ return(0); } #ifndef NOLOCAL if (cx == XXCON || cx == XXCQ) /* CONNECT or CONNECT /QUIETLY */ return(doxconn(cx)); #endif /* NOLOCAL */ #ifndef NOFRILLS #ifdef ZCOPY if (cx == XXCPY) { /* COPY a file */ #ifdef IKSD if (inserver && !ENABLED(en_cpy)) { printf("?Sorry, COPY is disabled\n"); return(-9); } #endif /* IKSD */ #ifdef CK_APC if (apcactive == APC_LOCAL || (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)) ) return(success = 0); #endif /* CK_APC */ return(docopy()); } #endif /* ZCOPY */ #ifdef NT if ( cx == XXLINK ) { #ifdef IKSD if (inserver && !ENABLED(en_cpy)) { printf("?Sorry, LINK (COPY) is disabled\n"); return(-9); } #endif /* IKSD */ #ifdef CK_APC if (apcactive == APC_LOCAL || (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)) ) return(success = 0); #endif /* CK_APC */ return(dolink()); } #endif /* NT */ #endif /* NOFRILLS */ /* CD and friends */ if (cx == XXCWD || cx == XXCDUP || cx == XXBACK || cx == XXLCWD || cx == XXLCDU || cx == XXKCD) { #ifdef LOCUS if (!locus) { if (cx == XXCWD) { #ifdef NOXFER return(-2); #else return(dormt(XZCWD)); #endif /* NOXFER */ } else if (cx == XXCDUP) { #ifdef NOXFER return(-2); #else return(dormt(XZCDU)); #endif /* NOXFER */ } } #endif /* LOCUS */ #ifdef IKSD if (inserver && !ENABLED(en_cwd)) { printf("?Sorry, changing directories is disabled\n"); return(-9); } #endif /* IKSD */ return(success = docd(cx)); } if (cx == XXCHK) /* CHECK */ return(success = dochk()); if (cx == XXCLO) { /* CLOSE */ x = cmkey(clstab,ncls,"\"CONNECTION\", or log or file to close", "connection",xxstring); if (x == -3) { printf("?You must say which file or log\n"); return(-9); } if (x < 0) return(x); if ((y = cmcfm()) < 0) return(y); #ifndef NOLOCAL if (x == 9999) { /* CLOSE CONNECTION */ x = clsconnx(0); switch (x) { case 0: if (msgflg) printf("?Connection was not open\n"); case -1: return(0); case 1: whyclosed = WC_CLOS; return(1); } return(0); } #endif /* NOLOCAL */ y = doclslog(x); success = (y == 1); return(success); } #ifndef NOSPL if (cx == XXDCL || cx == XXUNDCL) { /* DECLARE an array */ return(dodcl(cx)); } #endif /* NOSPL */ #ifndef NODIAL if (cx == XXRED || cx == XXDIAL || cx == XXPDIA || cx == XXANSW || cx == XXLOOK) { /* DIAL, REDIAL etc */ #ifdef VMS extern int batch; #else #ifdef UNIXOROSK extern int backgrd; #endif /* UNIXOROSK */ #endif /* VMS */ x = dodial(cx); debug(F101,"dodial returns","",x); if ((cx == XXDIAL || cx == XXRED || cx == XXANSW) && (x > 0) && /* If DIAL or REDIAL succeeded */ (dialsta != DIA_PART) && /* and it wasn't partial */ (dialcon > 0)) { if ((dialcon == 1 || /* And DIAL CONNECT is ON, */ ((dialcon == 2) && /* or DIAL CONNECT is AUTO */ !xcmdsrc /* and we're at top level... */ #ifdef VMS && !batch /* Not if running from batch */ #else #ifdef UNIXOROSK && !backgrd /* Not if running in background */ #endif /* UNIXOROSK */ #endif /* VMS */ ))) /* Or AUTO */ x = doconect(dialcq, /* Then also CONNECT */ cmdlvl == 0 ? 1 : 0 ); if (ttchk() < 0) dologend(); } return(success = x); } #endif /* NODIAL */ #ifndef NOPUSH #ifdef CK_REXX if (cx == XXREXX) { /* REXX */ extern int nopush; if ( nopush ) return(success=0); return(dorexx()); } #endif /* CK_REXX */ #endif /* NOPUSH */ #ifndef NOFRILLS if (cx == XXDEL || cx == XXLDEL) { /* DELETE */ #ifdef LOCUS if (!locus && cx != XXLDEL) { #ifdef NOXFER return(-2); #else return(dormt(XZDEL)); #endif /* NOXFER */ } #endif /* LOCUS */ #ifdef IKSD if (inserver && (!ENABLED(en_del) #ifdef CK_LOGIN || isguest #endif /* CK_LOGIN */ )) { printf("?Sorry, DELETE is disabled\n"); return(-9); } #endif /* IKSD */ #ifdef CK_APC if ((apcactive == APC_LOCAL) || ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH)))) return(success = 0); #endif /* CK_APC */ return(dodel()); } #endif /* NOFRILLS */ if (cx == XXTOUC) /* TOUCH */ return(dodir(cx)); /* DIRECTORY commands */ if (cx == XXDIR || cx == XXLS || cx == XXLDIR || cx == XXWDIR || cx == XXHDIR) { #ifdef LOCUS if (!locus && cx != XXLDIR) { #ifdef NOXFER return(-2); #else return(dormt(XZDIR)); #endif /* NOXFER */ } #endif /* LOCUS */ #ifdef IKSD if (inserver && !ENABLED(en_dir)) { printf("?Sorry, DIRECTORY is disabled\n"); return(-9); } #endif /* IKSD */ return(dodir(cx)); } #ifndef NOSPL if (cx == XXELS) /* ELSE */ return(doelse()); #endif /* NOSPL */ #ifndef NOSERVER #ifndef NOFRILLS if (cx == XXENA || cx == XXDIS) { /* ENABLE, DISABLE */ s = (cx == XXENA) ? "Server function to enable" : "Server function to disable"; if ((x = cmkey(enatab,nena,s,"",xxstring)) < 0) { if (x == -3) { printf("?Name of server function required\n"); return(-9); } else return(x); } if ((y = cmkey(kmstab,3,"mode","both",xxstring)) < 0) { if (y == -3) { printf("?Please specify remote, local, or both\n"); return(-9); } else return(y); } if (cx == XXDIS) /* Disabling, not enabling */ y = 3 - y; if ((z = cmcfm()) < 0) return(z); #ifdef CK_APC if ((apcactive == APC_LOCAL) || ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH)))) return(success = 0); #endif /* CK_APC */ #ifdef IKSD /* This may seem like it duplicates the work in doenable() */ /* but this code returns failure whereas doenable() returns */ /* success. */ if (inserver && #ifdef IKSDCONF iksdcf && #endif /* IKSDCONF */ (x == EN_HOS || x == EN_PRI || x == EN_MAI || x == EN_WHO || isguest)) return(success = 0); #endif /* IKSD */ return(doenable(y,x)); } #endif /* NOFRILLS */ #endif /* NOSERVER */ #ifndef NOSPL if (cx == XXRET) { /* RETURN */ if ((x = cmtxt("Optional return value","",&s,NULL)) < 0) return(x); s = brstrip(s); /* Strip braces */ if (cmdlvl == 0) /* At top level, nothing happens... */ return(success = 1); switch (cmdstk[cmdlvl].src) { /* Action depends on command source */ case CMD_TF: /* Command file */ popclvl(); /* Pop command level */ return(success = 1); /* always succeeds */ case CMD_MD: /* Macro */ case CMD_KB: /* Prompt */ return(doreturn(s)); /* Trailing text is return value. */ default: /* Shouldn't happen */ return(-2); } } #endif /* NOSPL */ #ifndef NOSPL if (cx == XXOPE) /* OPEN */ return(doopen()); #endif /* NOSPL */ #ifndef NOSPL if (cx == XXOUT || cx == XXLNOUT) { /* OUTPUT or LINEOUT */ if ((x = cmtxt("Text to be output","",&s,NULL)) < 0) return(x); #ifdef CK_APC if ((apcactive == APC_LOCAL) || ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH)))) return(success = 0); #endif /* CK_APC */ debug(F110,"OUTPUT 1",s,0); s = brstrip(s); /* Strip enclosing braces, */ debug(F110,"OUTPUT 2",s,0); /* I don't think I could ever fully explain this in a million years... We have read the user's string without calling the variable-expander function. Now, before we call it, we have to double backslashes that appear before \N, \B, \L, and \ itself, so the expander function will reduce them back to single backslashes, so when we call dooutput()... But it's more complicated than that. */ if (cmdgquo()) { /* Only if COMMAND QUOTING ON ... */ for (x = 0, y = 0; s[x]; x++, y++) { if (s[x] == CMDQ) { char c = s[x+1]; if (c == 'n' || c == 'N' || c == 'b' || c == 'B' || c == 'l' || c == 'L' || c == CMDQ) line[y++] = CMDQ; } line[y] = s[x]; } line[y++] = '\0'; /* Now expand variables, etc. */ debug(F110,"OUTPUT 3",line,0); s = line+y+1; x = LINBUFSIZ - (int) strlen(line) - 1; debug(F101,"OUTPUT size","",x); if (zzstring(line,&s,&x) < 0) return(success = 0); s = line+y+1; debug(F110,"OUTPUT 4",s,0); } success = dooutput(s,cx); return(success); } #endif /* NOSPL */ #ifdef ANYX25 #ifndef IBMX25 if (cx == XXPAD) { /* PAD commands */ x = cmkey(padtab,npadc,"PAD command","",xxstring); if (x == -3) { printf("?You must specify a PAD command to execute\n"); return(-9); } if (x < 0) return(x); switch (x) { case XYPADL: if (x25stat() < 0) printf("Sorry, you must 'set network' & 'set host' first\r\n"); else { x25clear(); initpad(); } break; case XYPADS: if (x25stat() < 0) printf("Not connected\r\n"); else { extern int linkid, lcn; conol("Connected thru "); conol(ttname); printf(", Link id %d, Logical channel number %d\r\n", linkid,lcn); } break; case XYPADR: if (x25stat() < 0) printf("Sorry, you must 'set network' & 'set host' first\r\n"); else x25reset(0,0); break; case XYPADI: if (x25stat() < 0) printf("Sorry, you must 'set network' & 'set host' first\r\n"); else x25intr(0); } return(0); } #endif /* IBMX25 */ #endif /* ANYX25 */ #ifndef NOSPL if (cx == XXPAU || cx == XXWAI || cx == XXMSL) /* PAUSE, WAIT, etc */ return(dopaus(cx)); #endif /* NOSPL */ #ifndef NOFRILLS if (cx == XXPRI) { #ifdef IKSD #ifdef CK_LOGIN if (inserver && (isguest || !ENABLED(en_pri))) { printf("?Sorry, printing is disabled\n"); return(-9); } #endif /* CK_LOGIN */ #endif /* IKSD */ if ((x = cmifi("File to print","",&s,&y,xxstring)) < 0) { if (x == -3) { printf("?A file specification is required\n"); return(-9); } else return(x); } if (y != 0) { printf("?Wildcards not allowed\n"); return(-9); } ckstrncpy(line,s,LINBUFSIZ); s = ""; #ifndef NT if ((x = cmtxt("Local print command options, or carriage return","",&s, xxstring)) < 0) return(x); #endif /* NT */ if ((x = cmcfm()) < 0) return(x); return(success = (zprint(s,line) == 0) ? 1 : 0); } #endif /* NOFRILLS */ #ifdef TCPSOCKET #ifndef NOPUSH if (cx == XXPNG) /* PING an IP host */ return(doping()); #endif /* NOPUSH */ #ifndef NOFTP if (cx == XXFTP) /* FTP */ #ifdef SYSFTP #ifndef NOPUSH return(doftp()); /* Just runs system's ftp program */ #else return(-2); #endif /* NOPUSH */ #else return(doxftp()); #endif /* SYSFTP */ #endif /* NOFTP */ #endif /* TCPSOCKET */ if (cx == XXPWD || cx == XXLPWD) { /* PWD */ #ifdef OS2 char *pwp; #endif /* OS2 */ if ((x = cmcfm()) < 0) return(x); #ifdef LOCUS if (!locus && cx != XXLPWD) { #ifdef NOXFER return(-2); #else return(dormt(XZPWD)); #endif /* NOXFER */ } #endif /* LOCUS */ #ifndef MAC #ifndef OS2 #ifdef UNIX printf("%s\n",zgtdir()); #else xsystem(PWDCMD); #endif /* UNIX */ return(success = 1); /* Blind faith */ #else /* OS2 */ if (pwp = zgtdir()) { if (*pwp) { #ifdef NT line[0] = NUL; ckGetLongPathName(pwp,line,LINBUFSIZ); line[LINBUFSIZ-1] = NUL; tmpbuf[0] = NUL; GetShortPathName(pwp,tmpbuf,TMPBUFSIZ); tmpbuf[TMPBUFSIZ-1] = NUL; pwp = line; if (!strcmp(line,tmpbuf)) { #endif /* NT */ printf("%s\n",pwp); #ifdef NT } else { printf(" Long name: %s\n",line); printf(" Short name: %s\n",tmpbuf); } #endif /* NT */ } return(success = ((int)strlen(pwp) > 0)); } else return(success = 0); #endif /* OS2 */ #else /* MAC */ if (pwp = zgtdir()) { printf("%s\n",pwp); return(success = ((int)strlen(pwp) > 0)); } else return(success = 0); #endif /* MAC */ } if (cx == XXQUI || cx == XXEXI) { /* EXIT, QUIT */ extern int quitting; if ((y = cmnum("exit status code",ckitoa(xitsta),10,&x,xxstring)) < 0) return(y); if ((y = cmtxt("Optional EXIT message","",&s,xxstring)) < 0) return(y); s = brstrip(s); ckstrncpy(line,s,LINBUFSIZ); if (!hupok(0)) /* Check if connection still open */ return(success = 0); if (line[0]) /* Print EXIT message if given */ printf("%s\n",(char *)line); quitting = 1; /* Flag that we are quitting. */ #ifdef VMS doexit(GOOD_EXIT,x); #else #ifdef OSK /* Returning any codes here makes the OS-9 shell print an error message. */ doexit(GOOD_EXIT,-1); #else #ifdef datageneral doexit(GOOD_EXIT,x); #else doexit(x,-1); #endif /* datageneral */ #endif /* OSK */ #endif /* VMS */ } #ifndef NOXFER #ifndef NOFRILLS if (cx == XXERR) { /* ERROR */ #ifdef CK_XYZ if (protocol != PROTO_K) { printf("Sorry, E-PACKET only works with Kermit protocol\n"); return(-9); } #endif /* CK_XYZ */ if ((x = cmcfm()) < 0) return(x); ttflui(); epktflg = 1; sstate = 'a'; return(0); } #endif /* NOFRILLS */ if (cx == XXFIN) { /* FINISH */ #ifdef NEWFTP if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) return(ftpbye()); #endif /* NEWFTP */ #ifdef CK_XYZ if (protocol != PROTO_K) { printf("Sorry, FINISH only works with Kermit protocol\n"); return(-9); } #endif /* CK_XYZ */ if ((x = cmcfm()) < 0) return(x); #ifdef IKS_OPTION if ( #ifdef CK_XYZ protocol == PROTO_K && #endif /* CK_XYZ */ !iks_wait(KERMIT_REQ_START,1)) { printf( "?A Kermit Server is not available to process this command\n"); return(-9); /* Correct the return code */ } #endif /* IKS_OPTION */ sstate = setgen('F',"","",""); if (local) ttflui(); /* If local, flush tty input buffer */ return(0); } #endif /* NOXFER */ #ifndef NOSPL if (cx == XXFOR) /* FOR loop */ return(dofor()); #endif /* NOSPL */ #ifndef NOXFER /* GET MGET REGET RETRIEVE etc */ if (cx == XXGET || cx == XXMGET || cx == XXREGET || cx == XXRETR) { #ifdef IKSD if (inserver && !ENABLED(en_sen)) { printf("?Sorry, reception of files is disabled\n"); return(-9); } #endif /* IKSD */ return(doxget(cx)); } #endif /* NOXFER */ #ifndef NOSPL #ifndef NOFRILLS if (cx == XXGOK) { /* GETOK */ return(success = doask(cx)); } #endif /* NOFRILLS */ #endif /* NOSPL */ if (cx == XXHLP) { /* HELP */ #ifdef NOHELP return(dohlp(XXHLP)); #else x = cmkey2(cmdtab, ncmd,"\nCommand or topic","help",toktab,xxstring,1+2+8); debug(F111,"HELP command x",cmdbuf,x); if (x == -5) { y = chktok(toktab); debug(F101,"HELP cmkey token","",y); /* ungword(); */ switch (y) { #ifndef NOPUSH case '!': case '@': x = XXSHE; break; case '<': x = XXFUN; break; #endif /* NOPUSH */ case '#': x = XXCOM; break; case ';': x = XXCOM; break; #ifndef NOSPL case '.': x = XXDEF; break; case ':': x = XXLBL; break; #ifndef NOSEXP case '(': x = XXSEXP; break; #endif /* NOSEXP */ #endif /* NOSPL */ #ifdef CK_RECALL case '^': x = XXREDO; break; #endif /* CK_RECALL */ case '&': x = XXECH; break; /* (what is this?) */ default: printf("\n?Invalid - %s\n",cmdbuf); x = -2; } } makestr(&hlptok,atmbuf); debug(F111,"HELP token",hlptok,x); return(dohlp(x)); #endif /* NOHELP */ } #ifndef NOHELP if (cx == XXINT) /* INTRO */ return(hmsga(introtxt)); if (cx == XXNEW) { /* NEWS */ int x; extern char * k_info_dir; x = hmsga(newstxt); return(x); } #ifdef OS2ONLY if (cx == XXUPD) { /* View UPDATE file */ extern char exedir[]; char * pTopic; char updstr[2048]; if ((x = cmtxt("topic name","",&pTopic,xxstring)) < 0) return x; #ifdef COMMENT sprintf(updstr, "start view %s\\docs\\k2.inf+%s\\docs\\using_ck.inf+\ %s\\docs\\dialing.inf+%s\\docs\\modems.inf %s", exedir,exedir,exedir,exedir,pTopic ); #else if (ckmakxmsg(updstr, 2048, "start view ", exedir, "\\docs\\k2.inf+", exedir, "\\docs\\using_ck.inf+", exedir, "\\docs\\dialing.inf+", exedir, "\\docs\\modems.inf ", pTopic, NULL, NULL ) > 0) #endif /* COMMENT */ system(updstr); return(success = 1); } #endif /* OS2ONLY */ #endif /* NOHELP */ #ifndef NOLOCAL if (cx == XXHAN) { /* HANGUP */ if ((x = cmcfm()) < 0) return(x); #ifdef NEWFTP if ((ftpget == 1) || ((ftpget == 2) && !local && ftpisopen())) return(success = ftpbye()); #endif /* NEWFTP */ #ifndef NODIAL if ((x = mdmhup()) < 1) { debug(F101,"HANGUP mdmup","",x); #endif /* NODIAL */ x = tthang(); debug(F101,"HANGUP tthang","",x); x = (x > -1); #ifndef NODIAL } dialsta = DIA_UNK; #endif /* NODIAL */ whyclosed = WC_CLOS; ttchk(); /* In case of CLOSE-ON-DISCONNECT */ dologend(); #ifdef OS2 if (x) DialerSend(OPT_KERMIT_HANGUP, 0); #endif /* OS2 */ if (x) haveline = 0; return(success = x); } #endif /* NOLOCAL */ #ifndef NOSPL /* INPUT, REINPUT, and MINPUT */ if (cx == XXINP || cx == XXREI || cx == XXMINP) { long zz; int flags = 0, incount = 0; extern int itsapattern, isjoin, isinbuflen; int c, getval; struct FDB sw, nu, fl; int fc, havetime = 0; char * m; if (cx == XXREI) { m = "Timeout in seconds (ignored)"; } else { m = "Seconds to wait for input,\n or time of day hh:mm:ss,\ or switch"; } cmfdbi(&sw, /* First FDB - command switches */ _CMKEY, /* fcode */ m, /* helpmsg */ ckitoa(indef), /* default */ "", /* addtl string data */ ninputsw, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ inputsw, /* Keyword table */ &nu /* Pointer to next FDB */ ); cmfdbi(&nu, _CMNUM, /* Number */ m, /* Help message */ ckitoa(indef), /* default */ "", /* N/A */ 10, /* Radix = 10 */ 0, /* N/A */ xxstring, /* Processing function */ NULL, /* N/A */ &fl /* Next */ ); cmfdbi(&fl, /* Time of day hh:mm:ss */ _CMFLD, /* fcode */ "", /* hlpmsg */ "", "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); fc = (cx == XXREI) ? cmfdb(&nu) : cmfdb(&sw); /* Parse something */ for (y = 0; y < MINPMAX; y++) { /* Initialize search strings */ mp[y] = 0; /* Assume it's not a pattern */ if (!mpinited) { ms[y] = NULL; } if (ms[y]) { free(ms[y]); /* Free old strings, if any */ ms[y] = NULL; } } mpinited = 1; while (!havetime) { if (fc < 0) { /* Error */ if (fc == -3) { printf("?Syntax error in INPUT-class command\n"); return(-9); } else return(fc); } switch (cmresult.fcode) { case _CMKEY: /* Switch */ c = cmgbrk(); if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) { printf("?This switch does not take an argument\n"); return(-9); } if (getval && cmresult.nresult == INPSW_COU) { if ((y = cmnum("Number of bytes to read", "",10,&x,xxstring)) < 0) return(y); incount = x; } flags |= cmresult.nresult; fc = cmfdb(&sw); /* Maybe parse more switches */ continue; case _CMNUM: /* Seconds to time out */ x = cmresult.nresult; #ifdef CKFLOAT if (inscale != 1.0) /* Scale */ x *= inscale; #endif /* CKFLOAT */ havetime++; break; case _CMFLD: zz = tod2sec(atmbuf); /* Convert to secs since midnight */ if (zz < 0L) { printf("?Number, expression, or time of day required\n"); return(-9); } else { char now[32]; /* Current time */ char *p; long tnow; p = now; ztime(&p); tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17); if (zz < tnow) /* User's time before now */ zz += 86400L; /* So make it tomorrow */ zz -= tnow; /* Seconds from now. */ if (zz > -1L) { x = zz; if (zz != (long) x) { printf( "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n" ); return(-9); } } havetime++; } break; default: printf("?Internal error\n"); return(-9); } } /* Now parse the search text */ #ifdef CK_MINPUT if (cx == XXMINP) { /* MINPUT */ int i, k = 0, n = 0; struct stringarray * q; keepallchars = 1; while (k < MINPMAX) { if ((y = cmfld("String or pattern","",&s,xxstring)) < 0) { if (y == -3) { if ((y = cmcfm()) < 0) return(y); break; } else { return(y); } } debug(F111,"MINPUT field",s,k); if (isjoin) { if ((q = cksplit(1,0,s," ",(char *)c1chars,3,0,0))) { char ** ap = q->a_head; n = q->a_size; debug(F101,"minput cksplit size","",n); for (i = 1; i <= n && k < MINPMAX; i++) { if (!ap[i]) /* Add non-empty elements */ continue; if (!*(ap[i])) continue; makestr(&(ms[k]),ap[i]); debug(F111,"MINPUT JOIN",ms[k],k); k++; } } } else { if (s) if (*s) { makestr(&(ms[k]),brstrip(s)); if (itsapattern) mp[k] = 1; debug(F111,"MINPUT",ms[k],itsapattern); k++; } } } keepallchars = 0; } else { #endif /* CK_MINPUT */ /* INPUT or REINPUT */ if (flags & INPSW_COU) { if ((y = cmcfm()) < 0) return(y); } else { if ((y = cmtxt("Material to be input","",&s,xxstring)) < 0) return(y); } mp[0] = itsapattern ? 1 : 0; makestr(&(ms[0]),brstrip(s)); ms[1] = NULL; #ifdef CK_MINPUT } #endif /* CK_MINPUT */ if (incount > 0) /* No searching if /COUNT: given */ makestr(&(ms[0]),NULL); if (cx == XXINP || cx == XXMINP) { /* Not REINPUT... */ i_active = 1; /* Go try to input the search string */ success = doinput(x,ms,mp,flags,incount); i_active = 0; } else { /* REINPUT */ success = doreinp(x,ms[0],itsapattern); } if (intime[cmdlvl] && !success) { /* TIMEOUT-ACTION = QUIT? */ popclvl(); /* If so, pop command level. */ if (pflag && cmdlvl == 0) { if (cx == XXINP) printf("?INPUT timed out\n"); if (cx == XXMINP) printf("?MINPUT timed out\n"); if (cx == XXREI) printf("?REINPUT failed\n"); } } return(success); /* Return do(re)input's return code */ } #endif /* NOSPL */ if (cx == XXLOG) { /* LOG */ x = cmkey(logtab,nlog,"What to log","",xxstring); if (x == -3) { printf("?Type of log required\n"); return(-9); } if (x < 0) return(x); x = dolog(x); if (x < 0) return(x); else return(success = x); } if (cx == XXLOGIN) { /* (REMOTE) LOGIN */ #ifdef NEWFTP if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) return(success = doftpusr()); #endif /* NEWFTP */ #ifdef IKSD if (inserver) { printf("?Already logged in\n"); return(-9); } else #endif /* IKSD */ { #ifdef NOXFER return(-2); #else return(dormt(XZLGI)); #endif /* NOXFER */ } } if (cx == XXLOGOUT) { /* (REMOTE) LOGOUT */ #ifdef NEWFTP if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) return(success = doftpres()); #endif /* NEWFTP */ #ifdef IKSD if (inserver) { if ((x = cmcfm()) < 0) return(x); doexit(GOOD_EXIT,xitsta); } else #endif /* IKSD */ if (!local || (network && ttchk() < 0)) { printf("?No connection.\n"); return(-9); } else { #ifdef NOXFER return(-2); #else return(dormt(XZLGO)); #endif /* NOXFER */ } } #ifndef NOSCRIPT if (cx == XXLOGI) { /* UUCP-style script */ if ((x = cmtxt("expect-send expect-send ...","",&s,xxstring)) < 0) return(x); #ifdef CK_APC if ((apcactive == APC_LOCAL) || ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH)))) return(success = 0); #endif /* CK_APC */ #ifdef VMS conres(); /* For Ctrl-C to work... */ #endif /* VMS */ return(success = dologin(s)); /* Return 1=completed, 0=failed */ } #endif /* NOSCRIPT */ #ifndef NOXFER #ifdef PIPESEND if (cx == XXCREC) { /* CRECEIVE */ if (protocol != PROTO_K) { printf("?Sorry, CRECEIVE works only with Kermit protocol\n"); return(-9); } else return(doxget(cx)); } if (cx == XXCGET) { /* CGET */ return(doxget(cx)); } #endif /* PIPESEND */ if (cx == XXREC) /* RECEIVE */ return(doxget(cx)); #endif /* NOXFER */ #ifndef NOXFER if (cx == XXREM) { /* REMOTE */ #ifdef NEWFTP if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) return(doftprmt(0,0)); #endif /* NEWFTP */ #ifdef CK_XYZ if (protocol != PROTO_K) { printf("Sorry, REMOTE commands only work with Kermit protocol\n"); return(-9); } #endif /* CK_XYZ */ x = cmkey(remcmd,nrmt,"Remote Kermit server command","",xxstring); if (x == -3) { printf("?You must specify a command for the remote server\n"); return(-9); } return(dormt(x)); } #endif /* NOXFER */ #ifndef NORENAME #ifndef NOFRILLS if (cx == XXREN || cx == XXLREN) { /* RENAME */ #ifdef LOCUS if (!locus && cx != XXLREN) { #ifdef NOXFER return(-2); #else return(dormt(XZREN)); #endif /* NOXFER */ } #endif /* LOCUS */ #ifdef IKSD if (inserver && (!ENABLED(en_ren) #ifdef CK_LOGIN || isguest #endif /* CK_LOGIN */ )) { printf("?Sorry, renaming of files is disabled\n"); return(-9); } #endif /* IKSD */ #ifdef CK_APC if ((apcactive == APC_LOCAL) || ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH)))) return(success = 0); #endif /* CK_APC */ return(dorenam()); } #endif /* NOFRILLS */ #endif /* NORENAME */ if (cx == XXEIGHT) { /* EIGHTBIT */ extern int parity, cmask, cmdmsk; if ((x = cmcfm()) < 0) return(x); parity = 0; cmask = 0xff; cmdmsk = 0xff; return(success = 1); } #ifndef NOXFER /* SEND, CSEND, MOVE, MAIL, and RESEND use the new common code */ if (cx == XXSEN /* SEND */ #ifdef PIPESEND || cx == XXCSEN /* CSEND */ #endif /* PIPESEND */ || cx == XXMOVE /* MOVE */ || cx == XXMAI /* MAIL */ #ifdef CK_RESEND || cx == XXRSEN /* RESEND */ #endif /* CK_RESEND */ ) { #ifdef IKSD if (inserver && !ENABLED(en_get)) { printf("?Sorry, sending files is disabled\n"); return(-9); } #endif /* IKSD */ return(doxsend(cx)); } /* PSEND, ADD, and REMOVE use special parsing */ #ifdef ADDCMD /* ADD and REMOVE */ if (cx == XXADD || cx == XXREMV) { char * m; m = (cx == XXADD) ? "Add to which list?" : "Remove from which list?"; x = cmkey(addtab,naddtab,m,"",xxstring); if (x < 0) return(x); #ifndef NOMSEND if (x == ADD_SND) return(addsend(cx)); else #endif /* NOMSEND */ return(doadd(cx,x)); } #endif /* ADDCMD */ #ifdef CK_RESEND if (cx == XXPSEN) { /* PSEND */ int seekto = 0; /* FIX THIS */ cmarg = cmarg2 = ""; x = cmifi("File to partially send", "", &s, &y, xxstring); if (x < 0) { if (x == -3) { printf("?A file specification is required\n"); return(-9); } else return(x); } nfils = -1; /* Files come from internal list. */ #ifndef NOMSEND addlist = 0; /* Don't use SEND-LIST. */ filenext = NULL; #endif /* NOMSEND */ ckstrncpy(line,s,LINBUFSIZ); /* Save copy of string just parsed. */ debug(F110,"PSEND line",line,0); if (y != 0) { printf("?Sorry, wildcards not permitted in this command\n"); return(-9); } if (sizeof(int) < 4) { printf("?Sorry, this command needs 32-bit integers\n"); return(-9); } x = cmnum("starting position (byte number)", "",10,&seekto,xxstring); if (x < 0) return(x); zfnqfp(s,fspeclen,fspec); /* Get full path */ if ((x = cmtxt("Name to send it with","",&s,NULL)) < 0) return(x); ckstrncpy(tmpbuf,s,TMPBUFSIZ); #ifdef IKSD if (inserver && !ENABLED(en_get)) { printf("?Sorry, sending files is disabled\n"); return(-9); } #endif /* IKSD */ #ifdef PIPESEND if (sndfilter) { printf("?Sorry, no PSEND while SEND FILTER selected\n"); return(-9); } #endif /* PIPESEND */ #ifdef CK_XYZ if ((protocol == PROTO_X || protocol == PROTO_XC)) { printf("Sorry, PSEND works only with Kermit protocol\n"); return(-9); } #endif /* CK_XYZ */ cmarg2 = brstrip(tmpbuf); /* Strip braces */ cmarg = line; /* File to send */ debug(F110,"PSEND filename",cmarg,0); debug(F110,"PSEND as-name",cmarg2,0); sendstart = seekto; sstate = 's'; /* Set start state to SEND */ #ifndef NOMSEND addlist = 0; filenext = NULL; #endif /* NOMSEND */ sendmode = SM_PSEND; #ifdef MAC what = W_SEND; scrcreate(); #endif /* MAC */ if (local) { /* If in local mode, */ displa = 1; /* enable file transfer display */ } return(0); } #endif /* CK_RESEND */ #endif /* NOXFER */ #ifndef NOXFER #ifndef NOMSEND if (cx == XXMSE || cx == XXMMOVE) { #ifdef NEWFTP if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) return(doftpput(cx,0)); #endif /* NEWFTP */ #ifdef CK_XYZ if (protocol == PROTO_X || protocol == PROTO_XC) { printf( "Sorry, you can only send one file at a time with XMODEM protocol\n" ); return(-9); } #endif /* CK_XYZ */ return(doxsend(cx)); } #ifdef COMMENT /* (moved to doxsend) */ if (cx == XXMSE || cx == XXMMOVE) { /* MSEND and MMOVE commands */ nfils = 0; /* Like getting a list of */ lp = line; /* files on the command line */ addlist = 0; /* Do not use SEND-LIST */ filenext = NULL; /* Ditto ! */ while (1) { char *p; if ((x = cmifi("Names of files to send, separated by spaces","", &s,&y,xxstring)) < 0) { if (x == -3) { if (nfils <= 0) { printf("?A file specification is required\n"); return(-9); } else break; } return(x); } msfiles[nfils++] = lp; /* Got one, count it, point to it, */ p = lp; /* remember pointer, */ while (*lp++ = *s++) /* and copy it into buffer */ if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */ printf("?MSEND list too long\n"); line[0] = NUL; return(-9); } debug(F111,"msfiles",msfiles[nfils-1],nfils-1); if (nfils == 1) *fspec = NUL; /* Take care of \v(filespec) */ #ifdef ZFNQFP zfnqfp(p,TMPBUFSIZ,tmpbuf); p = tmpbuf; #endif /* ZFNQFP */ if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) { strcat(fspec,p); /* safe */ strcat(fspec," "); /* safe */ } else printf("WARNING - \\v(filespec) buffer overflow\n"); } cmlist = msfiles; /* Point cmlist to pointer array */ cmarg2 = ""; /* No internal expansion list (yet) */ sndsrc = nfils; /* Filenames come from cmlist */ sendmode = SM_MSEND; /* Remember this kind of SENDing */ sstate = 's'; /* Set start state for SEND */ if (cx == XXMMOVE) /* If MMOVE'ing, */ moving = 1; /* set this flag. */ #ifdef MAC what = W_SEND; scrcreate(); #endif /* MAC */ if (local) { /* If in local mode, */ displa = 1; /* turn on file transfer display */ ttflui(); /* and flush tty input buffer. */ } return(0); } #endif /* COMMENT */ #endif /* NOMSEND */ #endif /* NOXFER */ #ifndef NOSERVER if (cx == XXSER) { /* SERVER */ #ifdef CK_XYZ if (protocol != PROTO_K) { printf("Sorry, SERVER only works with Kermit protocol\n"); return(-9); } #endif /* CK_XYZ */ #ifdef COMMENT /* Parse for time limit, but since we don't use it yet, the parsing is commented out. */ x_ifnum = 1; /* Turn off internal complaints */ y = cmnum("optional time limit, seconds, or time of day as hh:mm:ss", "0", 10, &x, xxstring ); x_ifnum = 0; if (y < 0) { if (y == -2) { /* Invalid number or expression */ zz = tod2sec(atmbuf); /* Convert to secs since midnight */ if (zz < 0L) { printf("?Number, expression, or time of day required\n"); return(-9); } else { char now[32]; /* Current time */ char *p; long tnow; p = now; ztime(&p); tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17); if (zz < tnow) /* User's time before now */ zz += 86400L; /* So make it tomorrow */ zz -= tnow; /* Seconds from now. */ } } else return(y); } if (zz > -1L) { x = zz; if (zz != (long) x) { printf( "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n" ); return(-9); } } if (x < 0) x = 0; #endif /* COMMENT */ if ((x = cmcfm()) < 0) return(x); sstate = 'x'; #ifdef MAC what = W_RECV; scrcreate(); #endif /* MAC */ if (local) displa = 1; #ifdef AMIGA reqoff(); /* No DOS requestors while server */ #endif /* AMIGA */ return(0); } #endif /* NOSERVER */ if (cx == XXSAVE) { /* SAVE command */ x = cmkey(savtab,nsav,"option","keymap",xxstring); if (x == -3) { printf("?You must specify an option to save\n"); return(-9); } if (x < 0) return(x); /* have to set success separately for each item in doprm()... */ /* actually not really, could have just had doprm return 0 or 1 */ /* and set success here... */ y = dosave(x); if (y == -3) { printf("?More fields required\n"); return(-9); } else return(y); } if (cx == XXSET) { /* SET command */ x = cmkey(prmtab,nprm,"Parameter","",xxstring); if (x == -3) { printf("?You must specify a parameter to set\n"); return(-9); } if (x < 0) return(x); /* have to set success separately for each item in doprm()... */ /* actually not really, could have just had doprm return 0 or 1 */ /* and set success here... */ y = doprm(x,0); if (y == -3) { printf("?More fields required\n"); return(-9); } else return(y); } #ifndef NOPUSH if (cx == XXSHE /* SHELL (system) command */ || cx == XXEXEC /* exec() */ ) { int rx = 0; char * p = NULL; int i /* ,n */ ; #ifdef UNIXOROSK char * args[256]; #endif /* UNIXOROSK */ #ifdef IKSD if (inserver && (nopush || !ENABLED(en_hos))) { printf("?Sorry, host command access is disabled\n"); return(-9); } #endif /* IKSD */ #ifdef CKEXEC if (cx == XXEXEC) { /* EXEC (overlay ourselves) */ struct FDB sw, fl; cmfdbi(&sw, /* First FDB - command switches */ _CMKEY, /* fcode */ "Command to overlay C-Kermit\n or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 1, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ redirsw, /* Keyword table */ &fl /* Pointer to next FDB */ ); cmfdbi(&fl, /* 2nd FDB - command to exec */ _CMFLD, /* fcode */ "Command to overlay C-Kermit", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL /* No more after this */ ); while (1) { x = cmfdb(&sw); /* Parse something */ debug(F101,"exec cmfdb","",x); if (x < 0) return(x); /* Generalize this if we add more switches */ if (cmresult.fcode == _CMKEY) { rx = 1; continue; } if (cmresult.fcode == _CMFLD) break; return(-2); } ckstrncpy(tmpbuf,cmresult.sresult,TMPBUFSIZ); if (!tmpbuf[0]) { printf("?Command required\n"); return(-9); } p = brstrip(tmpbuf); args[0] = NULL; /* Set argv[0] to it */ makestr(&args[0],p); for (i = 1; i < 255; i++) { /* Get arguments for command */ if ((x = cmfld("Argument","",&s,xxstring)) < 0) { if (x == -3) { if ((x = cmcfm()) < 0) return(x); break; } else return(x); } args[i] = NULL; s = brstrip(s); makestr(&args[i],s); } args[i] = NULL; } else { #endif /* CKEXEC */ if ((x = cmtxt("System command to execute","",&s,xxstring)) < 0) return(x); #ifdef CKEXEC } #endif /* CKEXEC */ if (nopush) return(success = 0); #ifdef CK_APC if (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)) return(success = 0); #endif /* CK_APC */ conres(); /* Make console normal */ #ifdef OS2 if (!(s && *s)) { os2push(); return(success = 1); } else #endif /* OS2 */ if (cx == XXSHE) { x = zshcmd(s); debug(F101,"RUN zshcmd code","",x); concb((char)escape); return(success = x); #ifdef CKEXEC } else { #ifdef DEBUG if (deblog) { debug(F111,"EXEC cmd",p,0); for (i = 0; i < 256 && args[i]; i++) debug(F111,"EXEC arg",args[i],i); } #endif /* DEBUG */ if (p) { z_exec(p,args,rx); /* Overlay ourself */ debug(F100,"EXEC fails","",0); concb((char)escape); /* In case it returns */ } return(success = 0); #endif /* CKEXEC */ } } #ifdef CK_REDIR if (cx == XXFUN) { /* REDIRECT */ #ifdef CK_APC if ((apcactive == APC_LOCAL) || ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH)))) return(success = 0); #endif /* CK_APC */ ckmakmsg(tmpbuf, TMPBUFSIZ, "Local command to run,\n", "with its standard input/output redirected to ", local ? ttname : "the communications connection", "\n" ); if ((x = cmtxt(tmpbuf,"",&s,xxstring)) < 0) return(x); if (nopush) { printf("?REDIRECT disabled\n"); return(success=0); } if (!local) { printf("?SET LINE or SET HOST required first\n"); return(-9); } if (!*s) { printf("?REDIRECT requires a command to redirect\n"); return(-9); } return(success = ttruncmd(s)); } #endif /* CK_REDIR */ #endif /* NOPUSH */ #ifndef NOSHOW if (cx == XXSHO) { /* SHOW */ x = cmkey(shotab,nsho,"","parameters",xxstring); if (x < 0) return(x); return(doshow(x)); } #endif /* NOSHOW */ #ifndef MAC if (cx == XXSPA) { /* SPACE */ #ifdef IKSD if (inserver && !ENABLED(en_spa)) { printf("?Sorry, SPACE command disabled\n"); return(-9); } #endif /* IKSD */ #ifdef datageneral /* AOS/VS can take an argument after its "space" command. */ if ((x = cmtxt("Confirm, or local directory name","",&s,xxstring)) < 0) return(x); if (nopush) { printf("?Sorry, SPACE command disabled\n"); return(-9); } else if (*s == NUL) { xsystem(SPACMD); } else { ckmakmsg(line,LINBUFSIZ,"space ",s,NULL,NULL); xsystem(line); } #else #ifdef OS2 if ((x = cmtxt("Press Enter for current disk,\n\ or specify a disk letter like A:","",&s,xxstring)) < 0) return(x); if (*s == NUL) { /* Current disk */ unsigned long space = zdskspace(0); if (space > 0 && space < 1024) printf(" Free space: unknown\n"); else printf(" Free space: %ldK\n", space/1024L); } else { int drive = toupper(*s); unsigned long space = zdskspace(drive - 'A' + 1); if (space > 0 && space < 1024) printf(" Drive %c: unknown free\n"); else printf(" Drive %c: %ldK free\n", drive,space / 1024L); } #else #ifdef UNIXOROSK x = cmdir("Confirm for current disk,\n\ or specify a disk device or directory","",&s,xxstring); if (x == -3) s = ""; else if (x < 0) return(x); ckstrncpy(tmpbuf,s,TMPBUFSIZ); s = tmpbuf; if ((x = cmcfm()) < 0) return(x); if (nopush) { printf("?Sorry, SPACE command disabled\n"); return(-9); } if (!*s) { /* Current disk */ xsystem(SPACMD); } else { /* Specified disk */ ckmakmsg(line,LINBUFSIZ,SPACM2," ",s,NULL); xsystem(line); } #else if ((x = cmcfm()) < 0) return(x); if (nopush) { printf("?Sorry, SPACE command disabled\n"); return(-9); } xsystem(SPACMD); #endif /* UNIXOROSK */ #endif /* OS2 */ #endif /* datageneral */ return(success = 1); /* Pretend it worked */ } #endif /* MAC */ #ifndef NOXFER if (cx == XXSTA) { /* STATISTICS */ if ((x = cmkey(stattab,2,"Carriage return, or option", "/brief",xxstring)) < 0) return(x); if ((y = cmcfm()) < 0) return(y); return(success = dostat(x)); } #endif /* NOXFER */ if (cx == XXSTO || cx == XXEND) { /* STOP, END, or POP */ if ((y = cmnum("exit status code","0",10,&x,xxstring)) < 0) return(y); if ((y = cmtxt("Message to print","",&s,xxstring)) < 0) return(y); s = brstrip(s); if (*s) printf("%s\n",s); if (cx == XXSTO) { dostop(); } else { doend(x); } return(success = (x == 0)); } if (cx == XXSUS) { /* SUSPEND */ if ((y = cmcfm()) < 0) return(y); #ifdef NOJC printf("Sorry, this version of Kermit cannot be suspended\n"); #else #ifdef IKSD if (inserver) { printf("?Sorry, IKSD can not be suspended\n"); return(-9); } else #endif /* IKSD */ if (nopush) { printf("?Sorry, access to system is disabled\n"); return(-9); } stptrap(0); #endif /* NOJC */ return(0); } if (cx == XXTAK) { /* TAKE */ char * scriptenv = NULL; #ifdef OS2 char * GetAppData(int); extern char startupdir[],exedir[],inidir[]; char * keymapenv = NULL; char * appdata0 = NULL, *appdata1 = NULL; int xx; #define TAKEPATHLEN 4096 #else /* OS2 */ #define TAKEPATHLEN 1024 #endif /* OS2 */ char takepath[TAKEPATHLEN]; if (tlevel >= MAXTAKE-1) { printf("?Take files nested too deeply\n"); return(-9); } #ifdef OS2 #ifdef NT scriptenv = getenv("K95SCRIPTS"); keymapenv = getenv("K95KEYMAPS"); makestr(&appdata0,(char *)GetAppData(0)); makestr(&appdata1,(char *)GetAppData(1)); #else /* NT */ scriptenv = getenv("K2SCRIPTS"); keymapenv = getenv("K2KEYMAPS"); #endif /* NT */ #endif /* OS2 */ if (!scriptenv) /* Let this work for Unix etc too */ scriptenv = getenv("CK_SCRIPTS"); /* Use this if defined */ #ifndef OS2 if (!scriptenv) /* Otherwise use home directory */ scriptenv = homepath(); #endif /* OS2 */ if (!scriptenv) scriptenv = ""; ckstrncpy(takepath,scriptenv,TAKEPATHLEN); debug(F110,"TAKE initial takepath",takepath,0); #ifdef OS2 if (!keymapenv) keymapenv = getenv("CK_KEYMAPS"); if (!keymapenv) keymapenv = ""; ckstrncat(takepath, (scriptenv && scriptenv[strlen(scriptenv)-1]==';')?"":";", TAKEPATHLEN ); ckstrncat(takepath,keymapenv?keymapenv:"",TAKEPATHLEN); ckstrncat(takepath, (keymapenv && keymapenv[strlen(keymapenv)-1]==';')?"":";", TAKEPATHLEN ); ckstrncat(takepath,startupdir,TAKEPATHLEN); ckstrncat(takepath,";",TAKEPATHLEN); ckstrncat(takepath,startupdir,TAKEPATHLEN); ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN); ckstrncat(takepath,startupdir,TAKEPATHLEN); ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN); ckstrncat(takepath,appdata1,TAKEPATHLEN); ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN); ckstrncat(takepath,appdata1,TAKEPATHLEN); ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN); ckstrncat(takepath,appdata1,TAKEPATHLEN); ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN); ckstrncat(takepath,appdata0,TAKEPATHLEN); ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN); ckstrncat(takepath,appdata0,TAKEPATHLEN); ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN); ckstrncat(takepath,appdata0,TAKEPATHLEN); ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN); ckstrncat(takepath,inidir,TAKEPATHLEN); ckstrncat(takepath,";",TAKEPATHLEN); ckstrncat(takepath,inidir,TAKEPATHLEN); ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN); ckstrncat(takepath,inidir,TAKEPATHLEN); ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN); ckstrncat(takepath,zhome(),TAKEPATHLEN); ckstrncat(takepath,";",TAKEPATHLEN); ckstrncat(takepath,zhome(),TAKEPATHLEN); ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN); ckstrncat(takepath,zhome(),TAKEPATHLEN); ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN); ckstrncat(takepath,exedir,TAKEPATHLEN); ckstrncat(takepath,";",TAKEPATHLEN); ckstrncat(takepath,exedir,TAKEPATHLEN); ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN); ckstrncat(takepath,exedir,TAKEPATHLEN); ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN); #endif /* OS2 */ debug(F110,"TAKE final takepath",takepath,0); if ((y = cmifip("Commands from file", "",&s,&x,0,takepath,xxstring)) < 0) { if (y == -3) { printf("?A file name is required\n"); return(-9); } else return(y); } if (x != 0) { printf("?Wildcards not allowed in command file name\n"); return(-9); } ckstrncpy(line,s,LINBUFSIZ); debug(F110,"TAKE file",s,0); if (isdir(s)) { printf("?Can't execute a directory - \"%s\"\n", s); return(-9); } #ifndef NOTAKEARGS { char * p; x = strlen(line); debug(F111,"TAKE args",line,x); p = line + x + 1; if ((y = cmtxt("Optional arguments","",&s,xxstring)) < 0) return(y); if (*s) { /* Args given? */ ckstrncpy(p,s,LINBUFSIZ-x-1); #ifdef ZFNQFP zfnqfp(line,TMPBUFSIZ,tmpbuf); s = tmpbuf; #else s = line; #endif /* ZFNQFP */ debug(F110,"TAKE filename",s,0); x = strlen(s); debug(F101,"TAKE new len",s,x); #ifdef COMMENT /* This was added in C-Kermit 7.0 to allow args to be passed from the TAKE command to the command file. But it overwrites the current argument vector, which is at best surprising, and at worst unsafe. */ addmac("%0",s); /* Define %0 = name of file */ varnam[0] = '%'; varnam[2] = '\0'; debug(F110,"take arg 0",s,0); debug(F110,"take args",p,0); for (y = 1; y < 10; y++) { /* Clear current args %1..%9 */ varnam[1] = (char) (y + '0'); delmac(varnam,0); } xwords(p,MAXARGLIST,NULL,0); /* Assign new args */ debug(F110,"take args",p,0); #else /* This method is used in 8.0. If the TAKE command includes arguments, we insert an intermediate temporary macro between the current level; we pass the arguments to the macro and then the macro TAKEs the command file. If the user Ctrl-C's out of the TAKE file, some temporary macro definitions and other small malloc'd bits might be left behind. */ { char * q = NULL; char * r = NULL; int k, m; m = maclvl; q = (char *)malloc(x+24); if (q) { r = (char *)malloc(x+24); if (r) { sprintf(q,"_file[%s](%d)",s,cmdlvl); /* safe */ sprintf(r,"take %s",s); /* safe */ k = addmac(q,r); if (k > -1) { dodo(k,p,0); while (maclvl > m) { sstate = (CHAR) parser(1); if (sstate) proto(); } } k = delmac(q,0); free(q); free(r); return(success); } } } return(success = 0); #endif /* COMMENT */ } } #else if ((y = cmcfm()) < 0) return(y); #endif /* NOTAKEARGS */ return(success = dotake(line)); } #ifndef NOLOCAL #ifdef OS2 if (cx == XXVIEW) { /* VIEW Only Terminal mode */ viewonly = TRUE; success = doconect(0, 0); viewonly = FALSE; return success; } #endif /* OS2 */ #ifdef NETCONN if (cx == XXTEL || cx == XXIKSD) { /* TELNET */ int x,z; #ifdef OS2 if (!tcp_avail) { printf("?Sorry, either TCP/IP is not available on this system or\n\ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"); success = 0; return(-9); } else #endif /* OS2 */ { x = nettype; /* Save net type in case of failure */ z = ttnproto; /* Save protocol in case of failure */ nettype = NET_TCPB; ttnproto = (cx == XXTEL) ? NP_TELNET : NP_KERMIT; if ((y = setlin(XYHOST,0,1)) <= 0) { nettype = x; /* Failed, restore net type. */ ttnproto = z; /* and protocol */ success = 0; } didsetlin++; } return(y); } #ifndef PTYORPIPE #ifdef NETCMD #define PTYORPIPE #else #ifdef NETPTY #define PTYORPIPE #endif /* NETPTY */ #endif /* NETCMD */ #endif /* PTYORPIPE */ #ifdef PTYORPIPE if (cx == XXPIPE || cx == XXPTY) { /* PIPE or PTY */ int x; extern int netsave; x = nettype; /* Save net type in case of failure */ nettype = (cx == XXPIPE) ? NET_CMD : NET_PTY; if ((y = setlin(XYHOST,0,1)) < 0) { nettype = x; /* Failed, restore net type. */ ttnproto = z; /* and protocol */ success = 0; } didsetlin++; netsave = x; return(y); } #endif /* PTYORPIPE */ #ifdef ANYSSH if (cx == XXSSH) { /* SSH (Secure Shell) */ extern int netsave; #ifdef SSHBUILTIN int k, x, havehost = 0, trips = 0; int tmpver = -1, tmpxfw = -1; #ifndef SSHTEST extern int sl_ssh_xfw, sl_ssh_xfw_saved; extern int sl_ssh_ver, sl_ssh_ver_saved; #endif /* SSHTEST */ extern int mdmtyp, mdmsav, cxtype, sl_uid_saved; extern char * slmsg; extern char uidbuf[], sl_uidbuf[]; extern char pwbuf[], * g_pswd; extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal; struct FDB sw, kw, fl; if (ssh_tmpstr) memset(ssh_tmpstr,0,strlen(ssh_tmpstr)); makestr(&ssh_tmpstr,NULL); makestr(&ssh_tmpuid,NULL); makestr(&ssh_tmpcmd,NULL); makestr(&ssh_tmpport,NULL); cmfdbi(&kw, /* 1st FDB - commands */ _CMKEY, /* fcode */ "host [ port ],\n or action", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nsshcmd, /* addtl numeric data 1: tbl size */ 0, /* addtl numeric data 2: 0 = keyword */ xxstring, /* Processing function */ sshkwtab, /* Keyword table */ &fl /* Pointer to next FDB */ ); cmfdbi(&fl, /* Host */ _CMFLD, /* fcode */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); x = cmfdb(&kw); if (x == -3) { printf("?ssh what?\n"); return(-9); } if (x < 0) return(x); havehost = 0; if (cmresult.fcode == _CMFLD) { havehost = 1; ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */ cmresult.nresult = XSSH_OPN; } switch (cmresult.nresult) { /* SSH keyword */ case XSSH_OPN: /* SSH OPEN */ if (!havehost) { if ((x = cmfld("Host","",&s,xxstring)) < 0) return(x); ckstrncpy(line,s,LINBUFSIZ); } /* Parse [ port ] [ switches ] */ cmfdbi(&kw, /* Switches */ _CMKEY, "Port number or service name,\nor switch", "", "", nsshopnsw, 4, xxstring, sshopnsw, &fl ); cmfdbi(&fl, /* Port number or service name */ _CMFLD, "", "", "", 0, 0, xxstring, NULL, NULL ); trips = 0; /* Explained below */ while (1) { /* Parse port and switches */ x = cmfdb(&kw); /* Get a field */ if (x == -3) /* User typed CR so quit from loop */ break; if (x < 0) /* Other parse error, pass it back */ return(x); switch (cmresult.fcode) { /* Field or Keyword? */ case _CMFLD: /* Field */ makestr(&ssh_tmpport,cmresult.sresult); break; case _CMKEY: /* Keyword */ switch (cmresult.nresult) { /* Which one? */ case SSHSW_USR: /* /USER: */ if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } if ((y = cmfld("Username","",&s,xxstring)) < 0) return(y); s = brstrip(s); makestr(&ssh_tmpuid,s); break; case SSHSW_PWD: if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } debok = 0; if ((x = cmfld("Password","",&s,xxstring)) < 0) { if (x == -3) { makestr(&ssh_tmpstr,""); } else { return(x); } } else { s = brstrip(s); if ((x = (int)strlen(s)) > PWBUFL) { makestr(&slmsg,"Internal error"); printf("?Sorry, too long - max = %d\n",PWBUFL); return(-9); } makestr(&ssh_tmpstr,s); } break; case SSHSW_VER: if ((x = cmnum("Number","",10,&z,xxstring)) < 0) return(x); if (z < 1 || z > 2) { printf("?Out of range: %d\n",z); return(-9); } tmpver = z; break; case SSHSW_CMD: case SSHSW_SUB: if ((x = cmfld("Text","",&s,xxstring)) < 0) return(x); makestr(&ssh_tmpcmd,s); ssh_cas = (cmresult.nresult == SSHSW_SUB); break; case SSHSW_X11: if ((x = cmkey(onoff,2,"","on",xxstring)) < 0) return(x); tmpxfw = x; break; default: return(-2); } } if (trips++ == 0) { /* After first time through */ cmfdbi(&kw, /* only parse switches, not port. */ _CMKEY, "Switch", "", "", nsshopnsw, 4, xxstring, sshopnsw, NULL ); } } if ((x = cmcfm()) < 0) /* Get confirmation */ return(x); if (clskconnx(1) < 0) { /* Close current Kermit connection */ if ( ssh_tmpstr ) { memset(ssh_tmpstr,0,strlen(ssh_tmpstr)); makestr(&ssh_tmpstr,NULL); } return(success = 0); } makestr(&ssh_hst,line); /* Stash everything */ if (ssh_tmpuid) { if (!sl_uid_saved) { ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN); sl_uid_saved = 1; } ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN); makestr(&ssh_tmpuid,NULL); } if (ssh_tmpport) { makestr(&ssh_prt,ssh_tmpport); makestr(&ssh_tmpport,NULL); } else makestr(&ssh_prt,NULL); if (ssh_tmpcmd) { makestr(&ssh_cmd,brstrip(ssh_tmpcmd)); makestr(&ssh_tmpcmd,NULL); } else makestr(&ssh_cmd,NULL); if (tmpver > -1) { #ifndef SSHTEST if (!sl_ssh_ver_saved) { sl_ssh_ver = ssh_ver; sl_ssh_ver_saved = 1; } #endif /* SSHTEST */ ssh_ver = tmpver; } if (tmpxfw > -1) { #ifndef SSHTEST if (!sl_ssh_xfw_saved) { sl_ssh_xfw = ssh_xfw; sl_ssh_xfw_saved = 1; } #endif /* SSHTEST */ ssh_xfw = tmpxfw; } if (ssh_tmpstr) { if (ssh_tmpstr[0]) { ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1); pwflg = 1; pwcrypt = 0; } else pwflg = 0; makestr(&ssh_tmpstr,NULL); } nettype = NET_SSH; if (mdmsav < 0) mdmsav = mdmtyp; mdmtyp = -nettype; x = 1; #ifndef NOSPL makestr(&g_pswd,pwbuf); /* Save global pwbuf */ g_pflg = pwflg; /* and flag */ g_pcpt = pwcrypt; #endif /* NOSPL */ /* Line parameter to ttopen() is ignored */ debug(F110,"SSH line",line,0); k = ttopen(line,&x,mdmtyp, 0); if (k < 0) { printf("?Unable to connect to %s\n",ssh_hst); mdmtyp = mdmsav; slrestor(); return(success = 0); } duplex = 0; /* Remote echo */ ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */ debug(F110,"ssh ttname",ttname,0); makestr(&slmsg,NULL); /* No SET LINE error message */ cxtype = CXT_SSH; #ifndef NODIAL dialsta = DIA_UNK; #endif /* NODIAL */ success = 1; /* SET LINE succeeded */ network = 1; /* Network connection (not serial) */ local = 1; /* Local mode (not remote) */ if ((reliable != SET_OFF || !setreliable)) reliable = SET_ON; /* Transport is reliable end to end */ #ifdef OS2 DialerSend(OPT_KERMIT_CONNECT, 0); #endif /* OS2 */ setflow(); /* Set appropriate flow control */ haveline = 1; #ifdef CKLOGDIAL #ifdef NETCONN dolognet(); #endif /* NETCONN */ #endif /* CKLOGDIAL */ #ifndef NOSPL if (local) { if (nmac) { /* Any macros defined? */ int k; /* Yes */ k = mlook(mactab,"on_open",nmac); /* Look this up */ if (k >= 0) { /* If found, */ if (dodo(k,ssh_hst,0) > -1) /* set it up, */ parser(1); /* and execute it */ } } } #endif /* NOSPL */ #ifdef LOCUS if (autolocus) setlocus(1,1); #endif /* LOCUS */ /* Command was confirmed so we can pre-pop command level. */ /* This is so CONNECT module won't think we're executing a */ /* script if CONNECT was the final command in the script. */ if (cmdlvl > 0) prepop(); success = doconect(0,cmdlvl == 0 ? 1 : 0); if (ttchk() < 0) dologend(); return(success); case XSSH_CLR: if ((y = cmkey(sshclr,nsshclr,"","", xxstring)) < 0) { if (y == -3) { printf("?clear what?\n"); return(-9); } return(y); } if ((x = cmcfm()) < 0) return(x); switch (y) { case SSHC_LPF: ssh_pf_lcl_n = 0; break; case SSHC_RPF: ssh_pf_rmt_n = 0; break; default: return(-2); } return(success = 1); /* or whatever */ case XSSH_AGT: { /* SSH AGENT */ int doeach = 0; if ((y = cmkey(sshagent,nsshagent,"","",xxstring)) < 0) return(y); switch (y) { case SSHA_ADD: /* SSH AGENT ADD ... */ if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) { #ifndef SSHTEST if (x == -3) /* No name given */ doeach = 1; /* so do them all */ else #endif /* SSHTEST */ return(x); } ckstrncpy(line,s,LINBUFSIZ); if ((x = cmcfm()) < 0) return(x); #ifdef SSHTEST x = 0; #else if (doeach) { int i; x = 0; for (i = 0; i < ssh_idf_n; i++) x += ssh_agent_add_file(ssh_idf[i]); } else x = ssh_agent_add_file(line); #endif /* SSHTEST */ return(success = (x == 0)); case SSHA_DEL: { /* SSH AGENT DELETE ... */ int doall = 0; if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) { #ifndef SSHTEST if (x == -3) /* No name given */ doall = 1; /* so do them all */ else #endif /* SSHTEST */ return(x); } ckstrncpy(line,s,LINBUFSIZ); if ((x = cmcfm()) < 0) return(x); #ifdef SSHTEST x = 0; #else if (doall) x = ssh_agent_delete_all(); else x = ssh_agent_delete_file(line); #endif /* SSHTEST */ return(success = (x == 0)); } case SSHA_LST: { int fingerprint = 0; if ((y = cmswi(sshagtsw,nsshagtsw,"","",xxstring)) < 0) { if (y != -3) return(y); } else if (cmgbrk() > SP) { printf("?This switch does not take an argument\n"); return(-9); } else if (y == SSHASW_FP) { fingerprint = 1; } if ((x = cmcfm()) < 0) return(x); #ifdef SSHTEST return(success = 1); #else return(success = (ssh_agent_list_identities(fingerprint) == 0)); #endif /* SSHTEST */ } default: return(-2); } } case XSSH_ADD: { /* SSH ADD */ /* ssh add { local, remote } port host port */ int cx, i, j, k; char * h; if ((cx = cmkey(addfwd,naddfwd,"","", xxstring)) < 0) return(cx); if ((x = cmnum((cx == SSHF_LCL) ? "Local port number" : "Remote port number", "",10,&j,xxstring)) < 0) return(x); if ((x = cmfld("Host","",&s,xxstring)) < 0) return(x); makestr(&h,s); if ((x = cmnum("Port","",10,&k,xxstring)) < 0) return(x); if ((x = cmcfm()) < 0) return(x); switch(cx) { case SSHF_LCL: if (ssh_pf_lcl_n == 32) { printf( "?Maximum number of local port forwardings already specified\n" ); free(h); return(success = 0); } ssh_pf_lcl[ssh_pf_lcl_n].p1 = j; makestr(&(ssh_pf_lcl[ssh_pf_lcl_n].host),h); makestr(&h,NULL); ssh_pf_lcl[ssh_pf_lcl_n].p2 = k; ssh_pf_lcl_n++; break; case SSHF_RMT: if (ssh_pf_rmt_n == 32) { printf( "?Maximum number of remote port forwardings already specified\n" ); free(h); return(success = 0); } ssh_pf_rmt[ssh_pf_rmt_n].p1 = j; makestr(&(ssh_pf_rmt[ssh_pf_rmt_n].host),h); makestr(&h,NULL); ssh_pf_rmt[ssh_pf_rmt_n].p2 = k; ssh_pf_rmt_n++; } return(success = 1); } /* Not supporting arbitrary forwarding yet */ case XSSH_FLP: /* SSH FORWARD-LOCAL-PORT */ case XSSH_FRP: { /* SSH FORWARD-REMOTE-PORT */ int li_port = 0; int to_port = 0; char * fw_host = NULL; int n; if ((x = cmnum(cmresult.nresult == XSSH_FLP ? "local-port":"remote-port", "",10,&li_port,xxstring)) < 0) return(x); if (li_port < 1 || li_port > 65535) { printf("?Out range - min: 1, max: 65535\n"); return(-9); } if ((x = cmfld("host",ssh_hst?ssh_hst:"",&s,xxstring)) < 0) return(x); n = ckstrncpy(tmpbuf,s,TMPBUFSIZ); fw_host = tmpbuf; if ((x = cmnum("host-port",ckuitoa(li_port),10, &to_port,xxstring)) < 0) return(x); if (to_port < 1 || to_port > 65535) { printf("?Out range - min: 1, max: 65535\n"); return(-9); } if ((x = cmcfm()) < 0) return(x); switch (cmresult.nresult) { case XSSH_FLP: /* SSH FORWARD-LOCAL-PORT */ #ifndef SSHTEST ssh_fwd_local_port(li_port,fw_host,to_port); #endif /* SSHTEST */ return(success = 1); case XSSH_FRP: /* SSH FORWARD-REMOTE-PORT */ #ifndef SSHTEST ssh_fwd_remote_port(li_port,fw_host,to_port); #endif /* SSHTEST */ return(success = 1); } return(success = 1); } case XSSH_V2: /* SSH V2 */ if ((cx = cmkey(ssh2tab,nssh2tab,"","", xxstring)) < 0) return(cx); switch (cx) { case XSSH2_RKE: if ((x = cmcfm()) < 0) return(x); #ifndef SSHTEST ssh_v2_rekey(); #endif /* SSHTEST */ return(success = 1); default: return(-2); } case XSSH_KEY: if ((cx = cmkey(sshkey,nsshkey,"","", xxstring)) < 0) return(cx); switch (cx) { case SSHK_PASS: { /* Change passphrase */ char * oldp = NULL, * newp = NULL; struct FDB df, sw; cmfdbi(&sw, _CMKEY, /* fcode */ "Filename, or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 2, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ sshkpsw, /* Keyword table */ &df /* Pointer to next FDB */ ); cmfdbi(&df, /* 2nd FDB - file for display */ _CMIFI, /* output file */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); line[0] = NUL; while (1) { x = cmfdb(&sw); if (x == -3) break; if (x < 0) return(x); if (cmresult.fcode != _CMKEY) break; if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } if ((y = cmfld("Passphrase","",&s,xxstring)) < 0) return(y); switch (cmresult.nresult) { case 1: /* Old */ makestr(&oldp,s); break; case 2: /* New */ makestr(&newp,s); } } if (cmresult.fcode == _CMIFI) { /* Filename */ ckstrncpy(line,cmresult.sresult,LINBUFSIZ); if (zfnqfp(line,TMPBUFSIZ,tmpbuf)) ckstrncpy(line,tmpbuf,LINBUFSIZ); } if ((x = cmcfm()) < 0) return(x); #ifndef SSHTEST x = sshkey_change_passphrase(line[0] ? line : NULL, oldp, newp); #endif /* SSHTEST */ makestr(&oldp,NULL); makestr(&newp,NULL); success = (x == 0); return(success); } case SSHK_CREA: { /* SSH KEY CREATE /switches... */ int bits = 1024, keytype = SSHKT_2R; char * pass = NULL, * comment = NULL; struct FDB df, sw; /* * char * sshkey_default_file(int keytype) * will provide the default filename for a given keytype * is it possible to have the default value for the 2nd * FDB set and changed when a /TYPE switch is provided? * Would this allow for tab completion of the filename? */ cmfdbi(&sw, _CMKEY, /* fcode */ "Filename, or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nsshkcrea, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ sshkcrea, /* Keyword table */ &df /* Pointer to next FDB */ ); cmfdbi(&df, /* 2nd FDB - file for display */ _CMOFI, /* output file */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); line[0] = NUL; while (1) { x = cmfdb(&sw); if (x == -3) break; if (x < 0) return(x); if (cmresult.fcode != _CMKEY) break; if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } switch (cmresult.nresult) { case SSHKC_BI: /* /BITS:n */ if ((y = cmnum("","1024",10,&z,xxstring)) < 0) return(y); if (z < 512 || z > 4096) { printf("?Out range - min: 512, max: 4096\n"); return(-9); } bits = z; break; case SSHKC_PP: /* /PASSPHRASE:blah */ if ((y = cmfld("Passphrase","",&s,xxstring)) < 0) return(y); makestr(&pass,s); break; case SSHKC_TY: /* /TYPE:keyword */ if ((y = cmkey(sshkcty,nsshkcty,"", "v2-rsa",xxstring)) < 0) return(y); keytype = y; break; case SSHKC_1R: /* /COMMENT */ if ((y = cmfld("Text","",&s,xxstring)) < 0) return(y); makestr(&comment,s); break; } } if (cmresult.fcode == _CMOFI) { /* Filename */ if (cmresult.sresult) { ckstrncpy(line,cmresult.sresult,LINBUFSIZ); if (zfnqfp(line,TMPBUFSIZ,tmpbuf)) ckstrncpy(line,tmpbuf,LINBUFSIZ); } } if ((y = cmcfm()) < 0) /* Confirm */ return(y); #ifndef SSHTEST x = sshkey_create(line[0] ? line : NULL, bits, pass, keytype, comment); if (pass) memset(pass,0,strlen(pass)); #endif /* SSHTEST */ makestr(&pass,NULL); makestr(&comment,NULL); return(success = (x == 0)); } case SSHK_DISP: { /* SSH KEY DISPLAY /switches... */ char c; int infmt = 0, outfmt = 0; struct FDB df, sw; cmfdbi(&sw, _CMKEY, /* fcode */ "Filename, or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nsshdswi, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ sshdswi, /* Keyword table */ &df /* Pointer to next FDB */ ); cmfdbi(&df, /* 2nd FDB - file for display */ _CMIFI, /* fcode */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); line[0] = NUL; while (1) { x = cmfdb(&sw); if (x == -3) break; if (x < 0) return(x); if (cmresult.fcode != _CMKEY) break; if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } switch (cmresult.nresult) { #ifdef COMMENT case SSHKD_IN: /* /IN-FORMAT: */ if ((y = cmkey(sshdifmt,nsshdifmt, "","",xxstring)) < 0) return(y); infmt = y; break; #endif /* COMMENT */ case SSHKD_OUT: /* /FORMAT: */ if ((y = cmkey(sshdofmt,nsshdofmt, "","",xxstring)) < 0) return(y); outfmt = y; break; } } if (cmresult.fcode == _CMIFI) { /* Filename */ ckstrncpy(line,cmresult.sresult,LINBUFSIZ); if (zfnqfp(line,TMPBUFSIZ,tmpbuf)) ckstrncpy(line,tmpbuf,LINBUFSIZ); } #ifdef COMMENT if (!line[0]) { printf("?Key filename required\n"); return(-9); } #endif /* COMMENT */ if ((y = cmcfm()) < 0) /* Confirm */ return(y); #ifndef SSHTEST switch (outfmt) { case SKDF_OSSH: /* 2nd param is optional passphrase */ x = sshkey_display_public(line[0] ? line : NULL, NULL); break; case SKDF_SSHC: /* 2nd param is optional passphrase */ x = sshkey_display_public_as_ssh2(line[0] ? line : NULL, NULL); break; case SKDF_IETF: x = sshkey_display_fingerprint(line[0] ? line : NULL, 1); break; case SKDF_FING: x = sshkey_display_fingerprint(line[0] ? line : NULL, 0); break; } #endif /* SSHTEST */ return(success = (x == 0)); } case SSHK_V1: /* SSH KEY V1 SET-COMMENT */ if ((x = cmkey(sshkv1,1,"","set-comment", xxstring)) < 0) return(x); if (x != 1) return(-2); if ((x = cmifi("Key file name","",&s,&y,xxstring)) < 0) { if (x == -3) { printf("?Name of key file required\n"); return(-9); } } ckstrncpy(line,s,LINBUFSIZ); if ((x = cmtxt("Comment text","",&s,xxstring)) < 0) return(x); #ifndef SSHTEST x = sshkey_v1_change_comment(line, /* filename */ s, /* new comment */ NULL /* passphrase */ ); #endif /* SSHTEST */ success = (x == 0); return(success); } default: return(-2); } #else /* SSHBUILTIN */ #ifdef SSHCMD x = nettype; if ((y = setlin(XXSSH,0,1)) < 0) { if (errno) printf("?%s\n",ck_errstr()); else #ifdef COMMENT /* This isn't right either because it catches command editing */ printf("?Sorry, pseudoterminal open failed\n"); if (hints) printf("Hint: Try \"ssh -t %s\"\n",line); #else return(y); #endif /* COMMENT */ nettype = x; /* Failed, restore net type. */ ttnproto = z; /* and protocol */ success = 0; } didsetlin++; netsave = x; return(y); #endif /* SSHCMD */ #endif /* SSHBUILTIN */ } #endif /* ANYSSH */ #ifdef SSHBUILTIN if (cx == XXSKRM) { /* SKERMIT (Secure Shell Kermit) */ extern int netsave; int k, x, havehost = 0, trips = 0; int tmpver = -1, tmpxfw = -1; #ifndef SSHTEST extern int sl_ssh_xfw, sl_ssh_xfw_saved; extern int sl_ssh_ver, sl_ssh_ver_saved; #endif /* SSHTEST */ extern int mdmtyp, mdmsav, cxtype, sl_uid_saved; extern char * slmsg; extern char uidbuf[], sl_uidbuf[]; extern char pwbuf[], * g_pswd; extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal; struct FDB sw, kw, fl; if (ssh_tmpstr) memset(ssh_tmpstr,0,strlen(ssh_tmpstr)); makestr(&ssh_tmpstr,NULL); makestr(&ssh_tmpuid,NULL); makestr(&ssh_tmpcmd,NULL); makestr(&ssh_tmpport,NULL); cmfdbi(&kw, /* 1st FDB - commands */ _CMKEY, /* fcode */ "host [ port ],\n or action", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nsshkermit, /* addtl numeric data 1: tbl size */ 0, /* addtl numeric data 2: 0 = keyword */ xxstring, /* Processing function */ sshkermit, /* Keyword table */ &fl /* Pointer to next FDB */ ); cmfdbi(&fl, /* Host */ _CMFLD, /* fcode */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); x = cmfdb(&kw); if (x == -3) { printf("?skermit what?\n"); return(-9); } if (x < 0) return(x); havehost = 0; if (cmresult.fcode == _CMFLD) { havehost = 1; ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */ cmresult.nresult = SKRM_OPN; } switch (cmresult.nresult) { /* SSH keyword */ case SKRM_OPN: /* SSH OPEN */ if (!havehost) { if ((x = cmfld("Host","",&s,xxstring)) < 0) return(x); ckstrncpy(line,s,LINBUFSIZ); } /* Parse [ port ] [ switches ] */ cmfdbi(&kw, /* Switches */ _CMKEY, "Port number or service name,\nor switch", "", "", nsshkrmopnsw, 4, xxstring, sshkrmopnsw, &fl ); cmfdbi(&fl, /* Port number or service name */ _CMFLD, "", "", "", 0, 0, xxstring, NULL, NULL ); trips = 0; /* Explained below */ while (1) { /* Parse port and switches */ x = cmfdb(&kw); /* Get a field */ if (x == -3) /* User typed CR so quit from loop */ break; if (x < 0) /* Other parse error, pass it back */ return(x); switch (cmresult.fcode) { /* Field or Keyword? */ case _CMFLD: /* Field */ makestr(&ssh_tmpport,cmresult.sresult); break; case _CMKEY: /* Keyword */ switch (cmresult.nresult) { /* Which one? */ case SSHSW_USR: /* /USER: */ if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } if ((y = cmfld("Username","",&s,xxstring)) < 0) return(y); s = brstrip(s); makestr(&ssh_tmpuid,s); break; case SSHSW_PWD: if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } debok = 0; if ((x = cmfld("Password","",&s,xxstring)) < 0) { if (x == -3) { makestr(&ssh_tmpstr,""); } else { return(x); } } else { s = brstrip(s); if ((x = (int)strlen(s)) > PWBUFL) { makestr(&slmsg,"Internal error"); printf("?Sorry, too long - max = %d\n",PWBUFL); return(-9); } makestr(&ssh_tmpstr,s); } break; case SSHSW_VER: if ((x = cmnum("Number","",10,&z,xxstring)) < 0) return(x); if (z < 1 || z > 2) { printf("?Out of range: %d\n",z); return(-9); } tmpver = z; break; default: return(-2); } } if (trips++ == 0) { /* After first time through */ cmfdbi(&kw, /* only parse switches, not port. */ _CMKEY, "Switch", "", "", nsshkrmopnsw, 4, xxstring, sshkrmopnsw, NULL ); } } if ((x = cmcfm()) < 0) /* Get confirmation */ return(x); if (clskconnx(1) < 0) { /* Close current Kermit connection */ if ( ssh_tmpstr ) { memset(ssh_tmpstr,0,strlen(ssh_tmpstr)); makestr(&ssh_tmpstr,NULL); } return(success = 0); } makestr(&ssh_hst,line); /* Stash everything */ if (ssh_tmpuid) { if (!sl_uid_saved) { ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN); sl_uid_saved = 1; } ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN); makestr(&ssh_tmpuid,NULL); } if (ssh_tmpport) { makestr(&ssh_prt,ssh_tmpport); makestr(&ssh_tmpport,NULL); } else makestr(&ssh_prt,NULL); /* Set the Subsystem to Kermit */ ssh_cas = 1; makestr(&ssh_cmd,"kermit"); if (tmpver > -1) { #ifndef SSHTEST if (!sl_ssh_ver_saved) { sl_ssh_ver = ssh_ver; sl_ssh_ver_saved = 1; } #endif /* SSHTEST */ ssh_ver = tmpver; } /* Disable X11 Forwarding */ #ifndef SSHTEST if (!sl_ssh_xfw_saved) { sl_ssh_xfw = ssh_xfw; sl_ssh_xfw_saved = 1; } #endif /* SSHTEST */ ssh_xfw = 0; if (ssh_tmpstr) { if (ssh_tmpstr[0]) { ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1); pwflg = 1; pwcrypt = 0; } else pwflg = 0; makestr(&ssh_tmpstr,NULL); } nettype = NET_SSH; if (mdmsav < 0) mdmsav = mdmtyp; mdmtyp = -nettype; x = 1; #ifndef NOSPL makestr(&g_pswd,pwbuf); /* Save global pwbuf */ g_pflg = pwflg; /* and flag */ g_pcpt = pwcrypt; #endif /* NOSPL */ /* Line parameter to ttopen() is ignored */ k = ttopen(line,&x,mdmtyp, 0); if (k < 0) { printf("?Unable to connect to %s\n",ssh_hst); mdmtyp = mdmsav; slrestor(); return(success = 0); } duplex = 0; /* Remote echo */ ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */ debug(F110,"ssh ttname",ttname,0); makestr(&slmsg,NULL); /* No SET LINE error message */ cxtype = CXT_SSH; #ifndef NODIAL dialsta = DIA_UNK; #endif /* NODIAL */ success = 1; /* SET LINE succeeded */ network = 1; /* Network connection (not serial) */ local = 1; /* Local mode (not remote) */ if ((reliable != SET_OFF || !setreliable)) reliable = SET_ON; /* Transport is reliable end to end */ #ifdef OS2 DialerSend(OPT_KERMIT_CONNECT, 0); #endif /* OS2 */ setflow(); /* Set appropriate flow control */ haveline = 1; #ifdef CKLOGDIAL #ifdef NETCONN dolognet(); #endif /* NETCONN */ #endif /* CKLOGDIAL */ #ifndef NOSPL if (local) { if (nmac) { /* Any macros defined? */ int k; /* Yes */ k = mlook(mactab,"on_open",nmac); /* Look this up */ if (k >= 0) { /* If found, */ if (dodo(k,ssh_hst,0) > -1) /* set it up, */ parser(1); /* and execute it */ } } } #endif /* NOSPL */ #ifdef LOCUS if (autolocus) setlocus(1,1); #endif /* LOCUS */ /* Command was confirmed so we can pre-pop command level. */ /* This is so CONNECT module won't think we're executing a */ /* script if CONNECT was the final command in the script. */ if (cmdlvl > 0) prepop(); return(success = 1); default: return(-2); } } #endif /* SSHBUILTIN */ #ifdef SFTP_BUILTIN if (cx == XXSFTP) { /* SFTP (Secure Shell File Transfer) */ extern int netsave; int k, x, havehost = 0, trips = 0; int tmpver = -1, tmpxfw = -1; #ifndef SSHTEST extern int sl_ssh_xfw, sl_ssh_xfw_saved; extern int sl_ssh_ver, sl_ssh_ver_saved; #endif /* SSHTEST */ extern int mdmtyp, mdmsav, cxtype, sl_uid_saved; extern char * slmsg; extern char uidbuf[], sl_uidbuf[]; extern char pwbuf[], * g_pswd; extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal; struct FDB sw, kw, fl; if (ssh_tmpstr) memset(ssh_tmpstr,0,strlen(ssh_tmpstr)); makestr(&ssh_tmpstr,NULL); makestr(&ssh_tmpuid,NULL); makestr(&ssh_tmpcmd,NULL); makestr(&ssh_tmpport,NULL); cmfdbi(&kw, /* 1st FDB - commands */ _CMKEY, /* fcode */ "host [ port ],\n or action", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nsftpkwtab, /* addtl numeric data 1: tbl size */ 0, /* addtl numeric data 2: 0 = keyword */ xxstring, /* Processing function */ sftpkwtab, /* Keyword table */ &fl /* Pointer to next FDB */ ); cmfdbi(&fl, /* Host */ _CMFLD, /* fcode */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); x = cmfdb(&kw); if (x == -3) { printf("?sftp what?\n"); return(-9); } if (x < 0) return(x); havehost = 0; if (cmresult.fcode == _CMFLD) { havehost = 1; ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */ cmresult.nresult = SFTP_OPN; } switch (cmresult.nresult) { /* SFTP keyword */ case SFTP_OPN: /* SFTP OPEN */ if (!havehost) { if ((x = cmfld("Host","",&s,xxstring)) < 0) return(x); ckstrncpy(line,s,LINBUFSIZ); } /* Parse [ port ] [ switches ] */ cmfdbi(&kw, /* Switches */ _CMKEY, "Port number or service name,\nor switch", "", "", nsshkrmopnsw, 4, xxstring, sshkrmopnsw, &fl ); cmfdbi(&fl, /* Port number or service name */ _CMFLD, "", "", "", 0, 0, xxstring, NULL, NULL ); trips = 0; /* Explained below */ while (1) { /* Parse port and switches */ x = cmfdb(&kw); /* Get a field */ if (x == -3) /* User typed CR so quit from loop */ break; if (x < 0) /* Other parse error, pass it back */ return(x); switch (cmresult.fcode) { /* Field or Keyword? */ case _CMFLD: /* Field */ makestr(&ssh_tmpport,cmresult.sresult); break; case _CMKEY: /* Keyword */ switch (cmresult.nresult) { /* Which one? */ case SSHSW_USR: /* /USER: */ if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } if ((y = cmfld("Username","",&s,xxstring)) < 0) return(y); s = brstrip(s); makestr(&ssh_tmpuid,s); break; case SSHSW_PWD: if (!cmgbrk()) { printf("?This switch requires an argument\n"); return(-9); } debok = 0; if ((x = cmfld("Password","",&s,xxstring)) < 0) { if (x == -3) { makestr(&ssh_tmpstr,""); } else { return(x); } } else { s = brstrip(s); if ((x = (int)strlen(s)) > PWBUFL) { makestr(&slmsg,"Internal error"); printf("?Sorry, too long - max = %d\n",PWBUFL); return(-9); } makestr(&ssh_tmpstr,s); } break; case SSHSW_VER: if ((x = cmnum("Number","",10,&z,xxstring)) < 0) return(x); if (z < 1 || z > 2) { printf("?Out of range: %d\n",z); return(-9); } tmpver = z; break; default: return(-2); } } if (trips++ == 0) { /* After first time through */ cmfdbi(&kw, /* only parse switches, not port. */ _CMKEY, "Switch", "", "", nsshkrmopnsw, 4, xxstring, sshkrmopnsw, NULL ); } } if ((x = cmcfm()) < 0) /* Get confirmation */ return(x); if (clskconnx(1) < 0) { /* Close current Kermit connection */ if ( ssh_tmpstr ) { memset(ssh_tmpstr,0,strlen(ssh_tmpstr)); makestr(&ssh_tmpstr,NULL); } return(success = 0); } makestr(&ssh_hst,line); /* Stash everything */ if (ssh_tmpuid) { if (!sl_uid_saved) { ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN); sl_uid_saved = 1; } ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN); makestr(&ssh_tmpuid,NULL); } if (ssh_tmpport) { makestr(&ssh_prt,ssh_tmpport); makestr(&ssh_tmpport,NULL); } else makestr(&ssh_prt,NULL); /* Set the Subsystem to Kermit */ ssh_cas = 1; makestr(&ssh_cmd,"sftp"); if (tmpver > -1) { #ifndef SSHTEST if (!sl_ssh_ver_saved) { sl_ssh_ver = ssh_ver; sl_ssh_ver_saved = 1; } #endif /* SSHTEST */ ssh_ver = tmpver; } /* Disable X11 Forwarding */ #ifndef SSHTEST if (!sl_ssh_xfw_saved) { sl_ssh_xfw = ssh_xfw; sl_ssh_xfw_saved = 1; } #endif /* SSHTEST */ ssh_xfw = 0; if (ssh_tmpstr) { if (ssh_tmpstr[0]) { ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1); pwflg = 1; pwcrypt = 0; } else pwflg = 0; makestr(&ssh_tmpstr,NULL); } nettype = NET_SSH; if (mdmsav < 0) mdmsav = mdmtyp; mdmtyp = -nettype; x = 1; #ifndef NOSPL makestr(&g_pswd,pwbuf); /* Save global pwbuf */ g_pflg = pwflg; /* and flag */ g_pcpt = pwcrypt; #endif /* NOSPL */ /* Line parameter to ttopen() is ignored */ k = ttopen(line,&x,mdmtyp, 0); if (k < 0) { printf("?Unable to connect to %s\n",ssh_hst); mdmtyp = mdmsav; slrestor(); return(success = 0); } duplex = 0; /* Remote echo */ ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */ debug(F110,"ssh ttname",ttname,0); makestr(&slmsg,NULL); /* No SET LINE error message */ cxtype = CXT_SSH; #ifndef NODIAL dialsta = DIA_UNK; #endif /* NODIAL */ success = 1; /* SET LINE succeeded */ network = 1; /* Network connection (not serial) */ local = 1; /* Local mode (not remote) */ if ((reliable != SET_OFF || !setreliable)) reliable = SET_ON; /* Transport is reliable end to end */ #ifdef OS2 DialerSend(OPT_KERMIT_CONNECT, 0); #endif /* OS2 */ setflow(); /* Set appropriate flow control */ haveline = 1; #ifdef CKLOGDIAL #ifdef NETCONN dolognet(); #endif /* NETCONN */ #endif /* CKLOGDIAL */ #ifndef NOSPL if (local) { if (nmac) { /* Any macros defined? */ int k; /* Yes */ k = mlook(mactab,"on_open",nmac); /* Look this up */ if (k >= 0) { /* If found, */ if (dodo(k,ssh_hst,0) > -1) /* set it up, */ parser(1); /* and execute it */ } } } #endif /* NOSPL */ #ifdef LOCUS if (autolocus) setlocus(1,1); #endif /* LOCUS */ /* Command was confirmed so we can pre-pop command level. */ /* This is so CONNECT module won't think we're executing a */ /* script if CONNECT was the final command in the script. */ if (cmdlvl > 0) prepop(); success = sftp_do_init(); return(success = 1); case SFTP_CD: case SFTP_CHGRP: case SFTP_CHMOD: case SFTP_CHOWN: case SFTP_RM: case SFTP_DIR: case SFTP_GET: case SFTP_MKDIR: case SFTP_PUT: case SFTP_PWD: case SFTP_REN: case SFTP_RMDIR: case SFTP_LINK: case SFTP_VER: if ((y = cmtxt("command parameters","",&s,xxstring)) < 0) return(y); if (ssh_tchk() < 0 || !ssh_cas || strcmp(ssh_cmd,"sftp")) { printf("?Not connected to SFTP Service\n"); return(success = 0); } success = sftp_do_cmd(cmresult.nresult,s); return(success); default: return(-2); } } #endif /* SFTP_BUILTIN */ if (cx == XXRLOG) { /* RLOGIN */ #ifdef RLOGCODE int x,z; #ifdef OS2 if (!tcp_avail) { printf("?Sorry, either TCP/IP is not available on this system or\n\ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n" ); success = 0; return(-9); } else { #endif /* OS2 */ x = nettype; /* Save net type in case of failure */ z = ttnproto; /* Save protocol in case of failure */ nettype = NET_TCPB; ttnproto = NP_RLOGIN; if ((y = setlin(XYHOST,0,1)) <= 0) { nettype = x; /* Failed, restore net type. */ ttnproto = z; /* and protocol */ success = 0; } didsetlin++; #ifdef OS2 } #endif /* OS2 */ return(y); #else printf("?Sorry, RLOGIN is not configured in this copy of C-Kermit.\n"); return(-9); #endif /* RLOGCODE */ } #endif /* NETCONN */ #endif /* NOLOCAL */ #ifndef NOXMIT if (cx == XXTRA) { /* TRANSMIT */ extern int xfrxla; int i, n, xpipe = 0, xbinary = 0, xxlate = 1, xxnowait = 0, getval; int xxecho = 0; int scan = 1; char c; struct FDB sf, sw, tx; /* FDBs for parse functions */ #ifndef NOCSETS extern int tcs_transp; /* Term charset is transparent */ #else int tcs_transp = 1; #endif /* NOCSETS */ #ifdef COMMENT xbinary = binary; /* Default text/binary mode */ #else xbinary = 0; /* Default is text */ #endif /* COMMENT */ xxecho = xmitx; cmfdbi(&sw, /* First FDB - command switches */ _CMKEY, /* fcode */ "Filename, or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ nxmitsw, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ xmitsw, /* Keyword table */ &sf /* Pointer to next FDB */ ); cmfdbi(&sf, /* 2nd FDB - file to send */ _CMIFI, /* fcode */ "File to transmit", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, #ifdef PIPESEND &tx #else NULL #endif /* PIPESEND */ ); #ifdef PIPESEND cmfdbi(&tx, _CMTXT, /* fcode */ "Command", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); #endif /* PIPESEND */ while (1) { x = cmfdb(&sw); if (x < 0) return(x); if (cmresult.fcode != _CMKEY) break; c = cmgbrk(); /* Have switch, get break character */ if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) { printf("?This switch does not take an argument\n"); return(-9); } if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); return(-9); } n = cmresult.nresult; /* Numeric result = switch ID */ switch (n) { /* Process the switch */ #ifdef PIPESEND case XMI_CMD: /* Transmit from a command */ if (nopush) { printf("?Sorry, system command access is disabled\n"); return(-9); } sw.hlpmsg = "Command, or switch"; /* Change help message */ xpipe = 1; /* (No way to undo this one) */ break; #endif /* PIPESEND */ case XMI_BIN: /* Binary */ xbinary = 1; xxlate = 0; /* Don't translate charsets */ scan = 0; break; case XMI_TXT: /* Text */ xbinary = 0; xxlate = !tcs_transp; /* Translate if TERM CHAR not TRANSP */ scan = 0; break; case XMI_TRA: /* Transparent text */ xbinary = 0; xxlate = 0; /* But don't translate charsets */ scan = 0; break; #ifdef COMMENT case XMI_VRB: /* /VERBOSE */ case XMI_QUI: /* /QUIET */ break; /* (not implemented yet) */ #endif /* COMMENT */ case XMI_NOW: /* /NOWAIT */ xxnowait = 1; break; case XMI_NOE: /* /NOWAIT */ xxecho = 0; break; default: return(-2); } } if (cmresult.fcode != _CMIFI && cmresult.fcode != _CMTXT) return(-2); ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Filename */ if (zfnqfp(line,TMPBUFSIZ,tmpbuf)) ckstrncpy(line,tmpbuf,LINBUFSIZ); s = line; if ((y = cmcfm()) < 0) /* Confirm */ return(y); #ifdef CK_APC if ((apcactive == APC_LOCAL) || ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH)))) return(success = 0); #endif /* CK_APC */ if (cmresult.nresult != 0) { printf("?Only a single file may be transmitted\n"); return(-9); } #ifdef PIPESEND if (xpipe) { s = brstrip(s); if (!*s) { printf("?Sorry, a command to send from is required\n"); return(-9); } pipesend = 1; } #endif /* PIPESEND */ if (scan && (filepeek #ifndef NOXFER || patterns #endif /* NOXFER */ )) { /* If user didn't specify type */ int k, x; /* scan the file to see */ x = -1; k = scanfile(s,&x,nscanfile); if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T; } if (!xfrxla) xxlate = 0; success = transmit(s, (char) (xxnowait ? '\0' : (char)xmitp), xxlate, xbinary, xxecho ); return(success); } #endif /* NOXMIT */ #ifndef NOFRILLS if (cx == XXTYP || cx == XXCAT || cx == XXMORE || cx == XXHEAD || cx == XXTAIL) { int paging = 0, havename = 0, head = 0, width = 0; int height = 0, count = 0; char pfxbuf[64], * prefix = NULL; char outfile[CKMAXPATH+1]; struct FDB sf, sw; char * pat = NULL; int incs = 0, outcs = 0, cset = -1, number = 0; #ifdef UNICODE char * tocs = ""; extern int fileorder; #ifdef OS2 #ifdef NT char guibuf[128], * gui_title = NULL; int gui = 0; #endif /* NT */ #ifndef NOCSETS extern int tcsr, tcsl; #endif /* NOCSETS */ #endif /* OS2 */ #endif /* UNICODE */ outfile[0] = NUL; if (cx == XXMORE) paging = 1; else if (cx == XXCAT) paging = 0; else paging = (typ_page < 0) ? xaskmore : typ_page; if (paging < 0) paging = saveask; if (cx == XXHEAD) { head = 10; cx = XXTYP; } else if (cx == XXTAIL) { head = -10; cx = XXTYP; } #ifdef IKSD if (inserver && !ENABLED(en_typ)) { printf("?Sorry, TYPE command disabled\n"); return(-9); } #endif /* IKSD */ cmfdbi(&sw, /* 2nd FDB - optional /PAGE switch */ _CMKEY, /* fcode */ "Filename or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ ntypetab, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ typetab, /* Keyword table */ &sf /* Pointer to next FDB */ ); cmfdbi(&sf, /* 1st FDB - file to type */ _CMIFI, /* fcode */ "", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 0, /* addtl numeric data 1 */ 0, /* addtl numeric data 2 */ xxstring, NULL, NULL ); while (!havename) { x = cmfdb(&sw); /* Parse something */ debug(F101,"type cmfdb","",x); debug(F101,"type cmresult.fcode","",cmresult.fcode); debug(F101,"type cmresult.nresult","",cmresult.nresult); if (x < 0) { /* Error */ if (x == -3) { x = -9; printf("?Filename required\n"); } return(x); } else if (cmresult.fcode == _CMKEY) { char c; int getval; c = cmgbrk(); getval = (c == ':' || c == '='); if (getval && !(cmgkwflgs() & CM_ARG)) { printf("?This switch does not take an argument\n"); return(-9); } #ifdef COMMENT if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); /* Not if it has a default! */ return(-9); } #endif /* COMMENT */ switch (cmresult.nresult) { #ifdef CK_TTGWSIZ case TYP_PAG: paging = 1; break; case TYP_NOP: paging = 0; break; #endif /* CK_TTGWSIZ */ case TYP_COU: paging = 0; count = 1; break; case TYP_HEA: case TYP_TAI: y = 10; if (getval) if ((x = cmnum("Number of lines", "10",10,&y,xxstring)) < 0) return(x); head = (cmresult.nresult == TYP_TAI) ? -y : y; break; case TYP_WID: y = typ_wid > -1 ? typ_wid : cmd_cols; if (getval) if ((x = cmnum("Column at which to truncate", ckitoa(y),10,&y,xxstring)) < 0) return(x); width = y; break; #ifdef KUI case TYP_HIG: if (getval) if ((x = cmnum("Height of GUI dialog", ckitoa(y),10,&y,xxstring)) < 0) return(x); height = y; break; #endif /* KUI */ case TYP_PAT: if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); return(-9); } if ((x = cmfld("pattern","",&s,xxstring)) < 0) return(x); ckstrncpy(tmpbuf,s,TMPBUFSIZ); pat = tmpbuf; break; case TYP_PFX: if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); return(-9); } if ((x = cmfld("prefix for each line","",&s,xxstring)) < 0) return(x); if ((int)strlen(s) > 63) { printf("?Too long - 63 max\n"); return(-9); } ckstrncpy(pfxbuf,s,64); prefix = brstrip(pfxbuf); number = 0; break; #ifdef KUI case TYP_GUI: if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); return(-9); } if ((x = cmfld("Dialog box title","",&s,xxstring)) < 0) { if (x != -3) return(x); } else { if ((int)strlen(s) > 127) { printf("?Too long - 127 max\n"); return(-9); } ckstrncpy(guibuf,s,128); gui_title = brstrip(guibuf); } gui = 1; break; #endif /* KUI */ case TYP_NUM: /* /NUMBER */ number = 1; prefix = NULL; break; #ifdef UNICODE case TYP_XPA: /* /TRANSPARENT */ incs = 0; cset = 0; outcs = -1; break; case TYP_XIN: /* /CHARACTER-SET: */ if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); return(-9); } if ((incs = cmkey(fcstab,nfilc, "character-set name","",xxstring)) < 0) { if (incs == -3) /* Note: No default */ incs = -2; return(incs); } cset = incs; break; case TYP_XUT: /* /TRANSLATE-TO: */ if (!getval && (cmgkwflgs() & CM_ARG)) { printf("?This switch requires an argument\n"); return(-9); } #ifdef OS2 if (!inserver && !k95stdout) { tocs = "ucs2"; } else { #ifdef CKOUNI tocs = rlookup(txrtab,ntxrtab,tcsl); #else /* CKOUNI */ extern struct keytab ttcstab[]; extern int ntxrtab; tocs = rlookup(ttcstab,ntermc,tocs); if (!tocs) tocs = getdcset(); #endif /* CKOUNI */ } #else /* OS2 */ tocs = getdcset(); #endif /* OS2 */ if ((outcs = cmkey(fcstab,nfilc, "character-set",tocs,xxstring)) < 0) return(outcs); break; #endif /* UNICODE */ case TYP_OUT: if ((x = cmofi("File for result lines","", &s,xxstring)) < 0) return(x); ckstrncpy(outfile,s,CKMAXPATH); break; } } else if (cmresult.fcode == _CMIFI) havename = 1; else return(-2); } if (havename) { ckstrncpy(line,cmresult.sresult,LINBUFSIZ); y = cmresult.nresult; } else { if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) { if (x == -3) { printf("?Name of an existing file required\n"); return(-9); } else return(x); } ckstrncpy(line,s,LINBUFSIZ); } if (y != 0) { printf("?A single file please\n"); return(-9); } #ifdef KUI if ( outfile[0] && gui ) { printf("?/GUI and /OUTPUT are incompatible\n"); return(-9); } #endif /* KUI */ if ((y = cmcfm()) < 0) /* Confirm the command */ return(y); #ifdef UNICODE fileorder = -1; if (cset < 0 && filepeek) { /* If no charset switches given */ int k, x = -1; k = scanfile(line,&x,nscanfile); /* Call file analyzer */ debug(F111,"type scanfile",line,k); debug(F101,"type scanfile flag","",x); switch(k) { case FT_UTF8: /* which can detect UTF-8... */ cset = 0; incs = FC_UTF8; break; case FT_UCS2: /* and UCS-2... */ cset = 0; incs = FC_UCS2; fileorder = x; /* even if there is no BOM. */ debug(F101,"type fileorder","",fileorder); break; } } #ifdef OS2 if (cset < 0) { /* If input charset still not known */ #ifdef CKOUNI tocs = rlookup(txrtab,ntxrtab,tcsl); #else /* CKOUNI */ extern struct keytab ttcstab[]; extern int ntxrtab; tocs = rlookup(ttcstab,ntermc,incs); if (!tocs) tocs = getdcset(); #endif /* CKOUNI */ incs = lookup(fcstab,tocs,nfilc,&x); } #endif /* OS2 */ if (outcs == 0 && incs != 0) { /* Supply default target charset */ int x = 0; /* if switch not given. */ tocs = getdcset(); outcs = lookup(fcstab,tocs,nfilc,&x); } #else /* !UNICODE */ if (cset < 0) incs = outcs = 0; #endif /* UNICODE */ if (outfile[0] && paging) /* This combination makes no sense */ paging = 0; /* so turn off paging */ #ifdef KUI /* No paging when dialog is used */ if ( gui && paging ) paging = 0; if ( !gui && height ) { printf("?The /HEIGHT switch is not supported without /GUI\n"); return(-9); } #endif /* KUI */ if (count) paging = -1; debug(F111,"type",line,paging); #ifdef KUI if ( gui ) { s = (char *)1; /* ok, its an ugly hack */ if (gui_text_popup_create(gui_title ? gui_title : line, height,width) < 0) { printf("?/GUI not supported on this system\n"); gui = 0; return(-9); } width = 0; } else #endif /* KUI */ s = outfile; success = dotype(line,paging,0,head,pat,width,prefix,incs,outcs,s,number); return(success); } #endif /* NOFRILLS */ #ifndef NOCSETS if (cx == XXXLA) { /* TRANSLATE file's charset */ _PROTOTYP (int doxlate, ( void ) ); return(doxlate()); } #endif /* NOCSETS */ if (cx == XXVER) { /* VERSION */ int n = 0; extern char * ck_patch, * ck_s_test; #ifdef COMMENT extern int hmtopline; #endif /* COMMENT */ if ((y = cmcfm()) < 0) return(y); #ifdef CK_64BIT printf("\n%s, for%s (64-bit)\n Numeric: %ld",versio,ckxsys,vernum); #else printf("\n%s, for%s\n Numeric: %ld",versio,ckxsys,vernum); #endif /* CK_64BIT */ printf("\n\n"); printf("Authors:\n"); printf(" <NAME>, Columbia University\n"); printf(" <NAME>, Secure Endpoints, Inc. %s\n", "<<EMAIL>>" ); printf(" Contributions from many others.\n"); n = 7; if (*ck_s_test) { printf("\nTHIS IS A TEST VERSION, NOT FOR PRODUCTION USE.\n"); n += 2; } if (*ck_patch) { printf(" Patches: %s\n", ck_patch); n++; } printf(" Type COPYRIGHT for copyright and license.\n\n"); #ifdef OS2 shoreg(); #else #ifdef COMMENT hmtopline = n+1; hmsga(copyright); hmtopline = 0; #endif /* COMMENT */ #endif /* OS2 */ return(success = 1); } if (cx == XXCPR) { /* COPYRIGHT or LICENSE */ _PROTOTYP( int hmsgaa, (char * [], char *) ); extern char * ck_cryear; if ((y = cmcfm()) < 0) return(y); hmsgaa(copyright,ck_cryear); return(success = 1); } #ifndef MAC /* Only for multiuser systems */ #ifndef OS2 #ifndef NOFRILLS if (cx == XXWHO) { /* WHO */ char *wc; #ifdef IKSD if (inserver && !ENABLED(en_who)) { printf("?Sorry, WHO command disabled\n"); return(-9); } #endif /* IKSD */ #ifdef datageneral if ((z = cmcfm()) < 0) return(z); if (nopush) { printf("?Sorry, who not allowed\n"); return(success = 0); } xsystem(WHOCMD); #else if ((y = cmtxt("user name","",&s,xxstring)) < 0) return(y); if (nopush) { printf("?Sorry, WHO command disabled\n"); return(success = 0); } if (!(wc = getenv("CK_WHO"))) wc = WHOCMD; if (wc) if ((int) strlen(wc) > 0) { ckmakmsg(line,LINBUFSIZ,wc," ",s,NULL); xsystem(line); } #endif /* datageneral */ return(success = 1); } #endif /* NOFRILLS */ #endif /* OS2 */ #endif /* MAC */ #ifndef NOFRILLS if (cx == XXWRI || cx == XXWRL || cx == XXWRBL) { /* WRITE */ int x,y; /* On stack in case of \fexec() */ if ((x = cmkey(writab,nwri,"to file or log","",xxstring)) < 0) { if (x == -3) printf("?Write to what?\n"); return(x); } if ((y = cmtxt("text","",&s,xxstring)) < 0) return(y); s = brstrip(s); switch (x) { case LOGD: y = ZDFILE; break; case LOGP: y = ZPFILE; break; #ifndef NOLOCAL case LOGS: y = ZSFILE; break; #endif /* NOLOCAL */ case LOGT: y = ZTFILE; break; #ifndef NOSPL case LOGW: y = ZWFILE; break; #endif /* NOSPL */ case LOGX: /* SCREEN (stdout) */ case LOGE: /* ERROR (stderr) */ if (x == LOGE) { debug(F110, (cx == XXWRL) ? "WRITELN ERROR" : "WRITE ERROR", s,0); fprintf(stderr,"%s%s",s,(cx == XXWRL) ? "\n" : ""); } else { debug(F110, (cx == XXWRL) ? "WRITELN SCREEN" : "WRITE SCREEN", s,0); printf("%s%s",s,(cx == XXWRL) ? "\n" : ""); } return(success = 1); default: return(-2); } if (chkfn(y) > 0) { x = (cx == XXWRI) ? zsout(y,s) : zsoutl(y,s); debug(F111,"WRITE", (cx == XXWRI) ? "zsout" : "zsoutl", x); if (x < 0) printf("?Write error\n"); } else { x = -1; printf("?File or log not open\n"); } debug(F101,"WRITE x","",x); return(success = (x == 0) ? 1 : 0); } #endif /* NOFRILLS */ #ifndef NOXFER if (cx == XXASC || cx == XXBIN) { if ((x = cmcfm()) < 0) return(x); #ifdef NEWFTP /* Make C-Kermit work like other ftp clients, where the ASCII (TEXT) and BINARY commands are global settings. */ if (ftpisopen()) { doftpglobaltype((cx == XXASC) ? XYFT_T : XYFT_B); /* Fall thru--the command it should apply to both FTP and Kermit */ /* return(success = 1); */ } #endif /* NEWFTP */ xfermode = XMODE_M; /* Set manual Kermit transfer mode */ binary = (cx == XXASC) ? XYFT_T : XYFT_B; return(success = 1); } #endif /* NOXFER */ if (cx == XXCLS) { if ((x = cmcfm()) < 0) return(x); y = ck_cls(); return(success = (y > -1) ? 1 : 0); } #ifdef CK_MKDIR if (cx == XXMKDIR || cx == XXLMKD) { char *p; #ifdef LOCUS if (!locus && cx != XXLMKD) { #ifdef NOXFER return(-2); #else return(dormt(XZMKD)); #endif /* NOXFER */ } #endif /* LOCUS */ #ifdef IKSD if (inserver && !ENABLED(en_mkd)) { printf("?Sorry, directory creation is disabled\n"); return(-9); } #endif /* IKSD */ if ((x = cmfld("Name for new directory","",&s,xxstring)) < 0) { if (x != -3) { return(x); } else { printf("?Directory name required\n"); return(-9); } } ckstrncpy(line,s,LINBUFSIZ); s = line; if ((x = cmcfm()) < 0) return(x); s = brstrip(s); bgchk(); /* Set msgflg */ x = ckmkdir(0,s,&p,msgflg,0); #ifdef COMMENT if (msgflg && x == 0) printf("?Directory already exists\n"); #endif /* COMMENT */ return(success = (x < 0) ? 0 : 1); } if (cx == XXRMDIR || cx == XXLRMD) { /* RMDIR */ char *p; #ifdef LOCUS if (!locus && cx != XXLRMD) { #ifdef NOXFER return(-2); #else return(dormt(XZRMD)); #endif /* NOXFER */ } #endif /* LOCUS */ #ifdef IKSD if (inserver && !ENABLED(en_rmd)) { printf("?Sorry, directory removal is disabled\n"); return(-9); } #endif /* IKSD */ if ((x = cmdir("Name of directory to be removed","",&s,xxstring)) < 0) return(x); ckstrncpy(line,s,LINBUFSIZ); s = line; if ((x = cmcfm()) < 0) return(x); s = brstrip(s); x = ckmkdir(1,s,&p,msgflg,0); return(success = (x < 0) ? 0 : 1); } #endif /* CK_MKDIR */ #ifdef TNCODE if (cx == XXTELOP) return(dotelopt()); #endif /* TNCODE */ #ifndef NOPUSH if (cx == XXNPSH) { if ((z = cmcfm()) < 0) return(z); nopush = 1; #ifndef NOSERVER en_hos = 0; #endif /* NOSERVER */ #ifdef PIPESEND usepipes = 0; #endif /* PIPESEND */ return(success = 1); } #endif /* NOPUSH */ #ifdef OS2 if (cx == XXNSCR) { if ((z = cmcfm()) < 0) return(z); tt_scroll = 0; return(success = 1); } #endif /* OS2 */ #ifndef NOSPL if (cx == XXLOCAL) /* LOCAL variable declarations */ return(success = dolocal()); #endif /* NOSPL */ if (cx == XXKERMI) { /* The KERMIT command */ char * list[65]; extern char **xargv; extern int xargc; int i; if ((y = cmtxt("kermit command-line arguments, -h for help", "",&s,xxstring)) < 0) return(y); ckstrncpy(line,"kermit ",LINBUFSIZ); ckstrncat(line,s,LINBUFSIZ-8); xwords(line,64,list,0); for (i = 1; i < 64; i++) { if (!list[i]) break; } i--; xargc = i; xargv = list; xargv++; sstate = cmdlin(); if (sstate) { extern int justone; debug(F000,"KERMIT sstate","",sstate); justone = 1; /* Force return to command mode */ proto(); /* after protocol */ return(success); } else { debug(F101,"KERMIT sstate","",sstate); return(success = 1); /* Not exactly right, but... */ } } if (cx == XXDATE) { /* DATE command */ extern char cmdatebuf[], * cmdatemsg; #ifndef COMMENT char * dp; if ((y = cmtxt("date and/or time, or carriage return for current", "",&s,xxstring)) < 0) return(y); s = brstrip(s); dp = cmcvtdate(s,1); if (!dp) { printf("?%s\n",cmdatemsg ? cmdatemsg : "Date conversion error"); success = 0; } else { printf("%s\n",dp); success = 1; } #else /* This works fine but messes up my "dates" torture-test script */ if ((x = cmdate("Date and/or time, or carriage return for current", "",&s,0,xxstring)) < 0) { return(x); } else { printf("%s\n",cmdatebuf); success = 1; } #endif /* COMMENT */ return(success); } #ifndef NOPUSH #ifndef NOFRILLS if (cx == XXEDIT) return(doedit()); #endif /* NOFRILLS */ #endif /* NOPUSH */ #ifdef BROWSER /* Defined only ifndef NOPUSH */ if (cx == XXBROWS) return(dobrowse()); #endif /* BROWSER */ #ifdef CK_TAPI if (cx == XXTAPI) { /* Microsoft TAPI */ return (success = dotapi()); } #endif /* CK_TAPI */ #ifndef NOXFER if (cx == XXWHERE) { extern char * rfspec, * sfspec, * srfspec, * rrfspec; if ((x = cmcfm()) < 0) return(x); printf("\nFile most recently...\n\n"); printf(" Sent: %s\n", sfspec ? sfspec : "(none)"); if (sfspec && srfspec) { printf(" Stored as: %s\n", srfspec); printf("\n"); } printf(" Received: %s\n", rrfspec ? rrfspec : "(none)"); if (rfspec && rrfspec) printf(" Stored as: %s\n", rfspec); printf( "\nIf the full path is not shown, then the file is probably in your current\n" ); printf( "directory or your download directory (if any - SHOW FILE to find out).\n\n" ); return(success = 1); } #endif /* NOXFER */ #ifdef CK_RECALL if (cx == XXREDO) return(doredo()); #endif /* CK_RECALL */ #ifdef CKROOT if (cx == XXCHRT) /* Change Kermit's root directory */ return(dochroot()); #endif /* CKROOT */ #ifdef CK_KERBEROS if (cx == XXAUTH) { /* KERBEROS */ x = cp_auth(); /* Parse it */ #ifdef IKSD if (inserver) { printf("?Command disabled in IKSD.\r\n"); return(success = 0); } #endif /* IKSD */ if (x < 0) /* Pass parse errors back */ return(x); return(success = doauth(cx)); } #endif /* CK_KERBEROS */ #ifndef NOLOCAL if (cx == XXTERM) { return(settrmtyp()); } #endif /* NOLOCAL */ if (cx == XXSTATUS) { if ((x = cmcfm()) < 0) return(x); printf( " %s\n", success ? "SUCCESS" : "FAILURE" ); return(0); /* Don't change it */ } if (cx == XXFAIL) { if ((x = cmcfm()) < 0) return(x); return(success = 0); } if (cx == XXSUCC) { if ((x = cmcfm()) < 0) return(x); return(success = 1); } if (cx == XXNLCL) { extern int nolocal; if ((x = cmcfm()) < 0) return(x); nolocal = 1; return(success = 1); } #ifndef NOXFER if (cx == XXRASG) /* Shortcuts for REMOTE commands */ return(dormt(XZASG)); if (cx == XXRCWD) return(dormt(XZCWD)); if (cx == XXRCPY) return(dormt(XZCPY)); if (cx == XXRDEL) return(dormt(XZDEL)); if (cx == XXRDIR) return(dormt(XZDIR)); if (cx == XXRXIT) return(dormt(XZXIT)); if (cx == XXRHLP) return(dormt(XZHLP)); if (cx == XXRHOS) return(dormt(XZHOS)); if (cx == XXRKER) return(dormt(XZKER)); if (cx == XXRPWD) return(dormt(XZPWD)); if (cx == XXRQUE) return(dormt(XZQUE)); if (cx == XXRREN) return(dormt(XZREN)); if (cx == XXRMKD) return(dormt(XZMKD)); if (cx == XXRMSG) return(dormt(XZMSG)); if (cx == XXRRMD) return(dormt(XZRMD)); if (cx == XXRSET) return(dormt(XZSET)); if (cx == XXRSPA) return(dormt(XZSPA)); if (cx == XXRTYP) return(dormt(XZTYP)); if (cx == XXRWHO) return(dormt(XZWHO)); if (cx == XXRCDUP) return(dormt(XZCDU)); if (cx == XXRPRI) return(dormt(XZPRI)); #endif /* NOXFER */ if (cx == XXRESET) { /* RESET */ if ((x = cmcfm()) < 0) return(x); concb((char)escape); /* Make command echoing to normal */ doclean(0); /* Close all files */ return(success = 1); } #ifndef NOXFER #ifndef NOCSETS if (cx == XXASSOC) /* ASSOCIATE */ return(doassoc()); #endif /* NOCSETS */ #endif /* NOXFER */ #ifndef NOSPL if (cx == XXSHIFT) { /* SHIFT */ if ((y = cmnum("Number of arguments to shift","1",10,&x,xxstring)) < 0) return(y); if ((z = cmcfm()) < 0) return(z); return(success = doshift(x)); } #endif /* NOSPL */ #ifndef NOHELP if (cx == XXMAN) return(domanual()); #endif /* NOHELP */ #ifndef NOSPL if (cx == XXSORT) /* SORT an array */ return(dosort()); #endif /* NOSPL */ if (cx == XXPURGE) { #ifdef IKSD if (inserver && (!ENABLED(en_del) #ifdef CK_LOGIN || isguest #endif /* CK_LOGIN */ )) { printf("?Sorry, DELETE is disabled\n"); return(-9); } #endif /* IKSD */ #ifdef CK_APC if ((apcactive == APC_LOCAL) || ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH)))) return(success = 0); #endif /* CK_APC */ #ifdef CKPURGE return(dopurge()); #else #ifdef VMS if ((x = cmtxt("optional switches followed by filespec", "",&s,xxstring)) < 0) return(x); if (nopush) { printf("?Sorry, DCL access is disabled\n"); return(-9); } ckstrncpy(line,s,LINBUFSIZ); s = line; x = mlook(mactab,"purge",nmac); return(success = dodo(x,s,cmdstk[cmdlvl].ccflgs)); #else return(-2); #endif /* VMS */ #endif /* CKPURGE */ } #ifndef NOSPL if (cx == XXFAST) { if ((x = cmcfm()) < 0) return(x); x = mlook(mactab,"fast",nmac); return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs)); } if (cx == XXCAU) { if ((x = cmcfm()) < 0) return(x); x = mlook(mactab,"cautious",nmac); return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs)); } if (cx == XXROB) { if ((x = cmcfm()) < 0) return(x); x = mlook(mactab,"robust",nmac); return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs)); } #endif /* NOSPL */ if (cx == XXSCRN) { /* SCREEN */ int row, col; if ((x = cmkey(scntab, nscntab,"screen action","", xxstring)) < 0) return(x); switch (x) { /* MOVE-TO (cursor position) */ case SCN_MOV: if ((y = cmnum("Row (1-based)","",10,&z,xxstring)) < 0) return(y); row = z; y = cmnum("Column (1-based)","1",10,&z,xxstring); if (y < 0) return(y); col = z; if ((y = cmcfm()) < 0) return(y); if (row < 0 || col < 0) { printf("?Row and Column must be 1 or greater\n"); return(-9); } if (cmd_rows > 0 && row > cmd_rows) row = cmd_rows; if (cmd_cols > 0 && col > cmd_cols) col = cmd_cols; y = ck_curpos(row,col); return(success = (y > -1) ? 1 : 0); case SCN_CLR: /* CLEAR */ if ((y = cmcfm()) < 0) return(y); debug(F100,"screen calling ck_cls()","",0); y = ck_cls(); return(success = (y > -1) ? 1 : 0); case SCN_CLE: /* CLEOL */ if ((y = cmcfm()) < 0) return(y); y = ck_cleol(); return(success = (y > -1) ? 1 : 0); } } #ifndef NOHTTP #ifdef TCPSOCKET if (cx == XXHTTP) return(dohttp()); #endif /* TCPSOCKET */ #endif /* NOHTTP */ #ifndef NOSPL if (cx == XXARRAY) { /* ARRAY */ #ifndef NOSHOW extern int showarray(); #endif /* NOSHOW */ if ((x = cmkey(arraytab, narraytab,"Array operation","",xxstring)) < 0) return(x); switch (x) { case ARR_DCL: return(dodcl(XXDCL)); case ARR_SRT: return(dosort()); #ifndef NOSHOW case ARR_SHO: return(showarray()); #endif /* NOSHOW */ case ARR_CPY: return(copyarray()); case ARR_SET: case ARR_CLR: return(clrarray(x)); case ARR_DST: return(unarray()); case ARR_RSZ: return(rszarray()); case ARR_EQU: return(linkarray()); default: printf("?Sorry, not implemented yet - \"%s\"\n",cmdbuf); return(-9); } } if (cx == XXTRACE) /* TRACE */ return(dotrace()); #endif /* NOSPL */ #ifdef CK_PERMS #ifdef UNIX if (cx == XXCHMOD) return(douchmod()); /* Do Unix chmod */ #endif /* UNIX */ #endif /* CK_PERMS */ if (cx == XXPROMP) return(doprompt()); if (cx == XXGREP) return(dogrep()); if (cx == XXDEBUG) { /* DEBUG */ #ifndef DEBUG int dummy = 0; return(seton(&dummy)); #else return(seton(&deblog)); #endif /* DEBUG */ } if (cx == XXMSG || cx == XXXMSG) { /* MESSAGE */ extern int debmsg; /* Script debugging messages */ if ((x = cmtxt("Message to print if SET DEBUG MESSAGE is ON or STDERR", "",&s,xxstring)) < 0) return(x); if (!s) /* Watch out for null result */ s = ""; /* Make it an empty string */ else /* Not null */ s = brstrip(s); /* Strip braces and doublequotes */ switch (debmsg) { /* Not debugging - don't print */ case 0: break; case 1: printf("%s",s); /* Print to stdout */ if (cx == XXMSG) printf("\n"); break; case 2: fprintf(stderr,"%s",s); /* Ditto but print to stderr */ if (cx == XXMSG) fprintf(stderr,"\n"); break; } return(0); /* Return without affecting SUCCESS */ } #ifdef CKLEARN if (cx == XXLEARN) { /* LEARN */ struct FDB of, sw, cm; int closing = 0, off = 0, on = 0, confirmed = 0; char c; cmfdbi(&sw, /* 2nd FDB - optional /PAGE switch */ _CMKEY, /* fcode */ "Script file name, or switch", /* hlpmsg */ "", /* default */ "", /* addtl string data */ 3, /* addtl numeric data 1: tbl size */ 4, /* addtl numeric data 2: 4 = cmswi */ xxstring, /* Processing function */ learnswi, /* Keyword table */ &of /* Pointer to next FDB */ ); cmfdbi(&of,_CMOFI,"","","",0,0,xxstring,NULL,&cm); cmfdbi(&cm,_CMCFM,"","","",0,0,NULL,NULL,NULL); line[0] = NUL; while (!confirmed) { x = cmfdb(&sw); /* Parse something */ if (x < 0) return(x); switch (cmresult.fcode) { /* What was it? */ case _CMOFI: /* Output file name */ ckstrncpy(line,cmresult.sresult,LINBUFSIZ); break; case _CMKEY: /* Switch */ c = cmgbrk(); if ((c == ':' || c == '=') && !(cmgkwflgs() & CM_ARG)) { printf("?This switch does not take an argument\n"); return(-9); } switch (cmresult.nresult) { case 2: /* /CLOSE */ closing = 1; /* Fall thru on purpose */ case 0: /* /OFF */ off = 1; on = 0; break; case 1: /* /ON */ on = 1; off = 0; break; } break; case _CMCFM: /* Confirmation */ confirmed++; break; } } if (closing) { if (learnfp) { fclose(learnfp); learnfp = NULL; } makestr(&learnfile,NULL); } if (line[0]) { if (!on && !off) on = 1; if (learnfp) { fclose(learnfp); learnfp = NULL; } makestr(&learnfile,line); if (learnfile) { char * modes = "w"; learnfp = fopen(learnfile,modes); if (!learnfp) { debug(F110,"LEARN file open error",learnfile,0); perror(learnfile); return(-9); } else { #ifdef ZFNQFP if (zfnqfp(learnfile,TMPBUFSIZ,tmpbuf)) makestr(&learnfile,tmpbuf); #endif /* ZFNQFP */ debug(F110,"LEARN file open ok",learnfile,0); if (!quiet) { printf("Recording to %s...\n\n",learnfile); printf( " WARNING: If you type your password during script recording, it will appear\n\ in the file. Be sure to edit it or take other appropriate precautions.\n\n" ); } fputs( "; Scriptfile: ",learnfp); fputs(learnfile,learnfp); fputs("\n; Directory: ",learnfp); fputs(zgtdir(),learnfp); fputs("\n; Recorded: ",learnfp); fputs(ckdate(),learnfp); fputs("\n",learnfp); } } } if (on) { learning = 1; } else if (off) { learning = 0; } debug(F101,"LEARN learning","",learning); return(success = 1); } #endif /* CKLEARN */ #ifdef NEWFTP if (cx == XXUSER || cx == XXACCT) { if (!ftpisopen()) { printf("?FTP connection is not open\n"); return(-9); } return(success = (cx == XXUSER) ? doftpusr() : doftpacct()); } if (cx == XXSITE || cx == XXPASV) { if (!ftpisopen()) { printf("?FTP connection is not open\n"); return(-9); } return(success = (cx == XXSITE) ? doftpsite() : dosetftppsv()); } #endif /* NEWFTP */ if (cx == XXORIE) { /* ORIENTATION */ extern char * myname; int i, y, n = 0; char * s, *p, vbuf[32]; char * vars[16]; char * legend[16]; if ((y = cmcfm()) < 0) return(y); printf("\nProgram name:\n %s\n\n",myname); n += 4; #ifdef NT vars[0] = "home"; legend[0] = "Your home directory"; vars[1] = "directory"; legend[1] = "K95's current directory"; vars[2] = "exedir"; legend[2] = "K95 Program directory"; vars[3] = "inidir"; legend[3] = "K95 Initialization file directory"; vars[4] = "startup"; legend[4] = "Current directory when started"; vars[5] = "common"; legend[5] = "K95 data for all users and K95SITE.INI file"; vars[6] = "personal"; legend[6] = "Your personal data directory tree"; vars[7] = "desktop"; legend[7] = "Your deskop directory tree"; vars[8] = "appdata"; legend[8] = "Your personal K95 data tree and K95CUSTOM.INI file"; vars[9] = "download"; legend[9] = "Your K95 download directory"; vars[10] = "tmpdir"; legend[10] = "Your TEMP directory"; vars[11] = NULL; legend[11] = NULL; for (i = 0; i < 16 && vars[i]; i++) { printf("%s:\n",legend[i]); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL); printf(" Variable: %s\n",vbuf); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; y = TMPBUFSIZ; s = tmpbuf; zzstring(vbuf,&s,&y); line[0] = NUL; ckGetLongPathName(tmpbuf,line,LINBUFSIZ); printf(" Long name: %s\n",line); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; line[0] = NUL; GetShortPathName(tmpbuf,line,LINBUFSIZ); printf(" Short name: %s\n",line); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; printf("\n"); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; } #else /* NT */ vars[0] = "home"; legend[0] = "Your home directory"; vars[1] = "directory"; legend[1] = "Kermit's current directory"; vars[2] = "exedir"; legend[2] = "Kermit's program directory"; vars[3] = "inidir"; legend[3] = "Initialization file directory"; vars[4] = "startup"; legend[4] = "Current directory when started"; vars[5] = "download"; legend[5] = "Kermit download directory"; vars[6] = NULL; legend[6] = NULL; for (i = 0; i < 16 && vars[i]; i++) { printf("%s:\n",legend[i]); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL); printf(" Variable: %s\n",vbuf); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; y = TMPBUFSIZ; s = tmpbuf; zzstring(vbuf,&s,&y); printf(" Value: %s\n",tmpbuf); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; printf("\n"); if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0; } #endif /* NT */ return(success = 1); } #ifdef NT if (cx == XXDIALER) { StartDialer(); return(success = 1); } #endif /* NT */ if (cx == XXCONT) { /* CONTINUE */ if ((x = cmcfm()) < 0) return(x); if (!xcmdsrc) { /* At prompt: continue script */ if (cmdlvl > 0) popclvl(); /* Pop command level */ return(success = 1); /* always succeeds */ #ifndef NOSPL } else { /* In script: whatever... */ x = mlook(mactab,"continue",nmac); /* Don't set success */ return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs)); #endif /* NOSPL */ } } #ifdef UNIX #ifndef NOPUTENV /* NOTE: Syntax is PUTENV name value, not PUTENV name=value. I could check for this but it would be too much magic. */ if (cx == XXPUTE) { /* PUTENV */ char * t = tmpbuf; /* Create or alter environment var */ char * s1 = NULL, * s2 = NULL; if ((x = cmfld("Variable name","",&s,xxstring)) < 0) return(x); if (s) if (s == "") s = NULL; (VOID) makestr(&s1,s); if (s && !s1) { printf("?PUTENV - memory allocation failure\n"); return(-9); } if ((x = cmtxt("Value","",&s,xxstring)) < 0) return(x); if (s) if (s == "") s = NULL; (VOID) makestr(&s2,s); success = doputenv(s1,s2); (VOID) makestr(&s1,NULL); (VOID) makestr(&s2,NULL); return(success); } #endif /* NOPUTENV */ #endif /* UNIX */ if (cx == XXNOTAV) { /* Command in table not available */ ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ); if ((x = cmtxt("Rest of command","",&s,NULL)) < 0) return(x); printf("Sorry, \"%s\" not configured in this version of Kermit.\n", tmpbuf ); return(success = 0); } return(-2); /* None of the above */ } /* end of docmd() */ #endif /* NOICP */
1.507813
2
thirdparty/p7logger/Headers/P7_Cproxy.h
Throne3d/d912pxy
29
7998907
//////////////////////////////////////////////////////////////////////////////// // / // 2012-2017 (c) Baical / // / // This library is free software; you can redistribute it and/or / // modify it under the terms of the GNU Lesser General Public / // License as published by the Free Software Foundation; either / // version 3.0 of the License, or (at your option) any later version. / // / // This library is distributed in the hope that it will be useful, / // but WITHOUT ANY WARRANTY; without even the implied warranty of / // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU / // Lesser General Public License for more details. / // / // You should have received a copy of the GNU Lesser General Public / // License along with this library. / // / //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // This header file provides access to P7 library functionality from C language/ // or from any other language using dll/so interface / // / // +-------------------+ / // | Sink | / // | * Network (Baical)| / // | * FileBin | / // | * FileTxt | / // | * Console | / // | * Syslog | / // | * Auto | / // | * Null | / // +---------^---------+ / // | / // | / // +---------+---------+ / // | P7 Client | / // | [ Channels ] | / // | +-+ +-+ +--+ | / // | |0| |1| ...|31| | / // | +^+ +^+ +-^+ | / // +---|---|-------|---+ / // | | | / // +-----+ | +----------+ / // | | | / // | | | / // +---+---+ +---+--------+ +---+---+ / // | Trace | | Telemetry | | Trace | / // |Channel| | channel | ... |Channel| / // +-------+ +------------+ +-------+ / // / //////////////////////////////////////////////////////////////////////////////// // // // Documentation is located in <P7>/Documentation/P7.pdf // // // //////////////////////////////////////////////////////////////////////////////// #ifndef P7_PROXY_H #define P7_PROXY_H #ifdef __cplusplus extern "C" { #endif //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // // // P7 client // // // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// typedef void* hP7_Client; typedef tUINT64 (__cdecl *fnGet_Time_Stamp)(void *i_pContext); typedef void (__cdecl *fnConnect)(void *i_pContext, tBOOL i_bConnected); //////////////////////////////////////////////////////////////////////////////// //P7_Client_Create - function creates new P7 client, client is used as transport //engine for telemetry & trace channels, every client can handle up to 32 //channels. //See documentation for details. //////////////////////////////////////////////////////////////////////////////// //N.B: P7 client in addition will analyze your application command line and // arguments specified through command line will have higher priority then // i_sArgs arguments extern P7_EXPORT hP7_Client __cdecl P7_Client_Create(const tXCHAR *i_pArgs); //dll/so function prototype typedef hP7_Client (__cdecl *fnP7_Client_Create)(const tXCHAR *i_pArgs); //////////////////////////////////////////////////////////////////////////////// //This functions allows you to get P7 client instance if it was created by //someone else inside current process and shared using P7_Client_Share() func. //If no instance was registered inside current process - function will return //NULL. Do not forget to call P7_Client_Free() when you finish your work. //See documentation for details. extern P7_EXPORT hP7_Client __cdecl P7_Client_Get_Shared(const tXCHAR *i_pName); //dll/so function prototype typedef hP7_Client (__cdecl *fnP7_Client_Get_Shared)(const tXCHAR *i_pName); //////////////////////////////////////////////////////////////////////////////// //P7_Client_Share - function to share current P7 client object in address space //of the current process, to get shared client use function P7_Client_Get_Shared //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Client_Share(hP7_Client i_hClient, const tXCHAR *i_pName ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Client_Share)(hP7_Client i_hClient, const tXCHAR *i_pName ); //////////////////////////////////////////////////////////////////////////////// //P7_Client_Add_Ref - increase reference counter for the client //See documentation for details. extern P7_EXPORT tINT32 __cdecl P7_Client_Add_Ref(hP7_Client i_hClient); //dll/so function prototype typedef tINT32 (__cdecl *fnP7_Client_Add_Ref)(hP7_Client i_hClient); //////////////////////////////////////////////////////////////////////////////// //P7_Client_Release - function release the client, reference counter technology //See documentation for details. extern P7_EXPORT tINT32 __cdecl P7_Client_Release(hP7_Client i_hClient); //dll/so function prototype typedef tINT32 (__cdecl *fnP7_Client_Release)(hP7_Client i_hClient); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // P7 Crash processor // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //This function setup crash handler to catch and process exceptions like // * access violation/segmentation fault // * division by zero // * pure virtual call // * etc. //When crash occurs handler will call P7_Exceptional_Flush function automatically extern P7_EXPORT void __cdecl P7_Set_Crash_Handler(); //dll/so function prototype typedef void (__cdecl *fnP7_Set_Crash_Handler)(); //////////////////////////////////////////////////////////////////////////////// //This function clears crash handler extern P7_EXPORT void __cdecl P7_Clr_Crash_Handler(); //dll/so function prototype typedef void (__cdecl *fnP7_Clr_Crash_Handler)(); //////////////////////////////////////////////////////////////////////////////// //Function allows to flush (deliver) not delivered/saved P7 buffers for all //opened clients and related channels owned by process in CASE OF your app/proc. //crash. //This function do not call system memory allocation functions only writes to //file/socket. //Classical scenario: your application has been crushed, you catch the moment of //crush and call this function once. //Has to be used if integrator implements own crash handling mechanism. //N.B.: DO NOT USE OTHER P7 FUNCTION AFTER CALLING OF THIS FUNCTION //See documentation for details. extern P7_EXPORT void __cdecl P7_Exceptional_Flush(); //dll/so function prototype typedef void (__cdecl *fnP7_Exceptional_Flush)(); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // // // P7 Telemetry // // // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// typedef void* hP7_Telemetry; typedef void (__cdecl *fnTelemetry_Enable)(void *i_pContext, tUINT8 i_bId, tBOOL i_bEnable); typedef struct { void *pContext; //context to be passed back to callbacks tUINT64 qwTimestamp_Frequency; //count ticks per second, works in cooperation with pTimestamp_Callback fnGet_Time_Stamp pTimestamp_Callback; //callback for getting user timestamps, works in cooperation with qwTimestamp_Frequency fnTelemetry_Enable pEnable_Callback; //Callback to notify user when counter has been enables/disabled remotely fnConnect pConnect_Callback; //Callback notifies user when connection with Baical is established/closed } stTelemetry_Conf; //////////////////////////////////////////////////////////////////////////////// //P7_Telemetry_Create - function create new instance of IP7_Telemetry object //See documentation for details. extern P7_EXPORT hP7_Telemetry __cdecl P7_Telemetry_Create(hP7_Client i_hClient, const tXCHAR *i_pName, const stTelemetry_Conf *i_pConf ); //dll/so function prototype typedef hP7_Telemetry (__cdecl *fnP7_Telemetry_Create)(hP7_Client i_hClient, const tXCHAR *i_pName, const stTelemetry_Conf *i_pConf ); //////////////////////////////////////////////////////////////////////////////// //P7_Telemetry_Share - function to share current P7 telemetry object in address //space of the current process, to get shared client use function //P7_Telemetry_Get_Shared //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Telemetry_Share(hP7_Telemetry i_hTelemetry, const tXCHAR *i_pName ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Telemetry_Share)(hP7_Telemetry i_hTelemetry, const tXCHAR *i_pName ); //////////////////////////////////////////////////////////////////////////////// //This functions allow you to get P7 telemetry instance if it was created by //someone other inside current process. If no instance was registered inside //current process - function will return NULL. Do not forget to call Release //on interface when you finish your work //See documentation for details. extern P7_EXPORT hP7_Telemetry __cdecl P7_Telemetry_Get_Shared(const tXCHAR *i_pName); //dll/so function prototype typedef hP7_Telemetry (__cdecl *fnP7_Telemetry_Get_Shared)(const tXCHAR *i_pName); //////////////////////////////////////////////////////////////////////////////// //P7_Telemetry_Create_Counter - create new telemetry counter, max amount of //counters - 256, if you need more - we recommends you to create another telem. //channel using P7_Telemetry_Create() function //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Telemetry_Create_Counter(hP7_Telemetry i_hTelemetry, const tXCHAR *i_pName, tINT64 i_llMin, tINT64 i_llMax, tINT64 i_llAlarm, tUINT8 i_bOn, tUINT8 *o_pCounter_ID ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Telemetry_Create_Counter)(hP7_Telemetry i_hTelemetry, const tXCHAR *i_pName, tINT64 i_llMin, tINT64 i_llMax, tINT64 i_llAlarm, tUINT8 i_bOn, tUINT8 *o_pCounter_ID ); //////////////////////////////////////////////////////////////////////////////// //P7_Telemetry_Put_Value - add counter smaple value //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Telemetry_Put_Value(hP7_Telemetry i_hTelemetry, tUINT8 i_bCounter_ID, tINT64 i_llValue ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Telemetry_Put_Value)(hP7_Telemetry i_hTelemetry, tUINT8 i_bCounter_ID, tINT64 i_llValue ); //////////////////////////////////////////////////////////////////////////// //P7_Telemetry_Find_Counter - find counter ID by name //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Telemetry_Find_Counter(hP7_Telemetry i_hTelemetry, const tXCHAR *i_pName, tUINT8 *o_pCounter_ID ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Telemetry_Find_Counter)(hP7_Telemetry i_hTelemetry, const tXCHAR *i_pName, tUINT8 *o_pCounter_ID ); //////////////////////////////////////////////////////////////////////////////// //P7_Telemetry_Add_Ref - increase reference counter for the telemetry channel //See documentation for details. extern P7_EXPORT tINT32 __cdecl P7_Telemetry_Add_Ref(hP7_Telemetry i_hTelemetry); //dll/so function prototype typedef tINT32 (__cdecl *fnP7_Telemetry_Add_Ref)(hP7_Telemetry i_hTelemetry); //////////////////////////////////////////////////////////////////////////////// //P7_Telemetry_Release - function releases the telemetry, reference counter //technology is used, it mean the same client instance can be used from few //program parts, and every instance has to be released to completely destroy the //P7 telemetry object //See documentation for details. extern P7_EXPORT tINT32 __cdecl P7_Telemetry_Release(hP7_Telemetry i_hTelemetry); //dll/so function prototype typedef tINT32 (__cdecl *fnP7_Telemetry_Release)(hP7_Telemetry i_hTelemetry); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // // // P7 Trace // // // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// typedef void* hP7_Trace; typedef void* hP7_Trace_Module; //////////////////////////////////////////////////////////////////////////////// //Trace levels: #define P7_TRACE_LEVEL_TRACE 0 #define P7_TRACE_LEVEL_DEBUG 1 #define P7_TRACE_LEVEL_INFO 2 #define P7_TRACE_LEVEL_WARNING 3 #define P7_TRACE_LEVEL_ERROR 4 #define P7_TRACE_LEVEL_CRITICAL 5 typedef void (__cdecl *fnTrace_Verbosity)(void *i_pContext, hP7_Trace_Module i_hModule, tUINT32 i_dwVerbosity); typedef struct { void *pContext; //context to be passed back to callbacks tUINT64 qwTimestamp_Frequency; //count ticks per second, works in cooperation with pTimestamp_Callback fnGet_Time_Stamp pTimestamp_Callback; //callback for getting user timestamps, works in cooperation with qwTimestamp_Frequency fnTrace_Verbosity pVerbosity_Callback; //Callback to notify user when verbosity has been changed fnConnect pConnect_Callback; //Callback notifies user when connection with Baical is established/closed } stTrace_Conf; //////////////////////////////////////////////////////////////////////////////// //P7_TRACE_ADD macro for trace function calling simplification #define P7_TRACE_ADD(i_hTrace,\ i_wID,\ i_eLevel,\ i_dwModuleID,\ i_pFormat,\ ...)\ P7_Trace_Add(i_hTrace,\ i_wID,\ i_eLevel,\ i_dwModuleID,\ (tUINT16)__LINE__,\ __FILE__,\ __FUNCTION__,\ i_pFormat,\ __VA_ARGS__) //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Create_Trace - function create new instance of IP7_Trace object //See documentation for details. extern P7_EXPORT hP7_Trace __cdecl P7_Trace_Create(hP7_Client i_hClient, const tXCHAR *i_pName, const stTrace_Conf *i_pConf ); //dll/so function prototype typedef hP7_Trace (__cdecl *fnP7_Trace_Create)(hP7_Client i_hClient, const tXCHAR *i_pName, const stTrace_Conf *i_pConf ); //////////////////////////////////////////////////////////////////////////////// //This functions allow you to get P7 trace instance if it was created by someone //other inside current process. If no instance was registered inside current //process - function will return NULL. Do not forget to call Release //on interface when you finish your work //See documentation for details. extern P7_EXPORT hP7_Trace __cdecl P7_Trace_Get_Shared(const tXCHAR *i_pName); //dll/so function prototype typedef hP7_Trace (__cdecl *fnP7_Trace_Get_Shared)(const tXCHAR *i_pName); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Share - function to share current P7 trace object in address space of //the current process, to get shared trace channel use function //P7_Trace_Get_Shared() //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Trace_Share(hP7_Trace i_hTrace, const tXCHAR *i_pName ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Trace_Share)(hP7_Trace i_hTrace, const tXCHAR *i_pName ); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Set_Verbosity - function to set minimal trace verbosity, all traces //with less priority will be rejected by channel. You may set verbosity online //from Baical server //See documentation for details. extern P7_EXPORT void __cdecl P7_Trace_Set_Verbosity(hP7_Trace i_hTrace, hP7_Trace_Module i_hModule, tUINT32 i_dwVerbosity ); //dll/so function prototype typedef void (__cdecl *fnP7_Trace_Set_Verbosity)(hP7_Trace i_hTrace, hP7_Trace_Module i_hModule, tUINT32 i_dwVerbosity ); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Register_Thread - function used to specify name for current/special //thread. //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Trace_Register_Thread(hP7_Trace i_hTrace, const tXCHAR *i_pName, tUINT32 i_dwThreadId ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Trace_Register_Thread)(hP7_Trace i_hTrace, const tXCHAR *i_pName, tUINT32 i_dwThreadId ); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Unregister_Thread - function used to unregister current/special thread. //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Trace_Unregister_Thread(hP7_Trace i_hTrace, tUINT32 i_dwThreadId ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Trace_Unregister_Thread)(hP7_Trace i_hTrace, tUINT32 i_dwThreadId ); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Register_Module - function used to register module for following usage //by P7_Trace_Add/P7_Trace_Embedded/P7_Trace_Managed functions //See documentation for details. extern P7_EXPORT hP7_Trace_Module __cdecl P7_Trace_Register_Module(hP7_Trace i_hTrace, const tXCHAR *i_pName ); //dll/so function prototype typedef hP7_Trace_Module (__cdecl *fnP7_Trace_Register_Module)(hP7_Trace i_hTrace, const tXCHAR *i_pName ); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Add - send trace message to Baical server. //You may use macro P7_TRACE_ADD to simplify calling of this function //////////////////////////////////////////////////////////////////////////////// //N.B.: DO NOT USE VARIABLE for format string! You should always use CONSTANT // TEXT like L"My Format %d, %s" // USE THIS FUNCTION ONLY FROM C/C++ LANGUAGES! If you want to use trace // functionality from other languages please call Trace_Managed() function //////////////////////////////////////////////////////////////////////////////// //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Trace_Add(hP7_Trace i_hTrace, tUINT16 i_wTrace_ID, tUINT32 i_dwLevel, hP7_Trace_Module i_hModule, tUINT16 i_wLine, const char *i_pFile, const char *i_pFunction, const tXCHAR *i_pFormat, ... ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Trace_Add)(hP7_Trace i_hTrace, tUINT16 i_wTrace_ID, tUINT32 i_dwLevel, hP7_Trace_Module i_hModule, tUINT16 i_wLine, const char *i_pFile, const char *i_pFunction, const tXCHAR *i_pFormat, ... ); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Embedded - send trace message to Baical server. //this function is a copy of P7_Trace_Add function, but it is dedicated for //embedding into your log function with variable arguments list: //Usage scenario: you already have function with variable arguments, but body of //your function may be replaced by Trace_Embedded. //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Trace_Embedded(hP7_Trace i_hTrace, tUINT16 i_wTrace_ID, tUINT32 i_dwLevel, hP7_Trace_Module i_hModule, tUINT16 i_wLine, const char *i_pFile, const char *i_pFunction, const tXCHAR **i_ppFormat, va_list *i_pVa_List ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Trace_Embedded)(hP7_Trace i_hTrace, tUINT16 i_wTrace_ID, tUINT32 i_dwLevel, hP7_Trace_Module i_hModule, tUINT16 i_wLine, const char *i_pFile, const char *i_pFunction, const tXCHAR **i_ppFormat, va_list *i_pVa_List ); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Managed - send trace message to Baical server. //This function is intended for use by MANAGED languages like C#, Python, etc //It is slightly slower than P7_Trace_Add. //See documentation for details. extern P7_EXPORT tBOOL __cdecl P7_Trace_Managed(hP7_Trace i_hTrace, tUINT16 i_wTrace_ID, tUINT32 i_dwLevel, hP7_Trace_Module i_hModule, tUINT16 i_wLine, const tXCHAR *i_pFile, const tXCHAR *i_pFunction, const tXCHAR *i_pMessage ); //dll/so function prototype typedef tBOOL (__cdecl *fnP7_Trace_Managed)(hP7_Trace i_hTrace, tUINT16 i_wTrace_ID, tUINT32 i_dwLevel, hP7_Trace_Module i_hModule, tUINT16 i_wLine, const tXCHAR *i_pFile, const tXCHAR *i_pFunction, const tXCHAR *i_pMessage ); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Add_Ref - increase reference counter for the telemetry channel //See documentation for details. extern P7_EXPORT tINT32 __cdecl P7_Trace_Add_Ref(hP7_Trace i_hTrace); //dll/so function prototype typedef tINT32 (__cdecl *fnP7_Trace_Add_Ref)(hP7_Trace i_hTrace); //////////////////////////////////////////////////////////////////////////////// //P7_Trace_Release - function releases the trace object, reference counter //technology is used, it mean the same trace instance can be used from few //program parts, and every instance has to be released to completely destroy the //P7 trace object //See documentation for details. extern P7_EXPORT tINT32 __cdecl P7_Trace_Release(hP7_Trace i_hTrace); //dll/so function prototype typedef tINT32 (__cdecl *fnP7_Trace_Release)(hP7_Trace i_hTrace); #ifdef __cplusplus } #endif #endif //P7_PROXY_H
0.992188
1
extern/sdlew/include/SDL2/SDL_error.h
rbabari/blender
365
7998915
#ifndef _SDL_error_h #define _SDL_error_h #include "SDL_stdinc.h" #include "begin_code.h" #ifdef __cplusplus extern "C" { #endif typedef int SDLCALL tSDL_SetError(const char *fmt, ...); typedef const char * SDLCALL tSDL_GetError(void); typedef void SDLCALL tSDL_ClearError(void); #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) typedef enum { SDL_ENOMEM, SDL_EFREAD, SDL_EFWRITE, SDL_EFSEEK, SDL_UNSUPPORTED, SDL_LASTERROR } SDL_errorcode; typedef int SDLCALL tSDL_Error(SDL_errorcode code); extern tSDL_SetError *SDL_SetError; extern tSDL_GetError *SDL_GetError; extern tSDL_ClearError *SDL_ClearError; extern tSDL_Error *SDL_Error; #ifdef __cplusplus } #endif #include "close_code.h" #endif
0.859375
1
libsrc/common/strxfrm.c
cvemu/cc65
1
7998923
/* * strxfrm.c * * <NAME>, 11.12.1998 */ #include <string.h> size_t __fastcall__ strxfrm (char* dest, const char* src, size_t count) { strncpy (dest, src, count); return strlen (src); }
0.746094
1
Marlin/Marlin/pins_5DPRINT.h
StarbuckBG/Geeetech-G2s-Firmwares
0
7998931
/** * 5DPrint D8 Driver board pin assignments * * https://bitbucket.org/makible/5dprint-d8-controller-board */ #ifndef __AVR_AT90USB1286__ #error Oops! Make sure you have 'Teensy++ 2.0' selected from the 'Tools -> Boards' menu. #endif #define AT90USB 1286 // Disable MarlinSerial etc. #define LARGE_FLASH true #define X_STEP_PIN 0 #define X_DIR_PIN 1 #define X_ENABLE_PIN 23 #define X_STOP_PIN 37 #define Y_STEP_PIN 2 #define Y_DIR_PIN 3 #define Y_ENABLE_PIN 19 #define Y_STOP_PIN 36 #define Z_STEP_PIN 4 #define Z_DIR_PIN 5 #define Z_ENABLE_PIN 18 #define Z_STOP_PIN 39 #define E0_STEP_PIN 6 #define E0_DIR_PIN 7 #define E0_ENABLE_PIN 17 #define HEATER_0_PIN 21 // Extruder #define HEATER_1_PIN -1 #define HEATER_2_PIN -1 #define HEATER_BED_PIN 20 // Bed // You may need to change FAN_PIN to 16 because Marlin isn't using fastio.h // for the fan and Teensyduino uses a different pin mapping. #define FAN_PIN 16 // Fan #define TEMP_0_PIN 1 // Extruder / Analog pin numbering #define TEMP_BED_PIN 0 // Bed / Analog pin numbering #define TEMP_1_PIN -1 #define TEMP_2_PIN -1 #define SDPOWER -1 #define LED_PIN -1 #define PS_ON_PIN -1 #define KILL_PIN -1 #define ALARM_PIN -1 // The SDSS pin uses a different pin mapping from file Sd2PinMap.h #define SDSS 20 #ifndef SDSUPPORT // these pins are defined in the SD library if building with SD support #define SCK_PIN 9 #define MISO_PIN 11 #define MOSI_PIN 10 #endif // Microstepping pins // Note that the pin mapping is not from fastio.h // See Sd2PinMap.h for the pin configurations #undef X_MS1_PIN #undef X_MS2_PIN #undef Y_MS1_PIN #undef Y_MS2_PIN #undef Z_MS1_PIN #undef Z_MS2_PIN #undef E0_MS1_PIN #undef E0_MS2_PIN #define X_MS1_PIN 25 #define X_MS2_PIN 26 #define Y_MS1_PIN 9 #define Y_MS2_PIN 8 #define Z_MS1_PIN 7 #define Z_MS2_PIN 6 #define E0_MS1_PIN 5 #define E0_MS2_PIN 4
1.046875
1
chapter1/1-18.c
gchaperon/the-c-programming-language
0
7998939
#include <stdio.h> #define MAXLINE 1000 int getline(char line[], int maxline); void copy(char to[], char from[]); int filter(char c); main() { int len, i; char line[MAXLINE]; while ((len = getline(line, MAXLINE)) > 0) { if (len == 1 && line[0] == '\n') continue; for (i = len-1; i>=0 && (line[i]==' ' || line[i]=='\t' || line[i]=='\n'); --i) ; printf("%.*s", i+1, line); if (line[len-1] == '\n') putchar('\n'); } return 0; } int filter(char c) { return c==' ' || c=='\t'; } int getline(char s[], int lim) { int c, i; for (i=0; i<lim-1 && (c = getchar())!=EOF && c!='\n'; ++i) s[i] = c; if (c == '\n') { s[i] = c; ++i; } s[i] = '\0'; return i; } void copy(char to[], char from[]) { int i; i = 0; while ((to[i] = from[i]) != '\0') ++i; }
2.015625
2
avr_code/hardware.h
qweqq/dwmb
2
7998947
#pragma once #define F_CPU 14745600ul #define BAUDRATE 115200 #define LCD_E_port PORTD #define LCD_E_pin 6 #define LCD_RS_port PORTD #define LCD_RS_pin 5 #define LCD_D4_port PORTD #define LCD_D4_pin 7 #define LCD_D5_port PORTB #define LCD_D5_pin 0 #define LCD_D6_port PORTB #define LCD_D6_pin 2 #define LCD_D7_port PORTB #define LCD_D7_pin 1 #define LCD_BACKLIGHT_port PORTD #define LCD_BACKLIGHT_pin 4 #define ADC_MULTIPLEXER_port PORTC #define ADC_MULTIPLEXER_shift 1 #define ADC_MULTIPLEXER_mask (7 << ADC_MULTIPLEXER_shift) #define LED_COUNTER_RESET_port PORTD #define LED_COUNTER_RESET_pin 2 #define LED_COUNTER_CLOCK_port PORTD #define LED_COUNTER_CLOCK_pin 3 #define LED_RED_ANODE_port PORTC #define LED_RED_ANODE_pin 4 #define LED_GREEN_ANODE_port PORTC #define LED_GREEN_ANODE_pin 5 #define BUTTON_INPUT_port PORTB #define BUTTON_INPUT_pin 5 // 1 - out, 0 - in v bits v // 76543210 #define DDRB_STATE 0b00000111 #define DDRC_STATE 0b00111110 #define DDRD_STATE 0b11111110
0.777344
1
phi_lib/phi_btn.c
eranrund/phi
6
7998955
#include "phi_lib/phi_btn.h" void phi_btn_init(phi_btn_t * btn) { memset(btn, 0, sizeof(*btn)); } void phi_btn_update_state(phi_btn_t * btn, systime_t now, bool is_pressed) { btn->cur_state = is_pressed; btn->cur_state_time = now; } void phi_btn_process(phi_btn_t * btns, uint8_t n_btns, phi_btn_event_callback_f callback, systime_t debounce, systime_t hold_threshold, systime_t hold_interval) { phi_btn_t * btn; int i; for (i = 0; i < n_btns; ++i) { btn = &(btns[i]); // Test for button pressed and store the down time if (btn->cur_state && !btn->is_pressed && (btn->cur_state_time - btn->last_released) > debounce) { btn->last_pressed = btn->cur_state_time; callback(i, PHI_BTN_EVENT_PRESSED, 0); } // Test for button release and store the up time if (!btn->cur_state && btn->is_pressed && (btn->cur_state_time - btn->last_pressed) > debounce) { callback(i, PHI_BTN_EVENT_RELEASED, btn->ignore_release ? 1 : 0); btn->last_released = btn->cur_state; btn->ignore_release = FALSE; } // Test for button held down for longer than the hold time if (btn->is_pressed && btn->cur_state && (btn->cur_state_time - btn->last_pressed) > hold_threshold) { if ((btn->cur_state_time - btn->last_held) > hold_interval) { callback(i, PHI_BTN_EVENT_HELD, ST2MS(btn->cur_state_time - btn->last_pressed)); btn->last_held = btn->cur_state_time; btn->ignore_release = TRUE; } } btn->is_pressed = btn->cur_state; } }
1.367188
1
Example/Pods/Target Support Files/ViewHider/ViewHider-umbrella.h
iThinker/ViewHider
0
7998963
FOUNDATION_EXPORT double ViewHiderVersionNumber; FOUNDATION_EXPORT const unsigned char ViewHiderVersionString[];
-0.294922
0
kernel/arch/arm64/include/asm/irq.h
tianhengZhang/rtochius
0
7998971
/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __ASM_IRQ_H_ #define __ASM_IRQ_H_ #ifndef __ASSEMBLER__ #include <asm-generic/irq.h> #endif /* !__ASSEMBLER__ */ #endif /* !__ASM_IRQ_H_ */
0.34375
0
test/bench-key-proc.c
michaelforney/libxkbcommon
1
7998979
/* * Copyright © 2012 <NAME> <<EMAIL>> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include <stdlib.h> #include <time.h> #include "test.h" #define BENCHMARK_ITERATIONS 20000000 static void bench(struct xkb_state *state) { int8_t keys[256] = { 0 }; xkb_keycode_t keycode; xkb_keysym_t keysym; int i; for (i = 0; i < BENCHMARK_ITERATIONS; i++) { keycode = (rand() % (255 - 9)) + 9; if (keys[keycode]) { xkb_state_update_key(state, keycode, XKB_KEY_UP); keys[keycode] = 0; keysym = xkb_state_key_get_one_sym(state, keycode); (void) keysym; } else { xkb_state_update_key(state, keycode, XKB_KEY_DOWN); keys[keycode] = 1; } } } int main(void) { struct xkb_context *ctx; struct xkb_keymap *keymap; struct xkb_state *state; struct timespec start, stop, elapsed; ctx = test_get_context(0); assert(ctx); keymap = test_compile_rules(ctx, "evdev", "pc104", "us,ru,il,de", ",,,neo", "grp:menu_toggle"); assert(keymap); state = xkb_state_new(keymap); assert(state); xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL); xkb_context_set_log_verbosity(ctx, 0); srand(time(NULL)); clock_gettime(CLOCK_MONOTONIC, &start); bench(state); clock_gettime(CLOCK_MONOTONIC, &stop); elapsed.tv_sec = stop.tv_sec - start.tv_sec; elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec; if (elapsed.tv_nsec < 0) { elapsed.tv_nsec += 1000000000; elapsed.tv_sec--; } fprintf(stderr, "ran %d iterations in %ld.%09lds\n", BENCHMARK_ITERATIONS, elapsed.tv_sec, elapsed.tv_nsec); xkb_state_unref(state); xkb_keymap_unref(keymap); xkb_context_unref(ctx); return 0; }
1.554688
2
usb/usb_composition_switch.c
paralin/platform_system_core
0
7998987
/* Copyright (c) 2013, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of The Linux Foundation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <errno.h> #include <unistd.h> #include <syslog.h> #include <string.h> #include <signal.h> #define COMMAND_SIZE sizeof("usb_composition 9060 n n y y") int main(int argc, char **argv) { /* Our process ID and Session ID */ pid_t pid, sid; char command[COMMAND_SIZE]; if (argc < 5) { exit(EXIT_FAILURE); } /* E.g. "usb_composition 9060 n n y n" to switch to composition 9060*/ snprintf(command, COMMAND_SIZE, "usb_composition %s %s %s y y", argv[1], argv[2], argv[3]); pid = fork(); if (pid < 0) { exit(EXIT_FAILURE); } /* Let parent process exit after disabling USB */ if (pid > 0) { system(command); exit(EXIT_SUCCESS); } if (pid == 0) { umask(0); sid = setsid(); if (sid < 0) { exit(EXIT_FAILURE); } if ((chdir("/")) < 0) { exit(EXIT_FAILURE); } close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); /* Let child process execute remaining usb_composition switch */ system(command); exit(EXIT_SUCCESS); } }
1.414063
1
src/wmecore/LightGizmo.h
retrowork/wme
0
7998995
// This file is part of Wintermute Engine // For conditions of distribution and use, see copyright notice in license.txt #ifndef __WmeLightGizmo_H__ #define __WmeLightGizmo_H__ #include "GizmoBase.h" namespace Wme { class LightEntity; class Viewport; class LightGizmo : public GizmoBase { public: LightGizmo(LightEntity* parentLight); virtual ~LightGizmo(); void Create(); void Destroy(); void PreRender(Viewport* viewport); Ogre::SceneNode* GetSceneNode() const { return m_SceneNode; } LightEntity* GetParentLight() const { return m_ParentLight; } Ogre::Entity* GetOgreEntity() const { return m_Entity; } private: LightEntity* m_ParentLight; Ogre::SceneNode* m_SceneNode; Ogre::Entity* m_Entity; }; } #endif // __WmeLightGizmo_H__
0.789063
1
test/UnitTest/generated/stubs/Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode.h
ConnectedVision/ConnectedVision
3
7999003
// auto-generated header by CodeFromTemplate // CodeFromTemplate Version: 0.3 alpha // // NEVER TOUCH this file! #ifndef Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode_def #define Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode_def #include <DataHandling/Store_Manager_Ringbuffer_Pool.h> // include class #include "../Class_UnitTest_GeneratorTestCode.h" // --> Do NOT EDIT <-- namespace ConnectedVision { namespace UnitTest { namespace DataHandling { // --> Do NOT EDIT <-- /** * stub class for: Store_Manager_Ringbuffer_UnitTest_GeneratorTestCode * * module: * description: test object to check generator */ class Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode : public ConnectedVision::DataHandling::Store_Manager_Ringbuffer_Pool<Class_UnitTest_GeneratorTestCode> { public: /** * constructor */ Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode( const int64_t storeCount, ///< [in] number of stores in manager const int64_t ringbufferSize, ///< [in] number of element slots in ringbuffer const int64_t poolSize ///< [in] total number of available objects (for all ring buffers) ); /* * virtual destructor */ virtual ~Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode(); private: // singleton in module scope Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode(const Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode &); // restrict copy constructor Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode & operator = (const Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode &); // restrict assign operator static int creationCount; }; } // namespace DataHandling } // namespace UnitTest } // namespace ConnectedVision #endif // Store_Manager_Ringbuffer_Stub_UnitTest_GeneratorTestCode_def
1.265625
1
3party/gtk+-3.12.1/gtk/gtktypebuiltins.c
kongaraju/antkorp
1
7999011
/* Generated data (by glib-mkenums) */ #include "config.h" #include "gtk.h" #include "gtkprivate.h" /* enumerations from "gtkaboutdialog.h" */ GType gtk_license_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_LICENSE_UNKNOWN, "GTK_LICENSE_UNKNOWN", "unknown" }, { GTK_LICENSE_CUSTOM, "GTK_LICENSE_CUSTOM", "custom" }, { GTK_LICENSE_GPL_2_0, "GTK_LICENSE_GPL_2_0", "gpl-2-0" }, { GTK_LICENSE_GPL_3_0, "GTK_LICENSE_GPL_3_0", "gpl-3-0" }, { GTK_LICENSE_LGPL_2_1, "GTK_LICENSE_LGPL_2_1", "lgpl-2-1" }, { GTK_LICENSE_LGPL_3_0, "GTK_LICENSE_LGPL_3_0", "lgpl-3-0" }, { GTK_LICENSE_BSD, "GTK_LICENSE_BSD", "bsd" }, { GTK_LICENSE_MIT_X11, "GTK_LICENSE_MIT_X11", "mit-x11" }, { GTK_LICENSE_ARTISTIC, "GTK_LICENSE_ARTISTIC", "artistic" }, { GTK_LICENSE_GPL_2_0_ONLY, "GTK_LICENSE_GPL_2_0_ONLY", "gpl-2-0-only" }, { GTK_LICENSE_GPL_3_0_ONLY, "GTK_LICENSE_GPL_3_0_ONLY", "gpl-3-0-only" }, { GTK_LICENSE_LGPL_2_1_ONLY, "GTK_LICENSE_LGPL_2_1_ONLY", "lgpl-2-1-only" }, { GTK_LICENSE_LGPL_3_0_ONLY, "GTK_LICENSE_LGPL_3_0_ONLY", "lgpl-3-0-only" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkLicense"), values); } return etype; } /* enumerations from "gtkaccelgroup.h" */ GType gtk_accel_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_ACCEL_VISIBLE, "GTK_ACCEL_VISIBLE", "visible" }, { GTK_ACCEL_LOCKED, "GTK_ACCEL_LOCKED", "locked" }, { GTK_ACCEL_MASK, "GTK_ACCEL_MASK", "mask" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkAccelFlags"), values); } return etype; } /* enumerations from "gtkapplication.h" */ GType gtk_application_inhibit_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_APPLICATION_INHIBIT_LOGOUT, "GTK_APPLICATION_INHIBIT_LOGOUT", "logout" }, { GTK_APPLICATION_INHIBIT_SWITCH, "GTK_APPLICATION_INHIBIT_SWITCH", "switch" }, { GTK_APPLICATION_INHIBIT_SUSPEND, "GTK_APPLICATION_INHIBIT_SUSPEND", "suspend" }, { GTK_APPLICATION_INHIBIT_IDLE, "GTK_APPLICATION_INHIBIT_IDLE", "idle" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkApplicationInhibitFlags"), values); } return etype; } /* enumerations from "gtkassistant.h" */ GType gtk_assistant_page_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ASSISTANT_PAGE_CONTENT, "GTK_ASSISTANT_PAGE_CONTENT", "content" }, { GTK_ASSISTANT_PAGE_INTRO, "GTK_ASSISTANT_PAGE_INTRO", "intro" }, { GTK_ASSISTANT_PAGE_CONFIRM, "GTK_ASSISTANT_PAGE_CONFIRM", "confirm" }, { GTK_ASSISTANT_PAGE_SUMMARY, "GTK_ASSISTANT_PAGE_SUMMARY", "summary" }, { GTK_ASSISTANT_PAGE_PROGRESS, "GTK_ASSISTANT_PAGE_PROGRESS", "progress" }, { GTK_ASSISTANT_PAGE_CUSTOM, "GTK_ASSISTANT_PAGE_CUSTOM", "custom" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkAssistantPageType"), values); } return etype; } /* enumerations from "gtkbuilder.h" */ GType gtk_builder_error_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION, "GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION", "invalid-type-function" }, { GTK_BUILDER_ERROR_UNHANDLED_TAG, "GTK_BUILDER_ERROR_UNHANDLED_TAG", "unhandled-tag" }, { GTK_BUILDER_ERROR_MISSING_ATTRIBUTE, "GTK_BUILDER_ERROR_MISSING_ATTRIBUTE", "missing-attribute" }, { GTK_BUILDER_ERROR_INVALID_ATTRIBUTE, "GTK_BUILDER_ERROR_INVALID_ATTRIBUTE", "invalid-attribute" }, { GTK_BUILDER_ERROR_INVALID_TAG, "GTK_BUILDER_ERROR_INVALID_TAG", "invalid-tag" }, { GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE, "GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE", "missing-property-value" }, { GTK_BUILDER_ERROR_INVALID_VALUE, "GTK_BUILDER_ERROR_INVALID_VALUE", "invalid-value" }, { GTK_BUILDER_ERROR_VERSION_MISMATCH, "GTK_BUILDER_ERROR_VERSION_MISMATCH", "version-mismatch" }, { GTK_BUILDER_ERROR_DUPLICATE_ID, "GTK_BUILDER_ERROR_DUPLICATE_ID", "duplicate-id" }, { GTK_BUILDER_ERROR_OBJECT_TYPE_REFUSED, "GTK_BUILDER_ERROR_OBJECT_TYPE_REFUSED", "object-type-refused" }, { GTK_BUILDER_ERROR_TEMPLATE_MISMATCH, "GTK_BUILDER_ERROR_TEMPLATE_MISMATCH", "template-mismatch" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkBuilderError"), values); } return etype; } /* enumerations from "gtkcalendar.h" */ GType gtk_calendar_display_options_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_CALENDAR_SHOW_HEADING, "GTK_CALENDAR_SHOW_HEADING", "show-heading" }, { GTK_CALENDAR_SHOW_DAY_NAMES, "GTK_CALENDAR_SHOW_DAY_NAMES", "show-day-names" }, { GTK_CALENDAR_NO_MONTH_CHANGE, "GTK_CALENDAR_NO_MONTH_CHANGE", "no-month-change" }, { GTK_CALENDAR_SHOW_WEEK_NUMBERS, "GTK_CALENDAR_SHOW_WEEK_NUMBERS", "show-week-numbers" }, { GTK_CALENDAR_SHOW_DETAILS, "GTK_CALENDAR_SHOW_DETAILS", "show-details" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkCalendarDisplayOptions"), values); } return etype; } /* enumerations from "gtkcellrenderer.h" */ GType gtk_cell_renderer_state_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_CELL_RENDERER_SELECTED, "GTK_CELL_RENDERER_SELECTED", "selected" }, { GTK_CELL_RENDERER_PRELIT, "GTK_CELL_RENDERER_PRELIT", "prelit" }, { GTK_CELL_RENDERER_INSENSITIVE, "GTK_CELL_RENDERER_INSENSITIVE", "insensitive" }, { GTK_CELL_RENDERER_SORTED, "GTK_CELL_RENDERER_SORTED", "sorted" }, { GTK_CELL_RENDERER_FOCUSED, "GTK_CELL_RENDERER_FOCUSED", "focused" }, { GTK_CELL_RENDERER_EXPANDABLE, "GTK_CELL_RENDERER_EXPANDABLE", "expandable" }, { GTK_CELL_RENDERER_EXPANDED, "GTK_CELL_RENDERER_EXPANDED", "expanded" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkCellRendererState"), values); } return etype; } GType gtk_cell_renderer_mode_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_CELL_RENDERER_MODE_INERT, "GTK_CELL_RENDERER_MODE_INERT", "inert" }, { GTK_CELL_RENDERER_MODE_ACTIVATABLE, "GTK_CELL_RENDERER_MODE_ACTIVATABLE", "activatable" }, { GTK_CELL_RENDERER_MODE_EDITABLE, "GTK_CELL_RENDERER_MODE_EDITABLE", "editable" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkCellRendererMode"), values); } return etype; } /* enumerations from "gtkcellrendereraccel.h" */ GType gtk_cell_renderer_accel_mode_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_CELL_RENDERER_ACCEL_MODE_GTK, "GTK_CELL_RENDERER_ACCEL_MODE_GTK", "gtk" }, { GTK_CELL_RENDERER_ACCEL_MODE_OTHER, "GTK_CELL_RENDERER_ACCEL_MODE_OTHER", "other" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkCellRendererAccelMode"), values); } return etype; } /* enumerations from "gtkcssprovider.h" */ GType gtk_css_provider_error_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_CSS_PROVIDER_ERROR_FAILED, "GTK_CSS_PROVIDER_ERROR_FAILED", "failed" }, { GTK_CSS_PROVIDER_ERROR_SYNTAX, "GTK_CSS_PROVIDER_ERROR_SYNTAX", "syntax" }, { GTK_CSS_PROVIDER_ERROR_IMPORT, "GTK_CSS_PROVIDER_ERROR_IMPORT", "import" }, { GTK_CSS_PROVIDER_ERROR_NAME, "GTK_CSS_PROVIDER_ERROR_NAME", "name" }, { GTK_CSS_PROVIDER_ERROR_DEPRECATED, "GTK_CSS_PROVIDER_ERROR_DEPRECATED", "deprecated" }, { GTK_CSS_PROVIDER_ERROR_UNKNOWN_VALUE, "GTK_CSS_PROVIDER_ERROR_UNKNOWN_VALUE", "unknown-value" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkCssProviderError"), values); } return etype; } /* enumerations from "gtkcsssection.h" */ GType gtk_css_section_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_CSS_SECTION_DOCUMENT, "GTK_CSS_SECTION_DOCUMENT", "document" }, { GTK_CSS_SECTION_IMPORT, "GTK_CSS_SECTION_IMPORT", "import" }, { GTK_CSS_SECTION_COLOR_DEFINITION, "GTK_CSS_SECTION_COLOR_DEFINITION", "color-definition" }, { GTK_CSS_SECTION_BINDING_SET, "GTK_CSS_SECTION_BINDING_SET", "binding-set" }, { GTK_CSS_SECTION_RULESET, "GTK_CSS_SECTION_RULESET", "ruleset" }, { GTK_CSS_SECTION_SELECTOR, "GTK_CSS_SECTION_SELECTOR", "selector" }, { GTK_CSS_SECTION_DECLARATION, "GTK_CSS_SECTION_DECLARATION", "declaration" }, { GTK_CSS_SECTION_VALUE, "GTK_CSS_SECTION_VALUE", "value" }, { GTK_CSS_SECTION_KEYFRAMES, "GTK_CSS_SECTION_KEYFRAMES", "keyframes" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkCssSectionType"), values); } return etype; } /* enumerations from "gtkdebug.h" */ GType gtk_debug_flag_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_DEBUG_MISC, "GTK_DEBUG_MISC", "misc" }, { GTK_DEBUG_PLUGSOCKET, "GTK_DEBUG_PLUGSOCKET", "plugsocket" }, { GTK_DEBUG_TEXT, "GTK_DEBUG_TEXT", "text" }, { GTK_DEBUG_TREE, "GTK_DEBUG_TREE", "tree" }, { GTK_DEBUG_UPDATES, "GTK_DEBUG_UPDATES", "updates" }, { GTK_DEBUG_KEYBINDINGS, "GTK_DEBUG_KEYBINDINGS", "keybindings" }, { GTK_DEBUG_MULTIHEAD, "GTK_DEBUG_MULTIHEAD", "multihead" }, { GTK_DEBUG_MODULES, "GTK_DEBUG_MODULES", "modules" }, { GTK_DEBUG_GEOMETRY, "GTK_DEBUG_GEOMETRY", "geometry" }, { GTK_DEBUG_ICONTHEME, "GTK_DEBUG_ICONTHEME", "icontheme" }, { GTK_DEBUG_PRINTING, "GTK_DEBUG_PRINTING", "printing" }, { GTK_DEBUG_BUILDER, "GTK_DEBUG_BUILDER", "builder" }, { GTK_DEBUG_SIZE_REQUEST, "GTK_DEBUG_SIZE_REQUEST", "size-request" }, { GTK_DEBUG_NO_CSS_CACHE, "GTK_DEBUG_NO_CSS_CACHE", "no-css-cache" }, { GTK_DEBUG_BASELINES, "GTK_DEBUG_BASELINES", "baselines" }, { GTK_DEBUG_PIXEL_CACHE, "GTK_DEBUG_PIXEL_CACHE", "pixel-cache" }, { GTK_DEBUG_NO_PIXEL_CACHE, "GTK_DEBUG_NO_PIXEL_CACHE", "no-pixel-cache" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkDebugFlag"), values); } return etype; } /* enumerations from "gtkdialog.h" */ GType gtk_dialog_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_DIALOG_MODAL, "GTK_DIALOG_MODAL", "modal" }, { GTK_DIALOG_DESTROY_WITH_PARENT, "GTK_DIALOG_DESTROY_WITH_PARENT", "destroy-with-parent" }, { GTK_DIALOG_USE_HEADER_BAR, "GTK_DIALOG_USE_HEADER_BAR", "use-header-bar" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkDialogFlags"), values); } return etype; } GType gtk_response_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_RESPONSE_NONE, "GTK_RESPONSE_NONE", "none" }, { GTK_RESPONSE_REJECT, "GTK_RESPONSE_REJECT", "reject" }, { GTK_RESPONSE_ACCEPT, "GTK_RESPONSE_ACCEPT", "accept" }, { GTK_RESPONSE_DELETE_EVENT, "GTK_RESPONSE_DELETE_EVENT", "delete-event" }, { GTK_RESPONSE_OK, "GTK_RESPONSE_OK", "ok" }, { GTK_RESPONSE_CANCEL, "GTK_RESPONSE_CANCEL", "cancel" }, { GTK_RESPONSE_CLOSE, "GTK_RESPONSE_CLOSE", "close" }, { GTK_RESPONSE_YES, "GTK_RESPONSE_YES", "yes" }, { GTK_RESPONSE_NO, "GTK_RESPONSE_NO", "no" }, { GTK_RESPONSE_APPLY, "GTK_RESPONSE_APPLY", "apply" }, { GTK_RESPONSE_HELP, "GTK_RESPONSE_HELP", "help" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkResponseType"), values); } return etype; } /* enumerations from "gtkdnd.h" */ GType gtk_dest_defaults_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_DEST_DEFAULT_MOTION, "GTK_DEST_DEFAULT_MOTION", "motion" }, { GTK_DEST_DEFAULT_HIGHLIGHT, "GTK_DEST_DEFAULT_HIGHLIGHT", "highlight" }, { GTK_DEST_DEFAULT_DROP, "GTK_DEST_DEFAULT_DROP", "drop" }, { GTK_DEST_DEFAULT_ALL, "GTK_DEST_DEFAULT_ALL", "all" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkDestDefaults"), values); } return etype; } GType gtk_target_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_TARGET_SAME_APP, "GTK_TARGET_SAME_APP", "same-app" }, { GTK_TARGET_SAME_WIDGET, "GTK_TARGET_SAME_WIDGET", "same-widget" }, { GTK_TARGET_OTHER_APP, "GTK_TARGET_OTHER_APP", "other-app" }, { GTK_TARGET_OTHER_WIDGET, "GTK_TARGET_OTHER_WIDGET", "other-widget" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkTargetFlags"), values); } return etype; } /* enumerations from "gtkentry.h" */ GType gtk_entry_icon_position_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ENTRY_ICON_PRIMARY, "GTK_ENTRY_ICON_PRIMARY", "primary" }, { GTK_ENTRY_ICON_SECONDARY, "GTK_ENTRY_ICON_SECONDARY", "secondary" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkEntryIconPosition"), values); } return etype; } /* enumerations from "gtkenums.h" */ GType gtk_align_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ALIGN_FILL, "GTK_ALIGN_FILL", "fill" }, { GTK_ALIGN_START, "GTK_ALIGN_START", "start" }, { GTK_ALIGN_END, "GTK_ALIGN_END", "end" }, { GTK_ALIGN_CENTER, "GTK_ALIGN_CENTER", "center" }, { GTK_ALIGN_BASELINE, "GTK_ALIGN_BASELINE", "baseline" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkAlign"), values); } return etype; } GType gtk_arrow_placement_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ARROWS_BOTH, "GTK_ARROWS_BOTH", "both" }, { GTK_ARROWS_START, "GTK_ARROWS_START", "start" }, { GTK_ARROWS_END, "GTK_ARROWS_END", "end" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkArrowPlacement"), values); } return etype; } GType gtk_arrow_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ARROW_UP, "GTK_ARROW_UP", "up" }, { GTK_ARROW_DOWN, "GTK_ARROW_DOWN", "down" }, { GTK_ARROW_LEFT, "GTK_ARROW_LEFT", "left" }, { GTK_ARROW_RIGHT, "GTK_ARROW_RIGHT", "right" }, { GTK_ARROW_NONE, "GTK_ARROW_NONE", "none" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkArrowType"), values); } return etype; } GType gtk_attach_options_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_EXPAND, "GTK_EXPAND", "expand" }, { GTK_SHRINK, "GTK_SHRINK", "shrink" }, { GTK_FILL, "GTK_FILL", "fill" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkAttachOptions"), values); } return etype; } GType gtk_baseline_position_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_BASELINE_POSITION_TOP, "GTK_BASELINE_POSITION_TOP", "top" }, { GTK_BASELINE_POSITION_CENTER, "GTK_BASELINE_POSITION_CENTER", "center" }, { GTK_BASELINE_POSITION_BOTTOM, "GTK_BASELINE_POSITION_BOTTOM", "bottom" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkBaselinePosition"), values); } return etype; } GType gtk_button_box_style_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_BUTTONBOX_SPREAD, "GTK_BUTTONBOX_SPREAD", "spread" }, { GTK_BUTTONBOX_EDGE, "GTK_BUTTONBOX_EDGE", "edge" }, { GTK_BUTTONBOX_START, "GTK_BUTTONBOX_START", "start" }, { GTK_BUTTONBOX_END, "GTK_BUTTONBOX_END", "end" }, { GTK_BUTTONBOX_CENTER, "GTK_BUTTONBOX_CENTER", "center" }, { GTK_BUTTONBOX_EXPAND, "GTK_BUTTONBOX_EXPAND", "expand" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkButtonBoxStyle"), values); } return etype; } GType gtk_delete_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_DELETE_CHARS, "GTK_DELETE_CHARS", "chars" }, { GTK_DELETE_WORD_ENDS, "GTK_DELETE_WORD_ENDS", "word-ends" }, { GTK_DELETE_WORDS, "GTK_DELETE_WORDS", "words" }, { GTK_DELETE_DISPLAY_LINES, "GTK_DELETE_DISPLAY_LINES", "display-lines" }, { GTK_DELETE_DISPLAY_LINE_ENDS, "GTK_DELETE_DISPLAY_LINE_ENDS", "display-line-ends" }, { GTK_DELETE_PARAGRAPH_ENDS, "GTK_DELETE_PARAGRAPH_ENDS", "paragraph-ends" }, { GTK_DELETE_PARAGRAPHS, "GTK_DELETE_PARAGRAPHS", "paragraphs" }, { GTK_DELETE_WHITESPACE, "GTK_DELETE_WHITESPACE", "whitespace" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkDeleteType"), values); } return etype; } GType gtk_direction_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_DIR_TAB_FORWARD, "GTK_DIR_TAB_FORWARD", "tab-forward" }, { GTK_DIR_TAB_BACKWARD, "GTK_DIR_TAB_BACKWARD", "tab-backward" }, { GTK_DIR_UP, "GTK_DIR_UP", "up" }, { GTK_DIR_DOWN, "GTK_DIR_DOWN", "down" }, { GTK_DIR_LEFT, "GTK_DIR_LEFT", "left" }, { GTK_DIR_RIGHT, "GTK_DIR_RIGHT", "right" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkDirectionType"), values); } return etype; } GType gtk_expander_style_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_EXPANDER_COLLAPSED, "GTK_EXPANDER_COLLAPSED", "collapsed" }, { GTK_EXPANDER_SEMI_COLLAPSED, "GTK_EXPANDER_SEMI_COLLAPSED", "semi-collapsed" }, { GTK_EXPANDER_SEMI_EXPANDED, "GTK_EXPANDER_SEMI_EXPANDED", "semi-expanded" }, { GTK_EXPANDER_EXPANDED, "GTK_EXPANDER_EXPANDED", "expanded" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkExpanderStyle"), values); } return etype; } GType gtk_icon_size_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ICON_SIZE_INVALID, "GTK_ICON_SIZE_INVALID", "invalid" }, { GTK_ICON_SIZE_MENU, "GTK_ICON_SIZE_MENU", "menu" }, { GTK_ICON_SIZE_SMALL_TOOLBAR, "GTK_ICON_SIZE_SMALL_TOOLBAR", "small-toolbar" }, { GTK_ICON_SIZE_LARGE_TOOLBAR, "GTK_ICON_SIZE_LARGE_TOOLBAR", "large-toolbar" }, { GTK_ICON_SIZE_BUTTON, "GTK_ICON_SIZE_BUTTON", "button" }, { GTK_ICON_SIZE_DND, "GTK_ICON_SIZE_DND", "dnd" }, { GTK_ICON_SIZE_DIALOG, "GTK_ICON_SIZE_DIALOG", "dialog" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkIconSize"), values); } return etype; } GType gtk_sensitivity_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SENSITIVITY_AUTO, "GTK_SENSITIVITY_AUTO", "auto" }, { GTK_SENSITIVITY_ON, "GTK_SENSITIVITY_ON", "on" }, { GTK_SENSITIVITY_OFF, "GTK_SENSITIVITY_OFF", "off" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkSensitivityType"), values); } return etype; } GType gtk_text_direction_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_TEXT_DIR_NONE, "GTK_TEXT_DIR_NONE", "none" }, { GTK_TEXT_DIR_LTR, "GTK_TEXT_DIR_LTR", "ltr" }, { GTK_TEXT_DIR_RTL, "GTK_TEXT_DIR_RTL", "rtl" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkTextDirection"), values); } return etype; } GType gtk_justification_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_JUSTIFY_LEFT, "GTK_JUSTIFY_LEFT", "left" }, { GTK_JUSTIFY_RIGHT, "GTK_JUSTIFY_RIGHT", "right" }, { GTK_JUSTIFY_CENTER, "GTK_JUSTIFY_CENTER", "center" }, { GTK_JUSTIFY_FILL, "GTK_JUSTIFY_FILL", "fill" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkJustification"), values); } return etype; } GType gtk_menu_direction_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_MENU_DIR_PARENT, "GTK_MENU_DIR_PARENT", "parent" }, { GTK_MENU_DIR_CHILD, "GTK_MENU_DIR_CHILD", "child" }, { GTK_MENU_DIR_NEXT, "GTK_MENU_DIR_NEXT", "next" }, { GTK_MENU_DIR_PREV, "GTK_MENU_DIR_PREV", "prev" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkMenuDirectionType"), values); } return etype; } GType gtk_message_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_MESSAGE_INFO, "GTK_MESSAGE_INFO", "info" }, { GTK_MESSAGE_WARNING, "GTK_MESSAGE_WARNING", "warning" }, { GTK_MESSAGE_QUESTION, "GTK_MESSAGE_QUESTION", "question" }, { GTK_MESSAGE_ERROR, "GTK_MESSAGE_ERROR", "error" }, { GTK_MESSAGE_OTHER, "GTK_MESSAGE_OTHER", "other" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkMessageType"), values); } return etype; } GType gtk_movement_step_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_MOVEMENT_LOGICAL_POSITIONS, "GTK_MOVEMENT_LOGICAL_POSITIONS", "logical-positions" }, { GTK_MOVEMENT_VISUAL_POSITIONS, "GTK_MOVEMENT_VISUAL_POSITIONS", "visual-positions" }, { GTK_MOVEMENT_WORDS, "GTK_MOVEMENT_WORDS", "words" }, { GTK_MOVEMENT_DISPLAY_LINES, "GTK_MOVEMENT_DISPLAY_LINES", "display-lines" }, { GTK_MOVEMENT_DISPLAY_LINE_ENDS, "GTK_MOVEMENT_DISPLAY_LINE_ENDS", "display-line-ends" }, { GTK_MOVEMENT_PARAGRAPHS, "GTK_MOVEMENT_PARAGRAPHS", "paragraphs" }, { GTK_MOVEMENT_PARAGRAPH_ENDS, "GTK_MOVEMENT_PARAGRAPH_ENDS", "paragraph-ends" }, { GTK_MOVEMENT_PAGES, "GTK_MOVEMENT_PAGES", "pages" }, { GTK_MOVEMENT_BUFFER_ENDS, "GTK_MOVEMENT_BUFFER_ENDS", "buffer-ends" }, { GTK_MOVEMENT_HORIZONTAL_PAGES, "GTK_MOVEMENT_HORIZONTAL_PAGES", "horizontal-pages" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkMovementStep"), values); } return etype; } GType gtk_scroll_step_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SCROLL_STEPS, "GTK_SCROLL_STEPS", "steps" }, { GTK_SCROLL_PAGES, "GTK_SCROLL_PAGES", "pages" }, { GTK_SCROLL_ENDS, "GTK_SCROLL_ENDS", "ends" }, { GTK_SCROLL_HORIZONTAL_STEPS, "GTK_SCROLL_HORIZONTAL_STEPS", "horizontal-steps" }, { GTK_SCROLL_HORIZONTAL_PAGES, "GTK_SCROLL_HORIZONTAL_PAGES", "horizontal-pages" }, { GTK_SCROLL_HORIZONTAL_ENDS, "GTK_SCROLL_HORIZONTAL_ENDS", "horizontal-ends" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkScrollStep"), values); } return etype; } GType gtk_orientation_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ORIENTATION_HORIZONTAL, "GTK_ORIENTATION_HORIZONTAL", "horizontal" }, { GTK_ORIENTATION_VERTICAL, "GTK_ORIENTATION_VERTICAL", "vertical" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkOrientation"), values); } return etype; } GType gtk_corner_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_CORNER_TOP_LEFT, "GTK_CORNER_TOP_LEFT", "top-left" }, { GTK_CORNER_BOTTOM_LEFT, "GTK_CORNER_BOTTOM_LEFT", "bottom-left" }, { GTK_CORNER_TOP_RIGHT, "GTK_CORNER_TOP_RIGHT", "top-right" }, { GTK_CORNER_BOTTOM_RIGHT, "GTK_CORNER_BOTTOM_RIGHT", "bottom-right" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkCornerType"), values); } return etype; } GType gtk_pack_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PACK_START, "GTK_PACK_START", "start" }, { GTK_PACK_END, "GTK_PACK_END", "end" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPackType"), values); } return etype; } GType gtk_path_priority_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PATH_PRIO_LOWEST, "GTK_PATH_PRIO_LOWEST", "lowest" }, { GTK_PATH_PRIO_GTK, "GTK_PATH_PRIO_GTK", "gtk" }, { GTK_PATH_PRIO_APPLICATION, "GTK_PATH_PRIO_APPLICATION", "application" }, { GTK_PATH_PRIO_THEME, "GTK_PATH_PRIO_THEME", "theme" }, { GTK_PATH_PRIO_RC, "GTK_PATH_PRIO_RC", "rc" }, { GTK_PATH_PRIO_HIGHEST, "GTK_PATH_PRIO_HIGHEST", "highest" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPathPriorityType"), values); } return etype; } GType gtk_path_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PATH_WIDGET, "GTK_PATH_WIDGET", "widget" }, { GTK_PATH_WIDGET_CLASS, "GTK_PATH_WIDGET_CLASS", "widget-class" }, { GTK_PATH_CLASS, "GTK_PATH_CLASS", "class" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPathType"), values); } return etype; } GType gtk_policy_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_POLICY_ALWAYS, "GTK_POLICY_ALWAYS", "always" }, { GTK_POLICY_AUTOMATIC, "GTK_POLICY_AUTOMATIC", "automatic" }, { GTK_POLICY_NEVER, "GTK_POLICY_NEVER", "never" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPolicyType"), values); } return etype; } GType gtk_position_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_POS_LEFT, "GTK_POS_LEFT", "left" }, { GTK_POS_RIGHT, "GTK_POS_RIGHT", "right" }, { GTK_POS_TOP, "GTK_POS_TOP", "top" }, { GTK_POS_BOTTOM, "GTK_POS_BOTTOM", "bottom" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPositionType"), values); } return etype; } GType gtk_relief_style_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_RELIEF_NORMAL, "GTK_RELIEF_NORMAL", "normal" }, { GTK_RELIEF_HALF, "GTK_RELIEF_HALF", "half" }, { GTK_RELIEF_NONE, "GTK_RELIEF_NONE", "none" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkReliefStyle"), values); } return etype; } GType gtk_resize_mode_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_RESIZE_PARENT, "GTK_RESIZE_PARENT", "parent" }, { GTK_RESIZE_QUEUE, "GTK_RESIZE_QUEUE", "queue" }, { GTK_RESIZE_IMMEDIATE, "GTK_RESIZE_IMMEDIATE", "immediate" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkResizeMode"), values); } return etype; } GType gtk_scroll_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SCROLL_NONE, "GTK_SCROLL_NONE", "none" }, { GTK_SCROLL_JUMP, "GTK_SCROLL_JUMP", "jump" }, { GTK_SCROLL_STEP_BACKWARD, "GTK_SCROLL_STEP_BACKWARD", "step-backward" }, { GTK_SCROLL_STEP_FORWARD, "GTK_SCROLL_STEP_FORWARD", "step-forward" }, { GTK_SCROLL_PAGE_BACKWARD, "GTK_SCROLL_PAGE_BACKWARD", "page-backward" }, { GTK_SCROLL_PAGE_FORWARD, "GTK_SCROLL_PAGE_FORWARD", "page-forward" }, { GTK_SCROLL_STEP_UP, "GTK_SCROLL_STEP_UP", "step-up" }, { GTK_SCROLL_STEP_DOWN, "GTK_SCROLL_STEP_DOWN", "step-down" }, { GTK_SCROLL_PAGE_UP, "GTK_SCROLL_PAGE_UP", "page-up" }, { GTK_SCROLL_PAGE_DOWN, "GTK_SCROLL_PAGE_DOWN", "page-down" }, { GTK_SCROLL_STEP_LEFT, "GTK_SCROLL_STEP_LEFT", "step-left" }, { GTK_SCROLL_STEP_RIGHT, "GTK_SCROLL_STEP_RIGHT", "step-right" }, { GTK_SCROLL_PAGE_LEFT, "GTK_SCROLL_PAGE_LEFT", "page-left" }, { GTK_SCROLL_PAGE_RIGHT, "GTK_SCROLL_PAGE_RIGHT", "page-right" }, { GTK_SCROLL_START, "GTK_SCROLL_START", "start" }, { GTK_SCROLL_END, "GTK_SCROLL_END", "end" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkScrollType"), values); } return etype; } GType gtk_selection_mode_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SELECTION_NONE, "GTK_SELECTION_NONE", "none" }, { GTK_SELECTION_SINGLE, "GTK_SELECTION_SINGLE", "single" }, { GTK_SELECTION_BROWSE, "GTK_SELECTION_BROWSE", "browse" }, { GTK_SELECTION_MULTIPLE, "GTK_SELECTION_MULTIPLE", "multiple" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkSelectionMode"), values); } return etype; } GType gtk_shadow_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SHADOW_NONE, "GTK_SHADOW_NONE", "none" }, { GTK_SHADOW_IN, "GTK_SHADOW_IN", "in" }, { GTK_SHADOW_OUT, "GTK_SHADOW_OUT", "out" }, { GTK_SHADOW_ETCHED_IN, "GTK_SHADOW_ETCHED_IN", "etched-in" }, { GTK_SHADOW_ETCHED_OUT, "GTK_SHADOW_ETCHED_OUT", "etched-out" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkShadowType"), values); } return etype; } GType gtk_state_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_STATE_NORMAL, "GTK_STATE_NORMAL", "normal" }, { GTK_STATE_ACTIVE, "GTK_STATE_ACTIVE", "active" }, { GTK_STATE_PRELIGHT, "GTK_STATE_PRELIGHT", "prelight" }, { GTK_STATE_SELECTED, "GTK_STATE_SELECTED", "selected" }, { GTK_STATE_INSENSITIVE, "GTK_STATE_INSENSITIVE", "insensitive" }, { GTK_STATE_INCONSISTENT, "GTK_STATE_INCONSISTENT", "inconsistent" }, { GTK_STATE_FOCUSED, "GTK_STATE_FOCUSED", "focused" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkStateType"), values); } return etype; } GType gtk_toolbar_style_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_TOOLBAR_ICONS, "GTK_TOOLBAR_ICONS", "icons" }, { GTK_TOOLBAR_TEXT, "GTK_TOOLBAR_TEXT", "text" }, { GTK_TOOLBAR_BOTH, "GTK_TOOLBAR_BOTH", "both" }, { GTK_TOOLBAR_BOTH_HORIZ, "GTK_TOOLBAR_BOTH_HORIZ", "both-horiz" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkToolbarStyle"), values); } return etype; } GType gtk_window_position_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_WIN_POS_NONE, "GTK_WIN_POS_NONE", "none" }, { GTK_WIN_POS_CENTER, "GTK_WIN_POS_CENTER", "center" }, { GTK_WIN_POS_MOUSE, "GTK_WIN_POS_MOUSE", "mouse" }, { GTK_WIN_POS_CENTER_ALWAYS, "GTK_WIN_POS_CENTER_ALWAYS", "center-always" }, { GTK_WIN_POS_CENTER_ON_PARENT, "GTK_WIN_POS_CENTER_ON_PARENT", "center-on-parent" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkWindowPosition"), values); } return etype; } GType gtk_window_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_WINDOW_TOPLEVEL, "GTK_WINDOW_TOPLEVEL", "toplevel" }, { GTK_WINDOW_POPUP, "GTK_WINDOW_POPUP", "popup" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkWindowType"), values); } return etype; } GType gtk_wrap_mode_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_WRAP_NONE, "GTK_WRAP_NONE", "none" }, { GTK_WRAP_CHAR, "GTK_WRAP_CHAR", "char" }, { GTK_WRAP_WORD, "GTK_WRAP_WORD", "word" }, { GTK_WRAP_WORD_CHAR, "GTK_WRAP_WORD_CHAR", "word-char" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkWrapMode"), values); } return etype; } GType gtk_sort_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SORT_ASCENDING, "GTK_SORT_ASCENDING", "ascending" }, { GTK_SORT_DESCENDING, "GTK_SORT_DESCENDING", "descending" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkSortType"), values); } return etype; } GType gtk_im_preedit_style_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_IM_PREEDIT_NOTHING, "GTK_IM_PREEDIT_NOTHING", "nothing" }, { GTK_IM_PREEDIT_CALLBACK, "GTK_IM_PREEDIT_CALLBACK", "callback" }, { GTK_IM_PREEDIT_NONE, "GTK_IM_PREEDIT_NONE", "none" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkIMPreeditStyle"), values); } return etype; } GType gtk_im_status_style_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_IM_STATUS_NOTHING, "GTK_IM_STATUS_NOTHING", "nothing" }, { GTK_IM_STATUS_CALLBACK, "GTK_IM_STATUS_CALLBACK", "callback" }, { GTK_IM_STATUS_NONE, "GTK_IM_STATUS_NONE", "none" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkIMStatusStyle"), values); } return etype; } GType gtk_pack_direction_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PACK_DIRECTION_LTR, "GTK_PACK_DIRECTION_LTR", "ltr" }, { GTK_PACK_DIRECTION_RTL, "GTK_PACK_DIRECTION_RTL", "rtl" }, { GTK_PACK_DIRECTION_TTB, "GTK_PACK_DIRECTION_TTB", "ttb" }, { GTK_PACK_DIRECTION_BTT, "GTK_PACK_DIRECTION_BTT", "btt" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPackDirection"), values); } return etype; } GType gtk_print_pages_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PRINT_PAGES_ALL, "GTK_PRINT_PAGES_ALL", "all" }, { GTK_PRINT_PAGES_CURRENT, "GTK_PRINT_PAGES_CURRENT", "current" }, { GTK_PRINT_PAGES_RANGES, "GTK_PRINT_PAGES_RANGES", "ranges" }, { GTK_PRINT_PAGES_SELECTION, "GTK_PRINT_PAGES_SELECTION", "selection" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPrintPages"), values); } return etype; } GType gtk_page_set_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PAGE_SET_ALL, "GTK_PAGE_SET_ALL", "all" }, { GTK_PAGE_SET_EVEN, "GTK_PAGE_SET_EVEN", "even" }, { GTK_PAGE_SET_ODD, "GTK_PAGE_SET_ODD", "odd" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPageSet"), values); } return etype; } GType gtk_number_up_layout_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM, "GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM", "lrtb" }, { GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP, "GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP", "lrbt" }, { GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM, "GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM", "rltb" }, { GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP, "GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP", "rlbt" }, { GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT, "GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT", "tblr" }, { GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT, "GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT", "tbrl" }, { GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT, "GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT", "btlr" }, { GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT, "GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT", "btrl" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkNumberUpLayout"), values); } return etype; } GType gtk_page_orientation_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PAGE_ORIENTATION_PORTRAIT, "GTK_PAGE_ORIENTATION_PORTRAIT", "portrait" }, { GTK_PAGE_ORIENTATION_LANDSCAPE, "GTK_PAGE_ORIENTATION_LANDSCAPE", "landscape" }, { GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT, "GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT", "reverse-portrait" }, { GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE, "GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE", "reverse-landscape" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPageOrientation"), values); } return etype; } GType gtk_print_quality_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PRINT_QUALITY_LOW, "GTK_PRINT_QUALITY_LOW", "low" }, { GTK_PRINT_QUALITY_NORMAL, "GTK_PRINT_QUALITY_NORMAL", "normal" }, { GTK_PRINT_QUALITY_HIGH, "GTK_PRINT_QUALITY_HIGH", "high" }, { GTK_PRINT_QUALITY_DRAFT, "GTK_PRINT_QUALITY_DRAFT", "draft" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPrintQuality"), values); } return etype; } GType gtk_print_duplex_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PRINT_DUPLEX_SIMPLEX, "GTK_PRINT_DUPLEX_SIMPLEX", "simplex" }, { GTK_PRINT_DUPLEX_HORIZONTAL, "GTK_PRINT_DUPLEX_HORIZONTAL", "horizontal" }, { GTK_PRINT_DUPLEX_VERTICAL, "GTK_PRINT_DUPLEX_VERTICAL", "vertical" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPrintDuplex"), values); } return etype; } GType gtk_unit_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_UNIT_NONE, "GTK_UNIT_NONE", "none" }, { GTK_UNIT_POINTS, "GTK_UNIT_POINTS", "points" }, { GTK_UNIT_INCH, "GTK_UNIT_INCH", "inch" }, { GTK_UNIT_MM, "GTK_UNIT_MM", "mm" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkUnit"), values); } return etype; } GType gtk_tree_view_grid_lines_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_TREE_VIEW_GRID_LINES_NONE, "GTK_TREE_VIEW_GRID_LINES_NONE", "none" }, { GTK_TREE_VIEW_GRID_LINES_HORIZONTAL, "GTK_TREE_VIEW_GRID_LINES_HORIZONTAL", "horizontal" }, { GTK_TREE_VIEW_GRID_LINES_VERTICAL, "GTK_TREE_VIEW_GRID_LINES_VERTICAL", "vertical" }, { GTK_TREE_VIEW_GRID_LINES_BOTH, "GTK_TREE_VIEW_GRID_LINES_BOTH", "both" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkTreeViewGridLines"), values); } return etype; } GType gtk_drag_result_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_DRAG_RESULT_SUCCESS, "GTK_DRAG_RESULT_SUCCESS", "success" }, { GTK_DRAG_RESULT_NO_TARGET, "GTK_DRAG_RESULT_NO_TARGET", "no-target" }, { GTK_DRAG_RESULT_USER_CANCELLED, "GTK_DRAG_RESULT_USER_CANCELLED", "user-cancelled" }, { GTK_DRAG_RESULT_TIMEOUT_EXPIRED, "GTK_DRAG_RESULT_TIMEOUT_EXPIRED", "timeout-expired" }, { GTK_DRAG_RESULT_GRAB_BROKEN, "GTK_DRAG_RESULT_GRAB_BROKEN", "grab-broken" }, { GTK_DRAG_RESULT_ERROR, "GTK_DRAG_RESULT_ERROR", "error" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkDragResult"), values); } return etype; } GType gtk_size_group_mode_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SIZE_GROUP_NONE, "GTK_SIZE_GROUP_NONE", "none" }, { GTK_SIZE_GROUP_HORIZONTAL, "GTK_SIZE_GROUP_HORIZONTAL", "horizontal" }, { GTK_SIZE_GROUP_VERTICAL, "GTK_SIZE_GROUP_VERTICAL", "vertical" }, { GTK_SIZE_GROUP_BOTH, "GTK_SIZE_GROUP_BOTH", "both" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkSizeGroupMode"), values); } return etype; } GType gtk_size_request_mode_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH, "GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH", "height-for-width" }, { GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT, "GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT", "width-for-height" }, { GTK_SIZE_REQUEST_CONSTANT_SIZE, "GTK_SIZE_REQUEST_CONSTANT_SIZE", "constant-size" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkSizeRequestMode"), values); } return etype; } GType gtk_scrollable_policy_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SCROLL_MINIMUM, "GTK_SCROLL_MINIMUM", "minimum" }, { GTK_SCROLL_NATURAL, "GTK_SCROLL_NATURAL", "natural" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkScrollablePolicy"), values); } return etype; } GType gtk_state_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_STATE_FLAG_NORMAL, "GTK_STATE_FLAG_NORMAL", "normal" }, { GTK_STATE_FLAG_ACTIVE, "GTK_STATE_FLAG_ACTIVE", "active" }, { GTK_STATE_FLAG_PRELIGHT, "GTK_STATE_FLAG_PRELIGHT", "prelight" }, { GTK_STATE_FLAG_SELECTED, "GTK_STATE_FLAG_SELECTED", "selected" }, { GTK_STATE_FLAG_INSENSITIVE, "GTK_STATE_FLAG_INSENSITIVE", "insensitive" }, { GTK_STATE_FLAG_INCONSISTENT, "GTK_STATE_FLAG_INCONSISTENT", "inconsistent" }, { GTK_STATE_FLAG_FOCUSED, "GTK_STATE_FLAG_FOCUSED", "focused" }, { GTK_STATE_FLAG_BACKDROP, "GTK_STATE_FLAG_BACKDROP", "backdrop" }, { GTK_STATE_FLAG_DIR_LTR, "GTK_STATE_FLAG_DIR_LTR", "dir-ltr" }, { GTK_STATE_FLAG_DIR_RTL, "GTK_STATE_FLAG_DIR_RTL", "dir-rtl" }, { GTK_STATE_FLAG_LINK, "GTK_STATE_FLAG_LINK", "link" }, { GTK_STATE_FLAG_VISITED, "GTK_STATE_FLAG_VISITED", "visited" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkStateFlags"), values); } return etype; } GType gtk_region_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_REGION_EVEN, "GTK_REGION_EVEN", "even" }, { GTK_REGION_ODD, "GTK_REGION_ODD", "odd" }, { GTK_REGION_FIRST, "GTK_REGION_FIRST", "first" }, { GTK_REGION_LAST, "GTK_REGION_LAST", "last" }, { GTK_REGION_ONLY, "GTK_REGION_ONLY", "only" }, { GTK_REGION_SORTED, "GTK_REGION_SORTED", "sorted" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkRegionFlags"), values); } return etype; } GType gtk_junction_sides_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_JUNCTION_NONE, "GTK_JUNCTION_NONE", "none" }, { GTK_JUNCTION_CORNER_TOPLEFT, "GTK_JUNCTION_CORNER_TOPLEFT", "corner-topleft" }, { GTK_JUNCTION_CORNER_TOPRIGHT, "GTK_JUNCTION_CORNER_TOPRIGHT", "corner-topright" }, { GTK_JUNCTION_CORNER_BOTTOMLEFT, "GTK_JUNCTION_CORNER_BOTTOMLEFT", "corner-bottomleft" }, { GTK_JUNCTION_CORNER_BOTTOMRIGHT, "GTK_JUNCTION_CORNER_BOTTOMRIGHT", "corner-bottomright" }, { GTK_JUNCTION_TOP, "GTK_JUNCTION_TOP", "top" }, { GTK_JUNCTION_BOTTOM, "GTK_JUNCTION_BOTTOM", "bottom" }, { GTK_JUNCTION_LEFT, "GTK_JUNCTION_LEFT", "left" }, { GTK_JUNCTION_RIGHT, "GTK_JUNCTION_RIGHT", "right" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkJunctionSides"), values); } return etype; } GType gtk_border_style_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_BORDER_STYLE_NONE, "GTK_BORDER_STYLE_NONE", "none" }, { GTK_BORDER_STYLE_SOLID, "GTK_BORDER_STYLE_SOLID", "solid" }, { GTK_BORDER_STYLE_INSET, "GTK_BORDER_STYLE_INSET", "inset" }, { GTK_BORDER_STYLE_OUTSET, "GTK_BORDER_STYLE_OUTSET", "outset" }, { GTK_BORDER_STYLE_HIDDEN, "GTK_BORDER_STYLE_HIDDEN", "hidden" }, { GTK_BORDER_STYLE_DOTTED, "GTK_BORDER_STYLE_DOTTED", "dotted" }, { GTK_BORDER_STYLE_DASHED, "GTK_BORDER_STYLE_DASHED", "dashed" }, { GTK_BORDER_STYLE_DOUBLE, "GTK_BORDER_STYLE_DOUBLE", "double" }, { GTK_BORDER_STYLE_GROOVE, "GTK_BORDER_STYLE_GROOVE", "groove" }, { GTK_BORDER_STYLE_RIDGE, "GTK_BORDER_STYLE_RIDGE", "ridge" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkBorderStyle"), values); } return etype; } GType gtk_level_bar_mode_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_LEVEL_BAR_MODE_CONTINUOUS, "GTK_LEVEL_BAR_MODE_CONTINUOUS", "continuous" }, { GTK_LEVEL_BAR_MODE_DISCRETE, "GTK_LEVEL_BAR_MODE_DISCRETE", "discrete" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkLevelBarMode"), values); } return etype; } GType gtk_input_purpose_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_INPUT_PURPOSE_FREE_FORM, "GTK_INPUT_PURPOSE_FREE_FORM", "free-form" }, { GTK_INPUT_PURPOSE_ALPHA, "GTK_INPUT_PURPOSE_ALPHA", "alpha" }, { GTK_INPUT_PURPOSE_DIGITS, "GTK_INPUT_PURPOSE_DIGITS", "digits" }, { GTK_INPUT_PURPOSE_NUMBER, "GTK_INPUT_PURPOSE_NUMBER", "number" }, { GTK_INPUT_PURPOSE_PHONE, "GTK_INPUT_PURPOSE_PHONE", "phone" }, { GTK_INPUT_PURPOSE_URL, "GTK_INPUT_PURPOSE_URL", "url" }, { GTK_INPUT_PURPOSE_EMAIL, "GTK_INPUT_PURPOSE_EMAIL", "email" }, { GTK_INPUT_PURPOSE_NAME, "GTK_INPUT_PURPOSE_NAME", "name" }, { GTK_INPUT_PURPOSE_PASSWORD, "GTK_INPUT_PURPOSE_PASSWORD", "password" }, { GTK_INPUT_PURPOSE_PIN, "GTK_INPUT_PURPOSE_PIN", "pin" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkInputPurpose"), values); } return etype; } GType gtk_input_hints_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_INPUT_HINT_NONE, "GTK_INPUT_HINT_NONE", "none" }, { GTK_INPUT_HINT_SPELLCHECK, "GTK_INPUT_HINT_SPELLCHECK", "spellcheck" }, { GTK_INPUT_HINT_NO_SPELLCHECK, "GTK_INPUT_HINT_NO_SPELLCHECK", "no-spellcheck" }, { GTK_INPUT_HINT_WORD_COMPLETION, "GTK_INPUT_HINT_WORD_COMPLETION", "word-completion" }, { GTK_INPUT_HINT_LOWERCASE, "GTK_INPUT_HINT_LOWERCASE", "lowercase" }, { GTK_INPUT_HINT_UPPERCASE_CHARS, "GTK_INPUT_HINT_UPPERCASE_CHARS", "uppercase-chars" }, { GTK_INPUT_HINT_UPPERCASE_WORDS, "GTK_INPUT_HINT_UPPERCASE_WORDS", "uppercase-words" }, { GTK_INPUT_HINT_UPPERCASE_SENTENCES, "GTK_INPUT_HINT_UPPERCASE_SENTENCES", "uppercase-sentences" }, { GTK_INPUT_HINT_INHIBIT_OSK, "GTK_INPUT_HINT_INHIBIT_OSK", "inhibit-osk" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkInputHints"), values); } return etype; } /* enumerations from "gtkfilechooser.h" */ GType gtk_file_chooser_action_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_FILE_CHOOSER_ACTION_OPEN, "GTK_FILE_CHOOSER_ACTION_OPEN", "open" }, { GTK_FILE_CHOOSER_ACTION_SAVE, "GTK_FILE_CHOOSER_ACTION_SAVE", "save" }, { GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER", "select-folder" }, { GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, "GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER", "create-folder" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkFileChooserAction"), values); } return etype; } GType gtk_file_chooser_confirmation_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM, "GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM", "confirm" }, { GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME, "GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME", "accept-filename" }, { GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN, "GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN", "select-again" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkFileChooserConfirmation"), values); } return etype; } GType gtk_file_chooser_error_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_FILE_CHOOSER_ERROR_NONEXISTENT, "GTK_FILE_CHOOSER_ERROR_NONEXISTENT", "nonexistent" }, { GTK_FILE_CHOOSER_ERROR_BAD_FILENAME, "GTK_FILE_CHOOSER_ERROR_BAD_FILENAME", "bad-filename" }, { GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS, "GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS", "already-exists" }, { GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME, "GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME", "incomplete-hostname" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkFileChooserError"), values); } return etype; } /* enumerations from "gtkfilefilter.h" */ GType gtk_file_filter_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_FILE_FILTER_FILENAME, "GTK_FILE_FILTER_FILENAME", "filename" }, { GTK_FILE_FILTER_URI, "GTK_FILE_FILTER_URI", "uri" }, { GTK_FILE_FILTER_DISPLAY_NAME, "GTK_FILE_FILTER_DISPLAY_NAME", "display-name" }, { GTK_FILE_FILTER_MIME_TYPE, "GTK_FILE_FILTER_MIME_TYPE", "mime-type" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkFileFilterFlags"), values); } return etype; } /* enumerations from "gtkicontheme.h" */ GType gtk_icon_lookup_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_ICON_LOOKUP_NO_SVG, "GTK_ICON_LOOKUP_NO_SVG", "no-svg" }, { GTK_ICON_LOOKUP_FORCE_SVG, "GTK_ICON_LOOKUP_FORCE_SVG", "force-svg" }, { GTK_ICON_LOOKUP_USE_BUILTIN, "GTK_ICON_LOOKUP_USE_BUILTIN", "use-builtin" }, { GTK_ICON_LOOKUP_GENERIC_FALLBACK, "GTK_ICON_LOOKUP_GENERIC_FALLBACK", "generic-fallback" }, { GTK_ICON_LOOKUP_FORCE_SIZE, "GTK_ICON_LOOKUP_FORCE_SIZE", "force-size" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkIconLookupFlags"), values); } return etype; } GType gtk_icon_theme_error_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ICON_THEME_NOT_FOUND, "GTK_ICON_THEME_NOT_FOUND", "not-found" }, { GTK_ICON_THEME_FAILED, "GTK_ICON_THEME_FAILED", "failed" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkIconThemeError"), values); } return etype; } /* enumerations from "gtkiconview.h" */ GType gtk_icon_view_drop_position_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_ICON_VIEW_NO_DROP, "GTK_ICON_VIEW_NO_DROP", "no-drop" }, { GTK_ICON_VIEW_DROP_INTO, "GTK_ICON_VIEW_DROP_INTO", "drop-into" }, { GTK_ICON_VIEW_DROP_LEFT, "GTK_ICON_VIEW_DROP_LEFT", "drop-left" }, { GTK_ICON_VIEW_DROP_RIGHT, "GTK_ICON_VIEW_DROP_RIGHT", "drop-right" }, { GTK_ICON_VIEW_DROP_ABOVE, "GTK_ICON_VIEW_DROP_ABOVE", "drop-above" }, { GTK_ICON_VIEW_DROP_BELOW, "GTK_ICON_VIEW_DROP_BELOW", "drop-below" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkIconViewDropPosition"), values); } return etype; } /* enumerations from "gtkimage.h" */ GType gtk_image_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_IMAGE_EMPTY, "GTK_IMAGE_EMPTY", "empty" }, { GTK_IMAGE_PIXBUF, "GTK_IMAGE_PIXBUF", "pixbuf" }, { GTK_IMAGE_STOCK, "GTK_IMAGE_STOCK", "stock" }, { GTK_IMAGE_ICON_SET, "GTK_IMAGE_ICON_SET", "icon-set" }, { GTK_IMAGE_ANIMATION, "GTK_IMAGE_ANIMATION", "animation" }, { GTK_IMAGE_ICON_NAME, "GTK_IMAGE_ICON_NAME", "icon-name" }, { GTK_IMAGE_GICON, "GTK_IMAGE_GICON", "gicon" }, { GTK_IMAGE_SURFACE, "GTK_IMAGE_SURFACE", "surface" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkImageType"), values); } return etype; } /* enumerations from "gtkmessagedialog.h" */ GType gtk_buttons_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_BUTTONS_NONE, "GTK_BUTTONS_NONE", "none" }, { GTK_BUTTONS_OK, "GTK_BUTTONS_OK", "ok" }, { GTK_BUTTONS_CLOSE, "GTK_BUTTONS_CLOSE", "close" }, { GTK_BUTTONS_CANCEL, "GTK_BUTTONS_CANCEL", "cancel" }, { GTK_BUTTONS_YES_NO, "GTK_BUTTONS_YES_NO", "yes-no" }, { GTK_BUTTONS_OK_CANCEL, "GTK_BUTTONS_OK_CANCEL", "ok-cancel" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkButtonsType"), values); } return etype; } /* enumerations from "gtknotebook.h" */ GType gtk_notebook_tab_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_NOTEBOOK_TAB_FIRST, "GTK_NOTEBOOK_TAB_FIRST", "first" }, { GTK_NOTEBOOK_TAB_LAST, "GTK_NOTEBOOK_TAB_LAST", "last" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkNotebookTab"), values); } return etype; } /* enumerations from "gtkplacessidebar.h" */ GType gtk_places_open_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_PLACES_OPEN_NORMAL, "GTK_PLACES_OPEN_NORMAL", "normal" }, { GTK_PLACES_OPEN_NEW_TAB, "GTK_PLACES_OPEN_NEW_TAB", "new-tab" }, { GTK_PLACES_OPEN_NEW_WINDOW, "GTK_PLACES_OPEN_NEW_WINDOW", "new-window" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkPlacesOpenFlags"), values); } return etype; } /* enumerations from "gtkprintoperation.h" */ GType gtk_print_status_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PRINT_STATUS_INITIAL, "GTK_PRINT_STATUS_INITIAL", "initial" }, { GTK_PRINT_STATUS_PREPARING, "GTK_PRINT_STATUS_PREPARING", "preparing" }, { GTK_PRINT_STATUS_GENERATING_DATA, "GTK_PRINT_STATUS_GENERATING_DATA", "generating-data" }, { GTK_PRINT_STATUS_SENDING_DATA, "GTK_PRINT_STATUS_SENDING_DATA", "sending-data" }, { GTK_PRINT_STATUS_PENDING, "GTK_PRINT_STATUS_PENDING", "pending" }, { GTK_PRINT_STATUS_PENDING_ISSUE, "GTK_PRINT_STATUS_PENDING_ISSUE", "pending-issue" }, { GTK_PRINT_STATUS_PRINTING, "GTK_PRINT_STATUS_PRINTING", "printing" }, { GTK_PRINT_STATUS_FINISHED, "GTK_PRINT_STATUS_FINISHED", "finished" }, { GTK_PRINT_STATUS_FINISHED_ABORTED, "GTK_PRINT_STATUS_FINISHED_ABORTED", "finished-aborted" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPrintStatus"), values); } return etype; } GType gtk_print_operation_result_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PRINT_OPERATION_RESULT_ERROR, "GTK_PRINT_OPERATION_RESULT_ERROR", "error" }, { GTK_PRINT_OPERATION_RESULT_APPLY, "GTK_PRINT_OPERATION_RESULT_APPLY", "apply" }, { GTK_PRINT_OPERATION_RESULT_CANCEL, "GTK_PRINT_OPERATION_RESULT_CANCEL", "cancel" }, { GTK_PRINT_OPERATION_RESULT_IN_PROGRESS, "GTK_PRINT_OPERATION_RESULT_IN_PROGRESS", "in-progress" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPrintOperationResult"), values); } return etype; } GType gtk_print_operation_action_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, "GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG", "print-dialog" }, { GTK_PRINT_OPERATION_ACTION_PRINT, "GTK_PRINT_OPERATION_ACTION_PRINT", "print" }, { GTK_PRINT_OPERATION_ACTION_PREVIEW, "GTK_PRINT_OPERATION_ACTION_PREVIEW", "preview" }, { GTK_PRINT_OPERATION_ACTION_EXPORT, "GTK_PRINT_OPERATION_ACTION_EXPORT", "export" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPrintOperationAction"), values); } return etype; } GType gtk_print_error_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_PRINT_ERROR_GENERAL, "GTK_PRINT_ERROR_GENERAL", "general" }, { GTK_PRINT_ERROR_INTERNAL_ERROR, "GTK_PRINT_ERROR_INTERNAL_ERROR", "internal-error" }, { GTK_PRINT_ERROR_NOMEM, "GTK_PRINT_ERROR_NOMEM", "nomem" }, { GTK_PRINT_ERROR_INVALID_FILE, "GTK_PRINT_ERROR_INVALID_FILE", "invalid-file" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkPrintError"), values); } return etype; } /* enumerations from "gtkrecentchooser.h" */ GType gtk_recent_sort_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_RECENT_SORT_NONE, "GTK_RECENT_SORT_NONE", "none" }, { GTK_RECENT_SORT_MRU, "GTK_RECENT_SORT_MRU", "mru" }, { GTK_RECENT_SORT_LRU, "GTK_RECENT_SORT_LRU", "lru" }, { GTK_RECENT_SORT_CUSTOM, "GTK_RECENT_SORT_CUSTOM", "custom" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkRecentSortType"), values); } return etype; } GType gtk_recent_chooser_error_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_RECENT_CHOOSER_ERROR_NOT_FOUND, "GTK_RECENT_CHOOSER_ERROR_NOT_FOUND", "not-found" }, { GTK_RECENT_CHOOSER_ERROR_INVALID_URI, "GTK_RECENT_CHOOSER_ERROR_INVALID_URI", "invalid-uri" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkRecentChooserError"), values); } return etype; } /* enumerations from "gtkrecentfilter.h" */ GType gtk_recent_filter_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_RECENT_FILTER_URI, "GTK_RECENT_FILTER_URI", "uri" }, { GTK_RECENT_FILTER_DISPLAY_NAME, "GTK_RECENT_FILTER_DISPLAY_NAME", "display-name" }, { GTK_RECENT_FILTER_MIME_TYPE, "GTK_RECENT_FILTER_MIME_TYPE", "mime-type" }, { GTK_RECENT_FILTER_APPLICATION, "GTK_RECENT_FILTER_APPLICATION", "application" }, { GTK_RECENT_FILTER_GROUP, "GTK_RECENT_FILTER_GROUP", "group" }, { GTK_RECENT_FILTER_AGE, "GTK_RECENT_FILTER_AGE", "age" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkRecentFilterFlags"), values); } return etype; } /* enumerations from "gtkrecentmanager.h" */ GType gtk_recent_manager_error_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_RECENT_MANAGER_ERROR_NOT_FOUND, "GTK_RECENT_MANAGER_ERROR_NOT_FOUND", "not-found" }, { GTK_RECENT_MANAGER_ERROR_INVALID_URI, "GTK_RECENT_MANAGER_ERROR_INVALID_URI", "invalid-uri" }, { GTK_RECENT_MANAGER_ERROR_INVALID_ENCODING, "GTK_RECENT_MANAGER_ERROR_INVALID_ENCODING", "invalid-encoding" }, { GTK_RECENT_MANAGER_ERROR_NOT_REGISTERED, "GTK_RECENT_MANAGER_ERROR_NOT_REGISTERED", "not-registered" }, { GTK_RECENT_MANAGER_ERROR_READ, "GTK_RECENT_MANAGER_ERROR_READ", "read" }, { GTK_RECENT_MANAGER_ERROR_WRITE, "GTK_RECENT_MANAGER_ERROR_WRITE", "write" }, { GTK_RECENT_MANAGER_ERROR_UNKNOWN, "GTK_RECENT_MANAGER_ERROR_UNKNOWN", "unknown" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkRecentManagerError"), values); } return etype; } /* enumerations from "gtkrevealer.h" */ GType gtk_revealer_transition_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_REVEALER_TRANSITION_TYPE_NONE, "GTK_REVEALER_TRANSITION_TYPE_NONE", "none" }, { GTK_REVEALER_TRANSITION_TYPE_CROSSFADE, "GTK_REVEALER_TRANSITION_TYPE_CROSSFADE", "crossfade" }, { GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT, "GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT", "slide-right" }, { GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT, "GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT", "slide-left" }, { GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP, "GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP", "slide-up" }, { GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN, "GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN", "slide-down" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkRevealerTransitionType"), values); } return etype; } /* enumerations from "gtkspinbutton.h" */ GType gtk_spin_button_update_policy_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_UPDATE_ALWAYS, "GTK_UPDATE_ALWAYS", "always" }, { GTK_UPDATE_IF_VALID, "GTK_UPDATE_IF_VALID", "if-valid" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkSpinButtonUpdatePolicy"), values); } return etype; } GType gtk_spin_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_SPIN_STEP_FORWARD, "GTK_SPIN_STEP_FORWARD", "step-forward" }, { GTK_SPIN_STEP_BACKWARD, "GTK_SPIN_STEP_BACKWARD", "step-backward" }, { GTK_SPIN_PAGE_FORWARD, "GTK_SPIN_PAGE_FORWARD", "page-forward" }, { GTK_SPIN_PAGE_BACKWARD, "GTK_SPIN_PAGE_BACKWARD", "page-backward" }, { GTK_SPIN_HOME, "GTK_SPIN_HOME", "home" }, { GTK_SPIN_END, "GTK_SPIN_END", "end" }, { GTK_SPIN_USER_DEFINED, "GTK_SPIN_USER_DEFINED", "user-defined" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkSpinType"), values); } return etype; } /* enumerations from "gtkstack.h" */ GType gtk_stack_transition_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_STACK_TRANSITION_TYPE_NONE, "GTK_STACK_TRANSITION_TYPE_NONE", "none" }, { GTK_STACK_TRANSITION_TYPE_CROSSFADE, "GTK_STACK_TRANSITION_TYPE_CROSSFADE", "crossfade" }, { GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT, "GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT", "slide-right" }, { GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT, "GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT", "slide-left" }, { GTK_STACK_TRANSITION_TYPE_SLIDE_UP, "GTK_STACK_TRANSITION_TYPE_SLIDE_UP", "slide-up" }, { GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN, "GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN", "slide-down" }, { GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT, "GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT", "slide-left-right" }, { GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN, "GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN", "slide-up-down" }, { GTK_STACK_TRANSITION_TYPE_OVER_UP, "GTK_STACK_TRANSITION_TYPE_OVER_UP", "over-up" }, { GTK_STACK_TRANSITION_TYPE_OVER_DOWN, "GTK_STACK_TRANSITION_TYPE_OVER_DOWN", "over-down" }, { GTK_STACK_TRANSITION_TYPE_OVER_LEFT, "GTK_STACK_TRANSITION_TYPE_OVER_LEFT", "over-left" }, { GTK_STACK_TRANSITION_TYPE_OVER_RIGHT, "GTK_STACK_TRANSITION_TYPE_OVER_RIGHT", "over-right" }, { GTK_STACK_TRANSITION_TYPE_UNDER_UP, "GTK_STACK_TRANSITION_TYPE_UNDER_UP", "under-up" }, { GTK_STACK_TRANSITION_TYPE_UNDER_DOWN, "GTK_STACK_TRANSITION_TYPE_UNDER_DOWN", "under-down" }, { GTK_STACK_TRANSITION_TYPE_UNDER_LEFT, "GTK_STACK_TRANSITION_TYPE_UNDER_LEFT", "under-left" }, { GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT, "GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT", "under-right" }, { GTK_STACK_TRANSITION_TYPE_OVER_UP_DOWN, "GTK_STACK_TRANSITION_TYPE_OVER_UP_DOWN", "over-up-down" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkStackTransitionType"), values); } return etype; } /* enumerations from "gtktextbuffer.h" */ GType gtk_text_buffer_target_info_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS, "GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS", "buffer-contents" }, { GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT, "GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT", "rich-text" }, { GTK_TEXT_BUFFER_TARGET_INFO_TEXT, "GTK_TEXT_BUFFER_TARGET_INFO_TEXT", "text" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkTextBufferTargetInfo"), values); } return etype; } /* enumerations from "gtktextiter.h" */ GType gtk_text_search_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_TEXT_SEARCH_VISIBLE_ONLY, "GTK_TEXT_SEARCH_VISIBLE_ONLY", "visible-only" }, { GTK_TEXT_SEARCH_TEXT_ONLY, "GTK_TEXT_SEARCH_TEXT_ONLY", "text-only" }, { GTK_TEXT_SEARCH_CASE_INSENSITIVE, "GTK_TEXT_SEARCH_CASE_INSENSITIVE", "case-insensitive" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkTextSearchFlags"), values); } return etype; } /* enumerations from "gtktextview.h" */ GType gtk_text_window_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_TEXT_WINDOW_PRIVATE, "GTK_TEXT_WINDOW_PRIVATE", "private" }, { GTK_TEXT_WINDOW_WIDGET, "GTK_TEXT_WINDOW_WIDGET", "widget" }, { GTK_TEXT_WINDOW_TEXT, "GTK_TEXT_WINDOW_TEXT", "text" }, { GTK_TEXT_WINDOW_LEFT, "GTK_TEXT_WINDOW_LEFT", "left" }, { GTK_TEXT_WINDOW_RIGHT, "GTK_TEXT_WINDOW_RIGHT", "right" }, { GTK_TEXT_WINDOW_TOP, "GTK_TEXT_WINDOW_TOP", "top" }, { GTK_TEXT_WINDOW_BOTTOM, "GTK_TEXT_WINDOW_BOTTOM", "bottom" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkTextWindowType"), values); } return etype; } /* enumerations from "gtktoolbar.h" */ GType gtk_toolbar_space_style_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_TOOLBAR_SPACE_EMPTY, "GTK_TOOLBAR_SPACE_EMPTY", "empty" }, { GTK_TOOLBAR_SPACE_LINE, "GTK_TOOLBAR_SPACE_LINE", "line" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkToolbarSpaceStyle"), values); } return etype; } /* enumerations from "gtktoolpalette.h" */ GType gtk_tool_palette_drag_targets_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_TOOL_PALETTE_DRAG_ITEMS, "GTK_TOOL_PALETTE_DRAG_ITEMS", "items" }, { GTK_TOOL_PALETTE_DRAG_GROUPS, "GTK_TOOL_PALETTE_DRAG_GROUPS", "groups" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkToolPaletteDragTargets"), values); } return etype; } /* enumerations from "gtktreemodel.h" */ GType gtk_tree_model_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_TREE_MODEL_ITERS_PERSIST, "GTK_TREE_MODEL_ITERS_PERSIST", "iters-persist" }, { GTK_TREE_MODEL_LIST_ONLY, "GTK_TREE_MODEL_LIST_ONLY", "list-only" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkTreeModelFlags"), values); } return etype; } /* enumerations from "gtktreeview.h" */ GType gtk_tree_view_drop_position_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_TREE_VIEW_DROP_BEFORE, "GTK_TREE_VIEW_DROP_BEFORE", "before" }, { GTK_TREE_VIEW_DROP_AFTER, "GTK_TREE_VIEW_DROP_AFTER", "after" }, { GTK_TREE_VIEW_DROP_INTO_OR_BEFORE, "GTK_TREE_VIEW_DROP_INTO_OR_BEFORE", "into-or-before" }, { GTK_TREE_VIEW_DROP_INTO_OR_AFTER, "GTK_TREE_VIEW_DROP_INTO_OR_AFTER", "into-or-after" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkTreeViewDropPosition"), values); } return etype; } /* enumerations from "gtktreeviewcolumn.h" */ GType gtk_tree_view_column_sizing_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_TREE_VIEW_COLUMN_GROW_ONLY, "GTK_TREE_VIEW_COLUMN_GROW_ONLY", "grow-only" }, { GTK_TREE_VIEW_COLUMN_AUTOSIZE, "GTK_TREE_VIEW_COLUMN_AUTOSIZE", "autosize" }, { GTK_TREE_VIEW_COLUMN_FIXED, "GTK_TREE_VIEW_COLUMN_FIXED", "fixed" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkTreeViewColumnSizing"), values); } return etype; } /* enumerations from "gtkwidget.h" */ GType gtk_widget_help_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_WIDGET_HELP_TOOLTIP, "GTK_WIDGET_HELP_TOOLTIP", "tooltip" }, { GTK_WIDGET_HELP_WHATS_THIS, "GTK_WIDGET_HELP_WHATS_THIS", "whats-this" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkWidgetHelpType"), values); } return etype; } /* enumerations from "deprecated/gtkrc.h" */ GType gtk_rc_flags_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_RC_FG, "GTK_RC_FG", "fg" }, { GTK_RC_BG, "GTK_RC_BG", "bg" }, { GTK_RC_TEXT, "GTK_RC_TEXT", "text" }, { GTK_RC_BASE, "GTK_RC_BASE", "base" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkRcFlags"), values); } return etype; } GType gtk_rc_token_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { { GTK_RC_TOKEN_INVALID, "GTK_RC_TOKEN_INVALID", "invalid" }, { GTK_RC_TOKEN_INCLUDE, "GTK_RC_TOKEN_INCLUDE", "include" }, { GTK_RC_TOKEN_NORMAL, "GTK_RC_TOKEN_NORMAL", "normal" }, { GTK_RC_TOKEN_ACTIVE, "GTK_RC_TOKEN_ACTIVE", "active" }, { GTK_RC_TOKEN_PRELIGHT, "GTK_RC_TOKEN_PRELIGHT", "prelight" }, { GTK_RC_TOKEN_SELECTED, "GTK_RC_TOKEN_SELECTED", "selected" }, { GTK_RC_TOKEN_INSENSITIVE, "GTK_RC_TOKEN_INSENSITIVE", "insensitive" }, { GTK_RC_TOKEN_FG, "GTK_RC_TOKEN_FG", "fg" }, { GTK_RC_TOKEN_BG, "GTK_RC_TOKEN_BG", "bg" }, { GTK_RC_TOKEN_TEXT, "GTK_RC_TOKEN_TEXT", "text" }, { GTK_RC_TOKEN_BASE, "GTK_RC_TOKEN_BASE", "base" }, { GTK_RC_TOKEN_XTHICKNESS, "GTK_RC_TOKEN_XTHICKNESS", "xthickness" }, { GTK_RC_TOKEN_YTHICKNESS, "GTK_RC_TOKEN_YTHICKNESS", "ythickness" }, { GTK_RC_TOKEN_FONT, "GTK_RC_TOKEN_FONT", "font" }, { GTK_RC_TOKEN_FONTSET, "GTK_RC_TOKEN_FONTSET", "fontset" }, { GTK_RC_TOKEN_FONT_NAME, "GTK_RC_TOKEN_FONT_NAME", "font-name" }, { GTK_RC_TOKEN_BG_PIXMAP, "GTK_RC_TOKEN_BG_PIXMAP", "bg-pixmap" }, { GTK_RC_TOKEN_PIXMAP_PATH, "GTK_RC_TOKEN_PIXMAP_PATH", "pixmap-path" }, { GTK_RC_TOKEN_STYLE, "GTK_RC_TOKEN_STYLE", "style" }, { GTK_RC_TOKEN_BINDING, "GTK_RC_TOKEN_BINDING", "binding" }, { GTK_RC_TOKEN_BIND, "GTK_RC_TOKEN_BIND", "bind" }, { GTK_RC_TOKEN_WIDGET, "GTK_RC_TOKEN_WIDGET", "widget" }, { GTK_RC_TOKEN_WIDGET_CLASS, "GTK_RC_TOKEN_WIDGET_CLASS", "widget-class" }, { GTK_RC_TOKEN_CLASS, "GTK_RC_TOKEN_CLASS", "class" }, { GTK_RC_TOKEN_LOWEST, "GTK_RC_TOKEN_LOWEST", "lowest" }, { GTK_RC_TOKEN_GTK, "GTK_RC_TOKEN_GTK", "gtk" }, { GTK_RC_TOKEN_APPLICATION, "GTK_RC_TOKEN_APPLICATION", "application" }, { GTK_RC_TOKEN_THEME, "GTK_RC_TOKEN_THEME", "theme" }, { GTK_RC_TOKEN_RC, "GTK_RC_TOKEN_RC", "rc" }, { GTK_RC_TOKEN_HIGHEST, "GTK_RC_TOKEN_HIGHEST", "highest" }, { GTK_RC_TOKEN_ENGINE, "GTK_RC_TOKEN_ENGINE", "engine" }, { GTK_RC_TOKEN_MODULE_PATH, "GTK_RC_TOKEN_MODULE_PATH", "module-path" }, { GTK_RC_TOKEN_IM_MODULE_PATH, "GTK_RC_TOKEN_IM_MODULE_PATH", "im-module-path" }, { GTK_RC_TOKEN_IM_MODULE_FILE, "GTK_RC_TOKEN_IM_MODULE_FILE", "im-module-file" }, { GTK_RC_TOKEN_STOCK, "GTK_RC_TOKEN_STOCK", "stock" }, { GTK_RC_TOKEN_LTR, "GTK_RC_TOKEN_LTR", "ltr" }, { GTK_RC_TOKEN_RTL, "GTK_RC_TOKEN_RTL", "rtl" }, { GTK_RC_TOKEN_COLOR, "GTK_RC_TOKEN_COLOR", "color" }, { GTK_RC_TOKEN_UNBIND, "GTK_RC_TOKEN_UNBIND", "unbind" }, { GTK_RC_TOKEN_LAST, "GTK_RC_TOKEN_LAST", "last" }, { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GtkRcTokenType"), values); } return etype; } /* enumerations from "deprecated/gtkuimanager.h" */ GType gtk_ui_manager_item_type_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const GFlagsValue values[] = { { GTK_UI_MANAGER_AUTO, "GTK_UI_MANAGER_AUTO", "auto" }, { GTK_UI_MANAGER_MENUBAR, "GTK_UI_MANAGER_MENUBAR", "menubar" }, { GTK_UI_MANAGER_MENU, "GTK_UI_MANAGER_MENU", "menu" }, { GTK_UI_MANAGER_TOOLBAR, "GTK_UI_MANAGER_TOOLBAR", "toolbar" }, { GTK_UI_MANAGER_PLACEHOLDER, "GTK_UI_MANAGER_PLACEHOLDER", "placeholder" }, { GTK_UI_MANAGER_POPUP, "GTK_UI_MANAGER_POPUP", "popup" }, { GTK_UI_MANAGER_MENUITEM, "GTK_UI_MANAGER_MENUITEM", "menuitem" }, { GTK_UI_MANAGER_TOOLITEM, "GTK_UI_MANAGER_TOOLITEM", "toolitem" }, { GTK_UI_MANAGER_SEPARATOR, "GTK_UI_MANAGER_SEPARATOR", "separator" }, { GTK_UI_MANAGER_ACCELERATOR, "GTK_UI_MANAGER_ACCELERATOR", "accelerator" }, { GTK_UI_MANAGER_POPUP_WITH_ACCELS, "GTK_UI_MANAGER_POPUP_WITH_ACCELS", "popup-with-accels" }, { 0, NULL, NULL } }; etype = g_flags_register_static (g_intern_static_string ("GtkUIManagerItemType"), values); } return etype; } /* Generated data ends here */
1.125
1
src/prefs.c
ralic/gnu_sciteproj
0
7999019
/** * prefs.c - prefs for SciteProj * * Copyright 2006 <NAME>, 2009-2016 <NAME> * * This file is part of SciteProj. * * SciteProj is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * SciteProj is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SciteProj. If not, see <http://www.gnu.org/licenses/>. * */ #include <gtk/gtk.h> #include <string.h> #include <lua.h> #include <lualib.h> #include <lauxlib.h> #include "prefs.h" #include "string_utils.h" #include "script.h" #include "file_utils.h" /** * */ gboolean check_for_old_style_config(); int load_lua_config(gchar *filename, gchar *full_string); /** * */ sciteproj_prefs prefs; gchar *prefs_filename; gchar *default_config_string = (gchar*)"" \ "-----------------------------\n" "-- Configuration for SciteProj\n" "-----------------------------\n" "\n" "-- Window geometry:\n" "xpos=40\n" "ypos=40\n" "width=200\n" "height=400\n" "\n" "-- Search window geometry (-1 on xpos and ypos means default center screen):\n" "search_xpos=-1\n" "search_ypos=-1\n" "search_width=500\n" "search_height=400\n" "\n" "search_alert_file_warnings=TRUE\n" "search_match_case=FALSE\n" "search_match_whole_words=FALSE\n" "search_trim_results=TRUE\n" "\n" "-- other:\n" "give_scite_focus=FALSE\n" "search_give_scite_focus=TRUE\n" "\n" "show_recent=FALSE\n" "recent_add_to_bottom=FALSE\n" "\n" "hide_statusbar=FALSE\n" "\n" "\n"; /** * Check config string - is it valid? */ gboolean check_config_string(gchar *in_config) { gboolean result = FALSE; int co=0; gdouble tempdouble; gchar *tempstring = NULL; int pos=-1; gchar *value=in_config; // clear scite Path prefs.scite_path = NULL; for (co=0; co < (int)strlen(in_config); co++) { if (in_config[co] == '=') pos=co; if (pos == -1) { value++; } } if (pos != -1) { tempstring = g_strndup(in_config, pos); value++; } if ((tempstring != NULL) && (value != NULL)) { tempstring = g_strchug(tempstring); tempstring = g_strchomp(tempstring); value = g_strchug(value); value = g_strchomp(value); if (g_ascii_strcasecmp(tempstring, "xpos")==0) { tempdouble = g_ascii_strtod(value, NULL); prefs.xpos = (int) tempdouble; } if (g_ascii_strcasecmp(tempstring, "ypos")==0) { tempdouble = g_ascii_strtod(value, NULL); prefs.ypos = (int)tempdouble; } if (g_ascii_strcasecmp(tempstring, "width")==0) { tempdouble = g_ascii_strtod(value, NULL); prefs.width = (int)tempdouble; } if (g_ascii_strcasecmp(tempstring, "height")==0) { tempdouble = g_ascii_strtod(value, NULL); prefs.height = (int)tempdouble; } if (g_ascii_strcasecmp(tempstring, "give_scite_focus")==0) { if (g_ascii_strcasecmp(value, "TRUE")==0) { prefs.give_scite_focus = TRUE; } } if (g_ascii_strcasecmp(tempstring, "scite_path")==0) { prefs.scite_path = g_strdup_printf("%s", value); } if (g_ascii_strcasecmp(tempstring, "show_recent") == 0) { if (g_ascii_strcasecmp(value, "TRUE") == 0) { prefs.show_recent = TRUE; } } if (g_ascii_strcasecmp(tempstring, "recent_add_to_bottom")==0) { if (g_ascii_strcasecmp(value, "TRUE") == 0) { prefs.recent_add_to_bottom = TRUE; } } if (g_ascii_strcasecmp(tempstring, "hide_statusbar") == 0) { if (g_ascii_strcasecmp(value, "TRUE") == 0) { prefs.hide_statusbar = TRUE; } } if (g_ascii_strcasecmp(tempstring, "start_scite") == 0) { if (g_ascii_strcasecmp(value, "TRUE") == 0) { prefs.start_scite = TRUE; } } } if (tempstring != NULL) g_free(tempstring); return result; } /** * init_prefs */ gboolean init_prefs(gchar *target_directory, GError **err) { //FILE *fp; //gchar buf[PREFS_BUFSIZE]; gchar *config_string = NULL; gboolean result = TRUE; // the list of strings gchar **list = NULL; // Set default values prefs.lhs = 1; prefs.width = 200; prefs.height = 600; prefs.verbosity = 0; // No informational messages prefs.last_file_filter = -1; // All files (my choice) prefs.give_scite_focus = FALSE; prefs.show_recent = FALSE; prefs.recent_add_to_bottom = FALSE; prefs.scite_path = NULL; prefs.hide_statusbar = FALSE; prefs.start_scite = FALSE; // First, check the file ~/.config/sciteprojrc.lua gchar *test_prefs_filename = g_build_filename(g_get_user_config_dir(), "sciteprojrc.lua",NULL); if (g_file_test(test_prefs_filename, G_FILE_TEST_IS_REGULAR)) { // the file exists, load it: if (!g_file_get_contents(test_prefs_filename, &config_string, NULL, err)) { result = FALSE; goto ERROR; } if (load_lua_config(test_prefs_filename, config_string) != 0) { printf("error loading LUA config!\n"); } g_free(config_string); } g_free(test_prefs_filename); // Otherwise, check current directory, and the directories that the previous // versions used test_prefs_filename = g_build_filename(target_directory, "sciteprojrc.lua", NULL); if (!g_file_test(test_prefs_filename, G_FILE_TEST_IS_REGULAR)) { // the result of g_get_user_config_dir doesn't need to be freed, so we // dont need to put it in a pointer of its own. prefs_filename = g_build_filename(g_get_user_config_dir(), "sciteprojrc",NULL); // Check if a config-file exists if (!g_file_test(prefs_filename, G_FILE_TEST_IS_REGULAR)) { // First, check if ~/.sciteproj exists. gchar *old_configfilename = g_build_filename(g_get_home_dir(), ".sciteproj", NULL); if (!g_file_test(old_configfilename, G_FILE_TEST_IS_REGULAR)) { // No config-file exists, default to sciteprojrc.lua prefs_filename = g_strdup(test_prefs_filename); } } } else { prefs_filename = g_strdup(test_prefs_filename); } g_free(test_prefs_filename); // Load preferences from config if (!g_file_get_contents(prefs_filename, &config_string, NULL, err)) { result = FALSE; goto ERROR; } // Check if it is an old-style config, or a new LUA one if (check_for_old_style_config(config_string)) { gchar **savedlist = NULL; debug_printf("Old style config\n"); // split out the lines, and add each to the list of strings list = g_strsplit(config_string, "\n", -1); savedlist = list; gchar *temp = NULL; do { temp = *list; if (temp != NULL) { if ((temp[0] != '#') && (strcmp(temp, "")!=0)) { // We got a valid string: // no starting #, and not an empty string. check_config_string(temp); } list++; } } while (temp != NULL); g_strfreev(savedlist); } else { // ----- New style (LUA) config //if (!load_lua_config(config_string)) { if (load_lua_config(prefs_filename, config_string)!=0) { printf("error loading LUA config!\n"); } } ERROR: g_free(config_string); return result; } /** * */ void done_prefs() { g_free(prefs_filename); } /** * */ gboolean check_for_old_style_config(const gchar *teststring) { gboolean result = FALSE; int co = 0; // We satisfy it by checking for the default header and assume that if // that is there, we have an old-styled (non-LUA) config file if (g_str_has_prefix(teststring, "# ---------------------------\n" "# Configuration for SciteProj\n" "# ---------------------------\n") ) { result = TRUE; } // Another way to check is to check for lines starting with # - as a comment // LUA uses "--", so this is should work to identify oldstyle config. for (co=0; co<strlen(teststring); co++) { if (teststring[co] == '\n') { //printf("Tecken: %c\n", teststring[co+1]); if (teststring[co+1] == '#') { result = TRUE; } } } return result; } /** * */ int load_lua_config(gchar *filename, gchar *full_string) { lua_State *lua; lua = init_script(); //if (load_script_buffer(lua, config_string)!=0) { if (load_script_buffer(lua, full_string)!=0) { printf("Error loading file: %s\n", filename); return FALSE; } run_script(lua); if (lua_global_exists(lua, "xpos")) prefs.xpos = lua_get_number(lua, "xpos"); if (lua_global_exists(lua, "ypos")) prefs.ypos = lua_get_number(lua, "ypos"); if (lua_global_exists(lua, "width")) prefs.width = lua_get_number(lua, "width"); if (lua_global_exists(lua, "height")) prefs.height = lua_get_number(lua, "height"); if (lua_global_exists(lua, "give_scite_focus")) prefs.give_scite_focus = lua_get_boolean(lua, "give_scite_focus"); if (lua_global_exists(lua, "show_recent")) prefs.show_recent = (gboolean)lua_get_boolean(lua, "show_recent"); if (lua_global_exists(lua, "recent_add_to_bottom")) prefs.recent_add_to_bottom = (gboolean)lua_get_boolean(lua, "recent_add_to_bottom"); if (lua_global_exists(lua, "hide_statusbar")) prefs.hide_statusbar = lua_get_boolean(lua, "hide_statusbar"); if (lua_global_exists(lua, "use_stock_folder_icon")) prefs.use_stock_folder_icon = lua_get_boolean(lua, "use_stock_folder_icon"); if (lua_global_exists(lua, "write_protect")) prefs.write_protect = lua_get_boolean(lua, "write_protect"); if (lua_global_exists(lua, "start_scite")) prefs.start_scite = lua_get_boolean(lua, "start_scite"); done_script(lua); return 0; }
1.039063
1
Deja_Demo/Feature/BaseTabViewController/MLUIBaseTabViewController.h
iosfunny/Deja-iOS-Demo
0
7999027
// // MLUIBaseTabViewController.h // ProjectBaseService // // Created by mozat on 2019/5/3. // Copyright © 2019 xiaozf. All rights reserved. // #import "MLUILightViewController.h" NS_ASSUME_NONNULL_BEGIN /* 一级页面都继承这个类. */ @interface MLUIBaseTabViewController : MLUILightViewController // sub class hook .. @property (nonatomic, strong) UIView * leftTitleView; @property (nonatomic, strong) UIView * rightItemView; @end NS_ASSUME_NONNULL_END
0.427734
0
WOF2/src/WOF/match/entity/ball/_WOFMatchBall.h
jadnohra/World-Of-Football
3
7999035
#ifndef _WOFMatchBall_h #define _WOFMatchBall_h #include "WE3/WEPtr.h" #include "WE3/phys/WEPhysRigidBody.h" #include "WE3/math/WESphere.h" using namespace WE; #include "EE/scene/entity/EESceneEntityMesh.h" using namespace EE; namespace WOF { class MatchBallController; class Match; class MatchBall : public SceneEntityMesh, public PhysRigidBody { public: MatchBall(); bool bindNode(Match& match); void bindController(MatchBallController* pController); public: SoftPtr<MatchBallController> mController; Sphere mCollSphere; }; } #endif
1.015625
1
src/map/include/components/level.h
RavenX8/osirosenew
49
7999043
#pragma once namespace Component { struct Level { uint16_t level; uint64_t xp; uint64_t penaltyXp; }; }
0.165039
0
Headers/Frameworks/Ozone/OZChanTransformSwitchController.h
CommandPost/FinalCutProFrameworks
3
7999051
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Mar 11 2021 20:53:35). // // Copyright (C) 1997-2019 <NAME>. // #import <ProInspector/OZViewController.h> @class LKSegmentedControl; @interface OZChanTransformSwitchController : OZViewController { LKSegmentedControl *_pSwitch; } - (void)setChannelValue:(id)arg1; - (void)update; - (BOOL)isEnabled; - (id)initWithChan:(struct OZChannelBase *)arg1 isHUD:(BOOL)arg2; @end
0.523438
1
macOS/10.13/AVFoundation.framework/AVFigEndpointRemoteControlSessionCommunicationChannelManager.h
onmyway133/Runtime-Headers
30
7999059
/* Generated by RuntimeBrowser Image: /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation */ @interface AVFigEndpointRemoteControlSessionCommunicationChannelManager : NSObject <AVFigRoutingContextCommunicationChannelManager> { struct __CFDictionary { } * _communicationChannelsForRemoteControlSessions; NSObject<OS_dispatch_queue> * _ivarAccessQueue; struct OpaqueFigEndpointRemoteControlSession { } * _outgoingRemoteControlSession; AVFigRoutingContextOutputContextImpl * _parentOutputContextImpl; struct OpaqueFigRoutingContext { } * _routingContext; } @property (atomic, readonly, copy) NSString *debugDescription; @property (atomic, readonly, copy) NSString *description; @property (atomic, readonly) unsigned long long hash; @property (nonatomic, readonly) AVOutputContextCommunicationChannel *outgoingCommunicationChannel; @property (atomic, readwrite) AVFigRoutingContextOutputContextImpl *parentOutputContextImpl; @property (atomic, readonly) Class superclass; - (void).cxx_destruct; - (void)communicationChannelImpl:(id)arg1 didReceiveData:(id)arg2; - (void)communicationChannelImplDidClose:(id)arg1; - (void)dealloc; - (id)init; - (id)initWithRoutingContext:(struct OpaqueFigRoutingContext { }*)arg1; - (id)outgoingCommunicationChannel; - (id)parentOutputContextImpl; - (void)setParentOutputContextImpl:(id)arg1; @end
0.796875
1
rokol_ffi/wrappers/rokol_app.h
toyboot4e/rokol
2
7999067
//! File for generating Rust FFI #define SOKOL_NO_ENTRY #define SOKOL_NO_DEPRECATED #define SOKOL_TRACE_HOOKS // search from include path (-I flag) #include "sokol_app.h"
0.400391
0
Sem2C/4_3/main.c
vAdamski/Dante_C
0
7999075
#include <stdio.h> #include <stdlib.h> int create_array_2d_2(int ***ptr, int width, int height); void destroy_array_2d(int ***ptr, int height); void display_array_2d(int **ptr, int width, int height); int sum_array_2d(int **ptr, int width, int height); int sum_row(int *ptr, int width); int main() { int **tab = NULL; int width, height, error; printf("Podaj szerokość i wysokość: "); if(scanf("%d %d", &width, &height) != 2) { printf("Incorrect input\n"); return 1; } if(height < 1 || width < 1) { printf("Incorrect input data\n"); return 2; } error = create_array_2d_2(&tab, width, height); if(error == 2) { printf("Failed to allocate memory"); return 8; } printf("Podaj liczby: "); for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { if(scanf("%d", *(tab + i) + j) != 1) { destroy_array_2d(&tab, height); printf("Incorrect input\n"); return 1; } } } display_array_2d(tab, width, height); for (int i = 0; i < height; ++i) { printf("%d\n", sum_row(*(tab + i), width)); } printf("%d\n", sum_array_2d(tab, width, height)); destroy_array_2d(&tab,height); return 0; } int create_array_2d_2(int ***ptr, int width, int height) { if(height < 1 || width < 1 || ptr == NULL) return 1; *ptr = malloc(height * sizeof(int*)); if(*ptr == NULL) { return 2; } for (int i = 0; i < height; ++i) { *(*ptr + i) = malloc(width * sizeof(int)); if(*(*ptr+i) == NULL) { for (int j = 0; j < i ; ++j) { free(*(*ptr + j)); } free(*ptr); *ptr=NULL; return 2; } } return 0; } void destroy_array_2d(int ***ptr, int height) { if(ptr == NULL || height < 1) return; for (int i = 0; i < height; ++i) { free(*(*ptr+i)); } free(*ptr); *ptr = NULL; } void display_array_2d(int **ptr, int width, int height) { if(ptr == NULL || height < 1 || width < 1) return; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { printf("%3d ", *(*(ptr + i) + j)); } printf("\n"); } } int sum_array_2d(int **ptr, int width, int height) { if(ptr == NULL || height < 1 || width < 1) return -1; int sum = 0; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { sum += *(*(ptr + i) + j); } } return sum; } int sum_row(int *ptr, int width) { if(ptr == NULL || width < 1) return -1; int sum = 0; for (int i = 0; i < width; ++i) { sum += *(ptr + i); } return sum; }
2.609375
3
src/openms/thirdparty/seqan/include/seqan/seeds/banded_chain_alignment_scout.h
vmusch/OpenMS
348
7999083
// ========================================================================== // SeqAn - The Library for Sequence Analysis // ========================================================================== // Copyright (c) 2006-2013, <NAME>, FU Berlin // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of Knut Reinert or the FU Berlin nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // // ========================================================================== // Author: <NAME> <<EMAIL>> // ========================================================================== // Implements the DPScout for the banded chain alignment algorithm. // The ScoutState is used to keep track of the initialization values for // the next matrix. // ========================================================================== #ifndef CORE_INCLUDE_SEQAN_SEEDS_BANDED_CHAIN_ALIGNMENT_SCOUT_H_ #define CORE_INCLUDE_SEQAN_SEEDS_BANDED_CHAIN_ALIGNMENT_SCOUT_H_ namespace seqan { // ============================================================================ // Forwards // ============================================================================ // ============================================================================ // Tags, Classes, Enums // ============================================================================ // ---------------------------------------------------------------------------- // Tag BandedChainAlignmentScout // ---------------------------------------------------------------------------- struct BandedChainAlignmentScout_; typedef Tag<BandedChainAlignmentScout_> BandedChainAlignmentScout; // ---------------------------------------------------------------------------- // Class BandedChainAlignmentScoutState // ---------------------------------------------------------------------------- // Used to determine the scout state of the BandedChainAlignmentScout. template <typename TSpec> struct BandedChainAlignmentScoutState; // ---------------------------------------------------------------------------- // Class DPScoutState_ // ---------------------------------------------------------------------------- // Stores the state of the algorithm. // It keeps track of the initialization values for horziontal and vertical // direction of the current matrix and the next matrix that intersects with // the current active matrix. template <typename TDPCell> class DPScoutState_<BandedChainAlignmentScoutState<TDPCell> > { public: typedef Triple<unsigned, unsigned, TDPCell> TInitCell; typedef std::set<TInitCell> TInitializationCellSet; unsigned int _horizontalNextGridOrigin; unsigned int _verticalNextGridOrigin; String<TDPCell> _horizontalInitCurrentMatrix; String<TDPCell> _verticalInitCurrentMatrix; String<TDPCell> _horizontalInitNextMatrix; String<TDPCell> _verticalInitNextMatrix; TInitializationCellSet _nextInitializationCells; DPScoutState_() : _horizontalNextGridOrigin(0u), _verticalNextGridOrigin(0u) {} }; // ---------------------------------------------------------------------------- // Class DPScout_ // ---------------------------------------------------------------------------- template<typename TDPCell> class DPScout_<TDPCell, BandedChainAlignmentScout> { public: typedef typename ScoutStateSpecForScout_<DPScout_>::Type TDPScoutStateSpec; typedef DPScoutState_<TDPScoutStateSpec> TScoutState; typedef String<unsigned int> TMaxHostPositionString; typedef typename Value<TDPCell>::Type TScoreValue; // TScoreValue _maxScore; // the maximal score detected TDPCell _maxScore; TScoutState * _dpScoutStatePtr; TMaxHostPositionString _maxHostPositions; // the array containing all positions that have a maximal score DPScout_() : _maxScore(), _dpScoutStatePtr(0), _maxHostPositions() {} DPScout_(TScoutState & scoutState) : _maxScore(), _dpScoutStatePtr(&scoutState), _maxHostPositions() {} }; // ============================================================================ // Metafunctions // ============================================================================ // ---------------------------------------------------------------------------- // Metafunction ScoutSpecForAlignmentAlgorithm_ // ---------------------------------------------------------------------------- template <typename TSpec, typename TDPMatrixLocation> struct ScoutSpecForAlignmentAlgorithm_<BandedChainAlignment_<TSpec, TDPMatrixLocation> > { typedef BandedChainAlignmentScout Type; }; // ---------------------------------------------------------------------------- // Metafunction ScoutStateSpecForScout_ // ---------------------------------------------------------------------------- template <typename TDPCell> struct ScoutStateSpecForScout_<DPScout_<TDPCell, BandedChainAlignmentScout> > { typedef BandedChainAlignmentScoutState<TDPCell> Type; }; // ============================================================================ // Functions // ============================================================================ // ---------------------------------------------------------------------------- // Function _rinitScout() // ---------------------------------------------------------------------------- template <typename TDPCell> inline void _reinitScout(DPScout_<TDPCell, BandedChainAlignmentScout> & dpScout) { //typedef typename Value<TDPCell>::Type TScoreValue; dpScout._maxScore = TDPCell(); resize(dpScout._maxHostPositions, 1, 0); } // ---------------------------------------------------------------------------- // Function _reinitScoutState() // ---------------------------------------------------------------------------- template <typename TDPCell, typename TPosH, typename TPosV, typename TSizeCurrInit, typename TSizeNextInit> inline void _reinitScoutState(DPScoutState_<BandedChainAlignmentScoutState<TDPCell> > & scoutState, TPosH const & originNextMatrixH, TPosV const & originNextMatrixV, TSizeCurrInit const & sizeCurrMatrixInitH, TSizeCurrInit const & sizeCurrMatrixInitV, TSizeNextInit const & sizeNextMatrixInitH, TSizeNextInit const & sizeNextMatrixInitV) { typedef DPScoutState_<BandedChainAlignmentScoutState<TDPCell> > TDPScoutState; typedef typename TDPScoutState::TInitializationCellSet TInitCellSet; typedef typename TInitCellSet::iterator TInitCellSetIterator; scoutState._horizontalNextGridOrigin = originNextMatrixH; scoutState._verticalNextGridOrigin = originNextMatrixV; // initialize the current initialization values of the tracker arrayFill(begin(scoutState._horizontalInitCurrentMatrix), end(scoutState._horizontalInitCurrentMatrix), TDPCell()); arrayFill(begin(scoutState._verticalInitCurrentMatrix), end(scoutState._verticalInitCurrentMatrix), TDPCell()); arrayFill(begin(scoutState._horizontalInitNextMatrix), end(scoutState._horizontalInitNextMatrix), TDPCell()); arrayFill(begin(scoutState._verticalInitNextMatrix), end(scoutState._verticalInitNextMatrix), TDPCell()); // check if the value needs to be resized ... (can be longer but not smaller) if ((TSizeCurrInit) length(scoutState._horizontalInitCurrentMatrix) < sizeCurrMatrixInitH) resize(scoutState._horizontalInitCurrentMatrix, sizeCurrMatrixInitH, TDPCell()); if ((TSizeCurrInit) length(scoutState._verticalInitCurrentMatrix) < sizeCurrMatrixInitV) resize(scoutState._verticalInitCurrentMatrix, sizeCurrMatrixInitV, TDPCell()); if ((TSizeNextInit) length(scoutState._horizontalInitNextMatrix) < sizeNextMatrixInitH) resize(scoutState._horizontalInitNextMatrix, sizeNextMatrixInitH, TDPCell()); if ((TSizeNextInit) length(scoutState._verticalInitNextMatrix) < sizeNextMatrixInitV) resize(scoutState._verticalInitNextMatrix, sizeNextMatrixInitV, TDPCell()); // Parsing the set to get the values. for (TInitCellSetIterator it = scoutState._nextInitializationCells.begin(); // We need to plant the initialization values here. At the moment we only put the old values here. it != scoutState._nextInitializationCells.end(); ++it) { // std::cerr << "TInitCell == " << it->i1 << " " << it->i2 << " " << _scoreOfCell(it->i3) << std::endl; if (it->i1 == 0) scoutState._verticalInitCurrentMatrix[it->i2] = it->i3; if (it->i2 == 0) scoutState._horizontalInitCurrentMatrix[it->i1] = it->i3; } } // ---------------------------------------------------------------------------- // Function _setScoutState() // ---------------------------------------------------------------------------- // Sets the state of the scout. template <typename TDPCell, typename TStateSpec> inline void _setScoutState(DPScout_<TDPCell, BandedChainAlignmentScout> & dpScout, DPScoutState_<BandedChainAlignmentScoutState<TStateSpec> > & state) { dpScout._dpScoutStatePtr = & state; } // ---------------------------------------------------------------------------- // Function _scoutBestScore() // ---------------------------------------------------------------------------- template <typename TDPCell, typename TTraceMatrixNavigator> inline void _scoutBestScore(DPScout_<TDPCell, BandedChainAlignmentScout> & dpScout, TDPCell const & dpCell, TTraceMatrixNavigator const & navigator, bool isLastColumn, bool isLastRow, bool trackNextInitColumn, bool trackNextInitRow) { // Store value for vertical initialization of next grid. if(trackNextInitColumn) dpScout._dpScoutStatePtr->_verticalInitNextMatrix[coordinate(navigator, +DPMatrixDimension_::VERTICAL) - dpScout._dpScoutStatePtr->_verticalNextGridOrigin] = dpCell; // Store value for horizontal initialization of next grid. if (trackNextInitRow) dpScout._dpScoutStatePtr->_horizontalInitNextMatrix[coordinate(navigator, +DPMatrixDimension_::HORIZONTAL) - dpScout._dpScoutStatePtr->_horizontalNextGridOrigin] = dpCell; // Now we have to track the optimal score from the last column or row. if (isLastColumn || isLastRow) { if (_scoreOfCell(dpCell) >= _scoreOfCell(dpScout._maxScore)) { if (_scoreOfCell(dpCell) == _scoreOfCell(dpScout._maxScore)) appendValue(dpScout._maxHostPositions, position(navigator)); else { resize(dpScout._maxHostPositions, 1); dpScout._maxHostPositions[0] = position(navigator); dpScout._maxScore = dpCell; } } } } template <typename TDPCell, typename TTraceMatrixNavigator> inline void _scoutBestScore(DPScout_<TDPCell, BandedChainAlignmentScout> &, TDPCell const &, TTraceMatrixNavigator const &, bool isLastColumn = false, bool isLastRow = false) { (void) isLastColumn; (void) isLastRow; //no-op } // ---------------------------------------------------------------------------- // Function maxScore() // ---------------------------------------------------------------------------- template <typename TDPCell> inline typename Value<TDPCell>::Type & maxScore(DPScout_<TDPCell, BandedChainAlignmentScout> & scout) { return _scoreOfCell(scout._maxScore); } template <typename TDPCell> inline typename Value<TDPCell>::Type const & maxScore(DPScout_<TDPCell, BandedChainAlignmentScout> const & scout) { return _scoreOfCell(scout._maxScore); } // ---------------------------------------------------------------------------- // Function maxHostPositions() // ---------------------------------------------------------------------------- template <typename TDPCell> inline typename DPScout_<TDPCell, BandedChainAlignmentScout>::TMaxHostPositionString const & maxHostPositions(DPScout_<TDPCell, BandedChainAlignmentScout> const & scout) { return scout._maxHostPositions; } template <typename TDPCell> inline typename DPScout_<TDPCell, BandedChainAlignmentScout>::TMaxHostPositionString & maxHostPositions(DPScout_<TDPCell, BandedChainAlignmentScout> & scout) { return scout._maxHostPositions; } // ---------------------------------------------------------------------------- // Function maxHostPosition() // ---------------------------------------------------------------------------- template <typename TDPCell> inline unsigned int maxHostPosition(DPScout_<TDPCell, BandedChainAlignmentScout> const & scout) { return scout._maxHostPositions[0]; } // ---------------------------------------------------------------------------- // Function nextMatrixBeginH() // ---------------------------------------------------------------------------- template <typename TDPCell> inline unsigned int _nextMatrixBeginH(DPScout_<TDPCell, BandedChainAlignmentScout> const & scout) { return scout._posH; } // ---------------------------------------------------------------------------- // Function nextMatrixBeginV() // ---------------------------------------------------------------------------- template <typename TDPCell> inline unsigned int _nextMatrixBeginV(DPScout_<TDPCell, BandedChainAlignmentScout> const & scout) { return scout._posV; } } // namespace seqan #endif // #ifndef CORE_INCLUDE_SEQAN_SEEDS_BANDED_CHAIN_ALIGNMENT_SCOUT_H_
1.234375
1
lib/libcurses/scanw.c
weiss/original-bsd
114
7999091
/* * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * %sccs.include.redist.c% */ #ifndef lint static char sccsid[] = "@(#)scanw.c 8.3 (Berkeley) 05/04/94"; #endif /* not lint */ /* * scanw and friends. */ #ifdef __STDC__ #include <stdarg.h> #else #include <varargs.h> #endif #include "curses.h" /* * scanw -- * Implement a scanf on the standard screen. */ int #ifdef __STDC__ scanw(const char *fmt, ...) #else scanw(fmt, va_alist) char *fmt; va_dcl #endif { va_list ap; int ret; #ifdef __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = vwscanw(stdscr, fmt, ap); va_end(ap); return (ret); } /* * wscanw -- * Implements a scanf on the given window. */ int #ifdef __STDC__ wscanw(WINDOW *win, const char *fmt, ...) #else wscanw(win, fmt, va_alist) WINDOW *win; char *fmt; va_dcl #endif { va_list ap; int ret; #ifdef __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = vwscanw(win, fmt, ap); va_end(ap); return (ret); } /* * mvscanw, mvwscanw -- * Implement the mvscanw commands. Due to the variable number of * arguments, they cannot be macros. Another sigh.... */ int #ifdef __STDC__ mvscanw(register int y, register int x, const char *fmt,...) #else mvscanw(y, x, fmt, va_alist) register int y, x; char *fmt; va_dcl #endif { va_list ap; int ret; if (move(y, x) != OK) return (ERR); #ifdef __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = vwscanw(stdscr, fmt, ap); va_end(ap); return (ret); } int #ifdef __STDC__ mvwscanw(register WINDOW * win, register int y, register int x, const char *fmt, ...) #else mvwscanw(win, y, x, fmt, va_alist) register WINDOW *win; register int y, x; char *fmt; va_dcl #endif { va_list ap; int ret; if (move(y, x) != OK) return (ERR); #ifdef __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = vwscanw(win, fmt, ap); va_end(ap); return (ret); } /* * vwscanw -- * This routine actually executes the scanf from the window. */ int vwscanw(win, fmt, ap) WINDOW *win; const char *fmt; va_list ap; { char buf[1024]; return (wgetstr(win, buf) == OK ? vsscanf(buf, fmt, ap) : ERR); }
1.296875
1
sys/src/cmd/disk/pip/tosh.c
Plan9-Archive/plan9-2e
1
7999099
#include "all.h" enum { Nblock = 12, /* blocking factor */ }; static Dev dev; static int topen(void); static int tgettoc(void); static int tmodeset(int); static void tcopytrack(int, int, int, int); static int topen(void) { if(dev.chan.open == 0) { doprobe(Dtosh, &dev.chan); if(dev.chan.open == 0) { print("toshiba not on scsi\n"); return 1; } } if(tmodeset(Bcdda)) return 1; if(tgettoc()) /* toc address are adjusted by block size */ return 1; return 0; } void tload(void) { int fromtrack, type, totrack; int bs, i; if(topen()) return; fromtrack = gettrack("CD track [number]/*"); if(fromtrack < dev.firsttrack || fromtrack > dev.lasttrack) if(fromtrack != Trackall) { print("from track out of range %d-%d\n", dev.firsttrack, dev.lasttrack); return; } type = gettype("type [cdda/cdrom]"); switch(type) { default: print("bad type\n"); return; case Tcdrom: bs = Bcdrom; break; case Tcdda: bs = Bcdda; break; } totrack = gettrack("disk track [number]"); if(fromtrack == Trackall) { for(i=dev.firsttrack; i<=dev.lasttrack; i++) { print("track %d\n", i); tcopytrack(i, totrack, bs, type); totrack++; } return; } tcopytrack(fromtrack, totrack, bs, type); } void tverif(void) { int fromtrack, type, totrack; int bs, i; if(topen()) return; fromtrack = gettrack("CD track [number]/*"); if(fromtrack < dev.firsttrack || fromtrack > dev.lasttrack) if(fromtrack != Trackall) { print("from track out of range %d-%d\n", dev.firsttrack, dev.lasttrack); return; } type = Tcdda; bs = Bcdda; totrack = gettrack("disk track [number]"); if(fromtrack == Trackall) { for(i=dev.firsttrack; i<=dev.lasttrack; i++) { print("track %d->%d\n", i, totrack); tcopytrack(i, totrack, bs, type); for(;;) { print("track %d->t\n", i); tcopytrack(i, Tracktmp, bs, type); if(dverify(totrack, Tracktmp)) break; print("track %d->%d\n", i, totrack); tcopytrack(i, totrack, bs, type); if(dverify(totrack, Tracktmp)) break; } dclearentry(Tracktmp, 1); totrack++; } return; } print("track %d->%d\n", fromtrack, totrack); tcopytrack(fromtrack, totrack, bs, type); for(;;) { print("track %d->t\n", fromtrack); tcopytrack(fromtrack, Tracktmp, bs, type); if(dverify(totrack, Tracktmp)) break; print("track %d->%d\n", fromtrack, totrack); tcopytrack(fromtrack, totrack, bs, type); if(dverify(totrack, Tracktmp)) break; } dclearentry(Tracktmp, 1); } void ttoc(void) { int i; if(topen()) return; print("toshiba table of contents\n"); for(i=0; i<Ntrack; i++) if(dev.table[i].size) print("%3d %7ld %6ld\n", i, dev.table[i].start, dev.table[i].size); } static void tcopytrack(int from, int to, int bs, int type) { long sz, ad, n; uchar *buf; if(to < 0 || to >= Maxtrack) { print("disk track not in range %d\n", to); return; } buf = dbufalloc(Nblock, bs); if(buf == 0) return; sz = dev.table[from].size; ad = dev.table[from].start; while(sz > 0) { n = Nblock; if(sz < Nblock) n = sz; if(readscsi(dev.chan, buf, ad, n*bs, bs, 0x28, 0)) return; if(dwrite(buf, n)) return; ad += n; sz -= n; } dcommit(to, type); } static int tgettoc(void) { uchar cmd[10], resp[50*8 + 4]; int i, n, t, ft, lt; memset(cmd, 0, sizeof(cmd)); cmd[0] = 0x43; /* disk info */ cmd[7] = sizeof(resp)>>8; cmd[8] = sizeof(resp); n = scsi(dev.chan, cmd, sizeof(cmd), resp, sizeof(resp), 0); if(n < 4) { print("cant issue in disk info command\n"); return 1; } dev.firsttrack = 0; dev.lasttrack = 0; for(i=0; i<Ntrack; i++) dev.table[i].start = -1; ft = resp[2]; lt = resp[3]; if(ft <= 0 || ft >= Maxtrack) { print("first table %d not in range\n", ft); return 1; } if(lt <= 0 || lt >= Maxtrack) { print("last table %d not in range\n", lt); return 1; } n -= 7; for(i=4; i<n; i+=8) { t = resp[i+2]; if(t >= 0xa0) t = Maxtrack; else if(t < ft || t > lt) { print("table %d not in range\n", t); return 1; } dev.table[t].type = resp[i+1]; dev.table[t].start = bige(&resp[i+4]); } dev.table[0].start = 0; dev.table[0].size = dev.table[ft].start; for(i=1; i<ft; i++) { dev.table[i].start = dev.table[ft].start; dev.table[i].size = 0; } for(i=lt+1; i<Ntrack; i++) { dev.table[i].start = dev.table[Maxtrack].start; dev.table[i].size = 0; } for(i=ft; i<=lt; i++) { if(dev.table[i].start == -1) { print("table %d not in toc\n", i); return 1; } dev.table[i].size = dev.table[i+1].start - dev.table[i].start; } if(dev.table[Maxtrack].start == -1) { print("table %d not in toc\n", Maxtrack); return 1; } dev.firsttrack = ft; dev.lasttrack = lt; return 0; } int tmodeset(int bs) { uchar cmd[6], resp[28]; memset(cmd, 0, sizeof(cmd)); cmd[0] = 0x15; /* mode select */ cmd[1] = 0x10; cmd[4] = sizeof(resp); memset(resp, 0, sizeof(resp)); resp[3] = 8; resp[4] = 0x82; resp[8] = bs>>24; resp[9] = bs>>16; resp[10] = bs>>8; resp[11] = bs>>0; resp[12] = 2; /* mode select page 2 */ resp[13] = 0xe; /* length of page 2 */ resp[14] = 0x6f; /* reconnect after 16 blocks of data */ if(scsi(dev.chan, cmd, sizeof(cmd), resp, sizeof(resp), 1) != sizeof(resp)) { print("scsi mode select\n"); return 1; } return 0; }
1.523438
2
src/media/third_party/chromium_media/media/base/decoder_buffer.h
fabio-d/fuchsia-stardock
5
7999107
// Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_BASE_DECODER_BUFFER_H_ #define MEDIA_BASE_DECODER_BUFFER_H_ #include <vector> #include "media/base/decrypt_config.h" #include <lib/fit/defer.h> #include <lib/media/codec_impl/codec_buffer.h> namespace media { class DecoderBuffer { public: explicit DecoderBuffer(std::vector<uint8_t> data, const CodecBuffer* maybe_codec_buffer, uint32_t buffer_start_offset, fit::deferred_callback return_input_packet) : data_(std::move(data)), maybe_codec_buffer_(maybe_codec_buffer), buffer_start_offset_(buffer_start_offset), return_input_packet_(std::move(return_input_packet)) { ZX_DEBUG_ASSERT(!!maybe_codec_buffer_ == !!return_input_packet_); } explicit DecoderBuffer(std::vector<uint8_t> data) : data_(std::move(data)) { ZX_DEBUG_ASSERT(!!maybe_codec_buffer_ == !!return_input_packet_); } const uint8_t* data() const { return data_.data(); } size_t data_size() const { return data_.size(); } const uint8_t* side_data() const { return side_data_.get(); } size_t side_data_size() const { return side_data_size_; } const DecryptConfig* decrypt_config() const { return nullptr; } const CodecBuffer* codec_buffer() const { return maybe_codec_buffer_; } uint32_t buffer_start_offset() const { return buffer_start_offset_; } private: std::vector<uint8_t> data_; // If codec_buffer_, the data_ is also available at codec_buffer_.base() + // buffer_start_offset_ and potentially at codec_buffer_.phys_base() + // buffer_start_offset_. const CodecBuffer* maybe_codec_buffer_ = nullptr; // If codec_buffer_, this is the offset at which data_ starts within // codec_buffer_. uint32_t buffer_start_offset_ = 0; // If codec_buffer_, ~return_input_packet_ will recycle the input packet, so // the portion of codec_buffer_ can be re-used. fit::deferred_callback return_input_packet_; // Side data. Used for alpha channel in VPx, and for text cues. size_t side_data_size_; std::unique_ptr<uint8_t[]> side_data_; }; } // namespace media #endif // MEDIA_BASE_DECODER_BUFFER_H_
1.414063
1
src/ubus_map/ubus_map_tch.c
TechnicolorEDGM/libmultiap_platform
2
7999115
/************* COPYRIGHT AND CONFIDENTIALITY INFORMATION NOTICE ************* ** Copyright (c) [2019] – [Technicolor Delivery Technologies, SAS] * ** All Rights Reserved * ** The source code form of this Open Source Project components * ** is subject to the terms of the BSD-2-Clause-Patent. * ** You can redistribute it and/or modify it under the terms of * ** the BSD-2-Clause-Patent. (https://opensource.org/licenses/BSDplusPatent) * ** See COPYING file/LICENSE file for more details. * ****************************************************************************/ /* * Copyright (C) 2012 <NAME> <<EMAIL>> * Copyright (C) 2012 <NAME> <<EMAIL>> * Copyright (C) 2016 <NAME> <<EMAIL>> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <unistd.h> #include <libubus.h> #include <libubox/blobmsg.h> #include <libubox/blobmsg_json.h> #include <lauxlib.h> #include <lua.h> #define MODNAME "libubus_map_tch" #define METANAME MODNAME ".meta" static lua_State *state; struct ubus_lua_connection { int timeout; struct blob_buf buf; struct ubus_context *ctx; }; struct ubus_lua_object { struct ubus_object o; int r; int rsubscriber; }; struct ubus_lua_event { struct ubus_event_handler e; int r; }; struct ubus_lua_subscriber { struct ubus_subscriber s; int rnotify; int rremove; }; static struct ubus_context *connect = NULL; static int ubus_lua_parse_blob(lua_State *L, struct blob_attr *attr, bool table); static int ubus_lua_parse_blob_array(lua_State *L, struct blob_attr *attr, int len, bool table) { int rv; int idx = 1; int rem = len; struct blob_attr *pos; lua_newtable(L); __blob_for_each_attr(pos, attr, rem) { rv = ubus_lua_parse_blob(L, pos, table); if (rv > 1) lua_rawset(L, -3); else if (rv > 0) lua_rawseti(L, -2, idx++); } return 1; } static int ubus_lua_parse_blob(lua_State *L, struct blob_attr *attr, bool table) { int len; int off = 0; void *data; if (!blobmsg_check_attr(attr, false)) return 0; if (table && blobmsg_name(attr)[0]) { lua_pushstring(L, blobmsg_name(attr)); off++; } data = blobmsg_data(attr); len = blobmsg_data_len(attr); switch (blob_id(attr)) { case BLOBMSG_TYPE_BOOL: lua_pushboolean(L, *(uint8_t *)data); break; case BLOBMSG_TYPE_INT16: lua_pushinteger(L, be16_to_cpu(*(uint16_t *)data)); break; case BLOBMSG_TYPE_INT32: lua_pushinteger(L, be32_to_cpu(*(uint32_t *)data)); break; case BLOBMSG_TYPE_INT64: lua_pushnumber(L, (double) be64_to_cpu(*(uint64_t *)data)); break; case BLOBMSG_TYPE_STRING: lua_pushstring(L, data); break; case BLOBMSG_TYPE_ARRAY: ubus_lua_parse_blob_array(L, data, len, false); break; case BLOBMSG_TYPE_TABLE: ubus_lua_parse_blob_array(L, data, len, true); break; default: lua_pushnil(L); break; } return off + 1; } static bool ubus_lua_format_blob_is_array(lua_State *L) { lua_Integer prv = 0; lua_Integer cur = 0; /* Find out whether table is array-like */ for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { #ifdef LUA_TINT if (lua_type(L, -2) != LUA_TNUMBER && lua_type(L, -2) != LUA_TINT) #else if (lua_type(L, -2) != LUA_TNUMBER) #endif { lua_pop(L, 2); return false; } cur = lua_tointeger(L, -2); if ((cur - 1) != prv) { lua_pop(L, 2); return false; } prv = cur; } return true; } static int ubus_lua_format_blob_array(lua_State *L, struct blob_buf *b, bool table); static int ubus_lua_format_blob(lua_State *L, struct blob_buf *b, bool table) { void *c; bool rv = true; const char *key = table ? lua_tostring(L, -2) : NULL; switch (lua_type(L, -1)) { case LUA_TBOOLEAN: blobmsg_add_u8(b, key, (uint8_t)lua_toboolean(L, -1)); break; #ifdef LUA_TINT case LUA_TINT: #endif case LUA_TNUMBER: blobmsg_add_u32(b, key, (uint32_t)lua_tointeger(L, -1)); break; case LUA_TSTRING: case LUA_TUSERDATA: case LUA_TLIGHTUSERDATA: blobmsg_add_string(b, key, lua_tostring(L, -1)); break; case LUA_TTABLE: if (ubus_lua_format_blob_is_array(L)) { c = blobmsg_open_array(b, key); rv = ubus_lua_format_blob_array(L, b, false); blobmsg_close_array(b, c); } else { c = blobmsg_open_table(b, key); rv = ubus_lua_format_blob_array(L, b, true); blobmsg_close_table(b, c); } break; default: rv = false; break; } return rv; } static int ubus_lua_format_blob_array(lua_State *L, struct blob_buf *b, bool table) { for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { if (!ubus_lua_format_blob(L, b, table)) { lua_pop(L, 1); return false; } } return true; } static int ubus_lua_connect(lua_State *L) { struct ubus_lua_connection *c; const char *sockpath = luaL_optstring(L, 1, NULL); int timeout = luaL_optint(L, 2, 30); if ((c = lua_newuserdata(L, sizeof(*c))) != NULL && (c->ctx = ubus_connect(sockpath)) != NULL) { ubus_add_uloop(c->ctx); c->timeout = timeout; memset(&c->buf, 0, sizeof(c->buf)); luaL_getmetatable(L, METANAME); lua_setmetatable(L, -2); return 1; } /* NB: no errors from ubus_connect() yet */ lua_pushnil(L); lua_pushinteger(L, UBUS_STATUS_UNKNOWN_ERROR); return 2; } static int ubus_lua_connect_tch(lua_State *L) { struct ubus_lua_connection *c; int timeout = luaL_optint(L, 2, 30); lua_getglobal(L, "connect"); void *ctx = lua_touserdata(L, -1); connect = (struct ubus_context *)ctx; if (connect == NULL) { lua_pushnil(L); lua_pushstring( L, "CONNECT NULL" ); return 2; } if ((c = lua_newuserdata(L, sizeof(*c))) != NULL && (connect != NULL)) { c->ctx = connect; c->timeout = timeout; memset(&c->buf, 0, sizeof(c->buf)); luaL_getmetatable(L, METANAME); lua_setmetatable(L, -2); return 1; } /* NB: no errors from ubus_connect() yet */ lua_pushnil(L); lua_pushinteger(L, UBUS_STATUS_UNKNOWN_ERROR); return 2; } static void ubus_lua_objects_cb(struct ubus_context *c, struct ubus_object_data *o, void *p) { lua_State *L = (lua_State *)p; lua_pushstring(L, o->path); lua_rawseti(L, -2, lua_objlen(L, -2) + 1); } static int ubus_lua_objects(lua_State *L) { int rv; struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); lua_newtable(L); rv = ubus_lookup(c->ctx, NULL, ubus_lua_objects_cb, L); if (rv != UBUS_STATUS_OK) { lua_pop(L, 1); lua_pushnil(L); lua_pushinteger(L, rv); return 2; } return 1; } static int ubus_method_handler(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { struct ubus_lua_object *o = container_of(obj, struct ubus_lua_object, o); int rv = 0; lua_getglobal(state, "__ubus_cb"); lua_rawgeti(state, -1, o->r); lua_getfield(state, -1, method); lua_remove(state, -2); lua_remove(state, -2); if (lua_isfunction(state, -1)) { lua_pushlightuserdata(state, req); if (!msg) lua_pushnil(state); else ubus_lua_parse_blob_array(state, blob_data(msg), blob_len(msg), true); lua_call(state, 2, 1); if (lua_isnumber(state, -1)) rv = lua_tonumber(state, -1); } lua_pop(state, 1); return rv; } static int lua_gettablelen(lua_State *L, int index) { int cnt = 0; lua_pushnil(L); index -= 1; while (lua_next(L, index) != 0) { cnt++; lua_pop(L, 1); } return cnt; } static int ubus_lua_reply(lua_State *L) { struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); struct ubus_request_data *req; luaL_checktype(L, 3, LUA_TTABLE); blob_buf_init(&c->buf, 0); if (!ubus_lua_format_blob_array(L, &c->buf, true)) { lua_pushnil(L); lua_pushinteger(L, UBUS_STATUS_INVALID_ARGUMENT); return 2; } req = lua_touserdata(L, 2); ubus_send_reply(c->ctx, req, c->buf.head); return 0; } static int ubus_lua_defer_request(lua_State *L) { struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); struct ubus_request_data *req = lua_touserdata(L, 2); struct ubus_request_data *new_req = lua_newuserdata(L, sizeof(struct ubus_request_data)); ubus_defer_request(c->ctx, req, new_req); return 1; } static int ubus_lua_complete_deferred_request(lua_State *L) { struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); struct ubus_request_data *req = lua_touserdata(L, 2); int ret = luaL_checkinteger(L, 3); ubus_complete_deferred_request(c->ctx, req, ret); return 0; } static int ubus_lua_load_methods(lua_State *L, struct ubus_method *m) { struct blobmsg_policy *p; int plen; int pidx = 0; /* get the function pointer */ lua_pushinteger(L, 1); lua_gettable(L, -2); /* get the policy table */ lua_pushinteger(L, 2); lua_gettable(L, -3); /* check if the method table is valid */ if ((lua_type(L, -2) != LUA_TFUNCTION) || (lua_type(L, -1) != LUA_TTABLE) || lua_objlen(L, -1)) { lua_pop(L, 2); return 1; } /* store function pointer */ lua_pushvalue(L, -2); lua_setfield(L, -6, lua_tostring(L, -5)); m->name = lua_tostring(L, -4); m->handler = ubus_method_handler; plen = lua_gettablelen(L, -1); /* exit if policy table is empty */ if (!plen) { lua_pop(L, 2); return 0; } /* setup the policy pointers */ p = calloc(plen, sizeof(struct blobmsg_policy)); if (!p) return 1; m->policy = p; lua_pushnil(L); while (lua_next(L, -2) != 0) { int val = lua_tointeger(L, -1); /* check if the policy is valid */ if ((lua_type(L, -2) != LUA_TSTRING) || (lua_type(L, -1) != LUA_TNUMBER) || (val < 0) || (val > BLOBMSG_TYPE_LAST)) { lua_pop(L, 1); continue; } p[pidx].name = lua_tostring(L, -2); p[pidx].type = val; lua_pop(L, 1); pidx++; } m->n_policy = pidx; lua_pop(L, 2); return 0; } static void ubus_new_sub_cb(struct ubus_context *ctx, struct ubus_object *obj) { struct ubus_lua_object *luobj; luobj = container_of(obj, struct ubus_lua_object, o); lua_getglobal(state, "__ubus_cb_publisher"); lua_rawgeti(state, -1, luobj->rsubscriber); lua_remove(state, -2); if (lua_isfunction(state, -1)) { lua_pushnumber(state, luobj->o.has_subscribers ); lua_call(state, 1, 0); } else { lua_pop(state, 1); } } static void ubus_lua_load_newsub_cb( lua_State *L, struct ubus_lua_object *obj ) { /* keep ref to func */ lua_getglobal(L, "__ubus_cb_publisher"); lua_pushvalue(L, -2); obj->rsubscriber = luaL_ref(L, -2); lua_pop(L, 1); /* real callback */ obj->o.subscribe_cb = ubus_new_sub_cb; return; } static struct ubus_object* ubus_lua_load_object(lua_State *L) { struct ubus_lua_object *obj = NULL; int mlen = lua_gettablelen(L, -1); struct ubus_method *m; int midx = 0; /* setup object pointers */ obj = calloc(1, sizeof(struct ubus_lua_object)); if (!obj) return NULL; obj->o.name = lua_tostring(L, -2); /* setup method pointers */ m = calloc(mlen, sizeof(struct ubus_method)); obj->o.methods = m; /* setup type pointers */ obj->o.type = calloc(1, sizeof(struct ubus_object_type)); if (!obj->o.type) { free(obj); return NULL; } obj->o.type->name = lua_tostring(L, -2); obj->o.type->id = 0; obj->o.type->methods = obj->o.methods; /* create the callback lookup table */ lua_createtable(L, 1, 0); lua_getglobal(L, "__ubus_cb"); lua_pushvalue(L, -2); obj->r = luaL_ref(L, -2); lua_pop(L, 1); /* scan each method */ lua_pushnil(L); while (lua_next(L, -3) != 0) { /* check if its the subscriber notification callback */ if( lua_type( L, -2 ) == LUA_TSTRING && lua_type( L, -1 ) == LUA_TFUNCTION ){ if( !strcmp( lua_tostring( L, -2 ), "__subscriber_cb" ) ) ubus_lua_load_newsub_cb( L, obj ); } /* check if it looks like a method */ if ((lua_type(L, -2) != LUA_TSTRING) || (lua_type(L, -1) != LUA_TTABLE) || !lua_objlen(L, -1)) { lua_pop(L, 1); continue; } if (!ubus_lua_load_methods(L, &m[midx])) midx++; lua_pop(L, 1); } obj->o.type->n_methods = obj->o.n_methods = midx; /* pop the callback table */ lua_pop(L, 1); return &obj->o; } static int ubus_lua_add(lua_State *L) { struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); /* verify top level object */ if (lua_istable(L, 1)) { lua_pushstring(L, "you need to pass a table"); lua_error(L); return 0; } /* scan each object */ lua_pushnil(L); while (lua_next(L, -2) != 0) { struct ubus_object *obj = NULL; /* check if the object has a table of methods */ if ((lua_type(L, -2) == LUA_TSTRING) && (lua_type(L, -1) == LUA_TTABLE)) { obj = ubus_lua_load_object(L); if (obj){ ubus_add_object(c->ctx, obj); /* allow future reference of ubus obj */ lua_pushstring(state,"__ubusobj"); lua_pushlightuserdata(state, obj); lua_settable(state,-3); } } lua_pop(L, 1); } return 0; } static int ubus_lua_notify( lua_State *L ) { struct ubus_lua_connection *c; struct ubus_object *obj; const char* method; c = luaL_checkudata(L, 1, METANAME); method = luaL_checkstring(L, 3); luaL_checktype(L, 4, LUA_TTABLE); if( !lua_islightuserdata( L, 2 ) ){ lua_pushfstring( L, "Invald 2nd parameter, expected ubus obj ref" ); lua_error( L ); } obj = lua_touserdata( L, 2 ); /* create parameters from table */ blob_buf_init(&c->buf, 0); if( !ubus_lua_format_blob_array( L, &c->buf, true ) ){ lua_pushfstring( L, "Invalid 4th parameter, expected table of arguments" ); lua_error( L ); } ubus_notify( c->ctx, obj, method, c->buf.head, -1 ); return 0; } static void ubus_lua_signatures_cb(struct ubus_context *c, struct ubus_object_data *o, void *p) { lua_State *L = (lua_State *)p; if (!o->signature) return; ubus_lua_parse_blob_array(L, blob_data(o->signature), blob_len(o->signature), true); } static int ubus_lua_signatures(lua_State *L) { int rv; struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); const char *path = luaL_checkstring(L, 2); rv = ubus_lookup(c->ctx, path, ubus_lua_signatures_cb, L); if (rv != UBUS_STATUS_OK) { lua_pop(L, 1); lua_pushnil(L); lua_pushinteger(L, rv); return 2; } return 1; } static void ubus_lua_call_cb(struct ubus_request *req, int type, struct blob_attr *msg) { lua_State *L = (lua_State *)req->priv; if (!msg && L) lua_pushnil(L); if (msg && L) ubus_lua_parse_blob_array(L, blob_data(msg), blob_len(msg), true); } static int ubus_lua_call(lua_State *L) { int rv, top; uint32_t id; struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); const char *path = luaL_checkstring(L, 2); const char *func = luaL_checkstring(L, 3); luaL_checktype(L, 4, LUA_TTABLE); blob_buf_init(&c->buf, 0); if (!ubus_lua_format_blob_array(L, &c->buf, true)) { lua_pushnil(L); lua_pushinteger(L, UBUS_STATUS_INVALID_ARGUMENT); return 2; } rv = ubus_lookup_id(c->ctx, path, &id); if (rv) { lua_pushnil(L); lua_pushinteger(L, rv); return 2; } top = lua_gettop(L); rv = ubus_invoke(c->ctx, id, func, c->buf.head, ubus_lua_call_cb, L, c->timeout * 1000); if (rv != UBUS_STATUS_OK) { lua_pop(L, 1); lua_pushnil(L); lua_pushinteger(L, rv); return 2; } return lua_gettop(L) - top; } static void ubus_event_handler(struct ubus_context *ctx, struct ubus_event_handler *ev, const char *type, struct blob_attr *msg) { struct ubus_lua_event *listener = container_of(ev, struct ubus_lua_event, e); lua_getglobal(state, "__ubus_cb_event"); lua_rawgeti(state, -1, listener->r); lua_remove(state, -2); if (lua_isfunction(state, -1)) { ubus_lua_parse_blob_array(state, blob_data(msg), blob_len(msg), true); lua_call(state, 1, 0); } else { lua_pop(state, 1); } } static struct ubus_event_handler* ubus_lua_load_event(lua_State *L) { struct ubus_lua_event* event = NULL; event = calloc(1, sizeof(struct ubus_lua_event)); if (!event) return NULL; event->e.cb = ubus_event_handler; /* update the he callback lookup table */ lua_getglobal(L, "__ubus_cb_event"); lua_pushvalue(L, -2); event->r = luaL_ref(L, -2); lua_setfield(L, -1, lua_tostring(L, -3)); return &event->e; } static int ubus_lua_listen(lua_State *L) { struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); /* verify top level object */ luaL_checktype(L, 2, LUA_TTABLE); /* scan each object */ lua_pushnil(L); while (lua_next(L, -2) != 0) { struct ubus_event_handler *listener; /* check if the key is a string and the value is a method */ if ((lua_type(L, -2) == LUA_TSTRING) && (lua_type(L, -1) == LUA_TFUNCTION)) { listener = ubus_lua_load_event(L); if(listener != NULL) { ubus_register_event_handler(c->ctx, listener, lua_tostring(L, -2)); } } lua_pop(L, 1); } return 0; } static void ubus_sub_remove_handler(struct ubus_context *ctx, struct ubus_subscriber *s, uint32_t id) { struct ubus_lua_subscriber *sub; sub = container_of(s, struct ubus_lua_subscriber, s); lua_getglobal(state, "__ubus_cb_subscribe"); lua_rawgeti(state, -1, sub->rremove); lua_remove(state, -2); if (lua_isfunction(state, -1)) { lua_call(state, 0, 0); } else { lua_pop(state, 1); } } static int ubus_sub_notify_handler(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { struct ubus_subscriber *s; struct ubus_lua_subscriber *sub; s = container_of(obj, struct ubus_subscriber, obj); sub = container_of(s, struct ubus_lua_subscriber, s); lua_getglobal(state, "__ubus_cb_subscribe"); lua_rawgeti(state, -1, sub->rnotify); lua_remove(state, -2); if (lua_isfunction(state, -1)) { if( msg ){ ubus_lua_parse_blob_array(state, blob_data(msg), blob_len(msg), true); } else { lua_pushnil(state); } lua_pushstring(state, method); lua_call(state, 2, 0); } else { lua_pop(state, 1); } return 0; } static void ubus_lua_do_subscribe( struct ubus_context *ctx, lua_State *L, const char* target, int idxnotify, int idxremove ) { uint32_t id; int status; struct ubus_lua_subscriber *sub; if( ( status = ubus_lookup_id( ctx, target, &id ) ) ){ lua_pushfstring( L, "Unable find target, status=%d", status ); lua_error( L ); } sub = calloc( 1, sizeof( struct ubus_lua_subscriber ) ); if( !sub ){ lua_pushstring( L, "Out of memory" ); lua_error( L ); } if( idxnotify ){ lua_getglobal(L, "__ubus_cb_subscribe"); lua_pushvalue(L, idxnotify); sub->rnotify = luaL_ref(L, -2); lua_pop(L, 1); sub->s.cb = ubus_sub_notify_handler; } if( idxremove ){ lua_getglobal(L, "__ubus_cb_subscribe"); lua_pushvalue(L, idxnotify); sub->rnotify = luaL_ref(L, -2); lua_pop(L, 1); sub->s.remove_cb = ubus_sub_remove_handler; } if( ( status = ubus_register_subscriber( ctx, &sub->s ) ) ){ lua_pushfstring( L, "Failed to register subscriber, status=%d", status ); lua_error( L ); } if( ( status = ubus_subscribe( ctx, &sub->s, id) ) ){ lua_pushfstring( L, "Failed to register subscriber, status=%d", status ); lua_error( L ); } } static int ubus_lua_subscribe(lua_State *L) { int idxnotify, idxremove, stackstart; struct ubus_lua_connection *c; const char* target; idxnotify = idxremove = 0; stackstart = lua_gettop( L ); c = luaL_checkudata(L, 1, METANAME); target = luaL_checkstring(L, 2); luaL_checktype(L, 3, LUA_TTABLE); lua_pushstring( L, "notify"); lua_gettable( L, 3 ); if( lua_type( L, -1 ) == LUA_TFUNCTION ){ idxnotify = lua_gettop( L ); } else { lua_pop( L, 1 ); } lua_pushstring( L, "remove"); lua_gettable( L, 3 ); if( lua_type( L, -1 ) == LUA_TFUNCTION ){ idxremove = lua_gettop( L ); } else { lua_pop( L, 1 ); } if( idxnotify ) ubus_lua_do_subscribe( c->ctx, L, target, idxnotify, idxremove ); if( lua_gettop( L ) > stackstart ) lua_pop( L, lua_gettop( L ) - stackstart ); return 0; } static int ubus_lua_send(lua_State *L) { struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); const char *event = luaL_checkstring(L, 2); if (*event == 0) return luaL_argerror(L, 2, "no event name"); // Event content convert to ubus form luaL_checktype(L, 3, LUA_TTABLE); blob_buf_init(&c->buf, 0); if (!ubus_lua_format_blob_array(L, &c->buf, true)) { lua_pushnil(L); lua_pushinteger(L, UBUS_STATUS_INVALID_ARGUMENT); return 2; } // Send the event ubus_send_event(c->ctx, event, c->buf.head); return 0; } static int ubus_lua__gc(lua_State *L) { struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); lua_getglobal(L, "connect"); void *ctx = lua_touserdata(L, -1); connect = (struct ubus_context *)ctx; blob_buf_free(&c->buf); if (c->ctx != NULL) { /* This check is added to see if the UBUS connect happened with an existing context in case of monitor thread, in which case it should not be freed Rather the free will be done by monitor thread */ if(connect == NULL) { ubus_free(c->ctx); } memset(c, 0, sizeof(*c)); } return 0; } static const luaL_Reg ubus[] = { { "connect", ubus_lua_connect }, { "connecttch", ubus_lua_connect_tch }, { "objects", ubus_lua_objects }, { "add", ubus_lua_add }, { "notify", ubus_lua_notify }, { "reply", ubus_lua_reply }, { "defer_request", ubus_lua_defer_request }, { "complete_deferred_request", ubus_lua_complete_deferred_request }, { "signatures", ubus_lua_signatures }, { "call", ubus_lua_call }, { "close", ubus_lua__gc }, { "listen", ubus_lua_listen }, { "send", ubus_lua_send }, { "subscribe", ubus_lua_subscribe }, { "__gc", ubus_lua__gc }, { NULL, NULL }, }; /* avoid missing prototype warning */ int luaopen_ubus(lua_State *L); int luaopen_libubus_map_tch(lua_State *L) { /* create metatable */ luaL_newmetatable(L, METANAME); /* metatable.__index = metatable */ lua_pushvalue(L, -1); lua_setfield(L, -2, "__index"); /* fill metatable */ luaL_register(L, NULL, ubus); lua_pop(L, 1); /* create module */ luaL_register(L, MODNAME, ubus); /* set some enum defines */ lua_pushinteger(L, BLOBMSG_TYPE_ARRAY); lua_setfield(L, -2, "ARRAY"); lua_pushinteger(L, BLOBMSG_TYPE_TABLE); lua_setfield(L, -2, "TABLE"); lua_pushinteger(L, BLOBMSG_TYPE_STRING); lua_setfield(L, -2, "STRING"); lua_pushinteger(L, BLOBMSG_TYPE_INT64); lua_setfield(L, -2, "INT64"); lua_pushinteger(L, BLOBMSG_TYPE_INT32); lua_setfield(L, -2, "INT32"); lua_pushinteger(L, BLOBMSG_TYPE_INT16); lua_setfield(L, -2, "INT16"); lua_pushinteger(L, BLOBMSG_TYPE_INT8); lua_setfield(L, -2, "INT8"); lua_pushinteger(L, BLOBMSG_TYPE_BOOL); lua_setfield(L, -2, "BOOLEAN"); /* used in our callbacks */ state = L; /* create the callback table */ lua_createtable(L, 1, 0); lua_setglobal(L, "__ubus_cb"); /* create the event table */ lua_createtable(L, 1, 0); lua_setglobal(L, "__ubus_cb_event"); /* create the subscriber table */ lua_createtable(L, 1, 0); lua_setglobal(L, "__ubus_cb_subscribe"); /* create the publisher table - notifications of new subs */ lua_createtable(L, 1, 0); lua_setglobal(L, "__ubus_cb_publisher"); return 0; }
1.476563
1
src/Util/Joystick.h
roto5296/choreonoid
91
7999123
/*! @file @author <NAME> */ #ifndef CNOID_UTIL_JOYSTICK_H #define CNOID_UTIL_JOYSTICK_H #include "JoystickInterface.h" #include "Signal.h" #include <string> #include "exportdecl.h" namespace cnoid { class JoystickImpl; class CNOID_EXPORT Joystick : public JoystickInterface { public: Joystick(); Joystick(const char* device); virtual ~Joystick(); std::string device() const; int fileDescriptor() const; bool makeReady(); bool isReady() const; const char* errorMessage() const; enum AxisID { L_STICK_H_AXIS, L_STICK_V_AXIS, R_STICK_H_AXIS, R_STICK_V_AXIS, DIRECTIONAL_PAD_H_AXIS, DIRECTIONAL_PAD_V_AXIS, L_TRIGGER_AXIS, R_TRIGGER_AXIS, NUM_STD_AXES }; enum ButtonID { A_BUTTON, // Cross B_BUTTON, // Circle X_BUTTON, // Square Y_BUTTON, // Triangle L_BUTTON, R_BUTTON, SELECT_BUTTON, START_BUTTON, L_STICK_BUTTON, R_STICK_BUTTON, LOGO_BUTTON, NUM_STD_BUTTONS }; virtual int numAxes() const override; virtual int numButtons() const override; virtual bool readCurrentState() override; virtual double getPosition(int axis) const override; virtual bool getButtonState(int button) const override; void setAxisEnabled(int axis, bool on); //! \deprecated //double getDefaultPosition(int axis) const; #ifdef __linux__ bool getButtonDown(int button) const; bool getButtonUp(int button) const; bool getButtonHold(int button, int duration/*(msec)*/) const; bool getButtonHoldOn(int button, int duration/*(msec)*/) const; #endif bool isActive() const; SignalProxy<void(int id, bool isPressed)> sigButton(); SignalProxy<void(int id, double position)> sigAxis(); private: JoystickImpl* impl; friend class JoystickImpl; }; } #endif
1.117188
1
import/chips/p9/procedures/ppe_closed/cme/stop_cme/p9_cme_stop_irq_handlers.c
ibm-op-release/hcode
0
7999131
/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: import/chips/p9/procedures/ppe_closed/cme/stop_cme/p9_cme_stop_irq_handlers.c $ */ /* */ /* OpenPOWER HCODE Project */ /* */ /* COPYRIGHT 2015,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ /* You may obtain a copy of the License at */ /* */ /* http://www.apache.org/licenses/LICENSE-2.0 */ /* */ /* Unless required by applicable law or agreed to in writing, software */ /* distributed under the License is distributed on an "AS IS" BASIS, */ /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ /* implied. See the License for the specific language governing */ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ #include "p9_cme_stop.h" #include "p9_cme_stop_enter_marks.h" #include "qppm_register_addresses.h" #include "qppm_firmware_registers.h" #include "p9_cme_irq.h" #include "p9_cme_pstate.h" extern CmeStopRecord G_cme_stop_record; extern CmePstateRecord G_cme_pstate_record; extern CmeRecord G_cme_record; #if DISABLE_STOP8 uint8_t G_ndd20_disable_stop8_abort_stop11_rclk_handshake_flag = 0; #endif void p9_cme_stop_pcwu_handler(void) { uint32_t core_mask = 0; uint32_t core = (in32(G_CME_LCL_EISR) & BITS32(12, 2)) >> SHIFT32(13); data64_t scom_data = {0}; ppm_pig_t pig = {0}; MARK_TRAP(STOP_PCWU_HANDLER) PK_TRACE_INF("PCWU Handler Trigger: Core Interrupts %x", core); // consider wakeup is done on a running core // also ignore the decrementor request that already sent to sgpe core &= ~(G_cme_stop_record.core_running | G_cme_stop_record.core_blockpc); out32(G_CME_LCL_EISR_CLR, (G_cme_stop_record.core_running << SHIFT32(13))); for (core_mask = 2; core_mask; core_mask--) { if (core & core_mask) { CME_GETSCOM(CPPM_CPMMR, core_mask, scom_data.value); // If notify_select == sgpe if (scom_data.words.upper & BIT32(13)) { // In stop5 as using type2, send exit pig if (!(scom_data.words.upper & BIT32(10))) { pig.fields.req_intr_type = PIG_TYPE2; pig.fields.req_intr_payload = TYPE2_PAYLOAD_DECREMENTER_WAKEUP; send_pig_packet(pig.value, core_mask); } // block pc for stop8,11 or stop5 as pig sent G_cme_stop_record.core_blockpc |= core_mask; core = core - core_mask; } } } // if still wakeup for core with notify_select == cme, go exit if (core) { PK_TRACE_INF("PCWU Launching exit thread"); out32(G_CME_LCL_EIMR_OR, BITS32(12, 10)); g_eimr_override |= BITS64(12, 10); G_cme_stop_record.exit_ongoing = 1; wrteei(1); // The actual exit sequence p9_cme_stop_exit(); G_cme_stop_record.exit_ongoing = 0; } // in case abort, complete pending entry first if (!G_cme_stop_record.entry_ongoing) { // re-evaluate stop entry & exit enables p9_cme_stop_eval_eimr_override(); } } // When take an Interrupt on falling edge of SPWU from a CPPM. // 1) Read EINR to check if another one has been set // in the meantime from the same core. If so abort. // 2) Clear Special Wakeup Done to that CPPM. // 3) Read GPMMR[1] to see if any Special Wakeup has been sent to active // in the meantime. If so, set Special Wakeup Done again and abort. // 4) Otherwise flip polarity of Special Wakeup in EISR and clear PM_EXIT // (note for abort cases do not Do not flip polarity of Special Wakeup in EISR.) void p9_cme_stop_spwu_handler(void) { int spwu_rise = 0; uint32_t core_mask = 0; uint32_t core_index = 0; uint32_t raw_spwu = (in32(G_CME_LCL_EISR) & BITS32(14, 2)) >> SHIFT32(15); uint64_t scom_data = 0; MARK_TRAP(STOP_SPWU_HANDLER) PK_TRACE_INF("SPWU Handler Trigger: Core Interrupts %x SPWU States %x", raw_spwu, G_cme_stop_record.core_in_spwu); for(core_mask = 2; core_mask; core_mask--) { if (raw_spwu & core_mask) { core_index = core_mask & 1; PK_TRACE("Detect SPWU signal level change on core%d", core_index); // if falling edge == spwu drop: if (G_cme_stop_record.core_in_spwu & core_mask) { if (in32(G_CME_LCL_FLAGS) & BIT32(CME_FLAGS_SPWU_CHECK_ENABLE)) { CME_GETSCOM(PPM_SSHSRC, core_mask, scom_data); if ((scom_data & BIT64(0)) || ((~scom_data) & BIT64(1))) { PK_TRACE_ERR("Protocol Error[0]: SPWU Dropped when STOP_GATED=1/SPWU_DONE=0, SSH[%d][%x]", core_mask, (uint32_t)(scom_data >> 32)); PK_PANIC(CME_STOP_SPWU_PROTOCOL_ERROR); } } PK_TRACE_INF("Falling edge of SPWU, now clear spwu_done, eisr and flip eipr"); out32(G_CME_LCL_SICR_CLR, BIT32((16 + core_index))); out32(G_CME_LCL_EISR_CLR, BIT32((14 + core_index))); out32(G_CME_LCL_EIPR_OR, BIT32((14 + core_index))); // if spwu has been re-asserted after spwu_done is dropped: if (((in32(G_CME_LCL_EINR))) & BIT32((14 + core_index))) { out32(G_CME_LCL_EISR_CLR, BIT32((14 + core_index))); out32(G_CME_LCL_EIPR_CLR, BIT32((14 + core_index))); out32(G_CME_LCL_SICR_OR, BIT32((16 + core_index))); PK_TRACE_INF("SPWU asserts again, clear eisr, flip eipr, re-assert spwu_done"); } // if spwu truly dropped: else { out32(G_CME_LCL_SICR_CLR, BIT32((4 + core_index))); PK_TRACE_INF("SPWU drop confirmed, now drop pm_exit"); // Core is now out of spwu, allow pm_active // block entry mode is handled via eimr override G_cme_stop_record.core_in_spwu &= ~core_mask; // if in block entry mode, do not release the mask if (!(G_cme_stop_record.core_blockey & core_mask)) { // use 32 bit UPPER mask to prevent compiler from doing 64-bit shifting g_eimr_override &= ((uint64_t)~((IRQ_VEC_STOP_C0_UPPER) >> core_index)) << 32 | 0xFFFFFFFF; } } } // rising edge, do not clear EISR since thread will read and clear: // block wakeup mode is handled in the thread and eimr override else { PK_TRACE("Rising edge of spwu, clear EISR later in exit thread"); spwu_rise = 1; } } } if (spwu_rise) { PK_TRACE_INF("SPWU Launching exit thread"); out32(G_CME_LCL_EIMR_OR, BITS32(12, 10)); g_eimr_override |= BITS64(12, 10); G_cme_stop_record.exit_ongoing = 1; wrteei(1); // The actual exit sequence p9_cme_stop_exit(); G_cme_stop_record.exit_ongoing = 0; } // in case abort, complete pending entry first if (!G_cme_stop_record.entry_ongoing) { // re-evaluate stop entry & exit enables p9_cme_stop_eval_eimr_override(); } } void p9_cme_stop_rgwu_handler(void) { MARK_TRAP(STOP_RGWU_HANDLER) PK_TRACE_INF("RGWU Handler Trigger"); out32(G_CME_LCL_EIMR_OR, BITS32(12, 10)); g_eimr_override |= BITS64(12, 10); G_cme_stop_record.exit_ongoing = 1; wrteei(1); // The actual exit sequence p9_cme_stop_exit(); G_cme_stop_record.exit_ongoing = 0; // in case abort, complete pending entry first if (!G_cme_stop_record.entry_ongoing) { // re-evaluate stop entry & exit enables p9_cme_stop_eval_eimr_override(); } } void p9_cme_stop_enter_handler(void) { MARK_TRAP(STOP_ENTER_HANDLER) PK_TRACE_INF("PM_ACTIVE Handler Trigger"); // Abort Protection out32(G_CME_LCL_EIMR_OR, BITS32(12, 10)); g_eimr_override |= BITS64(12, 10); G_cme_stop_record.entry_ongoing = 1; wrteei(1); // The actual entry sequence p9_cme_stop_entry(); // Restore Abort Protection G_cme_stop_record.entry_ongoing = 0; // re-evaluate stop entry & exit enables p9_cme_stop_eval_eimr_override(); } void p9_cme_stop_db2_handler(void) { cppm_cmedb2_t db2 = {0}; ppm_pig_t pig = {0}; uint32_t core = (in32(G_CME_LCL_EISR) & BITS32(18, 2)) >> SHIFT32(19); uint32_t core_mask; MARK_TRAP(STOP_DB2_HANDLER) PK_TRACE_INF("DB2 Handler Trigger: Core Interrupts %x", core); for(core_mask = 2; core_mask; core_mask--) { if (core & core_mask) { CME_GETSCOM(CPPM_CMEDB2, core_mask, db2.value); CME_PUTSCOM_NOP(CPPM_CMEDB2, core_mask, 0); out32(G_CME_LCL_EISR_CLR, (core_mask << SHIFT32(19))); PK_TRACE_DBG("DB2 Handler MessageID %d Triggered By Core %d", db2.fields.cme_message_numbern, core_mask); switch (db2.fields.cme_message_numbern) { case MSGID_DB2_DECREMENTER_WAKEUP: // unmask pc interrupt pending to wakeup that is still pending G_cme_stop_record.core_blockpc &= ~(core_mask & (~(G_cme_stop_record.core_running))); break; case MSGID_DB2_RESONANT_CLOCK_DISABLE: #if (NIMBUS_DD_LEVEL < 21 || CUMULUS_DD_LEVEL == 10) || DISABLE_STOP8 == 1 #ifdef USE_CME_RESCLK_FEATURE // Quad going into Stop11, need to potentially disable Resclks if((in32(G_CME_LCL_FLAGS) & BIT32(CME_FLAGS_RCLK_OPERABLE)) && G_cme_pstate_record.qmFlag) { p9_cme_resclk_update(ANALOG_COMMON, p9_cme_resclk_get_index(ANALOG_PSTATE_RESCLK_OFF), G_cme_pstate_record.resclkData.common_resclk_idx); // prevent Pstate changes from accidentally re-enabling // in the meantime before interlock with PGPE out32(G_CME_LCL_FLAGS_CLR, BIT32(CME_FLAGS_RCLK_OPERABLE)); // in case we abort, need this flag to get into reenable below G_ndd20_disable_stop8_abort_stop11_rclk_handshake_flag = 1; } #endif #endif // Finish handshake with SGPE for Stop11 via PIG pig.fields.req_intr_type = PIG_TYPE0; pig.fields.req_intr_payload = TYPE0_PAYLOAD_ENTRY_RCLK | STOP_LEVEL_11; //CME_PUTSCOM_NOP(PPM_PIG, core_mask, pig.value); send_pig_packet(pig.value, core_mask); break; case MSGID_DB2_RESONANT_CLOCK_ENABLE: #if (NIMBUS_DD_LEVEL < 21 || CUMULUS_DD_LEVEL == 10) || DISABLE_STOP8 == 1 #ifdef USE_CME_RESCLK_FEATURE // Quad aborted Stop11, need to regressively enable Resclks // IF wakeup from fully entered Stop11, this is done by QM if(((in32(G_CME_LCL_FLAGS) & BIT32(CME_FLAGS_RCLK_OPERABLE)) || G_ndd20_disable_stop8_abort_stop11_rclk_handshake_flag) && G_cme_pstate_record.qmFlag) { p9_cme_resclk_update(ANALOG_COMMON, p9_cme_resclk_get_index(G_cme_pstate_record.quadPstate), G_cme_pstate_record.resclkData.common_resclk_idx); // reenable pstate from changing resonant clock out32(G_CME_LCL_FLAGS_OR, BIT32(CME_FLAGS_RCLK_OPERABLE)); // clear abort flag to start clean slate G_ndd20_disable_stop8_abort_stop11_rclk_handshake_flag = 0; } #endif #endif // Finish handshake with SGPE for Stop11 via PIG pig.fields.req_intr_type = PIG_TYPE0; pig.fields.req_intr_payload = TYPE0_PAYLOAD_EXIT_RCLK; //CME_PUTSCOM_NOP(PPM_PIG, core_mask, pig.value); send_pig_packet(pig.value, core_mask); break; default: break; } } } // re-evaluate stop entry & exit enables p9_cme_stop_eval_eimr_override(); } void p9_cme_stop_db1_handler(void) { cppm_cmedb1_t db1 = {0}; ppm_pig_t pig = {0}; uint32_t core = 0; uint32_t encode = 0; uint32_t suspend_ack = 0; MARK_TRAP(STOP_DB1_HANDLER) PK_TRACE_INF("DB1 Handler Trigger"); // Suspend DB should only come from the first good core core = G_cme_pstate_record.firstGoodCoreMask; CME_GETSCOM(CPPM_CMEDB1, core, db1.value); CME_PUTSCOM_NOP(CPPM_CMEDB1, core, 0); out32_sh(CME_LCL_EISR_CLR, core << SHIFT64SH(41)); PK_TRACE_DBG("DB1 Handler MessageID %d Triggered By Core %d", db1.fields.cme_message_numbern, core); encode = db1.fields.cme_message_numbern & STOP_SUSPEND_ENCODE; // block/suspend msgs(0xA-0xF) if ((encode > (STOP_SUSPEND_ACTION | STOP_SUSPEND_SELECT)) && (encode <= STOP_SUSPEND_ENCODE)) { suspend_ack = 1; // exit if (encode & STOP_SUSPEND_EXIT) { if (encode & STOP_SUSPEND_SELECT) { G_cme_stop_record.core_suspendwu |= CME_MASK_BC; } else { G_cme_stop_record.core_blockwu |= CME_MASK_BC; } g_eimr_override |= IRQ_VEC_WAKE_C0 | IRQ_VEC_WAKE_C1; #if HW386841_NDD1_DSL_STOP1_FIX // Set AUTO_STOP1_DISABLE out32(G_CME_LCL_LMCR_OR, BIT32(18)); #endif // Set PM_BLOCK_INTERRUPTS out32(G_CME_LCL_SICR_OR, BITS32(2, 2)); // Block Exit Enabled out32(G_CME_LCL_FLAGS_OR, BITS32(8, 2)); } // entry if (encode & STOP_SUSPEND_ENTRY) { if (encode & STOP_SUSPEND_SELECT) { G_cme_stop_record.core_suspendey |= CME_MASK_BC; } else { G_cme_stop_record.core_blockey |= CME_MASK_BC; } g_eimr_override |= IRQ_VEC_STOP_C0 | IRQ_VEC_STOP_C1; #if HW386841_NDD1_DSL_STOP1_FIX // Set AUTO_STOP1_DISABLE out32(G_CME_LCL_LMCR_OR, BIT32(18)); #endif // Block Entry Enabled out32(G_CME_LCL_FLAGS_OR, BITS32(10, 2)); } } // unblock/unsuspend msgs(0x2-0x7) else if ((encode < STOP_SUSPEND_ACTION) && (encode > STOP_SUSPEND_SELECT)) { suspend_ack = 1; // exit if (encode & STOP_SUSPEND_EXIT) { if (encode & STOP_SUSPEND_SELECT) { G_cme_stop_record.core_suspendwu &= ~CME_MASK_BC; } else { G_cme_stop_record.core_blockwu &= ~CME_MASK_BC; } g_eimr_override &= ~(IRQ_VEC_WAKE_C0 | IRQ_VEC_WAKE_C1); #if HW386841_NDD1_DSL_STOP1_FIX // Clear AUTO_STOP1_DISABLE out32(G_CME_LCL_LMCR_CLR, BIT32(18)); #endif // Clear PM_BLOCK_INTERRUPTS out32(G_CME_LCL_SICR_CLR, BITS32(2, 2)); // Block Exit Disabled out32(G_CME_LCL_FLAGS_CLR, BITS32(8, 2)); } // entry if (encode & STOP_SUSPEND_ENTRY) { if (encode & STOP_SUSPEND_SELECT) { G_cme_stop_record.core_suspendey &= ~CME_MASK_BC; } else { G_cme_stop_record.core_blockey &= ~CME_MASK_BC; } g_eimr_override &= ~(IRQ_VEC_STOP_C0 | IRQ_VEC_STOP_C1); #if HW386841_NDD1_DSL_STOP1_FIX // Clear AUTO_STOP1_DISABLE out32(G_CME_LCL_LMCR_CLR, BIT32(18)); #endif // Block Entry Disabled out32(G_CME_LCL_FLAGS_CLR, BITS32(10, 2)); } } if (suspend_ack) { // Shift encode to bit4 of 12 bits, then set bit5 pig.fields.req_intr_payload = ((encode << 7) | TYPE2_PAYLOAD_SUSPEND_ACK_MASK); pig.fields.req_intr_type = PIG_TYPE3; send_pig_packet(pig.value, core); } // re-evaluate stop entry & exit enables p9_cme_stop_eval_eimr_override(); }
1.171875
1
Synchronized.h
rbmj/wpilib
17
7999139
/*----------------------------------------------------------------------------*/ /* Copyright (c) FIRST 2008. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ /*----------------------------------------------------------------------------*/ #ifndef SYNCHRONIZED_H #define SYNCHRONIZED_H #include <semLib.h> #include "Base.h" #define CRITICAL_REGION(s) { Synchronized _sync(s); #define END_REGION } class Synchronized; /** * Wrap a vxWorks semaphore (SEM_ID) for easier use in C++. For a static * instance, the constructor runs at program load time before main() can spawn * any tasks. Use that to fix race conditions in setup code. * * This uses a semM semaphore which is "reentrant" in the sense that the owning * task can "take" the semaphore more than once. It will need to "give" the * semaphore the same number of times to unlock it. * * This class is safe to use in static variables because it does not depend on * any other C++ static constructors or destructors. */ class ReentrantSemaphore { public: explicit ReentrantSemaphore() { m_semaphore = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE); } ~ReentrantSemaphore() { semDelete(m_semaphore); } /** * Lock the semaphore, blocking until it's available. * @return 0 for success, -1 for error. If -1, the error will be in errno. */ int take() { return semTake(m_semaphore, WAIT_FOREVER); } /** * Unlock the semaphore. * @return 0 for success, -1 for error. If -1, the error will be in errno. */ int give() { return semGive(m_semaphore); } private: SEM_ID m_semaphore; friend class Synchronized; DISALLOW_COPY_AND_ASSIGN(ReentrantSemaphore); }; /** * Provide easy support for critical regions. * * A critical region is an area of code that is always executed under mutual exclusion. Only * one task can be executing this code at any time. The idea is that code that manipulates data * that is shared between two or more tasks has to be prevented from executing at the same time * otherwise a race condition is possible when both tasks try to update the data. Typically * semaphores are used to ensure only single task access to the data. * * Synchronized objects are a simple wrapper around semaphores to help ensure * that semaphores are always unlocked (semGive) after locking (semTake). * * You allocate a Synchronized as a local variable, *not* on the heap. That * makes it a "stack object" whose destructor runs automatically when it goes * out of scope. E.g. * * { Synchronized _sync(aReentrantSemaphore); ... critical region ... } */ class Synchronized { public: explicit Synchronized(SEM_ID); explicit Synchronized(ReentrantSemaphore&); virtual ~Synchronized(); private: SEM_ID m_semaphore; DISALLOW_COPY_AND_ASSIGN(Synchronized); }; #endif
1.992188
2
JKWKWebViewHandler_OC/JKWKWebViewHandler/Classes/JKEventHandler.h
xindizhiyin2014/JKWKWebViewHandler
102
7999147
// // JKEventHandler.h // Pods // // Created by Jack on 17/3/31. // // #import <Foundation/Foundation.h> #import <webkit/webkit.h> static NSString * const JKEventHandlerName = @"JKEventHandler"; @interface JKEventHandler : NSObject<WKScriptMessageHandler> @property (nonatomic, weak) WKWebView *webView; + (NSString *)handlerJS; /** 清空handler的数据信息, 注入的脚本。绑定事件信息等等 */ + (void)cleanHandler:(JKEventHandler *)handler; /** 执行js脚本 @param js js脚本 @param completed 回调 */ - (void)evaluateJavaScript:(NSString *)js completed:(void(^)(id data, NSError *error))completed; /// 执行js脚本,同步返回 /// @param js js脚本 /// @param error 错误 - (id)synEvaluateJavaScript:(NSString *)js error:(NSError **)error; @end
0.412109
0
src/opentimelineio/trackAlgorithm.h
camkerr/OpenTimelineIO
1,021
7999155
#pragma once #include "opentimelineio/track.h" #include "opentimelineio/version.h" namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { Track* track_trimmed_to_range( Track* in_track, TimeRange trim_range, ErrorStatus* error_status = nullptr); }} // namespace opentimelineio::OPENTIMELINEIO_VERSION
0.425781
0
projects/robots/adept/pioneer3/controllers/pioneer3dx_collision_avoidance/pioneer3dx_collision_avoidance.c
awesome-archive/webots
2
7999163
/* * Copyright 1996-2018 Cyberbotics Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Description: A controller moving the Pioneer 3-DX and avoiding obstacles. 3 LEDs are switched on and off periodically */ #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <webots/distance_sensor.h> #include <webots/led.h> #include <webots/motor.h> #include <webots/robot.h> // maximal speed allowed #define MAX_SPEED 5.24 // how many sensors are on the robot #define MAX_SENSOR_NUMBER 16 // delay used for the blinking leds #define DELAY 70 // maximal value returned by the sensors #define MAX_SENSOR_VALUE 1024 // minimal distance, in meters, for an obstacle to be considered #define MIN_DISTANCE 1.0 // minimal weight for the robot to turn #define WHEEL_WEIGHT_THRESHOLD 100 // structure to store the data associated to one sensor typedef struct { WbDeviceTag device_tag; double wheel_weight[2]; } SensorData; // enum to represent the state of the robot typedef enum { FORWARD, LEFT, RIGHT } State; // how much each sensor affects the direction of the robot static SensorData sensors[MAX_SENSOR_NUMBER] = { {.wheel_weight = {150, 0}}, {.wheel_weight = {200, 0}}, {.wheel_weight = {300, 0}}, {.wheel_weight = {600, 0}}, {.wheel_weight = {0, 600}}, {.wheel_weight = {0, 300}}, {.wheel_weight = {0, 200}}, {.wheel_weight = {0, 150}}, {.wheel_weight = {0, 0}}, {.wheel_weight = {0, 0}}, {.wheel_weight = {0, 0}}, {.wheel_weight = {0, 0}}, {.wheel_weight = {0, 0}}, {.wheel_weight = {0, 0}}, {.wheel_weight = {0, 0}}, {.wheel_weight = {0, 0}}}; int main() { // necessary to initialize Webots wb_robot_init(); // stores simulation time step int time_step = wb_robot_get_basic_time_step(); // stores device IDs for the wheels WbDeviceTag left_wheel = wb_robot_get_device("left wheel"); WbDeviceTag right_wheel = wb_robot_get_device("right wheel"); // stores device IDs for the LEDs WbDeviceTag red_led[3]; red_led[0] = wb_robot_get_device("red led 1"); red_led[1] = wb_robot_get_device("red led 2"); red_led[2] = wb_robot_get_device("red led 3"); char sensor_name[5] = ""; int i; // sets up sensors and stores some info about them for (i = 0; i < MAX_SENSOR_NUMBER; ++i) { sprintf(sensor_name, "so%d", i); sensors[i].device_tag = wb_robot_get_device(sensor_name); wb_distance_sensor_enable(sensors[i].device_tag, time_step); } // sets up wheels wb_motor_set_position(left_wheel, INFINITY); wb_motor_set_position(right_wheel, INFINITY); wb_motor_set_velocity(left_wheel, 0.0); wb_motor_set_velocity(right_wheel, 0.0); int j, led_number = 0, delay = 0; double speed[2] = {0.0, 0.0}; double wheel_weight_total[2] = {0.0, 0.0}; double distance, speed_modifier, sensor_value; // by default, the robot goes forward State state = FORWARD; // run simulation while (wb_robot_step(time_step) != -1) { // initialize speed and wheel_weight_total arrays at the beginning of the loop memset(speed, 0, sizeof(double) * 2); memset(wheel_weight_total, 0, sizeof(double) * 2); for (i = 0; i < MAX_SENSOR_NUMBER; ++i) { sensor_value = wb_distance_sensor_get_value(sensors[i].device_tag); // if the sensor doesn't see anything, we don't use it for this round if (sensor_value == 0.0) speed_modifier = 0.0; else { // computes the actual distance to the obstacle, given the value returned by the sensor distance = 5.0 * (1.0 - (sensor_value / MAX_SENSOR_VALUE)); // lookup table inverse. // if the obstacle is close enough, we may want to turn // here we compute how much this sensor will influence the direction of the robot if (distance < MIN_DISTANCE) speed_modifier = 1 - (distance / MIN_DISTANCE); else speed_modifier = 0.0; } // add the modifier for both wheels for (j = 0; j < 2; ++j) wheel_weight_total[j] += sensors[i].wheel_weight[j] * speed_modifier; } // (very) simplistic state machine to handle the direction of the robot switch (state) { // when the robot is going forward, it will start turning in either direction when an obstacle is close enough case FORWARD: if (wheel_weight_total[0] > WHEEL_WEIGHT_THRESHOLD) { speed[0] = 0.7 * MAX_SPEED; speed[1] = -0.7 * MAX_SPEED; state = LEFT; } else if (wheel_weight_total[1] > WHEEL_WEIGHT_THRESHOLD) { speed[0] = -0.7 * MAX_SPEED; speed[1] = 0.7 * MAX_SPEED; state = RIGHT; } else { speed[0] = MAX_SPEED; speed[1] = MAX_SPEED; } break; // when the robot has started turning, it will go on in the same direction until no more obstacle are in sight // this will prevent the robot from being caught in a loop going left, then right, then left, and so on. case LEFT: if (wheel_weight_total[0] > WHEEL_WEIGHT_THRESHOLD || wheel_weight_total[1] > WHEEL_WEIGHT_THRESHOLD) { speed[0] = 0.7 * MAX_SPEED; speed[1] = -0.7 * MAX_SPEED; } else { speed[0] = MAX_SPEED; speed[1] = MAX_SPEED; state = FORWARD; } break; case RIGHT: if (wheel_weight_total[0] > WHEEL_WEIGHT_THRESHOLD || wheel_weight_total[1] > WHEEL_WEIGHT_THRESHOLD) { speed[0] = -0.7 * MAX_SPEED; speed[1] = 0.7 * MAX_SPEED; } else { speed[0] = MAX_SPEED; speed[1] = MAX_SPEED; state = FORWARD; } break; } // the three red LEDs are swicthed on and off periodically ++delay; if (delay == DELAY) { wb_led_set(red_led[led_number], 0); ++led_number; led_number = led_number % 3; wb_led_set(red_led[led_number], 1); delay = 0; } // sets the motor speeds wb_motor_set_velocity(left_wheel, speed[0]); wb_motor_set_velocity(right_wheel, speed[1]); } wb_robot_cleanup(); return 0; }
2.53125
3
CI/rule/pclint/pclint_include/include_linux/c++/4.8.2/gnu/javax/net/ssl/provider/Jessie.h
chewaiwai/huaweicloud-sdk-c-obs
22
7999171
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- #ifndef __gnu_javax_net_ssl_provider_Jessie__ #define __gnu_javax_net_ssl_provider_Jessie__ #pragma interface #include <java/security/Provider.h> extern "Java" { namespace gnu { namespace javax { namespace net { namespace ssl { namespace provider { class Jessie; } } } } } } class gnu::javax::net::ssl::provider::Jessie : public ::java::security::Provider { public: Jessie(); private: static const jlong serialVersionUID = -1LL; public: static ::java::lang::String * VERSION; static jdouble VERSION_DOUBLE; static ::java::lang::Class class$; }; #endif // __gnu_javax_net_ssl_provider_Jessie__
0.746094
1
logdevice/admin/safety/SafetyAPI.h
SimonKinds/LogDevice
0
7999179
/** * Copyright (c) 2017-present, Facebook, Inc. and its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include "logdevice/include/NodeLocationScope.h" #include "logdevice/include/types.h" namespace facebook { namespace logdevice { using SafetyMargin = std::map<NodeLocationScope, int>; struct Impact { enum ImpactResult { NONE = 0, // ERROR during check. For example event log is not readable ERROR = (1u << 0), // operation could lead to rebuilding stall, as full rebuilding // of all logs a is not possible due to historical nodesets REBUILDING_STALL = (1u << 1), // operation could lead to loss of write availability. WRITE_AVAILABILITY_LOSS = (1u << 2), // operation could lead to loss of read availability, // as there is no f-majority for certain logs READ_AVAILABILITY_LOSS = (1u << 3), // operation could lead to data loss. DATA_LOSS = (1u << 4), // operation could lead to metadata being inaccessible METADATA_LOSS = (1u << 5), }; // bit set of ImpactResult int result; std::string details; // Set of data logs affected. std::vector<logid_t> logs_affected; // Whether metadata logs are also affected (ie the operations have impact on // the metadata nodeset). bool metadata_logs_affected; explicit Impact(int result, std::string details = "", std::vector<logid_t> logs_affected = {}, bool ml_affected = false); std::string toString() const; static std::string toStringImpactResult(int); }; enum Operation { DISABLE_WRITES = (1u << 0), DISABLE_READS = (1u << 1), WIPE_DATA = (1u << 2) }; }} // namespace facebook::logdevice
1.445313
1
base/security/rc4.c
rocious/omaha
4
7999187
// Copyright 2005-2009 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ======================================================================== #include "rc4.h" #include <inttypes.h> void RC4_setKey(RC4_CTX* ctx, const uint8_t* key, int len) { uint8_t* S = ctx->S; int i, j; for (i = 0; i < 256; ++i) { S[i] = i; } j = 0; for (i = 0; i < 256; ++i) { uint8_t tmp; j = (j + S[i] + key[i % len]) & 255; tmp = S[i]; S[i] = S[j]; S[j] = tmp; } ctx->i = 0; ctx->j = 0; } void RC4_crypt(RC4_CTX* ctx, const uint8_t *in, uint8_t* out, int len) { uint8_t i = ctx->i; uint8_t j = ctx->j; uint8_t* S = ctx->S; int n; for (n = 0; n < len; ++n) { uint8_t tmp; i = (i + 1) & 255; j = (j + S[i]) & 255; tmp = S[i]; S[i] = S[j]; S[j] = tmp; if (in) { if (out) { out[n] = in[n] ^ S[(S[i] + S[j]) & 255]; } } else { if (out) { out[n] = S[(S[i] + S[j]) & 255]; } } } ctx->i = i; ctx->j = j; } void RC4_discard(RC4_CTX* ctx, int len) { RC4_crypt(ctx, 0, 0, len); } void RC4_stream(RC4_CTX* ctx, uint8_t* out, int len) { RC4_crypt(ctx, 0, out, len); }
1.492188
1
net/homenet/netsh/strdefs.h
npocmaka/Windows-Server-2003
17
7999195
//+--------------------------------------------------------------------------- // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1998 - 2001 // // File : strdefs.h // // Contents : // // Notes : // // Author : <NAME> (rgatta) 10 May 2001 // //---------------------------------------------------------------------------- #ifndef __STRDEFS_H__ #define __STRDEFS_H__ // The string table entries that are identified here are arranged // in a hierachy as follows // common hlp messages // command usage messages per protocol // show command usage // add command usage // delete command usage // set command usage // Output messages // Bridge messages // Miscellaneous messages // Strings // Protocol types // Miscellaneous strings // Error Messages // Bridge error messages #define MSG_NULL 1000 // commmon hlp messages #define HLP_HELP 2100 #define HLP_HELP_EX 2101 #define HLP_HELP1 HLP_HELP #define HLP_HELP1_EX HLP_HELP_EX #define HLP_HELP2 HLP_HELP #define HLP_HELP2_EX HLP_HELP_EX #define HLP_INSTALL 2110 #define HLP_INSTALL_EX 2111 #define HLP_UNINSTALL 2112 #define HLP_UNINSTALL_EX 2113 #define HLP_DUMP 2120 #define HLP_DUMP_EX 2121 #define HLP_GROUP_SET 2150 #define HLP_GROUP_SHOW 2151 // BRIDGE // bridge install/uninstall #define HLP_BRIDGE_INSTALL 5000 #define HLP_BRIDGE_INSTALL_EX 5001 #define HLP_BRIDGE_UNINSTALL 5002 #define HLP_BRIDGE_UNINSTALL_EX 5003 #define HLP_BRIDGE_USE_GUI 5004 // bridge dump #define DMP_BRIDGE_HEADER 5010 #define DMP_BRIDGE_FOOTER 5011 // bridge set hlp #define HLP_BRIDGE_SET_ADAPTER 5110 #define HLP_BRIDGE_SET_ADAPTER_EX 5111 // bridge show hlp #define HLP_BRIDGE_SHOW_ADAPTER 5210 #define HLP_BRIDGE_SHOW_ADAPTER_EX 5211 // Output messages // Bridge messages #define MSG_BRIDGE_GLOBAL_INFO 20501 #define MSG_BRIDGE_ADAPTER_INFO_HDR 20551 #define MSG_BRIDGE_ADAPTER_INFO 20552 #define MSG_BRIDGE_FLAGS 20553 // Miscellaneous messages #define MSG_OK 30001 #define MSG_NO_HELPER 30002 #define MSG_NO_HELPERS 30003 #define MSG_CTRL_C_TO_QUIT 30004 // Strings // Protocol types #define STRING_PROTO_OTHER 31001 #define STRING_PROTO_BRIDGE 31002 // Miscellaneous strings #define STRING_CREATED 32001 #define STRING_DELETED 32002 #define STRING_ENABLED 32003 #define STRING_DISABLED 32004 #define STRING_YES 32011 #define STRING_NO 32012 #define STRING_Y 32013 #define STRING_N 32014 #define STRING_UNKNOWN 32100 #define TABLE_SEPARATOR 32200 // Error messages // Bridge error messages #define MSG_BRIDGE_PRESENT 40100 #define MSG_BRIDGE_NOT_PRESENT 40101 // Miscellaneous messages #define EMSG_BAD_OPTION_VALUE 50100 #endif
0.875
1
src/common/player.h
gorel/C-Poker-AI
36
7999203
#ifndef __PLAYER_H__ #define __PLAYER_H__ #include <stdbool.h> #include <stdlib.h> #include <string.h> #include "cJSON.h" #define MAX_NAME_LEN 20 typedef struct player { char name[MAX_NAME_LEN + 1]; int initial_stack; int current_bet; int stack; bool folded; } Player; /* * Create a new player from the given cJSON object * playerjson: a cJSON object representing the player * return: a new Player */ Player *CreatePlayer(cJSON *playerjson); /* * Destroy the given player * player: the player object to free all memory for */ void DestroyPlayer(Player *player); #endif
1.640625
2
libuvcpp/accept.h
NFCHKK/libuv-learn
1
7999211
#ifndef _ACCEPT_H_ #define _ACCEPT_H_ #include <thread> #include <condition_variable> #include <mutex> #include <functional> #include <map> #include <deque> #include <memory> #include "loop.h" #include "SafeBuffer.h" #include "connect.h" #include "../include/uv.h" #ifdef WIN32 #include <WinSock2.h> #pragma comment(lib, "ws2_32.lib") #ifdef _DEBUG #pragma comment(lib, "libuv.lib") #else #pragma comment(lib, "libuv.lib") #endif #pragma comment(lib, "IPHLPAPI.lib") #pragma comment(lib, "Psapi.lib") #pragma comment(lib, "Userenv.lib") #else #define _stdcall #endif typedef std::function<void(std::shared_ptr<uvconnect>)> NewConnectcb; class uvaccept:public std::enable_shared_from_this<uvaccept> { public: uvaccept(); ~uvaccept(); void SetIPAndPort(char *phost = "0.0.0.0", unsigned int port = 12396); bool RegisterAccept(std::shared_ptr<uvloop> ploop); void SetNewConnectCallback(NewConnectcb cocb); bool listen(); std::shared_ptr<uvloop> m_ploop; NewConnectcb m_pConnectcb; std::shared_ptr<uv_tcp_t> m_pServer; private: sockaddr_in m_addr; void ServerListenStart(); }; #endif // !_ACCEPT_H_
1.40625
1
snapgear_linux/user/a60/main.c
impedimentToProgress/UCI-BlueChip
0
7999219
/* * Main interpreter module that can handle one language: Algol 60 * * Copyright (C) 1991,1992 <NAME> (<EMAIL>) * * This file is part of NASE A60. * * NASE A60 is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * NASE A60 is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NASE A60; see the file COPYING. If not, write to the Free * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * main.c: aug '90 * * the main module for the Algol 60 interpreter. */ #include "comm.h" #include "a60.h" #include "version.h" #include "eval.h" #include "run.h" #include "util.h" #include "mkc.h" /* be verbose: */ int verbose; /* be verbose on check pass: */ int cverbose; /* be verbose when creating/compiling c-code: */ int make_c_verbose; /* xa60 is being used: sent output of stderr to stdout and disallow input: */ int run_with_xa60; /* name of the input file: */ char *infname; /* file to read from; (used by yylex ()): */ FILE *infile; /* name of the outputfile (used for c-output): */ char *outfname; /* name of the outputfile (used for redirecton of stdout): */ static char *termfname; /* append the output to outfname: */ static int append_output; /* warn about uncheckable conditions; runtime errors may occur. */ int rwarn; /* verbose debug (if compiled with YYDEBUG enable parser debugging). */ int do_debug; /* print debug info on memory allocation and release. */ int do_memdebug; /* print the parse tree (only useful for debugging) : */ static int do_dump; /* print trace information: */ int trace; /* don't execute the fun: */ static int norun; /* don't check the tree (inplicite norun): */ static int nocheck; /* * look for strict (pedantic) rra60 conformace: * (skip whites in input, except in strings) */ int strict_a60; /* and following strict_a60: scan in this manner: */ int scan_strict; /* print a memory statistics summary: */ int do_memstat; #ifndef EMBED /* create c-output: */ int make_cout; /* create c-output and compile: */ int make_bin; #endif /* root of the parse tree: */ TREE *rtree; #ifdef ATARI /* * the magic way to set the runtime stacksize (for use with gcc). */ long _stksize = 100000l; #endif /* * onk - what you're doing; give a hint and exit. */ static void usage () { fprintf (stderr, "\nuse: a60 [options] [file]\n"); fprintf (stderr, "options are:\n"); fprintf (stderr, "\t-V print version and exit\n"); fprintf (stderr, "\t-v be verbose\n"); fprintf (stderr, "\t-t turn tracing on\n"); fprintf (stderr, "\t-n do not execute (parse and check only)\n"); fprintf (stderr, "\t-i do not check (parse only)\n"); fprintf (stderr, "\t-Wr warn about runtime decisions\n"); fprintf (stderr, "\t-strict follow strict a60 conventions\n"); #ifndef EMBED fprintf (stderr, "\t-c create c output\n"); fprintf (stderr, "\t-C create and compile c output\n"); fprintf (stderr, "\t-o <file> output file; used with -c or -C\n"); #endif fprintf (stderr, "\t> <file> send terminal output to <file>\n"); fprintf (stderr, "\t>> <file> append terminal output to <file>\n"); #ifdef unix fprintf (stderr, "\t-X a60 is run from xa60\n"); #endif #ifdef DEBUG fprintf (stderr, "\t-d turn debug on\n"); fprintf (stderr, "\t-d[admp] turn selected debug on\n"); fprintf (stderr, "\t-D dump the parse tree\n"); #endif /* ! DEBUG */ #ifdef MEMORY_STATISTICS fprintf (stderr, "\t-m print memory statistics\n"); #endif /* MEMORY_STATISTICS */ exit (-1); } static void usage_err (s) char *s; { fprintf (stderr, "commandline error: %s\n", s); usage (); } /* * print the header: version and copyright: */ static void print_header () { fprintf (stderr, " %s\n", VERSION); fprintf (stderr, " Copyright (C) 1991,1992 <NAME> (<EMAIL>)\n"); fprintf (stderr, " The NASE A60 interpreter is free software. See the file COPYING for\n"); fprintf (stderr, " copying permission.\n"); } /* * examine the string for verbose info; */ static void select_verbose (s) char *s; { while (s && *s) { switch (*s) { case 'a': /* set all the flags: */ verbose = 1; cverbose = 1; make_c_verbose = 1; break; case 'c': /* set check-pass verbositivity: */ cverbose = 1; break; case 'C': /* set compilation verbositivity: */ make_c_verbose = 1; break; case 'v': /* set common verbositivity: */ verbose = 1; break; default: fprintf (stderr, "hint: verboseflag `%c' ignored.\n", *s); } s++; } } #ifdef DEBUG /* * examine the string for debug info; */ static void select_debug (s) char *s; { while (s && *s) { switch (*s) { case 'a': /* set all the flags: */ do_debug = 1; do_memdebug = 1; verbose = 1; trace = 1; #ifdef PARSEDEBUG yydebug = 1; #endif break; case 'd': do_debug = 1; break; case 'm': do_memdebug = 1; break; case 'p': #ifndef PARSEDEBUG fprintf (stderr, "parser debugging not avail.\n"); #else yydebug = 1; #endif break; default: if (verbose) fprintf (stderr, "debugflag `%c' ignored.\n", *s); } s++; } } #endif /* DEBUG */ /* * parse all the arguments; initialize the flags. */ static void parse_args(argc, argv) int argc; char *argv[]; { do_dump = verbose = 0; infname = (char *) 0; rwarn = trace = do_memstat = 0; #ifndef EMBED make_cout = 0; make_bin = 0; #endif nocheck = norun = 0; outfname = (char *) 0; termfname = (char *) 0; append_output = 0; make_c_verbose = 0; run_with_xa60 = 0; scan_strict = 0; strict_a60 = 0; do_debug = do_memdebug = 0; while(++argv, --argc > 0) { if((*argv)[0] == '-' && ! (*argv)[2]) { switch((*argv)[1]) { #ifndef EMBED case 'o': if (argc < 2) usage_err ("incomplete option `-o'"); ++argv, --argc; outfname = *argv; break; #endif case 'v': verbose = 1; print_header (); break; case 'V': print_header (); exit (0); /* never reached */ break; case 'h': usage (); break; case 'D': do_dump = 1; break; case 'd': #ifdef DEBUG do_debug = 1; #else /* ! DEBUG */ fprintf (stderr, "hint: debug not avail.\n"); #endif /* ! DEBUG */ break; case 'm': #ifdef MEMORY_STATISTICS do_memstat = 1; #else /* ! MEMORY_STATISTICS */ fprintf (stderr, "hint: memory statistics not avail.\n"); #endif /* ! MEMORY_STATISTICS */ break; case 't': trace = 1; break; case 'n': norun = 1; break; case 'i': nocheck = norun = 1; break; #ifndef EMBED case 'c': make_cout = 1; norun = 1; break; case 'C': make_cout = 1; norun = 1; make_bin = 1; break; #endif case 'X': #ifdef unix if (run_with_xa60) usage (); if (dup2 (fileno (stdout), fileno (stderr)) < 0) xabort ("internal error: dup2"); run_with_xa60 = 1; #else /* ! unix */ fprintf (stderr, "hint: -X option not avail.\n"); #endif /* ! unix */ break; default: usage(); } } else { if (! strcmp (*argv, "-Wr")) { rwarn = 1; } else if (! strncmp (*argv, ">>", 2)) { if (! argv[0][2] && argc < 2) usage_err ("incomplete option `>>'"); append_output = 1; if (! argv[0][2]) { ++argv, --argc; termfname = *argv; } else termfname = *argv+2; } else if (! strncmp (*argv, ">", 1)) { if (! argv[0][1] && argc < 2) usage_err ("incomplete option `>'"); if (! argv[0][1]) { ++argv, --argc; termfname = *argv; } else termfname = *argv+1; } else if (! strncmp (*argv, "-d", 2)) { #ifdef DEBUG select_debug ((*argv)+2); #else /* ! DEBUG */ fprintf (stderr, "hint: debug not avail.\n"); #endif /* ! DEBUG */ } else if (! strncmp (*argv, "-v", 2)) { select_verbose ((*argv)+2); } else if (! strcmp (*argv, "-strict")) { strict_a60 = 1; scan_strict = 1; } else { if (infname) { usage_err ( "input file already specified"); } infname = *argv; } } } if (! infname) infname = "-"; } /* * print the number of errors found and exit. */ static void nerror_exit (n) int n; { fprintf (stderr, "%d error%s found.\n", n, (n == 1) ? "" : "s"); if (do_dump) { printf ("\n Tree dump:\n\n"); print_tree (rtree); } if (verbose) fprintf (stderr, "bye.\n"); exit (n); } /* * M A I N : */ int main(argc, argv) int argc; char *argv[]; { #ifdef MEMORY_STATISTICS STACK_STAT_INIT; #endif /* MEMORY_STATISTICS */ if (verbose) fprintf (stderr, "Hi\n"); parse_args (argc, argv); if (termfname) { /* redirect stdout to <termfname>: */ char *filemode; if (append_output) filemode = "a"; else filemode = "w"; if (stdout != freopen (termfname, filemode, stdout)) { fprintf (stderr, "cannot open `%s' for output - ignored.\n", termfname); } } /* * now, let's examine the input medium: */ if (! strcmp (infname, "-")) { infname = "<stdin>"; infile = stdin; } else infile = fopen (infname, "r"); if (! infile) { int len = strlen (infname) + 10; /* 4 or 5 - gna */ char *tmp = NTALLOC(len, char); sprintf (tmp, "%s.a60", infname); infile = fopen (tmp, "r"); if (! infile) { fprintf (stderr, "cannot open file `%s' for reading.\n", infname); exit (-1); } else infname = tmp; } if (verbose) fprintf (stderr, "reading from `%s'\n", infname); init_lex (); if (yyparse ()) { if (! nerrors) nerrors++; } if (nerrors) { nerror_exit (nerrors); /* never reached */ } if ((nocheck || nerrors) && do_dump) { printf ("\n Parse-Tree dump:\n\n"); print_tree (rtree); } if (nocheck) return say_goodbye (0); if (check_tree () != 0) { nerror_exit (cerrors); /* never reached */ } if (verbose) fprintf (stderr, "no error found.\n"); if (do_dump) { printf ("\n Tree dump:\n\n"); print_tree (rtree); } #ifndef EMBED if (make_cout) { make_c (); return say_goodbye (0); } #endif if (! norun && rtree) { init_evalst (); interpret (); } return say_goodbye (0); } /* end of main.c */
1.695313
2
third-party/libfabric/libfabric-src/prov/psm3/psm3/psm_ep.c
jhh67/chapel
1,602
7999227
/* This file is provided under a dual BSD/GPLv2 license. When using or redistributing this file, you may do so under either license. GPL LICENSE SUMMARY Copyright(c) 2016 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Contact Information: Intel Corporation, www.intel.com BSD LICENSE Copyright(c) 2016 Intel Corporation. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Copyright (c) 2003-2016 Intel Corporation. All rights reserved. */ #include <sys/types.h> #include <sys/stat.h> #include <sched.h> /* cpu_set */ #include <ctype.h> /* isalpha */ #include <stdbool.h> #include "psm_user.h" #include "psm2_hal.h" #include "psm_mq_internal.h" #include "psm_am_internal.h" #include "ips_proto_params.h" #ifdef PSM_CUDA #include "psm_gdrcpy.h" #endif /* * Endpoint management */ psm2_ep_t psmi_opened_endpoint = NULL; int psmi_opened_endpoint_count = 0; static uint32_t *hfi_lids; static uint32_t nlids; static psm2_error_t psmi_ep_open_device(const psm2_ep_t ep, const struct psm2_ep_open_opts *opts, const psm2_uuid_t unique_job_key, struct psmi_context *context, psm2_epid_t *epid); /* * Device management * * PSM uses "devices" as components to manage communication to self, to peers * reachable via shared memory and finally to peers reachable only through * hfi. */ static psm2_error_t psmi_parse_devices(int devices[PTL_MAX_INIT], const char *devstr); static int psmi_device_is_enabled(const int devices[PTL_MAX_INIT], int devid); int psmi_ep_device_is_enabled(const psm2_ep_t ep, int devid); psm2_error_t __psm2_ep_num_devunits(uint32_t *num_units_o) { static int num_units = -1; PSM2_LOG_MSG("entering"); PSMI_ERR_UNLESS_INITIALIZED(NULL); if (num_units == -1) { num_units = psmi_hal_get_num_units(); if (num_units == -1) num_units = 0; } *num_units_o = (uint32_t) num_units; PSM2_LOG_MSG("leaving"); return PSM2_OK; } PSMI_API_DECL(psm2_ep_num_devunits) static int cmpfunc(const void *p1, const void *p2) { uint64_t a = ((uint64_t *) p1)[0]; uint64_t b = ((uint64_t *) p2)[0]; if (a < b) return -1; if (a == b) return 0; return 1; } // process PSM3_MULTIRAIL and PSM3_MULTIRAIL_MAP and return the // list of unit/port in unit[0-*num_rails] and port[0-*num_rails] // When *num_rails is returned as 0, multirail is not enabled and // other mechanisms (PSM3_NIC, PSM3_NIC_SELECTION_ALG) must be // used by the caller to select a single NIC for the process static psm2_error_t psmi_ep_multirail(int *num_rails, uint32_t *unit, uint16_t *port) { uint32_t num_units; uint64_t gid_hi; unsigned i, j, count = 0; int ret; psm2_error_t err = PSM2_OK; uint64_t gidh[PSMI_MAX_RAILS][3]; union psmi_envvar_val env_multirail; union psmi_envvar_val env_multirail_map; int multirail_within_socket_used = 0; int node_id = -1, found = 0; psmi_getenv("PSM3_MULTIRAIL", "Use all available NICs in the system for communication.\n" "0: Disabled (default),\n" "1: Enable multirail across all available NICs,\n" "2: Enable multirail within socket.\n" "\t For multirail within a socket, we try to find at\n" "\t least one NIC on the same socket as current task.\n" "\t If none found, we continue to use other NICs within\n" "\t the system.", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_INT, (union psmi_envvar_val)0, &env_multirail); if (!env_multirail.e_int) { *num_rails = 0; return PSM2_OK; } if (env_multirail.e_int == 2) multirail_within_socket_used = 1; /* * map is in format: unit:port,unit:port,... * where :port is optional (default of 1) and unit can be name or number */ #define MAX_MAP_LEN (PSMI_MAX_RAILS*128) if (!psmi_getenv("PSM3_MULTIRAIL_MAP", "NIC selections for each rail in format:\n" " rail,rail,...\n" "Where rail can be: unit:port or unit\n" "When port is omitted, it defaults to 1\n" "unit can be device name or unit number\n" "default autoselects", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_STR, (union psmi_envvar_val)"", &env_multirail_map)) { char temp[MAX_MAP_LEN+1]; char *s; char *delim; strncpy(temp, env_multirail_map.e_str, MAX_MAP_LEN); if (temp[MAX_MAP_LEN-1] != 0) return psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "PSM3_MULTIRAIL_MAP too long: '%s'", env_multirail_map.e_str); s = temp; psmi_assert(*s); do { int u, p; int skip_port = 0; if (! *s) // trailing ',' on 2nd or later loop break; if (count >= PSMI_MAX_RAILS) return psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "PSM3_MULTIRAIL_MAP exceeds %u rails: '%s'", PSMI_MAX_RAILS, env_multirail_map.e_str); // parse unit delim = strchr(s, ':'); if (! delim) { delim = strchr(s, ','); skip_port = 1; p = 1; } if (! delim && !skip_port) return psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "PSM3_MULTIRAIL_MAP invalid format: '%s'", env_multirail_map.e_str); if (delim) *delim = '\0'; u = sysfs_find_unit(s); if (u < 0) return psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "PSM3_MULTIRAIL_MAP invalid unit: '%s'", s); if (delim) s = delim+1; // optionally parse port if (! skip_port) { delim = strchr(s, ','); if (delim) *delim = '\0'; p = psmi_parse_str_long(s); if (p < 0) return psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "PSM3_MULTIRAIL_MAP invalid port: '%s'", s); if (delim) s = delim+1; } unit[count] = u; port[count] = p; count++; } while (delim); *num_rails = count; /* * Check if any of the port is not usable. */ for (i = 0; i < count; i++) { _HFI_VDBG("rail %d: %u(%s) %u\n", i, unit[i], sysfs_unit_dev_name(unit[i]), port[i]); ret = psmi_hal_get_port_active(unit[i], port[i]); if (ret <= 0) return psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "PSM3_MULTIRAIL_MAP: Unit/port: %d(%s):%d is not active.", unit[i], sysfs_unit_dev_name(unit[i]), port[i]); ret = psmi_hal_get_port_lid(unit[i], port[i]); if (ret <= 0) return psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "PSM3_MULTIRAIL_MAP: Couldn't get lid for unit %d(%s):%d", unit[i], sysfs_unit_dev_name(unit[i]), port[i]); ret = psmi_hal_get_port_subnet(unit[i], port[i], NULL, NULL, NULL, NULL, NULL, NULL, NULL); if (ret == -1) return psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "PSM3_MULTIRAIL_MAP: Couldn't get subnet for unit %d(%s):%d", unit[i], sysfs_unit_dev_name(unit[i]), port[i]); } return PSM2_OK; } if ((err = psm2_ep_num_devunits(&num_units))) { return err; } if (num_units > PSMI_MAX_RAILS) { _HFI_INFO ("Found %d units, max %d units are supported, use %d\n", num_units, PSMI_MAX_RAILS, PSMI_MAX_RAILS); num_units = PSMI_MAX_RAILS; } /* * PSM3_MULTIRAIL=2 functionality- * - Try to find at least find one HFI in the same root * complex. If none found, continue to run and * use remaining HFIs in the system. * - If we do find at least one HFI in same root complex, we * go ahead and add to list. */ if (multirail_within_socket_used) { node_id = psmi_get_current_proc_location(); for (i = 0; i < num_units; i++) { if (psmi_hal_get_unit_active(i) <= 0) continue; int node_id_i; if (!psmi_hal_get_node_id(i, &node_id_i)) { if (node_id_i == node_id) { found = 1; break; } } } } /* * Get all the ports with a valid lid and gid, one per unit. */ for (i = 0; i < num_units; i++) { int node_id_i; if (!psmi_hal_get_node_id(i, &node_id_i)) { if (multirail_within_socket_used && found && (node_id_i != node_id)) continue; } for (j = HFI_MIN_PORT; j <= HFI_MAX_PORT; j++) { ret = psmi_hal_get_port_lid(i, j); if (ret <= 0) continue; ret = psmi_hal_get_port_subnet(i, j, &gid_hi, NULL, NULL, NULL, NULL, NULL, NULL); if (ret == -1) continue; gidh[count][0] = gid_hi; gidh[count][1] = i; gidh[count][2] = j; count++; break; } } /* * Sort all the ports with gidh from small to big. * This is for multiple fabrics, and we use fabric with the * smallest gid to make the master connection. */ qsort(gidh, count, sizeof(uint64_t) * 3, cmpfunc); for (i = 0; i < count; i++) { unit[i] = (uint32_t) gidh[i][1]; port[i] = (uint16_t) (uint32_t) gidh[i][2]; } *num_rails = count; return PSM2_OK; } // this is used to find devices with the same address as another process, // implying intra-node comms. #define MAX_GID_IDX 31 static psm2_error_t psmi_ep_devlids(uint32_t **lids, uint32_t *num_lids_o, uint64_t my_gid_hi, uint64_t my_gid_lo, psm2_epid_t my_epid) { uint32_t num_units; int i; psm2_error_t err = PSM2_OK; PSMI_ERR_UNLESS_INITIALIZED(NULL); if (hfi_lids == NULL) { if ((err = psm2_ep_num_devunits(&num_units))) goto fail; hfi_lids = (uint32_t *) psmi_calloc(PSMI_EP_NONE, UNDEFINED, num_units * psmi_hal_get_num_ports(), sizeof(*hfi_lids)); if (hfi_lids == NULL) { err = psmi_handle_error(NULL, PSM2_NO_MEMORY, "Couldn't allocate memory for dev_lids structure"); goto fail; } for (i = 0; i < num_units; i++) { int j; for (j = HFI_MIN_PORT; j <= HFI_MAX_PORT; j++) { int lid = psmi_hal_get_port_lid(i, j); int ret, idx = 0; uint64_t gid_hi = 0, gid_lo = 0; uint64_t actual_gid_hi = 0; uint32_t ipaddr = 0; // if looking for IB/OPA lid, skip ports we can't get lid for if (lid <= 0 && psmi_epid_version(my_epid) == PSMI_EPID_V3) continue; // we just need subnet and addr within subnet and idx ret = psmi_hal_get_port_subnet(i, j, &gid_hi, &gid_lo, &ipaddr, NULL, &idx, &actual_gid_hi, NULL); if (ret == -1) continue; if (my_gid_hi != gid_hi) { _HFI_VDBG("LID %d, unit %d, port %d, mismatched " "GID[%d] %llx:%llx and %llx:%llx\n", lid, i, j, idx, (unsigned long long)gid_hi, (unsigned long long)gid_lo, (unsigned long long)my_gid_hi, (unsigned long long)my_gid_lo); continue; } if (actual_gid_hi != gid_hi) { if (_HFI_VDBG_ON) { char buf[INET_ADDRSTRLEN]; _HFI_VDBG("LID %d=>IPaddr %s, unit %d, port %d, matched " "GID[%d] %llx:%llx and %llx:%llx\n", lid, psmi_ipv4_ntop(ipaddr, buf, sizeof(buf)), i, j, idx, (unsigned long long)gid_hi, (unsigned long long)gid_lo, (unsigned long long)my_gid_hi, (unsigned long long)my_gid_lo); } hfi_lids[nlids++] = (uint32_t) ipaddr; } else { _HFI_VDBG("LID %d, unit %d, port %d, matched " "GID[%d] %llx:%llx and %llx:%llx\n", lid, i, j, idx, (unsigned long long)gid_hi, (unsigned long long)gid_lo, (unsigned long long)my_gid_hi, (unsigned long long)my_gid_lo); hfi_lids[nlids++] = (uint16_t) lid; } } } if (nlids == 0) { err = psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "Couldn't get lid&gid from any unit/port"); goto fail; } } *lids = hfi_lids; *num_lids_o = nlids; fail: return err; } static psm2_error_t psmi_ep_verify_pkey(psm2_ep_t ep, uint16_t pkey, uint16_t *opkey, uint16_t* oindex) { int i, ret; psm2_error_t err; for (i = 0; i < 16; i++) { // TBD - if we adjust HAL to take a hw_context for this function and // put the verbs_ep inside the HAL hw context, we can eliminate this ifdef // and simply call into HAL _HFI_UDDBG("looking for pkey 0x%x\n", pkey); ret = verbs_get_port_index2pkey(ep, ep->portnum, i); if (ret < 0) { err = psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "Can't get a valid pkey value from pkey table\n"); return err; } // pkey == 0 means get slot 0 if (! pkey && ! i) break; if ((pkey & 0x7fff) == (uint16_t)(ret & 0x7fff)) { break; } } /* if pkey does not match */ if (i == 16) { err = psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "Wrong pkey 0x%x, please use PSM3_PKEY to specify a valid pkey\n", pkey); return err; } if (((uint16_t)ret & 0x8000) == 0) { err = psmi_handle_error(NULL, PSM2_EP_DEVICE_FAILURE, "Limited Member pkey 0x%x, please use PSM3_PKEY to specify a valid pkey\n", (uint16_t)ret); return err; } /* return the final pkey */ *opkey = (uint16_t)ret; *oindex = (uint16_t)i; return PSM2_OK; } uint64_t __psm2_epid_nid(psm2_epid_t epid) { uint64_t rv; PSM2_LOG_MSG("entering"); rv = (uint64_t) PSMI_EPID_GET_LID(epid); PSM2_LOG_MSG("leaving"); return rv; } PSMI_API_DECL(psm2_epid_nid) /* Currently not exposed to users, we don't acknowledge the existence of * service levels encoding within epids. This may require * changing to expose SLs */ uint64_t psmi_epid_version(psm2_epid_t epid) { return (uint64_t) PSMI_EPID_GET_EPID_VERSION(epid); } uint64_t __psm2_epid_context(psm2_epid_t epid) { uint64_t rv; PSM2_LOG_MSG("entering"); rv = (uint64_t) PSMI_EPID_GET_CONTEXT(epid); PSM2_LOG_MSG("leaving"); return rv; } PSMI_API_DECL(psm2_epid_context) uint64_t __psm2_epid_port(psm2_epid_t epid) { uint64_t rv; PSM2_LOG_MSG("entering"); rv = __psm2_epid_context(epid); PSM2_LOG_MSG("leaving"); return rv; } PSMI_API_DECL(psm2_epid_port) psm2_error_t __psm2_ep_query(int *num_of_epinfo, psm2_epinfo_t *array_of_epinfo) { psm2_error_t err = PSM2_OK; int i; psm2_ep_t ep; PSM2_LOG_MSG("entering"); PSMI_ERR_UNLESS_INITIALIZED(NULL); if (*num_of_epinfo <= 0) { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "Invalid psm2_ep_query parameters"); PSM2_LOG_MSG("leaving"); return err; } if (psmi_opened_endpoint == NULL) { err = psmi_handle_error(NULL, PSM2_EP_WAS_CLOSED, "PSM Endpoint is closed or does not exist"); PSM2_LOG_MSG("leaving"); return err; } ep = psmi_opened_endpoint; for (i = 0; i < *num_of_epinfo; i++) { if (ep == NULL) break; array_of_epinfo[i].ep = ep; array_of_epinfo[i].epid = ep->epid; array_of_epinfo[i].jkey = ep->jkey; memcpy(array_of_epinfo[i].uuid, (void *)ep->uuid, sizeof(psm2_uuid_t)); psmi_uuid_unparse(ep->uuid, array_of_epinfo[i].uuid_str); ep = ep->user_ep_next; } *num_of_epinfo = i; PSM2_LOG_MSG("leaving"); return err; } PSMI_API_DECL(psm2_ep_query) psm2_error_t __psm2_ep_epid_lookup(psm2_epid_t epid, psm2_epconn_t *epconn) { psm2_error_t err = PSM2_OK; psm2_epaddr_t epaddr; psm2_ep_t ep; PSM2_LOG_MSG("entering"); PSMI_ERR_UNLESS_INITIALIZED(NULL); /* Need to have an opened endpoint before we can resolve epids */ if (psmi_opened_endpoint == NULL) { err = psmi_handle_error(NULL, PSM2_EP_WAS_CLOSED, "PSM Endpoint is closed or does not exist"); PSM2_LOG_MSG("leaving"); return err; } ep = psmi_opened_endpoint; while (ep) { epaddr = psmi_epid_lookup(ep, epid); if (!epaddr) { ep = ep->user_ep_next; continue; } /* Found connection for epid. Return info about endpoint to caller. */ psmi_assert_always(epaddr->ptlctl->ep == ep); epconn->addr = epaddr; epconn->ep = ep; epconn->mq = ep->mq; PSM2_LOG_MSG("leaving"); return err; } err = psmi_handle_error(NULL, PSM2_EPID_UNKNOWN, "Endpoint connection status unknown"); PSM2_LOG_MSG("leaving"); return err; } PSMI_API_DECL(psm2_ep_epid_lookup); psm2_error_t __psm2_ep_epid_lookup2(psm2_ep_t ep, psm2_epid_t epid, psm2_epconn_t *epconn) { psm2_error_t err = PSM2_OK; PSM2_LOG_MSG("entering"); PSMI_ERR_UNLESS_INITIALIZED(NULL); /* Need to have an opened endpoint before we can resolve epids */ if (ep == NULL) { err = psmi_handle_error(NULL, PSM2_EP_WAS_CLOSED, "PSM Endpoint is closed or does not exist"); PSM2_LOG_MSG("leaving"); return err; } if (epconn == NULL) { err = psmi_handle_error(ep, PSM2_PARAM_ERR, "Invalid output parameter"); PSM2_LOG_MSG("leaving"); return err; } psm2_epaddr_t epaddr = psmi_epid_lookup(ep, epid); if (epaddr) { /* Found connection for epid. Return info about endpoint to caller. */ psmi_assert_always(epaddr->ptlctl->ep == ep); epconn->addr = epaddr; epconn->ep = ep; epconn->mq = ep->mq; PSM2_LOG_MSG("leaving"); return err; } err = psmi_handle_error(ep, PSM2_EPID_UNKNOWN, "Endpoint connection status unknown"); PSM2_LOG_MSG("leaving"); return err; } PSMI_API_DECL(psm2_ep_epid_lookup2); psm2_error_t __psm2_epaddr_to_epid(psm2_epaddr_t epaddr, psm2_epid_t *epid) { psm2_error_t err = PSM2_OK; PSM2_LOG_MSG("entering"); if (epaddr && epid) { *epid = epaddr->epid; } else { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "Invalid input epaddr or output epid parameter"); } PSM2_LOG_MSG("leaving"); return err; } PSMI_API_DECL(psm2_epaddr_to_epid); psm2_error_t __psm2_ep_epid_share_memory(psm2_ep_t ep, psm2_epid_t epid, int *result_o) { int result = 0; uint32_t num_lids = 0; uint32_t epid_lid; uint32_t *lids = NULL; int i; psm2_error_t err; PSM2_LOG_MSG("entering"); psmi_assert_always(ep != NULL); PSMI_ERR_UNLESS_INITIALIZED(ep); if ((!psmi_ep_device_is_enabled(ep, PTL_DEVID_IPS)) || (psmi_epid_version(epid) == PSMI_EPID_VERSION_SHM)) { /* If we are in the no hfi-mode, or the other process is, * the epid doesn't help us - so assume both we're on the same * machine and try to connect. */ result = 1; } else { epid_lid = (uint32_t) psm2_epid_nid(epid); err = psmi_ep_devlids(&lids, &num_lids, ep->gid_hi, ep->gid_lo, ep->epid); if (err) { PSM2_LOG_MSG("leaving"); return err; } for (i = 0; i < num_lids; i++) { if (epid_lid == lids[i]) { /* we share memory if the lid is the same. */ result = 1; break; } } } *result_o = result; PSM2_LOG_MSG("leaving"); return PSM2_OK; } PSMI_API_DECL(psm2_ep_epid_share_memory) psm2_error_t __psm2_ep_open_opts_get_defaults(struct psm2_ep_open_opts *opts) { PSM2_LOG_MSG("entering"); PSMI_ERR_UNLESS_INITIALIZED(NULL); if (!opts) return PSM2_PARAM_ERR; /* Set in order in the structure. */ opts->timeout = 30000000000LL; /* 30 sec */ opts->unit = PSM3_NIC_ANY; opts->affinity = PSM2_EP_OPEN_AFFINITY_SET; opts->shm_mbytes = 0; /* deprecated in psm2.h */ opts->sendbufs_num = 1024; opts->network_pkey = psmi_hal_get_default_pkey(); opts->port = PSM3_NIC_PORT_ANY; opts->outsl = PSMI_SL_DEFAULT; opts->service_id = HFI_DEFAULT_SERVICE_ID; opts->path_res_type = PSM2_PATH_RES_NONE; opts->senddesc_num = 4096; opts->imm_size = VERBS_SEND_MAX_INLINE; // PSM header size is 56 PSM2_LOG_MSG("leaving"); return PSM2_OK; } PSMI_API_DECL(psm2_ep_open_opts_get_defaults) psm2_error_t psmi_poll_noop(ptl_t *ptl, int replyonly); psm2_error_t __psm2_ep_open_internal(psm2_uuid_t const unique_job_key, int *devid_enabled, struct psm2_ep_open_opts const *opts_i, psm2_mq_t mq, psm2_ep_t *epo, psm2_epid_t *epido) { psm2_ep_t ep = NULL; uint32_t num_units; size_t len; psm2_error_t err; psm2_epaddr_t epaddr = NULL; char buf[128], *p; union psmi_envvar_val envvar_val; size_t ptl_sizes; struct psm2_ep_open_opts opts; ptl_t *amsh_ptl, *ips_ptl, *self_ptl; int i; /* First get the set of default options, we overwrite with the user's * desired values afterwards */ if ((err = psm2_ep_open_opts_get_defaults(&opts))) goto fail; if (opts_i != NULL) { if (opts_i->timeout != -1) opts.timeout = opts_i->timeout; if (opts_i->unit != -1) opts.unit = opts_i->unit; if (opts_i->affinity != -1) opts.affinity = opts_i->affinity; if (opts_i->sendbufs_num != -1) opts.sendbufs_num = opts_i->sendbufs_num; if (opts_i->network_pkey != psmi_hal_get_default_pkey()) opts.network_pkey = opts_i->network_pkey; if (opts_i->port != 0) opts.port = opts_i->port; if (opts_i->outsl != -1) opts.outsl = opts_i->outsl; if (opts_i->service_id) opts.service_id = (uint64_t) opts_i->service_id; if (opts_i->path_res_type != PSM2_PATH_RES_NONE) opts.path_res_type = opts_i->path_res_type; if (opts_i->senddesc_num) opts.senddesc_num = opts_i->senddesc_num; if (opts_i->imm_size) opts.imm_size = opts_i->imm_size; } /* Get Service ID from environment */ if (!psmi_getenv("PSM3_IB_SERVICE_ID", "Service ID for RV module RC QP connection establishment", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_ULONG_FLAGS, // FLAGS only affects output: hex (union psmi_envvar_val)HFI_DEFAULT_SERVICE_ID, &envvar_val)) { opts.service_id = (uint64_t) envvar_val.e_ulonglong; } opts.path_res_type = PSM2_PATH_RES_NONE; /* If a specific unit is set in the environment, use that one. */ // PSM3_NIC may be a unit name, number, "any" or -1 if (!psmi_getenv("PSM3_NIC", "Device Unit number or name (-1 or 'any' autodetects)", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_STR, (union psmi_envvar_val)"any", &envvar_val)) { if (0 == strcasecmp(envvar_val.e_str, "any")) { opts.unit = PSM3_NIC_ANY; } else { // convert name to a unit number since rest of APIs use number opts.unit = sysfs_find_unit(envvar_val.e_str); if (opts.unit < 0) { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "Unit unknown %s", envvar_val.e_str); goto fail; } } } /* Get user specified port number to use. */ if (!psmi_getenv("PSM3_NIC_PORT", "NIC Port number (0 autodetects)", PSMI_ENVVAR_LEVEL_HIDDEN, PSMI_ENVVAR_TYPE_LONG, (union psmi_envvar_val)PSM3_NIC_PORT_ANY, &envvar_val)) { opts.port = envvar_val.e_long; } /* Get service level from environment, path-query overrides it */ if (!psmi_getenv ("PSM3_NIC_SL", "NIC outging ServiceLevel number (default 0)", PSMI_ENVVAR_LEVEL_HIDDEN, PSMI_ENVVAR_TYPE_LONG, (union psmi_envvar_val)PSMI_SL_DEFAULT, &envvar_val)) { opts.outsl = envvar_val.e_long; } /* Get network key from environment. MVAPICH and other vendor MPIs do not * specify it on ep open and we may require it for vFabrics. * path-query will override it. */ if (!psmi_getenv("PSM3_PKEY", "PKey to use for endpoint (0=use slot 0)", PSMI_ENVVAR_LEVEL_HIDDEN, PSMI_ENVVAR_TYPE_ULONG_FLAGS, // show in hex (union psmi_envvar_val)((unsigned int)(psmi_hal_get_default_pkey())), &envvar_val)) { opts.network_pkey = (uint64_t) envvar_val.e_ulong; } /* BACKWARDS COMPATIBILITY: Open MPI likes to choose its own PKEY of 0x7FFF. That's no longer a valid default, so override it if the client was compiled against PSM v1 */ if (PSMI_VERNO_GET_MAJOR(psmi_verno_client()) < 2 && opts.network_pkey == 0x7FFF) { opts.network_pkey = psmi_hal_get_default_pkey();; } /* Get number of default send buffers from environment */ if (!psmi_getenv("PSM3_NUM_SEND_BUFFERS", "Number of send buffers to allocate [1024]", PSMI_ENVVAR_LEVEL_HIDDEN, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)1024, &envvar_val)) { opts.sendbufs_num = envvar_val.e_uint; } /* Get immediate data size - transfers less than immediate data size do * not consume a send buffer and require just a send descriptor. */ if (!psmi_getenv("PSM3_SEND_IMMEDIATE_SIZE", "Immediate data send size not requiring a buffer [128]", PSMI_ENVVAR_LEVEL_HIDDEN, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)128, &envvar_val)) { opts.imm_size = envvar_val.e_uint; } /* Get number of send descriptors - by default this is 4 times the number * of send buffers - mainly used for short/inlined messages. */ if (!psmi_getenv("PSM3_NUM_SEND_DESCRIPTORS", "Number of send descriptors to allocate [4096]", PSMI_ENVVAR_LEVEL_HIDDEN, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)4096, &envvar_val)) { opts.senddesc_num = envvar_val.e_uint; } if (psmi_device_is_enabled(devid_enabled, PTL_DEVID_IPS)) { if ((err = psm2_ep_num_devunits(&num_units)) != PSM2_OK) goto fail; } else num_units = 0; /* do some error checking */ if (opts.timeout < -1) { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "Invalid timeout value %lld", (long long)opts.timeout); goto fail; } else if (num_units && (opts.unit < -1 || opts.unit >= (int)num_units)) { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "Invalid Device Unit ID %d (%d units found)", opts.unit, num_units); goto fail; } else if ((opts.port < HFI_MIN_PORT || opts.port > HFI_MAX_PORT) && opts.port != PSM3_NIC_PORT_ANY) { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "Invalid Device port number %d", opts.port); goto fail; } else if (opts.affinity < 0 || opts.affinity > PSM2_EP_OPEN_AFFINITY_FORCE) { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "Invalid Affinity option: %d", opts.affinity); goto fail; } else if (opts.outsl < PSMI_SL_MIN || opts.outsl > PSMI_SL_MAX) { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "Invalid SL number: %lld", (unsigned long long)opts.outsl); goto fail; } /* Allocate end point structure storage */ ptl_sizes = (psmi_device_is_enabled(devid_enabled, PTL_DEVID_SELF) ? psmi_ptl_self.sizeof_ptl() : 0) + (psmi_device_is_enabled(devid_enabled, PTL_DEVID_IPS) ? psmi_ptl_ips.sizeof_ptl() : 0) + (psmi_device_is_enabled(devid_enabled, PTL_DEVID_AMSH) ? psmi_ptl_amsh.sizeof_ptl() : 0); if (ptl_sizes == 0) return PSM2_EP_NO_DEVICE; ep = (psm2_ep_t) psmi_memalign(PSMI_EP_NONE, UNDEFINED, 64, sizeof(struct psm2_ep) + ptl_sizes); epaddr = (psm2_epaddr_t) psmi_calloc(PSMI_EP_NONE, PER_PEER_ENDPOINT, 1, sizeof(struct psm2_epaddr)); if (ep == NULL || epaddr == NULL) { err = psmi_handle_error(NULL, PSM2_NO_MEMORY, "Couldn't allocate memory for %s structure", ep == NULL ? "psm2_ep" : "psm2_epaddr"); goto fail; } memset(ep, 0, sizeof(struct psm2_ep) + ptl_sizes); /* Copy PTL enabled status */ for (i = 0; i < PTL_MAX_INIT; i++) ep->devid_enabled[i] = devid_enabled[i]; /* Matched Queue initialization. We do this early because we have to * make sure ep->mq exists and is valid before calling ips_do_work. */ ep->mq = mq; /* Get ready for PTL initialization */ memcpy(&ep->uuid, (void *)unique_job_key, sizeof(psm2_uuid_t)); ep->epaddr = epaddr; ep->memmode = mq->memmode; ep->hfi_num_sendbufs = opts.sendbufs_num; ep->service_id = opts.service_id; ep->path_res_type = opts.path_res_type; ep->hfi_num_descriptors = opts.senddesc_num; ep->hfi_imm_size = opts.imm_size; ep->errh = psmi_errhandler_global; /* by default use the global one */ ep->ptl_amsh.ep_poll = psmi_poll_noop; ep->ptl_ips.ep_poll = psmi_poll_noop; ep->connections = 0; ep->rdmamode = psmi_parse_rdmamode(); // PSM3_RDMA /* MR cache mode */ // we need this early when creating the verbs_ep since it may affect // if we open rv module. // The value returned is a MR_CACHE_MODE_* selection { union psmi_envvar_val env_mr_cache_mode; if (! (ep->rdmamode & IPS_PROTOEXP_FLAG_ENABLED)) { env_mr_cache_mode.e_uint = MR_CACHE_MODE_NONE; } else if (IPS_PROTOEXP_FLAG_KERNEL_QP(ep->rdmamode)) { // RDMA enabled in kernel mode. Must use rv MR cache env_mr_cache_mode.e_uint = MR_CACHE_MODE_RV; } else { /* Behavior of user space MR Cache * when 0, we merely share MRs for concurrently used buffers */ // mode 2 (user space MR w/cache) is purposely not documented psmi_getenv("PSM3_MR_CACHE_MODE", "Enable MR caching 0=user space MR no cache" #ifdef RNDV_MOD ", 1=kernel MR w/cache [1]", #else "[0]", #endif PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, #ifdef RNDV_MOD (union psmi_envvar_val)MR_CACHE_MODE_KERNEL, #else (union psmi_envvar_val)MR_CACHE_MODE_NONE, #endif &env_mr_cache_mode); if (! MR_CACHE_MODE_VALID(env_mr_cache_mode.e_uint) || env_mr_cache_mode.e_uint == MR_CACHE_MODE_RV) env_mr_cache_mode.e_uint = MR_CACHE_MODE_NONE; } #ifndef RNDV_MOD if (env_mr_cache_mode.e_uint == MR_CACHE_MODE_KERNEL) env_mr_cache_mode.e_uint = MR_CACHE_MODE_NONE; #endif ep->mr_cache_mode = env_mr_cache_mode.e_uint; } /* See how many iterations we want to spin before yielding */ psmi_getenv("PSM3_YIELD_SPIN_COUNT", "Spin poll iterations before yield", PSMI_ENVVAR_LEVEL_HIDDEN, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)PSMI_BLOCKUNTIL_POLLS_BEFORE_YIELD, &envvar_val); ep->yield_spin_cnt = envvar_val.e_uint; /* Set skip_affinity flag if PSM is not allowed to set affinity */ if (opts.affinity == PSM2_EP_OPEN_AFFINITY_SKIP) ep->skip_affinity = true; ptl_sizes = 0; amsh_ptl = ips_ptl = self_ptl = NULL; if (psmi_ep_device_is_enabled(ep, PTL_DEVID_AMSH)) { amsh_ptl = (ptl_t *) (ep->ptl_base_data + ptl_sizes); ptl_sizes += psmi_ptl_amsh.sizeof_ptl(); } if (psmi_ep_device_is_enabled(ep, PTL_DEVID_IPS)) { ips_ptl = (ptl_t *) (ep->ptl_base_data + ptl_sizes); ptl_sizes += psmi_ptl_ips.sizeof_ptl(); } if (psmi_ep_device_is_enabled(ep, PTL_DEVID_SELF)) { self_ptl = (ptl_t *) (ep->ptl_base_data + ptl_sizes); ptl_sizes += psmi_ptl_self.sizeof_ptl(); } /* Get number of send WQEs */ psmi_getenv("PSM3_NUM_SEND_WQES", "Number of send WQEs to allocate [4080]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)VERBS_SEND_QP_ENTRIES, &envvar_val); ep->hfi_num_send_wqes = envvar_val.e_uint; psmi_getenv("PSM3_SEND_REAP_THRESH", "Number of outstanding send WQEs before reap CQEs [256]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)VERBS_SEND_CQ_REAP, &envvar_val); ep->hfi_send_reap_thresh = envvar_val.e_uint; psmi_getenv("PSM3_NUM_SEND_RDMA", "Number of user space send RDMA to allow [128]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)VERBS_NUM_SEND_RDMA, &envvar_val); ep->hfi_num_send_rdma = envvar_val.e_uint; /* Get number of recv WQEs */ psmi_getenv("PSM3_NUM_RECV_WQES", "Number of recv WQEs to allocate [4095]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)VERBS_RECV_QP_ENTRIES, &envvar_val); ep->hfi_num_recv_wqes = envvar_val.e_uint; /* Get number of recv CQEs */ psmi_getenv("PSM3_NUM_RECV_CQES", "Number of recv CQEs to allocate\n" "(0 will calculate as PSM3_NUM_RECV_WQES+1032 for PSM3_RDMA=0-2\n" "and 4000 more than that for PSM3_RDMA=3]) [0]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)0, &envvar_val); ep->hfi_num_recv_cqes = envvar_val.e_uint; /* Get RC QP timeout and retry */ psmi_getenv("PSM3_QP_TIMEOUT", "Number of microseconds for RC QP timeouts [536870]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_ULONG, (union psmi_envvar_val)VERBS_QP_TIMEOUT, &envvar_val); ep->hfi_qp_timeout = timeout_usec_to_mult(envvar_val.e_ulong); psmi_getenv("PSM3_QP_RETRY", "Limit on retries after RC QP timeout or RNR [7]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)VERBS_QP_RETRY, &envvar_val); ep->hfi_qp_retry = (envvar_val.e_uint <= VERBS_QP_MAX_RETRY)? envvar_val.e_uint:VERBS_QP_MAX_RETRY; /* Size of RV Cache - only used for MR_CACHE_MODE_RV or KERNEL, * otherwise ignored */ psmi_getenv("PSM3_RV_MR_CACHE_SIZE", "kernel space MR cache size" " (MBs, 0 lets rv module decide) [0]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)0, &envvar_val); // TBD - min should be (HFI_TF_NFLOWS + ep->hfi_num_send_rdma) * // chunk size (mq->hfi_base_window_rv after psmi_mq_initialize_defaults // TBD actual window_sz may be larger than mq->hfi_base_window_rv ep->rv_mr_cache_size = envvar_val.e_uint; psmi_getenv("PSM3_RV_QP_PER_CONN", "Number of sets of RC QPs per RV connection (0 lets rv module decide) [0]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)0, &envvar_val); ep->rv_num_conn = envvar_val.e_uint; psmi_getenv("PSM3_RV_Q_DEPTH", "Size of QPs and CQs per RV QP (0 lets rv module decide) [0]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)0, &envvar_val); ep->rv_q_depth = envvar_val.e_uint; psmi_getenv("PSM3_RV_RECONNECT_TIMEOUT", "RV End-point minimum re-connection timeout in seconds. 0 for no connection recovery [30]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)30, &envvar_val); ep->rv_reconnect_timeout = envvar_val.e_uint; psmi_getenv("PSM3_RV_HEARTBEAT_INTERVAL", "RV End-point heartbeat interval in milliseconds. 0 for no heartbeat [1000]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)1000, &envvar_val); ep->rv_hb_interval = envvar_val.e_uint; // HFI Interface. if ((err = psmi_ep_open_device(ep, &opts, unique_job_key, &(ep->context), &ep->epid))) goto fail; if (psmi_ep_device_is_enabled(ep, PTL_DEVID_IPS)) { _HFI_UDDBG("my QPN=%u (0x%x) EPID=0x%"PRIx64" %s\n", ep->verbs_ep.qp->qp_num, ep->verbs_ep.qp->qp_num, (uint64_t)ep->epid, psmi_epaddr_fmt_addr(ep->epid)); } psmi_assert_always(ep->epid != 0); ep->epaddr->epid = ep->epid; _HFI_VDBG("psmi_ep_open_device() passed\n"); /* Set our new label as soon as we know what it is */ strncpy(buf, psmi_gethostname(), sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; p = buf + strlen(buf); /* If our rank is set, use it (same as mylabel). If not, use context */ /* hostname.rank# or hostname.# (context), or hostname.pid# */ if (hfi_get_myrank() >= 0) len = snprintf(p, sizeof(buf) - strlen(buf), ":rank%d.", hfi_get_myrank()); else len = snprintf(p, sizeof(buf) - strlen(buf), ":"PSMI_EPID_CONTEXT_FMT".", PSMI_EPID_GET_CONTEXT_VAL(ep->epid)); *(p + len) = '\0'; ep->context_mylabel = psmi_strdup(ep, buf); if (ep->context_mylabel == NULL) { err = PSM2_NO_MEMORY; goto fail; } /* hfi_set_mylabel(ep->context_mylabel); */ if ((err = psmi_epid_set_hostname(psm2_epid_nid(ep->epid), buf, 0))) goto fail; _HFI_VDBG("start ptl device init...\n"); if (psmi_ep_device_is_enabled(ep, PTL_DEVID_SELF)) { if ((err = psmi_ptl_self.init(ep, self_ptl, &ep->ptl_self))) goto fail; } if (psmi_ep_device_is_enabled(ep, PTL_DEVID_IPS)) { if ((err = psmi_ptl_ips.init(ep, ips_ptl, &ep->ptl_ips))) goto fail; } /* If we're shm-only, this device is enabled above */ if (psmi_ep_device_is_enabled(ep, PTL_DEVID_AMSH)) { if ((err = psmi_ptl_amsh.init(ep, amsh_ptl, &ep->ptl_amsh))) goto fail; } else { /* We may have pre-attached as part of getting our rank for enabling * shared contexts. */ } _HFI_VDBG("finish ptl device init...\n"); /* * Keep only IPS since only IPS support multi-rail, other devices * are only setup once. IPS device can come to this function again. */ for (i = 0; i < PTL_MAX_INIT; i++) { if (devid_enabled[i] != PTL_DEVID_IPS) { devid_enabled[i] = -1; } } *epido = ep->epid; *epo = ep; return PSM2_OK; fail: if (ep != NULL) { psmi_hal_close_context(&ep->context.psm_hw_ctxt); psmi_free(ep); } if (epaddr != NULL) psmi_free(epaddr); return err; } psm2_error_t __psm2_ep_open(psm2_uuid_t const unique_job_key, struct psm2_ep_open_opts const *opts_i, psm2_ep_t *epo, psm2_epid_t *epido) { psm2_error_t err; psm2_mq_t mq; psm2_epid_t epid; psm2_ep_t ep, tmp; uint32_t units[PSMI_MAX_QPS]; uint16_t ports[PSMI_MAX_QPS]; int i, num_rails = 0; char *uname = "PSM3_NIC"; char *pname = "PSM3_NIC_PORT"; char uvalue[6], pvalue[6]; int devid_enabled[PTL_MAX_INIT]; union psmi_envvar_val devs; int show_nics = 0; PSM2_LOG_MSG("entering"); PSMI_ERR_UNLESS_INITIALIZED(NULL); if (!epo || !epido) return PSM2_PARAM_ERR; /* Allowing only one EP (unless explicitly enabled). */ if (psmi_opened_endpoint_count > 0 && !psmi_multi_ep_enabled) { PSM2_LOG_MSG("leaving"); return PSM2_TOO_MANY_ENDPOINTS; } /* Matched Queue initialization. We do this early because we have to * make sure ep->mq exists and is valid before calling ips_do_work. */ err = psmi_mq_malloc(&mq); PSMI_LOCK(psmi_creation_lock); if (err != PSM2_OK) goto fail; /* Set some of the MQ thresholds from the environment. Do this before ptl initialization - the ptl may have other constraints that will limit the MQ's settings. */ err = psmi_mq_initialize_defaults(mq); if (err != PSM2_OK) goto fail; psmi_init_lock(&(mq->progress_lock)); /* See which ptl devices we want to use for this ep to be opened */ psmi_getenv("PSM3_DEVICES", "Ordered list of PSM-level devices", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_STR, (union psmi_envvar_val)PSMI_DEVICES_DEFAULT, &devs); if ((err = psmi_parse_devices(devid_enabled, devs.e_str))) goto fail; if (psmi_device_is_enabled(devid_enabled, PTL_DEVID_IPS)) { show_nics = psmi_parse_identify(); err = psmi_ep_multirail(&num_rails, units, ports); if (err != PSM2_OK) goto fail; /* If multi-rail is used, set the first ep unit/port */ if (num_rails > 0) { snprintf(uvalue, 6, "%1d", units[0]); snprintf(pvalue, 6, "%1d", ports[0]); setenv(uname, uvalue, 1); setenv(pname, pvalue, 1); } } #ifdef PSM_CUDA if (PSMI_IS_GDR_COPY_ENABLED) hfi_gdr_open(); #endif err = __psm2_ep_open_internal(unique_job_key, devid_enabled, opts_i, mq, &ep, &epid); if (err != PSM2_OK) goto fail; if (psmi_opened_endpoint == NULL) { psmi_opened_endpoint = ep; } else { tmp = psmi_opened_endpoint; while (tmp->user_ep_next) tmp = tmp->user_ep_next; tmp->user_ep_next = ep; } psmi_opened_endpoint_count++; ep->mctxt_prev = ep->mctxt_next = ep; ep->mctxt_master = ep; mq->ep = ep; if (show_nics) printf("%s %s NIC %u (%s) Port %u\n", hfi_get_mylabel(), hfi_ident_tag, ep->unit_id, sysfs_unit_dev_name(ep->unit_id), ep->portnum); /* Active Message initialization */ err = psmi_am_init_internal(ep); if (err != PSM2_OK) goto fail; *epo = ep; *epido = epid; if (psmi_device_is_enabled(devid_enabled, PTL_DEVID_IPS)) { int j; union psmi_envvar_val envvar_val; if (num_rails <= 0) { // the NIC has now been selected for our process // use the same NIC for any additional QPs below num_rails = 1; units[0] = ep->unit_id; ports[0] = ep->portnum; } // When QP_PER_NIC >1, creates more than 1 QP on each NIC and then // uses the multi-rail algorithms to spread the traffic across QPs // This helps get better BW when there are relatively few processes/node // care must be taken when combining this with user space RC QPs as // scalability (memory footprint) issues can be multiplied // This approach duplicates some per NIC resources (CQs, etc) but // provides a simple approach psmi_getenv("PSM3_QP_PER_NIC", "Number of sets of QPs to open per NIC [1]", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)1, &envvar_val); if ((num_rails * envvar_val.e_uint) > PSMI_MAX_QPS) { err = psmi_handle_error(NULL, PSM2_TOO_MANY_ENDPOINTS, "PSM3_QP_PER_NIC (%u) * num_rails (%d) > Max Support QPs (%u)", envvar_val.e_uint, num_rails, PSMI_MAX_QPS); goto fail; } for (j= 0; j< envvar_val.e_uint; j++) { for (i = 0; i < num_rails; i++) { _HFI_VDBG("rail %d unit %u port %u\n", i, units[i], ports[i]); // did 0, 0 already above if (i == 0 && j== 0) continue; snprintf(uvalue, 6, "%1d", units[i]); snprintf(pvalue, 6, "%1d", ports[i]); setenv(uname, uvalue, 1); setenv(pname, pvalue, 1); /* Create slave EP */ err = __psm2_ep_open_internal(unique_job_key, devid_enabled, opts_i, mq, &tmp, &epid); if (err) goto fail; /* Point back to shared resources on the master EP */ tmp->am_htable = ep->am_htable; /* Link slave EP after master EP. */ PSM_MCTXT_APPEND(ep, tmp); if (j == 0 && show_nics) printf("%s %s NIC %u (%s) Port %u\n", hfi_get_mylabel(), hfi_ident_tag, tmp->unit_id, sysfs_unit_dev_name(tmp->unit_id), tmp->portnum); } } } _HFI_VDBG("psm2_ep_open() OK....\n"); fail: fflush(stdout); PSMI_UNLOCK(psmi_creation_lock); PSM2_LOG_MSG("leaving"); return err; } PSMI_API_DECL(psm2_ep_open) psm2_error_t __psm2_ep_close(psm2_ep_t ep, int mode, int64_t timeout_in) { psm2_error_t err = PSM2_OK; psmi_stats_ep_close(); // allow output of stats on 1st ep close if desired #if _HFI_DEBUGGING uint64_t t_start = 0; if (_HFI_PRDBG_ON) { t_start = get_cycles(); } #endif #ifdef PSM_CUDA /* * The close on the gdr fd needs to be called before the * close on the hfi fd as the the gdr device will hold * reference count on the hfi device which will make the close * on the hfi fd return without actually closing the fd. */ if (PSMI_IS_GDR_COPY_ENABLED) hfi_gdr_close(); #endif union psmi_envvar_val timeout_intval; psm2_ep_t tmp; psm2_mq_t mmq; PSM2_LOG_MSG("entering"); PSMI_ERR_UNLESS_INITIALIZED(ep); psmi_assert_always(ep->mctxt_master == ep); PSMI_LOCK(psmi_creation_lock); psmi_am_fini_internal(ep); if (psmi_opened_endpoint == NULL) { err = psmi_handle_error(NULL, PSM2_EP_WAS_CLOSED, "PSM Endpoint is closed or does not exist"); PSM2_LOG_MSG("leaving"); PSMI_UNLOCK(psmi_creation_lock); return err; } tmp = psmi_opened_endpoint; while (tmp && tmp != ep) { tmp = tmp->user_ep_next; } if (!tmp) { err = psmi_handle_error(NULL, PSM2_EP_WAS_CLOSED, "PSM Endpoint is closed or does not exist"); PSM2_LOG_MSG("leaving"); PSMI_UNLOCK(psmi_creation_lock); return err; } psmi_getenv("PSM3_CLOSE_TIMEOUT", "End-point close timeout over-ride.", PSMI_ENVVAR_LEVEL_HIDDEN, PSMI_ENVVAR_TYPE_UINT, (union psmi_envvar_val)0, &timeout_intval); if (getenv("PSM3_CLOSE_TIMEOUT")) { timeout_in = timeout_intval.e_uint * SEC_ULL; } else if (timeout_in > 0) { /* The timeout parameter provides the minimum timeout. A heuristic * is used to scale up the timeout linearly with the number of * endpoints, and we allow one second per 100 endpoints. */ timeout_in = max(timeout_in, (ep->connections * SEC_ULL) / 100); } if (timeout_in > 0 && timeout_in < PSMI_MIN_EP_CLOSE_TIMEOUT) timeout_in = PSMI_MIN_EP_CLOSE_TIMEOUT; /* Infinite and excessive close time-out are limited here to a max. * The "rationale" is that there is no point waiting around forever for * graceful termination. Normal (or forced) process termination should clean * up the context state correctly even if termination is not graceful. */ if (timeout_in <= 0 || timeout_in > PSMI_MAX_EP_CLOSE_TIMEOUT) timeout_in = PSMI_MAX_EP_CLOSE_TIMEOUT; _HFI_PRDBG("Closing endpoint %p with force=%s and to=%.2f seconds and " "%d connections\n", ep, mode == PSM2_EP_CLOSE_FORCE ? "YES" : "NO", (double)timeout_in / 1e9, (int)ep->connections); /* XXX We currently cheat in the sense that we leave each PTL the allowed * timeout. There's no good way to do this until we change the PTL * interface to allow asynchronous finalization */ /* Check if transfer ownership of receive thread is needed before closing ep. * In case of PSM3_MULTI_EP support receive thread is created and assigned * to first opened endpoint. Receive thread is killed when closing this * endpoint. */ if (ep->user_ep_next != NULL) { /* Receive thread will be transfered and assigned to ep->user_ep_next * only if currently working receive thread (which will be killed) is * assigned to ep and there isn't any assigned to ep->user_ep_next. */ if ((psmi_ptl_ips_rcvthread.is_enabled(ep->ptl_ips.ptl)) && (!psmi_ptl_ips_rcvthread.is_enabled(ep->user_ep_next->ptl_ips.ptl))) psmi_ptl_ips_rcvthread.transfer_ownership(ep->ptl_ips.ptl, ep->user_ep_next->ptl_ips.ptl); } /* * Before freeing the master ep itself, * remove it from the global linklist. * We do it here to let atexit handler in ptl_am directory * to search the global linklist and free the shared memory file. */ if (psmi_opened_endpoint == ep) { /* Removing ep from global endpoint list. */ psmi_opened_endpoint = ep->user_ep_next; } else { tmp = psmi_opened_endpoint; while (tmp->user_ep_next != ep) { tmp = tmp->user_ep_next; } /* Removing ep from global endpoint list. */ tmp->user_ep_next = ep->user_ep_next; } psmi_opened_endpoint_count--; /* * This do/while loop is used to close and free memory of endpoints. * * If MULTIRAIL feature is disable this loop will be passed only once * and only endpoint passed in psm2_ep_close will be closed/removed. * * If MULTIRAIL feature is enabled then this loop will be passed * multiple times (depending on number of rails). The order in which * endpoints will be closed is shown below: * * |--this is master endpoint in case of multirail * | this endpoint is passed to psm2_ep_close and * V this is only endpoint known to user. * +<-Ep0<-Ep1<-Ep2<-Ep3 * |__________________| Ep3->mctxt_prev points to Ep2 * (3) (2) (1) (4) Ep2->mctxt_prev points to Ep1 * ^ Ep1->mctxt_prev points to Ep0 * | Ep0->mctxt_prev points to Ep3 (master ep) * | * |---- order in which endpoints will be closed. * * Closing MULTIRAILs starts by closing slaves (Ep2, Ep1, Ep0) * If MULTIRAIL is enabled then Ep3->mctxt_prev will point to Ep2, if * feature is disabled then Ep3->mctxt_prev will point to Ep3 and * do/while loop will have one pass. * * In case of MULTIRAIL enabled Ep3 which is master endpoint will be * closed as the last one. */ mmq = ep->mq; if (mmq) { // in case mq_finalize not called, need to get stats out // it will be a noop if called twice psm2_mq_finalize(mmq); } tmp = ep->mctxt_prev; do { ep = tmp; tmp = ep->mctxt_prev; PSMI_LOCK(ep->mq->progress_lock); PSM_MCTXT_REMOVE(ep); if (psmi_ep_device_is_enabled(ep, PTL_DEVID_AMSH)) err = psmi_ptl_amsh.fini(ep->ptl_amsh.ptl, mode, timeout_in); if ((err == PSM2_OK || err == PSM2_TIMEOUT) && psmi_ep_device_is_enabled(ep, PTL_DEVID_IPS)) err = psmi_ptl_ips.fini(ep->ptl_ips.ptl, mode, timeout_in); /* If there's timeouts in the disconnect requests, * still make sure that we still get to close the *endpoint and mark it closed */ if (psmi_ep_device_is_enabled(ep, PTL_DEVID_IPS)) psmi_context_close(&ep->context); psmi_epid_remove_all(ep); psmi_free(ep->epaddr); psmi_free(ep->context_mylabel); PSMI_UNLOCK(ep->mq->progress_lock); ep->mq = NULL; __psm2_ep_free_verbs(ep); psmi_free(ep); } while ((err == PSM2_OK || err == PSM2_TIMEOUT) && tmp != ep); if (mmq) { psmi_destroy_lock(&(mmq->progress_lock)); err = psmi_mq_free(mmq); } if (hfi_lids) { psmi_free(hfi_lids); hfi_lids = NULL; nlids = 0; } PSMI_UNLOCK(psmi_creation_lock); if (_HFI_PRDBG_ON) { _HFI_PRDBG_ALWAYS("Closed endpoint in %.3f secs\n", (double)cycles_to_nanosecs(get_cycles() - t_start) / SEC_ULL); } PSM2_LOG_MSG("leaving"); return err; } PSMI_API_DECL(psm2_ep_close) static psm2_error_t psmi_ep_open_device(const psm2_ep_t ep, const struct psm2_ep_open_opts *opts, const psm2_uuid_t unique_job_key, struct psmi_context *context, psm2_epid_t *epid) { psm2_error_t err = PSM2_OK; /* Skip affinity. No affinity if: * 1. User explicitly sets no-affinity=YES in environment. * 2. User doesn't set affinity in environment and PSM is opened with * option affinity skip. */ if (psmi_ep_device_is_enabled(ep, PTL_DEVID_IPS)) { union psmi_envvar_val env_rcvthread; static int norcvthread; /* only for first rail */ ep->out_sl = opts->outsl; if ((err = psmi_context_open(ep, opts->unit, opts->port, unique_job_key, opts->timeout, context)) != PSM2_OK) goto fail; _HFI_DBG("[%d]use unit %d port %d\n", getpid(), ep->unit_id, 1); /* At this point, we have the unit id and port number, so * check if pkey is not 0x0/0x7fff/0xffff, and match one * of the pkey in table. */ if ((err = psmi_ep_verify_pkey(ep, (uint16_t) opts->network_pkey, &ep->network_pkey, &ep->network_pkey_index)) != PSM2_OK) goto fail; /* See if we want to activate support for receive thread */ psmi_getenv("PSM3_RCVTHREAD", "Enable Recv thread (0 disables thread)", PSMI_ENVVAR_LEVEL_USER, PSMI_ENVVAR_TYPE_UINT_FLAGS, // default to 0 for all but 1st rail (union psmi_envvar_val)(norcvthread++ ? 0 : PSMI_RCVTHREAD_FLAGS), &env_rcvthread); /* If enabled, use the polling capability to implement a receive * interrupt thread that can handle urg packets */ if (env_rcvthread.e_uint) { psmi_hal_add_sw_status(PSM_HAL_PSMI_RUNTIME_RTS_RX_THREAD); #ifdef PSMI_PLOCK_IS_NOLOCK psmi_handle_error(PSMI_EP_NORETURN, PSM2_INTERNAL_ERR, "#define PSMI_PLOCK_IS_NOLOCK not functional yet " "with RCVTHREAD on"); #endif } *epid = context->epid; } else if (psmi_ep_device_is_enabled(ep, PTL_DEVID_AMSH)) { *epid = PSMI_EPID_PACK_SHM(getpid(), PSMI_EPID_SHM_ONLY); /*is a only-shm epid */ } else { /* Self-only, meaning only 1 proc max */ *epid = PSMI_EPID_PACK_SHM(0, PSMI_EPID_SHM_ONLY); /*is a only-shm epid */ } fail: return err; } /* Get a list of PTLs we want to use. The order is important, it affects * whether node-local processes use shm or ips */ static psm2_error_t psmi_parse_devices(int devices[PTL_MAX_INIT], const char *devstring) { char *devstr = NULL; char *b_new, *e, *ee, *b; psm2_error_t err = PSM2_OK; int len; int i = 0; psmi_assert_always(devstring != NULL); len = strlen(devstring) + 1; for (i = 0; i < PTL_MAX_INIT; i++) devices[i] = -1; devstr = (char *)psmi_calloc(PSMI_EP_NONE, UNDEFINED, 2, len); if (devstr == NULL) goto fail; b_new = (char *)devstr; e = b_new + len; strncpy(e, devstring, len); ee = e + len; i = 0; while (e < ee && *e && i < PTL_MAX_INIT) { while (*e && !isalpha(*e)) e++; b = e; while (*e && isalpha(*e)) e++; *e = '\0'; if (*b) { if (!strcasecmp(b, "self")) { devices[i++] = PTL_DEVID_SELF; b_new = strcpy(b_new, "self,"); b_new += 5; } else if (!strcasecmp(b, "shm") || !strcasecmp(b, "shmem") || !strcasecmp(b, "amsh")) { devices[i++] = PTL_DEVID_AMSH; strcpy(b_new, "amsh,"); b_new += 5; } else if (!strcasecmp(b, "hfi") || !strcasecmp(b, "nic") || !strcasecmp(b, "ipath") || !strcasecmp(b, "ips")) { devices[i++] = PTL_DEVID_IPS; strcpy(b_new, "ips,"); b_new += 4; } else { err = psmi_handle_error(NULL, PSM2_PARAM_ERR, "%s set in environment variable PSM_PTL_DEVICES=\"%s\" " "is not one of the recognized PTL devices (%s)", b, devstring, PSMI_DEVICES_DEFAULT); goto fail; } e++; } } if (b_new != devstr) /* we parsed something, remove trailing comma */ *(b_new - 1) = '\0'; _HFI_PRDBG("PSM Device allocation order: %s\n", devstr); fail: if (devstr != NULL) psmi_free(devstr); return err; } static int psmi_device_is_enabled(const int devid_enabled[PTL_MAX_INIT], int devid) { int i; for (i = 0; i < PTL_MAX_INIT; i++) if (devid_enabled[i] == devid) return 1; return 0; } int psmi_ep_device_is_enabled(const psm2_ep_t ep, int devid) { return psmi_device_is_enabled(ep->devid_enabled, devid); }
1.367188
1
tabelas_hashing/enderecamento_livre/ohtbl.c
Fazendaaa/C
0
7999235
/* Autor: <NAME> */ /* nome do arquivo: ohtbl.c */ #include "ohtbl.h" static char vacated; /* */ OHTBL * ohtbl_initialize ( int positions, int ( * h1 ) ( const void * key ), int ( * h2 ) ( const void * key ), int ( * match ) ( const void * key_1 , const void * key_2 ), void ( * destroy ) ( void * data ) ) { OHTBL *new = NULL; if ( positions > 0 ) { new = ( OHTBL * ) malloc ( sizeof ( OHTBL ) ); if ( new != NULL ) { new->positions = positions; new->vacated = &vacated; new->h1 = h1; new->h2 = h2; new->match = match; new->destroy = destroy; new->size = 0; new->table = ( void ** ) malloc ( sizeof ( void * ) * positions ); } } return new; } /* */ void ohtble_destroy ( OHTBL * ohtbl ) { unsigned int i = 0; if ( ( ohtbl != NULL ) && ( ohtbl->destroy != NULL ) ) { for ( ; i < ohtbl->positions; i++ ) { if ( ( ohtbl->table[ i ] != NULL ) && ( ohtbl->table[ i ] != ohtbl->vacated ) ) ohtbl->destroy ( ohtbl->table[ i ] ); } free ( ohtbl->table ); free ( ohtbl ); } } /* */ int ohtbl_insert ( OHTBL * ohtbl, void * data ) { unsigned int pos = 0, i = 0; if ( ( ohtbl == NULL ) || ( data == NULL ) ) return ERROR; else if ( ohtbl_size( ohtbl ) != ohtbl->positions ) { if ( ohtbl_lookup ( ohtbl, data ) == NULL ) { for ( ; i < ohtbl->positions; i++ ) { pos = ( ohtbl->h1 ( data ) + ( i * ohtbl->h2 ( data ) ) ) % ohtbl->positions; if ( ( ohtbl->table[ pos ] == NULL ) || ( ohtbl->table[ pos ] == ohtbl->vacated ) ) break; } ohtbl->table[ pos ] = data; ohtbl->size++; return SUCESS; } else return EXIST; } else return ERROR; } /* */ void * ohtbl_remove ( OHTBL * ohtbl, void * data ) { unsigned int pos = 0, i = 0; void *rtnval = NULL; if ( ( ohtbl == NULL ) || ( data == NULL ) ) return NULL; else { if ( ohtbl_lookup ( ohtbl, data ) != NULL ) { for ( ; i < ohtbl->positions; i++ ) { pos = ( ohtbl->h1 ( data ) + ( i * ohtbl->h2 ( data ) ) ) % ohtbl->positions; if ( ohtbl->table[ pos ] == NULL ) break; else if ( ohtbl->table[ pos ] == ohtbl->vacated ) continue; else if ( !ohtbl->match ( ohtbl->table[ pos ], data ) ) { rtnval = ohtbl->table[ pos ]; ohtbl->table[ pos ] = ohtbl->vacated; ohtbl->size--; break; } } } return rtnval; } } /* */ void * ohtbl_lookup ( const OHTBL * ohtbl, const void * data ) { unsigned int pos = 0, i = 0; void *rtnval = NULL; if ( ( ohtbl == NULL ) || ( data == NULL ) ) return NULL; else { for ( ; i < ohtbl->positions; i++ ) { pos = ( ohtbl->h1 ( data ) + ( i * ohtbl->h2 ( data ) ) ) % ohtbl->positions; if ( ohtbl->table[ pos ] == NULL ) break; else if ( !ohtbl->match ( ohtbl->table[ pos ], data ) ) { rtnval = ohtbl->table[ pos ]; break; } } return rtnval; } }
1.8125
2
src/sample_app/app003_compute/pipeline_003.h
acuvue1102/si_graphics
0
7999243
#pragma once #include <cstdint> #include <si_app/pipeline/pipeline_base.h> #include <si_base/math/math_declare.h> namespace SI { namespace APP003 { class Pipeline : public PipelineBase { public: explicit Pipeline(int observerSortKey); virtual ~Pipeline(); int OnInitialize(const AppInitializeInfo&) override; int OnTerminate() override; void OnUpdate(const App& app, const AppUpdateInfo&) override; void OnRender(const App& app, const AppUpdateInfo&) override; int LoadAsset(const AppInitializeInfo& info); protected: struct IblLutShaderConstant; struct TextureShaderConstant; protected: GfxRootSignatureEx m_computeRootSignatures; GfxRootSignatureEx m_rootSignatures; GfxComputeState m_computeStates; GfxGraphicsState m_graphicsStates; GfxBufferEx_Constant m_iblLutConstantBuffers; GfxBufferEx_Constant m_constantBuffers; IblLutShaderConstant* m_iblLutConstant; TextureShaderConstant* m_textureConstant; GfxComputeShader m_iblLutCS; GfxVertexShader m_textureVS; GfxPixelShader m_texturePS; GfxBufferEx_Vertex m_quadVertexBuffer; GfxTestureEx_Uav m_iblLutTexture; GfxDynamicSampler m_sampler; }; } // namespace APP003 } // namespace SI
0.992188
1
src/engine/SwarmSynchro.h
SwarmEngine/SwarmEngine-Synchro
0
7999251
/* * Copyright 2017 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once // *************** // STD Libraries // *************** #include <map> // *********** // API Begin // *********** namespace swarm { namespace synchro { class Lock; class SharedLock; class UpgradeLock; //! Interface for a mutex lockable object /*! * Interface providing mutex lock and unlock methods. Provided methods are * protected and meant to be used by subclasses rather than external sources. * * Contains its own internal boost::mutex. */ class Lockable { public: Lockable(); virtual ~Lockable(); struct InternMutex; protected: //! Locks the internal mutex /*! * Locks this object's internal mutex. Essentially a wrapped call to * a boost::mutex's lock() method. Follows all rules for Boost's * mutexes. */ void lockMutex(); //! Unlocks the internal mutex /*! * Unlocks this object's internal mutex. Essentially a wrapped call to * a boost::mutex's unlock() method. Follows all rules for Boost's * mutexes. */ void unlockMutex(); private: friend class Lock; InternMutex* mMutex; }; //! Interface for a shared mutex lockable object /*! * Interface providing shared mutex lock and unlock methods (many reads, single * write). Provided methods are protected and meant to be used by subclasses * rather than external sources. * * Contains its own internal boost::shared_mutex. */ class SharedLockable { public: SharedLockable(); virtual ~SharedLockable(); struct InternSharedMutex; protected: //! Exclusively locks the internal mutex /*! * Exclusively locks this object's internal mutex. Essentially a * wrapped call to a boost::shared_mutex's lock() method. Follows * all rules for Boost's mutexes. * * Use this method for writing. */ void lockMutex(); //! Exclusively unlocks the internal mutex /*! * Exclusively unlocks this object's internal mutex. Essentially a * wrapped call to a boost::shared_mutex's unlock() method. Follows * all rules for Boost's mutexes. * * Use this method for writing. */ void unlockMutex(); //! Shared locks the internal mutex /*! * Shared locks this object's internal mutex. Essentially a * wrapped call to a boost::shared_mutex's lock_shared() method. * Follows all rules for Boost's mutexes. * * Use this method for reading. Many threads can obtain a shared * lock at the same time. */ void lockMutexShared(); //! Shared unlocks the internal mutex /*! * Shared unlocks this object's internal mutex. Essentially a * wrapped call to a boost::shared_mutex's unlock_shared() method. * Follows all rules for Boost's mutexes. * * Use this method for reading. Many threads can obtain a shared * lock at the same time. */ void unlockMutexShared(); private: friend class Lock; friend class SharedLock; friend class UpgradeLock; InternSharedMutex* mMutex; }; //! RAII Exclusive Lock /*! * An RAII lock to obtain exclusive access to a mutex. Can be created * from either a Lockable or SharedLockable object. * * Locks when constructed, and unlocks when destructed. Only a single * Lock can exist for a mutex at once. */ class Lock { public: explicit Lock(const Lockable& pLockable); explicit Lock(const SharedLockable& pLockable); ~Lock(); struct InternLock; private: InternLock* mLock; }; //! RAII Shared Lock /*! * An RAII lock to obtain shared access to a mutex. Can be created * from a SharedLockable object. Should be used for read access * only. * * Locks when constructed, and unlocks when destructed. Many * SharedLocks can exist for a single mutex at the same time. */ class SharedLock { public: explicit SharedLock(const SharedLockable& pLockable); ~SharedLock(); struct InternSharedLock; private: InternSharedLock* mLock; }; //! RAII Upgrade Lock /*! * An RAII lock to obtain shared access to a mutex which can be * upgraded to exclusive access a later time. Can be created * from a SharedLockable object. Should be used for read access * only while not upgraded. * * Locks when constructed, and unlocks when destructed. Only a single * UpgradeLock can exist for a mutex at a time. * * Once an UpgradeLock has been obtained, it can be upgraded * to exclusive access with upgrade(). */ class UpgradeLock { public: explicit UpgradeLock(const SharedLockable& pLockable); ~UpgradeLock(); struct InternUpgradeLock; //! Upgrades to an exclusive lock /*! * Upgrades this shared lock to an exclusive lock to be used * for write access. If this method is called on a shared lock * that has already been upgrades, it will throw an exception. */ void upgrade(); private: InternUpgradeLock* mLock; bool upgraded = false; }; } }
1.664063
2
UIViewExtension/HYBUIViewExtension/UIWindow+HYBKit.h
632840804/HYBUIViewExtension
1
7999259
// // UIWindow+HYBKit.h // HYBKitDemo // // Created by 黄仪标 on 15/2/12. // Copyright (c) 2015年 xiaoyaor. All rights reserved. // #import <UIKit/UIKit.h> @interface UIWindow (HYBKit) /** * Take a screenshot of current window * * @return Return the screenshot as an UIImage */ - (UIImage *)takeScreenshot; @end
0.617188
1
drivers/gpu/drm/i915/pxp/intel_pxp_irq.h
Sunrisepeak/Linux2.6-Reading
44
7999267
/* SPDX-License-Identifier: MIT */ /* * Copyright(c) 2020, Intel Corporation. All rights reserved. */ #ifndef __INTEL_PXP_IRQ_H__ #define __INTEL_PXP_IRQ_H__ #include <linux/types.h> struct intel_pxp; #define GEN12_DISPLAY_PXP_STATE_TERMINATED_INTERRUPT BIT(1) #define GEN12_DISPLAY_APP_TERMINATED_PER_FW_REQ_INTERRUPT BIT(2) #define GEN12_DISPLAY_STATE_RESET_COMPLETE_INTERRUPT BIT(3) #define GEN12_PXP_INTERRUPTS \ (GEN12_DISPLAY_PXP_STATE_TERMINATED_INTERRUPT | \ GEN12_DISPLAY_APP_TERMINATED_PER_FW_REQ_INTERRUPT | \ GEN12_DISPLAY_STATE_RESET_COMPLETE_INTERRUPT) #ifdef CONFIG_DRM_I915_PXP void intel_pxp_irq_enable(struct intel_pxp *pxp); void intel_pxp_irq_disable(struct intel_pxp *pxp); void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir); #else static inline void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir) { } #endif #endif /* __INTEL_PXP_IRQ_H__ */
0.867188
1
include/mlk/filesystem/fs_handle.h
Malekblubb/mlk
0
7999275
// // Copyright (c) 2013-2017 <NAME> // See LICENSE for more information. // #ifndef MLK_FILESYSTEM_FS_HANDLE_H #define MLK_FILESYSTEM_FS_HANDLE_H #include "dir_item.h" #include "fs_base.h" #include "dir.h" #include "file.h" #include <mlk/log/log_impl.h> #include <mlk/tools/stl_string_utl.h> #include <cstdint> #include <vector> namespace mlk { namespace fs { enum class fs_type : char { dir = 0, file }; using dir_contents = std::vector<dir_item>; template <fs_type type> class fs_handle; template <> class fs_handle<fs_type::dir> final : public internal::fs_base { public: fs_handle(const std::string& path) : fs_base{path} { this->init(); } bool exists() const noexcept override { return dir::exists(m_path); } bool create() const noexcept override { return dir::create(m_path); } bool remove() const override { return dir::remove(m_path); } const std::string& get_path() const noexcept { return m_path; } template <bool recursive> dir_contents get_content() { if(!this->exists()) return {}; dir_contents result; this->get_content_impl<recursive>(m_path, result); return result; } private: void init() { this->validate_path(m_path); } void validate_path(std::string& path) { if(path.size() < 1) return; if(*(path.end() - 1) != '/') path += '/'; } template <bool recursive> void get_content_impl(const std::string& path, dir_contents& result) { auto d(opendir(path.c_str())); dirent* dir_entry; while((dir_entry = readdir(d))) { auto name(std::string{dir_entry->d_name}); auto full(path + name); if(name == ".." || name == ".") continue; auto is_dir(dir::exists(full)); if(is_dir) this->validate_path(full); result.push_back({name, full, is_dir ? item_type::dir : item_type::file}); if(is_dir && recursive) this->get_content_impl<recursive>(full, result); } closedir(d); } }; template <> class fs_handle<fs_type::file> final : public internal::fs_base { std::fstream m_stream; bool m_need_open{true}; public: fs_handle() : fs_base{""} {} fs_handle(const std::string& path) : fs_base{path} {} ~fs_handle() { if(m_stream.is_open()) m_stream.close(); } void close() noexcept { m_stream.close(); m_need_open = true; } bool exists() const noexcept override { return file::exists(m_path); } bool create() const noexcept override { return file::create(m_path); } bool remove() const override { return file::remove(m_path); } bool open_io(std::ios::openmode modes) { m_stream.close(); m_stream.open(m_path, modes); m_need_open = false; return m_stream.is_open(); } bool reopen(std::ios::openmode modes) { return this->open_io(modes); } bool reopen(const std::string& path, std::ios::openmode modes) { m_path = path; return this->reopen(modes); } void set_pos_begin() noexcept { m_stream.seekg(0); } void write(const mlk::data_packet& data) { this->check_open(); if(!this->is_valid()) return; m_stream.write(reinterpret_cast<const char*>(data.data()), long(data.size())); } template <typename T> int64_t write(const T& val) { std::string str{stl_string::to_string(val)}; return this->write_impl(str); } template <typename T> int64_t write_line(const T& val) { std::string str{stl_string::to_string(val) + "\n"}; return this->write_impl(str); } std::size_t read_all(std::string& dest) { this->check_open(); if(!this->is_valid()) return 0; int64_t was_pos{m_stream.tellg()}; std::string s; std::size_t count{0}; m_stream.seekg(0); while(std::getline(m_stream, s)) { dest += s + "\n"; ++count; } m_stream.seekg(was_pos); return count; } data_packet read_all() { this->check_open(); if(!this->is_valid()) return {}; int64_t was_pos{m_stream.tellg()}; auto size(this->file_size()); this->set_pos_begin(); data_packet result(size); m_stream.read(reinterpret_cast<char*>(result.data()), long(size)); m_stream.seekg(was_pos); return result; } auto read_line(std::string& line) noexcept -> decltype(std::getline(m_stream, line)) { this->check_open(); return std::getline(m_stream, line); } std::size_t file_size() { auto pos(m_stream.tellg()); m_stream.seekg(0, std::ios::end); auto size(m_stream.tellg()); m_stream.seekg(pos); return std::size_t(size); } private: bool is_valid() const noexcept { return m_stream.is_open(); } int64_t write_impl(const std::string& str) { if(m_need_open) { lout("mlk::fs::fs_handle<fs_type::file>") << "can not write into closed stream. opening in mode " "'std::ios::out | std::ios::app'"; this->open_io(std::ios::out | std::ios::app); } int64_t start{m_stream.tellp()}; m_stream.write(str.c_str(), long(str.length())); int64_t end{m_stream.tellp()}; return end - start; } void check_open() noexcept { if(m_need_open) { lout("mlk::fs::fs_handle<fs_type::file>") << "can not read from closed stream. opening in mode " "'std::ios::in'"; this->open_io(std::ios::in); } } }; using dir_handle = fs_handle<fs_type::dir>; using file_handle = fs_handle<fs_type::file>; } } #endif// MLK_FILESYSTEM_FS_HANDLE_H
2.03125
2
IoT LoRaWAN Node/GreenhouseNode/GreenhouseNode/handlers/LightHandler.h
OZoneSQT/Sep4-Greenhouse
0
7999283
/* * LightHandler.h * * Created: 11/12/2021 19.17.33 * Author : <NAME>, 273966 */ #pragma once #include <stdint.h> #include "../controllers/light.h" typedef struct lightHandler { union // save allocated memory { uint32_t lux; uint16_t visibleRaw; uint16_t infraredRaw; uint16_t fullSpectrum; lightSensor_t sensorResult; }; }lightHandler; typedef struct lightHandler* lightHandler_t; /************************************************************************/ /* Initialize lightHandler Task, using a TSL2591 Light Sensor */ /* Set task_priority, event group, and event bit */ /************************************************************************/ lightHandler_t lightHandler_create(UBaseType_t light_task_priority, EventGroupHandle_t eventBits, EventBits_t bits); /************************************************************************/ /* Returns light level in lux as uint32_t */ /************************************************************************/ uint32_t lightHandler_getLux(lightHandler_t self); /************************************************************************/ /* Returns visible light level as uint16_t */ /************************************************************************/ uint16_t lightHandler_getVisibleRaw(lightHandler_t self); /************************************************************************/ /* Returns infrared light level as uint16_t */ /************************************************************************/ uint16_t lightHandler_getInfraredRaw(lightHandler_t self); /************************************************************************/ /* Returns full spectrum light level as uint16_t */ /************************************************************************/ uint16_t lightHandler_getFullSpectrum(lightHandler_t self); /************************************************************************/ /* Destroys lightHandler Task */ /************************************************************************/ void lightHandler_destroy(lightHandler_t self); /************************************************************************/ /* Measures light */ /************************************************************************/ void light_messure( lightHandler_t self );
0.984375
1
cheats/visuals/player_esp.h
Team-G0df4th3r/Snazzy.wtf-CSGO
1
7999291
#pragma once #include "..\..\includes.hpp" #include "..\..\sdk\structs.hpp" struct Box; class playeresp : public singleton <playeresp> { public: int type = ENEMY; float esp_alpha_fade[65]; int health[65]; HPInfo hp_info[65]; void paint_traverse(); void draw_health(player_t* m_entity, const Box& box, const HPInfo& hpbox); void draw_skeleton(player_t* e, Color color, matrix3x4_t matrix[MAXSTUDIOBONES]); bool draw_ammobar(player_t* m_entity, const Box& box); void draw_name(player_t* m_entity, const Box& box); void draw_weapon(player_t* m_entity, const Box& box, bool space); void draw_flags(player_t* e, const Box& box); void draw_lines(player_t* e); void draw_multi_points(player_t* e); };
0.871094
1
CProjects/Corewar/lib/my/my_putstr.c
667MARTIN/Epitech
40
7999299
/* ** my_putstr.c for my_putstr in /home/rodrig_1/lib/my ** ** Made by <NAME> ** Login <<EMAIL>> ** ** Started on Tue Nov 18 18:38:14 2014 <NAME> ** Last update Sun Mar 8 23:42:14 2015 <NAME> */ #include "my.h" int my_putstr(char *str) { int i; i = 0; while (str[i] != '\0') { my_putchar(str[i]); i = i + 1; } return (i); }
0.890625
1
DemoCollections/DemoCollections/HLGestureView.h
heron-newland/allDemos
1
7999307
// // HLGestureView.h // 手势密码 // // Created by helong on 5/21/16. // Copyright © 2016 helong. All rights reserved. // #import <UIKit/UIKit.h> @interface HLGestureView : UIView @end
0.269531
0
AutoIngest/Source/DTITCReportDownloadOperation.h
Cocoanetics/AutoIngest
5
7999315
// // DTITCReportDownloadOperation.h // AutoIngest // // Created by <NAME> on 4/20/13. // Copyright (c) 2013 Cocoanetics. All rights reserved. // #import "DTITC.h" @class GenericAccount; @class DTITCReportDownloadOperation; @protocol DTITCReportDownloadOperationDelegate <NSObject> @optional - (void)operation:(DTITCReportDownloadOperation *)operation didFailWithError:(NSError *)error; // informs the delegate of a completed download. The other parameters are available via properties - (void)operation:(DTITCReportDownloadOperation *)operation didDownloadReportWithDate:(NSDate *)date; @end @interface DTITCReportDownloadOperation : NSOperation - (id)initForReportsOfType:(ITCReportType)reportType subType:(ITCReportSubType)reportSubType dateType:(ITCReportDateType)reportDateType fromAccount:(GenericAccount *)account vendorID:(NSString *)vendorID intoFolder:(NSString *)folder; @property (nonatomic, assign) BOOL uncompressFiles; @property (nonatomic, weak) id <DTITCReportDownloadOperationDelegate> delegate; @property (nonatomic, readonly) ITCReportType reportType; @property (nonatomic, readonly) ITCReportSubType reportSubType; @property (nonatomic, readonly) ITCReportDateType reportDateType; @end
0.648438
1
Applications/TVHomeSharing/UIViewController-TVHomeSharing.h
lechium/tvOS10Headers
4
7999323
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by <NAME>. // #import "UIViewController.h" @interface UIViewController (TVHomeSharing) - (void)_removeContentViewController; // IMP=0x0000000100012df8 - (void)_setContentViewController:(id)arg1; // IMP=0x0000000100012de8 - (void)tvhs_showContentViewController:(id)arg1; // IMP=0x0000000100012ca0 @property(readonly, nonatomic) UIViewController *tvhs_contentViewController; @end
0.601563
1
c programming quiz/Quiz.c
AshishSingh13s/HactoberFest21
1
7999331
#include<conio.h> #include<ctype.h> #include<stdlib.h> #include<string.h> #include<time.h> int marks[6]={0,0,0,0,0,0},seconds_passed=0,question_number=1,unit_selection_checker[6]={0,0,0,0,0,0}; time_t time_start,time_end; struct Units { char questions[41][450]; char answers[41][100]; char input[41][100]; char temp_input[41][100]; int random_number[31]; } units[6]; //-----------------------The Quiz -----------------------------// void quizattempt(int unit_selected,int question_divider,int time_limit) { if(seconds_passed<time_limit) printf("\nYOU HAVE %d SECONDS LEFT\n",time_limit-seconds_passed); else printf("\nOUT OF TIME\n"); units[unit_selected].random_number[question_number]=rand()%10+question_divider; printf("\nQUESTION NUMBER--%d\n%s\n",question_number,units[unit_selected].questions[units[unit_selected].random_number[question_number]]); fflush(stdin); do{ gets(units[unit_selected].input[units[unit_selected].random_number[question_number]]); } while(units[unit_selected].input[units[unit_selected].random_number[question_number]][0] == '\0'); strcpy(units[unit_selected].temp_input[units[unit_selected].random_number[question_number]],units[unit_selected].input[units[unit_selected].random_number[question_number]]); strlwr(units[unit_selected].temp_input[units[unit_selected].random_number[question_number]]); time_end=time(NULL); seconds_passed=time_end-time_start; if(strcmp(units[unit_selected].temp_input[units[unit_selected].random_number[question_number]],units[unit_selected].answers[units[unit_selected].random_number[question_number]])==0 && seconds_passed<time_limit) { printf("\nYou are correct\n"); marks[unit_selected]++; } else if ( seconds_passed>=time_limit) { printf("\nYou are too slow\n"); strcpy(units[unit_selected].input[units[unit_selected].random_number[question_number]],"You were too slow"); } else { printf("\nYour answer is wrong\n"); printf("\nThe correct answer is %s\n",units[unit_selected].answers[units[unit_selected].random_number[question_number]]); } question_number++; } //---------------------Attempt checker for score-----------------// void attemptcheck(int unit_selected) { printf("\nYou have attemped quiz from Unit %d\n",unit_selected); printf("\nYour score from this Unit is %d\n",marks[unit_selected]); } //-----------------Attempt checker for review------------------------// void reviewcheck(int unit_selected) { question_number=1; printf("\nReview from unit %d\n",unit_selected); for(question_number=1;question_number<11;question_number++) { printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nQuestion %d-->%s\n",question_number,units[unit_selected].questions[units[unit_selected].random_number[question_number]]); printf("\nCorrect answer--> %s\n",units[unit_selected].answers[units[unit_selected].random_number[question_number]]); printf("\nYour answer--> %s\n",units[unit_selected].input[units[unit_selected].random_number[question_number]]); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); system("cls"); } } //------------------------MARKS CHANGER-------------------// void markscorrect(int unit_selected) { printf("\nYour score in the selected lesson is %d\n",marks[unit_selected]); printf("\n You want to change the score to \n"); scanf("%d",&marks[unit_selected]); while(marks[unit_selected]>10&&marks[unit_selected]<0) { printf("Enter a score between 0 to 10\n"); scanf("%d",&marks[unit_selected]); } printf("\n CHANGE SUCCESFUL"); } int main() { //----------------------- QUESTIONS FROM UNIT 1--------------------// //-----------------------TRUE OF FALSE----------------------------// strcpy(units[1].questions[1],"C programs are converted into machine language with the help of a program called Editor.\n"); strcpy(units[1].answers[1],"false"); strcpy(units[1].questions[2],"C is a low level language."); strcpy(units[1].answers[2],"false"); strcpy(units[1].questions[3],"Spaces and commas are allowed in a variable name.\n"); strcpy(units[1].answers[3],"false"); strcpy(units[1].questions[4],"The maximum value that an integer constant can have varies from one compiler to another.\n"); strcpy(units[1].answers[4],"true"); strcpy(units[1].questions[5],"A real constant in C can be expressed in both Fractional and Exponential forms.\n"); strcpy(units[1].answers[5],"true"); strcpy(units[1].questions[6],"Algorithm is the graphical representation of logic.\n"); strcpy(units[1].answers[6],"false"); strcpy(units[1].questions[7],"#define is known as preprocessor compiler directive.\n"); strcpy(units[1].answers[7],"true"); strcpy(units[1].questions[8],"The keywords can be used as variable names.\n"); strcpy(units[1].answers[8],"false"); strcpy(units[1].questions[9],"The ++ operator increments the operand by 1, whereas, the -- operator decrements it by 1.\n"); strcpy(units[1].answers[9],"true"); strcpy(units[1].questions[10],"The return type of malloc function is void.\n"); strcpy(units[1].answers[10],"false"); // -----------------------CHOOSE THE CORRECT OPTION QUESTIONS---------------------// strcpy(units[1].questions[11],"Low level language is .?\n A) Human readable like language.\n B) language with big program size.\n C) language with small program size.\n D) Difficult to understand and readability is questionable.\n"); strcpy(units[1].answers[11],"d"); strcpy(units[1].questions[12],"Who invented C Language.?\nA) <NAME>\n B) Grahambel\n C) <NAME>\n D) <NAME>\n "); strcpy(units[1].answers[12],"c"); strcpy(units[1].questions[13],"High level language is a .?\n A) Human readable like language.\n B) language with small program size.\n C) language with big program size.\n D) language which is difficult to understand and not human readable.\n"); strcpy(units[1].answers[13],"a"); strcpy(units[1].questions[14],"C language was invented to develop which Operating System.?\n A) Android\n B) Linux\n C) Ubuntu\n D) Unix\n"); strcpy(units[1].answers[14],"d"); strcpy(units[1].questions[15],"BCPL Language is also called..?\n A) C Language\n B) B Language\n C) D Language\n D) None\n"); strcpy(units[1].answers[15],"d"); strcpy(units[1].questions[16],"Identify wrong C Keywords below.\n A) union, const, var, float\n B) short, unsigned, continue, for\n C) signed, void, default, goto\n D) sizeof, volatile, do, if\n"); strcpy(units[1].answers[16],"a"); strcpy(units[1].questions[17],"Find a correct C Keyword below.\n A) breaker\n B) go to\n C) shorter\n D) default\n"); strcpy(units[1].answers[17],"d"); strcpy(units[1].questions[18],"Every C Variable must have.?\n A) Type\n B) Storage Class\n C) Both Type and Storage Class\n D) Either Type or Storage Class\n"); strcpy(units[1].answers[18],"c"); strcpy(units[1].questions[19],"Operator % in C Language is called.?\n A) Percentage Operator\n B) Quotient Operator\n C) Modulus\n D) Division\n"); strcpy(units[1].answers[19],"c"); strcpy(units[1].questions[20],"What is the other name for C Language ?: Question Mark Colon Operator.?\n A) Comparison Operator\n B) If-Else Operator\n C) Binary Operator\n D) Ternary Operator\n"); strcpy(units[1].answers[20],"d"); //------FILL IN THE BLANKS QUESTION-------------------------// strcpy(units[1].questions[21],"C is _______ type of programming language.\n "); strcpy(units[1].answers[21],"procedural"); strcpy(units[1].questions[22],"C language was invented in _______ laboratories.\n"); strcpy(units[1].answers[22],"bell"); strcpy(units[1].questions[23],"Output of an arithmetic expression with integers and real numbers is ___ by default.?\n"); strcpy(units[1].answers[23],"real number"); strcpy(units[1].questions[24],"If both numerator and denominator of a division operation in C language are integers, then we get _______\n"); strcpy(units[1].answers[24],"unexpected integer value"); strcpy(units[1].questions[25],"Size of a Turbo C C++ compiler is _______\n"); strcpy(units[1].answers[25],"16 bit"); strcpy(units[1].questions[26],"Sizes of short, int and long in a Turbo C C++ compiler in bytes are _______\n"); strcpy(units[1].answers[26],"2,2,4"); strcpy(units[1].questions[27],"The number of characters used to distinguish Identifier or Names of Functions and Global variables is _______\n"); strcpy(units[1].answers[27],"31"); strcpy(units[1].questions[28],"Single Line Comment // is also called _______\n"); strcpy(units[1].answers[28],"c++ style comment"); strcpy(units[1].questions[29],"Number of Keywords present in C Language are _______. \n"); strcpy(units[1].answers[29],"32"); strcpy(units[1].questions[30],"Each statement in a C program should end with _______.\n"); strcpy(units[1].answers[30],"semi colon"); //-------------------------ERROR FINDING/OUTPUT-------------------// strcpy(units[1].questions[31],"Find Error/Output in follwing code:\n void main ()\n {\n int x = 128;\n printf (\"%d\", 1 + x++);\n }\n"); strcpy(units[1].answers[31],"129"); strcpy(units[1].questions[32],"Find Error/Output in follwing code:\n main() {\n int a = 10;\n if ((fork ( ) == 0))\n a++;\n printf (\"%d\", a );\n }\n"); strcpy(units[1].answers[32],"10"); strcpy(units[1].questions[33],"What is the output of the program.?\n #include<stdio.h>\n int main()\n {\n printf(\"Hello Boss.\")\n }\n"); strcpy(units[1].answers[33],"compiler error"); strcpy(units[1].questions[34],"What is the output of the program.?\n int main()\n {\n auto int a=10;\n {\n auto int a = 15;\n printf(\"%d \", a);\n }\n printf(\"%d \", a);\n return 1;\n }\n"); strcpy(units[1].answers[34],"15 10"); strcpy(units[1].questions[35],"What is the output of the program.?\n int main()\n {\n register a=10;\n {\n register a = 15;\n printf(\"%d \", a);\n }\n printf(\"%d \", a);\n return 20;\n }\n"); strcpy(units[1].answers[35],"15 10"); strcpy(units[1].questions[36],"What is the output the program.?\n int main()\n {\n register a=80;\n auto int b;\n b=a;\n printf(\"%d \", a);\n printf(\"%d \", b);\n return -1;\n }\n"); strcpy(units[1].answers[36],"compiles but no output"); strcpy(units[1].questions[37],"What is the output of the program.?\n void myshow();\n int main()\n {\n myshow();\n myshow();\n myshow();\n }\n void myshow()\n {\n static int k = 20;\n printf(\"%d \", k);\n k++;\n }\n"); strcpy(units[1].answers[37],"20 21 22"); strcpy(units[1].questions[38],"What is the output of the program.?\n #include<stdio.h>\n static int k;\n int main()\n {\n printf(\"%d\", k);\n return 90;\n }\n"); strcpy(units[1].answers[38],"0"); strcpy(units[1].questions[39],"What is the output/error of the program.?\n int main()\n {\n register k = 25;\n printf(\"%d\", &k);\n return 90;\n }\n"); strcpy(units[1].answers[39],"compiler error"); strcpy(units[1].questions[40],"What is the output of C Program.?\n int main()\n {\n int a=0;\n a = printf(\"4\");\n printf(\"%d\",a);\n return 0;\n }\n"); strcpy(units[1].answers[40],"41"); //------------------QUESTIONS FROM UNIT 2--------------------------------// //-----------------------TRUE OF FALSE----------------------------// strcpy(units[2].questions[1],"When if statements are nested, the last else gets associated with the nearest if without an else"); strcpy(units[2].answers[1],"false"); strcpy(units[2].questions[2],"A switch statement can always be replaced by a series of if..else statements"); strcpy(units[2].answers[2],"false"); strcpy(units[2].questions[3],"A switch expression can be of any type"); strcpy(units[2].answers[3],"false"); strcpy(units[2].questions[4],"The do…while statement first executes the loop body and then evaluate the loop control expression"); strcpy(units[2].answers[4],"true"); strcpy(units[2].questions[5],"In a pretest loop, if the body is executed n times, the test expression is executed n+1 times"); strcpy(units[2].answers[5],"true"); strcpy(units[2].questions[6],"The number of times a control variable is updated always equals the number of loop iterations"); strcpy(units[2].answers[6],"true"); strcpy(units[2].questions[7],"The type of all elements in an array must be the same"); strcpy(units[2].answers[7],"true"); strcpy(units[2].questions[8],"When an array is declared, C automatically initializes its elements to zero"); strcpy(units[2].answers[8],"true"); strcpy(units[2].questions[9],"An expression that evaluates to an integral value may be used as a subscript"); strcpy(units[2].answers[9],"true"); strcpy(units[2].questions[10],"Accessing an array outside its range is a compile time error"); strcpy(units[2].answers[10],"true"); // -----------------------CHOOSE THE CORRECT OPTION QUESTIONS---------------------// strcpy(units[2].questions[11],"Choose a right C Statement.\n A) Loops or Repetition block executes a group of statements repeatedly.\n B) Loop is usually executed as long as a condition is met.\n C) Loops usually take advantage of Loop Counter\n D) All the above\n"); strcpy(units[2].answers[11],"d"); strcpy(units[2].questions[12],"Which loop is faster in C Language, for, while or Do While.?\n A) for\n B) while\n C) do while\n D) All work at same speed\n"); strcpy(units[2].answers[12],"d"); strcpy(units[2].questions[13],"Choose a correct C Statement.\n A) a++ is (a=a+1) POST INCREMENT Operator\n B) a-- is (a=a-1) POST DECREMENT Opeartor\n --a is (a=a-1) PRE DECREMENT Opeator\n C) ++a is (a=a+1) PRE INCRMENT Operator\n D) All the above.\n"); strcpy(units[2].answers[13],"d"); strcpy(units[2].questions[14],"What is the way to suddenly come out of or Quit any Loop in C Language.?\n A) continue; statement\n B) break; statement\n C) leave; statement\n D) quit; statement\n"); strcpy(units[2].answers[14],"b"); strcpy(units[2].questions[15],"Choose facts about continue; statement is C Language.\n A) continue; is used to take the execution control to next iteration or sequence\n B) continue; statement causes the statements below it to skip for execution\n C) continue; is usually accompanied by IF statement.\n D) All the above.\n"); strcpy(units[2].answers[15],"d"); strcpy(units[2].questions[16],"Choose a correct statement about C break; statement.?\n A) break; statement can be used inside switch block\n B) break; statement can be used with loops like for, while and do while.\n C) break; statement causes only the same or inner loop where break; is present to quit suddenly.\n D) All the above.\n"); strcpy(units[2].answers[16],"d"); strcpy(units[2].questions[17],"Choose a correct statement about C language break; statement.\n A) A single break; statement can force execution control to come out of only one loop.\n B) A single break; statement can force execution control to come out of a maximum of two nested loops.\n C) A single break; statement can force execution control to come out of a maximum of three nested loops.\n D) None of the above.\n"); strcpy(units[2].answers[17],"a"); strcpy(units[2].questions[18],"Choose a correct C Statement regarding for loop.\n for(; ;);\n A) for loop works exactly first time\n B) for loop works infinite number of times\n C) Compiler error\n D) None of the above\n"); strcpy(units[2].answers[18],"b"); strcpy(units[2].questions[19],"What are C ASCII character ranges.?\n A) A to Z = 65 to 91\n B) a to z = 97 to 122\n C) 0 to 9 = 48 to 57\n D) All the above\n"); strcpy(units[2].answers[19],"d"); strcpy(units[2].questions[20],"Expand or Abbreviate ASCII with regard to C Language.\n A) Australian Standard Code for Information Interchange\n B) American Standard Code for Information Interchange\n C) American Symbolic Code for Information Interchange\n D) Australian Symbolic Code for Information Interchange\n"); strcpy(units[2].answers[20],"b"); //------FILL IN THE BLANKS QUESTION-------------------------// strcpy(units[2].questions[21]," ______ is the other name for C Language ?: Question Mark Colon Operator."); strcpy(units[2].answers[21],"ternary operator"); strcpy(units[2].questions[22],"______ executes a group of statements repeatedly."); strcpy(units[2].answers[22],"loops"); strcpy(units[2].questions[23],"______ usually take advantage of Loop Counter"); strcpy(units[2].answers[23],"loops"); strcpy(units[2].questions[24],"___ is (a=a+1) POST INCREMENT Operator"); strcpy(units[2].answers[24],"a++"); strcpy(units[2].questions[25],"_____ is (a=a-1) POST DECREMENT Operator"); strcpy(units[2].answers[25],"a--"); strcpy(units[2].questions[26],"____ is (a=a-1) PRE DECREMENT Operator"); strcpy(units[2].answers[26],"--a"); strcpy(units[2].questions[27],"_____ is (a=a+1) PRE INCREMENT Operator"); strcpy(units[2].answers[27],"++a"); strcpy(units[2].questions[28],"_______ is the sum of sizes of all elements of the array."); strcpy(units[2].answers[28],"array size"); strcpy(units[2].questions[29],"int, long, float, double are types of ______"); strcpy(units[2].answers[29],"arrays"); strcpy(units[2].questions[30],"An array Index starts with ______"); strcpy(units[2].answers[30],"0"); //-------------------------Error Finding/Output-------------------// strcpy(units[2].questions[31],"What is the output of the C Program.?\n int main()\n {\n int a=0;\n a = (5>2) ? : 8;\n printf(\"%d\",a);\n return 0;\n }\n"); strcpy(units[2].answers[31],"1"); strcpy(units[2].questions[32],"What is the output of C Program.?\n int main()\n {\n int a=0, b;\n a = (5>2) ? b=6: b=8;\n printf(\"%d %d\",a, b);\n return 0;\n }\n"); strcpy(units[2].answers[32],"compiler error"); strcpy(units[2].questions[33],"What is the output of the C Program.?\n int main()\n {\n if( 4 > 5 )\n {\n printf(\"Hurray..\");\n }\n printf(\"Yes\");\n return 0;\n }\n"); strcpy(units[2].answers[33],"yes"); strcpy(units[2].questions[34],"What is the output of the C Program.?\n int main()\n {\n if( 4 < 5 )\n printf(\"Hurray..\");\n printf(\"Yes\");\n else\n printf(\"England\")\n return 0;\n }\n"); strcpy(units[2].answers[34],"compiler error"); strcpy(units[2].questions[35],"What is the output of the C Program.?\n int main()\n {\n if( 10 < 9 )\n printf(\"Hurray..\");\n else if(4 > 2)\n printf(\"England\");\n return 0;\n }\n"); strcpy(units[2].answers[35],"england"); strcpy(units[2].questions[36],"What is the output of C Program.?\n int main()\n {\nif( 10 > 9 )\n printf(\"Singapore \");\n else if(4%2 == 0)\n printf(\"England\");\n printf(\"Poland\");\n return 0;\n }\n"); strcpy(units[2].answers[36],"Singapore Poland"); strcpy(units[2].questions[37],"What is the output of the C Program.?\n int main()\n {\n if(-5)\n {\n printf(\"Germany \");\n }\n if(5)\n {\n printf(\"Texas \");\n }\n printf(\"ZING\");\n return 0;\n }\n"); strcpy(units[2].answers[37],"Germany Texas ZING"); strcpy(units[2].questions[38],"What is the output of the C Program.?\n int main()\n {\n if(10.0)\n {\n printf(\"Texas \");\n }\n printf(\"ZING\");\n return 0;\n }\n"); strcpy(units[2].answers[38],"Texas ZING"); strcpy(units[2].questions[39],"What is the output of C Program.?\n int main()\n {\n if(\"abc\")\n {\n printf(\"India \");\n }\n if('c')\n {\n printf(\"Honey \");\n }\n printf(\"ZING\");\n return 0;\n }\n"); strcpy(units[2].answers[39],"India Honey ZING"); strcpy(units[2].questions[40],"What is the output of C Program.?\n int main()\n {\n while(true) \n {\n printf(\"RABBIT\");\n break;\n }\n return 0;\n }\n"); strcpy(units[2].answers[40],"compiler error"); //------------------QUESTIONS FROM UNIT 3--------------------------------// //-----------------------TRUE OF FALSE----------------------------// strcpy(units[3].questions[1],"C functions can return only one value under their function name"); strcpy(units[3].answers[1],"true"); strcpy(units[3].questions[2],"A function in C should have atleast one argument"); strcpy(units[3].answers[2],"true"); strcpy(units[3].questions[3],"A function can be defined within the main function"); strcpy(units[3].answers[3],"false"); strcpy(units[3].questions[4],"A function can be defined and placed before the main function"); strcpy(units[3].answers[4],"false"); strcpy(units[3].questions[5],"An user-defined function must be called atleast once; otherwise a warning message will be issued"); strcpy(units[3].answers[5],"true"); strcpy(units[3].questions[6],"Any name can be used as a function name"); strcpy(units[3].answers[6],"false"); strcpy(units[3].questions[7],"Only a void type function can have void as it argument"); strcpy(units[3].answers[7],"false"); strcpy(units[3].questions[8],"When variable values are passed to functions, a copy of them are created in the memory"); strcpy(units[3].answers[8],"true"); strcpy(units[3].questions[9],"Program execution always begins in the main function irrespective of its location in the program"); strcpy(units[3].answers[9],"true"); strcpy(units[3].questions[10],"A function without a return statement is illegal"); strcpy(units[3].answers[10],"false"); // -----------------------CHOOSE THE CORRECT OPTION QUESTIONS---------------------// strcpy(units[3].questions[11],"A character constant is enclosed by.?\n A) Left Single Quotes\n B) Right Single Quotes\n C) Double Quotes\n D) None of the above\n"); strcpy(units[3].answers[11],"b"); strcpy(units[3].questions[12],"Choose a correct statement about C String.\n A) A string is a group of characters enclosed by double quotes.\n B) If a string is defined with double quotes, NULL is automatically added at the end.\n C) Size of a string is without counting NULL character at the end\n D) All the above\n"); strcpy(units[3].answers[12],"d"); strcpy(units[3].questions[13],"A C string elements are always stored in.?\n A) Random memory locations\n B) Alternate memory locations\n C) Sequential memory locations\n D) None of the above\n"); strcpy(units[3].answers[13],"c"); strcpy(units[3].questions[14],"Choose a correct C statement about String functions.?\n A) int n=strlen(\"abc\") returns 3.\n B) strupr(\"abc\") returns ABC\n C) strlwr(\"Abc\") returns abc\n D) All the above\n"); strcpy(units[3].answers[14],"d"); strcpy(units[3].questions[15],"Choose a correct C statement about String functions.?\n A) strrev(\"abcD\") returns Dcba.\n B) strcmp(\"abc\", \"bcd\") returns a negative number\n C) strcmp(\"234\",\"123\") returns a positive number\n D) All the above\n"); strcpy(units[3].answers[15],"d"); strcpy(units[3].questions[16],"Choose a correct C statement about String functions.?\n A) toupper('a') returns A\n B) tolower('D') returns d.\n C) strcmp(\"123\",\"12345\") returns a negative number\n D) All the above\n"); strcpy(units[3].answers[16],"d"); strcpy(units[3].questions[17],"What is actually passed to PRINTF or SCANF functions.?\n A) Value of String\n B) Address of String\n C) End address of String\n D) Integer equivalent value of String\n"); strcpy(units[3].answers[17],"b"); strcpy(units[3].questions[18],"Choose a correct C Statement about Strings.\n A) PRINTF is capable of printing a multi word string.\n B) PUTS is capable of printing a multi word string.\n C) GETS is capable of accepting a multi word string from console or command prompt\n D) All the above\n"); strcpy(units[3].answers[18],"d"); strcpy(units[3].questions[19],"What is the maximum length of a C String.?\n A) 32 characters\n B) 64 characters\n C) 256 characters\n D) None of the above\n"); strcpy(units[3].answers[19],"d"); strcpy(units[3].questions[20],"What is the minimum number of functions to be present in a C Program.?\n A) 1\n B) 2\n C) 3\n D) 4\n"); strcpy(units[3].answers[20],"a"); //------FILL IN THE BLANKS QUESTION-------------------------// strcpy(units[3].questions[21],"A function which calls itself is called a ___ function."); strcpy(units[3].answers[21],"recursive"); strcpy(units[3].questions[22],"A _______ is a group of c statements which can be reused any number of times."); strcpy(units[3].answers[22],"function"); strcpy(units[3].questions[23],"Every Function has a ______ type."); strcpy(units[3].answers[23],"return"); strcpy(units[3].questions[24],"Default return type of any function is an ______."); strcpy(units[3].answers[24],"integer"); strcpy(units[3].questions[25],"a C Function can return _____ values at a time.?"); strcpy(units[3].answers[25],"one"); strcpy(units[3].questions[26],"______ is an array of Characters with null character as the last element of array."); strcpy(units[3].answers[26],"string"); strcpy(units[3].questions[27],"________ is the Format specifier used to print a String or Character array in C Printf or Scanf function."); strcpy(units[3].answers[27]," %s "); strcpy(units[3].questions[28],"The maximum length of a C String is _____-."); strcpy(units[3].answers[28],"indefinite"); strcpy(units[3].questions[29],"_____ is used to accept a Multi Word Input in C Language."); strcpy(units[3].answers[29],"gets"); strcpy(units[3].questions[30],"_____ is the ASCII value of NULL or \0."); strcpy(units[3].answers[30],"0"); //-------------------------ERROR FINDING/OUTPUT-------------------// strcpy(units[3].questions[31],"What is the output of C Program with Functions.?\n int main()\n {\n void show()\n {\n printf(\"hide\");\n }\n show();\n return 0;\n }\n"); strcpy(units[3].answers[31],"hide"); strcpy(units[3].questions[32],"What is the output of C Program with functions.?\n void show();\n int main()\n {\n show();\n printf(\"argentina \");\n return 0;\n }\n void show()\n {\n printf(\"africa \");\n }\n"); strcpy(units[3].answers[32],"africa argentina"); strcpy(units[3].questions[33],"What is the output of C Program with functions.?\n int main()\n {\n show();\n printf(\"BANK \");\n return 0;\n }\n void show()\n {\n printf(\"CURRENCY \");\n }\n"); strcpy(units[3].answers[33],"compiler error"); strcpy(units[3].questions[34],"What is the output of a C program with functions.?\n void show();\n void main()\n {\n show();\n printf(\"rainbow \");\n return;\n }\n void show()\n {\n printf(\"colours \");\n }\n"); strcpy(units[3].answers[34],"colours rainbow"); strcpy(units[3].questions[35],"What is the output of C Program.?\n void show();\n void main()\n {\n printf(\"pista \");\n show();\n }\n void show()\n {\n printf(\"cashew \");\n return 10;\n }\n"); strcpy(units[3].answers[35],"pista cashew with compiler warning"); strcpy(units[3].questions[36],"What is the output of C Program with functions.?\n int show();\n void main()\n {\n int a;\n printf(\"pista count=\");\n a=show();\n printf(\"%d\", a);\n }\n int show()\n {\n return 10;\n }\n"); strcpy(units[3].answers[36],"pista count=10"); strcpy(units[3].questions[37],"What is the output of C Program with Strings.?\n int main()\n {\n char str[]={'g','l','o','b','e','\\0'};\n printf(\"%s\",str);\n return 0;\n }\n"); strcpy(units[3].answers[37],"globe"); strcpy(units[3].questions[38],"What is the output of C Program with arrays.?\n int main()\n {\n char str[]={\"C\",\"A\",\"T\",\"\\0\"};\n printf(\"%s\",str);\n return 0;\n }\n"); strcpy(units[3].answers[38],"compiler error"); strcpy(units[3].questions[39],"What is the output of C program with strings.?\n int main()\n {\n char str1[]=\"JOHN\";\n char str2[20];\n str2= str1;\n printf(\"%s\",str2);\n return 0;\n }\n"); strcpy(units[3].answers[39],"compiler error"); strcpy(units[3].questions[40],"What is the output of C Program with arrays.?\n int main()\n {\n char str[25];\n scanf(\"%s\", str);\n printf(\"%s\",str);\n return 0;\n }\n //input: south africa\n"); strcpy(units[3].answers[40],"south"); //------------------QUESTIONS FROM UNIT 4--------------------------------// //-----------------------TRUE OF FALSE----------------------------// strcpy(units[4].questions[1],"Are the expression *ptr++ and ++*ptr are same?"); strcpy(units[4].answers[1],"false"); strcpy(units[4].questions[2],"Are the three declarations char **apple, char *apple[], and char apple[][] same?"); strcpy(units[4].answers[2],"false"); strcpy(units[4].questions[3],"Pointer constants are the addresses of memory locations"); strcpy(units[4].answers[3],"true"); strcpy(units[4].questions[4],"The underlying type of a pointer variable is void"); strcpy(units[4].answers[4],"false"); strcpy(units[4].questions[5],"Pointers to pointers is a term used to describe pointers whose contents are the address of another pointer"); strcpy(units[4].answers[5],"true"); strcpy(units[4].questions[6],"It is possible to cast a pointer to float as a pointer to integer"); strcpy(units[4].answers[6],"false"); strcpy(units[4].questions[7],"An integer can be added to a pointer"); strcpy(units[4].answers[7],"true"); strcpy(units[4].questions[8],"When an array is passed as an argument to a function, a pointer is passed"); strcpy(units[4].answers[8],"true"); strcpy(units[4].questions[9],"Pointers cannot be used as formal parameters in headers to function definitions"); strcpy(units[4].answers[9],"false"); strcpy(units[4].questions[10],"Value of a local variable in a function can be changed by another function"); strcpy(units[4].answers[10],"true"); // -----------------------CHOOSE THE CORRECT OPTION QUESTIONS---------------------// strcpy(units[4].questions[11],"What is the limit for number of functions in a C Program.?\n A) 16\n B) 31\n C) 32\n D) None of the above\n"); strcpy(units[4].answers[11],"d"); strcpy(units[4].questions[12],"Every C Program should contain which function.?\n A) printf()\n B) show()\n C) scanf()\n D) main()\n"); strcpy(units[4].answers[12],"d"); strcpy(units[4].questions[13],"What is the maximum number of statements that can present in a C function.?\n A) 64\n B) 128\n C) 256\n D) None of the above\n"); strcpy(units[4].answers[13],"d"); strcpy(units[4].questions[14],"What characters are allowed in a C function name identifier.?\n A) Alphabets, Numbers, %, $, _\n B) Alphabets, Numbers, Underscore ( _ )\n C) Alphabets, Numbers, dollar $\n D) Alphabets, Numbers, %\n"); strcpy(units[4].answers[14],"b"); strcpy(units[4].questions[15],"Choose a corrects statement about C language function arguments.\n A) Number of arguments should be same when sending and receiving\n B) Type of each argument should match exactly \n C) Order of each argument should be same\n D) All the above\n"); strcpy(units[4].answers[15],"d"); strcpy(units[4].questions[16],"Choose a non Library C function below.\n A) printf()\n B) scanf()\n C) fprintf()\n D) printf(2)\n"); strcpy(units[4].answers[16],"d"); strcpy(units[4].questions[17],"What is the default return value of a C function if not specified explicitly.?\n A) -1\n B) 0\n C) 1\n D) None of the above\n"); strcpy(units[4].answers[17],"c"); strcpy(units[4].questions[18],"What do you call this C Function calling itself.?\n int funny2()\n {\n funny2(num);\n }\n A) Indefinite Function\n B) Definite Function\n C) Cursive Function\n D) Recursive Function\n"); strcpy(units[4].answers[18],"d"); strcpy(units[4].questions[19],"What is the C keyword that must be used to achieve expected result using Recursion.?\n A) printf\n B) scanf\n C) void\n D) return\n"); strcpy(units[4].answers[19],"d"); strcpy(units[4].questions[20],"How many functions are required to create a recursive functionality.?\n A) One\n B) Two\n C) More than two\n D) None of the above\n "); strcpy(units[4].answers[20],"a"); //------FILL IN THE BLANKS QUESTION-------------------------// strcpy(units[4].questions[21],"A recursive function without If and Else conditions will always lead to ______"); strcpy(units[4].answers[21],"infinite loop"); strcpy(units[4].questions[22],"A ______ can call any other function any number of times"); strcpy(units[4].answers[22],"function"); strcpy(units[4].questions[23],"You can refer to or call any function using a ______ also."); strcpy(units[4].answers[23],"pointer"); strcpy(units[4].questions[24],"Arguments received by a function in C language are called ___ arguments."); strcpy(units[4].answers[24],"formal"); strcpy(units[4].questions[25],"Arguments passed to a function in C language are called ___ arguments."); strcpy(units[4].answers[25],"actual"); strcpy(units[4].questions[26],"Difference of pointers to two elements of an array gives the difference between their _____."); strcpy(units[4].answers[26],"indexes"); strcpy(units[4].questions[27],"Accessing out of bounds index element is valid and it returns a ______ value."); strcpy(units[4].answers[27],"garbage"); strcpy(units[4].questions[28],"Array of Arrays is also called ________"); strcpy(units[4].answers[28],"multi dimensional array"); strcpy(units[4].questions[29],"A multidimensional array of dimension N is a collection of __________"); strcpy(units[4].answers[29],"n 1-d arrays"); strcpy(units[4].questions[30],"First Dimension size is _______ when initializing the array at the same time."); strcpy(units[4].answers[30],"optional"); //-------------------------ERROR FINDING/OUTPUT-------------------// strcpy(units[4].questions[31],"What is the output of C Program with functions and pointers.?\n int main()\n {\n int b=25;\n //b memory location=1234;\n int *p = b;\n printf(\"%d %d\", b, p);\n return 0;\n }\n"); strcpy(units[4].answers[31],"25 25"); strcpy(units[4].questions[32],"What is the output of C Program with functions and pointers.?\n int main()\n {\n int b=25;\n //b memory location=1234;\n int *p;\n p=&b;\n printf(\"%d %d %d\", &b, p);\n return 0;\n }\n"); strcpy(units[4].answers[32],"1234 1234"); strcpy(units[4].questions[33],"What is the output of C Program with functions.?\n #include<stdio.h>\n int sum(int,int);\n int main()\n {\n int a=5, b=10, mysum;\n mysum = sum(a,b);\n printf(\"sum=%d \", mysum);\n printf(\"sum=%d\", sum(10,20));\n return 0;\n }\n int sum(int i, int j)\n {\n return (i+j);\n }\n"); strcpy(units[4].answers[33],"sum=15 sum=30"); strcpy(units[4].questions[34],"What is the output of C program with functions.?\n int main()\n {\n printf(\"funny=%d\" , funny());\n return 0;\n }\n funny()\n {\n }\n"); strcpy(units[4].answers[34],"funny=0"); strcpy(units[4].questions[35],"What is the output of C Program with functions.?\n void funny2();\n int main()\n {\n printf(\"funny2=%d\" , funny2());\n return 0;\n }\n void funny2()\n {\n }\n"); strcpy(units[4].answers[35],"compiler error"); strcpy(units[4].questions[36],"What is the output of C Program with functions.?\n int bunny(int,int);\n int main()\n {\n int a, b;\n a = bunny(5, 10);\n b = bunny(10, 5);\n printf(\"%d %d\", a, b);\n return 0;\n }\n int bunny(int i, int j)\n {\n return (i, j);\n }\n"); strcpy(units[4].answers[36],"10 5"); strcpy(units[4].questions[37],"What is the output of a C Program with functions and pointers.?\n void texas(int *,int *);\n int main()\n {\n int a=11, b=22;\n printf(\"before=%d %d, \", a, b);\n texas(&a, &b);\n printf(\"after=%d %d\", a, b);\n return 0;\n }\n void texas(int *i, int *j)\n {\n *i = 55;\n *j = 65;\n }\n"); strcpy(units[4].answers[37],"before=11 22, after=55 65"); strcpy(units[4].questions[38],"What is the output of a C Program.?\n void show(int,int,int);\n int main()\n {\n int a = 1;\n show(++a, a++, a);\n return 0;\n }\n void show(int i, int j, int k)\n {\n printf(\"%d %d %d,\", i, j, k);\n }\n"); strcpy(units[4].answers[38],"3 1 3, "); strcpy(units[4].questions[39],"What is the output of C Program with pointers.?\n int main()\n {\n int a = 4;\n int *p;\n p=&a;\n while(*p > 0)\n {\n printf(\"%d \", *p);\n (*p)--;\n }\n return 0;\n }\n"); strcpy(units[4].answers[39],"4 3 2 1"); strcpy(units[4].questions[40],"What is the output of C Program with functions.?\n void show();\n int show();\n int main()\n {\n printf(\"ANT\");\n return 0;\n }\n void show()\n {\n printf(\"Integer\") ;\n }\n int show()\n {\n printf(\"Void\");\n }\n"); strcpy(units[4].answers[40],"compiler error"); //------------------QUESTIONS FROM UNIT 5--------------------------------// //-----------------------TRUE OF FALSE----------------------------// strcpy(units[5].questions[1],"A struct type in C is a built-in data type"); strcpy(units[5].answers[1],"false"); strcpy(units[5].questions[2],"The tag name of a structure is optional"); strcpy(units[5].answers[2],"false"); strcpy(units[5].questions[3],"Structures may contain members of only one data type"); strcpy(units[5].answers[3],"true"); strcpy(units[5].questions[4],"A structure variable is used to declare a data type containing multiple fields"); strcpy(units[5].answers[4],"true"); strcpy(units[5].questions[5],"Pointers can be used to access the members of structure variables"); strcpy(units[5].answers[5],"true"); strcpy(units[5].questions[6],"The keyword typedef is used to define a new data type"); strcpy(units[5].answers[6],"true"); strcpy(units[5].questions[7],"A union may be initialized in the same way a structure is initialized"); strcpy(units[5].answers[7],"false"); strcpy(units[5].questions[8],"A union an have another union as one of the members"); strcpy(units[5].answers[8],"true"); strcpy(units[5].questions[9],"A structure cannot have a union as one of its members"); strcpy(units[5].answers[9],"false"); strcpy(units[5].questions[10],"An array cannot be used as a member of a structure"); strcpy(units[5].answers[10],"false"); // -----------------------CHOOSE THE CORRECT OPTION QUESTIONS---------------------// strcpy(units[5].questions[11],"What are the types of data allowed inside a structure.?\n A) int, float, double, long double\n B) char, enum, union\n C) pointers and Same structure type members\n D) All the above\n"); strcpy(units[5].answers[11],"d"); strcpy(units[5].questions[12],"Choose a correct statement about structure and array.?\n A) An array stores only elements of same type. Accessing elements is easy.\n B) A structure is preferred when different type elements are to be combined as a single entity.\n C) An array implementation has performance improvements to structure\n D) All the above\n"); strcpy(units[5].answers[12],"d"); strcpy(units[5].questions[13],"Choose a correct statement about C structures.\n A) A structure enables display of folder structure in OS.\n B) A structure enables erasing contents in a folder in OS.\n C) A structure enables to detect and respond to mouse clicks.\n D) All the above\n"); strcpy(units[5].answers[13],"d"); strcpy(units[5].questions[14],"What is actually passed if you pass a structure variable to a function.?\n A) Copy of structure variable\n B) Reference of structure variable\n C) Starting address of structure variable\n D) Ending address of structure variable\n"); strcpy(units[5].answers[14],"a"); strcpy(units[5].questions[15],"In a nested structure definition, with country.state.district statement, memeber state is actually present in the structure.? (COUNTY, STATE, DISTRICT structures)\n A) district\n B) state\n C) country\n D) None of the above\n"); strcpy(units[5].answers[15],"c"); strcpy(units[5].questions[16],"What is a structure in C language.?\n A) A structure is a collection of elements that can be of same data type.\n B) A structure is a collection of elements that can be of different data type.\n C) Elements of a structure are called members.\n D) All the above\n"); strcpy(units[5].answers[16],"d"); strcpy(units[5].questions[17],"What is the size of a C structure.?\n A) C structure is always 128 bytes.\n B) Size of C structure is the total bytes of all elements of structure.\n C) Size of C structure is the size of largest element.\n D) None of the above\n"); strcpy(units[5].answers[17],"b"); strcpy(units[5].questions[18],"Choose a correct statement about C structure.?\n int main()\n {\n struct ship\n {\n };\n return 0;\n }\n A) It is wrong to define an empty structure\nB) Member variables can be added to a structure even after its first definition.\n C) There is no use of defining an empty structure\n D) None of the above\n"); strcpy(units[5].answers[18],"c"); strcpy(units[5].questions[19],"A C Structure or User defined data type is also called.?\n A) Derived data type\n B) Secondary data type\n C) Aggregate data type\n D) All the above\n"); strcpy(units[5].answers[19],"d"); strcpy(units[5].questions[20],"Choose a correct statement about C structures.\n A) A structure can contain same structure type member.\n B) A structure size is limited by only physical memory of that PC.\n C) You can define an unlimited number of members inside a structure.\n D) All the above.\n"); strcpy(units[5].answers[20],"d"); //------FILL IN THE BLANKS QUESTION-------------------------// strcpy(units[5].questions[21]," A structure size is limited by only ________ of the PC."); strcpy(units[5].answers[21],"physical memory"); strcpy(units[5].questions[22],"We can define an _______ number of members inside a structure."); strcpy(units[5].answers[22],"unlimited"); strcpy(units[5].questions[23],"________ is used to implement Linked Lists, Stack and Queue data structures"); strcpy(units[5].answers[23],"structure"); strcpy(units[5].questions[24],"________ are used in Operating System functionality like Display and Input taking."); strcpy(units[5].answers[24],"structures"); strcpy(units[5].questions[25],"structure elements are stored in _______ memory locations"); strcpy(units[5].answers[25],"contiguous"); strcpy(units[5].questions[26],"Structure members can not be initialized at the time of _______"); strcpy(units[5].answers[26],"declaration"); strcpy(units[5].questions[27],"Elements of a structure are called ________."); strcpy(units[5].answers[27],"members"); strcpy(units[5].questions[28],"A ________ enables display of folder structure in OS."); strcpy(units[5].answers[28],"structure"); strcpy(units[5].questions[29],"A _______ is preferred when different type elements are to be combined as a single entity."); strcpy(units[5].answers[29],"structure"); strcpy(units[5].questions[30],"An ____ implementation has performance improvements to structure"); strcpy(units[5].answers[30],"array"); //-------------------------ERROR FINDING/OUTPUT-------------------// strcpy(units[5].questions[31],"What is the output of C program with structures.?\n int main()\n {\n structure hotel\n {\n int items;\n char name[10];\n }a;\n strcpy(a.name, \"TAJ\");\n a.items=10;\n printf(\"%s\", a.name);\n return 0;\n }\n"); strcpy(units[5].answers[31],"compiler error"); strcpy(units[5].questions[32],"What is the output of C program.?\n int main()\n {\n struct book\n {\n int pages;\n char name[10];\n }a;\n a.pages=10;\n strcpy(a.name,\"Cbasics\");\n printf(\"%s=%d\", a.name,a.pages);\n return 0;\n }\n"); strcpy(units[5].answers[32],"Cbasics=10"); strcpy(units[5].questions[33],"What is the output of C program.?\n int main()\n {\n struct ship\n {\n int size;\n char color[10];\n }boat1, boat2;\n boat1.size=10;\n boat2 = boat1;\n printf(\"boat2=%d\",boat2.size);\n return 0;\n }\n"); strcpy(units[5].answers[33],"boat2=10"); strcpy(units[5].questions[34],"What is the output of C program with structures.?\n int main()\n {\n struct ship\n {\n char color[10];\n }boat1, boat2;\n strcpy(boat1.color,\"red\");\n printf(\"%s \",boat1.color);\n boat2 = boat1;\n strcpy(boat2.color,\"yellow\");\n printf(\"%s\",boat1.color);\n return 0;\n }\n"); strcpy(units[5].answers[34],"red red"); strcpy(units[5].questions[35],"What is the output of C program with structures.?\n int main()\n {\n struct tree\n {\n int h;\n }\n struct tree tree1;\n tree1.h=10;\n printf(\"height=%d\",tree1.h);\n return 0;\n }\n"); strcpy(units[5].answers[35],"height=10"); strcpy(units[5].questions[36],"What is the output of C program with structures.?\n int main()\n {\n struct tree\n {\n int h;\n int w;\n };\n struct tree tree1={10};\n printf(\"%d \",tree1.w);\n printf(\"%d\",tree1.h);\n return 0;\n }\n"); strcpy(units[5].answers[36],"0 10"); strcpy(units[5].questions[37],"What is the output of C program with structures.?\n int main()\n {\n struct tree\n {\n int h;\n int rate;\n };\n struct tree tree1={0};\n printf(\"%d \",tree1.rate);\n printf(\"%d\",tree1.h);\n return 0;\n }\n"); strcpy(units[5].answers[37],"0 0"); strcpy(units[5].questions[38],"What is the output of C program.?\n int main()\n {\n struct laptop\n {\n int cost;\n char brand[10];\n };\n struct laptop L1={5000,\"acer\"};\n struct laptop L2={6000,\"ibm\"};\n printf(\"Name=%s\",L1.brand);\n return 0;\n }\n"); strcpy(units[5].answers[38],"acer"); strcpy(units[5].questions[39],"What is the output of C program with structures pointers.?\n int main()\n {\n struct forest\n {\n int trees;\n int animals;\n }F1,*F2;\n F1.trees=1000;\n F1.animals=20;\n F2=&F1;\n printf(\"%d \",F2.animals);\n return 0;\n }\n"); strcpy(units[5].answers[39],"compiler error"); strcpy(units[5].questions[40],"What is the output of C program with structure arrays.?\n int main()\n {\n struct pens\n {\n int color;\n }p1[2];\n struct pens p2[3];\n p1[0].color=5;\n p1[1].color=9;\n printf(\"%d \",p1[0].color);\n printf(\"%d\",p1[1].color);\n return 0;\n }\n"); strcpy(units[5].answers[40],"5 9"); //------------------------END OF STORAGE PART--------------------------------// int loop_key,unit_selected[4]={0,0,0,0},quiz_attempt_number=1,unit,menu_option,unit_entered_checker=0,quiz_attempt_finished_checker=0,marks_and_review_opener=0; float total; char password[20],name[40]; FILE *filePointer ; int system ( const char * command ); printf("\n----------------------------------------------------------------------------------------\n"); printf("\n WELCOME \n"); printf(" TO\n THE "); printf("\n ******\n\n * *\n\n* *\n\n*\n\n*\n\n*\n\n*\n\n* *\n\n * *\n\n *****"); printf("\n QUIZ "); printf("\n GAME "); printf("\n---------------------------------------------------------------------------------------\n"); printf("ENTER YOUR NAME: "); gets(name); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); //-------MAIN MENU---------------------// mainmenu: { system("cls"); printf("WELCOME, %s",name); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nMAIN MENU\n"); printf("\nWhat would you like to do\n"); printf("\nPRESS 0 TO SELECT INSTRUCTIONS\n"); printf("\nPRESS 1 TO SELECT UNITS\n"); printf("\nPRESS 2 TO ATTEMPT QUIZ\n"); printf("\nPRESS 3 TO VERIFY MARKS\n"); printf("\nPRESS 4 TO SEE THE REVIEW\n"); printf("\nPRESS 5 FOR MARKS CORRECTION ((FOR HOST ONLY))\n"); printf("\nPRESS 6 TO QUIT\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); if(unit_entered_checker==1) { printf("\nYour Status\n"); printf("\nYou have selected the units %d,%d&%d\n",unit_selected[1],unit_selected[2],unit_selected[3]); } if(marks_and_review_opener==1&&quiz_attempt_finished_checker==0) { printf("\nYou have finished %d quizzes",quiz_attempt_number-1); } else if(quiz_attempt_finished_checker==1){ printf("\nYou have finished your quiz attempts\n"); printf("\nIf You have no corrections to make you can Press 6 QUIT\n"); } printf("\n--------------------------------------------------------------------------------------------------------------\n"); scanf("%d",&menu_option); while(isalnum(menu_option!=0)) { printf("Please enter a proper input\n"); scanf("%d",&menu_option); } } //-------------------MAIN MENU OPTIONS TO GO TO EACH CASE USING SWITCH CASE-------------// switch(menu_option) { case 0: { goto instructions; } case 1: { if(unit_entered_checker==1) { printf("\nYOU HAVE ALREADY ENTERED THE UNITS\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } else { goto unitchecker; } } case 2: { if (quiz_attempt_finished_checker==1) { printf("\nYOU HAVE ALLREADY FINISHED THE QUIZ ATTEMPTS\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } else if(unit_entered_checker==0) { printf("\nENTER THE UNITS FIRST\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } { goto quiz; } } case 3: { if(marks_and_review_opener!=1) { printf("\nATTEMPT QUIZ FIRST\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } else { goto score; } } case 4: { if(marks_and_review_opener!=1) { printf("\nATTEMPT QUIZ FIRST\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } else { goto review; } } case 5: { if (marks_and_review_opener!=1) { printf("\nATTEMPT QUIZ FIRST\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } else { goto markschanger; } } case 6: { goto quit; } default: { printf("\nYou have entered an invalid input\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } } //--------------------INSTRUCTIONS---------------------------------// instructions: { system("cls"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nINSTRUCTIONS FOR THE QUIZ"); printf("\n1. The Quiz is for 5 units 1 to 5\n"); printf("\n2. The User is supposed to select any 3 units out of 5\n"); printf("\nThe Units are\nUnit 1-Basics of C\nUnit 2-Conditions and Loops\nUnit 3-Strings and Functions\nUnit 4-Pointers and Recursion\nUnit 5-Structures and Unions\n"); printf("\n3. 3 Quizzes will be conducted of 1 unit each based on the choice of the user\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); system("cls"); printf("\nn"); printf("\n4. Each Quiz of 10 marks and have 4 parts\n"); printf("a. PART 1-Fill in the blanks--contains 3 questions and has a time of 3 minutes.\nThe user must answer 'true' or 'false'\n"); printf("b. PART 2-Choose the correct options--contains 3 questions and has a time of 3 minutes.\nThe user must answer 'a','b','c' or 'd'\n"); printf("c. PART 3-Fill in the blanks--contains 2 questions and has a time of 2 minutes.\nThe user must type the correct answer\n"); printf("d. PART 4-Correcting the error/Finding the output--contains 2 questions and has a time of 2 minutes.\nThe user must type the correct answer(type 'compiler error' if there is any error in the code\n"); printf("Note:-\ni. Please write the answer in the format given above\nii. User can answer in both capital and small letter but small letter is preffered\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); system("cls"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\n5. User can check their marks and reviews\n"); printf("\n6. If any kind of correction is required please contact host for marks correction and finalisation\n"); printf("\n7.The 3 quizzes scores will be averaged and displayed\n"); printf("\nWe hope you have a great quiz attempt\nBEST OF LUCK!!!!!\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } //------------------------ENTERING THE UNITS--------------------------// unitchecker: system("cls"); unit_selection_checker[1]=0;unit_selection_checker[2]=0;unit_selection_checker[3]=0;unit_selection_checker[4]=0;unit_selection_checker[5]=0; { printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nWhich three units you would like the quiz of\n"); for(unit=1;unit<4;unit++) { scanf("%d",&unit_selected[unit]); unit_selection_checker[unit_selected[unit]]=1; } for(unit=1;unit<4;unit++) { if(unit_selected[unit]>5||unit_selected[unit]<1) { printf("\nYou have enterend invalid input please select from 1-5\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto unitchecker; } } if(unit_selected[1]==unit_selected[2]||unit_selected[2]==unit_selected[3]||unit_selected[3]==unit_selected[1]) { printf("\nYou have entered a unit more than once please try again\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto unitchecker; } printf("\nYou have successfully entered the units\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); unit_entered_checker=1; goto mainmenu; } //-------------------------MAIN QUIZ------------------------// quiz : system("cls"); { if(quiz_attempt_finished_checker==1) { printf("You have completed the quiz attempt"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } while(quiz_attempt_number<4) { time_start=time(NULL); srand(time(0)); question_number=1; seconds_passed=0; printf("\nYou are attempting quiz from unit %d\n",unit_selected[quiz_attempt_number]); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPART 1-TRUE OR FALSE\n"); seconds_passed=0; while(question_number<4) { quizattempt(unit_selected[quiz_attempt_number],1,120); } printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); system("cls"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPART 2-CHOOSE THE CORRECT OPTION\n"); time_start=time(NULL); seconds_passed=0; while(question_number<7) { quizattempt(unit_selected[quiz_attempt_number],11,180); } printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); system("cls"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPART 3-FILL IN THE BLANKS\n"); time_start=time(NULL); seconds_passed=0; while(question_number<9) { quizattempt(unit_selected[quiz_attempt_number],21,120); } printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); system("cls"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPART 4-CORRECTING THE ERROR OR SHOWING THE OUTPUT QUESTIONS\n"); time_start=time(NULL); seconds_passed=0; while(question_number<11) { quizattempt(unit_selected[quiz_attempt_number],31,120); } unit_selection_checker[unit_selected[quiz_attempt_number]]=2; printf("\n--------------------------------------------------------------------------------------------------------------\n"); marks_and_review_opener=1; quiz_attempt_number++; break; } if(quiz_attempt_number==4) { quiz_attempt_finished_checker=1; } printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); system("cls"); goto mainmenu; } //----------------------SCORE------------------------------// score: system("cls"); { loop_key=1; while(loop_key==1) { printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nWhich units would you like to see the marks of\n"); printf("\nPRESS 6 TO SEE YOUR FINAL MARKS\n"); printf("\nPRESS 0 TO GOTO MAINMENU\n"); scanf("%d",&unit); if(unit==6 && quiz_attempt_finished_checker==1) { goto total_marks; } if(unit==6 && quiz_attempt_finished_checker!=1) { printf("Please finish your attempt first"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto score; } if(unit==0) { goto mainmenu; } if(unit_selection_checker[unit]==0) { printf("\nYou have not selected this unit for the quiz\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto score; } if(unit_selection_checker[unit]==1) { printf("\nYou have not attempted the quiz. TRY again after attempting\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto score; } else { attemptcheck(unit); } printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto score; } printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); total_marks: { if(quiz_attempt_finished_checker==1) { printf("\n--------------------------------------------------------------------------------------------------------------\n"); total=(marks[1]+marks[2]+marks[3]+marks[4]+marks[5])/3.0; printf("\nYour Final score is %.2f\n",total); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); } } goto mainmenu; } //-------------------REVIEWING THE ANSWERS-----------------------------// review: system("cls"); { loop_key=1; while(loop_key==1) { printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("Which unit would you like the review of\n"); printf(" \n0 TO GOTO MAINMENU\n"); scanf("%d",&unit); if(unit==0) { goto mainmenu; } if(unit_selection_checker[unit]==0) { printf("\nYou have not selected this unit for the quiz\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto review; } if(unit_selection_checker[unit]==1) { printf("\nYou have not attempted the quiz. TRY again after attempting\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto review; } else { reviewcheck(unit); } printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); } printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } //-------------------------MARKS CORRECTOR IN CASE OF MISTAKES---------------------// markschanger: system("cls"); { printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nEnter Password\n"); { scanf("%s",&password); } unit=0;loop_key=1; while(strcmp(password,"<PASSWORD>")!=0) { unit++; printf("\nWRONG PASSWORD!!\n"); printf("\nTRY AGAIN!!!\n"); scanf("%s",&password); if(unit==3) { printf("\nOut of attempts try again from mainmenu\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto mainmenu; } } passwordless: system("cls"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); { while(loop_key==1) { printf("\nWhich units would you like to correct\n"); printf("\nPRESS 0 TO GOTO MAINMENU\n"); scanf("%d",&unit); if(unit==0) { goto mainmenu; } if(unit_selection_checker[unit]==0) { printf("\nYou have not selected this unit for the quiz\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto passwordless; } if(unit_selection_checker[unit]==1) { printf("\nYou have not attempted the quiz. TRY again after attempting\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); goto passwordless; } else { markscorrect(unit); printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nPRESS ANY KEY TO CONTINUE\n"); getch(); } } } goto mainmenu; } //-----------------ENDING-------------------// quit: { FILE *filePointer ; int system ( const char * command ); char grade; printf("\n--------------------------------------------------------------------------------------------------------------\n"); if(quiz_attempt_finished_checker==1) { total=(marks[1]+marks[2]+marks[3]+marks[4]+marks[5])/3.0; if(total>=9) grade='S'; else if(total>=8) grade='A'; else if(total>=7) grade='B'; else if(total>=6) grade='C'; else if(total>=5) grade='D'; else if(total>=4) grade='E'; else grade='F'; filePointer=fopen("Scorecard.txt","w") ; if ( filePointer == NULL ) { printf("-----------------------------------------------------------------------------------------\n"); printf("| SCORECARD |\n"); printf("| Congratulations!! |\n"); printf("| %-40s |\n",name); printf("| Report:- |\n"); printf("| Unit Attempted Score |\n"); printf("|1. Unit-%d %2d |\n",unit_selected[1],marks[unit_selected[1]]); printf("|2. Unit-%d %2d |\n",unit_selected[2],marks[unit_selected[2]]); printf("|3. Unit-%d %2d |\n",unit_selected[3],marks[unit_selected[3]]); printf("|Your final Score is: %-6.2f |\n",total); printf("|Your final GRADE is: %-6.2c |\n",grade); printf("|Thank you for Attempting our quiz |\n"); printf("-----------------------------------------------------------------------------------------"); } else { fprintf(filePointer,"\n-----------------------------------------------------------------------------------------\n"); fprintf(filePointer,"| SCORECARD |\n"); fprintf(filePointer,"| Congratulations!! |\n"); fprintf(filePointer,"| %-40s |\n",name); fprintf(filePointer,"| Report:- |\n"); fprintf(filePointer,"| Unit Attempted Score(Max:10) |\n"); fprintf(filePointer,"|1. Unit-%d %2d |\n",unit_selected[1],marks[unit_selected[1]]); fprintf(filePointer,"|2. Unit-%d %2d |\n",unit_selected[2],marks[unit_selected[2]]); fprintf(filePointer,"|3. Unit-%d %2d |\n",unit_selected[3],marks[unit_selected[3]]); fprintf(filePointer,"|Your final Score is: %6.2f |\n",total); fprintf(filePointer,"|Your final GRADE is: %-6.2c |\n",grade); fprintf(filePointer,"|Thank you for Attempting our quiz |\n"); fprintf(filePointer,"-----------------------------------------------------------------------------------------"); fclose(filePointer); system("notepad Scorecard.txt"); } printf("\n--------------------------------------------------------------------------------------------------------------\n"); } else { printf("\n--------------------------------------------------------------------------------------------------------------\n"); printf("\nIt appears that you have left without finishing your attempt. Please notify to us the reason for this\n"); printf("\n--------------------------------------------------------------------------------------------------------------\n"); } } return 0; }
1.953125
2
src/shogun/kernel/ANOVAKernel.h
srgnuclear/shogun
1
7999339
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Written (W) 2011 <NAME> * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society */ #include <shogun/lib/config.h> #ifndef ANOVAKERNEL_H_ #define ANOVAKERNEL_H_ #include <shogun/lib/common.h> #include <shogun/kernel/DotKernel.h> #include <shogun/features/Features.h> #include <shogun/features/DenseFeatures.h> namespace shogun { class CDistance; /** @brief ANOVA (ANalysis Of VAriances) kernel * * Formally described as * * \f[ * K_d(x,z) = \sum_{1\le i_1<i_2<\dots<i_d\le n} \prod_{j=1}^d x_{i_j} z_{i_j} * \f] * with d(cardinality)=1 by default * this function is computed recusively */ class CANOVAKernel: public CDotKernel { public: /** default constructor */ CANOVAKernel(); /** constructor * @param cache size of cache * @param d kernel parameter cardinality */ CANOVAKernel(int32_t cache, int32_t d); /** constructor * @param l features left-side * @param r features right-side * @param d kernel parameter cardinality * @param cache cache size */ CANOVAKernel( CDenseFeatures<float64_t>* l, CDenseFeatures<float64_t>* r, int32_t d, int32_t cache); virtual ~CANOVAKernel(); /** initialize kernel with features * @param l features left-side * @param r features right-side * @return true if successful */ virtual bool init(CFeatures* l, CFeatures* r); /** * @return kernel type */ virtual EKernelType get_kernel_type() { return K_ANOVA; } /** * @return type of features */ virtual EFeatureType get_feature_type() { return F_DREAL; } /** * @return class of features */ virtual EFeatureClass get_feature_class() { return C_DENSE; } /** * @return name of kernel */ virtual const char* get_name() const { return "ANOVAKernel"; } /** getter for degree parameter * @return kernel parameter cardinality */ inline int32_t get_cardinality() { return this->cardinality; } /** setter for degree parameter * @param value kernel parameter cardinality */ inline void set_cardinality(int32_t value) { this->cardinality = value; } /** compute rec 1 * @param idx_a * @param idx_b * @return rec1 */ float64_t compute_rec1(int32_t idx_a, int32_t idx_b); /** computer rec 2 * @param idx_a * @param idx_b * @return rec2 */ float64_t compute_rec2(int32_t idx_a, int32_t idx_b); /** Casts the given kernel to CANOVAKernel. * @param kernel Kernel to cast. Must be CANOVAKernel. Might be NULL * @return casted CANOVAKernel object, NULL if input was NULL */ static CANOVAKernel* obtain_from_generic(CKernel* kernel); protected: /** * compute kernel for specific feature vectors * corresponding to [idx_a] of left-side and [idx_b] of right-side * @param idx_a left-side index * @param idx_b right-side index * @return kernel value */ virtual float64_t compute(int32_t idx_a, int32_t idx_b); /** register params */ void register_params(); private: float64_t compute_recursive1(float64_t* avec, float64_t* bvec, int32_t len); float64_t compute_recursive2(float64_t* avec, float64_t* bvec, int32_t len); protected: /// degree parameter of kernel int32_t cardinality; }; } #endif /* ANOVAKERNEL_H_ */
1.5
2
Example/GQTool/GQViewController.h
lin-it/GQTool
0
7999347
// // GQViewController.h // GQTool // // Created by lin-it on 10/26/2018. // Copyright (c) 2018 lin-it. All rights reserved. // @import UIKit; @interface GQViewController : UIViewController @end
0.10791
0
tests/validation/fixtures/DepthwiseSeparableConvolutionLayerFixture.h
tklebanoff/ComputeLibrary
18
7999355
/* * Copyright (c) 2017 ARM Limited. * * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE #define ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE #include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" #include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/IAccessor.h" #include "tests/framework/Asserts.h" #include "tests/framework/Fixture.h" #include "tests/validation/Helpers.h" #include "tests/validation/reference/DepthwiseSeparableConvolutionLayer.h" #include <random> namespace arm_compute { namespace test { namespace validation { template <typename TensorType, typename AccessorType, typename FunctionType, typename T> class DepthwiseSeparableConvolutionValidationFixture : public framework::Fixture { public: template <typename...> void setup(TensorShape in_shape, TensorShape depthwise_weights_shape, TensorShape depthwise_biases_shape, TensorShape depthwise_out_shape, TensorShape pointwise_weights_shape, TensorShape pointwise_biases_shape, TensorShape output_shape, PadStrideInfo pad_stride_depthwise_info, PadStrideInfo pad_stride_pointwise_info) { _target = compute_target(in_shape, depthwise_weights_shape, depthwise_biases_shape, depthwise_out_shape, pointwise_weights_shape, pointwise_biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); _reference = compute_reference(in_shape, depthwise_weights_shape, depthwise_biases_shape, depthwise_out_shape, pointwise_weights_shape, pointwise_biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); } protected: template <typename U> void fill(U &&tensor, int i, bool zero_fill = false) { switch(tensor.data_type()) { case DataType::F32: { std::uniform_real_distribution<> distribution((zero_fill) ? 0.f : -1.0f, (zero_fill) ? 0.f : 1.0f); library->fill(tensor, distribution, i); break; } default: library->fill_tensor_uniform(tensor, i); } } TensorType compute_target(const TensorShape &input_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_biases_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, const TensorShape &pointwise_biases_shape, const TensorShape &output_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) { // Create tensors TensorType src = create_tensor<TensorType>(input_shape, DataType::F32); TensorType depthwise_weights = create_tensor<TensorType>(depthwise_weights_shape, DataType::F32); TensorType depthwise_biases = create_tensor<TensorType>(depthwise_biases_shape, DataType::F32); TensorType depthwise_out = create_tensor<TensorType>(depthwise_out_shape, DataType::F32); TensorType pointwise_weights = create_tensor<TensorType>(pointwise_weights_shape, DataType::F32); TensorType pointwise_biases = create_tensor<TensorType>(pointwise_biases_shape, DataType::F32); TensorType dst = create_tensor<TensorType>(output_shape, DataType::F32); // Create Depthwise Separable Convolution Layer configure function FunctionType depthwise_separable_convolution_layer; depthwise_separable_convolution_layer.configure(&src, &depthwise_weights, &depthwise_biases, &depthwise_out, &pointwise_weights, &pointwise_biases, &dst, pad_stride_depthwise_info, pad_stride_pointwise_info); // Allocate tensors src.allocator()->allocate(); depthwise_weights.allocator()->allocate(); depthwise_biases.allocator()->allocate(); depthwise_out.allocator()->allocate(); pointwise_weights.allocator()->allocate(); pointwise_biases.allocator()->allocate(); dst.allocator()->allocate(); ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(!depthwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(!depthwise_biases.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(!depthwise_out.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(!pointwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(!pointwise_biases.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); // Fill tensors fill(AccessorType(src), 0); fill(AccessorType(depthwise_weights), 1); fill(AccessorType(depthwise_biases), 2, true); fill(AccessorType(pointwise_weights), 3); fill(AccessorType(pointwise_biases), 4); // Compute function depthwise_separable_convolution_layer.run(); return dst; } SimpleTensor<T> compute_reference(const TensorShape &in_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_biases_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, const TensorShape &pointwise_biases_shape, const TensorShape &dst_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) { SimpleTensor<T> src(in_shape, DataType::F32); SimpleTensor<T> depthwise_weights(depthwise_weights_shape, DataType::F32); SimpleTensor<T> depthwise_biases(depthwise_biases_shape, DataType::F32); SimpleTensor<T> pointwise_weights(pointwise_weights_shape, DataType::F32); SimpleTensor<T> pointwise_biases(pointwise_biases_shape, DataType::F32); fill(src, 0); fill(depthwise_weights, 1); fill(depthwise_biases, 2, true); fill(pointwise_weights, 3); fill(pointwise_biases, 4); return reference::depthwise_separable_convolution_layer(src, depthwise_weights, depthwise_biases, depthwise_out_shape, pointwise_weights, pointwise_biases, dst_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); } TensorType _target{}; SimpleTensor<T> _reference{}; }; } // namespace validation } // namespace test } // namespace arm_compute #endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE */
1.351563
1
source/include/presence/cs_PresenceDescription.h
lingfennan/bluenet
0
7999363
/* * Author: <NAME> * Copyright: Crownstone (https://crownstone.rocks) * Date: Oct 23, 2019 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed) */ #pragma once #include <logging/cs_Logger.h> #include <cstdint> // this typedef is expected to expand to a full class when implementing // the presence detection. // Current datatype: each bit indicates whether there is some user present // in the room labeled with that bit index. class PresenceStateDescription { private: uint64_t val; public: PresenceStateDescription(uint64_t v = 0) : val(v) {} // operator uint64_t(){return val;} operator uint64_t() const {return val;} friend bool operator== ( const PresenceStateDescription& lhs, const PresenceStateDescription& rhs) { return lhs.val == rhs.val; } // TODO: why templated? template<class T> friend bool operator== ( const PresenceStateDescription& lhs, const T& rhs) { return lhs == PresenceStateDescription(rhs); } // TODO: why templated? template<class T> friend bool operator== ( const T& lhs, const PresenceStateDescription& rhs) { return rhs == lhs; } void setRoom(uint8_t index) { // TODO: is this if even needed? // TODO: use util setBit function. if (index < 64) { val |= 1 << index; } } void clearRoom(uint8_t index) { // TODO: is this if even needed? // TODO: use util setBit function. if (index < 64) { val &= ~(1 << index); } } uint64_t getBitmask() { return val; } void print() { [[maybe_unused]] uint32_t rooms[2] = { static_cast<uint32_t>(val >> 0 ), static_cast<uint32_t>(val >> 32) }; LOGd("PresenceDesc(0x%04x 0x%04x)" , rooms[1], rooms[0]); } };
1.851563
2
test/threadstest.h
pmesnier/openssl
19,127
7999371
/* * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #if defined(_WIN32) # include <windows.h> #endif #include <string.h> #include "testutil.h" #if !defined(OPENSSL_THREADS) || defined(CRYPTO_TDEBUG) typedef unsigned int thread_t; static int run_thread(thread_t *t, void (*f)(void)) { f(); return 1; } static int wait_for_thread(thread_t thread) { return 1; } #elif defined(OPENSSL_SYS_WINDOWS) typedef HANDLE thread_t; static DWORD WINAPI thread_run(LPVOID arg) { void (*f)(void); *(void **) (&f) = arg; f(); return 0; } static int run_thread(thread_t *t, void (*f)(void)) { *t = CreateThread(NULL, 0, thread_run, *(void **) &f, 0, NULL); return *t != NULL; } static int wait_for_thread(thread_t thread) { return WaitForSingleObject(thread, INFINITE) == 0; } #else typedef pthread_t thread_t; static void *thread_run(void *arg) { void (*f)(void); *(void **) (&f) = arg; f(); return NULL; } static int run_thread(thread_t *t, void (*f)(void)) { return pthread_create(t, NULL, thread_run, *(void **) &f) == 0; } static int wait_for_thread(thread_t thread) { return pthread_join(thread, NULL) == 0; } #endif
1.070313
1
pkgs/libs/mesa/src/progs/util/matrix.c
manggoguy/parsec-modified
64
7999379
/* * matrix.c * * Some useful matrix functions. * * <NAME> * 10 Feb 2004 */ #include <stdio.h> #include <stdlib.h> #include <math.h> /** * Pretty-print the given matrix. */ void PrintMatrix(const float p[16]) { printf("[ %6.3f %6.3f %6.3f %6.3f ]\n", p[0], p[4], p[8], p[12]); printf("[ %6.3f %6.3f %6.3f %6.3f ]\n", p[1], p[5], p[9], p[13]); printf("[ %6.3f %6.3f %6.3f %6.3f ]\n", p[2], p[6], p[10], p[14]); printf("[ %6.3f %6.3f %6.3f %6.3f ]\n", p[3], p[7], p[11], p[15]); } /** * Build a glFrustum matrix. */ void Frustum(float left, float right, float bottom, float top, float nearZ, float farZ, float *m) { float x = (2.0F*nearZ) / (right-left); float y = (2.0F*nearZ) / (top-bottom); float a = (right+left) / (right-left); float b = (top+bottom) / (top-bottom); float c = -(farZ+nearZ) / ( farZ-nearZ); float d = -(2.0F*farZ*nearZ) / (farZ-nearZ); #define M(row,col) m[col*4+row] M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F; M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F; M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d; M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F; #undef M } /** * Build a glOrtho marix. */ void Ortho(float left, float right, float bottom, float top, float nearZ, float farZ, float *m) { #define M(row,col) m[col*4+row] M(0,0) = 2.0F / (right-left); M(0,1) = 0.0F; M(0,2) = 0.0F; M(0,3) = -(right+left) / (right-left); M(1,0) = 0.0F; M(1,1) = 2.0F / (top-bottom); M(1,2) = 0.0F; M(1,3) = -(top+bottom) / (top-bottom); M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = -2.0F / (farZ-nearZ); M(2,3) = -(farZ+nearZ) / (farZ-nearZ); M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = 0.0F; M(3,3) = 1.0F; #undef M } /** * Decompose a projection matrix to determine original glFrustum or * glOrtho parameters. */ void DecomposeProjection( const float *m, int *isPerspective, float *leftOut, float *rightOut, float *botOut, float *topOut, float *nearOut, float *farOut) { if (m[15] == 0.0) { /* perspective */ float p[16]; const float x = m[0]; /* 2N / (R-L) */ const float y = m[5]; /* 2N / (T-B) */ const float a = m[8]; /* (R+L) / (R-L) */ const float b = m[9]; /* (T+B) / (T-B) */ const float c = m[10]; /* -(F+N) / (F-N) */ const float d = m[14]; /* -2FN / (F-N) */ /* These equations found with simple algebra, knowing the arithmetic * use to set up a typical perspective projection matrix in OpenGL. */ const float nearZ = -d / (1.0 - c); const float farZ = (c - 1.0) * nearZ / (c + 1.0); const float left = nearZ * (a - 1.0) / x; const float right = 2.0 * nearZ / x + left; const float bottom = nearZ * (b - 1.0) / y; const float top = 2.0 * nearZ / y + bottom; *isPerspective = 1; *leftOut = left; *rightOut = right; *botOut = bottom; *topOut = top; *nearOut = nearZ; *farOut = farZ; } else { /* orthographic */ const float x = m[0]; /* 2 / (R-L) */ const float y = m[5]; /* 2 / (T-B) */ const float z = m[10]; /* -2 / (F-N) */ const float a = m[12]; /* -(R+L) / (R-L) */ const float b = m[13]; /* -(T+B) / (T-B) */ const float c = m[14]; /* -(F+N) / (F-N) */ /* again, simple algebra */ const float right = -(a - 1.0) / x; const float left = right - 2.0 / x; const float top = -(b - 1.0) / y; const float bottom = top - 2.0 / y; const float farZ = (c - 1.0) / z; const float nearZ = farZ + 2.0 / z; *isPerspective = 0; *leftOut = left; *rightOut = right; *botOut = bottom; *topOut = top; *nearOut = nearZ; *farOut = farZ; } } #if 0 /* test harness */ int main(int argc, char *argv[]) { float m[16], p[16]; float l, r, b, t, n, f; int persp; int i; #if 0 l = -.9; r = 1.2; b = -0.5; t = 1.4; n = 30; f = 84; printf(" Frustum(%f, %f, %f, %f, %f, %f\n",l+1, r+1.2, b+.5, t+.3, n, f); Frustum(l+1, r+1.2, b+.5, t+.3, n, f, p); DecomposeProjection(p, &persp, &l, &r, &b, &t, &n, &f); printf("glFrustum(%f, %f, %f, %f, %f, %f)\n", l, r, b, t, n, f); PrintMatrix(p); #else printf("Ortho(-1, 1, -1, 1, 10, 84)\n"); Ortho(-1, 1, -1, 1, 10, 84, m); PrintMatrix(m); DecomposeProjection(m, &persp, &l, &r, &b, &t, &n, &f); printf("Ortho(%f, %f, %f, %f, %f, %f) %d\n", l, r, b, t, n, f, persp); #endif return 0; } #endif
2.546875
3
release/src/router/samba3/source/tests/trivial.c
ghsecuritylab/tomato_egg
640
7999387
main() { exit(0); }
-0.037842
0
Kernel/VM/VirtualAddress.h
JamiKettunen/serenity
3
7999395
#pragma once #include <AK/LogStream.h> #include <AK/Types.h> class VirtualAddress { public: VirtualAddress() {} explicit VirtualAddress(u32 address) : m_address(address) { } bool is_null() const { return m_address == 0; } bool is_page_aligned() const { return (m_address & 0xfff) == 0; } VirtualAddress offset(u32 o) const { return VirtualAddress(m_address + o); } u32 get() const { return m_address; } void set(u32 address) { m_address = address; } void mask(u32 m) { m_address &= m; } bool operator<=(const VirtualAddress& other) const { return m_address <= other.m_address; } bool operator>=(const VirtualAddress& other) const { return m_address >= other.m_address; } bool operator>(const VirtualAddress& other) const { return m_address > other.m_address; } bool operator<(const VirtualAddress& other) const { return m_address < other.m_address; } bool operator==(const VirtualAddress& other) const { return m_address == other.m_address; } bool operator!=(const VirtualAddress& other) const { return m_address != other.m_address; } u8* as_ptr() { return reinterpret_cast<u8*>(m_address); } const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); } VirtualAddress page_base() const { return VirtualAddress(m_address & 0xfffff000); } private: u32 m_address { 0 }; }; inline VirtualAddress operator-(const VirtualAddress& a, const VirtualAddress& b) { return VirtualAddress(a.get() - b.get()); } inline const LogStream& operator<<(const LogStream& stream, VirtualAddress value) { return stream << 'V' << value.as_ptr(); }
1.15625
1
xarm_api/include/xarm_driver.h
stevewen/xarm_ros
0
7999403
#ifndef __XARM_DRIVER_H #define __XARM_DRIVER_H #include "ros/ros.h" #include <xarm_msgs/SetInt16.h> #include <xarm_msgs/TCPOffset.h> #include <xarm_msgs/SetAxis.h> #include <xarm_msgs/Move.h> #include <xarm_msgs/RobotMsg.h> #include <sensor_msgs/JointState.h> #include <xarm/common/data_type.h> #include <xarm/linux/thread.h> #include "xarm/connect.h" #include "xarm/report_data.h" namespace xarm_api { class XARMDriver { public: XARMDriver():spinner(4){spinner.start();}; ~XARMDriver(); void XARMDriverInit(ros::NodeHandle& root_nh, char *server_ip); bool MotionCtrlCB(xarm_msgs::SetAxis::Request &req, xarm_msgs::SetAxis::Response &res); bool SetModeCB(xarm_msgs::SetInt16::Request& req, xarm_msgs::SetInt16::Response& res); bool SetStateCB(xarm_msgs::SetInt16::Request &req, xarm_msgs::SetInt16::Response &res); bool SetTCPOffsetCB(xarm_msgs::TCPOffset::Request &req, xarm_msgs::TCPOffset::Response &res); bool GoHomeCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res); bool MoveJointCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res); bool MoveLinebCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res); bool MoveLineCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res); bool MoveServoJCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res); void pub_robot_msg(xarm_msgs::RobotMsg rm_msg); void pub_joint_state(sensor_msgs::JointState js_msg); int get_frame(void); int get_rich_data(ReportDataNorm &norm_data); private: SocketPort *arm_report_; ReportDataNorm norm_data_; UxbusCmd *arm_cmd_; unsigned char rx_data_[1280]; std::string ip; pthread_t thread_id_; ros::AsyncSpinner spinner; ros::NodeHandle nh_; ros::ServiceServer go_home_server_; ros::ServiceServer move_joint_server_; ros::ServiceServer motion_ctrl_server_; ros::ServiceServer set_state_server_; ros::ServiceServer set_mode_server_; ros::ServiceServer move_lineb_server_; ros::ServiceServer move_line_server_; ros::ServiceServer move_servoj_server_; ros::ServiceServer set_tcp_offset_server_; ros::Publisher joint_state_; ros::Publisher robot_rt_state_; }; } #endif
1.375
1
ubserver/com/soy/timer/TimeRunning.h
mikestrange/ubserver
0
7999411
// // TimeRunning.h // ubserver // // Created by MikeRiy on 16/12/13. // Copyright © 2016年 MikeRiy. All rights reserved. // #ifndef TimeRunning_h #define TimeRunning_h #include "lock.h" #include "array.h" #include "hashmap.h" #include "TimePush.h" #include "TimeEvent.h" class TimeEvent; class TimePush; class TimeRunning : private Locked, private Thread, public IEventHandler { STATIC_CLASS(TimeRunning); public: TimeRunning(); private: int currentTimeid; HashMap<int, TimeEvent*> m_table; int CreateTimer(TimePush* target, TIME_T delay = 0, int type = 0); void _StopTime(int tid); void _DelTime(int tid); TIME_T GetCompleteTimers(std::vector<TimeEvent*>& timers); friend class TimePush; int AddTimer(TimePush* target, TIME_T delay = 0, int type = 0); void StopTimer(int timeid); public: void OnEvent(EventBase* event)override; void run()override; }; #endif /* TimeRunning_h */
1.734375
2
MyOpenGL/MyOpenGL/Engine/MyObjectMesh.h
wangluo2028/MyOpenGL
0
7999419
#pragma once #include "MyShaderProgram.h" #include "Math/ProcMeshSection.h" class UMyObjectMesh { public: UMyObjectMesh(); ~UMyObjectMesh(); void CreateMeshSection(unsigned int Index, const std::vector<float> &InVertices, const std::vector<float> &InVertexColors, const std::vector<float> &InUVs, const std::vector<unsigned int> &InIndices); void SetupShaderProgram(class UMaterial *InShaderProgram); void SetTransform(const glm::mat4 &InTransform); void GenRenderBuffer(); void Render(); bool IsLight(); protected: virtual void BeginPlay(); protected: std::vector<FProcMeshSection> ProcMeshSections; unsigned int VAO; // vertex array object unsigned int VBO; // vertex buffer object unsigned int EBO; // element buffer object class UMaterial *MyShaderProgram; glm::mat4 Transform2World; };
1.132813
1
poreinfo.h
by-student-2017/Zeoplus2_v0.3
4
7999427
/** * In poreinfo.* files, there are functions to perform time-series analysis for * void space data contain in a set of .poreinfo summary files * * Initial code by <NAME>, June 2013 * **/ #ifndef POREINFO_H #define POREINFO_H #include <cstdio> #include <string> #include "general.h" #include "geometry.h" #include "networkstorage.h" /* POREINFO class is used to store and analyze pore information from time-series data */ class POREINFO { public: int dim; // dimentionality of pore double di; // largest inclluded sphere double sa, vol; // surface area and volume Point pos; // pore position, coordinates of Di double enc_radius; // radius of encapsulating sphere std::vector <NODESPHERE> nodes; std::vector <int> prevIDs; // IDs of corresponding pores in previous and next time steps std::vector <int> nextIDs; POREINFO() { dim = 0; nodes.clear(); prevIDs.clear(); nextIDs.clear(); }; }; /* Function that performs analysis for a set of .poreinfo files listed in listfilename. * Output is written to outputfilename. Atom_network has to be provided to enable distance calculations */ void analyzePoreInfoFiles(ATOM_NETWORK *atmnet, std::string listfilename, std::string outputfilename); /* Loads .poreinfo files into POREINFO vector */ void loadPoreInfoFile(std::vector < std::vector<POREINFO> > *, std::string); /* Function checks if two pores ar connected because of overlap of nodes */ bool arePoresConnected(POREINFO *, POREINFO *); #endif
2.421875
2
Lab3/Ex4/Help/tcp_serverEx2.c
DFTF-PConsole/IRC-Labs-Sockets-LEI-2019
0
7999435
/******************************************************************************* * SERVIDOR no porto 9000, à escuta de novos clientes. Quando surjem * novos clientes os dados por eles enviados são lidos e descarregados no ecran. *******************************************************************************/ #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <netdb.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <ctype.h> #define SERVER_PORT 9000 #define BUF_SIZE 1024 void process_client(int fd); void erro(char *msg); int main() { int fd, client; struct sockaddr_in addr, client_addr; int client_addr_size; char print_address[INET_ADDRSTRLEN]; bzero((void *) &addr, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_port = htons(SERVER_PORT); unsigned long addr_ntohl; if ( (fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) erro("na funcao socket"); if ( bind(fd,(struct sockaddr*)&addr,sizeof(addr)) < 0) erro("na funcao bind"); if( listen(fd, 5) < 0) erro("na funcao listen"); addr_ntohl = ntohl(addr.sin_addr.s_addr); inet_ntop(AF_INET, &addr_ntohl, print_address, INET_ADDRSTRLEN); printf("Endereco do Servidor: %s ; Porto: %d \n", print_address, ntohs(addr.sin_port)); client_addr_size = sizeof(client_addr); while (1) { //clean finished child processes, avoiding zombies //must use WNOHANG or would block whenever a child process was working while(waitpid(-1,NULL,WNOHANG)>0); //wait for new connection client = accept(fd,(struct sockaddr *)&client_addr,(socklen_t *)&client_addr_size); if (client > 0) { if (fork() == 0) { close(fd); inet_ntop(AF_INET, &(client_addr.sin_addr.s_addr), print_address, INET_ADDRSTRLEN); printf("\n\n***** Endereco do Cliente: %s ; Porto: %d *****\n\n", print_address, client_addr.sin_port); process_client(client); exit(0); } close(client); } } return 0; } void process_client(int client_fd) { int nread = 0; int n_char; char my_msg[BUF_SIZE-2]; char buffer[BUF_SIZE]; int factor, special_factor = 0; int i, counter, acumula, meu_erro, omg; int array[11]; char temp[11]; double media; while (1) { bzero(my_msg, BUF_SIZE -2); nread = read(client_fd, my_msg, BUF_SIZE-2); my_msg[nread] = '\0'; printf("[CLIENTE] %s \n", my_msg); factor = 0; if (strcmp("DADOS\n", my_msg) == 0) { factor = 1; special_factor = 1; } else { if (strcmp("SOMA\n", my_msg) == 0) { factor = 2; if (special_factor == 0) { bzero(my_msg, BUF_SIZE -2); n_char = sprintf(my_msg, "[SERVIDOR] Erro: Numeros ainda nao recebidos!\n"); write(client_fd, my_msg, 1 + n_char); factor = 0; } } else { if (strcmp("MEDIA\n", my_msg) == 0) { factor = 3; if (special_factor == 0) { bzero(my_msg, BUF_SIZE -2); n_char = sprintf(my_msg, "[SERVIDOR] Erro: Numeros ainda nao recebidos!\n"); write(client_fd, my_msg, 1 + n_char); factor = 0; } } else { bzero(my_msg, BUF_SIZE -2); n_char = sprintf(my_msg, "[SERVIDOR] Erro: Comando nao existe!\n"); write(client_fd, my_msg, 1 + n_char); factor = 0; } } } if (factor == 1) { bzero(my_msg, BUF_SIZE -2); n_char = sprintf(my_msg, "[SERVIDOR] Escreva os 10 numeros separados por espacos simples:\n"); write(client_fd, my_msg, 1 + n_char); bzero(my_msg, BUF_SIZE -2); nread = read(client_fd, my_msg, BUF_SIZE-1); my_msg[nread] = '\0'; printf("[CLIENTE] %s \n", my_msg); omg = 0; meu_erro = 0; for (i = 0, counter = 0; my_msg[i] != '\0'; i++) { n_char = 0; while (isdigit(my_msg[i])) { temp[n_char] = my_msg[i]; n_char++; i++; omg = 1; } if (counter >= 10 && omg == 1) { meu_erro = -1; break; } if (omg == 1) { array[counter] = atoi(temp); //printf(">>> %d\n", array[counter]); counter++; omg = 0; } bzero(temp, 11); } if (meu_erro == -1 || counter != 10) { bzero(my_msg, BUF_SIZE -2); n_char = sprintf(my_msg, "[SERVIDOR] Erro: Quantidade de Numeros Invalidos!\n"); write(client_fd, my_msg, 1 + n_char); factor = 0; special_factor = 0; meu_erro = 0; } else { bzero(my_msg, BUF_SIZE -2); n_char = sprintf(my_msg, "[SERVIDOR] Numeros Recebidos e Validos!\n"); write(client_fd, my_msg, 1 + n_char); } } if (factor == 2) { acumula = 0; for (i=0; i <10 ; i++) { acumula = acumula + array[i]; } bzero(my_msg, BUF_SIZE -2); n_char = sprintf(my_msg, "[SERVIDOR] Soma = %d\n", acumula); write(client_fd, my_msg, 1 + n_char); } if (factor == 3) { acumula = 0; for (i=0; i <10 ; i++) { acumula = acumula + array[i]; } media = acumula / 10; bzero(my_msg, BUF_SIZE -2); n_char = sprintf(my_msg, "[SERVIDOR] Media = %f\n", media); write(client_fd, my_msg, 1 + n_char); } } fflush(stdout); close(client_fd); } void erro(char *msg) { printf("Erro: %s\n", msg); exit(-1); }
1.601563
2
nimbus_source/004_wifi/maradns-1.3.07.09/tcp/zoneserver_en.h
isabella232/wireless-media-drive
10
7999443
#define L_LOG "Log: " #define L_FATAL "Fatal error: " #define L_MLC "Could not create mararc_loc string" #define L_MLL "Coule not set locale for mararc_loc string" #define L_EC "Could not create errors string" #define L_EL "Coule not set locale for errors string" #define L_KSC "Could not create kvar_str string" #define L_KSL "Could not set locale for kvar_str string" #define L_VC "Could not create verbstr string" #define L_VL "Could not set locale for verbstr string" #define L_MC "Could not create maxpstr string" #define L_ML "Could not set locale for maxpstr string" #define L_CC "Could not create chrootn string" #define L_CL "Could not set locale for chrootn string" #define L_KQC "Could not create kvar_query string" #define L_KQL "Could not set locale for kvar_query string" #define L_BAC "Could not create bins_address string" #define L_BAL "Could not set locale for bind_address string" #define L_IC "Could not create incoming string" #define L_IL "Could not set locale for incoming string" #define L_UC "Could not create uncomp string" #define L_UL "Could not set locale for uncomp string" #define L_MW "Error locating mararc file" #define L_GET_MARARC "Could not get mararc from command line" #define L_USAGE "Usage: zoneserver [-f mararc_location]" #define L_PARSE_MARARC "Error parsing contents of mararc file" #define L_PARSE_MARARC_LINE "Error parsing contents of mararc file on line " #define L_ERROR_CODE "Error code: " #define LF "\n" #define L_MAKE_KQ "Could not create kvar_query" #define L_MAXPROCS "Problem getting maxprocs value.\nmaxprocs must be set before starting the MaraDNS server" #define L_MAXPROCS_NUM "Problem converting maxprocs to a number\nThis must be a non-zero number" #define L_SETMAX "Unable to set maximum number of processes" #define L_CHROOT "Problem getting chroot kvar.\nYou must have chroot_dir set if you start this as root" #define L_CHROOT_NT "Problem making chroot nt string.\nMake sure the chroot directory is 200 chars or less" #define L_NO_CHROOT "Problem changing to chroot dir.\nMake sure chroot_dir points to a valid directory" #define L_CHROOT_ERROR "Problem changing the root directory." #define L_CHROOT_SUCCESS "Root directory changed" #define L_BIND_GET "Problem getting chroot kvar.\nYou must have bind_address set to the IP zoneserver will listen on" #define L_BIND "Problem binding to port 53.\nMost likely, another process is already listening on port 53" #define L_SOCKET_SUCCESS "Socket opened on TCP port 53" #define L_NO_UID "Problem getting maradns_uid kvar.\nYou must have maradns_uid set if you start this as root" #define L_UID_INVALID "maradns_uid is less than 10 or not a number.\nThis uid must have a value of 10 or more" #define L_NODROP "Could not drop root uid" #define L_STILL_ROOT "We seem to still be root" #define L_DROP_SUCCESS "Root privileges dropped" #define L_BE_ROOT "Problem binding to port 53.\nYou should run this as root" #define L_NO_ACL "Could not read zone_transfer_acl data" #define L_ACL_INETD "zone_transfer_acl must not be set when running in inetd mode" #define L_ACL_LIST "Could not make ip ACL list\nPlease add tcp_convert_acl with tcp_convert_server and/or zone_transfer_acl\nto mararc file. See mararc man page for details" #define L_WAITING "Awaiting data on port 53" #define L_GOT "Message received, processing" #define L_NO_ZONE_HERE "Zone we do not have asked for, disconnecting" #define L_THISIS "This is MaraDNS' zoneserver version" #define L_RTFM "For usage information, 'man zoneserver'"
0.828125
1
src/os.h
bryanwayb/lnklib
0
7999451
#ifndef __OS_H__ #define __OS_H__ #undef OS_WINDOWS #undef OS_UNIX #undef OS_MAC_OSX #undef OS_LINUX #undef ARCH_X86 #undef ARCH_X64 // OS type #if defined(__APPLE__) || defined(__MACH__) #define OS_MAC_OSX #endif #if defined(__unix__) || defined(__unix) #define OS_UNIX #endif #if defined(_WIN32) || defined(_WIN64) #define OS_WINDOWS #endif #if defined(__linux__) #define OS_LINUX #endif // Architectures #if defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) #define ARCH_X86 #endif #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) #define ARCH_X64 #endif #endif
0.470703
0
usr/libexec/thermalmonitord/tma8fdeb8d5d40a6fc75e76f541ccdfac4.h
zhangkn/iOS14Header
1
7999459
// // Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20). // // Copyright (C) 1997-2019 <NAME>. // #import "tm62a6a44d269463582cca62859fbfb389.h" @interface tma8fdeb8d5d40a6fc75e76f541ccdfac4 : tm62a6a44d269463582cca62859fbfb389 { } - (void)updateCoreAnalyticsInfo; // IMP=0x000000010001fff8 - (void)updateAllThermalLoad:(_Bool)arg1; // IMP=0x000000010001ff34 @end
0.746094
1
iphone/Classes/TiRootViewController.h
kasatani/titanium_mobile
0
7999467
/** * Appcelerator Titanium Mobile * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the Apache Public License * Please see the LICENSE included with this distribution for details. */ #import "TiRootController.h" #import "TiWindowProxy.h" @interface TiRootViewController : UIViewController<UIApplicationDelegate,TiRootController,TiOrientationController> { @private //Presentation: background image and color. UIColor * backgroundColor; UIImage * backgroundImage; //View Controller stack: /* * Due to historical reasons, there are three arrays that track views/ * windows/viewcontrollers that are 'opened' on the rootViewController. * For best results, this should be realigned with a traditional container- * style view controller, perhaps even something proxy-agnostic in the * future. TODO: Refactor viewController arrays. */ NSMutableArray *windowViewControllers; NSMutableArray * viewControllerStack; NSMutableArray * windowProxies; //While no windows are onscreen, present default.png UIImageView * defaultImageView; //Orientation handling: TiOrientationFlags allowedOrientations; UIInterfaceOrientation orientationHistory[4]; // Physical device orientation history UIInterfaceOrientation windowOrientation; // Current emulated orientation BOOL isCurrentlyVisible; //Keyboard handling -- This can probably be done in a better way. BOOL updatingAccessoryView; UIView * enteringAccessoryView; //View that will enter. UIView * accessoryView; //View that is onscreen. UIView * leavingAccessoryView; //View that is leaving the screen. TiViewProxy<TiKeyboardFocusableView> * keyboardFocusedProxy; //View whose becoming key affects things. CGRect startFrame; //Where the keyboard was before the handling CGRect targetedFrame; //The keyboard place relative to where the accessoryView is moving; CGRect endFrame; //Where the keyboard will be after the handling BOOL keyboardVisible; //If false, use enterCurve. If true, use leaveCurve. UIViewAnimationCurve enterCurve; CGFloat enterDuration; UIViewAnimationCurve leaveCurve; CGFloat leaveDuration; } @property(nonatomic,readonly) BOOL keyboardVisible; @property(nonatomic,readonly) UIImageView * defaultImageView; @property(nonatomic,readonly) UIInterfaceOrientation windowOrientation; -(void)dismissDefaultImageView; @property(nonatomic,readwrite,retain) UIColor * backgroundColor; @property(nonatomic,readwrite,retain) UIImage * backgroundImage; -(UIViewController *)focusedViewController; -(void)windowFocused:(UIViewController*)focusedViewController; -(void)windowClosed:(UIViewController *)closedViewController; -(CGRect)resizeView; -(CGRect)resizeViewForStatusBarHidden:(BOOL)statusBarHidden; -(void)repositionSubviews; -(void)refreshOrientationWithDuration:(NSTimeInterval) duration; -(NSTimeInterval)suggestedRotationDuration; -(void)manuallyRotateToOrientation:(UIInterfaceOrientation)newOrientation duration:(NSTimeInterval)duration; -(UIInterfaceOrientation)lastValidOrientation; - (void)openWindow:(TiWindowProxy *)window withObject:(id)args; - (void)closeWindow:(TiWindowProxy *)window withObject:(id)args; @end
1.21875
1
System/Library/PrivateFrameworks/iWorkImport.framework/Frameworks/TSTables.framework/TSTIndexingChunk.h
zhangkn/iOS14Header
1
7999475
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 12:31:32 PM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/PrivateFrameworks/iWorkImport.framework/Frameworks/TSTables.framework/TSTables * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by <NAME>. */ #import <TSTables/TSTables-Structs.h> @interface TSTIndexingChunk : NSObject { UUIDData<TSP::UUIDData> _tableUID; vector<std::__1::vector<NSString *, std::__1::allocator<NSString *> >, std::__1::allocator<std::__1::vector<NSString *, std::__1::allocator<NSString *> > > >* _wordFragmentsList; vector<TSU::UUIDCoord<TSP::UUIDCoord>, std::__1::allocator<TSU::UUIDCoord<TSP::UUIDCoord> > >* _headerCoords; } @property (nonatomic,readonly) UUIDData<TSP::UUIDData> tableUID; //@synthesize tableUID=_tableUID - In the implementation block @property (nonatomic,readonly) unsigned long long size; -(unsigned long long)size; -(UUIDData<TSP::UUIDData>)tableUID; -(id)initWithTableUID:(const UUIDData<TSP::UUIDData>*)arg1 ; -(const vector<std::__1::vector<NSString *, std::__1::allocator<NSString *> >, std::__1::allocator<std::__1::vector<NSString *, std::__1::allocator<NSString *> > > >*)wordFragmentsList; -(const vector<TSU::UUIDCoord<TSP::UUIDCoord>, std::__1::allocator<TSU::UUIDCoord<TSP::UUIDCoord> > >*)headerCoords; -(void)addHeaderWordFragments:(const vector<NSString *, std::__1::allocator<NSString *> >Ref)arg1 atCoord:(const UUIDCoord<TSP::UUIDCoord>*)arg2 ; @end
0.960938
1