MCPcopy Index your code
hub / github.com/RsyncProject/rsync / poptSaveArg

Function poptSaveArg

popt/popt.c:1104–1206  ·  view source on GitHub ↗

* Save the option argument through the (*opt->arg) pointer. * @param con context * @param opt option * @return 0 on success, otherwise POPT_* error. */

Source from the content-addressed store, hash-verified

1102 * @return 0 on success, otherwise POPT_* error.
1103 */
1104static int poptSaveArg(poptContext con, const struct poptOption * opt)
1105{
1106 poptArg arg = { .ptr = opt->arg };
1107 int rc = 0; /* assume success */
1108
1109 switch (poptArgType(opt)) {
1110 case POPT_ARG_BITSET:
1111 /* XXX memory leak, application is responsible for free. */
1112 rc = poptSaveBits(arg.ptr, opt->argInfo, con->os->nextArg);
1113 break;
1114 case POPT_ARG_ARGV:
1115 /* XXX memory leak, application is responsible for free. */
1116 rc = poptSaveString(arg.ptr, opt->argInfo, con->os->nextArg);
1117 break;
1118 case POPT_ARG_STRING:
1119 /* XXX memory leak, application is responsible for free. */
1120 arg.argv[0] = (con->os->nextArg) ? xstrdup(con->os->nextArg) : NULL;
1121 break;
1122
1123 case POPT_ARG_INT:
1124 case POPT_ARG_SHORT:
1125 case POPT_ARG_LONG:
1126 case POPT_ARG_LONGLONG:
1127 { unsigned int argInfo = poptArgInfo(con, opt);
1128 long long aNUM = 0;
1129
1130 if ((rc = poptParseInteger(&aNUM, argInfo, con->os->nextArg)) != 0)
1131 break;
1132
1133 switch (poptArgType(opt)) {
1134 case POPT_ARG_LONGLONG:
1135/* XXX let's not demand C99 compiler flags for <limits.h> quite yet. */
1136#if !defined(LLONG_MAX)
1137# define LLONG_MAX 9223372036854775807LL
1138# define LLONG_MIN (-LLONG_MAX - 1LL)
1139#endif
1140 rc = !(aNUM == LLONG_MIN || aNUM == LLONG_MAX)
1141 ? poptSaveLongLong(arg.longlongp, argInfo, aNUM)
1142 : POPT_ERROR_OVERFLOW;
1143 break;
1144 case POPT_ARG_LONG:
1145 rc = !(aNUM < (long long)LONG_MIN || aNUM > (long long)LONG_MAX)
1146 ? poptSaveLong(arg.longp, argInfo, (long)aNUM)
1147 : POPT_ERROR_OVERFLOW;
1148 break;
1149 case POPT_ARG_INT:
1150 rc = !(aNUM < (long long)INT_MIN || aNUM > (long long)INT_MAX)
1151 ? poptSaveInt(arg.intp, argInfo, (long)aNUM)
1152 : POPT_ERROR_OVERFLOW;
1153 break;
1154 case POPT_ARG_SHORT:
1155 rc = !(aNUM < (long long)SHRT_MIN || aNUM > (long long)SHRT_MAX)
1156 ? poptSaveShort(arg.shortp, argInfo, (long)aNUM)
1157 : POPT_ERROR_OVERFLOW;
1158 break;
1159 }
1160 } break;
1161

Callers 1

poptGetNextOptFunction · 0.85

Calls 8

poptSaveBitsFunction · 0.85
poptSaveStringFunction · 0.85
poptArgInfoFunction · 0.85
poptParseIntegerFunction · 0.85
poptSaveLongLongFunction · 0.85
poptSaveLongFunction · 0.85
poptSaveIntFunction · 0.85
poptSaveShortFunction · 0.85

Tested by

no test coverage detected